/// <summary></summary> public override async Task StartAsync(CancellationToken cancellationToken) { // If the user profile doesn't exist, stop if (!(WinOS.UserProfilePath(AppSettings.Value.UserProfile) is string profile_path)) { throw new Exception($"UserProfile '{AppSettings.Value.UserProfile}' does not have a home directory"); } // Output directory not found? stop OutputDirectory = Path.Combine(profile_path, "Documents", "Rylogic", "SolarHotWater"); if (!Path_.PathExists(OutputDirectory)) { throw new Exception($"Output directory path '{OutputDirectory}' does not exist"); } await base.StartAsync(cancellationToken); }
// Notes: // - Device updates come from within the EweLinkAPI. The websocket receives a message // for a device. It then calls 'Update' on the device, which the Consumer observes. public Model() { ConsumersList = new ConsumerList(); Settings = new SettingsData(SettingsData.Filepath); Shutdown = new CancellationTokenSource(); History = new History(); Fronius = new FroniusAPI(Settings.SolarInverterIP, Shutdown.Token); Ewe = new EweLinkAPI(Shutdown.Token); Solar = new SolarData(); Sched = new Schedule(); Sched.Add(new Schedule.Range("Monitor Active", Schedule.ERepeat.Daily, new DateTimeOffset(1, 1, 1, 8, 0, 0, TimeSpan.Zero), new DateTimeOffset(1, 1, 1, 18, 0, 0, TimeSpan.Zero))); Log.Write(ELogLevel.Info, "Model initialised"); m_settings.NotifyAllSettingsChanged(); // Prevent system sleep WinOS.SystemSleep(keep_awake: true); }