private bool LocateConsolidationDevice() { if (ConsolidationDevice == null) { ConsolidationDevice = ManagerManager.FindPVOutputConsolidationDevice(SystemId); if (ConsolidationDevice == null) { GlobalSettings.LogMessage("LocateConsolidationDevice", "Cannot find ConsolidationDevice for: " + SystemId, LogEntryType.Information); return false; } } return true; }
private void PrepareConsumptionLoadList(DateTime runLimit) { try { if (ConsolidationDevice == null) { ConsolidationDevice = ManagerManager.FindPVOutputConsolidationDevice(SystemId); if (ConsolidationDevice == null) { GlobalSettings.LogMessage("PrepareConsumptionLoadList", "Cannot find ConsolidationDevice for: " + SystemId, LogEntryType.Information); return; } } for (DateTime day = DateTime.Today; day >= PVDateLimit; day = day.AddDays(-1.0)) { DeviceDetailPeriod_EnergyConsolidation consumptionPeriod = (DeviceDetailPeriod_EnergyConsolidation)ConsolidationDevice.FindOrCreateFeaturePeriod(FeatureType.ConsumptionAC, 0, day); long energy = 0; long power = 0; foreach (EnergyReading reading in consumptionPeriod.GetReadings()) { // exclude readings beyond limit to prevent exposure of values in incomplete intervals if (reading.ReadingEnd > runLimit) break; int timeVal = (int)(reading.ReadingEnd.AddMinutes(-PVInterval).TimeOfDay.TotalSeconds); if (Settings.PowerMinMax) // do not have instantaneous power - do have min and max power // alternale between min and max in each interval if (((int)((int)(timeVal / Settings.DataIntervalSeconds) % 2)) == 0) power = reading.MaxPower.HasValue ? reading.MaxPower.Value : reading.Power.HasValue ? reading.Power.Value : reading.AveragePower; else power = reading.MinPower.HasValue ? reading.MinPower.Value : reading.Power.HasValue ? reading.Power.Value : reading.AveragePower; else power = reading.Power.HasValue ? reading.Power.Value : reading.AveragePower; energy += (long)(reading.TotalReadingDelta * 1000.0); RecordConsumption(reading.ReadingEnd, energy, power, reading.Temperature); } } if (LastDeleteOld == null || LastDeleteOld.Value < DateTime.Now.AddDays(-1.0)) { DeleteOldLogEntries(); LastDeleteOld = DateTime.Now; } } catch (Exception e) { throw new Exception("PrepareConsumptionLoadList - Error : " + e.Message, e); } }
public PVOutputManager(GenThreadManager genThreadManager, IOutputManagerManager managerManager, PvOutputSiteSettings settings) : base(genThreadManager, GlobalSettings.SystemServices) { ManagerManager = managerManager; Settings = settings; SystemId = settings.SystemId; APIKey = settings.APIKey; if (settings.LiveDays == null) PVLiveDays = PVLiveDaysDefault; else PVLiveDays = settings.LiveDays.Value; if (Settings.HaveSubscription) PVOutputHourLimit = 100; else PVOutputHourLimit = 60; RequestCount = 0; RequestHour = (int)DateTime.Now.TimeOfDay.TotalHours; PVOutputLimitReported = false; PVOutputCurrentDayLimitReported = false; InitialOutputCycle = true; OutputReadyEvent = new ManualResetEvent(true); LastYieldReady = DateTime.MinValue; LastConsumeReady = DateTime.MinValue; PVInterval = settings.DataInterval == "" ? 10 : Convert.ToInt32(settings.DataInterval); // Common lock object for all OutputManagers if (OutputProcessLock == null) OutputProcessLock = new Object(); ConsolidationDevice = ManagerManager.FindPVOutputConsolidationDevice(SystemId); }