Пример #1
0
        static void Main()
        {
            Simulator.Simulator  process      = new Simulator.Simulator();
            TCP_PLC.ProcessLogic processLogic = new TCP_PLC.ProcessLogic(process);
            //int i = 0;

            process.Command_Update(Simulator.Command.Start);

            Thread processThread = new Thread(process.Simulate);

            processThread.Start();

            Thread processLogicThread = new Thread(processLogic.Run);

            processLogicThread.Start();

            while (true)
            {
                Console.WriteLine(process.Get_State());
                Console.WriteLine(process.Level);
                Thread.Sleep(500);
            }
            //process.PumpSpeed = 110;
            //process.Command_Update(SimulatorImproved.Command.Pump_1_On);
            //while (i < 10000)
            //{
            //    Console.WriteLine(process.Get_State());
            //    Console.WriteLine(process.level);
            //    i++;
            //    if (i > 20)
            //        process.Command_Update(SimulatorImproved.Command.Pump_2_On);
            //    Thread.Sleep(500);
            //}
        }
Пример #2
0
 public void Send()
 {
     try
     {
         while (true)
         {
             Console.WriteLine("--------------------------");
             Console.WriteLine(string.Format("Sending byte = {0} ", process.Get_State()));
             //Console.WriteLine(string.Format("Water level: " + process.Level));
             //Console.WriteLine(string.Format("Fill Speed: " + process.FillSpeed));
             Console.WriteLine("--------------------------");
             networkStream.Write(new byte[] { process.Get_State(), 0x00 }, 0, 2);
             Thread.Sleep(1000);
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.ToString());
     }
 }