Exemplo n.º 1
0
        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;
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
0
        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);
        }
Exemplo n.º 7
0
        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);
        }
Exemplo n.º 8
0
        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);
        }
Exemplo n.º 9
0
        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);
        }
Exemplo n.º 10
0
        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);
        }
Exemplo n.º 11
0
        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);
        }
Exemplo n.º 12
0
        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 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());
        }
Exemplo n.º 14
0
        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);
        }
Exemplo n.º 15
0
        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);
        }
Exemplo n.º 16
0
        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);
        }
Exemplo n.º 17
0
        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);
        }
Exemplo n.º 18
0
        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);
        }
Exemplo n.º 20
0
        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;
        }
Exemplo n.º 21
0
        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]);
        }
Exemplo n.º 22
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);
            }
        }
Exemplo n.º 23
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, "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);
            }
        }
Exemplo n.º 24
0
        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);
            }
        }