private void ThreadReadInfo() { while (!m_bAlive && SystemPub.ADSio.bConnected) { System.Threading.Thread.Sleep(20); // Protocol Parameters if (!PassiveCommand.GetInformation(SystemPub.ADRcp)) //if (!SystemPub.ADRcp.SendBytePkt(SystemPub.ADRcp.BuildCmdPacketByte(PassiveRcp.RCP_MSG_GET, PassiveRcp.RCP_CMD_INFO, null))) { mReadInfoCount++; if (mReadInfoCount > 3) { mReadInfoCount = 0; if (m_bStopComm) { break; } SwitchPortAndBaud(); } continue; } mReadInfoCount = 0; System.Threading.Thread.Sleep(100); // this.tsStatusInfo.Text = " Ready.."; } System.Console.WriteLine(" End ThreadReadInfo()"); }
private void tmrClock_Tick(object sender, EventArgs e) { if (SystemPub.ADRcp.CommMode == ADSDK.Device.CommMode.ACTIVE) { if (btnStart.Visible) { btnStart.Visible = false; } } else { if (!btnStart.Visible) { btnStart.Visible = true; } } if (IsStart) { if (IniSettings.Communication == CommType.USB) { PassiveCommand.Identify6C(SystemPub.ADRcp); //if (!SystemPub.ADRcp.SendBytePkt(PassiveRcp.Identify6C(SystemPub.ADRcp.Address))) { } } else { PassiveCommand.Identify6CMult(SystemPub.ADRcp); //if (!SystemPub.ADRcp.SendBytePkt(PassiveRcp.Identify6CMult(SystemPub.ADRcp.Address))) { } } } }
private void btnIO2Close_Click(object sender, EventArgs e) { ((Button)sender).Enabled = false; Application.DoEvents(); PassiveCommand.Remote(SystemPub.ADRcp, 2, 0); //if (!SystemPub.ADRcp.SendBytePkt(PassiveRcp.SetRemote(SystemPub.ADRcp.Address, 2,0))) { } ((Button)sender).Enabled = true; }
private void btnAddress_Click(object sender, EventArgs e) { ((Button)sender).Enabled = false; Application.DoEvents(); PassiveCommand.SetAddress(SystemPub.ADRcp, Convert.ToInt32(utxtNewAddr.Text)); //if (!SystemPub.ADRcp.SendBytePkt(PassiveRcp.SetAddress(SystemPub.ADRcp.Address, Convert.ToInt32(utxtNewAddr.Text)))) { } ((Button)sender).Enabled = true; }
private void btnGetTime_Click(object sender, EventArgs e) { txtNowTime.Text = txtReaderTime.Text = ""; ((Button)sender).Enabled = false; Application.DoEvents(); PassiveCommand.GetTime(SystemPub.ADRcp); //if (!SystemPub.ADRcp.SendBytePkt(PassiveRcp.GetTime(SystemPub.ADRcp.Address))) { } ((Button)sender).Enabled = true; }
private void btnIdentify_Click(object sender, EventArgs e) { btnIdentify.Enabled = false; utxtCard.Value = ""; Application.DoEvents(); PassiveCommand.Identify6C(SystemPub.ADRcp); //if (!SystemPub.ADRcp.SendBytePkt(PassiveRcp.Identify6C(SystemPub.ADRcp.Address))) { } btnIdentify.Enabled = true; }
private void dispatcherTimer_Tick(object sender, EventArgs e) { if (IsStart & !m_bStopComm) { DoEvents(); //CardID.Text = ""; //Application.DoEvents(); PassiveCommand.Identify6C(SystemPub.ADRcp); //PassiveCommand.Identify6CMult(SystemPub.ADRcp); } }
private void btnRead_Click(object sender, EventArgs e) { ActionType = WRITETYPE.DATA; btnRead.Enabled = false; utxtReadData.Value = ""; Application.DoEvents(); byte mem = Convert.ToByte(cmbReadBlock.SelectedIndex); byte state = Convert.ToByte(ltxtReadAddress.Text); byte len = Convert.ToByte(ltxtReadLength.Text); PassiveCommand.Read6C(SystemPub.ADRcp, mem, state, len); //if (!SystemPub.ADRcp.SendBytePkt(PassiveRcp.Read6C(SystemPub.ADRcp.Address, mem, state, len))) { } btnRead.Enabled = true; }
private void btnWrite_Click(object sender, EventArgs e) { btnWrite.Enabled = false; byte state = Convert.ToByte(ltxtWriteAddress.Text); byte len = Convert.ToByte(ltxtWriteLength.Text); byte[] sndData = ConvertData.HexStringToByteArray(utxtWriteData.Text.Replace("-", "")); PassiveCommand.Write6B(SystemPub.ADRcp, state, len, sndData); //if (!SystemPub.ADRcp.SendBytePkt(PassiveRcp.Write6B(SystemPub.ADRcp.Address, state, len, sndData))) { } btnWrite.Enabled = true; }
private void btnRead_Click(object sender, EventArgs e) { btnRead.Enabled = false; utxtReadData.Value = ""; Application.DoEvents(); byte state = Convert.ToByte(ltxtReadAddress.Text); byte len = Convert.ToByte(ltxtReadLength.Text); PassiveCommand.Read6B(SystemPub.ADRcp, state, len); //if (!SystemPub.ADRcp.SendBytePkt(PassiveRcp.Read6B(SystemPub.ADRcp.Address, state, len))) { } btnRead.Enabled = true; }
private void btnWrite_Click(object sender, EventArgs e) { ActionType = WRITETYPE.DATA; btnWrite.Enabled = false; byte mem = Convert.ToByte(cmbWriteBlock.SelectedIndex); byte state = Convert.ToByte(ltxtWriteAddress.Text); byte len = Convert.ToByte(ltxtWriteLength.Text); byte[] sndData = ConvertData.HexStringToByteArray(utxtWriteData.Text.Replace("-", "")); PassiveCommand.Write6C(SystemPub.ADRcp, mem, state, len, sndData); //if (!SystemPub.ADRcp.SendBytePkt(PassiveRcp.Write6C(SystemPub.ADRcp.Address, mem, state, len, sndData))) { } btnWrite.Enabled = true; }
private void syncParameters() { processing = true; System.Threading.Thread.Sleep(20); // Protocol Parameters PassiveCommand.GetConfig(SystemPub.ADRcp); //if (!SystemPub.ADRcp.SendBytePkt(PassiveRcp.GetConfig(SystemPub.ADRcp.Address))) { } System.Threading.Thread.Sleep(20); if (IniSettings.Communication != IniSettings.CommType.USB) { PassiveCommand.GetTcpip(SystemPub.ADRcp); //if (!SystemPub.ADRcp.SendBytePkt(PassiveRcp.GetTcpip(SystemPub.ADRcp.Address))) { } } processing = false; }
private void btnSetTime_Click(object sender, EventArgs e) { txtNowTime.Text = txtReaderTime.Text = ""; DateTime dtNow = DateTime.Now; byte[] dtTemp = new byte[7]; dtTemp[0] = (byte)(dtNow.Year % 200); dtTemp[1] = (byte)dtNow.Month; dtTemp[2] = (byte)dtNow.Day; dtTemp[3] = (byte)dtNow.DayOfWeek; dtTemp[4] = (byte)dtNow.Hour; dtTemp[5] = (byte)dtNow.Minute; dtTemp[6] = (byte)dtNow.Second; ((Button)sender).Enabled = false; Application.DoEvents(); PassiveCommand.SetTime(SystemPub.ADRcp, dtTemp); //if (!SystemPub.ADRcp.SendBytePkt(PassiveRcp.SetTime(SystemPub.ADRcp.Address, dtTemp))) { } ((Button)sender).Enabled = true; }
private void btnInitSyris_Click(object sender, EventArgs e) { List <byte> lstByte = new List <byte>(); byte[] bytSN = Encoding.ASCII.GetBytes(txtSyrisSN.Text); lstByte.AddRange(bytSN); bytSN = Encoding.ASCII.GetBytes((cmbSyrisID.SelectedIndex + 1).ToString()); lstByte.AddRange(bytSN); byte[] bytOther = new byte[10]; lstByte.AddRange(bytOther); byte[] bytResult = lstByte.ToArray(); ((Button)sender).Enabled = false; Application.DoEvents(); PassiveCommand.InitSyris(SystemPub.ADRcp, lstByte.ToArray()); //if (!SystemPub.ADRcp.SendBytePkt(PassiveRcp.InitSyris(SystemPub.ADRcp.Address, lstByte.ToArray()))) { } ((Button)sender).Enabled = true; }
private void btnWriteAscii_Click(object sender, EventArgs e) { ActionType = WRITETYPE.DATA; btnWriteAscii.Enabled = false; byte[] bytData = Encoding.GetEncoding("gb2312").GetBytes(txtWriteAscii.Text.Trim()); byte[] sndData = new byte[12]; for (int i = 0; i < 8; i++) { sndData[i] = bytData[i]; } for (int i = 8; i < 12; i++) { sndData[i] = 0; } PassiveCommand.Write6C(SystemPub.ADRcp, 1, 2, 12, sndData); //if (!SystemPub.ADRcp.SendBytePkt(PassiveRcp.Write6C(SystemPub.ADRcp.Address, 1, 2, 12, sndData))) { } btnWriteAscii.Enabled = true; }
public void ParseRsp(ProtocolStruct Data) { switch (Data.Code) { case PassiveRcp.RCP_CMD_PARA: if (Data.Length > 0 && Data.Type == 0) { PBasicParameters ppTemp = new PBasicParameters(); ppTemp.AddRange(Data.Payload); ShowBasicParametersPnfo(ppTemp); SystemPub.ADRcp.CommMode = ppTemp.WorkMode == 2 ? CommMode.ACTIVE : CommMode.PASSIVE; if (IniSettings.Communication == CommType.USB) { PassiveCommand.GetOutCard(SystemPub.ADRcp); //if (!SystemPub.ADRcp.SendBytePkt(PassiveRcp.GetOutCard(SystemPub.ADRcp.Address))) { } } } else if (Data.Type == 0) { SystemPub.ADRcp.CommMode = cmbWorkMode.SelectedIndex == 1 ? CommMode.ACTIVE : CommMode.PASSIVE; if (IniSettings.Communication == CommType.USB || grbOutType.Visible) { PassiveCommand.SetOutCard(SystemPub.ADRcp, new byte[] { (byte)(cmbOutType.SelectedIndex + 1), (byte)((cmbOutLen.SelectedIndex * 2) + 6), (byte)(chkEnter.Checked ? 1 : 0) }); //if (!SystemPub.ADRcp.SendBytePkt(PassiveRcp.SetOutCard(SystemPub.ADRcp.Address, (byte)(cmbOutType.SelectedIndex + 1), (byte)((cmbOutLen.SelectedIndex*2) + 6), (byte)(chkEnter.Checked ? 1 : 0)))) { } } } break; case PassiveRcp.RCP_CMD_OUTCARD: if (Data.Length > 0) { cmbOutType.SelectedIndex = Data.Payload[0] - 1; cmbOutLen.Text = Data.Payload[1].ToString(); chkEnter.Checked = Data.Payload[2] > 0 ? true : false; } break; } }
private void WriteCard() { ActionType = WRITETYPE.CARD; try { byte[] SendDataBuff = ConvertData.DecLongToByteArray(LngSendData, IniSettings.WriteMode > 0); if (chkAddHex.Checked) { if (IniSettings.WriteMode > 0) { SendDataBuff = ConvertData.HexStringToByteArray(LngSendData.ToString("00000000")); } else { SendDataBuff = ConvertData.HexStringToByteArray(LngSendData.ToString("000000")); } } else { SendDataBuff = ConvertData.DecLongToByteArray(LngSendData, IniSettings.WriteMode > 0); } byte[] SendData = new byte[intlen]; for (int i = intpoint; i < intlen; i++) { try { SendData[i] = SendDataBuff[i - intpoint]; } catch { } } PassiveCommand.Write6C(SystemPub.ADRcp, 1, (byte)intAddr, (byte)intlen, SendData); //if (!SystemPub.ADRcp.SendBytePkt(PassiveRcp.Write6C(SystemPub.ADRcp.Address, 1, (byte)intAddr, (byte)intlen, SendData))) { } } 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 GetTcpip() { PassiveCommand.GetTcpip(SystemPub.ADRcp); //if (!SystemPub.ADRcp.SendBytePkt(PassiveRcp.GetTcpip(SystemPub.ADRcp.Address))) { } }
private void ReadCard() { ActionType = WRITETYPE.CARD; PassiveCommand.Read6C(SystemPub.ADRcp, 1, (byte)intAddr, (byte)intlen); //if (!SystemPub.ADRcp.SendBytePkt(PassiveRcp.Read6C(SystemPub.ADRcp.Address, 1, (byte)intAddr, (byte)intlen))) { } }
private void SecretCard() { PassiveCommand.Secret(SystemPub.ADRcp); //if (!SystemPub.ADRcp.SendBytePkt(PassiveRcp.SetSecret(SystemPub.ADRcp.Address))) { } }
private void tsmiInfo_Click(object sender, EventArgs e) { PassiveCommand.GetInformation(SystemPub.ADRcp); }
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 btnSetKeyboard_Click(object sender, EventArgs e) { PassiveCommand.SetKeyboard(SystemPub.ADRcp); //if (!SystemPub.ADRcp.SendBytePkt(PassiveRcp.SetUsbPara(65535, new byte[] { 5, 5 }))) { } }
private void btnSetPara_Click(object sender, EventArgs e) { PassiveCommand.SetConfig(SystemPub.ADRcp, GetBasicParametersPnfo().ToArray()); //if (!SystemPub.ADRcp.SendBytePkt(PassiveRcp.SetConfig(SystemPub.ADRcp.Address, GetBasicParametersPnfo().ToArray()))) { } }
private void btnGetPara_Click(object sender, EventArgs e) { PassiveCommand.GetConfig(SystemPub.ADRcp); //if (!SystemPub.ADRcp.SendBytePkt(PassiveRcp.GetConfig(SystemPub.ADRcp.Address))) { } }