int main() { try{ LinkedStack stk1=LinkedStack(); ArrayStack stk2=ArrayStack(45500); fillAll(stk1,"random.txt"); emptyAll(stk1,"LSoutput.txt"); fillAll(stk2,"random.txt"); emptyAll(stk2,"ASoutput.txt"); string test="({(())})((([({})])))(((((()([{()}])(()))))))()"; if(isBalanced(test)) cout<<"It is balanced"<<endl; else cout<<"It is not balanced"<<endl; } catch(string error) { cout<<"Error: "<< error<<endl; } }
void kitchenFrame::OnNotebook1PageChanged(wxNotebookEvent& event) { if(Notebook1->GetSelection() != 0) { OrderPanels[Notebook1->GetSelection()-1]->fillAll(); } else { fillAll(); } }
void kitchenFrame::OnUrlClick(wxHtmlLinkEvent& event) { long templong; wxString link = event.GetLinkInfo().GetHref(); link.Mid(0,link.Find(_T(":"))).ToLong(&templong); href=true; int num = templong; wxString temp; temp << num; mysqlpp::Query query = conn->query(); wxString dishId = link.Mid(link.Find(_T(":"))+1); query <<"UPDATE `orders_dishes` SET `ready` = '1' \ WHERE `orders_dishes`.`id` =" << wx2std(dishId, wxConvUI) << " LIMIT 1"; query.execute(); //we just set to ready only one dish from order int orderId; query << "SELECT `order_id` FROM `orders_dishes` WHERE `id`="<< wx2std(dishId, wxConvUI); mysqlpp::StoreQueryResult res = query.store(); if(res) { mysqlpp::Row row; row = res.at(0); orderId = int(row["order_id"]); } query << "SELECT `id` FROM `orders_dishes` WHERE `ready`=0 AND `order_id`="<< orderId; res = query.store(); if(res) { if(!res.num_rows()) //no dishes to prepare { query << "UPDATE `orders` SET `status` = '4' WHERE `orders`.`id` ="<< orderId <<" LIMIT 1 "; query.execute(); //set the whole order to ready state //redo the pages to update status fillAll(); wxString tem; tem << _T("r:") << orderId; sendMessageToServer(SocketClient1, tem); } } wxString prodName = StaticText9->GetLabel(); fillDetails(prodName); fillMain(); }
void Graphics::drawImageTransformed (const Image& imageToDraw, const AffineTransform& transform, const bool fillAlphaChannelWithCurrentBrush) const { if (imageToDraw.isValid() && ! context.isClipEmpty()) { if (fillAlphaChannelWithCurrentBrush) { context.saveState(); context.clipToImageAlpha (imageToDraw, transform); fillAll(); context.restoreState(); } else { context.drawImage (imageToDraw, transform); } } }
void Record::init(string data){ valid = false; //check if given data if(data==""){ return; } //check if data is properly formatted int numDelims = count(data.begin(),data.end(),DELIM); if(numDelims!=NUM_REQUIRED_DELIMS){ cerr<<"Found Malformed Record:"<<data<<endl; throw InvalidInputException(); } //populate vals fillAll(data); type = getType(vals[MISC_ATTR]); //check type if(type==None){ cerr<<"Found Malformed MISC:"<<vals[MISC_ATTR]<<endl <<"\tPath:"<<vals[PATH]<<endl; throw InvalidInputException(); } //being type OTHER is not exception worthy, but it isn't valid. if(type==Other){ cerr<<"Found Device, Socket, or Other Type. Will Not Move.\t" <<vals[PATH]<<endl; return; } //if we make it here, its good valid = true; }
void kitchenFrame::readFromDining(wxSocketBase *sock) { unsigned char len; char *buf; sock->SetFlags(wxSOCKET_WAITALL); // Read the size sock->Read(&len, 1); buf = new char[len]; // Read the data sock->Read(buf, len); wxString s; s.Printf(_("%s"), buf); if(s == _T("n:")) //we have new order { fillAll(); } else if(s.Mid(0,2) == _T("m:")) { TextCtrl1->AppendText(_("POS: ") + s.Mid(2,s.Length()) + _T("\n")); } }
int main(int argc, char **argv){ /* key_t shmKey; int shmid; time_t curtime = -1; char xtime[40]="\0"; long int size=4194304; // = 4 MB // 131072; //65536; */ long int ii=0; long int adc=0; pid_t pid; int xx=0; /* Set up LabJack U6 */ labjackSetup(); /* Shared memory creation and attachment */ shmSetup(); /* Get the process number for interupts when the two programs need to interact */ pid = getpid(); lnptr->pid = pid; printf("pid = %li \n",(long int)lnptr->pid); /* Set up the signal capture routine for when the reading program wants something changed */ memset (&act,'\0', sizeof(act)); act.sa_sigaction = &handlerCommand; act.sa_flags = SA_SIGINFO; if (sigaction(SIGALRM,&act,NULL) < 0){ perror("sigaction"); return 1; } /* Read setup file on disk and load into shared memory */ printf("Read conf file...\n"); readConf(); printf(" ... Conf file read \n"); /* Go out and read RTDs and get everything needed loaded into shared memory */ updateRTD(); /* for (ii=0; ii<20; ii++){ if (lnptr->ge[ii].onoff == 1){ lnptr->ge[ii].rtd = readRTD(lnptr->ge[ii].chanRTD); lnptr->ge[ii].oflo = readRTD(lnptr->ge[ii].chanOFLO); printf("Active det: %li -> %lf %lf\n", ii,lnptr->ge[ii].rtd,lnptr->ge[ii].oflo ); } } lnptr->tank.rtd = readRTD(lnptr->tank.chanRTD); lnptr->tank.pressure = readRTD(lnptr->tank.chanPRES); printf("TANK: %lf\n", lnptr->tank.rtd); */ /* Setup time of next fill based on current time and configure file */ curtime = time(NULL); time0 = curtime; // record starting time of program time1 = time0 + INTERVAL; // set up next read of RTD...usually every minute for (ii=0; ii<20; ii++){ if (lnptr->ge[ii].onoff == 1){ lnptr->ge[ii].next = time0 + lnptr->ge[ii].interval; } else { lnptr->ge[ii].next = 0; } } /* Setup monitoring loop to look for changes and requests */ // setTimer(); outletStatus(); /* Setup monitoring loop to look for changes/minute and requests */ nread = INTERVAL; lnptr->command = 0; while(lnptr->command != -1) { // curtime = time(NULL); // check what time it is - confirm still running // lnptr->secRunning = curtime - time0; // record time running (lets user now it it is still up) updateRTD(); // read and update the RTD information including lnptr->secRunning /* if (curtime >= time1) { // read RTDs every INTERVAL (usually ~60 s) // time1 = time1+INTERVAL; / time1 = time1+nread; // read RTDs every nread (usually INTERVAL though during a fill it might be more often) updateRTD(); } Check if an RTD is too high */ for (ii=0;ii<20;ii++){ // run thru each detector possibility if (lnptr->ge[ii].onoff == 1) { // run thru each detector that is ON if (lnptr->ge[ii].rtd > lnptr->ge[ii].limit){ // check rtd is within limit printf("SHUT DOWN !\n"); strcpy(lnptr->ge[ii].status,"ALARM"); } if (curtime > lnptr->ge[ii].next){ // check if its time to fill a detector printf("start a fill ...set command to 8 = Fill All! \n"); lnptr->command = 8; } } } // AFTER THIS LOOP CHECK FOR COMMANDS COMING IN FROM CONTROL PROGRAM if (lnptr->command > 20 && lnptr->command <= 40){ closeDet(lnptr->command-21); // way to close individual valves lnptr->command=0; } else if (lnptr->command > 40 && lnptr->command <= 60) { openDet(lnptr->command-41); // way to open individual valves lnptr->command=0; } else { switch (lnptr->command) { case 0: /* // signal(SIGTERM,alarm_wakeup); // set the Alarm signal capture sleep (1); // pause for time curtime = time(NULL); printf ("curtime = %li %li \n", curtime, (time1-curtime)); if (curtime >= time1) { time1 = time1+INTERVAL; updateRTD(); } */ break; case 1: printf ("1 selected\n"); updateRTD(); lnptr->command=0; break; case 2: printf ("2 selected\n"); lnptr->command=0; break; case 3: printf ("3 selected\n"); lnptr->command=0; break; case 7: printf ("7 selected\n"); // fill 1 detector lnptr->command=0; break; case 8: printf ("8 selected\n"); // fill All fillAll(); lnptr->command=0; break; case 10: printf ("10 selected\n"); closeAllValves(); // close all valves including tank but open manifold lnptr->command=0; break; case 11: printf ("14 selected\n"); closeTank(); // open tank lnptr->command=0; break; case 12: printf ("14 selected\n"); closeTank(); // close Tank lnptr->command=0; break; case 13: printf ("11 selected\n"); closeMani(); // close Manifold lnptr->command=0; break; case 14: printf ("15 selected\n"); openMani(); // open Manifold lnptr->command=0; break; case 17: printf ("17 selected\n"); // initial cooldown outletStatus (); lnptr->command=0; break; case 18: printf ("18 selected\n"); // initial cooldown break; default: printf ("default selected\n"); lnptr->command=0; break; } } sleep (nread); } /* Release the shared memory and close the U6 */ shmdt(lnptr); // detach from shared memory segment printf("detached from SHM\n"); shmctl(shmid, IPC_RMID, NULL); // remove the shared memory segment hopefully forever printf("removed from SHM\n"); closeUSBConnection(hU6); printf("USB closed\n"); return 0; }
void kitchenFrame::OnTimer1Trigger(wxTimerEvent& event) { fillAll(); }
void kitchenFrame::OnButton5Click(wxCommandEvent& event) { fillAll(); }