Example #1
0
        public static MSG_GET_READER_CAPABILITIES_RESPONSE FromBitArray(
            ref BitArray bit_array,
            ref int cursor,
            int length)
        {
            if (cursor > length)
            {
                return((MSG_GET_READER_CAPABILITIES_RESPONSE)null);
            }
            ArrayList arrayList = new ArrayList();
            MSG_GET_READER_CAPABILITIES_RESPONSE capabilitiesResponse = new MSG_GET_READER_CAPABILITIES_RESPONSE();

            cursor += 6;
            if ((int)(ulong)Util.CalculateVal(ref bit_array, ref cursor, 10) != (int)capabilitiesResponse.msgType)
            {
                cursor -= 16;
                return((MSG_GET_READER_CAPABILITIES_RESPONSE)null);
            }
            capabilitiesResponse.msgLen     = (uint)(ulong)Util.CalculateVal(ref bit_array, ref cursor, 32);
            capabilitiesResponse.msgID      = (uint)(ulong)Util.CalculateVal(ref bit_array, ref cursor, 32);
            capabilitiesResponse.LLRPStatus = PARAM_LLRPStatus.FromBitArray(ref bit_array, ref cursor, length);
            capabilitiesResponse.GeneralDeviceCapabilities = PARAM_GeneralDeviceCapabilities.FromBitArray(ref bit_array, ref cursor, length);
            capabilitiesResponse.LLRPCapabilities          = PARAM_LLRPCapabilities.FromBitArray(ref bit_array, ref cursor, length);
            capabilitiesResponse.RegulatoryCapabilities    = PARAM_RegulatoryCapabilities.FromBitArray(ref bit_array, ref cursor, length);
            ushort num1 = 1;

            while (num1 != (ushort)0)
            {
                num1 = (ushort)0;
                PARAM_C1G2LLRPCapabilities llrpCapabilities1 = PARAM_C1G2LLRPCapabilities.FromBitArray(ref bit_array, ref cursor, length);
                if (llrpCapabilities1 != null)
                {
                    ++num1;
                    capabilitiesResponse.AirProtocolLLRPCapabilities.Add((IParameter)llrpCapabilities1);
                }
                PARAM_C1G2LLRPCapabilities llrpCapabilities2;
                while ((llrpCapabilities2 = PARAM_C1G2LLRPCapabilities.FromBitArray(ref bit_array, ref cursor, length)) != null)
                {
                    capabilitiesResponse.AirProtocolLLRPCapabilities.Add((IParameter)llrpCapabilities2);
                }
            }
            int  num2;
            bool flag;

            do
            {
                num2 = cursor;
                flag = false;
                ICustom_Parameter customParameter = CustomParamDecodeFactory.DecodeCustomParameter(ref bit_array, ref cursor, length);
                if (customParameter != null && capabilitiesResponse.AddCustomParameter(customParameter))
                {
                    flag = true;
                }
            }while (flag);
            cursor = num2;
            return(capabilitiesResponse);
        }
Example #2
0
        public static MSG_GET_READER_CAPABILITIES_RESPONSE FromString(
            string str)
        {
            XmlDocument xmlDocument = new XmlDocument();

            xmlDocument.LoadXml(str);
            XmlNode             documentElement = (XmlNode)xmlDocument.DocumentElement;
            XmlNamespaceManager nsmgr           = new XmlNamespaceManager(documentElement.OwnerDocument.NameTable);

            nsmgr.AddNamespace("", "http://www.llrp.org/ltk/schema/core/encoding/xml/1.0");
            nsmgr.AddNamespace("llrp", "http://www.llrp.org/ltk/schema/core/encoding/xml/1.0");
            MSG_GET_READER_CAPABILITIES_RESPONSE capabilitiesResponse = new MSG_GET_READER_CAPABILITIES_RESPONSE();

            try
            {
                capabilitiesResponse.MSG_ID = Convert.ToUInt32(XmlUtil.GetNodeAttrValue(documentElement, "MessageID"));
            }
            catch
            {
            }
            try
            {
                XmlNodeList xmlNodes = XmlUtil.GetXmlNodes(documentElement, "LLRPStatus", nsmgr);
                if (xmlNodes != null)
                {
                    if (xmlNodes.Count != 0)
                    {
                        capabilitiesResponse.LLRPStatus = PARAM_LLRPStatus.FromXmlNode(xmlNodes[0]);
                    }
                }
            }
            catch
            {
            }
            try
            {
                XmlNodeList xmlNodes = XmlUtil.GetXmlNodes(documentElement, "GeneralDeviceCapabilities", nsmgr);
                if (xmlNodes != null)
                {
                    if (xmlNodes.Count != 0)
                    {
                        capabilitiesResponse.GeneralDeviceCapabilities = PARAM_GeneralDeviceCapabilities.FromXmlNode(xmlNodes[0]);
                    }
                }
            }
            catch
            {
            }
            try
            {
                XmlNodeList xmlNodes = XmlUtil.GetXmlNodes(documentElement, "LLRPCapabilities", nsmgr);
                if (xmlNodes != null)
                {
                    if (xmlNodes.Count != 0)
                    {
                        capabilitiesResponse.LLRPCapabilities = PARAM_LLRPCapabilities.FromXmlNode(xmlNodes[0]);
                    }
                }
            }
            catch
            {
            }
            try
            {
                XmlNodeList xmlNodes = XmlUtil.GetXmlNodes(documentElement, "RegulatoryCapabilities", nsmgr);
                if (xmlNodes != null)
                {
                    if (xmlNodes.Count != 0)
                    {
                        capabilitiesResponse.RegulatoryCapabilities = PARAM_RegulatoryCapabilities.FromXmlNode(xmlNodes[0]);
                    }
                }
            }
            catch
            {
            }
            capabilitiesResponse.AirProtocolLLRPCapabilities = new UNION_AirProtocolLLRPCapabilities();
            try
            {
                foreach (XmlNode childNode in documentElement.ChildNodes)
                {
                    switch (childNode.Name)
                    {
                    case "C1G2LLRPCapabilities":
                        capabilitiesResponse.AirProtocolLLRPCapabilities.Add((IParameter)PARAM_C1G2LLRPCapabilities.FromXmlNode(childNode));
                        continue;

                    default:
                        continue;
                    }
                }
            }
            catch
            {
            }
            try
            {
                ArrayList nodeCustomChildren = XmlUtil.GetXmlNodeCustomChildren(documentElement, nsmgr);
                if (nodeCustomChildren != null)
                {
                    for (int index = 0; index < nodeCustomChildren.Count; ++index)
                    {
                        ICustom_Parameter customParameter = CustomParamDecodeFactory.DecodeXmlNodeToCustomParameter((XmlNode)nodeCustomChildren[index]);
                        if (customParameter != null)
                        {
                            capabilitiesResponse.AddCustomParameter(customParameter);
                        }
                    }
                }
            }
            catch
            {
            }
            return(capabilitiesResponse);
        }