static void Main(string[] args) { Monitor m = new Monitor(); Session k = m.getSession("KD34AF24DS"); Console.WriteLine(k.sessionId); Console.WriteLine(k.temperature); Console.WriteLine(k.boilerState); Console.WriteLine(k.airConditionerState); //http://193.6.19.58:8182/smarthome/%7bhomeId%7d Driver d = new Driver(); Loader debug_loader = new Loader(); Subscribers debug_subscribers = debug_loader.loadSubscribers(); Console.WriteLine(d.sendCommand(debug_subscribers.subscribers[0], true, true)); //DEBUG //Console.WriteLine(debug_loader.ToString()); Controller c = new Controller(); Console.ReadKey(); }
private static Subscribers getSubsribers() { ILoader loader = new Loader(); Subscribers subs = loader.loadSubscribers(); return(subs); }
public Controller() { this.subscribers = this.loader.loadSubscribers(); refresher.Interval = 300000; //refresher.Interval = 5000; refresher.Elapsed += new ElapsedEventHandler(monitorReqest); monitorReqest(); refresher.Start(); }
private void loadFromJson() { try { string jsonString = File.ReadAllText(file_name); this.loaded_subscribers = JsonSerializer.Deserialize <Subscribers>(jsonString); } catch (Exception e) { Console.WriteLine("Something went wrong: [{0}]", e.Message); } }
private static async Task MainTask() { Subscribers subs = getSubsribers(); IMonitor mon = new Monitor(); IDriver driver = new Driver(); while (true) { foreach (var subscriber in subs.subscribers) { double desiredTemperature = 0; Session session = await mon.getSession(subscriber.homeId); showSubscriberAndSessionDetails(subscriber, session, ref desiredTemperature); await checkIfActionNeededAsync(session, desiredTemperature, subscriber, driver); } Console.WriteLine("Press Ctrl + C to exit"); Thread.Sleep(300000); } }