public void Init() { int a = 0; eState = eTestState.initState; ewriststate = eWristState.WristUnknown; log = new CLog(); log.EnableLog = true; Msg("****** APP_START ******"); Msg("LogFilePath : " + log.GetLogFileNamePath()); mserial = new ClassSerial(); mserial.AssignCallBackFunction(ForClassSerialCallBack); mtask = new mAsyncTask(); mtask.AssignCallBackFunction(ForTaskCallBack); mtask.StartTask(); cmsmq = new CMsmqIPC(); cmsmq.AssignCallBackFunction(ForCMsmqCallBack); cmsmq.SetRole(eRole.IamSerialPart); wlogin = new WindowsLoginLib(); wlogin.AssignCallBackFunction(ForWindowsLoginCallBack); wlogin.Init(); }
private void ForClassSerialCallBack(string inStr) { inStr = inStr.Trim(); Msg("ClassSerial:" + inStr); if (inStr.Equals("UsbCableUnplug;") && eState != eTestState.USBUnPlug) { this.SendMsmqMsg("UsbCableUnplug"); eState = eTestState.USBUnPlug; ewriststate = eWristState.WristUnknown; } if (inStr.Equals("UsbCablePlugIn;") && (eState != eTestState.USBInitWait)) { this.SendMsmqMsg("UsbCablePlugIn"); eState = eTestState.USBPlugIn; } if (inStr.Contains("SerialDataReceived;")) { } if (eState == eTestState.USBInitWait) { if (inStr.Contains("COMPORT_OPEN_SUCCESS")) { Msg("InitUSBSucess;"); GetWristStrapState(); eState = eTestState.USBInitSuccess; } if (inStr.Contains("COMPORT_NUMBER_NOT_FOUND")) { Msg("InitUSBFail;"); SendMsmqMsg("InitUSBFail"); eState = eTestState.USBInitFail; } } }
private void ForTaskCallBack(string taskResult) { System.Threading.Thread.Sleep(10); // Process Serial Query If have, at here if (!mserial.queryDone) { if (mserial.strRx.Count > 0) { mserial.ProcessQuery(mserial.strRx[0]); } else { mserial.ProcessQuery("null"); } } if (taskResult.Length > 0) { Msg("ForTaskCallBack:" + taskResult); } if (mserial.strRx.Count > 0) { string sres = mserial.strRx[0]; Msg("ClassSerial:Rx:" + mserial.strRx[0]); if ((sres.Contains("WristOn") == true) && (ewriststate != eWristState.WristOn)) { ewriststate = eWristState.WristOn; } if ((sres.Contains("WristOff")) && (ewriststate != eWristState.WristOff)) { // this.SendMsmqMsg("UsbCableUnplug"); ewriststate = eWristState.WristOff; } // consume here SendMsmqMsg(mserial.strRx[0]); mserial.strRx.RemoveAt(0); } //Console.WriteLine("test c=" +c.ToString()); //log.LogWrite("test c=" + c.ToString()); switch (eState) { case eTestState.initState: Msg("InitState;"); eState = eTestState.USBInit; break; case eTestState.USBInit: Msg("InitUSB;"); eState = eTestState.USBInitWait; mserial.Init(); break; case eTestState.USBInitSuccess: break; case eTestState.appExit: mtask.StopTask(); break; case eTestState.USBPlugIn: Msg("InitAfterUsbPlugIn;"); eState = eTestState.USBInitWait; mserial.Init(); break; } }