Beispiel #1
0
 public static void outputSwitch(List <SwitchOutput> objListOutSwitch, SwitchOutput Switch)
 {
     objListOutSwitch.Add(new SwitchOutput("Prekidac 1", Switch.Time_start, Switch.Time_end, Switch.State));
     using (var writer = new StreamWriter("SwitchOutput.csv"))
         using (var csv = new CsvWriter(writer))
         {
             csv.WriteRecords(objListOutSwitch);
         }
 }
Beispiel #2
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);
            }
        }