public CC_EnviR_Converse(IUtilityLog log)
            : base(log, null)
        {
            // don't bother with ConversationLoader - it is a very simple pattern
            // below creates the conversation definition

            Conversation conv = new Conversation(this, "CC_EnviR_Receive", log);
            Conversations.Add(conv);
            Message message = new Message(conv, MessageType.Find, "");
            Literal literal = new Literal(Element.StringToHex("<msg>", " "), conv);
            message.Elements.Add(literal);
            conv.Messages.Add(message);

            message = new Message(conv, MessageType.ExtractDynamic, "");
            DynamicByteVar variable = new DynamicByteVar("DATA", 10000, conv);
            Variables.Add(variable);
            UseVariable useVar = new UseVariable(conv, "DATA");
            message.Elements.Add(useVar);
            literal = new Literal(Element.StringToHex("</msg>", " "), conv);
            message.Elements.Add(literal);
            conv.Messages.Add(message);
        }
Exemplo n.º 2
0
        private Message LoadMessage(Conversation conv, MessageSettings settings)
        {
            MessageType type = settings.Type;
            if (type == MessageType.ValueCount)
                return null;

            Message message = new Message(conv, type, settings.Name);

            foreach (MessageSettings.ElementListValue element in settings.ElementList)
            {
                if (element.Type == "BYTE")
                {
                    if (element.ValueString != null)
                    {
                        message.Elements.Add(new Literal(element.ValueString, conv, element.ExcludeFromChecksum));
                    }
                    else
                    {
                        UseVariable useVar = new UseVariable(conv, element.Name, element.Type, element.Size, element.ExcludeFromChecksum);
                        message.Elements.Add(useVar);
                        if (element.SizeName != null)
                        {
                            try
                            {
                                ByteVar sizeVar = (ByteVar)conv.GetVariable(element.SizeName);
                                sizeVar.AddResizeVariable((ByteVar)useVar.Variable);
                            }
                            catch (Exception) // exceptions are caused by incorrect element types - both must be ByteVar
                            {
                            }
                        }
                    }
                }
                else if (element.Type == "DYNAMICBYTE")
                {
                    UseVariable useVar = new UseVariable(conv, element.Name, element.Type, element.Size, element.ExcludeFromChecksum);
                    message.Elements.Add(useVar);
                    if (element.SizeName != null)
                    {
                        try
                        {
                            ByteVar sizeVar = (ByteVar)conv.GetVariable(element.SizeName);
                            sizeVar.AddResizeVariable((ByteVar)useVar.Variable);
                        }
                        catch (Exception) // exceptions are caused by incorrect element types - both must be ByteVar
                        {
                        }
                    }
                }
                else if (element.Type == "STRING")
                {
                    UseVariable useVar = new UseVariable(conv, element.Name, element.Type, element.Size, element.ExcludeFromChecksum);
                    message.Elements.Add(useVar);
                }
            }

            return message;
        }