public bool CalibrationTest(Behavior behavior) { TestModbusTCPConnection testConnection = new TestModbusTCPConnection(behavior, "172.19.103.8"); WtxModbus WTXModbusObj = new WtxModbus(testConnection, 200); WTXModbusObj.Connect(this.OnConnect, 100); int testCalibrationValue = 111; WTXModbusObj.Calibrate(testCalibrationValue, "111"); // Check if: write reg 46, CalibrationWeight and write reg 50, 0x7FFFFFFF if ( (testConnection.getArrElement1 == (testCalibrationValue & 0xffff0000) >> 16) && (testConnection.getArrElement2 == (testCalibrationValue & 0x0000ffff)) && (testConnection.getArrElement3 == (0x7FFFFFFF & 0xffff0000) >> 16) && (testConnection.getArrElement4 == (0x7FFFFFFF & 0x0000ffff)) ) { return(true); } else { return(false); } }
public bool CalculateCalibrationTest(Behavior behavior) { TestModbusTCPConnection testConnection = new TestModbusTCPConnection(behavior, "172.19.103.8"); WtxModbus WTXModbusObj = new WtxModbus(testConnection, 200); WTXModbusObj.Connect(this.OnConnect, 100); double preload = 1; double capacity = 2; double multiplierMv2D = 500000; // 2 / 1000000; // 2mV/V correspond 1 million digits (d) double dPreload = preload * multiplierMv2D; double dNominalLoad = dPreload + (capacity * multiplierMv2D); WTXModbusObj.Calculate(preload, capacity); if ( (testConnection.getArrElement1 == (Convert.ToInt32(dPreload) & 0xffff0000) >> 16) && (testConnection.getArrElement2 == (Convert.ToInt32(dPreload) & 0x0000ffff)) && (testConnection.getArrElement3 == (Convert.ToInt32(dNominalLoad) & 0xffff0000) >> 16) && (testConnection.getArrElement4 == (Convert.ToInt32(dNominalLoad) & 0x0000ffff)) && WTXModbusObj.getDPreload == dPreload && WTXModbusObj.getDNominalLoad == dNominalLoad ) { return(true); } else { return(false); } }