Ejemplo n.º 1
0
        /// <summary>
        /// Deserialize a xml string to a MSG_CUSTOM_MESSAGE
        /// </summary>
        /// <param name="str">Input Xml string</param>
        /// <returns>MSG_CUSTOM_MESSAGE</returns>
        public new static MSG_CUSTOM_MESSAGE FromString(string str)
        {
            string val;

            XmlDocument xdoc = new XmlDocument();

            xdoc.LoadXml(str);
            XmlNode node = (XmlNode)xdoc.DocumentElement;

            MSG_CUSTOM_MESSAGE msg = new MSG_CUSTOM_MESSAGE();

            try
            {
                msg.MSG_ID = Convert.ToUInt32(XmlUtil.GetNodeAttrValue(node, "MessageID"));
            }
            catch { }

            val = XmlUtil.GetNodeValue(node, "VendorIdentifier");
            msg.VendorIdentifier = (UInt32)(Util.ParseValueTypeFromString(val, "u32", ""));

            val = XmlUtil.GetNodeValue(node, "MessageSubtype");
            msg.MessageSubtype = (byte)(Util.ParseValueTypeFromString(val, "u8", ""));

            val      = XmlUtil.GetNodeValue(node, "Data");
            msg.Data = (ByteArray)(Util.ParseArrayTypeFromString(val, "bytesToEnd", "Hex"));

            return(msg);
        }
