private IVariable CreateString(ModbusVariableParams variableParams) { ModbusVariable <string> variable = new ModbusVariable <string>(); variable.Initialize(variableParams); return(variable); }
private IVariable CreateDouble(ModbusVariableParams variableParams) { ModbusVariable <double> variable = new ModbusVariable <double>(); variable.Initialize(variableParams); return(variable); }
private IVariable CreateFloat(ModbusVariableParams variableParams) { ModbusVariable <float> variable = new ModbusVariable <float>(); variable.Initialize(variableParams); return(variable); }
private IVariable CreateUShort(ModbusVariableParams variableParams) { ModbusVariable <ushort> variable = new ModbusVariable <ushort>(); variable.Initialize(variableParams); return(variable); }
private IVariable CreateBool(ModbusVariableParams variableParams) { ModbusVariable <bool> variable = new ModbusVariable <bool>(); variable.Initialize(variableParams); return(variable); }
private static VariableViewModel MapFromStorage(IPlc plc, Variable variable) { return(variable switch { S7Variable s7var => new S7VariableViewModel((S7Plc)plc, variable.Name, s7var.Address, variable.TypeCode, variable.Length, MapFromStorage(variable.State)), ModbusVariable modbusVar => new ModbusVariableViewModel((ModbusPlc)plc, variable.Name, modbusVar.ObjectType, modbusVar.Address, variable.TypeCode, variable.Length, MapFromStorage(variable.State)), _ => throw new Exception("Unsupported variable type") });