void PD_UI_Tasklist::addTask(std::string _scenario, int _id, std::string _text){ if(numTasks == 0 && icon->isVisible()){ journalLayout->setVisible(true); } if(tasks.find(_scenario) == tasks.end()){ std::map<int, PD_UI_Task *> m; tasks.insert(std::make_pair(_scenario, m)); } if(tasks.at(_scenario).find(_id) == tasks.at(_scenario).end()){ PD_UI_Task * task = new PD_UI_Task(world, font, textShader); task->setRationalWidth(1.f, taskLayout); task->setHeight(font->getLineHeight() * 3.f); taskLayout->addChild(task); task->text->setText(_text); task->addTimeout->eventManager->addEventListener("start", [this](sweet::Event * _event){ std::stringstream s; s << "journalLayout: " << journalLayout << " taskLayout: " << taskLayout->height.getSize(); Log::info(s.str()); }); tasks.at(_scenario).insert(std::make_pair(_id, task)); task->addTimeout->restart(); incrementCount(1); invalidateLayout(); }else{ Log::warn("Task id for this scenario has already been added!"); } }
/** first 0 - FALSE - call to handel nodes with next priority / order 1 - TRUE (default) - first call for this object */ bool INode::childTopDown(bool first) { #ifdef DEBUGMSG qDebug("# INode::childTopDown (%s) cont_td (this %p) first: %d", (const char *) name(), this, first); qDebug("##(xxx) INode::childTopDown (%s) (this %p) #childcount %d, ordercount %d, aktivorder %d, aktivcount %d, truncation %d", (const char *) name(), this, childcount_,ordercount_,aktivorder_,aktivcount_,truncation()); #endif SNode *el; // hilfspointer if (first) {// first call of 'childTopDown' for this object childList_ = &(sNode_->children()); // liste der subknoten erzeugen childcount_ = childList_->count(); // anzahl aller (noch) zu bearbeitenden knoten aktivorder_=-1; // prioritaet der zu bearbeitenden nodes if (childcount_ == 0) { //no sub nodes aktivcount_ = 0; execBottomUp(); //execState(BU);// BottomUp return 0; } } else { // recursiv call of 'childTopDown' for this object if (aktivcount_ > 0 || ordercount_ > 0 ) return 1; if (childcount_ <= 0) return 0;//all sub nodes are handled if (truncation()) return 0; //all sub nodes are handelt or node is trash } //Praemisse (ordercount_ == 0) && (childcount_ > 0) while (ordercount_ == 0) { aktivorder_ ++; for (el = childList_->first(); el != 0; el = childList_->next()) if(el->order() == aktivorder_) ordercount_++; // anzahl der nodes der aktuellen prioritaet } #ifdef DEBUGMSG qDebug("## INode::childTopDown (%s) (this %p) #childs %d, ordercount %d, aktivorder %d, aktivcount_ %d", (const char *) name(), this, childcount_, ordercount_, aktivorder_,aktivcount_); #endif INode *inode; for (el = childList_->first(); el != 0; el = childList_->next()) { if (truncation()) { //bedingungen nicht mehr erfüllt aktivcount_ = 0; execBottomUp(); //execState(BU);// BottomUp return 0; } if (el->order() == aktivorder_) { incrementCount(); //einer mehr in der queue -> siehe decrementCount() childcount_--; ordercount_--; //aktuelle wird gleich bearbeitet inode = new INode(el); //new INode CHECK_PTR(inode); inode->status(HI); inode->execState(TD); childLink(inode); // remount node in the tree inode->execTopDown(); //start topdown operator //childcount_--; ordercount_--; //aktuelle wird gleich bearbeitet //!MP25.07.2001 inode might be deleted //! analysis_->nodeChange(inode); //info to the rest of the world analysis_->nodeChange(0); } } return 1; }
void Data::setRaw(void * dt, int off, int stride, Type ty){ // increment reference count first to avoid problems when dt == mData incrementCount(pointer(dt)); clear(); mData = pointer(dt); mStride= stride; mType = ty; offset(off); }
MojErr MojDbIsamQuery::getImpl(MojDbStorageItem*& itemOut, bool& foundOut, bool getItem) { itemOut = NULL; MojUInt32 group = 0; MojErr err = getKey(group, foundOut); MojErrCheck(err); if (foundOut && getItem) { err = getVal(itemOut, foundOut); if (err == MojErrInternalIndexOnFind) { #if defined (MOJ_DEBUG) char s[1024]; char *s2 = NULL; MojErr err2 = MojByteArrayToHex(m_keyData, m_keySize, s); MojErrCheck(err2); if (m_keySize > 17) s2 = ((char *)m_keyData) + m_keySize - 17; MojSize idIndex = m_plan->idIndex(); const MojChar * from = m_plan->query().from().data(); MojLogInfo(MojDb::s_log, _T("isamquery_warnindex: from: %s; indexid: %zu; group: %d; KeySize: %zu; %s ;id: %s \n"), from, idIndex, (int)group, m_keySize, s, (s2?s2:"NULL")); #endif } MojErrCheck(err); } if (foundOut) { //If distinct query is, We need to check that field is duplicated or not //In case of duplication, count will not incremented, //and set "itemOut" to NULL for getting next DB result. if(!m_distinct.empty() && itemOut) { bool distincted = false; err = distinct(itemOut, distincted); MojErrCheck(err); if(!distincted) incrementCount(); else itemOut = NULL; } else incrementCount(); } return MojErrNone; }
void PD_UI_Tasklist::removeTask(std::string _scenario, int _id){ if(tasks.find(_scenario) != tasks.end()){ auto sTasks = tasks.at(_scenario); if(sTasks.find(_id) != sTasks.end()){ PD_UI_Task * task = tasks.at(_scenario).at(_id); task->setTextShader(crossedTextShader); task->text->setFont(crossedFont, true); incrementCount(-1); invalidateLayout(); task->checkTimeout->restart(); } } }
void Node::spawnChild(int k) { // Inherit data from parent children[k] = Node(); children.at(k).semigroup.reserve(f+1); for(int k2 = 0; k2 < f+1; k2++){ children.at(k).semigroup[k2]=semigroup[k2]; } children.at(k).f = f; //Flip the necessary bits (refer to thm 4.1) children.at(k).semigroup[k] = false; children.at(k).semigroup[f-k] = true; //Increment the necessary counters incrementCount(); children.at(k).id = count; children.at(k).level = level+1; }
void safeArgs(Record *regs, char c,int sizeArray, int first, int last) { char chNull; int i; chNull = '0'; i = 0; i = lookforReg(regs,c,sizeArray); if(i == -1){ i = lookforReg(regs,chNull,sizeArray); regs[i].c = c; } incrementCount(regs,i); incrementFirst(regs,first,i); incrementLast(regs,last,i); }
int main (int argc, char * argv[]) { const char chars[] = "./0123456789ABCDEFGHIJKLMNOPQRST" "UVWXYZabcdefghijklmnopqrstuvwxyz\0"; char * guess = (char*) malloc (sizeof(char)*13+1); char target[] = "............."; char salt[] = ".."; int * count = (int*) malloc (sizeof(int)*10+1); int * work = (int*) malloc (sizeof(int)*3); int zIndex = -1; int i; int stat = 0; /* for wait() call */ char *hash; int foundOne = -1; int processCount = 0; pid_t child; if (argc != 2) { printf("Please choose a value between 0 and 12 as argument!\n"); exit(1); } zIndex = atoi(argv[1]); if (zIndex < 0 || zIndex > 12) { printf("Argument out of range!\n"); exit(1); } else printf("%d\n", zIndex); target[zIndex] = 'z'; // reset count for (i=0; i<10; ++i) count[i] = 0; count[10] = '\0'; /* Initialization done! * Now start sending out miners. */ hash = crypt(target,salt); printf("Target: %s\nHash:%s\n", target, crypt(target,salt)); while (foundOne == -1) { buildString(count,chars,&guess); if (processCount < 4) { child = fork(); if (child == -1) { perror("fork"); exit(1); } if (child == 0) { /* This is the childs process */ execl( "miner", /* path of the program */ "miner", /* name of the program, i.e. argv[0] */ hash, /* first argument, i.e. argv[1] */ guess, /* second argument with the first ten characters of the guess */ (char*)NULL /* terminate list of arguments */ ); /* not reached except if execl failed */ perror("miner"); exit(1); } ++processCount; incrementCount(&count); } else { if (wait(&stat) != -1) { --processCount; if (WEXITSTATUS(stat) == 0) foundOne=0; } } } // reset work for (i=0; i<3; ++i) work[i] = 0; while (wait(&stat) != -1); exit(0); }
void UISearchPage::recvIO_SearchReply( IOMessage * io ) { if ( m_done == true ) return ; // Order of appearance // // the first time a filename shows up it gets it's own line, // and if it shows up more than once it is reparented. QListViewItem * item = new QListViewItem( m_view ); item->setText( UIPageView::Col_Name, io->find( "name" ) ); item->setText( UIPageView::Col_Bitr, io->find( "bitrate" ) ); item->setText( UIPageView::Col_Size, io->find( "size" ) ); item->setText( UIPageView::Col_Time, io->find( "time" ) ); item->setText( UIPageView::Col_Freq, io->find( "freq" ) ); item->setText( UIPageView::Col_Link, io->find( "speed" ) ); item->setText( UIPageView::Col_Nick, io->find( "nick" ) ); item->setText( UIPageView::Col_Path, io->find( "path" ) ); item->setText( UIPageView::Col_Host, io->find( "host" ) ); // // count gets bumped, title gets updated // incrementCount(); updateTitle(); // // do some bizzare tree m_view stuff ? // QListViewItem * item2 = m_items->find( io->find( "name" ) ); if ( item2 == 0 ) { m_items->replace( io->find( "name" ), item ); } else { QListViewItem * from = 0; if ( item2->text( UIPageView::Col_Path ).isEmpty() == false ) { from = new QListViewItem( m_view ); from->setText( UIPageView::Col_Name, io->find( "name" ) ); from->setOpen( true ); from->setPixmap( UIPageView::Col_Name, m_folder ); // also add this item under parent m_view->takeItem( item2 ); from->insertItem( item2 ); } else { from = item2; } m_view->takeItem( item ); from->insertItem( item ); m_items->replace( io->find( "name" ), from ); } m_view->triggerUpdate(); }
int main(void) { WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer // Disable the GPIO power-on default high-impedance mode // to activate previously configured port settings PMM_unlockLPM5(); //bools for running control logic for each switch bool running = false; bool running2 = false; //initialise systems init(); __enable_interrupt(); //stores data returned from colour sensor struct colour detectedColour; //stores MM decision from comparator enum mmColours detectedMM; //initialise counts to 0 numOfMMs.red = 0; numOfMMs.orange = 0; numOfMMs.yellow = 0; numOfMMs.brown = 0; numOfMMs.green = 0; numOfMMs.blue = 0; //number of mms sorted in current batch int mmSorted = 0; //main loop while(1) { //switch 2 has interrupted if (SW2_interruptFlag_) { //ignore input from button for 0.1s __delay_cycles(100000); SW2_interruptFlag_ = false; //start sorting running = true; } //switch 1 has interrupted else if (SW1_interruptFlag_) { SW1_interruptFlag_ = false; //update LCD with next value running2 = true; } if (running2) { //display next mm count on the LCD showNextCount(); updateLCDWithCount(numOfMMs); running2 = false; } while (running) { //wait for an mm to enter seperator __delay_cycles(500000); //move seperator to colour sensor changeServoADutyCycle(0x32); //wait for mm to enter detection chamber __delay_cycles(300000); //run sensor detectedColour = runSensor(); //compare sensor reading to calibration data detectedMM = decideColour(detectedColour); //increse count for detected MM by 1 incrementCount(detectedMM); //run sorter moveSorter(detectedMM); __delay_cycles(1000000); //move seperator to exit changeServoADutyCycle(0x50); //wait for mm to drop __delay_cycles(700000); //move seperator to entrance changeServoADutyCycle(0x20); //reset servo b changeServoBDutyCycle(0x20); __delay_cycles(1000000); //sorted one more from current batch mmSorted++; if (mmSorted == 1) { running = false; mmSorted = 0; updateLCDWithCount(numOfMMs); } //stop if the button is pressed if (SW2_interruptFlag_) { __delay_cycles(100000); SW2_interruptFlag_ = false; running = false; mmSorted = 0; updateLCDWithCount(numOfMMs); } } } }