int main(int cszArg, char * rgszArg[]) { /* Parse paramaters */ if(!FParseParams(cszArg, rgszArg)) { return 1; } /* Initialization routine */ if(!FInit()) { printf("Error: Initialization failed\n"); return 1; } /* Perform various program actions */ if( fPulseWidth ) { DoPulseWidth(); } if( fAbsolutePos ) { DoAbsolutePos(); } if( fRelativePos ) { DoRelativePos(); } if( fVelocity ) { DoVelocity(); } /* Program termination */ DoTerminate(); return 0; }
void BetProcedureFrame::HandlerSwitchChange(const std::string& reply, CProtocolCommand& command) { int releta = command.data().releta; if (switch1_ != SW_FAILURE) { switch1_ = releta & 0x1; m_bmpInd1->SetBitmap(switch1_ ? lightG_ : lightS_); } if (switch2_ != SW_FAILURE) { if (releta & 0x2) switch2_ = SW_ON; else switch2_ = SW_OFF; m_bmpInd2->SetBitmap(switch2_ ? lightG_ : lightS_); } if (switch3_ != SW_FAILURE) { if (releta & 0x4) switch3_ = SW_ON; else switch3_ = SW_OFF; m_bmpInd3->SetBitmap(switch3_ ? lightG_ : lightS_); } if (switch4_ != SW_FAILURE) { if (releta & 0x8) switch4_ = SW_ON; else switch4_ = SW_OFF; m_bmpInd4->SetBitmap(switch4_ ? lightG_ : lightS_); } if (switch5_ != SW_FAILURE) { if (releta & 0x10) switch5_ = SW_ON; else switch5_ = SW_OFF; m_bmpInd5->SetBitmap(switch5_ ? lightG_ : lightS_); } if (switch6_ != SW_FAILURE) { if (releta & 0x20) switch6_ = SW_ON; else switch6_ = SW_OFF; m_bmpInd6->SetBitmap(switch6_ ? lightG_ : lightS_); } polarity_ = releta & 0x40; m_button8->SetBackgroundColour(polarity_ ? wxColor(255, 0, 0) : wxColor(0, 255, 0)); //if all switches happen to be OFF and we are in procedure DoTerminate if (((switch1_ == SW_OFF || switch1_ == SW_FAILURE) && (switch2_ == SW_OFF || switch2_ == SW_FAILURE) && (switch3_ == SW_OFF || switch3_ == SW_FAILURE) && (switch4_ == SW_OFF || switch4_ == SW_FAILURE) && (switch5_ == SW_OFF || switch5_ == SW_FAILURE) && (switch6_ == SW_OFF || switch6_ == SW_FAILURE)) && (state_ == STATE_RUNNING || state_ == STATE_FINISHING)) { DoTerminate(); } }
void BetProcedureFrame::updateKeyChannel(int status) { bool problem = false; if (0x4 & status) { //KEY switch (0x3 & status) { case 0: key_ = KEY_SHORT; m_txtKey->SetLabel("Short"); m_txtKey->SetForegroundColour(wxColor(255, 0, 0)); problem = true; break; case 1: key_ = KEY_ON; m_txtKey->SetLabel("On"); m_txtKey->SetForegroundColour(wxColor(255, 0, 0)); problem = true; break; case 2: key_ = KEY_OFF; m_txtKey->SetLabel("Off"); m_txtKey->SetForegroundColour(wxColor(0, 255, 0)); break; case 3: key_ = KEY_BREAK; m_txtKey->SetLabel("Break"); m_txtKey->SetForegroundColour(wxColor(255, 0, 0)); problem = true; break; } } else { m_txtKey->SetLabel("Out"); m_txtKey->SetForegroundColour(wxColor(255, 0, 0)); problem = true; } if (0x8 & status) { //CABLE cable_ = CABLE_OUT; m_txtCable->SetLabel("Out"); m_txtCable->SetForegroundColour(wxColor(255, 0, 0)); problem = true; } else { cable_ = CABLE_IN; m_txtCable->SetLabel("In"); m_txtCable->SetForegroundColour(wxColor(0, 255, 0)); } if(problem && (state_ == STATE_RUNNING || state_ == STATE_FINISHING)){ DoTerminate(); boost::thread(bind(&BetProcedureFrame::showMessage, std::string("Error"), std::string("Check Key or Cable"))); } }
// termination int Application::Terminate(int val) { StartTrace(Application.Terminate); String m(50); m << "\tTerminating <" << fName << ">" << "\n"; SystemLog::WriteToStderr(m); int iRetVal = DoTerminate(val); m.Trim(0); m << "\tTerminating <" << fName << "> done\n"; SystemLog::WriteToStderr(m); return iRetVal; }
int LeaderFollowerPool::Terminate(long lWaitToTerminate, long lWaitOnJoin) { StartTrace(LeaderFollowerPool.Terminate); int result = DoTerminate(lWaitToTerminate); fTerminated = true; if (result == 0) { LockUnlockEntry me(fLFMutex); fPoolState = Thread::eTerminated; // need to delete objects before unloading dlls if (fReactor) { Trace("deleting reactor"); delete fReactor; fReactor = 0; } Trace("LFPool termination done"); } else { SYSERROR("still " << result << " LeaderFollowerThreads in termination!"); } return result; }
void BetProcedureFrame::OnClose(wxCloseEvent& event) { if (event.CanVeto()) { if (state_ == STATE_RUNNING || state_ == STATE_FINISHING) { wxMessageBox("Cannot exit while procedure is running", "Finish", wxOK, this); return; } } my_timer_.Stop(); if (state_ == STATE_RUNNING || state_ == STATE_FINISHING) { //finish prematurely DoTerminate(); } protocol_.stop(); wxGetApp().setProcedureFrame(nullptr); MainFrame* mainFrame = static_cast<MainFrame*>(GetParent()); mainFrame->OnProcedureFinished(); Destroy(); }
void BetProcedureFrame::OnKeyEvent(wxKeyEvent& event) { int code = event.GetKeyCode(); bool special = false; //set focus if (code == 'v' || code == 'V') { m_txtVoltage->SetFocus(); special = true; } if (code == 'd' || code == 'D') { m_txtDuration->SetFocus(); special = true; } if (code == 'c' || code == 'C') { m_txtCurrent->SetFocus(); special = true; } //switches if (code >= 0x154 && code <= 0x159 && state_ == STATE_INITIAL) { DoSwitchChange(code - 0x154); //0...5 special = true; } //currents limit if (code >= 0x31 && code <= 0x36 && event.ControlDown()) { int cur = code - 0x31; switch (cur) { case 0: m_txtLimitCur1->SetFocus(); break; case 1: m_txtLimitCur2->SetFocus(); break; case 2: m_txtLimitCur3->SetFocus(); break; case 3: m_txtLimitCur4->SetFocus(); break; case 4: m_txtLimitCur5->SetFocus(); break; case 5: m_txtLimitCur6->SetFocus(); break; } special = true; } //start procedure if (code == 's' || code == 'S') { if (state_ == STATE_INITIAL && validate()) DoStart(); if (state_ == STATE_RUNNING) DoGoInFinishing(); special = true; } //increase values if ((code == 0x184 || code == 0x3d) && state_ == STATE_RUNNING) { //'+' wxWindow* focusWnd = wxWindow::FindFocus(); if (focusWnd == m_txtVoltage) { float value = std::atof(m_txtVoltage->GetValue()) + VOLTAGE_LOW_INCREMENT; if (value > VOLTAGE_LIMIT) value = VOLTAGE_LIMIT; DoUpdateVoltage(value); } if (focusWnd == m_txtCurrent) { int value = std::atoi(m_txtCurrent->GetValue()) + CURRENT_INCREMENT; if (value > CURRENT_LIMIT) value = CURRENT_LIMIT; DoUpdateCurrent(value); } if (focusWnd == m_txtDuration) { int value = std::atoi(m_txtDuration->GetValue()) * 60 + DURATION_INCREMENT; if (value > DURATION_LIMIT) value = DURATION_LIMIT; DoUpdateDuration(value); } special = true; } //decrease values if ((code == 0x2d) && state_ == STATE_RUNNING) { //'-' wxWindow* focusWnd = wxWindow::FindFocus(); if (focusWnd == m_txtVoltage) { float value = std::atof(m_txtVoltage->GetValue()) - VOLTAGE_LOW_DECREMENT; if (value < 0) value = 0; DoUpdateVoltage(value); } if (focusWnd == m_txtCurrent) { int value = std::atoi(m_txtCurrent->GetValue()) - CURRENT_DECREMENT; if (value < 0) value = 0; DoUpdateCurrent(value); } if (focusWnd == m_txtDuration) { int value = std::atoi(m_txtDuration->GetValue()) * 60 - DURATION_DECREMENT; if (value < 0) value = 0; DoUpdateDuration(value); } special = true; } if ((code == 'P' || code == 'p') && state_ == STATE_INITIAL) { DoPolarityChange(); special = true; } if ((code == 'E' || code == 'e') && state_ != STATE_INITIAL) { DoTerminate(); special = true; } if (state_ != STATE_INITIAL) special = true; event.Skip(special); }
void BetProcedureFrame::OnStop(wxCommandEvent& event) { DoTerminate(); }
bool TerminationPolicy::Terminate(Registry *r) { StartTrace(TerminationPolicy.Terminate); bool bRet = DoTerminate(r); bRet = IntFinalize(r) && bRet; return bRet; }