public virtual bool ConnectReader() { bool re = true; try { if (rfid.ConnectRadio(mComPort, 115200) == operateResult.ok) { // 这里演示初始化参数 // 配置天线功率 AntennaPortConfiguration portConfig = new AntennaPortConfiguration(); portConfig.powerLevel = mPower * 10; // 23dbm portConfig.numberInventoryCycles = 8192; portConfig.dwellTime = 2000; rfid.SetAntennaPortConfiguration(mComPort, 0, portConfig); rfid.SetCurrentLinkProfile(mComPort, 1); // 配置单化算法 SingulationAlgorithmParms singParm = new SingulationAlgorithmParms(); singParm.singulationAlgorithmType = SingulationAlgorithm.Dynamicq; singParm.startQValue = 4; singParm.minQValue = 0; singParm.maxQValue = 15; singParm.thresholdMultiplier = 4; singParm.toggleTarget = 1; rfid.SetCurrentSingulationAlgorithm(mComPort, singParm); rfid.SetTagGroupSession(mComPort, Session.S0); } else { re = false; } } catch (Exception) { re = false; } return(re); }
public bool connect() { #if DEBUG return(false); #endif bool re = false; if (mReaderType == READER_TYPE.READER_IMP) { try { mReaderIMP = new ImpinjReader(); mReaderIMP.TagsReported += this.tagsReportedIMP; mReaderIMP.Connect(mIp); mReaderIMP.ApplyDefaultSettings(); configIMP(mPower); re = true; } catch (Exception) { re = false; } } if (mReaderType == READER_TYPE.READER_TM) { try { Reader.SetSerialTransport("tcp", SerialTransportTCP.CreateSerialReader); mReaderTM = Reader.Create(string.Format("tcp://{0}", mIp)); mReaderTM.TagRead += tagsReportedTM; mReaderTM.Connect(); configTM(mPower); re = true; } catch (Exception) { re = false; } } if (mReaderType == READER_TYPE.READER_DLX_PM) { try { mReaderDLXPM = new RfidUARTLinkExtend(); mReaderDLXPM.RadioInventory += tagsReportedDLXPM; if (mReaderDLXPM.ConnectRadio(mComPort, 115200) == operateResult.ok) { AntennaPortConfiguration portConfig = new AntennaPortConfiguration(); portConfig.powerLevel = (uint)mPower; portConfig.numberInventoryCycles = 8192; portConfig.dwellTime = 2000; mReaderDLXPM.SetAntennaPortConfiguration(mComPort, 0, portConfig); mReaderDLXPM.SetCurrentLinkProfile(mComPort, 1); SingulationAlgorithmParms singParm = new SingulationAlgorithmParms(); singParm.singulationAlgorithmType = SingulationAlgorithm.Dynamicq; singParm.startQValue = 4; singParm.minQValue = 0; singParm.maxQValue = 15; singParm.thresholdMultiplier = 4; singParm.toggleTarget = 1; mReaderDLXPM.SetCurrentSingulationAlgorithm(mComPort, singParm); mReaderDLXPM.SetTagGroupSession(mComPort, Session.S0); re = true; } } catch (Exception) { re = false; } } if (mReaderType == READER_TYPE.READER_DLX_PM) { try { mReaderXDPM = new RfidReader(); mReaderXDPM.OnTagsReported += tagsReportedXDPM; re = mReaderXDPM.OpenReader(mIp, 2048, SynchronizationContext.Current, "M6E").Success; configXDPM(mPower); } catch (Exception) { re = false; } } return(re); }