예제 #1
0
파일: Program.cs 프로젝트: alwalker/TTU
        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();
        }
예제 #2
0
파일: PLC-Test.cs 프로젝트: alwalker/TTU
        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);
        }
예제 #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);
        }