void _tiSearchDevicePort_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { //0231 (地址 3030) 3030 (校验 3339) 03 //新检测串口设备 //0230 (地址 3030) 3031 (数据) (校验 3339) 03 byte[] by = PortAgreement.GetSearchHost(1); for (int i = 0; i < 10; i++) { foreach (string item in _m_ComPort.PortNames) { _m_Port.PortName = item; try { _m_Port.Open(); _m_Port.Write(by); Thread.Sleep(500); if (_m_Port.IsOpen) { _tiSearchDevicePort.Stop(); _tiSearchDevicePort.Dispose(); _tiSearchDevicePort = null; return; } _m_Port.Close(); } catch { } } } }
private void PortHelper_SerialPortConnection(string portname) { if (PortHelper.IsConnection) { return; } PortHelper.sp.PortName = portname; try { PortHelper.sp.Open(); byte[] by = PortAgreement.GetDistanceEncryption(Dal_DevicePwd.DistanceSystemPassword.Pwd); PortHelper.sp.Write(by); by = null; Thread.Sleep(550); if (PortHelper.IsConnection) { return; } PortHelper.sp.Close(); Thread.Sleep(10); } catch { } }
private static void Host_PostTestPort(object sender, CfrV8HandlerExecuteEventArgs e) { try { if (SerialPortManager.Device2.SerialPortDevice.BaudRate != WinApi.B38400) { SerialPortManager.Device2.SerialPortDevice.SetBaudRate(WinApi.B38400); Thread.Sleep(10); } byte[] by = PortAgreement.TestPort(SerialPortManager.Device2Address); bool ret = SerialPortManager.WriteSerialPortData(SerialPortManager.Device2, by); if (ret) { ReceivedManager.SetReceivedFunction <TestPort>(); } e.SetReturnValue(ret); } catch (Exception ex) { SerialPortManager.Device2.SerialPortDevice.SetBaudRate(WinApi.B19200); Log4Helper.ErrorInfo(ex.Message, ex); ViewCallFunction.ViewAlert(ex.Message); } }
private static void Host_PostWirelessTest(object sender, Chromium.Remote.Event.CfrV8HandlerExecuteEventArgs e) { try { ReceivedManager.SetReceivedFunction <WirelessTest>(); byte[] by = PortAgreement.OpenTheDoorAndVoice(new OpenTheDoorParam2() { DeviceAddress = 0, IcCardNumber = "093D2446", LicensePlateNumber = "福A000000", LicensePlateColor = LicensePlateColors.Blue, Time = DateTime.Now, }); SerialPortManager.WriteSerialPortData(SerialPortManager.Device1, by); } catch (Exception ex) { Log4Helper.ErrorInfo(ex.Message, ex); ViewCallFunction.ViewAlert(ex.Message); } finally { OverTimeManager.Stop(); } }
private static void Host_RefreshOperation(object sender, Chromium.Remote.Event.CfrV8HandlerExecuteEventArgs e) { //刷新操作 CardManager.CardInfos.Clear(); byte[] bys; try { bys = PortAgreement.ReadAllCard(); bool ret = SerialPortManager.WriteSerialPortData(SerialPortManager.Device1, bys); if (ret) { ReceivedManager.SetReceivedFunction <CardRefresh>(); } e.SetReturnValue(ret); } catch (Exception ex) { Log4Helper.ErrorInfo(ex.Message, ex); ViewCallFunction.ViewAlert(ex.Message); } finally { bys = null; } }
/// <summary> /// 解锁 /// </summary> /// <param name="cardnumber"></param> /// <param name="flag"></param> private void UnlockDistanceCard(int flag) { try { StopTimeOutThread(); int index = -1; foreach (KeyValuePair <CbCardInfo, int> item in _mUnLockList) { index++; if (_mUnLockCardInfo != null && item.Key == _mUnLockCardInfo) { if (flag == 0) { item.Key.Unlocked = 0; Dbhelper.Db.Update <CbCardInfo>(item.Key); dgv_UnlockList["c_State", index].Value = Properties.Resources.check; OnLockChange(item); } _mUnLockCardInfo = null; continue; } if (_mUnLockCardInfo != null) { continue; } if (item.Key.Unlocked == 0) { continue; } _mUnLockCardInfo = item.Key; DistanceTypeParameter typeparam = new DistanceTypeParameter() { Lock = 0, Distance = item.Key.Distance }; int typebyte = DistanceCardHelper.SetCardTypeByte(typeparam, 1); byte[] by = PortAgreement.GetDistanceContent(item.Key.CardNumber, typebyte); PortHelper.SerialPortWrite(by); StartTimeOutThread(); return; } foreach (KeyValuePair <CbCardInfo, int> item in _mUnLockList) { if (item.Key.Unlocked != 0) { UseControlEnabled(); return; } } dgv_UnlockList.Rows.Clear(); this.DialogResult = DialogResult.OK; } catch (Exception ex) { UseControlEnabled(); CustomExceptionHandler.GetExceptionMessage(ex); MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void CloseModule() { byte[] by = PortAgreement.GetCloseModule(); if (PortHelper.IsConnection) { PortHelper.SerialPortWrite(by); Thread.Sleep(10); } }
public void DataReceived(byte[] by) { PortDataParameter param = DataParsing.Parsing(by); OverTimeManager.Stop(); try { if (param.Command.DCommand == PortEnums.DCommands.Default) { if (param.DistanceDeviceParam != null && param.DistanceDeviceParam.Command == PortEnums.DistanceCommands.InitializeDevice) { if (param.DistanceDeviceParam.AuxiliaryCommand == PortEnums.AuxiliaryCommands.Success) { if (!EncryptNewDevice) { byte[] bys = PortAgreement.DistanceCardEncryption(NewPwd); SerialPortManager.WriteSerialPortData(SerialPortManager.Device1, bys); EncryptNewDevice = true; OverTimeManager.Start(); return; } else { ViewCallFunction.ViewEncryptMessage("定距卡加密结束。"); ViewCallFunction.ViewEncryptOver(); } } else { ViewCallFunction.ViewEncryptMessage("定距卡加密失败,请重新操作。"); ViewCallFunction.ViewEncryptOver(); } EncryptNewDevice = false; } else if (param.DistanceCardParam != null && param.DistanceCardParam.Command == PortEnums.DistanceCommands.ModifyAllCardPwd) { if (param.DistanceCardParam.AuxiliaryCommand == PortEnums.AuxiliaryCommands.Success) { DistanceCardParameter distanceParam = param.DistanceCardParam; string msg = $"定距卡:{distanceParam.CardNumber} 密码(口令)加密{(distanceParam.CardTypeParameter.CardType != PortEnums.CardTypes.PwdError ? "成功" : "失败")}"; ViewCallFunction.ViewEncryptMessage(msg); } else { DeviceNewPwd(); } OverTimeManager.Start(); } } } catch (Exception ex) { Log4Helper.ErrorInfo(ex.Message, ex); ViewCallFunction.ViewEncryptOver(); ViewCallFunction.ViewAlert(ex.Message); } }
private void SetModuleComesBack(int value) { _isModuleSet = false; byte[] by = PortAgreement.GetSetModule(string.Format("AT+BACK={0}", value)); if (PortHelper.IsConnection) { PortHelper.SerialPortWrite(by); Thread.Sleep(150); } }
private void ModuleTest() { _isModuleSet = false; byte[] by = PortAgreement.GetSetModule("ABCDEF"); if (PortHelper.IsConnection) { PortHelper.SerialPortWrite(by); Thread.Sleep(150); } }
private void SetModuleTid(int id) { _isModuleSet = false; byte[] by = PortAgreement.GetSetModule(string.Format("AT+TID=01{0}", id.ToString().PadLeft(8, '0'))); if (PortHelper.IsConnection) { PortHelper.SerialPortWrite(by); Thread.Sleep(150); } }
private void SetModuleFrequency(int frequency) { _isModuleSet = false; frequency = 127 - (frequency * 2 - 1); byte[] by = PortAgreement.GetSetModule(string.Format("AT+FREQ={0:X2}", frequency)); if (PortHelper.IsConnection) { PortHelper.SerialPortWrite(by); Thread.Sleep(150); } }
private static void Host_PostStopReadIcCard(object sender, Chromium.Remote.Event.CfrV8HandlerExecuteEventArgs e) { try { byte[] by = PortAgreement.CloseModular(); SerialPortManager.WriteSerialPortData(SerialPortManager.Device1, by); } catch (Exception ex) { Log4Helper.ErrorInfo(ex.Message, ex); ViewCallFunction.ViewAlert(ex.Message); } }
private void OverEncrypt() { try { byte[] by = PortAgreement.IcDeviceEncryption(Pwd); SerialPortManager.WriteSerialPortData(SerialPortManager.Device1, by); ReceivedManager.SetReceivedFunction <IcDeviceEncrypt>(); } catch (Exception ex) { Log4Helper.ErrorInfo(ex.Message, ex); ViewCallFunction.ViewAlert(ex.Message); } }
private static void Host_PostIcDeviceEncrypt(object sender, Chromium.Remote.Event.CfrV8HandlerExecuteEventArgs e) { try { string pwd = e.Arguments[0].StringValue; byte[] bys = PortAgreement.IcDeviceEncryption(pwd); SerialPortManager.WriteSerialPortData(SerialPortManager.Device1, bys); ReceivedManager.SetReceivedFunction <IcDeviceEncrypt>(); } catch (Exception ex) { Log4Helper.ErrorInfo(ex.Message, ex); ViewCallFunction.ViewAlert(ex.Message); } }
private static void Host_PostDownloadTime(object sender, Chromium.Remote.Event.CfrV8HandlerExecuteEventArgs e) { try { byte[] bys = PortAgreement.SetPersonnelHostTime(); bool ret = SerialPortManager.WriteSerialPortData(SerialPortManager.Device2, bys); if (ret) { ReceivedManager.SetReceivedFunction <TimeDownload>(); } e.SetReturnValue(ret); } catch (Exception ex) { Log4Helper.ErrorInfo(ex.Message, ex); ViewCallFunction.ViewAlert(ex.Message); } }
private static void Host_PostReadIcCard(object sender, Chromium.Remote.Event.CfrV8HandlerExecuteEventArgs e) { try { byte[] by = PortAgreement.ReadIc(); SerialPortManager.WriteSerialPortData(SerialPortManager.Device1, by); ReceivedManager.SetReceivedFunction <ReadIcCard>(); } catch (Exception ex) { Log4Helper.ErrorInfo(ex.Message, ex); ViewCallFunction.ViewAlert(ex.Message); } finally { OverTimeManager.Stop(); } }
private void Btn_SerialPortConnection_Click(object sender, EventArgs e) { Tab4_Form.GetInstance.IsReadIcCard = false; if (PortHelper.sp.IsOpen) { try { PortHelper.sp.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } SerialPortChange(PortHelper.IsConnection); } else { PortHelper.sp.PortName = cb_SerialPortName.SelectedItem.ToString(); try { PortHelper.sp.Open(); PortHelper.SerialPortWrite(PortAgreement.GetDistanceEncryption(Dal_DevicePwd.DistanceSystemPassword.Pwd)); Thread.Sleep(600); if (!PortHelper.IsConnection) { PortHelper.sp.Close(); MessageBox.Show("当前端口连接失败,请选择正确的端口进行连接。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { SerialPortChange(PortHelper.IsConnection); } } catch (Exception ex) { CustomExceptionHandler.GetExceptionMessage(ex); MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private static void Host_PostDownloadNumber(object sender, Chromium.Remote.Event.CfrV8HandlerExecuteEventArgs e) { try { int index = e.Arguments[0].IntValue; UserInfo info = UserManager.UserInfos[index]; byte[] bys = PortAgreement.SetPersonnelHostNumber(info.UserNumber); bool ret = SerialPortManager.WriteSerialPortData(SerialPortManager.Device2, bys); if (ret) { ReceivedManager.SetReceivedFunction <NumberDownload>(); } e.SetReturnValue(ret); } catch (Exception ex) { Log4Helper.ErrorInfo(ex.Message, ex); ViewCallFunction.ViewAlert(ex.Message); } }
private static void Host_PostPersonnelRecovery(object sender, CfrV8HandlerExecuteEventArgs e) { try { string loseCardNumber = GetLoseNumber(e); List <CardInfo> list = CardManager.GetCardInfos(loseCardNumber); CardManager.LossLists = list; byte[] by = PortAgreement.ReadACard("797979", 1); bool ret = SerialPortManager.WriteSerialPortData(SerialPortManager.Device1, by); if (ret) { ReceivedManager.SetReceivedFunction <PersonnelCardLoss>(); } e.SetReturnValue(ret); } catch (Exception ex) { Log4Helper.ErrorInfo(ex.Message, ex); ViewCallFunction.ViewAlert(ex.Message); } }
private static void Host_PostDownloadPassword(object sender, Chromium.Remote.Event.CfrV8HandlerExecuteEventArgs e) { try { string oldpwd = e.Arguments[0].StringValue; string newpwd = e.Arguments[1].StringValue; byte[] by = PortAgreement.SetPersonnelHostPassword(oldpwd, newpwd); bool ret = SerialPortManager.WriteSerialPortData(SerialPortManager.Device2, by); if (ret) { ReceivedManager.SetReceivedFunction <PasswordDownload>(); } e.SetReturnValue(ret); } catch (Exception ex) { Log4Helper.ErrorInfo(ex.Message, ex); ViewCallFunction.ViewAlert(ex.Message); } }
private void btn_DownLoad_Click(object sender, EventArgs e) { _currentNumber = 1; if (tb_ID.Text.Length != 0) { _currentNumber = Convert.ToInt32(tb_ID.Text); if (_currentNumber == 0) { MessageBox.Show("ID 编号从1开始。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } } if (_currentNumber > 99999999) { MessageBox.Show("ID 编号已经超出可写范围(0 - 99999999)", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (_currentNumber < _mNumber.Number) { if (MessageBox.Show(string.Format(" ID 编号:{0}已经在使用中,是否重新下载写入。(当前流水编号:{1})", _currentNumber, _mNumber.Number), @"提示", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) != DialogResult.Yes) { return; } } btn_DownLoad.Image = null; btn_DownLoad.Enabled = false; tb_ID.Enabled = false; byte[] by = PortAgreement.SetModuleNumber(tb_ID.Text); _mPort.Write(by); if (_tOverTime == null) { _tOverTime = new System.Timers.Timer(5000); _tOverTime.AutoReset = false; _tOverTime.Elapsed += _tOverTime_Elapsed; _tOverTime.Start(); } }
/// <summary> /// 确认 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Btn_Enter_Click(object sender, EventArgs e) { string oldpwd = tb_OldPwd.Text.Trim(); if (oldpwd.Length != tb_OldPwd.MaxLength) { DisplayContent("旧口令长度为 6 位数字,请重新输入旧口令。"); tb_OldPwd.Focus(); return; } try { IsEnd = false; byte[] by = PortAgreement.GetDistanceEncryption(oldpwd); PortHelper.SerialPortWrite(by); p_Top.Enabled = false; } catch (Exception ex) { CustomExceptionHandler.GetExceptionMessage(ex); MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void SendUpdateNumberDeal(int number) { tb_DownLoadDescription.Text = string.Empty; ContentMessage("准备写入的数据。", Color.Black); try { byte[] by = PortAgreement.GetClientNumber(number); _m_Port.Write(by); ContentMessage("数据准备完成,发送数据。", Color.Black); if (_tiDelayTimeOut == null) { _tiDelayTimeOut = new System.Timers.Timer(2000); _tiDelayTimeOut.AutoReset = false; _tiDelayTimeOut.Elapsed += _tiDelayTimeOut_Elapsed; } _tiDelayTimeOut.Start(); } catch (Exception ex) { LimitControl(true); ContentMessage("错误内容:" + ex.Message, Color.Red); } }
private static void Host_PostDistanceCardEncrypt(object sender, Chromium.Remote.Event.CfrV8HandlerExecuteEventArgs e) { try { string oldpwd = e.Arguments[0].StringValue; string pwd = e.Arguments[1].StringValue; string clientnumber = e.Arguments[2].StringValue; byte[] bys = PortAgreement.DistanceDeviceEncryption(clientnumber, oldpwd); bool ret = SerialPortManager.WriteSerialPortData(SerialPortManager.Device1, bys); if (ret) { ReceivedManager.SetReceivedFunction <DistanceCardEncrypt>(); DistanceCardEncrypt received = ReceivedManager.GetReceivedFun <DistanceCardEncrypt>(); received.ClientNumber = clientnumber; received.NewPwd = pwd; } } catch (Exception ex) { Log4Helper.ErrorInfo(ex.Message, ex); ViewCallFunction.ViewAlert(ex.Message); } }
private static void Host_PostWirelessSetting(object sender, Chromium.Remote.Event.CfrV8HandlerExecuteEventArgs e) { try { int wirelessNumber = e.Arguments[0].IntValue; int frequency = e.Arguments[1].IntValue; Task.Factory.StartNew(() => { SettingModule settingModule = SettingReceived(); try { ViewCallFunction.ViewWirelessMessage("打开模块设置功能。"); byte[] by = PortAgreement.OpenModular(); SerialPortManager.WriteSerialPortData(SerialPortManager.Device1, by); Thread.Sleep(20); #region 设置模块发送ID for (int i = 0; i < 3; i++) { settingModule.SettingOver = false; ViewCallFunction.ViewWirelessMessage("设置模块发送ID(编号)。"); by = PortAgreement.SetModuleTid(wirelessNumber); SerialPortManager.WriteSerialPortData(SerialPortManager.Device1, by); Thread.Sleep(250); if (settingModule.SettingOver) { break; } } for (int i = 0; i < 3; i++) { settingModule.SettingOver = false; ViewCallFunction.ViewWirelessMessage("设置模块接收ID(编号)。"); by = PortAgreement.SetModuleRid(wirelessNumber); SerialPortManager.WriteSerialPortData(SerialPortManager.Device1, by); Thread.Sleep(250); if (settingModule.SettingOver) { break; } } for (int i = 0; i < 3; i++) { settingModule.SettingOver = false; ViewCallFunction.ViewWirelessMessage("设置模块频率。"); by = PortAgreement.SetModuleFrequency(frequency); SerialPortManager.WriteSerialPortData(SerialPortManager.Device1, by); Thread.Sleep(250); if (settingModule.SettingOver) { break; } } for (int i = 0; i < 3; i++) { settingModule.SettingOver = false; ViewCallFunction.ViewWirelessMessage("设置模块回传功能。"); by = PortAgreement.SetModuleComesBack(1); SerialPortManager.WriteSerialPortData(SerialPortManager.Device1, by); Thread.Sleep(250); if (settingModule.SettingOver) { break; } } ViewCallFunction.ViewWirelessMessage("关闭模块设置功能。"); by = PortAgreement.CloseModular(); SerialPortManager.WriteSerialPortData(SerialPortManager.Device1, by); Thread.Sleep(20); for (int i = 0; i < 3; i++) { settingModule.SettingOver = false; ViewCallFunction.ViewWirelessMessage("发送数据测试。"); by = PortAgreement.SetModular("ABCDEF"); SerialPortManager.WriteSerialPortData(SerialPortManager.Device1, by); Thread.Sleep(250); if (settingModule.SettingOver) { break; } } #endregion 设置模块发送ID } catch (Exception ex) { Log4Helper.ErrorInfo(ex.Message, ex); ViewCallFunction.ViewAlert(ex.Message); } finally { OverTimeManager.Stop(); ViewCallFunction.ViewWirelessOver(); } }); } catch (Exception ex) { Log4Helper.ErrorInfo(ex.Message, ex); ViewCallFunction.ViewAlert(ex.Message); } }
private static void Host_PostWirelessQuery(object sender, Chromium.Remote.Event.CfrV8HandlerExecuteEventArgs e) { try { Task.Factory.StartNew(() => { ReceivedManager.SetReceivedFunction <WirelessQuery>(); WirelessQuery queryReceived = ReceivedManager.GetReceivedFun <WirelessQuery>(); try { ViewCallFunction.ViewWirelessMessage("打开模块设置功能。"); byte[] by = PortAgreement.OpenModular(); SerialPortManager.WriteSerialPortData(SerialPortManager.Device1, by); Thread.Sleep(20); for (int i = 0; i < 3; i++) { queryReceived.SettingOver = false; ViewCallFunction.ViewWirelessMessage("关闭模块回传功能。"); by = PortAgreement.SetModuleComesBack(0); SerialPortManager.WriteSerialPortData(SerialPortManager.Device1, by); Thread.Sleep(250); if (queryReceived.SettingOver) { break; } } ViewCallFunction.ViewWirelessMessage("关闭模块设置功能。"); by = PortAgreement.CloseModular(); SerialPortManager.WriteSerialPortData(SerialPortManager.Device1, by); Thread.Sleep(20); ViewCallFunction.ViewWirelessMessage("查询无线ID(编号)。"); string strQueryFrequency = "AT+FREQ?"; by = PortAgreement.SetModular(strQueryFrequency); SerialPortManager.WriteSerialPortData(SerialPortManager.Device1, by); Thread.Sleep(250); ViewCallFunction.ViewWirelessMessage("查询无线的频率。"); string strQueryRid = "AT+TID?"; by = PortAgreement.SetModular(strQueryRid); SerialPortManager.WriteSerialPortData(SerialPortManager.Device1, by); Thread.Sleep(250); } catch (Exception ex) { Log4Helper.ErrorInfo(ex.Message, ex); ViewCallFunction.ViewAlert(ex.Message); } finally { OverTimeManager.Stop(); ViewCallFunction.ViewWirelessOver(); } }); } catch (Exception ex) { Log4Helper.ErrorInfo(ex.Message, ex); ViewCallFunction.ViewAlert(ex.Message); } }
/// <summary> /// 端口数据接收 /// </summary> /// <param name="param"></param> private void SerialPortDataReceived(ParsingParameter param) { if (!PortHelper.IsConnection) { return; } if (PortHelper.CurrentForm != this) { return; } this.Invoke(new EventHandler(delegate { try { if (param.FunctionAddress == 66) { long result = DataParsing.TemporaryContent(param.DataContent); switch (param.Command) { case 204: if (result == 0) { DisplayContent("临时 IC 卡加载成功。", Color.Black); } else { DisplayContent("临时 IC 卡加载失败,请确认旧密码是否正确或IC 卡是否放置在读写区域内。"); } SetDeviceNewPassword(); IsEnd = true; break; case 221: if (!IsEnd) { if (result == 0) { DisplayContent("临时 IC 设备初始化成功。", Color.Black); PortHelper.SerialPortWrite(PortAgreement.GetTemporaryICEncryption(Dal_IcDevicePwd.TempIcDevicePassword.Pwd)); } else { DisplayContent("临时 IC 设备初始化失败。"); p_Top.Enabled = true; } } else { if (result != 0) { SetDeviceNewPassword(); } else { p_Top.Enabled = true; } } break; } } } catch (Exception ex) { CustomExceptionHandler.GetExceptionMessage(ex); MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } })); }
private static void Host_PostWirelessSearch(object sender, Chromium.Remote.Event.CfrV8HandlerExecuteEventArgs e) { try { Task.Factory.StartNew(() => { SettingModule settingModule = SettingReceived(); OverTimeManager.Stop(); byte[] by; try { for (int i = 1; i <= 64; i++) { if (m_StopWirelessSearch) { break; } ViewCallFunction.ViewWirelessMessage($"搜索目标频率{i}/64。"); //ViewCallFunction.ViewWirelessMessage("打开模块设置功能。"); by = PortAgreement.OpenModular(); SerialPortManager.WriteSerialPortData(SerialPortManager.Device1, by); Thread.Sleep(20); for (int j = 0; j < 3; j++) { if (m_StopWirelessSearch) { break; } settingModule.SettingOver = false; ViewCallFunction.ViewWirelessMessage("设置模块频率。"); by = PortAgreement.SetModuleFrequency(i); SerialPortManager.WriteSerialPortData(SerialPortManager.Device1, by); Thread.Sleep(250); if (settingModule.SettingOver) { break; } } for (int j = 0; j < 3; j++) { if (m_StopWirelessSearch) { break; } settingModule.SettingOver = false; //ViewCallFunction.ViewWirelessMessage("设置模块回传功能。"); by = PortAgreement.SetModuleComesBack(1); SerialPortManager.WriteSerialPortData(SerialPortManager.Device1, by); Thread.Sleep(250); if (settingModule.SettingOver) { break; } } //ViewCallFunction.ViewWirelessMessage("关闭模块设置功能。"); by = PortAgreement.CloseModular(); SerialPortManager.WriteSerialPortData(SerialPortManager.Device1, by); Thread.Sleep(20); for (int j = 0; j < 3; j++) { if (m_StopWirelessSearch) { break; } settingModule.SettingOver = false; ViewCallFunction.ViewWirelessMessage("发送数据测试。"); by = PortAgreement.SetModular("ABCDEF"); SerialPortManager.WriteSerialPortData(SerialPortManager.Device1, by); Thread.Sleep(250); if (settingModule.SettingOver) { ViewCallFunction.ViewWirelessMessage($"无线频率 {i} 发现设备。"); break; } } } } catch (Exception ex) { Log4Helper.ErrorInfo(ex.Message, ex); ViewCallFunction.ViewAlert(ex.Message); } finally { m_StopWirelessSearch = false; ViewCallFunction.ViewWirelessOver(); } }); } catch (Exception ex) { Log4Helper.ErrorInfo(ex.Message, ex); ViewCallFunction.ViewAlert(ex.Message); } }
/// <summary> /// 设置设备新密码 /// </summary> private void SetDeviceNewPassword() { PortHelper.SerialPortWrite(PortAgreement.GetTemporaryEncryption(Dal_IcDevicePwd.TempIcDevicePassword.Pwd)); }