コード例 #1
0
ファイル: LLRPParam.cs プロジェクト: ajeck/impinj-reader-app
        public static PARAM_AISpec FromXmlNode(XmlNode node)
        {
            string val;
            PARAM_AISpec param = new PARAM_AISpec();


            val = XmlUtil.GetNodeValue(node, "AntennaIDs");

            param.AntennaIDs = UInt16Array.FromString(val);

            try
            {

                XmlNodeList xnl = XmlUtil.GetXmlNodes(node, "AISpecStopTrigger");
                if (null != xnl)
                {
                    if (xnl.Count != 0)
                        param.AISpecStopTrigger = PARAM_AISpecStopTrigger.FromXmlNode(xnl[0]);
                }

            }
            catch { }

            try
            {

                XmlNodeList xnl = XmlUtil.GetXmlNodes(node, "InventoryParameterSpec");
                if (xnl != null)
                {
                    if (xnl.Count != 0)
                    {
                        param.InventoryParameterSpec = new PARAM_InventoryParameterSpec[xnl.Count];
                        for (int i = 0; i < xnl.Count; i++)
                            param.InventoryParameterSpec[i] = PARAM_InventoryParameterSpec.FromXmlNode(xnl[i]);
                    }
                }

            }
            catch { }

            try
            {

                ArrayList xnl = XmlUtil.GetXmlNodeCustomChildren(node);
                if (xnl != null)
                {
                    if (xnl.Count != 0)
                    {
                        for (int i = 0; i < xnl.Count; i++)
                        {
                            ICustom_Parameter custom = CustomParamDecodeFactory.DecodeXmlNodeToCustomParameter((XmlNode)xnl[i]);
                            if (custom != null) param.AddCustomParameter(custom);
                        }
                    }
                }

            }
            catch { }

            return param;
        }
