Esempio n. 1
0
        static void Main(string[] args)
        {
            List <config> objListIn = new List <config>();

            using (var reader = new StreamReader("input.txt"))
                using (var csv = new CsvReader(reader))
                {
                    var records = csv.GetRecords <config>();
                    objListIn = records.ToList();
                }
            int time = objListIn[0].Id;

            AdamComponent = new AdamCNT();


            AdamComponent.createCounterSocket();
            //AdamComponent.createSwitchSocket();
            AdamComponent.createButtonSocket();
            AdamComponent.counterStart();


            setTimer(time);
            Console.Write("Press ESC to exit...\n");
            ConsoleKeyInfo keyInfo = Console.ReadKey(true);

            if (keyInfo.Key == ConsoleKey.Escape)
            {
                AdamComponent.resetCounter();
                Environment.Exit(0);
            }
        }
Esempio n. 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);
            }
        }