Ejemplo 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;
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
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);
        }
        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 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);
        }
Ejemplo n.º 6
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]);
        }
Ejemplo n.º 7
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);
            }
        }