public void error() { Trace.WriteLine("tp ==> In Function error."); //get the failure state STATE.states state = queue.Dequeue(); //if it is not fatal error, then try to fix it. //TO-DO //if it is fatal error queue.Enqueue(STATE.states.exit); try { BridgePowerOff(); } catch{ } try { BridgeCloseDevice(); } catch { } bridge = null; }
public void error() { Trace.WriteLine("tp ==> In Function error."); //get the failure state STATE.states state = queue.Dequeue(); //if it is not fatal error, then try to fix it. //TO-DO //if it is fatal error queue.Enqueue(STATE.states.exit); try { BridgePowerOff(); } catch { } try { BridgeCloseDevice(); } catch { } bridge = null; }
public void exit() { Trace.WriteLine("tp ==> In Function exit."); try { BridgePowerOff(); } catch { } try { BridgeCloseDevice(); } catch { } bridge = null; //generate event that this thread is dead. StateStatus(new StateMachineEventArgs(true, STATE.states.exit, "tp ==> exit")); }
//##################################################################################################// public void initialize() { Trace.WriteLine("tp ==> In Function initialize."); try { bridge = new USB_I2C_Bridge(); BridgeGetDevice(); StateStatus(new StateMachineEventArgs(true, STATE.states.initialize, "tp ==> init succeed")); } catch (Exception ex) { bridge = null; Trace.WriteLine("tp ==> Error: " + ex.Message); //not try to fix the error in this class, directly go to the erorr handler. queue.Clear(); queue.TrimExcess(); queue.Enqueue(STATE.states.error); queue.Enqueue(STATE.states.initialize); StateStatus(new StateMachineEventArgs(false, STATE.states.initialize, "tp ==> init failed: " + ex.Message)); } }
//##################################################################################################// public void initialize() { Trace.WriteLine("tp ==> In Function initialize."); try { bridge = new USB_I2C_Bridge(); BridgeGetDevice(); StateStatus(new StateMachineEventArgs(true, STATE.states.initialize, "tp ==> init succeed")); } catch (Exception ex) { bridge = null; Trace.WriteLine("tp ==> Error: " + ex.Message); //not try to fix the error in this class, directly go to the erorr handler. queue.Clear(); queue.TrimExcess(); queue.Enqueue(STATE.states.error); queue.Enqueue(STATE.states.initialize); StateStatus(new StateMachineEventArgs(false, STATE.states.initialize, "tp ==> init failed: " + ex.Message)); } }
public void exit() { Trace.WriteLine("tp ==> In Function exit."); try { BridgePowerOff(); } catch { } try { BridgeCloseDevice(); } catch { } bridge = null; //generate event that this thread is dead. StateStatus(new StateMachineEventArgs(true, STATE.states.exit, "tp ==> exit")); }