Ejemplo n.º 1
0
static bool handleBootTask(int size, const byte *msg, CONTEXT *context)
    {
    TASK *task;
    byte bind = msg[1];
    byte *expr = (byte *) &msg[2];
    byte id = evalWord8Expr(&expr, context);
    byte bootReply[2];
    byte status = 0;

    if ((task = findTask(id)) != NULL)
        {
        unsigned int index = BOOT_TASK_INDEX_START;

        EEPROM[ 0 ] = 'H';
        EEPROM[ 1 ] = 'A';
        EEPROM[ 2 ] = 'S';
        EEPROM[ 3 ] = 'K';
        EEPROM[ 4 ] = task->currLen & 0xFF;
        EEPROM[ 5 ] = task->currLen >> 8;
        EEPROM[ 6 ] = task->context->bindSize & 0xFF;
        EEPROM[ 7 ] = task->context->bindSize >> 8;

        for (unsigned int i=0;i<task->currLen;i++,index++)
            {
            EEPROM[ index ] = task->data[i];
            }

        index = BOOT_TASK_INDEX_START;
        status = 1;
        for (unsigned int i=0;i<task->currLen;i++,index++)
            {
            if (EEPROM[ index ] != task->data[i])
                status = 0;
            }
        }
Ejemplo n.º 2
0
static bool scheduleById(byte id, unsigned long deltaMillis)
    {
    TASK *task;

    if ((task = findTask(id)) != NULL)
        {
        task->millis = millis() + deltaMillis;
        }
    return false;
    }
Ejemplo n.º 3
0
QString SmartNameCache::makeCombined( const Task& task ) const {
    Q_ASSERT( task.isValid() || task.name().isEmpty() ); // an invalid task (id == 0) must not have a name
    if ( !task.isValid() )
        return QString();
    const Task parent = findTask( task.parent() );

    if ( parent.isValid() )
        return QObject::tr( "%1/%2", "parent task name/task name" ).arg( parent.name(), task.name() );
    else
        return task.name();
}
Ejemplo n.º 4
0
static bool handleDeleteTask(int size, const byte *msg, CONTEXT *context)
    {
    byte *expr = (byte *) &msg[1];
    byte id = evalWord8Expr(&expr, context);
    TASK *task;

    if ((task = findTask(id)) != NULL)
        {
        deleteTask(task);
        }
    return false;
    }
Ejemplo n.º 5
0
/*
 * This function is supposed to be called seldom, thus it's ok to not have it
 * as optimized as the other functions, e.g. in terms of inlining
 */
void TraceAnalyzer::handleWrongTaskOnCPU(const TraceEvent &/*event*/,
					 unsigned int cpu,
					 CPU *eventCPU, int oldpid,
					 const vtl::Time &oldtime,
					 int idx)
{
	int epid = eventCPU->pidOnCPU;
	vtl::Time prevtime, faketime;
	double fakeDbl;
	CPUTask *cpuTask;
	Task *task;

	if (epid > 0) {
		cpuTask = &cpuTaskMaps[cpu][epid];
		Q_ASSERT(!cpuTask->isNew);
		Q_ASSERT(!cpuTask->schedTimev.isEmpty());
		prevtime = eventCPU->lastSched;
		faketime = prevtime + FAKE_DELTA;
		fakeDbl = faketime.toDouble();
		cpuTask->schedTimev.append(fakeDbl);
		cpuTask->schedData.append(FLOOR_BIT);
		cpuTask->schedEventIdx.append(eventCPU->lastSchedIdx);

		task = findTask(epid);
		Q_ASSERT(task != nullptr);
		task->lastSleepEntry = faketime;
		task->schedTimev.append(fakeDbl);
		task->schedData.append(FLOOR_BIT);
		task->schedEventIdx.append(eventCPU->lastSchedIdx);
	}

	if (oldpid > 0) {
		cpuTask = &cpuTaskMaps[cpu][oldpid];
		if (cpuTask->isNew) {
			cpuTask->pid = oldpid;
		}
		cpuTask->isNew = false;
		faketime = oldtime - FAKE_DELTA;
		fakeDbl = faketime.toDouble();
		cpuTask->schedTimev.append(fakeDbl);
		cpuTask->schedData.append(SCHED_BIT);
		cpuTask->schedEventIdx.append(idx);

		task = &taskMap[oldpid].getTask();
		if (task->isNew) {
			task->pid = oldpid;
		}
		task->isNew = false;
		task->schedTimev.append(fakeDbl);
		task->schedData.append(SCHED_BIT);
		task->schedEventIdx.append(idx);
	}
}
Ejemplo n.º 6
0
QString JobManager::slotRedoTask(std::list<Task*> lpt)
{
    std::list<Task*>::iterator it;
    for( it = lpt.begin() ; it != lpt.end() ; it++ )
    {
        string JobId;
	    Task* pt = findTask((*(*it)), JobId);
        m_SQLITE_wrapper->insertTask(JobId, pt);
    }
    m_pJobScheduler->pushTasksAndSort(lpt);
	return "Successful";
}
Ejemplo n.º 7
0
QString JobManager::slotChangeTaskState( Task t)
{

#ifdef DEBUG
    //ReturnGenType *r;
    //char* s;
    //int len;
    //s= (char*)t.taskInfo.getRetValue(len);
    //if(len > 0){
    //    printf("=============%d\n", len);
    //    printf("=============%s\n", s);
    //}
    //if(t.pid != -1) printf("pid = %d\n", t.pid);
#endif

    string JobId;
	Task* pt = findTask(t, JobId);
	if( pt != NULL)	{
        if(pt->status != PAUSED){
            (*pt) = t;

            m_SQLITE_wrapper->insertTask(JobId, pt);

            if(t.status == 	FINISHED || t.status == FAILED){
                
				pLogger->writeInfo(QString("Finished TaskId: '%1'.").arg(t.taskId));

				QMutexLocker locker(&m_mutex_MAP_JOBID_LISTTASK);

                MAP_JOBID_LISTTASK[JobId].remove(pt);

				delete pt;
				pt = NULL;

                if(MAP_JOBID_LISTTASK[JobId].size() == 0){
                    MAP_JOBID_LISTTASK.erase(MAP_JOBID_LISTTASK.find(JobId));
                }
            }else{
#ifdef DEBUG
                //m_pJobScheduler->stopTask(pt);
#endif
            }
            return "Successful";
        }else{
            return "Task has been pasued!";
        }
	}else{
        //idebug("%s\n", "Can not find task!");
        return "Can not find task!";
    }
}
Ejemplo n.º 8
0
void TaskManager::windowAdded(WId w )
{
  NETWinInfo info(qt_xdisplay(),  w, qt_xrootwin(),
                  NET::WMWindowType | NET::WMPid | NET::WMState );
  #ifdef KDE_3_2
  NET::WindowType windowType = info.windowType(NET_ALL_TYPES_MASK);
  #else
  NET::WindowType windowType = info.windowType();
  #endif
  // ignore NET::Tool and other special window types
  if (windowType != NET::Normal && windowType != NET::Override
      && windowType != NET::Unknown && windowType != NET::Dialog)
    return;
  // ignore windows that want to be ignored by the taskbar
  if ((info.state() & NET::SkipTaskbar) != 0)
  {
      _skiptaskbar_windows.push_front( w ); // remember them though
    return;
  }

  Window transient_for_tmp;
  if (XGetTransientForHint(qt_xdisplay(), (Window) w, &transient_for_tmp))
  {
    WId transient_for = (WId) transient_for_tmp;

    // check if it's transient for a skiptaskbar window
    if (_skiptaskbar_windows.contains(transient_for))
      return;

    // lets see if this is a transient for an existing task
    if (transient_for != qt_xrootwin() && transient_for != 0 )
    {
      Task* t = findTask(transient_for);
      if (t)
      {
        if (t->window() != w)
        {
          t->addTransient(w);
          // kdDebug() << "TM: Transient " << w << " added for Task: " << t->window() << endl;
        }
        return;
      }
    }
  }
  Task* t = new Task(w, this);
  _tasks.append(t);

  // kdDebug() << "TM: Task added for WId: " << w << endl;
  emit taskAdded(t);
}
Ejemplo n.º 9
0
void TaskManager::windowChanged(WId w, unsigned int dirty)
{
    if( dirty & NET::WMState ) {
        NETWinInfo info ( qt_xdisplay(),  w, qt_xrootwin(), NET::WMState );
        if ( (info.state() & NET::SkipTaskbar) != 0 ) {
            windowRemoved( w );
            _skiptaskbar_windows.push_front( w );
            return;
        }
        else {
            _skiptaskbar_windows.remove( w );
            if( !findTask( w ))
                windowAdded( w ); // skipTaskBar state was removed, so add this window
        }
    }

    // check if any state we are interested in is marked dirty
    if(!(dirty & (NET::WMVisibleName|NET::WMName|NET::WMState|NET::WMIcon|NET::XAWMState|NET::WMDesktop)) )
        return;

    // find task
    Task* t = findTask( w );
    if (!t) return;

    //kdDebug() << "TaskManager::windowChanged " << w << " " << dirty << endl;


    // refresh icon pixmap if necessary
    if (dirty & NET::WMIcon)
        t->refresh(true);
    else
        t->refresh();

    if(dirty & (NET::WMDesktop|NET::WMState|NET::XAWMState))
        emit windowChanged(w); // moved to different desktop or is on all or change in iconification/withdrawnnes
}
Ejemplo n.º 10
0
/* pragmatics analysis */
void
pragmatics(Symbol rule, RealTime delta)
{
    Expr	*x = symValue(rule);
    Task	*t;

    if (x->op != NOP) {
	t = findTask(delta);
	bundle(t, x);
	t->nrules++;
	t->rules = (Symbol *) ralloc(t->rules, t->nrules * sizeof(Symbol));
	t->rules[t->nrules-1] = symCopy(rule);
	perf->eval_expected += (float)1/delta;
    }
}
Ejemplo n.º 11
0
void MainWindow::loadFromIcsFile()
{
    char* line;
    icalcomponent *c;
    icalparser *parser = icalparser_new();

    FILE* stream = fopen("/home/quentin/Public/test.ics", "r");

    icalparser_set_gen_data(parser, stream);

    do
    {
        line = icalparser_get_line(parser, read_stream);
        c = icalparser_add_line(parser, line);

        if (c != 0)
        {
            icalcomponent *inner = icalcomponent_get_first_component(c, ICAL_ANY_COMPONENT);
            while (inner != NULL)
            {
                if (icalcomponent_isa(inner) == ICAL_VTODO_COMPONENT)
                {
                    const char* name   = icalcomponent_get_summary(inner);
                    const char* uid    = icalcomponent_get_uid(inner);
                    icalproperty *p    = icalcomponent_get_first_property(inner, ICAL_RELATEDTO_PROPERTY);
                    const char* parent = icalproperty_get_relatedto(p);
                    addTask(name, uid, parent);
                }
                if (icalcomponent_isa(inner) == ICAL_VEVENT_COMPONENT)
                {
                    const char* name   = icalcomponent_get_summary(inner);
                    const char* uid    = icalcomponent_get_uid(inner);
                    icalproperty *p    = icalcomponent_get_first_property(inner, ICAL_RELATEDTO_PROPERTY);
                    const char* parent = icalproperty_get_relatedto(p);
                    p                  = icalcomponent_get_first_property(inner, ICAL_DTSTART_PROPERTY);
                    icaltimetype start = icalproperty_get_dtstart(p);
                    p                  = icalcomponent_get_first_property(inner, ICAL_DTEND_PROPERTY);
                    icaltimetype end   = icalproperty_get_dtend(p);
                    Task* task         = findTask(parent);
                    addEvent(task, uid, name, start, end);
                }
                inner = icalcomponent_get_next_component(c, ICAL_ANY_COMPONENT);
            }
        }

    } while (line != 0);
}
Ejemplo n.º 12
0
static bool handleAddToTask(int size, const byte *msg, CONTEXT *context)
    {
    byte *expr = (byte *) &msg[1];
    byte id = evalWord8Expr(&expr, context);
    byte addSize = evalWord8Expr(&expr, context);
    const byte *data = expr;
    TASK *task;

    if ((task = findTask(id)) != NULL)
        {
        if (addSize + task->currLen <= task->size)
            {
            memcpy(&task->data[task->currLen], data, addSize);
            task->currLen += addSize;
            }
        }
    return false;
    }
Ejemplo n.º 13
0
void TaskManager::activeWindowChanged(WId w )
{
    //kdDebug() << "TaskManager::activeWindowChanged" << endl;

    Task* t = findTask( w );
    if (!t) {
        if (_active) {
            _active->setActive(false);
            _active = 0;
        }
    }
    else {
        if (_active)
            _active->setActive(false);

        _active = t;
        _active->setActive(true);
    }
}
Ejemplo n.º 14
0
void TaskManager::windowRemoved(WId w )
{
    _skiptaskbar_windows.remove( w );
    // find task
    Task* t = findTask(w);
    if (!t) return;

    if (t->window() == w) {
        _tasks.removeRef(t);

        emit taskRemoved(t);

        if(t == _active) _active = 0;
        delete t;
        //kdDebug() << "TM: Task for WId " << w << " removed." << endl;
    }
    else {
        t->removeTransient( w );
        //kdDebug() << "TM: Transient " << w << " for Task " << t->window() << " removed." << endl;
    }
}
Ejemplo n.º 15
0
void ConsolidateHome::proceed(component::World& world, utils::Team& team)
{
    computeGoals(team);
    if(computeDensity(world, team) < kDensityAim)
    {
        for(auto &blob : team)
        {
            if(blob.busy == true) continue;
            sf::Vector2i loc = findTask(world,
            {component::World::Cell::kNothing, component::World::Cell::kFood},
                                        world.getHome(team.id),
                                        blob.position,
                                        30);
            if(loc.x != -1)
            {
                goals_.push_back(loc);
                blob.job = std::make_shared<utils::BuildBlock>(loc);
                blob.busy = true;
            }
        }
    }
}
Ejemplo n.º 16
0
void SmartNameCache::regenerateSmartNames()
{
    m_smartTaskNamesById.clear();
    typedef QPair<TaskId, TaskId> TaskParentPair;

    QMap<QString, QVector<TaskParentPair> > byName;

    Q_FOREACH( const Task& task, m_tasks )
        byName[makeCombined(task)].append( qMakePair( task.id(), task.parent() ) );

    QSet<QString> cannotMakeUnique;

    while ( !byName.isEmpty() ) {
        QMap<QString, QVector<TaskParentPair> > newByName;
        for ( QMap<QString, QVector<TaskParentPair> >::ConstIterator it = byName.constBegin();
              it != byName.constEnd();
              ++it ) {
            const QString currentName = it.key();
            const QVector<TaskParentPair>& taskPairs = it.value();
            Q_ASSERT( !taskPairs.isEmpty() );
            if ( taskPairs.size() == 1 || cannotMakeUnique.contains( currentName ) ) {
                Q_FOREACH( const TaskParentPair& i, taskPairs )
                    m_smartTaskNamesById.insert( i.first, currentName );
            } else {
                Q_FOREACH( const TaskParentPair& taskPair, taskPairs ) {
                    const Task parent = findTask( taskPair.second );
                    if ( parent.isValid() ) {
                        const QString newName = parent.name() + QLatin1Char('/') + currentName;
                        newByName[newName].append( qMakePair( taskPair.first, parent.parent() ) );
                    } else {
                        QMap<QString, QVector<TaskParentPair> >::const_iterator existing = newByName.constFind( currentName );
                        if ( existing != newByName.constEnd() )
                            cannotMakeUnique.insert( currentName );
                        newByName[currentName].append( taskPair );
                    }
                }
            }
        }
Ejemplo n.º 17
0
static bool createById(byte id, unsigned int taskSize, unsigned int bindSize)
    {
    TASK *newTask;
    CONTEXT *newContext;
    byte *bind;

    if ((findTask(id) == NULL) &&
         ((newTask = (TASK *) malloc(taskSize + sizeof(TASK))) != NULL ))
        {
        if ((newContext = (CONTEXT *) malloc(sizeof(CONTEXT))) == NULL)
            {
            free(newTask);
            }
        else if ((bind = (byte *) calloc(1,bindSize*BIND_SPACING)) == NULL)
            {
            free(newContext);
            free(newTask);
            }
        else
            {
            newTask->next = firstTask;
            newTask->prev = NULL;
            newTask->context = newContext;
            firstTask = newTask;
            newTask->id = id;
            newTask->size = taskSize;
            newTask->currLen = 0;
            newTask->currPos = 0;
            newTask->endData = newTask->data + newTask->size;
            newContext->task = newTask;
            newContext->bindSize = bindSize;
            newContext->bind = bind;
            }
        }
    taskCount++;

    return false;
    }
Ejemplo n.º 18
0
void TaskManager::activeWindowChanged(WId w )
{
    //kdDebug() << "TaskManager::activeWindowChanged" << endl;

    Task* t = findTask( w );
    if (!t) {
        if (_active) {
            _active->setActive(false);
            _active = 0;

            // there is no active window at the moment
            emit activeTaskChanged(0);
        }
    }
    else {
        if (_active)
            _active->setActive(false);

        _active = t;
        _active->setActive(true);

        emit activeTaskChanged(_active);
    }
}
Ejemplo n.º 19
0
static bool handleQuery(int size, const byte *msg, CONTEXT *context)
    {
    byte *expr = (byte *) &msg[2];
    byte id = evalWord8Expr(&expr, context);
    byte queryReply[10];
    uint16_t *sizeReply = (uint16_t *) queryReply;
    uint16_t *lenReply = (uint16_t *) &queryReply[2];
    uint16_t *posReply = (uint16_t *) &queryReply[4];
    uint32_t *millisReply = (uint32_t *) &queryReply[6];
    TASK *task;
    if ((task = findTask(id)) != NULL)
        {
        *sizeReply = task->size;
        *lenReply = task->currLen;
        *posReply = task->currPos;
        *millisReply = task->millis - millis();
        sendReply(sizeof(queryReply), SCHED_RESP_QUERY, queryReply, context, 0);
        }
    else
        {
        sendReply(0, SCHED_RESP_QUERY, queryReply, context, 0);
        }
    return false;
    }
Ejemplo n.º 20
0
ECLParsingResult CCommandLineParser::parse() {
	if(m_parse_result!=Parse_none_found) return(m_parse_result);
	if(m_args.size()<2) return(Parse_none_found);
	
	m_cur_task=NULL;
	SCLTask* task;
	bool bFound;
	
	for(int i=0; i<m_argc; ++i) {
		const string& arg=m_args[i];
		if(arg.length()>1 && arg[0]=='-') {
			if(arg[1]=='-') { //name
				string arg_name=arg.substr(2);
				if((task=findTask(arg_name))) {
					m_cur_task=task;
					task->bGiven=true;
				} else {
					SCLSwitch* s=NULL;
					SCLParam* p=NULL;
					if(m_cur_task) {
						s=m_cur_task->findSwitch(arg_name);
						p=m_cur_task->findParam(arg_name);
					}
					if(!s) s=m_global.findSwitch(arg_name);
					if(!p) p=m_global.findParam(arg_name);
					
					if(s) {
						s->bGiven=true;
						bFound=true;
					} else if(p) {
						p->values.push(m_args[i+1]);
						++i;
					} else {
						return(unknownCommand(arg));
					}
				}
			} else { //short name
				for(size_t k=1; k<arg.length(); ++k) {
					char arg_name=arg[k];
					if((task=findTask(arg_name))) {
						m_cur_task=task;
						task->bGiven=true;
					} else {
						SCLSwitch* s=NULL;
						SCLParam* p=NULL;
						if(m_cur_task) {
							s=m_cur_task->findSwitch(arg_name);
							p=m_cur_task->findParam(arg_name);
						}
						if(!s) s=m_global.findSwitch(arg_name);
						if(!p) p=m_global.findParam(arg_name);
						
						if(s) {
							s->bGiven=true;
							bFound=true;
						} else if(p && k==arg.length()-1) {
							p->values.push(m_args[i+1]);
							++i;
						} else {
							return(unknownCommand(string("")+arg_name));
						}
					}
				}
			}
		} else {
			return(unknownCommand(arg));
		}
	}
	
	m_cur_task=NULL;
	
	return(m_parse_result=Parse_success);
}
Ejemplo n.º 21
0
const SCLTask* CCommandLineParser::setTask(const string& name) {
	m_cur_task=findTask(name);
	if(name.length()>0) ASSERT_THROW_e(m_cur_task, EINVALID_PARAMETER, "Parameter %s not found", name.c_str());
	return(m_cur_task);
}