private void Set_Reader_Config() { try { MSG_SET_READER_CONFIG msg = new MSG_SET_READER_CONFIG(); msg.AccessReportSpec = new PARAM_AccessReportSpec(); msg.AccessReportSpec.AccessReportTrigger = ENUM_AccessReportTriggerType.End_Of_AccessSpec; PARAM_C1G2InventoryCommand cmd = new PARAM_C1G2InventoryCommand(); cmd.C1G2RFControl = new PARAM_C1G2RFControl(); cmd.C1G2RFControl.ModeIndex = 1000; // 1000 = AD - Auto Dense Interrogator // 1001 = AS - Auto Single Interrogator // 0 = 0 - High Speed 640k bps // 1 = 1 - Hybrid 80k/160k bps // 2 = 2 - Dense Reader M=4 HiSpd // 3 = 3 - Dense Reader M=8 LoSpd // 4 = 4 - Dense Reader MaxMiller cmd.C1G2RFControl.Tari = 0; cmd.C1G2SingulationControl = new PARAM_C1G2SingulationControl(); cmd.C1G2SingulationControl.Session = new TwoBits(1); cmd.C1G2SingulationControl.TagPopulation = 32; cmd.C1G2SingulationControl.Session.Equals(1); cmd.C1G2SingulationControl.TagTransitTime = 0; cmd.TagInventoryStateAware = false; PARAM_ImpinjInventorySearchMode search_mode = new PARAM_ImpinjInventorySearchMode(); search_mode.InventorySearchMode = ENUM_ImpinjInventorySearchType.Dual_Target; //search_mode.InventorySearchMode = ENUM_ImpinjInventorySearchType.Dual_Target; cmd.AddCustomParameter(search_mode); //msg.AntennaConfiguration[0].AntennaID = 0; // 0 = all 4 antennas //msg.AntennaConfiguration = new PARAM_AntennaConfiguration[1]; /* if (cbAnt1.Checked == true) { msg.AntennaConfiguration[0].AntennaID = 1; } if (cbAnt2.Checked == true) { msg.AntennaConfiguration[0].AntennaID = 2; } if (cbAnt3.Checked == true) { msg.AntennaConfiguration[0].AntennaID = 3; } if (cbAnt4.Checked == true) { msg.AntennaConfiguration[0].AntennaID = 4; } */ msg.AntennaConfiguration = new PARAM_AntennaConfiguration[0]; msg.AntennaConfiguration[0].AntennaID = 0; // msg.AntennaConfiguration[0] = new PARAM_AntennaConfiguration(); msg.AntennaConfiguration[0].AirProtocolInventoryCommandSettings = new UNION_AirProtocolInventoryCommandSettings(); //msg.AntennaConfiguration[0] = new PARAM_AntennaConfiguration(); msg.AntennaConfiguration[0].AirProtocolInventoryCommandSettings = new UNION_AirProtocolInventoryCommandSettings(); msg.AntennaConfiguration[0].AirProtocolInventoryCommandSettings.Add(cmd); msg.AntennaConfiguration[0].RFReceiver = new PARAM_RFReceiver(); msg.AntennaConfiguration[0].RFReceiver.ReceiverSensitivity = 1;// (ushort)tbReaderSensitivity.Value; // 1 = max, 2 = -70, 3 = -69, 4 = -68, 5 = -67... msg.AntennaConfiguration[0].RFTransmitter = new PARAM_RFTransmitter(); msg.AntennaConfiguration[0].RFTransmitter.ChannelIndex = 1; msg.AntennaConfiguration[0].RFTransmitter.HopTableID = 1; msg.AntennaConfiguration[0].RFTransmitter.TransmitPower = 30;//(ushort)tbTxPower.Value; //########################################################################################### //########################################################################################### //########################################################################################### // made change so Matho could test channel index values for Japanese readers //ushort i; //i = ushort.Parse(tbChannelIndex.Text); //msg.AntennaConfiguration[0].RFTransmitter.ChannelIndex = i; //MessageBox.Show("Channel Index = " + i.ToString()); // made change so Matho could test channel index values for Japanese readers //########################################################################################### //########################################################################################### //########################################################################################### //////if you want to set antenana property. un-comment following code. Impinj reader does not support //msg.AntennaProperties = new PARAM_AntennaProperties[1]; //msg.AntennaProperties[0] = new PARAM_AntennaProperties(); //msg.AntennaProperties[0].AntennaConnected = true; //msg.AntennaProperties[0].AntennaGain = 0; //msg.AntennaProperties[0].AntennaID = 0; //////If you want to enable fixed frequency feature. un-comment following code. //PARAM_ImpinjFixedFrequencyList fix_list = new PARAM_ImpinjFixedFrequencyList(); //fix_list.FixedFrequencyMode = ENUM_FixedFrequencyMode.Disabled; //cmd.AddCustomParameter(fix_list); //////If you want to enable reduced power list, un-comment following code and add channels //PARAM_ImpinjReducedPowerFrequencyList power_list = new PARAM_ImpinjReducedPowerFrequencyList(); //power_list.ReducedPowerMode = ENUM_ImpinjReducedPowerMode.Enabled; //power_list.ChannelList.Add(chanellist); //cmd.AddCustomParameter(power_list); //////If you want to enable low duty cycle, un-comment following code //PARAM_ImpinjLowDutyCycle lowDuty = new PARAM_ImpinjLowDutyCycle(); //lowDuty.LowDutyCycleMode = ENUM_ImpinjLowDutyCycleMode.Disabled; //lowDuty.EmptyFieldTimeout = 0; //lowDuty.FieldPingInterval = 0; //cmd.AddCustomParameter(lowDuty); //////If you want to select reader events to send to application, change the following code //msg.EventsAndReports = new PARAM_EventsAndReports(); //msg.EventsAndReports.HoldEventsAndReportsUponReconnect = false; //msg.KeepaliveSpec = new PARAM_KeepaliveSpec(); //msg.KeepaliveSpec.KeepaliveTriggerType = ENUM_KeepaliveTriggerType.Null; //msg.KeepaliveSpec.PeriodicTriggerValue = 0; msg.ReaderEventNotificationSpec = new PARAM_ReaderEventNotificationSpec(); msg.ReaderEventNotificationSpec.EventNotificationState = new PARAM_EventNotificationState[7]; msg.ReaderEventNotificationSpec.EventNotificationState[0] = new PARAM_EventNotificationState(); msg.ReaderEventNotificationSpec.EventNotificationState[0].EventType = ENUM_NotificationEventType.AISpec_Event; msg.ReaderEventNotificationSpec.EventNotificationState[0].NotificationState = false; msg.ReaderEventNotificationSpec.EventNotificationState[1] = new PARAM_EventNotificationState(); msg.ReaderEventNotificationSpec.EventNotificationState[1].EventType = ENUM_NotificationEventType.Antenna_Event; msg.ReaderEventNotificationSpec.EventNotificationState[1].NotificationState = false; msg.ReaderEventNotificationSpec.EventNotificationState[2] = new PARAM_EventNotificationState(); msg.ReaderEventNotificationSpec.EventNotificationState[2].EventType = ENUM_NotificationEventType.GPI_Event; msg.ReaderEventNotificationSpec.EventNotificationState[2].NotificationState = false; msg.ReaderEventNotificationSpec.EventNotificationState[3] = new PARAM_EventNotificationState(); msg.ReaderEventNotificationSpec.EventNotificationState[3].EventType = ENUM_NotificationEventType.Reader_Exception_Event; msg.ReaderEventNotificationSpec.EventNotificationState[3].NotificationState = false; msg.ReaderEventNotificationSpec.EventNotificationState[4] = new PARAM_EventNotificationState(); msg.ReaderEventNotificationSpec.EventNotificationState[4].EventType = ENUM_NotificationEventType.Upon_Hopping_To_Next_Channel; msg.ReaderEventNotificationSpec.EventNotificationState[4].NotificationState = false; msg.ReaderEventNotificationSpec.EventNotificationState[5] = new PARAM_EventNotificationState(); msg.ReaderEventNotificationSpec.EventNotificationState[5].EventType = ENUM_NotificationEventType.ROSpec_Event; msg.ReaderEventNotificationSpec.EventNotificationState[5].NotificationState = false; msg.ReaderEventNotificationSpec.EventNotificationState[6] = new PARAM_EventNotificationState(); msg.ReaderEventNotificationSpec.EventNotificationState[6].EventType = ENUM_NotificationEventType.Report_Buffer_Fill_Warning; msg.ReaderEventNotificationSpec.EventNotificationState[6].NotificationState = false; msg.ROReportSpec = new PARAM_ROReportSpec(); msg.ROReportSpec.N = 1; msg.ROReportSpec.ROReportTrigger = ENUM_ROReportTriggerType.Upon_N_Tags_Or_End_Of_ROSpec; msg.ROReportSpec.TagReportContentSelector = new PARAM_TagReportContentSelector(); msg.ROReportSpec.TagReportContentSelector.AirProtocolEPCMemorySelector = new UNION_AirProtocolEPCMemorySelector(); PARAM_C1G2EPCMemorySelector c1g2mem = new PARAM_C1G2EPCMemorySelector(); c1g2mem.EnableCRC = false; c1g2mem.EnablePCBits = false; msg.ROReportSpec.TagReportContentSelector.AirProtocolEPCMemorySelector.Add(c1g2mem); msg.ROReportSpec.TagReportContentSelector.EnableAccessSpecID = false; msg.ROReportSpec.TagReportContentSelector.EnableAntennaID = false; msg.ROReportSpec.TagReportContentSelector.EnableChannelIndex = false; msg.ROReportSpec.TagReportContentSelector.EnableFirstSeenTimestamp = true; msg.ROReportSpec.TagReportContentSelector.EnableInventoryParameterSpecID = false; msg.ROReportSpec.TagReportContentSelector.EnableLastSeenTimestamp = false; msg.ROReportSpec.TagReportContentSelector.EnablePeakRSSI = true; msg.ROReportSpec.TagReportContentSelector.EnableROSpecID = false; msg.ROReportSpec.TagReportContentSelector.EnableSpecIndex = false; msg.ROReportSpec.TagReportContentSelector.EnableTagSeenCount = false; /////If you want to enable GPIO function, un-comment following code. //msg.GPIPortCurrentState = new PARAM_GPIPortCurrentState[1]; //msg.GPIPortCurrentState[0] = new PARAM_GPIPortCurrentState(); //msg.GPIPortCurrentState[0].Config = true; //msg.GPIPortCurrentState[0].GPIPortNum = 2; //msg.GPIPortCurrentState[0].State = ENUM_GPIPortState.Low; //msg.GPOWriteData = new PARAM_GPOWriteData[1]; //msg.GPOWriteData[0] = new PARAM_GPOWriteData(); //msg.GPOWriteData[0].GPOData = true; //msg.GPOWriteData[0].GPOPortNumber = 1; //////If you want to use tag direction function, un-comment following code //PARAM_ImpinjTagDirectionReporting imp_tag_reporting = new PARAM_ImpinjTagDirectionReporting(); //imp_tag_reporting.AntennaConfiguration = ENUM_ImpinjTagDirectionAntennaConfiguration.Dual_Antenna; //imp_tag_reporting.EnableTagDirection = true; //msg.ROReportSpec.AddCustomParameter(imp_tag_reporting); /////If you want to set sub-region, un-comment following code //PARAM_ImpinjSubRegulatoryRegion sub_region = new PARAM_ImpinjSubRegulatoryRegion(); //sub_region.RegulatoryRegion = ENUM_ImpinjRegulatoryRegion.FCC_Part_15_247; //msg.AddCustomParameter(sub_region); //msg.ResetToFactoryDefault = false; MSG_SET_READER_CONFIG_RESPONSE rsp = reader.SET_READER_CONFIG(msg, out msg_err, 2121); } catch (Exception ex) { //MessageBox.Show(ex.ToString()); } }
// Sets the client's configuration public void Set_Reader_Config(ReaderManager.ReaderConfig readerconfig) { // find number of antennas to set byte numAntennaToSet = 0; ushort antennaSet = 0; for (int i = 0; i < readerconfig.antennaID.Length; i++) { if (readerconfig.antennaID[i]) { antennaSet = (ushort)i; numAntennaToSet++; } } MSG_SET_READER_CONFIG msg = new MSG_SET_READER_CONFIG(); msg.AccessReportSpec = new PARAM_AccessReportSpec(); msg.AccessReportSpec.AccessReportTrigger = ENUM_AccessReportTriggerType.End_Of_AccessSpec; PARAM_C1G2InventoryCommand cmd = new PARAM_C1G2InventoryCommand(); cmd.C1G2RFControl = new PARAM_C1G2RFControl(); //cmd.C1G2RFControl.ModeIndex = 1000; cmd.C1G2RFControl.ModeIndex = readerconfig.modeIndex; cmd.C1G2RFControl.Tari = 0; cmd.C1G2SingulationControl = new PARAM_C1G2SingulationControl(); cmd.C1G2SingulationControl.Session = new TwoBits(0); cmd.C1G2SingulationControl.TagPopulation = readerconfig.tagPopulation; cmd.C1G2SingulationControl.TagTransitTime = readerconfig.tagTransitTime; cmd.TagInventoryStateAware = false; msg.AntennaConfiguration = new PARAM_AntennaConfiguration[numAntennaToSet]; for (ushort i = 1; i < numAntennaToSet + 1; i++) { msg.AntennaConfiguration[i - 1] = new PARAM_AntennaConfiguration(); msg.AntennaConfiguration[i - 1].AirProtocolInventoryCommandSettings = new UNION_AirProtocolInventoryCommandSettings(); msg.AntennaConfiguration[i - 1].AirProtocolInventoryCommandSettings.Add(cmd); msg.AntennaConfiguration[i - 1].AntennaID = antennaSet; msg.AntennaConfiguration[i - 1].RFReceiver = new PARAM_RFReceiver(); msg.AntennaConfiguration[i - 1].RFReceiver.ReceiverSensitivity = readerconfig.readerSensitivity; msg.AntennaConfiguration[i - 1].RFTransmitter = new PARAM_RFTransmitter(); msg.AntennaConfiguration[i - 1].RFTransmitter.ChannelIndex = readerconfig.channelIndex; msg.AntennaConfiguration[i - 1].RFTransmitter.HopTableID = readerconfig.hopTableIndex; msg.AntennaConfiguration[i - 1].RFTransmitter.TransmitPower = (ushort)(61 - (readerconfig.attenuation * 4)); } //msg.AntennaProperties = new PARAM_AntennaProperties[1]; //msg.AntennaProperties[0] = new PARAM_AntennaProperties(); //msg.AntennaProperties[0].AntennaConnected = true; //msg.AntennaProperties[0].AntennaGain = 0; //msg.AntennaProperties[0].AntennaID = 1; msg.EventsAndReports = new PARAM_EventsAndReports(); msg.EventsAndReports.HoldEventsAndReportsUponReconnect = false; msg.KeepaliveSpec = new PARAM_KeepaliveSpec(); msg.KeepaliveSpec.KeepaliveTriggerType = ENUM_KeepaliveTriggerType.Null; msg.KeepaliveSpec.PeriodicTriggerValue = readerconfig.periodicTriggerValue; msg.ReaderEventNotificationSpec = new PARAM_ReaderEventNotificationSpec(); msg.ReaderEventNotificationSpec.EventNotificationState = new PARAM_EventNotificationState[5]; msg.ReaderEventNotificationSpec.EventNotificationState[0] = new PARAM_EventNotificationState(); msg.ReaderEventNotificationSpec.EventNotificationState[0].EventType = ENUM_NotificationEventType.AISpec_Event; msg.ReaderEventNotificationSpec.EventNotificationState[0].NotificationState = false; msg.ReaderEventNotificationSpec.EventNotificationState[1] = new PARAM_EventNotificationState(); msg.ReaderEventNotificationSpec.EventNotificationState[1].EventType = ENUM_NotificationEventType.Antenna_Event; msg.ReaderEventNotificationSpec.EventNotificationState[1].NotificationState = true; msg.ReaderEventNotificationSpec.EventNotificationState[2] = new PARAM_EventNotificationState(); msg.ReaderEventNotificationSpec.EventNotificationState[2].EventType = ENUM_NotificationEventType.GPI_Event; msg.ReaderEventNotificationSpec.EventNotificationState[2].NotificationState = false; msg.ReaderEventNotificationSpec.EventNotificationState[3] = new PARAM_EventNotificationState(); msg.ReaderEventNotificationSpec.EventNotificationState[3].EventType = ENUM_NotificationEventType.Reader_Exception_Event; msg.ReaderEventNotificationSpec.EventNotificationState[3].NotificationState = true; msg.ReaderEventNotificationSpec.EventNotificationState[4] = new PARAM_EventNotificationState(); msg.ReaderEventNotificationSpec.EventNotificationState[4].EventType = ENUM_NotificationEventType.RFSurvey_Event; msg.ReaderEventNotificationSpec.EventNotificationState[4].NotificationState = true; msg.ROReportSpec = new PARAM_ROReportSpec(); msg.ROReportSpec.N = 1; msg.ROReportSpec.ROReportTrigger = ENUM_ROReportTriggerType.Upon_N_Tags_Or_End_Of_AISpec; msg.ROReportSpec.TagReportContentSelector = new PARAM_TagReportContentSelector(); msg.ROReportSpec.TagReportContentSelector.AirProtocolEPCMemorySelector = new UNION_AirProtocolEPCMemorySelector(); PARAM_C1G2EPCMemorySelector c1g2mem = new PARAM_C1G2EPCMemorySelector(); c1g2mem.EnableCRC = false; c1g2mem.EnablePCBits = false; msg.ROReportSpec.TagReportContentSelector.AirProtocolEPCMemorySelector.Add(c1g2mem); msg.ROReportSpec.TagReportContentSelector.EnableAccessSpecID = false; msg.ROReportSpec.TagReportContentSelector.EnableAntennaID = true; msg.ROReportSpec.TagReportContentSelector.EnableChannelIndex = false; msg.ROReportSpec.TagReportContentSelector.EnableFirstSeenTimestamp = true; msg.ROReportSpec.TagReportContentSelector.EnableInventoryParameterSpecID = false; msg.ROReportSpec.TagReportContentSelector.EnableLastSeenTimestamp = false; msg.ROReportSpec.TagReportContentSelector.EnablePeakRSSI = true; msg.ROReportSpec.TagReportContentSelector.EnableROSpecID = false; msg.ROReportSpec.TagReportContentSelector.EnableSpecIndex = false; msg.ROReportSpec.TagReportContentSelector.EnableTagSeenCount = true; msg.ResetToFactoryDefault = false; MSG_SET_READER_CONFIG_RESPONSE rsp = client.SET_READER_CONFIG(msg, out msg_err, 3000); if (rsp != null) { //textBox2.Text = rsp.ToString() + "\n"; WriteMessage(rsp.ToString(), "setReaderConfig"); } else if (msg_err != null) { WriteMessage("setReaderConfig " + rsp.ToString() + "\n"); } else { WriteMessage("setReaderConfig Commmand time out!" + "\n"); } }
private string SetReaderConfig() { string response = string.Empty; MSG_SET_READER_CONFIG msg = new MSG_SET_READER_CONFIG(); msg.AccessReportSpec = new PARAM_AccessReportSpec(); msg.AccessReportSpec.AccessReportTrigger = ENUM_AccessReportTriggerType.End_Of_AccessSpec; msg.AntennaConfiguration = new PARAM_AntennaConfiguration[1]; msg.AntennaConfiguration[0] = new PARAM_AntennaConfiguration(); msg.AntennaConfiguration[0].AirProtocolInventoryCommandSettings = new UNION_AirProtocolInventoryCommandSettings(); PARAM_C1G2InventoryCommand cmd = new PARAM_C1G2InventoryCommand(); cmd.C1G2RFControl = new PARAM_C1G2RFControl(); cmd.C1G2RFControl.ModeIndex = 2; cmd.C1G2RFControl.Tari = 0; cmd.C1G2SingulationControl = new PARAM_C1G2SingulationControl(); cmd.C1G2SingulationControl.Session = new LTKD.TwoBits(1); cmd.C1G2SingulationControl.TagPopulation = 0; cmd.C1G2SingulationControl.TagTransitTime = 1000; cmd.TagInventoryStateAware = false; msg.AntennaConfiguration[0].AirProtocolInventoryCommandSettings.Add(cmd); msg.AntennaConfiguration[0].AntennaID = 0; msg.AntennaConfiguration[0].RFReceiver = new PARAM_RFReceiver(); msg.AntennaConfiguration[0].RFReceiver.ReceiverSensitivity = 12; msg.AntennaConfiguration[0].RFTransmitter = new PARAM_RFTransmitter(); msg.AntennaConfiguration[0].RFTransmitter.ChannelIndex = 1; msg.AntennaConfiguration[0].RFTransmitter.HopTableID = 1; msg.AntennaConfiguration[0].RFTransmitter.TransmitPower = 61; msg.EventsAndReports = new PARAM_EventsAndReports(); msg.EventsAndReports.HoldEventsAndReportsUponReconnect = false; msg.KeepaliveSpec = new PARAM_KeepaliveSpec(); msg.KeepaliveSpec.KeepaliveTriggerType = ENUM_KeepaliveTriggerType.Null; msg.KeepaliveSpec.PeriodicTriggerValue = 0; msg.ReaderEventNotificationSpec = new PARAM_ReaderEventNotificationSpec(); msg.ReaderEventNotificationSpec.EventNotificationState = new PARAM_EventNotificationState[5]; msg.ReaderEventNotificationSpec.EventNotificationState[0] = new PARAM_EventNotificationState(); msg.ReaderEventNotificationSpec.EventNotificationState[0].EventType = ENUM_NotificationEventType.AISpec_Event; msg.ReaderEventNotificationSpec.EventNotificationState[0].NotificationState = true; msg.ReaderEventNotificationSpec.EventNotificationState[1] = new PARAM_EventNotificationState(); msg.ReaderEventNotificationSpec.EventNotificationState[1].EventType = ENUM_NotificationEventType.Antenna_Event; msg.ReaderEventNotificationSpec.EventNotificationState[1].NotificationState = true; msg.ReaderEventNotificationSpec.EventNotificationState[2] = new PARAM_EventNotificationState(); msg.ReaderEventNotificationSpec.EventNotificationState[2].EventType = ENUM_NotificationEventType.GPI_Event; msg.ReaderEventNotificationSpec.EventNotificationState[2].NotificationState = true; msg.ReaderEventNotificationSpec.EventNotificationState[3] = new PARAM_EventNotificationState(); msg.ReaderEventNotificationSpec.EventNotificationState[3].EventType = ENUM_NotificationEventType.Reader_Exception_Event; msg.ReaderEventNotificationSpec.EventNotificationState[3].NotificationState = true; msg.ReaderEventNotificationSpec.EventNotificationState[4] = new PARAM_EventNotificationState(); msg.ReaderEventNotificationSpec.EventNotificationState[4].EventType = ENUM_NotificationEventType.RFSurvey_Event; msg.ReaderEventNotificationSpec.EventNotificationState[4].NotificationState = true; msg.ROReportSpec = new PARAM_ROReportSpec(); msg.ROReportSpec.N = 1; msg.ROReportSpec.ROReportTrigger = ENUM_ROReportTriggerType.Upon_N_Tags_Or_End_Of_ROSpec; msg.ROReportSpec.TagReportContentSelector = new PARAM_TagReportContentSelector(); msg.ROReportSpec.TagReportContentSelector.AirProtocolEPCMemorySelector = new UNION_AirProtocolEPCMemorySelector(); PARAM_C1G2EPCMemorySelector c1g2mem = new PARAM_C1G2EPCMemorySelector(); c1g2mem.EnableCRC = true; c1g2mem.EnablePCBits = true; msg.ROReportSpec.TagReportContentSelector.AirProtocolEPCMemorySelector.Add(c1g2mem); msg.ROReportSpec.TagReportContentSelector.EnableAccessSpecID = true; msg.ROReportSpec.TagReportContentSelector.EnableAntennaID = true; msg.ROReportSpec.TagReportContentSelector.EnableChannelIndex = true; msg.ROReportSpec.TagReportContentSelector.EnableFirstSeenTimestamp = true; msg.ROReportSpec.TagReportContentSelector.EnableInventoryParameterSpecID = true; msg.ROReportSpec.TagReportContentSelector.EnableLastSeenTimestamp = true; msg.ROReportSpec.TagReportContentSelector.EnablePeakRSSI = true; msg.ROReportSpec.TagReportContentSelector.EnableROSpecID = false; msg.ROReportSpec.TagReportContentSelector.EnableSpecIndex = true; msg.ROReportSpec.TagReportContentSelector.EnableTagSeenCount = true; msg.ResetToFactoryDefault = false; MSG_SET_READER_CONFIG_RESPONSE rsp = llrp.SET_READER_CONFIG(msg, out errorMessage, 3000); if (rsp != null) { response = rsp.ToString(); } else if (errorMessage != null) { response = errorMessage.ToString(); } else { response = "Command time out!"; } return response; }
private void BuildRoSpec(ReadPlan rp, int timeOut, List<PARAM_ROSpec> roSpecList, bool isStandaloneOp) { string response = string.Empty; if (rp is MultiReadPlan) { MultiReadPlan mrp = (MultiReadPlan)rp; numPlans = mrp.Plans.Length; foreach (ReadPlan r in mrp.Plans) { // Ideally, totalWeight=0 would allow reader to // dynamically adjust timing based on tags observed. // For now, just divide equally. int subtimeout = (mrp.TotalWeight != 0) ? (int)timeOut * r.Weight / mrp.TotalWeight : timeOut / mrp.Plans.Length; totalWeight = (uint)mrp.TotalWeight; subtimeout = Math.Min(subtimeout, UInt16.MaxValue); BuildRoSpec(r, subtimeout, roSpecList,false); } } else if (rp is SimpleReadPlan) { //MSG_ADD_ROSPEC msg = new MSG_ADD_ROSPEC(); // Create a Reader Operation Spec (ROSpec). PARAM_ROSpec roSpec = new PARAM_ROSpec(); roSpec.CurrentState = ENUM_ROSpecState.Disabled; roSpec.Priority = 0; roSpec.ROSpecID = ++roSpecId; //Add rospec id and protocol in the hashtable. So that it can be used to populate the tagdata's protocol member with the read tag protocol. roSpecProtcolTable.Add(roSpec.ROSpecID,((SimpleReadPlan)rp).Protocol); // Set up the ROBoundarySpec // This defines the start and stop triggers. roSpec.ROBoundarySpec = new PARAM_ROBoundarySpec(); // Set the start trigger to null. // This means the ROSpec will start as soon as it is enabled. roSpec.ROBoundarySpec.ROSpecStartTrigger = new PARAM_ROSpecStartTrigger(); uint asyncOnTime = Convert.ToUInt16(ParamGet("/reader/read/asyncOnTime")); if (continuousReading && numPlans > 1) { roSpec.ROBoundarySpec.ROSpecStartTrigger.ROSpecStartTriggerType = ENUM_ROSpecStartTriggerType.Periodic; PARAM_PeriodicTriggerValue pValue = new PARAM_PeriodicTriggerValue(); pValue.Offset = 0; pValue.Period = asyncOnTime; roSpec.ROBoundarySpec.ROSpecStartTrigger.PeriodicTriggerValue = pValue; } else { roSpec.ROBoundarySpec.ROSpecStartTrigger.ROSpecStartTriggerType = ENUM_ROSpecStartTriggerType.Null; } // Set the stop trigger is null. This means the ROSpec // will keep running until an STOP_ROSPEC message is sent. roSpec.ROBoundarySpec.ROSpecStopTrigger = new PARAM_ROSpecStopTrigger(); roSpec.ROBoundarySpec.ROSpecStopTrigger.ROSpecStopTriggerType = ENUM_ROSpecStopTriggerType.Null; roSpec.SpecParameter = new UNION_SpecParameter(); PARAM_AISpec aiSpec = new PARAM_AISpec(); // Select which antenna ports we want to use based on the read plan settings aiSpec.AntennaIDs = new LTKD.UInt16Array(); SimpleReadPlan srp = (SimpleReadPlan)rp; //Check for fast search enable isFastSearch = srp.UseFastSearch; //Validate protocol ValidateProtocol(srp.Protocol); int[] antennas = srp.Antennas; if (null == antennas) { aiSpec.AntennaIDs.Add(0); //0 : applys to all antennae, } else { foreach (int antenna in antennas) aiSpec.AntennaIDs.Add((ushort)antenna); } //Specify AI spec trigger type aiSpec.AISpecStopTrigger = new PARAM_AISpecStopTrigger(); //Specify Report spec roSpec.ROReportSpec = new PARAM_ROReportSpec(); if (continuousReading) { // ASYNC Mode - Set the AI stop trigger to null. AI spec will run until the ROSpec stops. if(numPlans > 1) { // ASYNC Mode - Set the AI stop trigger to Duration - AsyncOnTime. AI spec will run until the Disable ROSpec is sent. aiSpec.AISpecStopTrigger.AISpecStopTriggerType = ENUM_AISpecStopTriggerType.Duration; aiSpec.AISpecStopTrigger.DurationTrigger = (uint)timeOut; } else { aiSpec.AISpecStopTrigger.AISpecStopTriggerType = ENUM_AISpecStopTriggerType.Null; aiSpec.AISpecStopTrigger.DurationTrigger = 0; } // Receive a report every time a tag is read. roSpec.ROReportSpec.N = 1; } else { // SYNC Mode - Set the AI stop trigger to inputted duration. AI spec will run for particular duration aiSpec.AISpecStopTrigger.AISpecStopTriggerType = ENUM_AISpecStopTriggerType.Duration; aiSpec.AISpecStopTrigger.DurationTrigger = (uint)timeOut; roSpec.ROReportSpec.N = 0; } PARAM_InventoryParameterSpec inventoryParam = new PARAM_InventoryParameterSpec(); List<PARAM_InventoryParameterSpec> invParamList = new List<PARAM_InventoryParameterSpec>(); inventoryParam.InventoryParameterSpecID = 1; TagFilter tagFilter = srp.Filter; //Filter if(tagFilter != null) { List<PARAM_AntennaConfiguration> antennaConfigList = new List<PARAM_AntennaConfiguration>(); PARAM_AntennaConfiguration antConfig = new PARAM_AntennaConfiguration(); antConfig.AntennaID = 0; if (TagProtocol.GEN2.Equals(srp.Protocol)) { List<PARAM_C1G2Filter> filterList = new List<PARAM_C1G2Filter>(); PARAM_C1G2Filter filter = new PARAM_C1G2Filter(); PARAM_C1G2TagInventoryMask mask; filter.T = ENUM_C1G2TruncateAction.Do_Not_Truncate; PARAM_C1G2InventoryCommand inventoryCommand = new PARAM_C1G2InventoryCommand(); inventoryCommand.TagInventoryStateAware = false; PARAM_C1G2TagInventoryStateUnawareFilterAction unAwareAction = new PARAM_C1G2TagInventoryStateUnawareFilterAction(); unAwareAction.Action = ENUM_C1G2StateUnawareAction.Select_Unselect; if (tagFilter is Gen2.Select) { Gen2.Select selectFilter = (Gen2.Select)tagFilter; mask = new PARAM_C1G2TagInventoryMask(); // Memory Bank mask.MB = new LTKD.TwoBits((ushort)selectFilter.Bank); mask.TagMask = LTKD.LLRPBitArray.FromHexString(ByteFormat.ToHex(selectFilter.Mask).Split('x')[1].ToString()); mask.Pointer = (ushort)selectFilter.BitPointer; filter.C1G2TagInventoryMask = mask; if (selectFilter.Invert) { unAwareAction.Action = ENUM_C1G2StateUnawareAction.Unselect_Select; } filter.C1G2TagInventoryStateUnawareFilterAction = unAwareAction; } else if (tagFilter is TagData) { TagData tagDataFilter = (TagData)tagFilter; mask = new PARAM_C1G2TagInventoryMask(); // EPC Memory Bank mask.MB = new LTKD.TwoBits((ushort)Gen2.Bank.EPC); mask.TagMask = LTKD.LLRPBitArray.FromHexString(tagDataFilter.EpcString); //For epc bit pointer is 32 mask.Pointer = 32; filter.C1G2TagInventoryMask = mask; filter.C1G2TagInventoryStateUnawareFilterAction = unAwareAction; } else { throw new Exception("Unsupported operation"); } filterList.Add(filter); inventoryCommand.C1G2Filter = filterList.ToArray(); antConfig.AirProtocolInventoryCommandSettings.Add(inventoryCommand); antennaConfigList.Add(antConfig); inventoryParam.AntennaConfiguration = antennaConfigList.ToArray(); } else if (TagProtocol.ISO180006B.Equals(srp.Protocol)) { if (tagFilter is Iso180006b.Select) { PARAM_ThingMagicISO180006BTagPattern tagPattern = new PARAM_ThingMagicISO180006BTagPattern(); //Filter type tagPattern.FilterType = ENUM_ThingMagicISO180006BFilterType.ISO180006BSelect; //Invert tagPattern.Invert = ((Iso180006b.Select)tagFilter).Invert; //Address tagPattern.Address = Convert.ToByte(((Iso180006b.Select)tagFilter).Address.ToString("X")); //Mask tagPattern.Mask = ((Iso180006b.Select)tagFilter).Mask; //SelectOp tagPattern.SelectOp = new Org.LLRP.LTK.LLRPV1.DataType.TwoBits(Convert.ToUInt16(((Iso180006b.Select)tagFilter).Op)); //TagData tagPattern.TagData = LTKD.ByteArray.FromHexString(ByteFormat.ToHex(((Iso180006b.Select)tagFilter).Data).Split('x')[1]); PARAM_ThingMagicISO180006BInventoryCommand iso18k6bInventoryCmd = new PARAM_ThingMagicISO180006BInventoryCommand(); iso18k6bInventoryCmd.ThingMagicISO180006BTagPattern = tagPattern; antConfig.AirProtocolInventoryCommandSettings.Add(iso18k6bInventoryCmd); antennaConfigList.Add(antConfig); inventoryParam.AntennaConfiguration = antennaConfigList.ToArray(); } else if(tagFilter is TagData) { PARAM_ThingMagicISO180006BTagPattern tagPattern = new PARAM_ThingMagicISO180006BTagPattern(); //Filter type tagPattern.FilterType = ENUM_ThingMagicISO180006BFilterType.ISO180006BTagData; //Invert tagPattern.Invert = false; //Address tagPattern.Address = 0; //Mask tagPattern.Mask = 0xff; //SelectOp tagPattern.SelectOp = new Org.LLRP.LTK.LLRPV1.DataType.TwoBits(Convert.ToUInt16(((Iso180006b.SelectOp.EQUALS)))); //TagData tagPattern.TagData = LTKD.ByteArray.FromHexString(((TagData)tagFilter).EpcString); PARAM_ThingMagicISO180006BInventoryCommand iso18k6bInventoryCmd = new PARAM_ThingMagicISO180006BInventoryCommand(); iso18k6bInventoryCmd.ThingMagicISO180006BTagPattern = tagPattern; antConfig.AirProtocolInventoryCommandSettings.Add(iso18k6bInventoryCmd); antennaConfigList.Add(antConfig); inventoryParam.AntennaConfiguration = antennaConfigList.ToArray(); } else { throw new Exception("Unsupported operation"); } } } if (isFastSearch) { List<PARAM_AntennaConfiguration> antennaConfigList = new List<PARAM_AntennaConfiguration>(); PARAM_AntennaConfiguration antConfig = new PARAM_AntennaConfiguration(); PARAM_ThingMagicFastSearchMode fastSearch = new PARAM_ThingMagicFastSearchMode(); fastSearch.ThingMagicFastSearch = ENUM_ThingMagicFastSearchValue.Enabled; PARAM_C1G2InventoryCommand inventoryCommandFastSearch = new PARAM_C1G2InventoryCommand(); inventoryCommandFastSearch.AddCustomParameter(fastSearch); antConfig.AirProtocolInventoryCommandSettings.Add(inventoryCommandFastSearch); antennaConfigList.Add(antConfig); inventoryParam.AntennaConfiguration = antennaConfigList.ToArray(); } //Emebeded tagops TagOp tagOperation = srp.Op; PARAM_AccessCommand accessCommand = new PARAM_AccessCommand(); PARAM_AccessSpec accessSpec = new PARAM_AccessSpec(); if (null != tagOperation) { accessSpec.AccessSpecID = ++AccessSpecID; accessSpec.AccessCommand = accessCommand; accessSpec.ROSpecID = roSpecId; PARAM_AccessSpecStopTrigger trigger = new PARAM_AccessSpecStopTrigger(); if (!isStandaloneOp)//Embedded operation { if (tagOperation is Gen2.NxpGen2TagOp.EasAlarm) { throw new FeatureNotSupportedException("Gen2.NxpGen2TagOp.EasAlarm command can be standalone tag operation "); } if (tagOperation is Gen2.NXP.G2X.ResetReadProtect) { throw new FeatureNotSupportedException("NXP Reset Read protect command can be embedded only if the chip-type is G2il"); } accessSpec.AntennaID = 0; trigger.AccessSpecStopTrigger = ENUM_AccessSpecStopTriggerType.Null; trigger.OperationCountValue = 0; } else { //standalone operation if (tagOperation is Gen2.Alien.Higgs2.PartialLoadImage) { if (null != tagFilter) { throw new ReaderException("Filter is not supported on this operation."); } } accessSpec.AntennaID = Convert.ToUInt16(ParamGet("/reader/tagop/antenna")); trigger.AccessSpecStopTrigger = ENUM_AccessSpecStopTriggerType.Operation_Count; trigger.OperationCountValue = 1; } accessCommand.AccessCommandOpSpec.Add(BuildOpSpec(srp)); accessSpec.ProtocolID = ENUM_AirProtocols.EPCGlobalClass1Gen2; accessSpec.CurrentState = ENUM_AccessSpecState.Disabled; accessSpec.AccessSpecStopTrigger = trigger; // Add a list of target tags to the tag spec. PARAM_C1G2TagSpec tagSpec = new PARAM_C1G2TagSpec(); PARAM_C1G2TargetTag targetTag = new PARAM_C1G2TargetTag(); targetTag.MB = new LTKD.TwoBits(0); targetTag.Match = false; targetTag.Pointer = 0; targetTag.TagData = LTKD.LLRPBitArray.FromBinString("0"); targetTag.TagMask = LTKD.LLRPBitArray.FromBinString("0"); List<PARAM_C1G2TargetTag> targetTagList = new List<PARAM_C1G2TargetTag>(); targetTagList.Add(targetTag); tagSpec.C1G2TargetTag = targetTagList.ToArray(); //Add the tag spec to the access command. accessCommand.AirProtocolTagSpec.Add(tagSpec); AddAccessSpec(accessSpec); EnableAccessSpec(accessSpec.AccessSpecID); } // Reading Gen2 Tags, specify in InventorySpec if (TagProtocol.GEN2 == srp.Protocol) { inventoryParam.ProtocolID = ENUM_AirProtocols.EPCGlobalClass1Gen2; } else if (TagProtocol.ISO180006B == srp.Protocol) { inventoryParam.ProtocolID = ENUM_AirProtocols.Unspecified; PARAM_ThingMagicCustomAirProtocols airProtocol = new PARAM_ThingMagicCustomAirProtocols(); airProtocol.customProtocolId = ENUM_ThingMagicCustomAirProtocolList.Iso180006b; inventoryParam.Custom.Add(airProtocol); } else { throw new FeatureNotSupportedException("Only GEN2 and ISO18K6B protocol is supported as of now"); } invParamList.Add(inventoryParam); aiSpec.InventoryParameterSpec = invParamList.ToArray(); // Specify what type of tag reports we want to receive and when we want to receive them. roSpec.ROReportSpec.ROReportTrigger = ENUM_ROReportTriggerType.Upon_N_Tags_Or_End_Of_ROSpec; roSpec.SpecParameter.Add(aiSpec); // Selecting which fields we want in the report. roSpec.ROReportSpec.TagReportContentSelector = new PARAM_TagReportContentSelector(); roSpec.ROReportSpec.TagReportContentSelector.EnableAccessSpecID = true; roSpec.ROReportSpec.TagReportContentSelector.EnableAntennaID = true; roSpec.ROReportSpec.TagReportContentSelector.EnableChannelIndex = true; roSpec.ROReportSpec.TagReportContentSelector.EnableFirstSeenTimestamp = true; roSpec.ROReportSpec.TagReportContentSelector.EnableInventoryParameterSpecID = true; roSpec.ROReportSpec.TagReportContentSelector.EnableLastSeenTimestamp = true; roSpec.ROReportSpec.TagReportContentSelector.EnablePeakRSSI = true; roSpec.ROReportSpec.TagReportContentSelector.EnableROSpecID = true; roSpec.ROReportSpec.TagReportContentSelector.EnableSpecIndex = true; roSpec.ROReportSpec.TagReportContentSelector.EnableTagSeenCount = true; // By default both PC and CRC bits are set, so sent from tmmpd PARAM_C1G2EPCMemorySelector gen2MemSelector = new PARAM_C1G2EPCMemorySelector(); gen2MemSelector.EnableCRC = true; gen2MemSelector.EnablePCBits = true; roSpec.ROReportSpec.TagReportContentSelector.AirProtocolEPCMemorySelector.Add(gen2MemSelector); // Since Spruce release firmware doesn't support phase, don't add PARAM_ThingMagicTagReportContentSelector // custom paramter in ROReportSpec string[] ver = softwareVersion.Split('.'); if (((Convert.ToInt32(ver[0]) == 4) && (Convert.ToInt32(ver[1]) >= 17)) || (Convert.ToInt32(ver[0]) > 4)) { PARAM_ThingMagicTagReportContentSelector tagReportContentSelector = new PARAM_ThingMagicTagReportContentSelector(); tagReportContentSelector.PhaseMode = ENUM_ThingMagicPhaseMode.Enabled; roSpec.ROReportSpec.AddCustomParameter(tagReportContentSelector); } roSpecList.Add(roSpec); } }
/// <summary></summary> protected override void AddROSpec(uint roSpecId) { MSG_ADD_ROSPEC msg = new MSG_ADD_ROSPEC(); // ROSpec PARAM_ROSpec pROSpec = new PARAM_ROSpec(); msg.ROSpec = pROSpec; pROSpec.ROSpecID = roSpecId; pROSpec.Priority = 0; pROSpec.CurrentState = ENUM_ROSpecState.Disabled; // Boundary Spec PARAM_ROBoundarySpec pBoundary = new PARAM_ROBoundarySpec(); pROSpec.ROBoundarySpec = pBoundary; // Start Trigger pBoundary.ROSpecStartTrigger = new PARAM_ROSpecStartTrigger(); //pBoundary.ROSpecStartTrigger.ROSpecStartTriggerType = ENUM_ROSpecStartTriggerType.Immediate; pBoundary.ROSpecStartTrigger.ROSpecStartTriggerType = ENUM_ROSpecStartTriggerType.Null; // Stop Trigger pBoundary.ROSpecStopTrigger = new PARAM_ROSpecStopTrigger(); pBoundary.ROSpecStopTrigger.DurationTriggerValue = 0; pBoundary.ROSpecStopTrigger.ROSpecStopTriggerType = ENUM_ROSpecStopTriggerType.Null; // Report Spec PARAM_ROReportSpec pReport = new PARAM_ROReportSpec(); pROSpec.ROReportSpec = pReport; pReport.N = 1; pReport.ROReportTrigger = ENUM_ROReportTriggerType.Upon_N_Tags_Or_End_Of_ROSpec; // Tag report content selector PARAM_TagReportContentSelector pTagReportContentSelector = new PARAM_TagReportContentSelector(); pReport.TagReportContentSelector = pTagReportContentSelector; pTagReportContentSelector.AirProtocolEPCMemorySelector = new UNION_AirProtocolEPCMemorySelector(); PARAM_C1G2EPCMemorySelector pEpcMemorySelector = new PARAM_C1G2EPCMemorySelector(); pTagReportContentSelector.AirProtocolEPCMemorySelector.Add(pEpcMemorySelector); pEpcMemorySelector.EnableCRC = false; pEpcMemorySelector.EnablePCBits = false; pTagReportContentSelector.EnableROSpecID = false; pTagReportContentSelector.EnableSpecIndex = false; pTagReportContentSelector.EnableInventoryParameterSpecID = false; pTagReportContentSelector.EnableAntennaID = true; pTagReportContentSelector.EnablePeakRSSI = true; pTagReportContentSelector.EnableFirstSeenTimestamp = true; pTagReportContentSelector.EnableLastSeenTimestamp = false; pTagReportContentSelector.EnableTagSeenCount = false; pTagReportContentSelector.EnableAccessSpecID = false; pROSpec.SpecParameter = new UNION_SpecParameter(); // Impinj DI spec PARAM_ImpinjDISpec pDI = new PARAM_ImpinjDISpec(); pROSpec.SpecParameter.Add(pDI); // Impinj Direction Sectors PARAM_ImpinjDirectionSectors pDirectionSectors = new PARAM_ImpinjDirectionSectors(); pDI.ImpinjDirectionSectors = pDirectionSectors; pDirectionSectors.EnabledSectorIDs = new UInt16Array(); pDirectionSectors.EnabledSectorIDs.Add(2); pDirectionSectors.EnabledSectorIDs.Add(3); // Direction Config PARAM_ImpinjDirectionConfig pDirectionConfig = new PARAM_ImpinjDirectionConfig(); pDI.ImpinjDirectionConfig = pDirectionConfig; pDirectionConfig.TagAgeIntervalSeconds = 0x02; pDirectionConfig.UpdateIntervalSeconds = 0x02; pDirectionConfig.FieldOfView = ENUM_ImpinjDirectionFieldOfView.ReaderSelected; PARAM_ImpinjDirectionUserTagPopulationLimit pDITagPopulationLimit = new PARAM_ImpinjDirectionUserTagPopulationLimit(); pDirectionConfig.ImpinjDirectionUserTagPopulationLimit = pDITagPopulationLimit; pDITagPopulationLimit.UserTagPopulationLimit = 20; // 0x14 // Impinj C1G2 Direction Config PARAM_ImpinjC1G2DirectionConfig pC1G2DirectionConfig = new PARAM_ImpinjC1G2DirectionConfig(); pDI.ImpinjC1G2DirectionConfig = pC1G2DirectionConfig; pC1G2DirectionConfig.RFMode = ENUM_ImpinjDirectionRFMode.HighPerformance; // 出力電力 PARAM_ImpinjTransmitPower pTransmitPower = new PARAM_ImpinjTransmitPower(); pC1G2DirectionConfig.ImpinjTransmitPower = pTransmitPower; //pTransmitPower.TransmitPower = 81; pTransmitPower.TransmitPower = 21; PARAM_ImpinjDirectionReporting pDirectionReporting = new PARAM_ImpinjDirectionReporting(); pDI.ImpinjDirectionReporting = pDirectionReporting; pDirectionReporting.DiagnosticReportLevel = 0; pDirectionReporting.EnableEntryReport = true; pDirectionReporting.EnableExitReport = true; pDirectionReporting.EnableUpdateReport = true; pDirectionReporting.EnableDiagnosticReport = false; MSG_ERROR_MESSAGE? msgErr = null; MSG_ADD_ROSPEC_RESPONSE?msgResp = this.BaseClient?.ADD_ROSPEC( msg: msg, msg_err: out msgErr, time_out: this.Timeout); LLRPHelper.CheckLLRPResponse(msgResp, msgErr); }