//-------------------------------------------------------------------------------------------------// private bool GetEngValue(ModbusRegs_Holding_RO register, ref double engValue, ref string units) { bool success; // // Find the register mapping // int index = this.FindRegisterMapping(register); RegisterMapping mapping = RegisterMapRO[index]; // // Read the register // ushort regValue = 0; if ((success = this.ReadHoldingRegister((int)register, ref regValue)) == true) { // // Convert the register value to eng. units // engValue = this.ConvertRawToEng(regValue, mapping.raw, mapping.eng); units = mapping.units; } //Trace.WriteLine((success == true) ? STRLOG_IsOk : STRLOG_HasFailed); return(success); }
//-------------------------------------------------------------------------------------------------// private int FindRegisterMapping(ModbusRegs_Holding_RO register) { int index = -1; for (int i = 0; i < RegisterMapRO.Length; i++) { if ((int)register == RegisterMapRO[i].register) { index = i; break; } } return(index); }
//-------------------------------------------------------------------------------------------------// private bool GetEngValue(ModbusRegs_Holding_RO register, ref double engValue, ref string units) { bool success; // // Find the register mapping // int index = this.FindRegisterMapping(register); RegisterMapping mapping = RegisterMapRO[index]; // // Read the register // ushort regValue = 0; if ((success = this.ReadHoldingRegister((int)register, ref regValue)) == true) { // // Convert the register value to eng. units // engValue = this.ConvertRawToEng(regValue, mapping.raw, mapping.eng); units = mapping.units; } //Trace.WriteLine((success == true) ? STRLOG_IsOk : STRLOG_HasFailed); return success; }
//-------------------------------------------------------------------------------------------------// private int FindRegisterMapping(ModbusRegs_Holding_RO register) { int index = -1; for (int i = 0; i < RegisterMapRO.Length; i++) { if ((int)register == RegisterMapRO[i].register) { index = i; break; } } return index; }