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); }
public UseVariable(Conversation conversation, String varName, String type = null, int? size = null, bool excludeFromChecksum = false, int messageId = 0) : base(conversation, excludeFromChecksum) { Converse session = conversation.Converse; int? variableSize; Variable = conversation.GetVariable(varName); VariableType = type; variableSize = size; Calculations = session.Calculations; IsChecksum16 = (varName.ToUpper() == "CHECKSUM16"); IsChecksum8 = (varName.ToUpper() == "CHECKSUM8"); IsChecksum = IsChecksum16 || IsChecksum8; if (Variable == null) // variable not defined if (type == null) { Variable = new StringVar(varName, conversation); session.Variables.Add(Variable); } else if (type == "BYTE") { Variable = new ByteVar(varName, variableSize, conversation); session.Variables.Add(Variable); } else if (type == "DYNAMICBYTE") { if (variableSize == null || variableSize < 1) variableSize = 10000; Variable = new DynamicByteVar(varName, variableSize.Value, conversation); session.Variables.Add(Variable); } else if (type == "STRING") { Variable = new StringVar(varName, conversation); session.Variables.Add(Variable); } else throw new Exception("Variable " + varName + " type not supported: " + type); }