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

            cursor += 6;
            if ((int)(ulong)Util.CalculateVal(ref bit_array, ref cursor, 10) != (int)readerCapabilities.msgType)
            {
                cursor -= 16;
                return((MSG_GET_READER_CAPABILITIES)null);
            }
            readerCapabilities.msgLen = (uint)(ulong)Util.CalculateVal(ref bit_array, ref cursor, 32);
            readerCapabilities.msgID  = (uint)(ulong)Util.CalculateVal(ref bit_array, ref cursor, 32);
            if (cursor > length)
            {
                throw new Exception("Input data is not a complete LLRP message");
            }
            int    field_len = 8;
            object obj;

            Util.ConvertBitArrayToObj(ref bit_array, ref cursor, out obj, typeof(uint), field_len);
            readerCapabilities.RequestedData = (ENUM_GetReaderCapabilitiesRequestedData)(uint)obj;
            int  num;
            bool flag;

            do
            {
                num  = cursor;
                flag = false;
                ICustom_Parameter customParameter = CustomParamDecodeFactory.DecodeCustomParameter(ref bit_array, ref cursor, length);
                if (customParameter != null && readerCapabilities.AddCustomParameter(customParameter))
                {
                    flag = true;
                }
            }while (flag);
            cursor = num;
            return(readerCapabilities);
        }
Beispiel #2
0
        public static MSG_GET_READER_CAPABILITIES 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 readerCapabilities = new MSG_GET_READER_CAPABILITIES();

            try
            {
                readerCapabilities.MSG_ID = Convert.ToUInt32(XmlUtil.GetNodeAttrValue(documentElement, "MessageID"));
            }
            catch
            {
            }
            string nodeValue = XmlUtil.GetNodeValue(documentElement, "RequestedData");

            readerCapabilities.RequestedData = (ENUM_GetReaderCapabilitiesRequestedData)Enum.Parse(typeof(ENUM_GetReaderCapabilitiesRequestedData), nodeValue);
            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)
                        {
                            readerCapabilities.AddCustomParameter(customParameter);
                        }
                    }
                }
            }
            catch
            {
            }
            return(readerCapabilities);
        }