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(); } }
private static void OnSignal(Object source, ElapsedEventArgs e) { AdamComponent.buttonRead(); AdamComponent.counterRead(); Console.WriteLine("Entered timer... "); objListOut.Add(new outputForm(AdamComponent.getCnt(), "OFF")); //napravi geter za cnt using (var writer = new StreamWriter("output2.csv")) using (var csv = new CsvWriter(writer)) { csv.WriteRecords(objListOut); } }