private Counter CreateCounter(CounterSpec counterSpec, Qbox qbox) { // NOTE: Using CounterSensorMappingsSmartMeter is not correct for S0 (generation), // since the Eltakos have different formulas. Keep it simple for now. return(new Counter { CounterId = counterSpec.CounterId, Secondary = counterSpec.CounterType == CounterType.Secondary, GroupId = _qboxType == QboxType.Mono ? CounterSource.Host : CounterSource.Client0, CounterSensorMappings = new List <CounterSensorMapping> { CounterSensorMappingsSmartMeter }, CounterDeviceMappings = new List <CounterDeviceMapping> { new CounterDeviceMapping { Device = new Device { EnergyType = counterSpec.DeviceEnergyType }, PeriodeBegin = new DateTime(2012, 1, 1), PeriodeEind = new DateTime(9999, 1, 1) } }, Qbox = qbox }); }
/// <summary> /// Create the Qbox object from the configured properties. /// </summary> public Mini Build() { VerifyConfiguration(); Qbox qbox = CreateQbox(_qboxSerial); Mini mini = CreateMini(_qboxSerial); foreach (CounterSpec counterSpec in _counters) { mini.Counters.Add(CreateCounter(counterSpec, qbox)); } return(mini); }
private static Mini CreateMini(string qboxSerial) { // SAM: previously the Qbox metadata was read from Redis. For now we take a huge shortcut and // only support Qbox Duo with smart meter EG with S0. // This code is tied to a similar construct in Qserver (QboxDataDumpContextFactory.Mini). var qbox = new Qbox { SerialNumber = qboxSerial, Precision = Precision.mWh, DataStore = new DataStore { Path = QboxNext.Core.Config.DataStorePath } }; var mini = new Mini { Counters = new List <Counter>() { new Counter { CounterId = 181, GroupId = CounterSource.Client0, CounterDeviceMappings = new List <CounterDeviceMapping> { new CounterDeviceMapping { Device = new Device { EnergyType = DeviceEnergyType.Consumption }, PeriodeBegin = new DateTime(2012, 1, 1), PeriodeEind = new DateTime(9999, 1, 1) } }, Qbox = qbox }, new Counter { CounterId = 182, GroupId = CounterSource.Client0, CounterDeviceMappings = new List <CounterDeviceMapping> { new CounterDeviceMapping { Device = new Device { EnergyType = DeviceEnergyType.Consumption }, PeriodeBegin = new DateTime(2012, 1, 1), PeriodeEind = new DateTime(9999, 1, 1) } }, Qbox = qbox }, new Counter { CounterId = 281, GroupId = CounterSource.Client0, CounterDeviceMappings = new List <CounterDeviceMapping> { new CounterDeviceMapping { Device = new Device { EnergyType = DeviceEnergyType.Generation }, PeriodeBegin = new DateTime(2012, 1, 1), PeriodeEind = new DateTime(9999, 1, 1) } }, Qbox = qbox }, new Counter { CounterId = 282, GroupId = CounterSource.Client0, CounterDeviceMappings = new List <CounterDeviceMapping> { new CounterDeviceMapping { Device = new Device { EnergyType = DeviceEnergyType.Generation }, PeriodeBegin = new DateTime(2012, 1, 1), PeriodeEind = new DateTime(9999, 1, 1) } }, Qbox = qbox }, new Counter { CounterId = 2421, GroupId = CounterSource.Client0, CounterDeviceMappings = new List <CounterDeviceMapping> { new CounterDeviceMapping { Device = new Device { EnergyType = DeviceEnergyType.Gas }, PeriodeBegin = new DateTime(2012, 1, 1), PeriodeEind = new DateTime(9999, 1, 1) } }, Qbox = qbox }, new Counter { CounterId = 1, GroupId = CounterSource.Client0, Secondary = true, CounterDeviceMappings = new List <CounterDeviceMapping> { new CounterDeviceMapping { Device = new Device { EnergyType = DeviceEnergyType.Generation }, PeriodeBegin = new DateTime(2012, 1, 1), PeriodeEind = new DateTime(9999, 1, 1) } }, Qbox = qbox } } }; foreach (var counter in mini.Counters) { counter.ComposeStorageid(); } return(mini); }