示例#1
0
        /*
         * private void ProcessResponseData(CommandType command)
         * {
         * if (command.Error == (byte)ErrorCode.CRC_Wrong)
         * {
         * userSerial.Console.WriteLine("Request failed: wrong CRC", LogTextColor.Error);
         * return;
         * }
         * switch (command.Funtion & 0xF0)
         * {
         * case (byte)FuntionCode.DeviceFuntion:
         * break;
         * case (byte)FuntionCode.ConfigFuntion:
         * ProcessConfigcommand(command);
         * break;
         * case (byte)FuntionCode.TestFuntion:
         * break;
         * case (byte)FuntionCode.GSMFuntion:
         * ProcessGSMCommand(command);
         * break;
         * case (byte)FuntionCode.ServerFuntion:
         * break;
         * case (byte)FuntionCode.BatteryFuntion:
         * break;
         * default:
         * break;
         *
         * }
         * }
         */
        private void ProcessDeviceCommand(CommandType command)
        {
            this.Invoke(new Action(() =>
            {
                switch (command.Funtion)
                {
                case (byte)FuntionCode.DeviceConnect:
                    if (command.NumArgs == 0)
                    {
                        break;
                    }

                    if (DeviceConnectStatus == DeviceConnectEnum.RequestConnect)
                    {
                        if (command.Args[0] == (UInt16)DeviceConnectParam.ConnectUnderReset)
                        {
                            DeviceConnectStatus = DeviceConnectEnum.ConnectedUnderReset;
                            formProcess.closeDiablog(true);
                        }
                        else if (command.Args[0] == (UInt16)DeviceConnectParam.ConnectNomal)
                        {
                            DeviceConnectStatus = DeviceConnectEnum.ConnectedNomal;
                            formProcess.closeDiablog(true);
                        }
                        //lastConnect = DateTime.Now.Ticks;
                        connectTime.Update();
                    }
                    else
                    {
                        //lastConnect = DateTime.Now.Ticks;
                        //Console.WriteLine(lastConnect);
                        connectTime.Update();
                    }
                    break;

                case (byte)FuntionCode.DeviceDisconnect:
                    if (DeviceConnectStatus != DeviceConnectEnum.Diconnect)
                    {
                        DeviceConnectStatus = DeviceConnectEnum.Diconnect;
                    }
                    MessageBox.Show(this, "Device Disconnected!", "Infomation", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    SetMenuButton(MenuButtonIndex.Home);
                    break;

                case (byte)FuntionCode.DeviceReset:

                    break;

                default:
                    break;
                }
            }));
        }
示例#2
0
        private void UserSerial_ProcessTestCommand(CommandType command)
        {
            if (this.Enabled == false)
            {
                return;
            }
            //this.Invoke(new ProcessDataEventHandler(ProcessTestCommand));
            this.Invoke(new Action(() =>
            {
                if (command.NumArgs < 1)
                {
                    return;                      //khung loi - in thieu arg
                }
                connectTime.Update();
                lostTest = 0;
                if (command.Funtion == (byte)FuntionCode.TestResStatus)
                {
                    setTestConloseText((byte)command.Args[0], TestStatus.Testting);
                    connectTime.Lock = true;
                    testTimeOut      = false;
                    return;
                }
                if (command.Args[0] == 1)//wait status
                {
                    setTestConloseText(command.Funtion, TestStatus.Start);
                    setTestingMode(command.Funtion);
                    //connectTime.Lock = true;
                    testTimeOut = false;
                    //timer1.Start();
                    setTimerStatus(true, statusTimeoutDefault);
                }
                else if (command.Args[0] == 0xFF)//ens test
                {
                    if (command.Funtion == (byte)FuntionCode.TestPulseIn || command.Funtion == (byte)FuntionCode.TestPowerSensor)
                    {
                        setTestConloseText(command.Funtion, TestStatus.End, command.Args, 1, command.NumArgs - 1);
                        //connectTime.Lock = true;
                        testTimeOut = false;
                    }
                    else
                    {
                        setTestConloseText(command.Funtion, TestStatus.End, command.Args, 1, command.NumArgs - 1);
                        setTestingMode((byte)0);
                        setTimerStatus(false, 0);
                    }

                    /*
                     * setTestConloseText(command.Funtion, TestStatus.End, command.Args, 1, command.NumArgs - 1);
                     * setTestingMode((byte)0);
                     * setTimerStatus(false, 0);
                     */
                    //if(command.NumArgs >= 2)
                }

                /*
                 * switch (command.Funtion)
                 * {
                 *  case (byte)FuntionCode.TestResStatus:
                 *      if (command.NumArgs < 1) break;//loi khung
                 *      lostTest = 0;
                 *      if (command.Args[1] == 1)
                 *      {
                 *          setTestConloseText((byte)command.Args[0], TestStatus.Start);
                 *          //TestConsoleWrite("UI: > Start test GSM\n");
                 *          setTestingMode((byte)command.Args[0]);
                 *          connectTime.Lock = true;
                 *          testTimeOut = false;
                 *          timer1.Start();
                 *      }
                 *      else if (command.Args[1] == 2)
                 *      {
                 *          //TestConsoleWrite("UI: > GSM testing\n");
                 *          setTestConloseText((byte)command.Args[0], TestStatus.Testting);
                 *          connectTime.Lock = true;
                 *          testTimeOut = false;
                 *      }
                 *      if (command.Args[1] == 3)//end
                 *      {
                 *          //TestConsoleWrite("UI: > End test GSM\n");
                 *          setTestConloseText((byte)command.Args[0], TestStatus.End);
                 *          setTestingMode((byte)0);
                 *          connectTime.Lock = false;
                 *          timer1.Stop();
                 *      }
                 *      break;
                 *  case (byte)FuntionCode.TestGSM:
                 *      //TestConsoleWrite("UI: > API test GSM", LogTextColor.Information);
                 *      //if(command)
                 *      break;
                 *  case (byte)FuntionCode.TestPowerSensor:
                 *
                 *      break;
                 *  case (byte)FuntionCode.TestGPRS3G:
                 *      TestConsoleWrite("UI: > API test GPRS / 3G", LogTextColor.Information);
                 *      break;
                 *  case (byte)FuntionCode.TestSDCard:
                 *      break;
                 *  case (byte)FuntionCode.TestPulseIn:
                 *      break;
                 *  case (byte)FuntionCode.TestSensorOut:
                 *      break;
                 *  case (byte)FuntionCode.TestFlowSensor:
                 *      break;
                 *  case (byte)FuntionCode.TestPerformance:
                 *      break;
                 *  case (byte)FuntionCode.TestEraseExternalFlash:
                 *      break;
                 *  case (byte)FuntionCode.TestReadExternalFlash:
                 *      break;
                 *  default:
                 *      break;
                 * }
                 * connectTime.Update();
                 */
            }));
        }