예제 #1
0
        public static void threadFun(AdamCNT AdamComponent)
        {
            Switch_off.State      = "OFF";
            Switch_on.State       = "ON";
            Switch_on.Time_start  = DateTime.Now.ToString("H:mm:ss:fff");
            Switch_off.Time_start = DateTime.Now.ToString("H:mm:ss:fff");

            while (true)
            {
                if (AdamComponent.switchRead() == 1 && trenutna == true)
                {
                    Console.WriteLine("Usao na promenu ON");
                    Switch_on.Time_start = DateTime.Now.ToString("H:mm:ss:fff");
                    Switch_off.Time_end  = DateTime.Now.ToString("H:mm:ss:fff");
                    FileIO.outputSwitch(switchOutList, Switch_off);
                    trenutna = false;
                }
                else if (AdamComponent.switchRead() == 0 && trenutna == false)
                {
                    Switch_on.Time_end    = DateTime.Now.ToString("H:mm:ss:fff");
                    Switch_off.Time_start = DateTime.Now.ToString("H:mm:ss:fff");
                    FileIO.outputSwitch(switchOutList, Switch_on);
                    Console.WriteLine("Usao na promenu OFF");
                    trenutna = true;
                }
                AdamComponent.counterRead();
            }
        }
예제 #2
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);
            }
        }
예제 #3
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);
         }
 }
예제 #4
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);
            }
        }