DWORD WINAPI TimerTickThread(LPVOID P) { while(TRUE) { if(!v_GameInit && Myself) OnGameEvent(FALSE); else if(v_GameInit && !Myself) OnGameEvent(TRUE); if(D2Inited) if(D2Delay<20) D2Delay++; else { if(GetGameInfo()->szCharName!=NULL) TimerTick(); else { Flash=false; D2Inited=false; D2Delay=0; } } Sleep(50); } return true; }
/* * InitGlobals * * INPUTS: * none * OUTPUTS: * none */ void InitGlobals() { adspGlobal.lastCID = (random() & 0xffff); adspGlobal.inTimer = 0; TimerTick(); /* start the ADSP timer */ }
void TIMER_IRQHandler( void ) { uint32_t flags; flags = TIMER_IntGet( TIMER ); if ( flags & TIMER_IF_CC0 ) { TIMER_IntClear( TIMER, TIMER_IFC_CC0 ); TIMER_CompareSet( TIMER, 0, TIMER_CaptureGet( TIMER, 0 ) + ticksPrMs ); TimerTick(); } }
void MyApp::MessageReceived( BMessage* pcMsg ) { switch( pcMsg->what ) { case TIMER_TICK: TimerTick( 0 ); // mTimer->SetCount( 1 ); default: BApplication::MessageReceived( pcMsg ); return; } }
void __fastcall TNodeForm::SpyButtonClick(TObject *Sender) { int i; for(i=0;i<ListBox->Items->Count;i++) if(ListBox->Selected[i]==true) { if(SpyForms[i]==NULL) { Application->CreateForm(__classid(TSpyForm), &SpyForms[i]); SpyForms[i]->inbuf=&MainForm->bbs_startup.node_inbuf[i]; SpyForms[i]->outbuf=&MainForm->bbs_startup.node_spybuf[i]; SpyForms[i]->Caption="Node "+AnsiString(i+1); } SpyForms[i]->Show(); } TimerTick(Sender); }
void __fastcall TNodeForm::InterruptNodeButtonClick(TObject *Sender) { int i; int file; node_t node; for(i=0;i<ListBox->Items->Count;i++) if(ListBox->Selected[i]==true) { if(getnodedat(i+1,&node,&file)) break; node.misc^=NODE_INTR; if(putnodedat(i+1,&node,file)) break; } TimerTick(Sender); }
void __fastcall TNodeForm::ClearErrorButtonClick(TObject *Sender) { int i; int file; node_t node; for(i=0;i<ListBox->Items->Count;i++) if(ListBox->Selected[i]==true) { if(getnodedat(i+1,&node,&file)) break; node.errors=0; if(putnodedat(i+1,&node,file)) break; } TimerTick(Sender); }
void __fastcall TNodeForm::UserEditButtonClick(TObject *Sender) { int i; char str[128]; node_t node; for(i=0;i<ListBox->Items->Count;i++) if(ListBox->Selected[i]==true) { if(getnodedat(i+1,&node,NULL)) break; if(node.useron==0) continue; sprintf(str,"%sUSEREDIT %s %d" ,MainForm->cfg.exec_dir ,MainForm->cfg.data_dir ,node.useron); WinExec(str,SW_SHOWNORMAL); } TimerTick(Sender); }
int RobotControl::Initialize(QString address, int port, int _engines, int _tickTime) { engines = _engines; tickTime = _tickTime; ticksForReverse = qRound(2000.0/tickTime + 0.5); //ceil((2 seconds)/(one tick)) QObject::connect(&timer, SIGNAL(timeout()), this, SLOT(TimerTick())); ed.newSpeed.resize(engines); ed.actualSpeed.resize(engines); ed.newReverse.resize(engines); ed.actualReverse.resize(engines); ed.ticksSinceLastReverse.resize(engines); timer.start(tickTime); socket.connectToHost(address, port); vertc.reset(new VerticalController(&socket)); currentState = Move; initialized = true; return 1; }
void __fastcall TNodeForm::DownButtonClick(TObject *Sender) { int i; int file; node_t node; for(i=0;i<ListBox->Items->Count;i++) if(ListBox->Selected[i]==true) { if(getnodedat(i+1,&node,&file)) break; if(node.status==NODE_WFC) node.status=NODE_OFFLINE; else if(node.status==NODE_OFFLINE) node.status=NODE_WFC; else node.misc^=NODE_DOWN; if(putnodedat(i+1,&node,file)) break; } TimerTick(Sender); }
void __fastcall TNodeForm::UserMsgButtonClick(TObject *Sender) { int i; node_t node; Application->CreateForm(__classid(TUserMsgForm), &UserMsgForm); UserMsgForm->Memo->Text="\1n\1y\1hMessage From Sysop:\1w "; UserMsgForm->Memo->SelStart=UserMsgForm->Memo->Text.Length(); if(UserMsgForm->ShowModal()==mrOk) { UserMsgForm->Memo->Lines->Add(""); for(i=0;i<ListBox->Items->Count;i++) if(ListBox->Selected[i]==true) { if(getnodedat(i+1,&node,NULL)) break; if(node.useron==0) continue; putsmsg(&MainForm->cfg,node.useron ,UserMsgForm->Memo->Text.c_str()); } } delete UserMsgForm; TimerTick(Sender); }
void __fastcall TNodeForm::ChatButtonClick(TObject *Sender) { char str[512]; char name[128]; int i; node_t node; for(i=0;i<ListBox->Items->Count;i++) if(ListBox->Selected[i]==true) { if(getnodedat(i+1,&node,NULL)) break; if(node.status==NODE_WFC || node.status>NODE_QUIET) continue; sprintf(str,"%sCHAT %s %s %d %s" ,MainForm->cfg.exec_dir ,MainForm->cfg.ctrl_dir ,MainForm->cfg.node_path[i] ,i+1 ,username(node.useron,name) ); WinExec(str,SW_SHOWNORMAL); } TimerTick(Sender); }
TestHarness::TestHarness(QWidget *parent) : QWidget(parent) { QGroupBox *ecu_box = new QGroupBox("Engine Control Unit"); QGroupBox *gps_box = new QGroupBox("GPS"); QGroupBox *imu_box = new QGroupBox("Inertial Measurement Unit"); QGroupBox *lts_box = new QGroupBox("Lighting System"); QGroupBox *wls_box = new QGroupBox("Wireless Radio"); QGroupBox *tmr_box = new QGroupBox("Timer/Logger"); QGridLayout *ecu_layout = new QGridLayout(); QGridLayout *gps_layout = new QGridLayout(); QGridLayout *imu_layout = new QGridLayout(); QGridLayout *lts_layout = new QGridLayout(); QGridLayout *wls_layout = new QGridLayout(); QGridLayout *tmr_layout = new QGridLayout(); QGridLayout *layout = new QGridLayout(); // ecu box ecu_rpm_label = new QLabel("RPM:"); ecu_rpm_edit = new QLineEdit("2000"); ecu_spark_label = new QLabel("Spark Advance:"); ecu_spark_edit = new QLineEdit("15.0"); ecu_cranking_label = new QLabel("Cranking:"); ecu_cranking_edit = new QCheckBox("Yes"); ecu_map_label = new QLabel("Manifold Air Pres:"); ecu_map_edit = new QLineEdit("1500.0"); ecu_mat_label = new QLabel("Manifold Air Temp:"); ecu_mat_edit = new QLineEdit("15.0"); ecu_clt_label = new QLabel("Coolant Temp:"); ecu_clt_edit = new QLineEdit("90.0"); ecu_tps_label = new QLabel("Throttle Position:"); ecu_tps_edit = new QLineEdit("50.0"); ecu_batt_label = new QLabel("Battery:"); ecu_batt_edit = new QLineEdit("11.9"); ecu_maf_label = new QLabel("Mass Airflow:"); ecu_maf_edit = new QLineEdit("900.0"); ecu_tc_label = new QLabel("Tach Count:"); ecu_tc_edit = new QLineEdit("100"); ecu_update_button = new QPushButton("Update"); ecu_layout->addWidget(ecu_rpm_label, 0, 0); ecu_layout->addWidget(ecu_rpm_edit, 0, 1); ecu_layout->addWidget(ecu_spark_label, 1, 0); ecu_layout->addWidget(ecu_spark_edit, 1, 1); ecu_layout->addWidget(ecu_cranking_label, 2, 0); ecu_layout->addWidget(ecu_cranking_edit, 2, 1); ecu_layout->addWidget(ecu_map_label, 3, 0); ecu_layout->addWidget(ecu_map_edit, 3, 1); ecu_layout->addWidget(ecu_mat_label, 4, 0); ecu_layout->addWidget(ecu_mat_edit, 4, 1); ecu_layout->addWidget(ecu_clt_label, 5, 0); ecu_layout->addWidget(ecu_clt_edit, 5, 1); ecu_layout->addWidget(ecu_tps_label, 6, 0); ecu_layout->addWidget(ecu_tps_edit, 6, 1); ecu_layout->addWidget(ecu_batt_label, 7, 0); ecu_layout->addWidget(ecu_batt_edit, 7, 1); ecu_layout->addWidget(ecu_maf_label, 8, 0); ecu_layout->addWidget(ecu_maf_edit, 8, 1); ecu_layout->addWidget(ecu_tc_label, 9, 0); ecu_layout->addWidget(ecu_tc_edit, 9, 1); ecu_layout->addWidget(ecu_update_button, 10, 0, 1, 2); ecu_layout->setRowStretch(11, 1); // gps box gps_time_label = new QLabel("UTC Time:"); gps_colon1_label = new QLabel(":"); gps_colon2_label = new QLabel(":"); gps_hrs_edit = new QLineEdit("12"); gps_mins_edit = new QLineEdit("01"); gps_secs_edit = new QLineEdit("01.001"); gps_lat_label = new QLabel("Latitude:"); gps_deg1_label = new QLabel("deg"); gps_min1_label = new QLabel("min"); gps_latdeg_edit = new QLineEdit("35"); gps_latmin_edit = new QLineEdit("15.653229"); gps_latdir_edit = new QLineEdit("N"); gps_long_label = new QLabel("Longitude:"); gps_deg2_label = new QLabel("deg"); gps_min2_label = new QLabel("min"); gps_longdeg_edit = new QLineEdit("120"); gps_longmin_edit = new QLineEdit("39.2362974"); gps_longdir_edit = new QLineEdit("W"); gps_alt_label = new QLabel("Altitude:"); gps_alt_edit = new QLineEdit("500.0"); gps_speed_label = new QLabel("Speed:"); gps_speed_edit = new QLineEdit("25.0"); gps_heading_label = new QLabel("Heading:"); gps_heading_edit = new QLineEdit("187.5"); gps_update_button = new QPushButton("Update"); gps_layout->addWidget(gps_time_label, 0, 0); gps_layout->addWidget(gps_hrs_edit, 0, 1); gps_layout->addWidget(gps_colon1_label, 0, 2); gps_layout->addWidget(gps_mins_edit, 0, 3); gps_layout->addWidget(gps_colon2_label, 0, 4); gps_layout->addWidget(gps_secs_edit, 0, 5); gps_layout->addWidget(gps_lat_label, 1, 0); gps_layout->addWidget(gps_latdeg_edit, 1, 1); gps_layout->addWidget(gps_deg1_label, 1, 2); gps_layout->addWidget(gps_latmin_edit, 1, 3); gps_layout->addWidget(gps_min1_label, 1, 4); gps_layout->addWidget(gps_latdir_edit, 1, 5); gps_layout->addWidget(gps_long_label, 2, 0); gps_layout->addWidget(gps_longdeg_edit, 2, 1); gps_layout->addWidget(gps_deg2_label, 2, 2); gps_layout->addWidget(gps_longmin_edit, 2, 3); gps_layout->addWidget(gps_min2_label, 2, 4); gps_layout->addWidget(gps_longdir_edit, 2, 5); gps_layout->addWidget(gps_alt_label, 3, 0); gps_layout->addWidget(gps_alt_edit, 3, 1, 1, 5); gps_layout->addWidget(gps_speed_label, 4, 0); gps_layout->addWidget(gps_speed_edit, 4, 1, 1, 5); gps_layout->addWidget(gps_heading_label, 5, 0); gps_layout->addWidget(gps_heading_edit, 5, 1, 1, 5); gps_layout->addWidget(gps_update_button, 6, 0, 1, 6); gps_layout->setRowStretch(7, 1); // imu box imu_ax_label = new QLabel("Accel X:"); imu_ax_edit = new QLineEdit("0.0"); imu_ay_label = new QLabel("Accel Y:"); imu_ay_edit = new QLineEdit("1.0"); imu_az_label = new QLabel("Accel Z:"); imu_az_edit = new QLineEdit("0.0"); imu_gx_label = new QLabel("Gyro X:"); imu_gx_edit = new QLineEdit("0.0"); imu_gy_label = new QLabel("Gyro Y:"); imu_gy_edit = new QLineEdit("0.0"); imu_gz_label = new QLabel("Gyro Z:"); imu_gz_edit = new QLineEdit("0.0"); imu_update_button = new QPushButton("Update"); imu_layout->addWidget(imu_ax_label, 0, 0); imu_layout->addWidget(imu_ax_edit, 0, 1); imu_layout->addWidget(imu_ay_label, 1, 0); imu_layout->addWidget(imu_ay_edit, 1, 1); imu_layout->addWidget(imu_az_label, 2, 0); imu_layout->addWidget(imu_az_edit, 2, 1); imu_layout->addWidget(imu_gx_label, 3, 0); imu_layout->addWidget(imu_gx_edit, 3, 1); imu_layout->addWidget(imu_gy_label, 4, 0); imu_layout->addWidget(imu_gy_edit, 4, 1); imu_layout->addWidget(imu_gz_label, 5, 0); imu_layout->addWidget(imu_gz_edit, 5, 1); imu_layout->addWidget(imu_update_button, 6, 0, 1, 2); imu_layout->setRowStretch(7, 1); // lights box lts_head_label = new QLabel("Headlights:"); lts_head_edit = new QCheckBox("On"); lts_brake_label = new QLabel("Brakelights:"); lts_brake_edit = new QCheckBox("On"); lts_left_label = new QLabel("Left Turn Signal:"); lts_left_edit = new QCheckBox("On"); lts_right_label = new QLabel("Right Turn Signal:"); lts_right_edit = new QCheckBox("On"); lts_hazards_label = new QLabel("Hazards:"); lts_hazards_edit = new QCheckBox("On"); lts_update_button = new QPushButton("Update"); lts_layout->addWidget(lts_head_label, 0, 0); lts_layout->addWidget(lts_head_edit, 0, 1); lts_layout->addWidget(lts_brake_label, 1, 0); lts_layout->addWidget(lts_brake_edit, 1, 1); lts_layout->addWidget(lts_left_label, 2, 0); lts_layout->addWidget(lts_left_edit, 2, 1); lts_layout->addWidget(lts_right_label, 3, 0); lts_layout->addWidget(lts_right_edit, 3, 1); lts_layout->addWidget(lts_hazards_label, 4, 0); lts_layout->addWidget(lts_hazards_edit, 4, 1); lts_layout->addWidget(lts_update_button, 5, 0, 1, 2); lts_layout->setRowStretch(6, 1); // wireless box wls_rx_label = new QLabel("Received from the radio:"); wls_rx_edit = new QTextEdit(); wls_tx_label = new QLabel("Transmit to the radio:"); wls_tx_edit = new QTextEdit(); wls_update_button = new QPushButton("Update"); wls_layout->addWidget(wls_rx_label, 0, 0); wls_layout->addWidget(wls_rx_edit, 1, 0); wls_layout->addWidget(wls_tx_label, 2, 0); wls_layout->addWidget(wls_tx_edit, 3, 0); wls_layout->addWidget(wls_update_button, 4, 0); wls_layout->setRowStretch(5, 1); // timer box tmr_time_display = new QLCDNumber(8); tmr_time_display->setSegmentStyle(QLCDNumber::Flat); tmr_start_button = new QPushButton("Start Timer"); tmr_stop_button = new QPushButton("Stop Timer"); log_start_button = new QPushButton("Start Data Logger"); log_stop_button = new QPushButton("Stop Data Logger"); tmr_layout->addWidget(tmr_time_display, 0, 0); tmr_layout->addWidget(tmr_start_button, 1, 0); tmr_layout->addWidget(tmr_stop_button, 2, 0); tmr_layout->addWidget(log_start_button, 3, 0); tmr_layout->addWidget(log_stop_button, 4, 0); tmr_layout->setRowStretch(5, 1); // master layout ecu_box->setLayout(ecu_layout); gps_box->setLayout(gps_layout); imu_box->setLayout(imu_layout); lts_box->setLayout(lts_layout); wls_box->setLayout(wls_layout); tmr_box->setLayout(tmr_layout); layout->addWidget(ecu_box, 0, 0); layout->addWidget(gps_box, 0, 1); layout->addWidget(imu_box, 0, 2); layout->addWidget(lts_box, 1, 0); layout->addWidget(wls_box, 1, 1); layout->addWidget(tmr_box, 1, 2); setLayout(layout); setWindowTitle("Hardware Interface Test Harness"); // connect up the ui to internal slots connect(tmr_start_button, SIGNAL(clicked()), this, SLOT(TmrStart())); connect(tmr_stop_button, SIGNAL(clicked()), this, SLOT(TmrStop())); connect(this, SIGNAL(TmrTick(int)), tmr_time_display, SLOT(display(int))); connect(ecu_update_button, SIGNAL(clicked()), this, SLOT(UpdateEcu())); connect(gps_update_button, SIGNAL(clicked()), this, SLOT(UpdateGps())); connect(imu_update_button, SIGNAL(clicked()), this, SLOT(UpdateImu())); connect(lts_update_button, SIGNAL(clicked()), this, SLOT(UpdateLts())); connect(wls_update_button, SIGNAL(clicked()), this, SLOT(UpdateWls())); // done initializing ui, set up some internal stuff timer_running = false; time = new QTime(); timer = new QTimer(this); connect(timer, SIGNAL(timeout()), this, SLOT(TimerTick())); // debug logger = new DataLogger(); dashboard = new Dashboard(); dashboard->show(); // connect up the test harness to the data logger connect(log_start_button, SIGNAL(clicked()), logger, SLOT(LogStart())); connect(log_stop_button, SIGNAL(clicked()), logger, SLOT(LogStop())); connect(this, SIGNAL(EcuStateChanged(ecustate_t)), logger, SLOT(EcuUpdate(ecustate_t))); connect(this, SIGNAL(GpsStateChanged(gpsstate_t)), logger, SLOT(GpsUpdate(gpsstate_t))); connect(this, SIGNAL(ImuStateChanged(imustate_t)), logger, SLOT(ImuUpdate(imustate_t))); connect(this, SIGNAL(LtsStateChanged(ltsstate_t)), logger, SLOT(LtsUpdate(ltsstate_t))); connect(this, SIGNAL(TmrTick(int)), logger, SLOT(TmrUpdate(int))); // connect up the test harness to the dashboard connect(this, SIGNAL(TmrTick(int)), dashboard, SLOT(TmrUpdate(int))); connect(this, SIGNAL(EcuStateChanged(ecustate_t)), dashboard, SLOT(EcuUpdate(ecustate_t))); connect(this, SIGNAL(GpsStateChanged(gpsstate_t)), dashboard, SLOT(GpsUpdate(gpsstate_t))); connect(this, SIGNAL(ImuStateChanged(imustate_t)), dashboard, SLOT(ImuUpdate(imustate_t))); connect(this, SIGNAL(LtsStateChanged(ltsstate_t)), dashboard, SLOT(LtsUpdate(ltsstate_t))); }
void ActivityWidgetsView::LoadWidgets() { std::string file = Utils::getConfigFile(WIDGET_CONFIG); TiXmlDocument document(file); if (!document.LoadFile()) { Utils::logger("root") << Priority::ERROR << "There was a parse error in " << file << log4cpp::eol; Utils::logger("root") << Priority::ERROR << document.ErrorDesc() << log4cpp::eol; Utils::logger("root") << Priority::ERROR << "In file " << file << " At line " << document.ErrorRow() << log4cpp::eol; //force save of file SaveWidgets(); } else { TiXmlHandle docHandle(&document); TiXmlElement *node = docHandle.FirstChildElement("calaos:widgets").FirstChildElement("calaos:widget").ToElement(); for(; node; node = node->NextSiblingElement()) { if (node->ValueStr() == "calaos:widget" && node->Attribute("id") && node->Attribute("type") && node->Attribute("posx") && node->Attribute("posy") && node->Attribute("width") && node->Attribute("height")) { string type, id; type = node->Attribute("type"); id = node->Attribute("id"); int x, y, w, h; from_string(node->Attribute("posx"), x); from_string(node->Attribute("posy"), y); from_string(node->Attribute("width"), w); from_string(node->Attribute("height"), h); ModuleDef t; vector<ModuleDef> mods = ModuleManager::Instance().getAvailableModules(); for (uint i = 0;i < mods.size();i++) { if (mods[i].mod_fname == type) { t = mods[i]; AddWidget(t, x, y, w, h, id); break; } } Show(); } } } //Check each 6 hours if (!timer) timer = new EcoreTimer(60.0 * 6.0, (sigc::slot<void>)sigc::mem_fun(*this, &ActivityWidgetsView::TimerTick) ); TimerTick(); }
void __fastcall TNodeForm::RefreshMenuItemClick(TObject *Sender) { ListBox->Clear(); TimerTick(Sender); }
mainw::mainw(QWidget *parent) : QMainWindow(parent), ui(new Ui::mainw) { ui->setupUi(this); HW_wrapper_setup( TIMER_INTERVAL ); memset( buttons, 0, sizeof(bool)*3 ); memset( &cmd_list, 0, sizeof(cmd_list) ); commwait_getstatus = false; commwait_getcoord = false; // setup text boxes QTextOption text_opt; QFont fnt; doc_commands = new QTextDocument("# command list", this); doc_comm_log = new QTextDocument("---- communication log ----", this); fnt = ui->txt_commands->font(); doc_commands->setDefaultFont( fnt ); doc_comm_log->setDefaultFont( fnt ); ui->txt_commands->setDocument( doc_commands ); text_opt = doc_commands->defaultTextOption(); text_opt.setWrapMode( QTextOption::NoWrap ); doc_commands->setDefaultTextOption( text_opt ); doc_commands->setMaximumBlockCount(-1); ui->txt_comm_window->setDocument( doc_comm_log ); ui->txt_comm_window->setFont( fnt ); text_opt = doc_comm_log->defaultTextOption(); text_opt.setWrapMode( QTextOption::NoWrap ); doc_comm_log->setDefaultTextOption( text_opt ); doc_comm_log->setMaximumBlockCount(1000); // set up the graphic display simulator gmem_xy = (uchar*)malloc( DISPSIM_MAX_W * DISPSIM_MAX_H * 3 ); scene_xy = new QGraphicsScene(0, 0, 1330, 460, ui->gw_xy ); QImage image( gmem_xy, DISPSIM_MAX_W, DISPSIM_MAX_H, DISPSIM_MAX_W * 3, QImage::Format_RGB888 ); image.fill(Qt::black ); G_item_xy = new QGraphicsPixmapItem( QPixmap::fromImage( image )); pointer_xy = new QGraphicsEllipseItem( QRect(-3, -3, 5, 5), 0 ); pointer_xy->setPen( QPen(Qt::red) ); pointer_xy->setBrush( QBrush(Qt::NoBrush) ); pointer_z = new QGraphicsLineItem( 1300, 0, 1330, 0 ); pointer_z->setPen( QPen(Qt::red) ); scene_xy->setBackgroundBrush( QBrush(QColor(0x33,0x33,0x33)) ); scene_xy->addItem(G_item_xy); scene_xy->addItem(pointer_xy); scene_xy->addItem(pointer_z); ui->gw_xy->setAlignment(Qt::AlignLeft); ui->gw_xy->setScene(scene_xy); // ui->gw_xy->setScene(scene_z); // init display Disp_Redraw(false); ticktimer = new QTimer( this ); connect(ticktimer, SIGNAL(timeout()), this, SLOT(TimerTick())); ticktimer->start( TIMER_INTERVAL ); client = NULL; comm = new QTcpServer(this); connect(comm, SIGNAL(newConnection()), SLOT(tcp_newConnection())); comm->listen(QHostAddress::Any, 4444); //--- test phase qsrand(0x64892354); main_entry( NULL ); }
//=========================>>> vTimer::tick <<<======================= void vTimer::tick(void) { // internal tick routine TimerTick(); // call the work routine }