Example #1
0
        public static PARAM_GeneralDeviceCapabilities FromXmlNode(XmlNode node)
        {
            string val;
            PARAM_GeneralDeviceCapabilities param = new PARAM_GeneralDeviceCapabilities();


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

            param.MaxNumberOfAntennaSupported = Convert.ToUInt16(val);

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

            param.CanSetAntennaProperties = Convert.ToBoolean(val);

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

            param.HasUTCClockCapability = Convert.ToBoolean(val);

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

            param.DeviceManufacturerName = Convert.ToUInt32(val);

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

            param.ModelName = Convert.ToUInt32(val);

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

            try
            {

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

            }
            catch { }

            try
            {

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

            }
            catch { }

            try
            {

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

            }
            catch { }

            try
            {

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

            }
            catch { }

            return param;
        }
Example #2
0
        public new static PARAM_GeneralDeviceCapabilities 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_GeneralDeviceCapabilities param = new PARAM_GeneralDeviceCapabilities();

            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 = 16;

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

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

            field_len = 1;

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

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

            field_len = 1;

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

            cursor += param_reserved_len;

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

            field_len = 32;

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

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

            field_len = 32;

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

            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(string), field_len);
            param.ReaderFirmwareVersion = (string)obj_val;

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

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

            param.GPIOCapabilities = PARAM_GPIOCapabilities.FromBitArray(ref bit_array, ref cursor, length);

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

            return param;
        }