コード例 #2
0
ファイル: RFIDReader.cs プロジェクト: ajeck/impinj-reader-app
        //////////////////////////////////////////////////////////////////////////////////////
        //////////////////////////////////////////////////////////////////////////////////////
        //////////////////////////////////////////////////////////////////////////////////////
        //////////////////////////////////////////////////////////////////////////////////////
        //////////////////////////////////////////////////////////////////////////////////////
        //////////////////////////////////////////////////////////////////////////////////////




        #region RO Spec
        /// <summary>
        /// Communicates the information of a ROSpec to the Reader.
        /// </summary>
        public void Add_RoSpec(ReaderManager.InventoryConfig inventoryconfig, ReaderManager.ReaderConfig readerconfig)
        {
            // Create a new message to be sent to the client
            MSG_ADD_ROSPEC msg = new MSG_ADD_ROSPEC();

            msg.ROSpec = new PARAM_ROSpec();
            msg.ROSpec.CurrentState = ENUM_ROSpecState.Disabled;   // Reader's current state: Disable 
            msg.ROSpec.Priority = 0x00;     // specifies the priority of the rospect                           
            msg.ROSpec.ROSpecID = 123;

            //==============================
            // Start condition
            msg.ROSpec.ROBoundarySpec = new PARAM_ROBoundarySpec();
            msg.ROSpec.ROBoundarySpec.ROSpecStartTrigger = new PARAM_ROSpecStartTrigger();
            // Null – No start trigger. The only way to start the ROSpec is with a START_ROSPEC from the Client.
            // 1 Immediate
            // 2 Periodic
            // 3 GPI
            // Note: This ROSpect starts immediatelly
            msg.ROSpec.ROBoundarySpec.ROSpecStartTrigger.ROSpecStartTriggerType = inventoryconfig.startTrigger;


            // Stop condition
            msg.ROSpec.ROBoundarySpec.ROSpecStopTrigger = new PARAM_ROSpecStopTrigger();
            // 0 Null – Stop when all AISpecs are done, or when preempted, or with a STOP_ROSPEC from the Client.
            // 1 Duration
            // 2 GPI with a timeout value
            // DurationTriggerValue: Duration in milliseconds

            // Trigger 1
            msg.ROSpec.ROBoundarySpec.ROSpecStopTrigger.ROSpecStopTriggerType = inventoryconfig.stopTrigger;

            //msg.ROSpec.ROBoundarySpec.ROSpecStopTrigger.DurationTriggerValue = 1000;


            // ROReportSpec triger 
            // 0 None
            // 1 (Upon N TagReportData Parameters or End of AISpec) Or (End of RFSurveySpec) - N=0 is unlimited.
            // 2 Upon N TagReportData Parameters or End of ROSpec N=0 is unlimited.

            // N: Unsigned Short Integer. This is the number of TagReportData Parameters used in ROReportTrigger = 1 and 2.
            // If N = 0, there is no limit on the number of TagReportData Parameters. 
            // This field SHALL be ignored when ROReportTrigger = 0.
            msg.ROSpec.ROReportSpec = new PARAM_ROReportSpec();
            msg.ROSpec.ROReportSpec.ROReportTrigger = inventoryconfig.reportTrigger;
            msg.ROSpec.ROReportSpec.N = inventoryconfig.reportN;


            // Report 2
            //msg.ROSpec.ROReportSpec.ROReportTrigger = ENUM_ROReportTriggerType.Upon_N_Tags_Or_End_Of_ROSpec;
            //msg.ROSpec.ROReportSpec.N = 0; 

            msg.ROSpec.ROReportSpec.TagReportContentSelector = new PARAM_TagReportContentSelector();
            msg.ROSpec.ROReportSpec.TagReportContentSelector.EnableAccessSpecID = true;
            msg.ROSpec.ROReportSpec.TagReportContentSelector.EnableAntennaID = true;
            msg.ROSpec.ROReportSpec.TagReportContentSelector.EnableChannelIndex = true;
            msg.ROSpec.ROReportSpec.TagReportContentSelector.EnableFirstSeenTimestamp = true;
            msg.ROSpec.ROReportSpec.TagReportContentSelector.EnableInventoryParameterSpecID = true;
            msg.ROSpec.ROReportSpec.TagReportContentSelector.EnableLastSeenTimestamp = true;
            msg.ROSpec.ROReportSpec.TagReportContentSelector.EnablePeakRSSI = true;
            msg.ROSpec.ROReportSpec.TagReportContentSelector.EnableROSpecID = true;
            msg.ROSpec.ROReportSpec.TagReportContentSelector.EnableSpecIndex = true;
            msg.ROSpec.ROReportSpec.TagReportContentSelector.EnableTagSeenCount = true;

            msg.ROSpec.SpecParameter = new UNION_SpecParameter();

            // Antena inventory operation
            PARAM_AISpec aiSpec = new PARAM_AISpec();

            // 12345

            aiSpec.AntennaIDs = new UInt16Array();
            //aiSpec.AntennaIDs.Add(0);       //0 :  applys to all antennae,
            for (ushort i = 1; i < readerconfig.antennaID.Length + 1; i++)
                if (readerconfig.antennaID[i - 1])
                {
                    aiSpec.AntennaIDs.Add(i);
                }
            // Stop trigger parameter 
            // 0 Null – Stop when ROSpec is done.
            // 1 Duration
            // 2 GPI with a timeout value
            // 3 Tag observation

            //if (inventorymode)
            //{
                // TriggerType: Integer
                // Possible Values: Value Modulation
                // ------ ------------
                // 0 Upon seeing N tag observations, or timeout
                // 1 Upon seeing no more new tag observations for t ms,or timeout
                // 2 N attempts to see all tags in the FOV, or timeout

                if (inventoryconfig.AITriggerType == ENUM_AISpecStopTriggerType.Tag_Observation)
                {
                    // Antena inventory operation
                    aiSpec.AISpecStopTrigger = new PARAM_AISpecStopTrigger();
                    aiSpec.AISpecStopTrigger.AISpecStopTriggerType = ENUM_AISpecStopTriggerType.Tag_Observation;
                    aiSpec.AISpecStopTrigger.TagObservationTrigger = new PARAM_TagObservationTrigger();

                    if (inventoryconfig.numAttempts == 0)
                    {
                        // Trigger type 1: works
                        aiSpec.AISpecStopTrigger.TagObservationTrigger.TriggerType = ENUM_TagObservationTriggerType.Upon_Seeing_N_Tags_Or_Timeout;
                        aiSpec.AISpecStopTrigger.TagObservationTrigger.NumberOfTags = inventoryconfig.numTags;
                        aiSpec.AISpecStopTrigger.TagObservationTrigger.Timeout = inventoryconfig.AITimeout;   // There is no time out
                    }
                    else
                    {
                        // Trigger type 2
                        aiSpec.AISpecStopTrigger.TagObservationTrigger.TriggerType = ENUM_TagObservationTriggerType.N_Attempts_To_See_All_Tags_In_FOV_Or_Timeout;
                        aiSpec.AISpecStopTrigger.TagObservationTrigger.NumberOfAttempts = inventoryconfig.numAttempts;
                        aiSpec.AISpecStopTrigger.TagObservationTrigger.Timeout = inventoryconfig.AITimeout;   // There is no time out
                    }

                }
                else if (inventoryconfig.AITriggerType == ENUM_AISpecStopTriggerType.Duration)
                {
                    // Antena inventory operation
                    aiSpec.AISpecStopTrigger = new PARAM_AISpecStopTrigger();
                    aiSpec.AISpecStopTrigger.AISpecStopTriggerType = ENUM_AISpecStopTriggerType.Duration;
                    aiSpec.AISpecStopTrigger.DurationTrigger = inventoryconfig.duration;
                }

                else if (inventoryconfig.AITriggerType == ENUM_AISpecStopTriggerType.GPI_With_Timeout)
                {
                    aiSpec.AISpecStopTrigger = new PARAM_AISpecStopTrigger();
                    aiSpec.AISpecStopTrigger.AISpecStopTriggerType = ENUM_AISpecStopTriggerType.GPI_With_Timeout;
                    aiSpec.AISpecStopTrigger.GPITriggerValue.Timeout = inventoryconfig.AITimeout;
                }

            //}


            // Operational parameters for an inventory using a single air protocol.
            aiSpec.InventoryParameterSpec = new PARAM_InventoryParameterSpec[1];
            aiSpec.InventoryParameterSpec[0] = new PARAM_InventoryParameterSpec();
            aiSpec.InventoryParameterSpec[0].InventoryParameterSpecID = 1234;
            aiSpec.InventoryParameterSpec[0].ProtocolID = ENUM_AirProtocols.EPCGlobalClass1Gen2;

            msg.ROSpec.SpecParameter.Add(aiSpec);   // Add operational parameters to Add_ROSpec msg

            // Send message to client and get the response

            MSG_ADD_ROSPEC_RESPONSE rsp = client.ADD_ROSPEC(msg, out msg_err, 3000);


            if (rsp != null)
            {
                //textBox2.Text = rsp.ToString() + "\n";
                WriteMessage(rsp.ToString(), "Add_RoSpec");
                WriteMessage("Add_RoSpec \n");
            }
            else if (msg_err != null)
            {
                WriteMessage("Add_RoSpec " + msg_err.ToString() + "\n");
            }
            else
                WriteMessage("Add_RoSpec Command time out!" + "\n");

        }