Ejemplo n.º 2
0
 public MSG_CUSTOM_MESSAGE CUSTOM_MESSAGE(
     MSG_CUSTOM_MESSAGE msg,
     out MSG_ERROR_MESSAGE msg_err,
     int time_out)
 {
     return((MSG_CUSTOM_MESSAGE) new Transaction(this.cI, msg.MSG_ID, ENUM_LLRP_MSG_TYPE.CUSTOM_MESSAGE).Transact((Message)msg, out msg_err, time_out));
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Decode bit array to a MSG_CUSTOM_MESSAGE
        /// </summary>
        /// <param name="bit_array">input bit array</param>
        /// <param name="cursor">pointer to current position</param>
        /// <param name="length">data length</param>
        /// <returns>MSG_CUSTOM_MESSAGE</returns>
        public new static MSG_CUSTOM_MESSAGE FromBitArray(ref BitArray bit_array, ref int cursor, int length)
        {
            if (cursor > length)
            {
                return(null);
            }

            UInt16    loop_control_counter = 1; //used for control choice element parsing loop
            int       field_len            = 0;
            int       msg_type             = 0;
            object    obj_val;
            ArrayList param_list = new ArrayList();

            MSG_CUSTOM_MESSAGE obj = new MSG_CUSTOM_MESSAGE();

            cursor  += 6;
            msg_type = (int)(UInt64)Util.CalculateVal(ref bit_array, ref cursor, 10);

            if (msg_type != obj.msgType)
            {
                cursor -= 16;
                return(null);
            }

            obj.msgLen = (UInt32)(UInt64)Util.CalculateVal(ref bit_array, ref cursor, 32);
            obj.msgID  = (UInt32)(UInt64)Util.CalculateVal(ref bit_array, ref cursor, 32);

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

            field_len = 32;
            Util.ConvertBitArrayToObj(ref bit_array, ref cursor, out obj_val, typeof(UInt32), field_len);
            obj.VendorIdentifier = (UInt32)obj_val;

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

            field_len = 8;
            Util.ConvertBitArrayToObj(ref bit_array, ref cursor, out obj_val, typeof(byte), field_len);
            obj.MessageSubtype = (byte)obj_val;

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

            field_len = (bit_array.Length - cursor) / 8;
            Util.ConvertBitArrayToObj(ref bit_array, ref cursor, out obj_val, typeof(ByteArray), field_len);
            obj.Data = (ByteArray)obj_val;

            return(obj);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Create vendor extended paramters from BitArray
        /// </summary>
        /// <param name="bit_array">BitArray. Input</param>
        /// <param name="cursor">The current bit position to be processed.</param>
        /// <param name="length">Total length of the array</param>
        /// <returns></returns>
        public new static MSG_CUSTOM_MESSAGE DecodeCustomMessage(ref BitArray bit_array, ref int cursor, int length)
        {
            if (cursor >= length)
            {
                return(null);
            }

            int old_cursor = cursor;

            MSG_CUSTOM_MESSAGE msg = MSG_CUSTOM_MESSAGE.FromBitArray(ref bit_array, ref cursor, length);

            if (null != msg)
            {
                string key = msg.VendorID + "-" + msg.SubType;
                if (null != vendorExtensionIDTypeHash)
                {
                    int new_cursor = cursor;

                    try
                    {
                        Type tp = (Type)vendorExtensionIDTypeHash[key];

                        MethodInfo mis = tp.GetMethod("FromBitArray");
                        if (null == mis)
                        {
                            return(null);
                        }

                        cursor = old_cursor;
                        object[] parameters = new object[] { bit_array, cursor, length };

                        object obj = mis.Invoke(null, parameters);
                        cursor = (int)parameters[1];

                        return((MSG_CUSTOM_MESSAGE)obj);
                    }
                    catch
                    {
                        cursor = new_cursor;
                    }
                }

                return(msg);
            }

            return(null);
        }
Ejemplo n.º 5
0
        public static MSG_CUSTOM_MESSAGE DecodeCustomMessage(
            ref BitArray bit_array,
            ref int cursor,
            int length)
        {
            if (cursor >= length)
            {
                return((MSG_CUSTOM_MESSAGE)null);
            }
            int num1 = cursor;
            MSG_CUSTOM_MESSAGE msgCustomMessage = MSG_CUSTOM_MESSAGE.FromBitArray(ref bit_array, ref cursor, length);

            if (msgCustomMessage == null)
            {
                return((MSG_CUSTOM_MESSAGE)null);
            }
            string str = msgCustomMessage.VendorID.ToString() + "-" + (object)msgCustomMessage.SubType;

            if (CustomMsgDecodeFactory.vendorExtensionIDTypeHash != null)
            {
                int num2 = cursor;
                try
                {
                    MethodInfo method = ((Type)CustomMsgDecodeFactory.vendorExtensionIDTypeHash[(object)str]).GetMethod("FromBitArray");
                    if (method == null)
                    {
                        return((MSG_CUSTOM_MESSAGE)null);
                    }
                    cursor = num1;
                    object[] parameters = new object[3]
                    {
                        (object)bit_array,
                        (object)cursor,
                        (object)length
                    };
                    object obj = method.Invoke((object)null, parameters);
                    cursor = (int)parameters[1];
                    return((MSG_CUSTOM_MESSAGE)obj);
                }
                catch
                {
                    cursor = num2;
                }
            }
            return(msgCustomMessage);
        }
Ejemplo n.º 6
0
        public static void LoadVendorExtensionAssembly(Assembly asm)
        {
            if (CustomMsgDecodeFactory.vendorExtensionIDTypeHash == null)
            {
                CustomMsgDecodeFactory.vendorExtensionIDTypeHash = new Hashtable();
            }
            if (CustomMsgDecodeFactory.vendorExtensionNameTypeHash == null)
            {
                CustomMsgDecodeFactory.vendorExtensionNameTypeHash = new Hashtable();
            }
            if (CustomMsgDecodeFactory.vendorExtensionAssemblyHash == null)
            {
                CustomMsgDecodeFactory.vendorExtensionAssemblyHash = new Hashtable();
            }
            string name = asm.GetName().Name;

            if (CustomMsgDecodeFactory.vendorExtensionAssemblyHash.ContainsKey((object)name))
            {
                return;
            }
            CustomMsgDecodeFactory.vendorExtensionAssemblyHash.Add((object)name, (object)asm);
            try
            {
                foreach (Type type in asm.GetTypes())
                {
                    if (type.BaseType == typeof(MSG_CUSTOM_MESSAGE))
                    {
                        string             typeName = type.Namespace + "." + type.Name;
                        MSG_CUSTOM_MESSAGE instance = (MSG_CUSTOM_MESSAGE)asm.CreateInstance(typeName);
                        string             str      = instance.VendorID.ToString() + "-" + (object)instance.SubType;
                        if (!CustomMsgDecodeFactory.vendorExtensionIDTypeHash.ContainsKey((object)str))
                        {
                            CustomMsgDecodeFactory.vendorExtensionIDTypeHash.Add((object)str, (object)type);
                        }
                        if (!CustomMsgDecodeFactory.vendorExtensionNameTypeHash.ContainsKey((object)type.Name))
                        {
                            CustomMsgDecodeFactory.vendorExtensionNameTypeHash.Add((object)type.Name, (object)type);
                        }
                    }
                }
            }
            catch
            {
                Console.WriteLine("LVEA failed", (object)asm);
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Decode Binary LLRP packet to LLRP message object
        /// </summary>
        /// <param name="packet">Binary LLRP packet to be decoded</param>
        /// <param name="msg">LLRP message. output</param>
        public static void Decode(ref byte [] packet, out Message msg)
        {
            LLRP_Envelope env;

            Decode_Envelope(packet, out env);

            BitArray ba     = Util.ConvertByteArrayToBitArray(packet);
            int      cursor = 0;

            switch (env.msg_type)
            {
            case ENUM_LLRP_MSG_TYPE.CUSTOM_MESSAGE:
                msg = MSG_CUSTOM_MESSAGE.FromBitArray(ref ba, ref cursor, (int)(env.msg_len * 8));
                return;

            case ENUM_LLRP_MSG_TYPE.GET_READER_CAPABILITIES:
                msg = MSG_GET_READER_CAPABILITIES.FromBitArray(ref ba, ref cursor, (int)(env.msg_len * 8));
                return;

            case ENUM_LLRP_MSG_TYPE.GET_READER_CAPABILITIES_RESPONSE:
                msg = MSG_GET_READER_CAPABILITIES_RESPONSE.FromBitArray(ref ba, ref cursor, (int)(env.msg_len * 8));
                return;

            case ENUM_LLRP_MSG_TYPE.ADD_ROSPEC:
                msg = MSG_ADD_ROSPEC.FromBitArray(ref ba, ref cursor, (int)(env.msg_len * 8));
                return;

            case ENUM_LLRP_MSG_TYPE.ADD_ROSPEC_RESPONSE:
                msg = MSG_ADD_ROSPEC_RESPONSE.FromBitArray(ref ba, ref cursor, (int)(env.msg_len * 8));
                return;

            case ENUM_LLRP_MSG_TYPE.DELETE_ROSPEC:
                msg = MSG_DELETE_ROSPEC.FromBitArray(ref ba, ref cursor, (int)(env.msg_len * 8));
                return;

            case ENUM_LLRP_MSG_TYPE.DELETE_ROSPEC_RESPONSE:
                msg = MSG_DELETE_ROSPEC_RESPONSE.FromBitArray(ref ba, ref cursor, (int)(env.msg_len * 8));
                return;

            case ENUM_LLRP_MSG_TYPE.START_ROSPEC:
                msg = MSG_START_ROSPEC.FromBitArray(ref ba, ref cursor, (int)(env.msg_len * 8));
                return;

            case ENUM_LLRP_MSG_TYPE.START_ROSPEC_RESPONSE:
                msg = MSG_START_ROSPEC_RESPONSE.FromBitArray(ref ba, ref cursor, (int)(env.msg_len * 8));
                return;

            case ENUM_LLRP_MSG_TYPE.STOP_ROSPEC:
                msg = MSG_STOP_ROSPEC.FromBitArray(ref ba, ref cursor, (int)(env.msg_len * 8));
                return;

            case ENUM_LLRP_MSG_TYPE.STOP_ROSPEC_RESPONSE:
                msg = MSG_STOP_ROSPEC_RESPONSE.FromBitArray(ref ba, ref cursor, (int)(env.msg_len * 8));
                return;

            case ENUM_LLRP_MSG_TYPE.ENABLE_ROSPEC:
                msg = MSG_ENABLE_ROSPEC.FromBitArray(ref ba, ref cursor, (int)(env.msg_len * 8));
                return;

            case ENUM_LLRP_MSG_TYPE.ENABLE_ROSPEC_RESPONSE:
                msg = MSG_ENABLE_ROSPEC_RESPONSE.FromBitArray(ref ba, ref cursor, (int)(env.msg_len * 8));
                return;

            case ENUM_LLRP_MSG_TYPE.DISABLE_ROSPEC:
                msg = MSG_DISABLE_ROSPEC.FromBitArray(ref ba, ref cursor, (int)(env.msg_len * 8));
                return;

            case ENUM_LLRP_MSG_TYPE.DISABLE_ROSPEC_RESPONSE:
                msg = MSG_DISABLE_ROSPEC_RESPONSE.FromBitArray(ref ba, ref cursor, (int)(env.msg_len * 8));
                return;

            case ENUM_LLRP_MSG_TYPE.GET_ROSPECS:
                msg = MSG_GET_ROSPECS.FromBitArray(ref ba, ref cursor, (int)(env.msg_len * 8));
                return;

            case ENUM_LLRP_MSG_TYPE.GET_ROSPECS_RESPONSE:
                msg = MSG_GET_ROSPECS_RESPONSE.FromBitArray(ref ba, ref cursor, (int)(env.msg_len * 8));
                return;

            case ENUM_LLRP_MSG_TYPE.ADD_ACCESSSPEC:
                msg = MSG_ADD_ACCESSSPEC.FromBitArray(ref ba, ref cursor, (int)(env.msg_len * 8));
                return;

            case ENUM_LLRP_MSG_TYPE.ADD_ACCESSSPEC_RESPONSE:
                msg = MSG_ADD_ACCESSSPEC_RESPONSE.FromBitArray(ref ba, ref cursor, (int)(env.msg_len * 8));
                return;

            case ENUM_LLRP_MSG_TYPE.DELETE_ACCESSSPEC:
                msg = MSG_DELETE_ACCESSSPEC.FromBitArray(ref ba, ref cursor, (int)(env.msg_len * 8));
                return;

            case ENUM_LLRP_MSG_TYPE.DELETE_ACCESSSPEC_RESPONSE:
                msg = MSG_DELETE_ACCESSSPEC_RESPONSE.FromBitArray(ref ba, ref cursor, (int)(env.msg_len * 8));
                return;

            case ENUM_LLRP_MSG_TYPE.ENABLE_ACCESSSPEC:
                msg = MSG_ENABLE_ACCESSSPEC.FromBitArray(ref ba, ref cursor, (int)(env.msg_len * 8));
                return;

            case ENUM_LLRP_MSG_TYPE.ENABLE_ACCESSSPEC_RESPONSE:
                msg = MSG_ENABLE_ACCESSSPEC_RESPONSE.FromBitArray(ref ba, ref cursor, (int)(env.msg_len * 8));
                return;

            case ENUM_LLRP_MSG_TYPE.DISABLE_ACCESSSPEC:
                msg = MSG_DISABLE_ACCESSSPEC.FromBitArray(ref ba, ref cursor, (int)(env.msg_len * 8));
                return;

            case ENUM_LLRP_MSG_TYPE.DISABLE_ACCESSSPEC_RESPONSE:
                msg = MSG_DISABLE_ACCESSSPEC_RESPONSE.FromBitArray(ref ba, ref cursor, (int)(env.msg_len * 8));
                return;

            case ENUM_LLRP_MSG_TYPE.GET_ACCESSSPECS:
                msg = MSG_GET_ACCESSSPECS.FromBitArray(ref ba, ref cursor, (int)(env.msg_len * 8));
                return;

            case ENUM_LLRP_MSG_TYPE.GET_ACCESSSPECS_RESPONSE:
                msg = MSG_GET_ACCESSSPECS_RESPONSE.FromBitArray(ref ba, ref cursor, (int)(env.msg_len * 8));
                return;

            case ENUM_LLRP_MSG_TYPE.GET_READER_CONFIG:
                msg = MSG_GET_READER_CONFIG.FromBitArray(ref ba, ref cursor, (int)(env.msg_len * 8));
                return;

            case ENUM_LLRP_MSG_TYPE.GET_READER_CONFIG_RESPONSE:
                msg = MSG_GET_READER_CONFIG_RESPONSE.FromBitArray(ref ba, ref cursor, (int)(env.msg_len * 8));
                return;

            case ENUM_LLRP_MSG_TYPE.SET_READER_CONFIG:
                msg = MSG_SET_READER_CONFIG.FromBitArray(ref ba, ref cursor, (int)(env.msg_len * 8));
                return;

            case ENUM_LLRP_MSG_TYPE.SET_READER_CONFIG_RESPONSE:
                msg = MSG_SET_READER_CONFIG_RESPONSE.FromBitArray(ref ba, ref cursor, (int)(env.msg_len * 8));
                return;

            case ENUM_LLRP_MSG_TYPE.CLOSE_CONNECTION:
                msg = MSG_CLOSE_CONNECTION.FromBitArray(ref ba, ref cursor, (int)(env.msg_len * 8));
                return;

            case ENUM_LLRP_MSG_TYPE.CLOSE_CONNECTION_RESPONSE:
                msg = MSG_CLOSE_CONNECTION_RESPONSE.FromBitArray(ref ba, ref cursor, (int)(env.msg_len * 8));
                return;

            case ENUM_LLRP_MSG_TYPE.GET_REPORT:
                msg = MSG_GET_REPORT.FromBitArray(ref ba, ref cursor, (int)(env.msg_len * 8));
                return;

            case ENUM_LLRP_MSG_TYPE.RO_ACCESS_REPORT:
                msg = MSG_RO_ACCESS_REPORT.FromBitArray(ref ba, ref cursor, (int)(env.msg_len * 8));
                return;

            case ENUM_LLRP_MSG_TYPE.KEEPALIVE:
                msg = MSG_KEEPALIVE.FromBitArray(ref ba, ref cursor, (int)(env.msg_len * 8));
                return;

            case ENUM_LLRP_MSG_TYPE.KEEPALIVE_ACK:
                msg = MSG_KEEPALIVE_ACK.FromBitArray(ref ba, ref cursor, (int)(env.msg_len * 8));
                return;

            case ENUM_LLRP_MSG_TYPE.READER_EVENT_NOTIFICATION:
                msg = MSG_READER_EVENT_NOTIFICATION.FromBitArray(ref ba, ref cursor, (int)(env.msg_len * 8));
                return;

            case ENUM_LLRP_MSG_TYPE.ENABLE_EVENTS_AND_REPORTS:
                msg = MSG_ENABLE_EVENTS_AND_REPORTS.FromBitArray(ref ba, ref cursor, (int)(env.msg_len * 8));
                return;

            case ENUM_LLRP_MSG_TYPE.ERROR_MESSAGE:
                msg = MSG_ERROR_MESSAGE.FromBitArray(ref ba, ref cursor, (int)(env.msg_len * 8));
                return;

            default:
                throw new MalformedPacket("Unrecognized message " + env.msg_type);
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Parse XML string to LLRP message
        /// </summary>
        /// <param name="xmlstr">XML string to be parsed.</param>
        /// <param name="msg">LLRP message. output</param>
        /// <param name="type">LLRP message type. output</param>
        public static void ParseXMLToLLRPMessage(string xmlstr, out Message msg, out ENUM_LLRP_MSG_TYPE type)
        {
            XmlDocument xdoc = new XmlDocument();

            xdoc.LoadXml(xmlstr);
            XmlNode node = (XmlNode)xdoc.DocumentElement;

            switch (node.Name)
            {
            case "CUSTOM_MESSAGE":
                msg  = (Message)MSG_CUSTOM_MESSAGE.FromString(xmlstr);
                type = ENUM_LLRP_MSG_TYPE.CUSTOM_MESSAGE;
                return;

            case "GET_READER_CAPABILITIES":
                msg  = (Message)MSG_GET_READER_CAPABILITIES.FromString(xmlstr);
                type = ENUM_LLRP_MSG_TYPE.GET_READER_CAPABILITIES;
                return;

            case "GET_READER_CAPABILITIES_RESPONSE":
                msg  = (Message)MSG_GET_READER_CAPABILITIES_RESPONSE.FromString(xmlstr);
                type = ENUM_LLRP_MSG_TYPE.GET_READER_CAPABILITIES_RESPONSE;
                return;

            case "ADD_ROSPEC":
                msg  = (Message)MSG_ADD_ROSPEC.FromString(xmlstr);
                type = ENUM_LLRP_MSG_TYPE.ADD_ROSPEC;
                return;

            case "ADD_ROSPEC_RESPONSE":
                msg  = (Message)MSG_ADD_ROSPEC_RESPONSE.FromString(xmlstr);
                type = ENUM_LLRP_MSG_TYPE.ADD_ROSPEC_RESPONSE;
                return;

            case "DELETE_ROSPEC":
                msg  = (Message)MSG_DELETE_ROSPEC.FromString(xmlstr);
                type = ENUM_LLRP_MSG_TYPE.DELETE_ROSPEC;
                return;

            case "DELETE_ROSPEC_RESPONSE":
                msg  = (Message)MSG_DELETE_ROSPEC_RESPONSE.FromString(xmlstr);
                type = ENUM_LLRP_MSG_TYPE.DELETE_ROSPEC_RESPONSE;
                return;

            case "START_ROSPEC":
                msg  = (Message)MSG_START_ROSPEC.FromString(xmlstr);
                type = ENUM_LLRP_MSG_TYPE.START_ROSPEC;
                return;

            case "START_ROSPEC_RESPONSE":
                msg  = (Message)MSG_START_ROSPEC_RESPONSE.FromString(xmlstr);
                type = ENUM_LLRP_MSG_TYPE.START_ROSPEC_RESPONSE;
                return;

            case "STOP_ROSPEC":
                msg  = (Message)MSG_STOP_ROSPEC.FromString(xmlstr);
                type = ENUM_LLRP_MSG_TYPE.STOP_ROSPEC;
                return;

            case "STOP_ROSPEC_RESPONSE":
                msg  = (Message)MSG_STOP_ROSPEC_RESPONSE.FromString(xmlstr);
                type = ENUM_LLRP_MSG_TYPE.STOP_ROSPEC_RESPONSE;
                return;

            case "ENABLE_ROSPEC":
                msg  = (Message)MSG_ENABLE_ROSPEC.FromString(xmlstr);
                type = ENUM_LLRP_MSG_TYPE.ENABLE_ROSPEC;
                return;

            case "ENABLE_ROSPEC_RESPONSE":
                msg  = (Message)MSG_ENABLE_ROSPEC_RESPONSE.FromString(xmlstr);
                type = ENUM_LLRP_MSG_TYPE.ENABLE_ROSPEC_RESPONSE;
                return;

            case "DISABLE_ROSPEC":
                msg  = (Message)MSG_DISABLE_ROSPEC.FromString(xmlstr);
                type = ENUM_LLRP_MSG_TYPE.DISABLE_ROSPEC;
                return;

            case "DISABLE_ROSPEC_RESPONSE":
                msg  = (Message)MSG_DISABLE_ROSPEC_RESPONSE.FromString(xmlstr);
                type = ENUM_LLRP_MSG_TYPE.DISABLE_ROSPEC_RESPONSE;
                return;

            case "GET_ROSPECS":
                msg  = (Message)MSG_GET_ROSPECS.FromString(xmlstr);
                type = ENUM_LLRP_MSG_TYPE.GET_ROSPECS;
                return;

            case "GET_ROSPECS_RESPONSE":
                msg  = (Message)MSG_GET_ROSPECS_RESPONSE.FromString(xmlstr);
                type = ENUM_LLRP_MSG_TYPE.GET_ROSPECS_RESPONSE;
                return;

            case "ADD_ACCESSSPEC":
                msg  = (Message)MSG_ADD_ACCESSSPEC.FromString(xmlstr);
                type = ENUM_LLRP_MSG_TYPE.ADD_ACCESSSPEC;
                return;

            case "ADD_ACCESSSPEC_RESPONSE":
                msg  = (Message)MSG_ADD_ACCESSSPEC_RESPONSE.FromString(xmlstr);
                type = ENUM_LLRP_MSG_TYPE.ADD_ACCESSSPEC_RESPONSE;
                return;

            case "DELETE_ACCESSSPEC":
                msg  = (Message)MSG_DELETE_ACCESSSPEC.FromString(xmlstr);
                type = ENUM_LLRP_MSG_TYPE.DELETE_ACCESSSPEC;
                return;

            case "DELETE_ACCESSSPEC_RESPONSE":
                msg  = (Message)MSG_DELETE_ACCESSSPEC_RESPONSE.FromString(xmlstr);
                type = ENUM_LLRP_MSG_TYPE.DELETE_ACCESSSPEC_RESPONSE;
                return;

            case "ENABLE_ACCESSSPEC":
                msg  = (Message)MSG_ENABLE_ACCESSSPEC.FromString(xmlstr);
                type = ENUM_LLRP_MSG_TYPE.ENABLE_ACCESSSPEC;
                return;

            case "ENABLE_ACCESSSPEC_RESPONSE":
                msg  = (Message)MSG_ENABLE_ACCESSSPEC_RESPONSE.FromString(xmlstr);
                type = ENUM_LLRP_MSG_TYPE.ENABLE_ACCESSSPEC_RESPONSE;
                return;

            case "DISABLE_ACCESSSPEC":
                msg  = (Message)MSG_DISABLE_ACCESSSPEC.FromString(xmlstr);
                type = ENUM_LLRP_MSG_TYPE.DISABLE_ACCESSSPEC;
                return;

            case "DISABLE_ACCESSSPEC_RESPONSE":
                msg  = (Message)MSG_DISABLE_ACCESSSPEC_RESPONSE.FromString(xmlstr);
                type = ENUM_LLRP_MSG_TYPE.DISABLE_ACCESSSPEC_RESPONSE;
                return;

            case "GET_ACCESSSPECS":
                msg  = (Message)MSG_GET_ACCESSSPECS.FromString(xmlstr);
                type = ENUM_LLRP_MSG_TYPE.GET_ACCESSSPECS;
                return;

            case "GET_ACCESSSPECS_RESPONSE":
                msg  = (Message)MSG_GET_ACCESSSPECS_RESPONSE.FromString(xmlstr);
                type = ENUM_LLRP_MSG_TYPE.GET_ACCESSSPECS_RESPONSE;
                return;

            case "GET_READER_CONFIG":
                msg  = (Message)MSG_GET_READER_CONFIG.FromString(xmlstr);
                type = ENUM_LLRP_MSG_TYPE.GET_READER_CONFIG;
                return;

            case "GET_READER_CONFIG_RESPONSE":
                msg  = (Message)MSG_GET_READER_CONFIG_RESPONSE.FromString(xmlstr);
                type = ENUM_LLRP_MSG_TYPE.GET_READER_CONFIG_RESPONSE;
                return;

            case "SET_READER_CONFIG":
                msg  = (Message)MSG_SET_READER_CONFIG.FromString(xmlstr);
                type = ENUM_LLRP_MSG_TYPE.SET_READER_CONFIG;
                return;

            case "SET_READER_CONFIG_RESPONSE":
                msg  = (Message)MSG_SET_READER_CONFIG_RESPONSE.FromString(xmlstr);
                type = ENUM_LLRP_MSG_TYPE.SET_READER_CONFIG_RESPONSE;
                return;

            case "CLOSE_CONNECTION":
                msg  = (Message)MSG_CLOSE_CONNECTION.FromString(xmlstr);
                type = ENUM_LLRP_MSG_TYPE.CLOSE_CONNECTION;
                return;

            case "CLOSE_CONNECTION_RESPONSE":
                msg  = (Message)MSG_CLOSE_CONNECTION_RESPONSE.FromString(xmlstr);
                type = ENUM_LLRP_MSG_TYPE.CLOSE_CONNECTION_RESPONSE;
                return;

            case "GET_REPORT":
                msg  = (Message)MSG_GET_REPORT.FromString(xmlstr);
                type = ENUM_LLRP_MSG_TYPE.GET_REPORT;
                return;

            case "RO_ACCESS_REPORT":
                msg  = (Message)MSG_RO_ACCESS_REPORT.FromString(xmlstr);
                type = ENUM_LLRP_MSG_TYPE.RO_ACCESS_REPORT;
                return;

            case "KEEPALIVE":
                msg  = (Message)MSG_KEEPALIVE.FromString(xmlstr);
                type = ENUM_LLRP_MSG_TYPE.KEEPALIVE;
                return;

            case "KEEPALIVE_ACK":
                msg  = (Message)MSG_KEEPALIVE_ACK.FromString(xmlstr);
                type = ENUM_LLRP_MSG_TYPE.KEEPALIVE_ACK;
                return;

            case "READER_EVENT_NOTIFICATION":
                msg  = (Message)MSG_READER_EVENT_NOTIFICATION.FromString(xmlstr);
                type = ENUM_LLRP_MSG_TYPE.READER_EVENT_NOTIFICATION;
                return;

            case "ENABLE_EVENTS_AND_REPORTS":
                msg  = (Message)MSG_ENABLE_EVENTS_AND_REPORTS.FromString(xmlstr);
                type = ENUM_LLRP_MSG_TYPE.ENABLE_EVENTS_AND_REPORTS;
                return;

            case "ERROR_MESSAGE":
                msg  = (Message)MSG_ERROR_MESSAGE.FromString(xmlstr);
                type = ENUM_LLRP_MSG_TYPE.ERROR_MESSAGE;
                return;

            default:
                msg  = null;
                type = 0;
                return;
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Register vendor extension assembly
        /// </summary>
        /// <param name="asm"></param>
        public static void LoadVendorExtensionAssembly(Assembly asm)
        {
            if (null == vendorExtensionIDTypeHash)
            {
                vendorExtensionIDTypeHash = new Hashtable();
            }

            if (null == vendorExtensionNameTypeHash)
            {
                vendorExtensionNameTypeHash = new Hashtable();
            }

            if (null == vendorExtensionAssemblyHash)
            {
                vendorExtensionAssemblyHash = new Hashtable();
            }

            // Prevent double registration, and recursion
            string assembly_name = asm.GetName().Name;

            if (!vendorExtensionAssemblyHash.ContainsKey(assembly_name))
            {
                vendorExtensionAssemblyHash.Add(assembly_name, asm);
            }
            else
            {
                return;
            }

            try
            {
                Type[] types = asm.GetTypes();

                foreach (Type tp in types)
                {
                    if (tp.BaseType != typeof(MSG_CUSTOM_MESSAGE))
                    {
                        continue;
                    }

                    string type_full_name = tp.Namespace + "." + tp.Name;
                    object obj            = asm.CreateInstance(type_full_name);

                    MSG_CUSTOM_MESSAGE temp_msg = (MSG_CUSTOM_MESSAGE)obj;
                    string             key      = temp_msg.VendorID + "-" + temp_msg.SubType;

                    if (!vendorExtensionIDTypeHash.ContainsKey(key))
                    {
                        vendorExtensionIDTypeHash.Add(key, tp);
                    }

                    if (!vendorExtensionNameTypeHash.ContainsKey(tp.Name))
                    {
                        vendorExtensionNameTypeHash.Add(tp.Name, tp);
                    }
                }
            }
            catch
            {
                Console.WriteLine("LVEA failed", asm);
            }
        }
Ejemplo n.º 10
0
        public static void ParseXMLToLLRPMessage(
            string xmlstr,
            out Message msg,
            out ENUM_LLRP_MSG_TYPE type)
        {
            XmlDocument xmlDocument = new XmlDocument();

            xmlDocument.LoadXml(xmlstr);
            XmlNode documentElement = (XmlNode)xmlDocument.DocumentElement;

            switch (documentElement.Name)
            {
            case "CUSTOM_MESSAGE":
                msg  = (Message)MSG_CUSTOM_MESSAGE.FromString(xmlstr);
                type = ENUM_LLRP_MSG_TYPE.CUSTOM_MESSAGE;
                break;

            case "GET_READER_CAPABILITIES":
                msg  = (Message)MSG_GET_READER_CAPABILITIES.FromString(xmlstr);
                type = ENUM_LLRP_MSG_TYPE.GET_READER_CAPABILITIES;
                break;

            case "GET_READER_CAPABILITIES_RESPONSE":
                msg  = (Message)MSG_GET_READER_CAPABILITIES_RESPONSE.FromString(xmlstr);
                type = ENUM_LLRP_MSG_TYPE.GET_READER_CAPABILITIES_RESPONSE;
                break;

            case "ADD_ROSPEC":
                msg  = (Message)MSG_ADD_ROSPEC.FromString(xmlstr);
                type = ENUM_LLRP_MSG_TYPE.ADD_ROSPEC;
                break;

            case "ADD_ROSPEC_RESPONSE":
                msg  = (Message)MSG_ADD_ROSPEC_RESPONSE.FromString(xmlstr);
                type = ENUM_LLRP_MSG_TYPE.ADD_ROSPEC_RESPONSE;
                break;

            case "DELETE_ROSPEC":
                msg  = (Message)MSG_DELETE_ROSPEC.FromString(xmlstr);
                type = ENUM_LLRP_MSG_TYPE.DELETE_ROSPEC;
                break;

            case "DELETE_ROSPEC_RESPONSE":
                msg  = (Message)MSG_DELETE_ROSPEC_RESPONSE.FromString(xmlstr);
                type = ENUM_LLRP_MSG_TYPE.DELETE_ROSPEC_RESPONSE;
                break;

            case "START_ROSPEC":
                msg  = (Message)MSG_START_ROSPEC.FromString(xmlstr);
                type = ENUM_LLRP_MSG_TYPE.START_ROSPEC;
                break;

            case "START_ROSPEC_RESPONSE":
                msg  = (Message)MSG_START_ROSPEC_RESPONSE.FromString(xmlstr);
                type = ENUM_LLRP_MSG_TYPE.START_ROSPEC_RESPONSE;
                break;

            case "STOP_ROSPEC":
                msg  = (Message)MSG_STOP_ROSPEC.FromString(xmlstr);
                type = ENUM_LLRP_MSG_TYPE.STOP_ROSPEC;
                break;

            case "STOP_ROSPEC_RESPONSE":
                msg  = (Message)MSG_STOP_ROSPEC_RESPONSE.FromString(xmlstr);
                type = ENUM_LLRP_MSG_TYPE.STOP_ROSPEC_RESPONSE;
                break;

            case "ENABLE_ROSPEC":
                msg  = (Message)MSG_ENABLE_ROSPEC.FromString(xmlstr);
                type = ENUM_LLRP_MSG_TYPE.ENABLE_ROSPEC;
                break;

            case "ENABLE_ROSPEC_RESPONSE":
                msg  = (Message)MSG_ENABLE_ROSPEC_RESPONSE.FromString(xmlstr);
                type = ENUM_LLRP_MSG_TYPE.ENABLE_ROSPEC_RESPONSE;
                break;

            case "DISABLE_ROSPEC":
                msg  = (Message)MSG_DISABLE_ROSPEC.FromString(xmlstr);
                type = ENUM_LLRP_MSG_TYPE.DISABLE_ROSPEC;
                break;

            case "DISABLE_ROSPEC_RESPONSE":
                msg  = (Message)MSG_DISABLE_ROSPEC_RESPONSE.FromString(xmlstr);
                type = ENUM_LLRP_MSG_TYPE.DISABLE_ROSPEC_RESPONSE;
                break;

            case "GET_ROSPECS":
                msg  = (Message)MSG_GET_ROSPECS.FromString(xmlstr);
                type = ENUM_LLRP_MSG_TYPE.GET_ROSPECS;
                break;

            case "GET_ROSPECS_RESPONSE":
                msg  = (Message)MSG_GET_ROSPECS_RESPONSE.FromString(xmlstr);
                type = ENUM_LLRP_MSG_TYPE.GET_ROSPECS_RESPONSE;
                break;

            case "ADD_ACCESSSPEC":
                msg  = (Message)MSG_ADD_ACCESSSPEC.FromString(xmlstr);
                type = ENUM_LLRP_MSG_TYPE.ADD_ACCESSSPEC;
                break;

            case "ADD_ACCESSSPEC_RESPONSE":
                msg  = (Message)MSG_ADD_ACCESSSPEC_RESPONSE.FromString(xmlstr);
                type = ENUM_LLRP_MSG_TYPE.ADD_ACCESSSPEC_RESPONSE;
                break;

            case "DELETE_ACCESSSPEC":
                msg  = (Message)MSG_DELETE_ACCESSSPEC.FromString(xmlstr);
                type = ENUM_LLRP_MSG_TYPE.DELETE_ACCESSSPEC;
                break;

            case "DELETE_ACCESSSPEC_RESPONSE":
                msg  = (Message)MSG_DELETE_ACCESSSPEC_RESPONSE.FromString(xmlstr);
                type = ENUM_LLRP_MSG_TYPE.DELETE_ACCESSSPEC_RESPONSE;
                break;

            case "ENABLE_ACCESSSPEC":
                msg  = (Message)MSG_ENABLE_ACCESSSPEC.FromString(xmlstr);
                type = ENUM_LLRP_MSG_TYPE.ENABLE_ACCESSSPEC;
                break;

            case "ENABLE_ACCESSSPEC_RESPONSE":
                msg  = (Message)MSG_ENABLE_ACCESSSPEC_RESPONSE.FromString(xmlstr);
                type = ENUM_LLRP_MSG_TYPE.ENABLE_ACCESSSPEC_RESPONSE;
                break;

            case "DISABLE_ACCESSSPEC":
                msg  = (Message)MSG_DISABLE_ACCESSSPEC.FromString(xmlstr);
                type = ENUM_LLRP_MSG_TYPE.DISABLE_ACCESSSPEC;
                break;

            case "DISABLE_ACCESSSPEC_RESPONSE":
                msg  = (Message)MSG_DISABLE_ACCESSSPEC_RESPONSE.FromString(xmlstr);
                type = ENUM_LLRP_MSG_TYPE.DISABLE_ACCESSSPEC_RESPONSE;
                break;

            case "GET_ACCESSSPECS":
                msg  = (Message)MSG_GET_ACCESSSPECS.FromString(xmlstr);
                type = ENUM_LLRP_MSG_TYPE.GET_ACCESSSPECS;
                break;

            case "GET_ACCESSSPECS_RESPONSE":
                msg  = (Message)MSG_GET_ACCESSSPECS_RESPONSE.FromString(xmlstr);
                type = ENUM_LLRP_MSG_TYPE.GET_ACCESSSPECS_RESPONSE;
                break;

            case "GET_READER_CONFIG":
                msg  = (Message)MSG_GET_READER_CONFIG.FromString(xmlstr);
                type = ENUM_LLRP_MSG_TYPE.GET_READER_CONFIG;
                break;

            case "GET_READER_CONFIG_RESPONSE":
                msg  = (Message)MSG_GET_READER_CONFIG_RESPONSE.FromString(xmlstr);
                type = ENUM_LLRP_MSG_TYPE.GET_READER_CONFIG_RESPONSE;
                break;

            case "SET_READER_CONFIG":
                msg  = (Message)MSG_SET_READER_CONFIG.FromString(xmlstr);
                type = ENUM_LLRP_MSG_TYPE.SET_READER_CONFIG;
                break;

            case "SET_READER_CONFIG_RESPONSE":
                msg  = (Message)MSG_SET_READER_CONFIG_RESPONSE.FromString(xmlstr);
                type = ENUM_LLRP_MSG_TYPE.SET_READER_CONFIG_RESPONSE;
                break;

            case "CLOSE_CONNECTION":
                msg  = (Message)MSG_CLOSE_CONNECTION.FromString(xmlstr);
                type = ENUM_LLRP_MSG_TYPE.CLOSE_CONNECTION;
                break;

            case "CLOSE_CONNECTION_RESPONSE":
                msg  = (Message)MSG_CLOSE_CONNECTION_RESPONSE.FromString(xmlstr);
                type = ENUM_LLRP_MSG_TYPE.CLOSE_CONNECTION_RESPONSE;
                break;

            case "GET_REPORT":
                msg  = (Message)MSG_GET_REPORT.FromString(xmlstr);
                type = ENUM_LLRP_MSG_TYPE.GET_REPORT;
                break;

            case "RO_ACCESS_REPORT":
                msg  = (Message)MSG_RO_ACCESS_REPORT.FromString(xmlstr);
                type = ENUM_LLRP_MSG_TYPE.RO_ACCESS_REPORT;
                break;

            case "KEEPALIVE":
                msg  = (Message)MSG_KEEPALIVE.FromString(xmlstr);
                type = ENUM_LLRP_MSG_TYPE.KEEPALIVE;
                break;

            case "KEEPALIVE_ACK":
                msg  = (Message)MSG_KEEPALIVE_ACK.FromString(xmlstr);
                type = ENUM_LLRP_MSG_TYPE.KEEPALIVE_ACK;
                break;

            case "READER_EVENT_NOTIFICATION":
                msg  = (Message)MSG_READER_EVENT_NOTIFICATION.FromString(xmlstr);
                type = ENUM_LLRP_MSG_TYPE.READER_EVENT_NOTIFICATION;
                break;

            case "ENABLE_EVENTS_AND_REPORTS":
                msg  = (Message)MSG_ENABLE_EVENTS_AND_REPORTS.FromString(xmlstr);
                type = ENUM_LLRP_MSG_TYPE.ENABLE_EVENTS_AND_REPORTS;
                break;

            case "ERROR_MESSAGE":
                msg  = (Message)MSG_ERROR_MESSAGE.FromString(xmlstr);
                type = ENUM_LLRP_MSG_TYPE.ERROR_MESSAGE;
                break;

            default:
                type = (ENUM_LLRP_MSG_TYPE)0;
                msg  = (Message)CustomMsgDecodeFactory.DecodeXmlNodeToCustomMessage(documentElement, xmlstr);
                if (msg == null)
                {
                    break;
                }
                type = ENUM_LLRP_MSG_TYPE.CUSTOM_MESSAGE;
                break;
            }
        }