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); }
protected void SetupVariables() { InverterAddress = (ByteVar)Params.Protocol.GetSessionVariable("%Address", null); ModbusCommand = (ByteVar)Params.Protocol.GetSessionVariable("%CommandId", null); RegisterCount = (ByteVar)Params.Protocol.GetSessionVariable("%Registers", null); FirstModbusAddress = (ByteVar)Params.Protocol.GetSessionVariable("%FirstAddress", null); DeviceData = (ByteVar)Params.Protocol.GetSessionVariable("%Data", null); DeviceDataSize = (ByteVar)Params.Protocol.GetSessionVariable("%DataSize", null); DeviceDataValue = (ByteVar)Params.Protocol.GetSessionVariable("%DataValue", null); DeviceDataValueSize = (ByteVar)Params.Protocol.GetSessionVariable("%DataValueSize", null); }
public void AddResizeVariable(ByteVar variable) { ResizeVariables.Add(variable); }