コード例 #3
0
ファイル: LLRPParam.cs プロジェクト: ajeck/impinj-reader-app
        public new static PARAM_AISpec FromBitArray(ref BitArray bit_array, ref int cursor, int length)
        {
            if (cursor >= length) return null;

            int field_len = 0;
            object obj_val;
            int parameter_len = 0;
            ArrayList param_list = new ArrayList();

            PARAM_AISpec param = new PARAM_AISpec();

            int param_type = 0;

            if (bit_array[cursor]) param.tvCoding = true;
            if (param.tvCoding)
            {
                cursor++;
                param_type = (int)(UInt64)Util.CalculateVal(ref bit_array, ref cursor, 7);

                if (param_type != param.TypeID)
                {
                    cursor -= 8;
                    return null;
                }
            }
            else
            {
                cursor += 6;
                param_type = (int)(UInt64)Util.CalculateVal(ref bit_array, ref cursor, 10);

                if (param_type != param.TypeID)
                {
                    cursor -= 16;
                    return null;
                }
                param.length = (UInt16)(int)Util.DetermineFieldLength(ref bit_array, ref cursor);
            }


            if (cursor > length) throw new Exception("Input data is not complete message");

            field_len = Util.DetermineFieldLength(ref bit_array, ref cursor);

            Util.ConvertBitArrayToObj(ref bit_array, ref cursor, out obj_val, typeof(UInt16Array), field_len);
            param.AntennaIDs = (UInt16Array)obj_val;

            param.AISpecStopTrigger = PARAM_AISpecStopTrigger.FromBitArray(ref bit_array, ref cursor, length);

            param_list = new ArrayList();
            PARAM_InventoryParameterSpec _param_InventoryParameterSpec = PARAM_InventoryParameterSpec.FromBitArray(ref bit_array, ref cursor, length);
            if (_param_InventoryParameterSpec != null)
            {
                param_list.Add(_param_InventoryParameterSpec);
                while ((_param_InventoryParameterSpec = PARAM_InventoryParameterSpec.FromBitArray(ref bit_array, ref cursor, length)) != null) param_list.Add(_param_InventoryParameterSpec);
                if (param_list.Count > 0)
                {
                    param.InventoryParameterSpec = new PARAM_InventoryParameterSpec[param_list.Count];
                    for (int i = 0; i < param_list.Count; i++)
                        param.InventoryParameterSpec[i] = (PARAM_InventoryParameterSpec)param_list[i];
                }
            }

            ICustom_Parameter custom = CustomParamDecodeFactory.DecodeCustomParameter(ref bit_array, ref cursor, length);
            if (custom != null)
            {
                param.Custom.Add(custom);
                while ((custom = CustomParamDecodeFactory.DecodeCustomParameter(ref bit_array, ref cursor, length)) != null) param.Custom.Add(custom);
            }

            return param;
        }