Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            Thread myThread = new Thread(() => ThreadFunctions.threadFun(AdamComponent));

            FileIO.inputFun();

            /*      Ucitavanje input fajla      */
            int time = FileIO.objListIn[0].Time;

            Constants.DEF_IP = FileIO.objListIn[0].Ip;

            AdamComponent = new AdamCNT();

            /*      Kreiranje socketa       */
            AdamComponent.createCounterSocket();
            AdamComponent.createSwitchSocket();

            AdamComponent.counterStart();

            myThread.Start();

            setTimer(time);
            Console.Write("Press ESC to exit...\n");

            ConsoleKeyInfo keyInfo = Console.ReadKey(true);

            if (keyInfo.Key == ConsoleKey.Escape)
            {
                SwitchOutput Switch_end = new SwitchOutput();
                if (AdamComponent.getSwitchState() == "ON")
                {
                    Switch_end.Time_start = ThreadFunctions.Switch_on.Time_start;
                }
                else
                {
                    Switch_end.Time_start = ThreadFunctions.Switch_off.Time_start;
                }
                Switch_end.State    = AdamComponent.getSwitchState();
                Switch_end.Time_end = DateTime.Now.ToString("H:mm:ss:fff");
                FileIO.outputSwitch(ThreadFunctions.switchOutList, Switch_end);
                myThread.Abort();
                AdamComponent.resetCounter();
                Environment.Exit(0);
            }
        }
Ejemplo n.º 2
0
 public static void outputFunTimer(List <outputForm> objListOut, AdamCNT AdamComponent)
 {
     objListOut.Add(new outputForm(AdamComponent.getCnt(), AdamComponent.getSwitchState()));
     using (var writer = new StreamWriter("TimerOutput.csv"))
         using (var csv = new CsvWriter(writer))
         {
             csv.WriteRecords(objListOut);
         }
 }
Ejemplo n.º 3
0
        private static void OnSignal(Object source, ElapsedEventArgs e)
        {
            Console.WriteLine("Entered timer... ");
            Console.WriteLine("######################");
            Console.WriteLine("Count: " + AdamComponent.getCnt());
            Console.WriteLine("State: " + AdamComponent.getSwitchState());
            Console.WriteLine("######################");

            FileIO.outputFunTimer(objListOut, AdamComponent);
        }