Event::Event(Task* parent): Model(parent) { initialize<Event, EventAdaptor>(); setTaskId(parent->id()); connect (this, SIGNAL(timeChanged()), SLOT(updateDuration())); }
void TimerTask::initialize (void* pArg) { UINT32 _pid = fork (); setTaskPID (_pid); assert (_pid >= 0); setTaskId (TaskId::TimerTask); switch (getTaskPID ()) { case 0: /* Child process */ { UINT32 mQIndex = 0; //prctl(PR_SET_NAME, (unsigned long) "TimerTask", 0, 0, 0); setThisTaskName ((const CHAR*) "TimerTask"); cout << "My process name is " << getThisTaskName () << endl; for (mQIndex = 0; mQIndex < MAX_TASKS; mQIndex++) { /** From man mq_open: If O_CREAT is specified in oflag, then two additional arguments must be supplied. The mode argument specifies the permissions to be placed on the new queue, as for open(2). (Symbolic definitions for the permissions bits can be obtained by including <sys/stat.h>.) The permissions settings are masked against the process umask. The attr argument specifies attributes for the queue. See mq_getattr(3) for details. If attr is NULL, then the queue is created with implementation-defined default attributes. */ pMQToTasks [mQIndex] = new PosixMessageQueue (const_cast<CHAR*>(TaskId::getPathNameFromId (static_cast<TaskId::Id>(mQIndex))), O_RDWR, 0, 0, 0, 0 // A number of zero-ed out parameters; these parameters, which // can be accessed using mq_getattr (...) are set by the // PMQ creator, not the PMQ accessor ); } run (pArg); break; } case -1: /* Error */ { assert (0); } default: /* Parent */ { /* Don't wait() here--if you did, then you will never get return in the lexical scope where the TimerTask::initialize() is called. The proper way would be to TimerTask::initialize () and then call wait on the main lexical scope where the TimerTask::initialize () is called. */ cout << "Parent " << getpid () << " will wait for TaskId::TimerTask (PID = " << getTaskPID () << ")" << endl; } } }
void *readTask(FILE *inputFile){ Task *task = createTask(); TaskIdList *list = NULL; int endedTasks=-1, metaSize=-1, taskState=-1, id=-1; char *metadata = NULL; READ_BEGIN(inputFile); list = (TaskIdList *)readTaskIdList(inputFile); setTaskDependsOnMe(task, list); taskIdListDestroy(list); list = (TaskIdList *)readTaskIdList(inputFile); setTaskMyDeps(task, list); taskIdListDestroy(list); hashIntVoidDeserialize(inputFile, task->children); // make the children point to its mother HashIntVoidIterator *it = createHashIntVoidIterator(task->children, 0); PosHandlerIntVoid pos = hashIntVoidIteratorNext(it, task->children); while (pos != NULL) { Task *child = posGetValue(pos); child->mother = task; pos = hashIntVoidIteratorNext(it, task->children); } hashIntVoidIteratorDestroy(it, task->children); READ_NUM("id", id); setTaskId(task, id); READ_NUM("endedTasks", endedTasks); setTaskEndedTasks(task, endedTasks); READ_NUM("metaSize", metaSize); if (metaSize > 0) { metadata = malloc(metaSize); } else { metadata = NULL; } READ_BYTES(inputFile, metadata, metaSize); setTaskMetadata(task, metadata, metaSize); if(metadata != NULL){ free(metadata); } READ_NUM("taskState", taskState); setTaskState(task, taskState); DataSpace* dataSpace = createDataSpace(); readDataSpace(inputFile, dataSpace); setTaskDataSpace(task, dataSpace); READ_END return (void *)task; }
bool LogoMove::start ( UInt16 task_id, UInt8 direction, UInt32 distance_ticks ) throw () { if ( m_is_active || distance_ticks == 0 ) { return false; } m_is_active = true; m_start_angle = m_p_gyro->getLatestReading().ypr[0]; m_start_tick_1 = m_p_encoder_1->getTotal(); m_start_tick_2 = m_p_encoder_2->getTotal(); m_target_distance = distance_ticks; setTaskId( task_id ); _turnMotorsOn( direction ); return true; }
void *readChildTask(FILE *inputFile){ Task *task = createTask(); TaskIdList *list = NULL; int metaSize = 0; char *metadata = NULL; int id = -1; READ_BEGIN(inputFile); list = (TaskIdList *)readTaskIdList(inputFile); setTaskDependsOnMe(task, list); taskIdListDestroy(list); list = (TaskIdList *)readTaskIdList(inputFile); setTaskMyDeps(task, list); taskIdListDestroy(list); READ_NUM("id", id); setTaskId(task, id); assert(id != -1); READ_NUM("metaSize", metaSize); if (metaSize > 0) { metadata = malloc(metaSize); } else { metadata = NULL; } READ_BYTES(inputFile, metadata, metaSize); setTaskMetadata(task, metadata, metaSize); if(metadata != NULL){ free(metadata); } READ_END return (void *)task; }
int handleKey(TDA_Task* task, char** key, char** content) { int out = -1; if (strcmp(*key, "data") == 0) { match(content, "{"); openBrackets++; out = parse(content, key); while (out > -1) { out = handleKey(task, key, content); if (!out) { // out == 0, Stop condition return out; } else if (out < 0) { return out; } else { out = parse(content, key); } } } else if (strcmp(*key, "assignee") == 0) { NamedObject n; out = readNamedObject(content, key, &n); setTaskAssignee(task, &n); } else if (strcmp(*key, "id") == 0) { out = getInt(content, key); setTaskId(task, *key); } else if (strcmp(*key, "name") == 0) { out = getString(content, key); setTaskName(task, *key); } else if (strcmp(*key, "notes") == 0) { out = getString(content, key); setTaskNotes(task, *key); } else if (strcmp(*key, "created_at") == 0) { out = getDate(content, key); setTaskCreationDate(task, *key); } else if (strcmp(*key, "modified_at") == 0) { out = getDate(content, key); setTaskModificationDate(task, *key); } else if (strcmp(*key, "completed_at") == 0) { out = getDate(content, key); setTaskCompletionDate(task, *key); } else if (strcmp(*key, "due_on") == 0) { out = getDate(content, key); setTaskDueDate(task, *key); } else if (strcmp(*key, "completed") == 0) { out = getBool(content, key); if (out > -1) setTaskCompleted(task, (bool) out); out = 2; // Can't return out, because it's 0 on false and 0 is parsing complete } else if (strcmp(*key, "tags") == 0) { out = match(content, "["); while(out > -1 && out != ']') { NamedObject n; out = readNamedObject(content, key, &n); addTaskTag(task, &n); } out = match(content, ","); } else { out = skipField(content); if (out == 0) { return 0; } } return out; }
Note::Note(const QString& id, Task* parent): Model(parent) { initialize<Note, NoteAdaptor>(id); setTaskId(parent->id()); }
Note::Note(Task* parent): Model(parent) { initialize<Note, NoteAdaptor>(); setTaskId(parent->id()); }