Пример #1
0
        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;
        }
Пример #2
0
        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;
        }
Пример #3
0
        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"));
        }
Пример #4
0
        //##################################################################################################//


        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));
            }
        }
Пример #5
0
        //##################################################################################################//
        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));
            }
        }
Пример #6
0
        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"));
        }