private void btngetrg_Click(object sender, EventArgs e) { try { int st = Environment.TickCount; ModuleTech.Region rg = (ModuleTech.Region)rdr.ParamGet("Region"); Debug.WriteLine((Environment.TickCount - st).ToString()); switch (rg) { case ModuleTech.Region.CN: this.cbbregion.SelectedIndex = 6; break; case ModuleTech.Region.EU: case ModuleTech.Region.EU2: case ModuleTech.Region.EU3: this.cbbregion.SelectedIndex = 4; break; case ModuleTech.Region.IN: this.cbbregion.SelectedIndex = 5; break; case ModuleTech.Region.JP: this.cbbregion.SelectedIndex = 2; break; case ModuleTech.Region.KR: this.cbbregion.SelectedIndex = 3; break; case ModuleTech.Region.NA: this.cbbregion.SelectedIndex = 1; break; case ModuleTech.Region.PRC: this.cbbregion.SelectedIndex = 0; break; case ModuleTech.Region.OPEN: this.cbbregion.SelectedIndex = 7; break; case ModuleTech.Region.PRC2: this.cbbregion.SelectedIndex = 8; break; } } catch (Exception ex) { MessageBox.Show("getting failed"); } }
private void btnsetrg_Click(object sender, EventArgs e) { ModuleTech.Region rg = ModuleTech.Region.UNSPEC; bool is840_845 = false; bool is840_925 = false;; if (this.cbbregion.SelectedIndex == -1) { MessageBox.Show("please select region"); return; } switch (this.cbbregion.SelectedIndex) { case 0: rg = ModuleTech.Region.PRC; break; case 1: rg = ModuleTech.Region.NA; break; case 2: rg = ModuleTech.Region.JP; break; case 3: rg = ModuleTech.Region.KR; break; case 4: rg = ModuleTech.Region.EU3; break; case 5: rg = ModuleTech.Region.IN; break; case 6: rg = ModuleTech.Region.CN; break; case 7: rg = ModuleTech.Region.OPEN; break; case 8: { if (rdr.HwDetails.module == Reader.Module_Type.MODOULE_M6E || rdr.HwDetails.module == Reader.Module_Type.MODOULE_M6E_PRC) { if (rdr.HwDetails.module == Reader.Module_Type.MODOULE_M6E_PRC) { rg = ModuleTech.Region.PRC2; } else { is840_845 = true; rg = ModuleTech.Region.OPEN; } break; } else { MessageBox.Show("this region dose not be supported"); return; } } case 9: { if (rdr.HwDetails.module == Reader.Module_Type.MODOULE_M6E || rdr.HwDetails.module == Reader.Module_Type.MODOULE_M6E_PRC) { rg = ModuleTech.Region.OPEN; is840_925 = true; break; } else { MessageBox.Show("this region dose not be supported"); return; } } } if (m_params.readertype == ReaderType.PR_ONEANT) { if (rg == ModuleTech.Region.OPEN || rg == ModuleTech.Region.CN) { MessageBox.Show("this region dose not be supported"); return; } } try { rdr.ParamSet("Region", rg); if (is840_845 || is840_925) { List <uint> htab = new List <uint>(); if (is840_845) { htab.Add(841375); htab.Add(842625); htab.Add(840875); htab.Add(843625); htab.Add(841125); htab.Add(840625); htab.Add(843125); htab.Add(841625); htab.Add(842125); htab.Add(843875); htab.Add(841875); htab.Add(842875); htab.Add(844125); htab.Add(843375); htab.Add(844375); htab.Add(842375); } else if (is840_925) { htab.Add(841375); htab.Add(921375); htab.Add(842625); htab.Add(922625); htab.Add(840875); htab.Add(920875); htab.Add(843625); htab.Add(923625); htab.Add(841125); htab.Add(921125); htab.Add(840625); htab.Add(920625); htab.Add(843125); htab.Add(923125); htab.Add(841625); htab.Add(921625); htab.Add(842125); htab.Add(922125); htab.Add(843875); htab.Add(923875); htab.Add(841875); htab.Add(921875); htab.Add(842875); htab.Add(922875); htab.Add(844125); htab.Add(924125); htab.Add(843375); htab.Add(923375); htab.Add(844375); htab.Add(924375); htab.Add(842375); htab.Add(922375); } rdr.ParamSet("FrequencyHopTable", htab.ToArray()); } else { } } catch (Exception) { MessageBox.Show("setting failed"); } }
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); }