private ModbusRTUReader ToModbusRTUReader() { ModbusRTUReader read = new ModbusRTUReader(); read.Type = this.Type; read.Address = this.PLCAddress; read.Length = this.Length; read.Scale = this.Scale; read.offsetAddress = this.offsetAddress; return(read); }
public void ReadValForModRTU(byte[] buffer) { this.LastTime = DataUtil.ToDateString(DateTime.Now); // this.LastTime = DataUtil.ToDateString(Config.LastTime); ModbusRTUReader read = ToModbusRTUReader(); read.Read(buffer); switch (read.state) { case ValueState.Success: { this.State = read.state; this.Value = DataUtil.ToDouble(read.Value); } break; case ValueState.Fail: { MakeFail(read.mess); return; } } }