// 连接天线 public void ConnectAnt(string antIp) { if (antIp == ANT1 | antIp == ANT2) { reader = Reader.Create(antIp, ModuleTech.Region.NA, 1); int[] ants = new int[] { 1 }; SimpleReadPlan searchPlan = new SimpleReadPlan(ants); reader.ParamSet("ReadPlan", searchPlan); AntPower[] antPower = new AntPower[1]; for (int i = 0; i < 1; i++) { ushort power = (ushort)((float)3000); antPower[i].AntId = (byte)(i + 1); antPower[i].WritePower = power; antPower[i].ReadPower = power; } reader.ParamSet("AntPowerConf", antPower); EmbededCmdData ecd = new EmbededCmdData(ModuleTech.Gen2.MemBank.TID, 0, 12); reader.ParamSet("EmbededCmdOfInventory", ecd); if (antIp == ANT1) { state = 1; } else { state = 2; } } if (antIp == ANT3) { reader = Reader.Create(antIp, ModuleTech.Region.NA, 4); int[] ants = new int[] { 3 };//货柜19 SimpleReadPlan searchPlan = new SimpleReadPlan(ants); reader.ParamSet("ReadPlan", searchPlan); AntPower[] antPower = new AntPower[4]; for (int i = 0; i < 4; i++) { ushort power = (ushort)((float)3100); antPower[i].AntId = (byte)(i + 1); antPower[i].WritePower = power; antPower[i].ReadPower = power; } reader.ParamSet("AntPowerConf", antPower); EmbededCmdData ecd = new EmbededCmdData(ModuleTech.Gen2.MemBank.TID, 0, 12); reader.ParamSet("EmbededCmdOfInventory", ecd); state = 3; } }
private void rdrParmSet() // read param set { if (rdr != null) { uint PassWord = uint.Parse(accPass, System.Globalization.NumberStyles.AllowHexSpecifier); //rdr.ParamSet("AccessPassword", PassWord); int[] ants = new int[] { 1 }; //SimpleReadPlan searchPlan = new SimpleReadPlan(ants); rdr.ParamSet("ReadPlan", new SimpleReadPlan(TagProtocol.GEN2, ants)); rdr.ParamSet("CheckAntConnection", false); rdr.ParamSet("Gen2Session", (Session)0); AntPower[] apwr = new AntPower[1]; apwr[0].AntId = (byte)1; apwr[0].WritePower = (ushort)((int)rdr.ParamGet("RfPowerMax") * db); apwr[0].ReadPower = (ushort)((int)rdr.ParamGet("RfPowerMax") * db); rdr.ParamSet("AntPowerConf", apwr); //rdr.GPOSet(1, false); } }
private void btnsetpwr_Click(object sender, EventArgs e) { if (this.tbreadpwr.Text.Trim() == string.Empty) { MessageBox.Show("please input read power"); return; } if (this.tbwritepwr.Text.Trim() == string.Empty) { MessageBox.Show("please input write power"); return; } AntPower[] pwrs = new AntPower[16]; ushort rpwr = ushort.Parse(this.tbreadpwr.Text.Trim()); ushort wpwr = ushort.Parse(this.tbwritepwr.Text.Trim()); int powermax = (int)rdr.ParamGet("RfPowerMax"); int powermin = (int)rdr.ParamGet("RfPowerMin"); if (rpwr < powermin || rpwr > powermax || wpwr < powermin || wpwr > powermax) { MessageBox.Show("power value must be in the range of " + powermin.ToString() + "-" + powermax.ToString()); return; } for (int i = 0; i < 16; ++i) { pwrs[i].AntId = (byte)(i + 1); pwrs[i].ReadPower = rpwr; pwrs[i].WritePower = wpwr; } try { rdr.ParamSet("AntPowerConf", pwrs); } catch (Exception ex) { MessageBox.Show("operation failed:" + ex.ToString()); } }
private void sdpower_ValueChanged(object sender, EventArgs e) { try { int valset = this.sdpower.Value; AntPower[] pwrs = new AntPower[AntPortLimit]; for (int i = 0; i < AntPortLimit; ++i) { pwrs[i].AntId = (byte)(i + 1); pwrs[i].ReadPower = (ushort)(valset * 10); pwrs[i].WritePower = (ushort)(valset * 10); } Rdr.ParamSet("AntPowerConf", pwrs); this.labxpwr.Text = (valset / 10).ToString(); } catch (System.Exception ex) { CusShowMsgBox("操作失败:" + ex.ToString()); return; } }
private void rdrParmSet() { try { int[] ants = new int[antNum]; AntPower[] apwr = new AntPower[antNum]; for (int i = 0; i < antNum; i++) { ants[i] = i + 1; apwr[0].AntId = (byte)ants[i]; apwr[0].WritePower = (ushort)((int)reader.ParamGet("RfPowerMax") * dp); apwr[0].ReadPower = (ushort)((int)reader.ParamGet("RfPowerMax") * dp); } reader.ParamSet("ReadPlan", new SimpleReadPlan(TagProtocol.GEN2, ants)); reader.ParamSet("CheckAntConnection", false); reader.ParamSet("Gen2Session", (Session)0); reader.ParamSet("AntPowerConf", apwr); } catch (Exception ee) { throw new Exception("reader parm set error: ", ee); } }
/// <summary> /// 更新天线参数设置 /// </summary> public void SetUpdateAntPower(ushort ReadPower) { AntPower[] apwrs = new AntPower[1]; try { for (int i = 0; i < apwrs.Length; i++) { apwrs[i].AntId = (byte)(i + 1); apwrs[i].ReadPower = ReadPower; apwrs[i].WritePower = ReadPower; } Reader.ParamSet("AntPowerConf", apwrs); SetUpdateParam(); System.Threading.Thread.Sleep(200); } catch (Exception) { throw new Exception("更新天线参数设置失败!"); } }
private void btnxconnect_Click(object sender, EventArgs e) { if (this.cbbxportnum.SelectedIndex == -1) { CusShowMsgBox("请选择天线端口数"); return; } if (this.tbxaddr.Text.Trim() == string.Empty) { CusShowMsgBox("请输入读写器地址(IP或串口号)"); return; } AntPortLimit = this.cbbxportnum.SelectedIndex + 1; try { Rdr = Reader.Create(this.tbxaddr.Text.Trim(), ModuleTech.Region.NA, AntPortLimit); int maxp = (int)Rdr.ParamGet("RfPowerMax"); int minp = (int)Rdr.ParamGet("RfPowerMin"); this.sdpower.Minimum = minp / 10; this.sdpower.Maximum = maxp / 10; this.sdpower.Step = 10; AntPower[] pwrs = new AntPower[AntPortLimit]; for (int i = 0; i < AntPortLimit; ++i) { AntList[i].Enabled = true; pwrs[i].AntId = (byte)(i + 1); pwrs[i].ReadPower = (ushort)maxp; pwrs[i].WritePower = (ushort)maxp; } Rdr.ParamSet("AntPowerConf", pwrs); int[] connports = (int[])Rdr.ParamGet("ConnectedAntennas"); for (int i = 0; i < connports.Length; ++i) { if (connports[i] <= AntPortLimit) { AntList[connports[i] - 1].TextColor = Color.SteelBlue; AntList[connports[i] - 1].Checked = true; } } this.sdpower.Value = maxp / 10; if (AntPortLimit == 1) { AntList[0].Checked = true; } if (Rdr.HwDetails.module == Reader.Module_Type.MODOULE_M6E || Rdr.HwDetails.module == Reader.Module_Type.MODOULE_M6E_MICRO || Rdr.HwDetails.module == Reader.Module_Type.MODOULE_M6E_PRC) { this.cbxpotlgen2.Enabled = true; this.cbxpotl6b.Enabled = true; this.cbxpotlipx256.Enabled = true; this.cbxpotlipx64.Enabled = true; this.cbxhighbkrate.Enabled = true; } } catch (System.Exception ex) { CusShowMsgBox(ex.ToString()); return; } this.epconnparam.Expanded = false; // this.epinvparam.Expanded = true; this.btnxconnect.Enabled = false; this.btnxdisconnect.Enabled = true; this.btnxstart.Enabled = true; this.labxmbtype.Text = MainBoard2Str(Rdr.HwDetails.board); this.labxmdtype.Text = RfidModule2Str(Rdr.HwDetails.module); this.epinvparam.Enabled = true; this.epdatastatistic.Enabled = true; this.epotherparam.Enabled = true; Form2 frm = new Form2("连接成功"); frm.ShowDialog(); }
/// <summary> /// 连接采集设备 /// </summary> private void Running() { while (Runningl) { try { reader = Reader.Create(sparmas.Comv, (ModuleTech.Region)sparmas.Region, (ReaderType)sparmas.ReaderType); Funpercent(30, "创建读写器完毕"); // reader.ParamSet("CheckAntConnection", sparmas.CheckAnt); Funpercent(40, "检测天线"); AntPower[] apwrs = new AntPower[sparmas.AntType]; for (int i = 0; i < apwrs.Length; i++) { apwrs[i].AntId = (byte)(i + 1); apwrs[i].ReadPower = ushort.Parse(sparmas.ReadPw[i]); apwrs[i].WritePower = ushort.Parse(sparmas.WritePw[i]); } reader.ParamSet("AntPowerConf", apwrs); Funpercent(50, "配置天线功率"); reader.ParamSet("TagopAntenna", sparmas.Opant); Funpercent(60, "配置默认天线"); int[] connectedants = (int[])reader.ParamGet("ConnectedAntennas"); SimpleReadPlan gen2srp = null; SimpleReadPlan iso6bsrp = null; if (connectedants.Length > 0) { sparmas.Connectants = connectedants; gen2srp = new SimpleReadPlan(TagProtocol.GEN2, connectedants); iso6bsrp = new SimpleReadPlan(TagProtocol.ISO180006B, connectedants); } else { sparmas.Connectants = null; gen2srp = new SimpleReadPlan(TagProtocol.GEN2, new int[] { sparmas.Opant }); iso6bsrp = new SimpleReadPlan(TagProtocol.ISO180006B, new int[] { sparmas.Opant }); } if (sparmas.Protocol == 0) { reader.ParamSet("ReadPlan", gen2srp); Funpercent(70, "配置盘点方式"); } else if (sparmas.Protocol == 1) { reader.ParamSet("ReadPlan", iso6bsrp); Funpercent(70, "配置盘点方式"); } else { ReadPlan[] rp = new ReadPlan[2]; rp[0] = gen2srp; rp[1] = iso6bsrp; MultiReadPlan mrp = new MultiReadPlan(rp); reader.ParamSet("ReadPlan", rp); Funpercent(70, "配置盘点方式"); } reader.ParamSet("Gen2Session", (ModuleTech.Gen2.Session)sparmas.Session); Funpercent(80, "配置会话模式"); if (sparmas.CustomFrequency) { List<uint> htb = new List<uint>(); for (int i = 0; i < sparmas.Frequencys.Length; i++) { htb.Add(uint.Parse(sparmas.Frequencys[i])); } reader.ParamSet("FrequencyHopTable", htb.ToArray()); Funpercent(90, "配置频率表"); } else { reader.ParamSet("Region", (ModuleTech.Region)sparmas.Region); Funpercent(90, "配置频率表"); } try { reader.ParamSet("PowerMode", (byte)sparmas.PowerMode); reader.ParamSet("IsTransmitPowerSave", true); } catch (Exception omitex) { } Funpercent(100, "配置完毕,读写器工作就绪"); } catch (System.Exception ex) { string msg = string.Empty; if (ex is ModuleLibrary.FatalInternalException) msg = Convert.ToString(((ModuleLibrary.FatalInternalException)ex).ErrCode, 16); if (ex is ModuleLibrary.HardwareAlertException) msg = Convert.ToString(((ModuleLibrary.HardwareAlertException)ex).ErrCode, 16); if (ex is ModuleLibrary.ModuleException) msg = Convert.ToString(((ModuleLibrary.ModuleException)ex).ErrCode, 16); if (ex is ModuleLibrary.OpFaidedException) msg = Convert.ToString(((ModuleLibrary.OpFaidedException)ex).ErrCode, 16); if (reader != null) reader.Disconnect(); Funpercent(0, "连接失败" + ex.Message + " :" + msg); dlog.WirteLog(ex.Message + ":" + msg + ex.StackTrace); } Thread.Sleep(1000); Runningl = false; } IsExit = false; Funpercent(-100, string.Empty); }
/// <summary> /// 连接采集设备 /// </summary> private void Running() { while (Runningl) { try { reader = Reader.Create(sparmas.Comv, (ModuleTech.Region)sparmas.Region, (ReaderType)sparmas.ReaderType); Funpercent(30, "创建读写器完毕"); // reader.ParamSet("CheckAntConnection", sparmas.CheckAnt); Funpercent(40, "检测天线"); AntPower[] apwrs = new AntPower[sparmas.AntType]; for (int i = 0; i < apwrs.Length; i++) { apwrs[i].AntId = (byte)(i + 1); apwrs[i].ReadPower = ushort.Parse(sparmas.ReadPw[i]); apwrs[i].WritePower = ushort.Parse(sparmas.WritePw[i]); } reader.ParamSet("AntPowerConf", apwrs); Funpercent(50, "配置天线功率"); reader.ParamSet("TagopAntenna", sparmas.Opant); Funpercent(60, "配置默认天线"); int[] connectedants = (int[])reader.ParamGet("ConnectedAntennas"); SimpleReadPlan gen2srp = null; SimpleReadPlan iso6bsrp = null; if (connectedants.Length > 0) { sparmas.Connectants = connectedants; gen2srp = new SimpleReadPlan(TagProtocol.GEN2, connectedants); iso6bsrp = new SimpleReadPlan(TagProtocol.ISO180006B, connectedants); } else { sparmas.Connectants = null; gen2srp = new SimpleReadPlan(TagProtocol.GEN2, new int[] { sparmas.Opant }); iso6bsrp = new SimpleReadPlan(TagProtocol.ISO180006B, new int[] { sparmas.Opant }); } if (sparmas.Protocol == 0) { reader.ParamSet("ReadPlan", gen2srp); Funpercent(70, "配置盘点方式"); } else if (sparmas.Protocol == 1) { reader.ParamSet("ReadPlan", iso6bsrp); Funpercent(70, "配置盘点方式"); } else { ReadPlan[] rp = new ReadPlan[2]; rp[0] = gen2srp; rp[1] = iso6bsrp; MultiReadPlan mrp = new MultiReadPlan(rp); reader.ParamSet("ReadPlan", rp); Funpercent(70, "配置盘点方式"); } reader.ParamSet("Gen2Session", (ModuleTech.Gen2.Session)sparmas.Session); Funpercent(80, "配置会话模式"); if (sparmas.CustomFrequency) { List <uint> htb = new List <uint>(); for (int i = 0; i < sparmas.Frequencys.Length; i++) { htb.Add(uint.Parse(sparmas.Frequencys[i])); } reader.ParamSet("FrequencyHopTable", htb.ToArray()); Funpercent(90, "配置频率表"); } else { reader.ParamSet("Region", (ModuleTech.Region)sparmas.Region); Funpercent(90, "配置频率表"); } try { reader.ParamSet("PowerMode", (byte)sparmas.PowerMode); reader.ParamSet("IsTransmitPowerSave", true); } catch (Exception omitex) { } Funpercent(100, "配置完毕,读写器工作就绪"); } catch (System.Exception ex) { string msg = string.Empty; if (ex is ModuleLibrary.FatalInternalException) { msg = Convert.ToString(((ModuleLibrary.FatalInternalException)ex).ErrCode, 16); } if (ex is ModuleLibrary.HardwareAlertException) { msg = Convert.ToString(((ModuleLibrary.HardwareAlertException)ex).ErrCode, 16); } if (ex is ModuleLibrary.ModuleException) { msg = Convert.ToString(((ModuleLibrary.ModuleException)ex).ErrCode, 16); } if (ex is ModuleLibrary.OpFaidedException) { msg = Convert.ToString(((ModuleLibrary.OpFaidedException)ex).ErrCode, 16); } if (reader != null) { reader.Disconnect(); } Funpercent(0, "连接失败" + ex.Message + " :" + msg); dlog.WirteLog(ex.Message + ":" + msg + ex.StackTrace); } Thread.Sleep(1000); Runningl = false; } IsExit = false; Funpercent(-100, string.Empty); }
private void Running() { while (Runningl) { try { ReaderType[] types = new ReaderType[] { ReaderType.MT_TWOANTS, ReaderType.MT_FOURANTS, ReaderType.MT_THREEANTS, ReaderType.MT_ONEANT, ReaderType.PR_ONEANT, ReaderType.MT_A7_FOURANTS, ReaderType.MT_A7_TWOANTS, ReaderType.SL_FOURANTS, ReaderType.M6_A7_FOURANTS, ReaderType.MT100, ReaderType.MT200 }; mf.Rd = Reader.Create(sparmas.Comv, ModuleTech.Region.PRC, types[sparmas.ReaderType]); Funpercent(30, "创建读写器完毕"); dlog.WirteLog("创建读写器完毕\r\n"); // if (!(types[sparmas.ReaderType] == ReaderType.M6_A7_FOURANTS && sparmas.AntType == 2)) { mf.Rd.ParamSet("CheckAntConnection", sparmas.CheckAnt); Funpercent(40, "检测天线"); dlog.WirteLog("检测天线\r\n"); } AntPower[] apwrs = new AntPower[sparmas.AntType]; for (int i = 0; i < apwrs.Length; i++) { apwrs[i].AntId = (byte)(i + 1); apwrs[i].ReadPower = ushort.Parse(sparmas.ReadPw[i]); apwrs[i].WritePower = ushort.Parse(sparmas.WritePw[i]); } mf.Rd.ParamSet("AntPowerConf", apwrs); Funpercent(50, "配置天线功率"); dlog.WirteLog("配置天线功率\r\n"); mf.Rd.ParamSet("TagopAntenna", sparmas.Opant); Funpercent(60, "配置默认天线"); dlog.WirteLog("配置默认天线\r\n"); int[] connectedants = (int[])mf.Rd.ParamGet("ConnectedAntennas"); SimpleReadPlan gen2srp = null; SimpleReadPlan iso6bsrp = null; if (connectedants.Length > 0 && (sparmas.AntType != 2 && types[sparmas.ReaderType] != ReaderType.M6_A7_FOURANTS)) { sparmas.Connectants = connectedants; gen2srp = new SimpleReadPlan(TagProtocol.GEN2, connectedants, 30); iso6bsrp = new SimpleReadPlan(TagProtocol.ISO180006B, connectedants, 30); } else { sparmas.Connectants = null; gen2srp = new SimpleReadPlan(TagProtocol.GEN2, new int[] { sparmas.Opant }, 30); iso6bsrp = new SimpleReadPlan(TagProtocol.ISO180006B, new int[] { sparmas.Opant }, 30); } if (sparmas.Protocol == 0) { mf.Rd.ParamSet("ReadPlan", gen2srp); } else if (sparmas.Protocol == 1) { mf.Rd.ParamSet("ReadPlan", iso6bsrp); } else { List <SimpleReadPlan> Lrp = new List <SimpleReadPlan>(); //List<ReadPlan> Lrp = new List<ReadPlan>(); Lrp.Add(gen2srp); Lrp.Add(iso6bsrp); MultiReadPlan mrp = new MultiReadPlan(Lrp.ToArray()); mf.Rd.ParamSet("ReadPlan", mrp); } Funpercent(70, "配置盘点方式"); dlog.WirteLog("配置盘点方式\r\n"); mf.Rd.ParamSet("Gen2Session", (ModuleTech.Gen2.Session)sparmas.Session); Funpercent(80, "配置会话模式"); dlog.WirteLog("配置会话模式\r\n"); ModuleTech.Region[] mregion = new ModuleTech.Region[] { ModuleTech.Region.UNSPEC, ModuleTech.Region.CN, ModuleTech.Region.EU, ModuleTech.Region.EU2, ModuleTech.Region.EU3, ModuleTech.Region.IN, ModuleTech.Region.KR, ModuleTech.Region.JP, ModuleTech.Region.NA, ModuleTech.Region.PRC, ModuleTech.Region.OPEN, ModuleTech.Region.OPEN }; mf.Rd.ParamSet("Region", mregion[sparmas.Region]); Funpercent(90, "配置区域"); dlog.WirteLog("配置区域" + mregion[sparmas.Region].ToString() + "\r\n"); if (sparmas.CustomFrequency) { List <uint> htb = new List <uint>(); for (int i = 0; i < sparmas.Frequencys.Length; i++) { htb.Add(uint.Parse(sparmas.Frequencys[i])); //dlog.WirteLog(sparmas.Frequencys[i].ToString()+"\r\n"); } try { mf.Rd.ParamSet("FrequencyHopTable", htb.ToArray()); Funpercent(90, "配置频率表"); dlog.WirteLog("配置频率表\r\n"); } catch (System.Exception ex) { } } try { //case 0x00: // pm = SerialReader.PowerMode.FULL; // break; //case 0x01: // pm = SerialReader.PowerMode.MINSAVE; // break; //case 0x02: // pm = SerialReader.PowerMode.MEDSAVE; // break; //case 0x03: // pm = SerialReader.PowerMode.MAXSAVE; // break; //case 0x04: // pm = SerialReader.PowerMode.SLEEP; mf.Rd.ParamSet("PowerMode", (byte)sparmas.PowerMode);//0x03 mf.Rd.ParamSet("IsTransmitPowerSave", true); } catch// (Exception omitex) { } Funpercent(100, "配置完毕,读写器工作就绪"); } catch (System.Exception ex) { string msg = string.Empty; if (ex is ModuleLibrary.FatalInternalException) { msg = Convert.ToString(((ModuleLibrary.FatalInternalException)ex).ErrCode, 16); } if (ex is ModuleLibrary.HardwareAlertException) { msg = Convert.ToString(((ModuleLibrary.HardwareAlertException)ex).ErrCode, 16); } if (ex is ModuleLibrary.ModuleException) { msg = Convert.ToString(((ModuleLibrary.ModuleException)ex).ErrCode, 16); } if (ex is ModuleLibrary.OpFaidedException) { msg = Convert.ToString(((ModuleLibrary.OpFaidedException)ex).ErrCode, 16); } if (mf.Rd != null) { mf.Rd.Disconnect(); } Funpercent(0, "连接失败" + ex.Message + " :" + msg); if (dlog != null) { dlog.WirteLog(ex.Message + ":" + msg + ex.StackTrace); } } Thread.Sleep(1000); Runningl = false; } IsExit = false; Funpercent(-100, string.Empty); }