예제 #1
0
        void cmdTimeoutTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            ParamTimer timer        = (ParamTimer)sender;
            int        timeoutCount = (int)timer.Param["TimeoutCount"];

            if ((int)timer.Param["funcCode"] == (int)IAP_CMD.GET_SOFTWARE_VERSION)
            {
                Dictionary <string, object> dir = new Dictionary <string, object>();
                dir.Add("success", false);
                dir.Add("m_id", timer.Param["m_id"]);
                dir.Add("s_id", timer.Param["s_id"]);
                getDevVerHandler(dir);
                return;
            }
            if (++timeoutCount >= 3)//超时3次
            {
                timeoutCount = 0;
                Dictionary <string, object> dir = new Dictionary <string, object>();
                dir.Add("m_id", (int)timer.Param["m_id"]);
                dir.Add("EventType", EventType.CMD_SEND_FAILED);
                dir.Add("s_id", (int)timer.Param["s_id"]);
                dir.Add("funcCode", (int)timer.Param["funcCode"]);
                CommonEvent(dir);
            }
            else
            {
                int    m_id     = (int)timer.Param["m_id"];
                int    s_id     = (int)timer.Param["s_id"];
                int    funcCode = (int)timer.Param["funcCode"];
                byte[] cmdVal   = (byte[])timer.Param["cmdVal"];
                SendCmd(m_id, s_id, funcCode, cmdVal);
            }
            timer.Param["TimeoutCount"] = timeoutCount;
        }
예제 #2
0
 public CanUpdateManager()
 {
     serial                    = new SerialPort();
     serial.BaudRate           = 115200;
     serial.DataReceived      += serial_DataReceived;
     cmdTimeoutTimer           = new ParamTimer();
     cmdTimeoutTimer.AutoReset = false;
     cmdTimeoutTimer.Elapsed  += cmdTimeoutTimer_Elapsed;
 }