Esempio n. 1
0
        static void Main(string[] args)
        {
            bool testVal1, testVal2;
            PLC  plc = new PLC("PLC.txt");

            while (!plc.Connect())
            {
            }
            while (!plc.WriteBit("OUT[4]", true))
            {
            }
            while (!plc.ReadBit("IN[5]", out testVal1))
            {
            }
            while (!plc.ReadBit("IN[6]", out testVal2))
            {
            }

            while (!plc.WriteBit("OUT[3]", true))
            {
            }
            while (!plc.ReadBit("IN[5]", out testVal1))
            {
            }
            while (!plc.ReadBit("IN[6]", out testVal2))
            {
            }

            Console.Write("Closed: " + testVal1.ToString() + "\nOpen: " + testVal2.ToString());
            Console.Read();
        }
Esempio n. 2
0
        public void WriteReadBit()
        {
            bool testVal = false;
            bool read = false, wrote = false;

            while (!read && !wrote)
            {
                wrote = _plc.WriteBit("IN[1]", true);
                read  = _plc.ReadBit("IN[1]", out testVal);

                if (!read || !wrote)
                {
                    wrote = read = false;
                }
            }

            Assert.AreEqual(testVal, true);
        }
Esempio n. 3
0
        /// <summary>
        /// Check the plc to see if the main tank is empty.
        /// </summary>
        /// <returns></returns>
        public bool CheckMainTankIsEmpty()
        {
            bool isEmpty;

            while (!_plc.ReadBit("IN[1]", out isEmpty))
            {
            }

            return(isEmpty);
        }