private void ReadCard() { ActionType = WRITETYPE.CARD; if (!SystemPub.ADRcp.SendBytePkt(PassiveRcp.Read6C(SystemPub.ADRcp.Address, 1, (byte)intAddr, (byte)intlen))) { } }
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 (UserSettings.Communication == UserSettings.CommType.USB) { if (!SystemPub.ADRcp.SendBytePkt(PassiveRcp.Identify6C(SystemPub.ADRcp.Address))) { } } else { if (!SystemPub.ADRcp.SendBytePkt(PassiveRcp.Identify6CMult(SystemPub.ADRcp.Address))) { } } } }
private void btnAddress_Click(object sender, EventArgs e) { ((Button)sender).Enabled = false; Application.DoEvents(); if (!SystemPub.ADRcp.SendBytePkt(PassiveRcp.SetAddress(SystemPub.ADRcp.Address, Convert.ToInt32(utxtNewAddr.Text)))) { } ((Button)sender).Enabled = true; }
private void btnIO2Close_Click(object sender, EventArgs e) { ((Button)sender).Enabled = false; Application.DoEvents(); if (!SystemPub.ADRcp.SendBytePkt(PassiveRcp.SetRemote(SystemPub.ADRcp.Address, 2, 0))) { } ((Button)sender).Enabled = true; }
private void btnIdentify_Click(object sender, EventArgs e) { btnIdentify.Enabled = false; utxtCard.Value = ""; Application.DoEvents(); if (!SystemPub.ADRcp.SendBytePkt(PassiveRcp.Identify6C(SystemPub.ADRcp.Address))) { } btnIdentify.Enabled = true; }
private void btnGetTime_Click(object sender, EventArgs e) { txtNowTime.Text = txtReaderTime.Text = ""; ((Button)sender).Enabled = false; Application.DoEvents(); if (!SystemPub.ADRcp.SendBytePkt(PassiveRcp.GetTime(SystemPub.ADRcp.Address))) { } ((Button)sender).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("-", "")); 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); if (!SystemPub.ADRcp.SendBytePkt(PassiveRcp.Read6B(SystemPub.ADRcp.Address, state, len))) { } btnRead.Enabled = true; }
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); if (!SystemPub.ADRcp.SendBytePkt(PassiveRcp.Read6C(SystemPub.ADRcp.Address, mem, 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("-", "")); 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 if (!SystemPub.ADRcp.SendBytePkt(PassiveRcp.GetConfig(SystemPub.ADRcp.Address))) { } System.Threading.Thread.Sleep(20); if (UserSettings.Communication != UserSettings.CommType.USB) { 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(); if (!SystemPub.ADRcp.SendBytePkt(PassiveRcp.SetTime(SystemPub.ADRcp.Address, dtTemp))) { } ((Button)sender).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 (UserSettings.Communication == UserSettings.CommType.USB) { 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 (UserSettings.Communication == UserSettings.CommType.USB || grbOutType.Visible) { 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 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(); 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; } if (!SystemPub.ADRcp.SendBytePkt(PassiveRcp.Write6C(SystemPub.ADRcp.Address, 1, 2, 12, sndData))) { } btnWriteAscii.Enabled = true; }
private void WriteCard() { ActionType = WRITETYPE.CARD; try { byte[] SendDataBuff = ConvertData.DecLongToByteArray(LngSendData, UserSettings.WriteMode > 0); if (chkAddHex.Checked) { if (UserSettings.WriteMode > 0) { SendDataBuff = ConvertData.HexStringToByteArray(LngSendData.ToString("00000000")); } else { SendDataBuff = ConvertData.HexStringToByteArray(LngSendData.ToString("000000")); } } else { SendDataBuff = ConvertData.DecLongToByteArray(LngSendData, UserSettings.WriteMode > 0); } byte[] SendData = new byte[intlen]; for (int i = intpoint; i < intlen; i++) { try { SendData[i] = SendDataBuff[i - intpoint]; } catch { } } 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())) { MessageStatus.Show("IP地址错误!", "IP Address Error!", (int)CommRtn.FAIL); return; } if (!RegexBase.IsIPv4(txtTCPMask.Text.ToString().Trim())) { MessageStatus.Show("子网掩码错误!", "Subnet Mask Error!", (int)CommRtn.FAIL); return; } if (!RegexBase.IsIPv4(txtTCPGateway.Text.ToString().Trim())) { MessageStatus.Show("网关地址错误!", "GateWay Error!", (int)CommRtn.FAIL); return; } if (!RegexBase.IsMac(txtTCPMac.Text.ToString().Trim())) { MessageStatus.Show("Mac地址错误!", "Mac Address Error!", (int)CommRtn.FAIL); return; } if (!RegexBase.IsIPv4(txtRemoteIP.Text.ToString().Trim())) { MessageStatus.Show("RemoteIP地址错误!", "RemoteIP Address Error!", (int)CommRtn.FAIL); return; } TcpipParameters newTemp = GetTcpipParaInfo(); if (!SystemPub.ADRcp.SendBytePkt(PassiveRcp.SetTcpip(SystemPub.ADRcp.Address, newTemp.ToArray()))) { } }
private void btnSetPara_Click(object sender, EventArgs e) { if (!SystemPub.ADRcp.SendBytePkt(PassiveRcp.SetConfig(SystemPub.ADRcp.Address, GetBasicParametersPnfo().ToArray()))) { } }
private void SecretCard() { if (!SystemPub.ADRcp.SendBytePkt(PassiveRcp.SetSecret(SystemPub.ADRcp.Address))) { } }
public void GetTcpip() { if (!SystemPub.ADRcp.SendBytePkt(PassiveRcp.GetTcpip(SystemPub.ADRcp.Address))) { } }
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 = BaseSettings.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) { 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) { if (!SystemPub.ADRcp.SendBytePkt(PassiveRcp.SetUsbPara(65535, new byte[] { 5, 5 }))) { } }
private void btnGetPara_Click(object sender, EventArgs e) { if (!SystemPub.ADRcp.SendBytePkt(PassiveRcp.GetConfig(SystemPub.ADRcp.Address))) { } }