/// <summary> /// 初始化 /// </summary> /// <param name="gsmModem"></param> public SimGSMMsg(GsmModem gsmModem) { // 初始化. srv = gsmModem; this._conQuSendMsg = new ConcurrentQueue <TMsg>(); _quSendMsgThread = new Thread(new ThreadStart(QuSendMsg)); }
//重启短信猫 private void ReStartService() { LogHelpers.Error("GMS服务开始重启"); try { srv.Close(); IsOpen = false; } catch (Exception e) { string exMsg = string.Format("GMS服务重启时关闭失败:{0}\n{1}", e.Message, e.StackTrace); LogHelpers.Error(exMsg); } try { // 初始化. GsmModem newSrv = new GsmModem(); newSrv.AutoDelMsg = srv.AutoDelMsg; newSrv.ComPort = srv.ComPort; newSrv.BaudRate = srv.BaudRate; // 启动服务... string sResult = ""; IsOpen = newSrv.Open(out sResult); if (!IsOpen) { LogHelpers.Error("GMS开启服务失败:" + sResult); return; } srv = newSrv; LogHelpers.Error("GMS服务重启成功"); } catch (Exception e) { string exMsg = string.Format("GMS服务重启失败:{0}\n{1}", e.Message, e.StackTrace); LogHelpers.Error(exMsg); } }