public bool CalibrationTest(Behavior behavior)
        {
            TestModbusTCPConnection testConnection = new TestModbusTCPConnection(behavior, "172.19.103.8");

            WTXModbus WTXModbusObj = new WTXModbus(testConnection, 200, update);

            WTXModbusObj.Connect(this.OnConnect, 100);

            int testCalibrationValue = 111;

            WTXModbusObj.AdjustNominalSignalWithCalibrationWeight((double)testCalibrationValue);

            // 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);
            }
        }
Exemple #2
0
        public async Task <bool> LogEventSetTest(Behavior behavior)
        {
            testConnection = new TestModbusTCPConnection(behavior, "172.19.103.8");
            _wtxDevice     = new WTXModbus(testConnection, 200, UpdateLogEventSetTest);

            _wtxDevice.Connect(this.OnConnect, 100);
            testConnection.IsConnected = true;

            _data = await testConnection.SyncData();

            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 _wtxDevice.ApplicationMode;
        }
        public bool CalculateCalibrationTest(Behavior behavior)
        {
            TestModbusTCPConnection testConnection = new TestModbusTCPConnection(behavior, "172.19.103.8");
            WTXModbus WTXModbusObj = new WTXModbus(testConnection, 200, update);

            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.CalculateAdjustment(preload, capacity);

            if (
                (testConnection.getArrElement1 == (Convert.ToInt32(dPreload) & 0xffff0000) >> 16) &&
                (testConnection.getArrElement2 == (Convert.ToInt32(dPreload) & 0x0000ffff))
                )
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #4
0
        public bool ConnectTestModbus(Behavior behavior)
        {
            testConnection = new TestModbusTCPConnection(behavior, "172.19.103.8");
            WTXModbusObj   = new WTXModbus(testConnection, 200, update);

            //this.connectCallbackCalled = false;

            WTXModbusObj.Connect(this.OnConnect, 100);

            return(WTXModbusObj.IsConnected);
        }
Exemple #5
0
        public bool DisconnectTestModbus(Behavior behavior)
        {
            testConnection = new TestModbusTCPConnection(behavior, "172.19.103.8");
            WTXModbusObj   = new WTXModbus(testConnection, 200, update);

            WTXModbusObj.Connect(this.OnConnect, 100);

            WTXModbusObj.Disconnect(this.OnDisconnect);

            return(WTXModbusObj.IsConnected);
        }
        public int ResetTimerTestModbus(Behavior behavior)
        {
            testConnection = new TestModbusTCPConnection(behavior, "172.19.103.8");
            _wtxObj        = new WTXModbus(testConnection, 200, Update);

            _wtxObj.Connect(this.OnConnect, 100);

            _wtxObj.ProcessDataInterval = 500;

            return((int)_wtxObj.ProcessDataInterval);
            //Assert.AreEqual(_wtxObj._aTimer.Interval, 500);
        }
Exemple #7
0
        public int ApplicationModeTest(Behavior behavior)
        {
            TestModbusTCPConnection testConnection = new TestModbusTCPConnection(behavior, "172.19.103.8");

            WTXModbus _wtxDevice = new WTXModbus(testConnection, 200, UpdateApplicationModeTest);

            _wtxDevice.Connect(this.OnConnect, 100);

            testConnection.WriteInteger(ModbusCommands.ControlWordActivateData, 0);

            testConnection.Read(0);

            return(testConnection.getData[5] & 0x3 >> 1);
        }
Exemple #8
0
        public async Task <ushort> ReadTestModbus(Behavior behavior)
        {
            testConnection = new TestModbusTCPConnection(behavior, "172.19.103.8");
            _wtxDevice     = new WTXModbus(testConnection, 200, UpdateReadTest);

            _wtxDevice.Connect(this.OnConnect, 100);

            await Task.Run(async() =>
            {
                ushort[] _data = await testConnection.SyncData();
            });

            _testValue = (ushort)_wtxDevice.ProcessData.Weight.Net;
            return(_testValue);
        }
Exemple #9
0
        public async Task <string> testModbus_NetGrossValueStringComment(Behavior behavior)
        {
            TestModbusTCPConnection testConnection = new TestModbusTCPConnection(behavior, ipaddress);
            WTXModbus _wtxObj = new WTXModbus(testConnection, 200, update);

            _wtxObj.Connect(this.OnConnect, 100);

            await Task.Run(async() =>
            {
                ushort[] _data = await testConnection.SyncData();
            });

            string strValue = _wtxObj.PrintableWeight.Net;

            return(strValue);
        }
Exemple #10
0
        public async Task <string> testModbus_Unit(Behavior behavior)
        {
            TestModbusTCPConnection testConnection = new TestModbusTCPConnection(behavior, ipaddress);

            WTXModbus _wtxObj = new WTXModbus(testConnection, 200, update);

            _wtxObj.Connect(this.OnConnect, 100);

            await Task.Run(async() =>
            {
                ushort[] _data = await testConnection.SyncData();
            });


            return(_wtxObj.ProcessData.Unit);
        }
        public bool LimitSwitch4ModeWriteTestModbus(Behavior behavior)
        {
            testConnection = new TestModbusTCPConnection(behavior, "172.19.103.8");
            _wtxObj        = new WTXModbus(testConnection, 200, Update);
            _wtxObj.Connect(this.OnConnect, 100);

            _wtxObj.DataStandard.LimitSwitch4Mode = LimitSwitchMode.OutsideBand;

            if (testConnection.GetCommand == 23 && _wtxObj.DataStandard.LimitSwitch4Mode == LimitSwitchMode.OutsideBand)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #12
0
        public bool LimitSwitch3ModeWriteTestModbus(Behavior behavior)
        {
            testConnection = new TestModbusTCPConnection(behavior, ipaddress);
            _wtxObj        = new WTXModbus(testConnection, 200, Update);
            _wtxObj.Connect(this.OnConnect, 100);

            _wtxObj.LimitSwitch.LimitSwitch3Mode = LimitSwitchMode.InsideBand;

            if (testConnection.GetCommand == 17 && _wtxObj.LimitSwitch.LimitSwitch3Mode == LimitSwitchMode.InsideBand)
            {
                return(true);
            }

            else
            {
                return(false);
            }
        }
        public void RecordweightMethodTestModbus(Behavior behavior)
        {
            testConnection = new TestModbusTCPConnection(behavior, "172.19.103.8");
            _wtxObj        = new WTXModbus(testConnection, 200, Update);

            _wtxObj.Connect(this.OnConnect, 100);

            _wtxObj.RecordWeight();

            if (behavior == Behavior.TareMethodTestSuccess)
            {
                Assert.AreEqual(0x4000, testConnection.GetCommand);
            }
            else
            if (behavior == Behavior.TareMethodTestFail)
            {
                Assert.AreEqual(0x0, testConnection.GetCommand);
            }
        }
        public void /*int*/ ActivateDataMethodTestModbus(Behavior behavior)
        {
            testConnection = new TestModbusTCPConnection(behavior, "172.19.103.8");
            _wtxObj        = new WTXModbus(testConnection, 200, Update);

            _wtxObj.Connect(this.OnConnect, 100);

            _wtxObj.ActivateData();

            if (behavior == Behavior.TareMethodTestSuccess)
            {
                Assert.AreEqual(0x800, testConnection.GetCommand);
            }
            else
            if (behavior == Behavior.TareMethodTestFail)
            {
                Assert.AreEqual(0x0, testConnection.GetCommand);
            }
        }
        public void AdjustingNominalMethodTestModbus(Behavior behavior)
        {
            testConnection = new TestModbusTCPConnection(behavior, "172.19.103.8");
            _wtxObj        = new WTXModbus(testConnection, 200, Update);

            _wtxObj.Connect(this.OnConnect, 100);

            _wtxObj.AdjustNominalSignal();

            if (behavior == Behavior.TareMethodTestSuccess)
            {
                Assert.AreEqual(0x100, testConnection.GetCommand);
            }
            else
            if (behavior == Behavior.TareMethodTestFail)
            {
                Assert.AreEqual(0x0, testConnection.GetCommand);
            }
        }
Exemple #16
0
        public void AdjustingZeroMethodTestModbus(Behavior behavior)
        {
            testConnection = new TestModbusTCPConnection(behavior, ipaddress);
            _wtxObj        = new WTXModbus(testConnection, 200, Update);

            _wtxObj.Connect(this.OnConnect, 100);

            _wtxObj.AdjustZeroSignal();

            if (behavior == Behavior.TareMethodTestSuccess)
            {
                Assert.AreEqual(0x80, testConnection.GetCommand);
            }
            else
            if (behavior == Behavior.TareMethodTestFail)
            {
                Assert.AreEqual(0x0, testConnection.GetCommand);
            }
        }
Exemple #17
0
        public void ManualTaringTestModbus(Behavior behavior)
        {
            testConnection = new TestModbusTCPConnection(behavior, ipaddress);
            _wtxObj        = new WTXModbus(testConnection, 200, Update);

            _wtxObj.Connect(this.OnConnect, 100);

            _wtxObj.TareManually(200.0);

            if (behavior == Behavior.TareMethodTestSuccess)
            {
                Assert.AreEqual(0x1000, testConnection.GetCommand);
            }
            else
            if (behavior == Behavior.TareMethodTestFail)
            {
                Assert.AreEqual(0x0, testConnection.GetCommand);
            }
        }
Exemple #18
0
        public async Task <string> testModbus_WeightMovingStringComment(Behavior behavior)
        {
            TestModbusTCPConnection testConnection = new TestModbusTCPConnection(behavior, ipaddress);
            WTXModbus _wtxObj = new WTXModbus(testConnection, 200, update);

            _wtxObj.Connect(this.OnConnect, 100);

            await Task.Run(async() =>
            {
                ushort[] _data = await testConnection.SyncData();
            });

            if (_wtxObj.WeightStable)
            {
                return("0=Weight is not moving.");
            }
            else
            {
                return("1=Weight is moving");
            }
        }
        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, Update);

            _wtxObj.Connect(this.OnConnect, 100);

            _wtxObj.Connection.WriteInteger(ModbusCommands.LIV1LimitSwitchSource, 0xA1);

            if (testConnection.getArrElement1 == _data[0] && testConnection.getWordNumber == 4)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #20
0
        public bool MeasureZeroTest(Behavior behavior)
        {
            testConnection = new TestModbusTCPConnection(behavior, "172.19.103.8");
            _wtxDevice     = new WTXModbus(testConnection, 200, UpdateMeasureZeroTest);

            _wtxDevice.Connect(this.OnConnect, 100);

            _wtxDevice.AdjustZeroSignal();

            //check if : write reg 48, 0x7FFFFFFF and if Net and gross value are zero.

            if ((testConnection.getArrElement1 == (0x7FFFFFFF & 0xffff0000) >> 16) &&
                (testConnection.getArrElement2 == (0x7FFFFFFF & 0x0000ffff)) &&
                _wtxDevice.ProcessData.Weight.Net == 0 && _wtxDevice.ProcessData.Weight.Gross == 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        public bool WriteU16ArrayTestModbus(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, Update);

            _wtxObj.Connect(this.OnConnect, 100);

            _wtxObj.Connection.WriteInteger(ModbusCommands.LWTNominalSignal, 0x7FFFFFFF);

            if (testConnection.getArrElement1 == _data[0] && testConnection.getArrElement2 == _data[1] && testConnection.getWordNumber == 50)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #22
0
        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, ipaddress);
            _wtxObj        = new WTXModbus(testConnection, 200, Update);

            _wtxObj.Connect(this.OnConnect, 100);

            _wtxObj.Connection.WriteInteger(ModbusCommands.LDWZeroSignal, 0x7FFFFFFF);

            if (testConnection.getArrElement1 == _data[0] && testConnection.getArrElement2 == _data[1] && testConnection.getWordNumber == 48)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }