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 LogEventSetTest(Behavior behavior) { testConnection = new TestModbusTCPConnection(behavior, "172.19.103.8"); WTXModbusObj = new WtxModbus(testConnection, 200); WTXModbusObj.Connect(this.OnConnect, 100); testConnection.IsConnected = true; WTXModbusObj.Async_Call(0x00, callbackMethod); Thread.Sleep(100); if (testConnection._logObj.Args.Equals("Read successful: Registers have been read")) { return(true); } else if (testConnection._logObj.Args.Equals("Read failed : Registers have not been read")) { return(false); } else { return(false); } //return WTXModbusObj.ApplicationMode; }
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); } }
public bool WriteArrayTestCasesModbus(Behavior behavior) { bool parameterEqualArrayWritten = false; TestModbusTCPConnection testConnection = new TestModbusTCPConnection(behavior, "172.19.103.8"); WtxModbus _wtxObj = new WtxModbus(testConnection, 200); _wtxObj.Connect(this.OnConnect, 100); _wtxObj.WriteOutputWordS32(0x7FFFFFFF, 50, Write_DataReceived); if ((testConnection.getArrElement1 == (0x7FFFFFFF & 0xffff0000) >> 16) && (testConnection.getArrElement2 == (0x7FFFFFFF & 0x0000ffff))) { parameterEqualArrayWritten = true; } else { parameterEqualArrayWritten = false; } //Assert.AreEqual(true ,parameterEqualArrayWritten); return(parameterEqualArrayWritten); }
public int testHandshake(Behavior behavior) { testConnection = new TestModbusTCPConnection(behavior, "172.19.103.8"); WTXModbusObj = new WtxModbus(testConnection, 200); WTXModbusObj.Connect(this.OnConnect, 100); WTXModbusObj.SyncCall(0, 0x1, OnWriteData); return(WTXModbusObj.Handshake); }
public void TareAsyncTestModbus(Behavior behavior) { testConnection = new TestModbusTCPConnection(behavior, "172.19.103.8"); _wtxObj = new WtxModbus(testConnection, 200); _wtxObj.Connect(this.OnConnect, 100); _wtxObj.Async_Call(0x1, callbackMethod); Assert.AreEqual(0x1, _wtxObj.getCommand); }
public void AbortDosingMethodTestModbus(Behavior behavior) { testConnection = new TestModbusTCPConnection(behavior, "172.19.103.8"); _wtxObj = new WtxModbus(testConnection, 200); _wtxObj.Connect(this.OnConnect, 100); //_wtxObj.isConnected = true; _wtxObj.abortDosing(callbackMethod); Assert.AreEqual(0x8, _wtxObj.getCommand); }
public void ManualRedosingMethodTestModbus(Behavior behavior) { testConnection = new TestModbusTCPConnection(behavior, "172.19.103.8"); _wtxObj = new WtxModbus(testConnection, 200); _wtxObj.Connect(this.OnConnect, 100); _wtxObj.manualReDosing(callbackMethod); //return _wtxObj.getCommand; Assert.AreEqual(0x8000, _wtxObj.getCommand); }
public int ResetTimerTestModbus(Behavior behavior) { testConnection = new TestModbusTCPConnection(behavior, "172.19.103.8"); _wtxObj = new WtxModbus(testConnection, 200); _wtxObj.Connect(this.OnConnect, 100); _wtxObj.ResetTimer(500); return((int)_wtxObj._aTimer.Interval); //Assert.AreEqual(_wtxObj._aTimer.Interval, 500); }
public void ZeroMethodTestModbus(Behavior behavior) { testConnection = new TestModbusTCPConnection(behavior, "172.19.103.8"); _wtxObj = new WtxModbus(testConnection, 200); _wtxObj.Connect(this.OnConnect, 100); _wtxObj.zeroing(callbackMethod); //return testConnection.getCommand; Assert.AreEqual(0x40, _wtxObj.getCommand); }
public void RecordweightMethodTestModbus(Behavior behavior) { testConnection = new TestModbusTCPConnection(behavior, "172.19.103.8"); _wtxObj = new WtxModbus(testConnection, 200); _wtxObj.Connect(this.OnConnect, 100); _wtxObj.recordWeight(callbackMethod); //return _wtxObj.getCommand; Assert.AreEqual(0x4000, _wtxObj.getCommand); }
public void ClearDosingResultsMethodTestModbus(Behavior behavior) { testConnection = new TestModbusTCPConnection(behavior, "172.19.103.8"); _wtxObj = new WtxModbus(testConnection, 200); _wtxObj.Connect(this.OnConnect, 100); _wtxObj.clearDosingResults(callbackMethod); //return _wtxObj.getCommand; Assert.AreEqual(0x4, _wtxObj.getCommand); }
public void /*int*/ ActivateDataMethodTestModbus(Behavior behavior) { testConnection = new TestModbusTCPConnection(behavior, "172.19.103.8"); _wtxObj = new WtxModbus(testConnection, 200); _wtxObj.Connect(this.OnConnect, 100); _wtxObj.activateData(callbackMethod); //return _wtxObj.getCommand; Assert.AreEqual(0x800, _wtxObj.getCommand); }
public void AdjustingNominalMethodTestModbus(Behavior behavior) { testConnection = new TestModbusTCPConnection(behavior, "172.19.103.8"); _wtxObj = new WtxModbus(testConnection, 200); _wtxObj.Connect(this.OnConnect, 100); _wtxObj.adjustNominal(callbackMethod); //return _wtxObj.getCommand; Assert.AreEqual(0x100, _wtxObj.getCommand); }
public int WriteTestCasesModbus(Behavior behavior) { testConnection = new TestModbusTCPConnection(behavior, "172.19.103.8"); _wtxObj = new WtxModbus(testConnection, 200); _wtxObj.Connect(this.OnConnect, 100); // Write : Gross/Net _wtxObj.Async_Call(0x2, OnWriteData); return(testConnection.getCommand); // Alternative Assert.AreEqual(0x2, testConnection.getCommand); }
public string testModbus_WeightMovingStringComment_Case1(Behavior behavior) { TestModbusTCPConnection testConnection = new TestModbusTCPConnection(behavior, "172.19.103.8"); WtxModbus _wtxObj = new WtxModbus(testConnection, 200); _wtxObj.Connect(this.OnConnect, 100); _wtxObj.Async_Call(0x00, OnReadData); Thread.Sleep(10); //testConnection.ReadRegisterPublishing(new DataEvent(new ushort[58], new string[58])); return(_wtxObj.WeightMovingStringComment()); }
public int WriteSyncTest(Behavior behavior) { testConnection = new TestModbusTCPConnection(behavior, "172.19.103.8"); _wtxObj = new WtxModbus(testConnection, 200); _wtxObj.Connect(this.OnConnect, 100); _wtxObj.SyncCall(0, 0x100, callbackMethod); return(testConnection.getCommand); // Alternative : Assert.AreEqual(0x100, testConnection.getCommand); }
public bool DisconnectTestModbus(Behavior behavior) { testConnection = new TestModbusTCPConnection(behavior, "172.19.103.8"); WTXModbusObj = new WtxModbus(testConnection, 200); WTXModbusObj.Connect(this.OnConnect, 100); Thread.Sleep(1000); // Do something.... and disconnect. WTXModbusObj.Disconnect(this.OnDisconnect); return(WTXModbusObj.isConnected); // Alternative : Assert.AreEqual(WTXModbusObj.isConnected, true); }
public bool ConnectTestModbus(Behavior behavior) { testConnection = new TestModbusTCPConnection(behavior, "172.19.103.8"); WTXModbusObj = new WtxModbus(testConnection, 200); this.connectCallbackCalled = false; WTXModbusObj.Connect(this.OnConnect, 100); Thread.Sleep(300); return(WTXModbusObj.isConnected); // Alternative : Assert.AreEqual(this.connectCallbackCalled, true); }
public bool UpdateOutput1Test(Behavior behavior) { bool compareDataWritten = false; ushort[] _dataWritten = new ushort[2]; ushort[] _outputData = new ushort[43]; for (int i = 0; i < _outputData.Length; i++) { _outputData[i] = 1; } testConnection = new TestModbusTCPConnection(behavior, "172.19.103.8"); _wtxObj = new WtxModbus(testConnection, 200); _wtxObj.Connect(this.OnConnect, 100); _wtxObj.UpdateOutputWords(_outputData); for (int i = 0; i < _outputData.Length; i++) { _wtxObj.WriteOutputWordS32(_outputData[i], (ushort)(i + 40), callbackMethod); _dataWritten[0] = (ushort)((_outputData[i] & 0xffff0000) >> 16); _dataWritten[1] = (ushort)(_outputData[i] & 0x0000ffff); if (testConnection.getArrElement1 == _dataWritten[0] && testConnection.getArrElement2 == _dataWritten[1] && testGetOutputwords() == true) { compareDataWritten = true; } else { compareDataWritten = false; } } _wtxObj.activateData(callbackMethod); if (compareDataWritten == true /* && testConnection.getCommand==0x800*/) { return(true); } else { return(false); } }
public void testModbus_NetGrossValueStringComment_6D(Behavior behavior) { TestModbusTCPConnection testConnection = new TestModbusTCPConnection(behavior, "172.19.103.8"); WtxModbus _wtxObj = new WtxModbus(testConnection, 200); _wtxObj.Connect(this.OnConnect, 100); _wtxObj.Async_Call(0x00, OnReadData); Thread.Sleep(10); //testConnection.ReadRegisterPublishing(new DataEvent(new ushort[58], new string[58])); string strValue = _wtxObj.NetGrossValueStringComment(_wtxObj.GrossValue, 6 /*_wtxObj.Decimals*/); double dValue = _wtxObj.GrossValue / Math.Pow(10, 6 /*_wtxObj.Decimals*/); Assert.AreEqual(dValue.ToString("0.000000"), strValue); }
public int ApplicationModeTest(Behavior behavior) { TestModbusTCPConnection testConnection = new TestModbusTCPConnection(behavior, "172.19.103.8"); WtxModbus WTXModbusObj = new WtxModbus(testConnection, 200); WTXModbusObj.Connect(this.OnConnect, 100); testConnection.Write(0, 0); testConnection.Read(0); return(testConnection.getData[5] & 0x3 >> 1); //return WTXModbusObj.ApplicationMode; }
public ushort ReadTestModbus(Behavior behavior) { testConnection = new TestModbusTCPConnection(behavior, "172.19.103.8"); WTXModbusObj = new WtxModbus(testConnection, 200); WTXModbusObj.Connect(this.OnConnect, 100); testConnection.IsConnected = true; WTXModbusObj.Async_Call(0x00, callbackMethod); Thread.Sleep(100); return(WTXModbusObj.GetDataUshort[1]); //return (ushort)WTXModbusObj.NetValue; // Alternative :Assert.AreEqual(_dataReadSuccess[0], WTXModbusObj.GetDataUshort[0]); }
public bool WriteU08ArrayTestModbus(Behavior behavior) { ushort[] _data = new ushort[1]; _data[0] = (ushort)(0xA1 & 0xFF); testConnection = new TestModbusTCPConnection(behavior, "172.19.103.8"); _wtxObj = new WtxModbus(testConnection, 200); _wtxObj.Connect(this.OnConnect, 100); _wtxObj.WriteOutputWordU08(0xA1, 1, callbackMethod); if (testConnection.getArrElement1 == _data[0] && testConnection.getWordNumber == 1) { return(true); } else { return(false); } }
public bool WriteS32ArrayTestModbus(Behavior behavior) { ushort[] _data = new ushort[2]; _data[0] = (ushort)((0x7FFFFFFF & 0xFFFF0000) >> 16); _data[1] = (ushort)(0x7FFFFFFF & 0x0000FFFF); testConnection = new TestModbusTCPConnection(behavior, "172.19.103.8"); _wtxObj = new WtxModbus(testConnection, 200); _wtxObj.Connect(this.OnConnect, 100); _wtxObj.WriteOutputWordS32(0x7FFFFFFF, 48, Write_DataReceived); if (testConnection.getArrElement1 == _data[0] && testConnection.getArrElement2 == _data[1] && testConnection.getWordNumber == 48) { return(true); } else { return(false); } }
public bool MeasureZeroTest(Behavior behavior) { testConnection = new TestModbusTCPConnection(behavior, "172.19.103.8"); WTXModbusObj = new WtxModbus(testConnection, 200); WTXModbusObj.Connect(this.OnConnect, 100); WTXModbusObj.MeasureZero(); WTXModbusObj.Async_Call(0x00, OnReadData); //check if : write reg 48, 0x7FFFFFFF and if Net and gross value are zero. if ((testConnection.getArrElement1 == (0x7FFFFFFF & 0xffff0000) >> 16) && (testConnection.getArrElement2 == (0x7FFFFFFF & 0x0000ffff)) && WTXModbusObj.NetValue == 0 && WTXModbusObj.GrossValue == 0) { return(true); } else { return(false); } }