private void btnDisConnect_Click(object sender, EventArgs e) { chkAutoConnect.Enabled = true; chkAutoConnect.Checked = false; rtxtRes.AppendText(IniSettings.GetLanguageString("CONNECT: DisConnected.", "联机: 已经断开读卡器.")); Application.DoEvents(); //Thread.Sleep(100); if (SystemPub.ADRcp.bConnected) { SystemPub.ADRcp.DisConnect(); } }
private void ShowState(string messageCH, string messageEN, Label label, bool flag) { label.Text = IniSettings.GetLanguageString(messageEN, messageCH); if (flag) { label.ForeColor = Color.Green; } else { label.ForeColor = Color.Red; } Application.DoEvents(); }
/// <summary> /// 加载界面语言选择 /// </summary> public void LoadCommLanguage() { try { string[] m_def_en = new string[] { "Configuration", "Serial Interface", "Net Interface", "USB Interface", "PortName", "BaudRate", "Remote IP", "Remote Port" }; string[] m_def_cn = new string[] { "通讯参数配置", "串口通讯(RS232/RS485)", "网络通讯(TCP/WIFI)", "USB通讯(虚拟键盘/编程模式)", "串口选择", "波特率", "远程IP地址", "远程IP端口" }; string[] m_def_tw = new string[] { "通訊參數設定", "串口通訊(RS232/RS485)", "網絡通訊(TCP/WIFI)", "USB通訊(虛擬鍵盤/編程模式)", "串行埠選擇", "串行傳輸速率", "遠程IP地址", "遠程IP埠" }; string[] MainValue = IniSettings.LoadLanguage("sioconfig", m_def_en, m_def_cn, m_def_tw); int index = 0; this.Text = IniSettings.GetLanguageString("Select the device connection mode", "设备连接方式选择"); grbComm.Text = MainValue[index++]; rdbSerial.Text = MainValue[index++]; rdbNet.Text = MainValue[index++]; rdbUsb.Text = MainValue[index++]; rdbSerial.Font = rdbNet.Font = rdbUsb.Font = new Font(IniSettings.AppsFont.FontFamily, 9, FontStyle.Bold); grbSerial.Text = rdbSerial.Text; grbNet.Text = rdbNet.Text; grbUsb.Text = rdbUsb.Text; lblPortName.Text = MainValue[index++]; lblBaudRate.Text = MainValue[index++]; lblRemoteIP.Text = MainValue[index++]; lblRemotePort.Text = MainValue[index++]; } catch { } }
private void SetTcpip() { if (!RegexBase.IsIPv4(txtTCPIP.Text.ToString().Trim())) { MessageBox.Show(IniSettings.GetLanguageString("IP Address Error!", "IP地址错误!")); return; } if (!RegexBase.IsIPv4(txtTCPMask.Text.ToString().Trim())) { MessageBox.Show(IniSettings.GetLanguageString("Subnet Mask Error!", "子网掩码错误!")); return; } if (!RegexBase.IsIPv4(txtTCPGateway.Text.ToString().Trim())) { MessageBox.Show(IniSettings.GetLanguageString("GateWay Error!", "网关地址错误!")); return; } if (!RegexBase.IsMac(txtTCPMac.Text.ToString().Trim())) { MessageBox.Show(IniSettings.GetLanguageString("Mac Address Error!", "Mac地址错误!")); return; } if (!RegexBase.IsIPv4(txtRemoteIP.Text.ToString().Trim())) { MessageBox.Show(IniSettings.GetLanguageString("RemoteIP Address Error!", "RemoteIP地址错误!")); return; } TcpipParameters newTemp = GetTcpipParaInfo(); PassiveCommand.SetTcpip(SystemPub.ADRcp, newTemp.ToArray()); //if (!SystemPub.ADRcp.SendBytePkt(PassiveRcp.SetTcpip(SystemPub.ADRcp.Address, newTemp.ToArray()))) { } }
public void ParseRsp(ProtocolStruct Data) { switch (Data.Code) { case PassiveRcp.RCP_CMD_TCPIP: if (Data.Length > 0 && Data.Type == 0) { TcpipParameters bpiTemp = new TcpipParameters(); bpiTemp.AddRange(Data.Payload); ShowTcpipParaInfo(bpiTemp); } else if (Data.Type == 0) { string stren = "Set the IP parameters under the network connection need restart the equipment!"; string strcn = "设置IP参数需要重启设备!"; string aMsg = IniSettings.GetLanguageString(stren, strcn); MessageBox.Show(aMsg, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } break; case PassiveRcp.RCP_CMD_INFO: if (Data.Length > 0 && Data.Type == 0) { string strInfo = Encoding.ASCII.GetString(Data.Payload, 0, Data.Length); SystemPub.ADRcp.Mode = strInfo.Substring(18, 1); SystemPub.ADRcp.Version = strInfo.Substring(19, 5); SystemPub.ADRcp.Address = Convert.ToInt32(strInfo.Substring(29, 5)); txtOldAddr.Text = SystemPub.ADRcp.Address.ToString(); } else if (Data.Type == 0) { PassiveCommand.GetInformation(SystemPub.ADRcp); //if (!SystemPub.ADRcp.SendBytePkt(PassiveRcp.GetInformation())) { } } break; case PassiveRcp.RCP_CMD_SECRET: break; case PassiveRcp.RCP_CMD_SOFTRESET: break; case PassiveRcp.RCP_CMD_INITSYRIS: break; case PassiveRcp.RCP_CMD_REMOTE: break; case PassiveRcp.RCP_CMD_TIME: if (Data.Length > 0 && Data.Type == 0) { string y = Data.Payload[0].ToString("00"); string m = Data.Payload[1].ToString("00"); string d = Data.Payload[2].ToString("00"); string w = Data.Payload[3].ToString("00"); string h = Data.Payload[4].ToString("00"); string mi = Data.Payload[5].ToString("00"); string se = Data.Payload[6].ToString("00"); string D = string.Format("20{0}-{1}-{2} {3}:{4}:{5}", y, m, d, h, mi, se); //2010-02-28 14:48:03 txtReaderTime.Text = DateTime.Parse(D).ToString(); } break; } }
private void pDisplayStatusInfo(byte code, byte type, byte len) { bool blnStatus = (type == 0x21 || type == 0x00 || type == 0x32); string strStatus = blnStatus ? IniSettings.GetLanguageString("Success ", "成功 ") : IniSettings.GetLanguageString("Fail ", "失败 "); bool blnAction = len > 0; string strAction = IniSettings.GetLanguageString("Action ", "操作 "); string strType = ""; switch (code) { case PassiveRcp.RCP_CMD_INFO: strType = blnAction ? IniSettings.GetLanguageString("Information ", "基本信息 ") : IniSettings.GetLanguageString("Address ", "通讯地址 "); break; case PassiveRcp.RCP_CMD_ISO6B_RW: strType = "ISO6B "; break; case PassiveRcp.RCP_CMD_EPC_RW: strType = "EPC "; break; case PassiveRcp.RCP_CMD_ISO6B_IDEN: strType = IniSettings.GetLanguageString("ISO6B Identify ", "ISO6B 识别 "); break; case PassiveRcp.RCP_CMD_EPC_IDEN: strType = IniSettings.GetLanguageString("EPC Identify ", "EPC 识别 "); break; case PassiveRcp.RCP_CMD_EPC_MULT: strType = IniSettings.GetLanguageString("Mult EPC Identify ", "多卡识别 "); break; case PassiveRcp.RCP_CMD_PARA: strType = IniSettings.GetLanguageString("BASE Parameters ", "基本参数 "); break; case PassiveRcp.RCP_CMD_TCPIP: strType = IniSettings.GetLanguageString("TCPIP Parameters ", "TCPIP参数 "); break; case PassiveRcp.RCP_CMD_OUTCARD: strType = IniSettings.GetLanguageString("Output Type ", "输出参数 "); break; case PassiveRcp.RCP_CMD_SECRET: strType = IniSettings.GetLanguageString("Secret ", "加密操作 "); break; case PassiveRcp.RCP_CMD_SOFTRESET: strType = IniSettings.GetLanguageString("Soft reset ", "软重启 "); break; case PassiveRcp.RCP_CMD_INITSYRIS: strType = IniSettings.GetLanguageString("Init syris number ", "初始化SYRIS序号 "); break; case PassiveRcp.RCP_CMD_REMOTE: strType = IniSettings.GetLanguageString("Remote IO ", "远程IO操作 "); break; case PassiveRcp.RCP_CMD_TIME: strType = IniSettings.GetLanguageString("Time ", "设备时间 "); break; case PassiveRcp.RCP_CMD_WIFI_DOWNLOAD: strType = IniSettings.GetLanguageString("WIFI Para ", "WIFI参数... "); if (type == 0x00) { strStatus = IniSettings.GetLanguageString("Success ", "成功 "); } else { strStatus = type.ToString() + " " + IniSettings.GetLanguageString("Step ", "阶段 "); } blnStatus = true; break; default: break; } if (blnStatus) { tsStatusInfo.ForeColor = Color.Green; } else { tsStatusInfo.ForeColor = Color.Red; } tsStatusInfo.Text = strAction + strType + strStatus; }