Update SchneiderMeterDriver.cs for test purpose
This commit is contained in:
parent
c19db1519d
commit
ad02629ed9
|
@ -3,6 +3,7 @@ using InnovEnergy.Lib.Devices.IEM3kGridMeter;
|
|||
using InnovEnergy.Lib.Protocols.DBus;
|
||||
using InnovEnergy.Lib.Protocols.Modbus.Clients;
|
||||
using InnovEnergy.Lib.Utils;
|
||||
using InnovEnergy.Lib.Utils.Reflection;
|
||||
using InnovEnergy.Lib.Victron.VeDBus;
|
||||
|
||||
namespace InnovEnergy.App.SchneiderDriver;
|
||||
|
@ -20,32 +21,52 @@ public static class SchneiderMeterDriver
|
|||
// var auth = AuthenticationMethod.ExternalAsRoot();
|
||||
// dbusAddress = new Bus(ep, auth);
|
||||
|
||||
var schnieder = new Iem3KGridMeterDevice(hostName, port, Config.ModbusNodeId);
|
||||
|
||||
|
||||
var schniederStatus = Observable
|
||||
var schneider = new Iem3KGridMeterDevice(hostName, port, Config.ModbusNodeId);
|
||||
|
||||
|
||||
var schneiderStatus = Observable
|
||||
.Interval(Config.UpdatePeriod)
|
||||
.Select(_ => schnieder.Read())
|
||||
.Select(_ => schneider.Read())
|
||||
.Publish();
|
||||
|
||||
var poller = schniederStatus.Connect();
|
||||
var x = schneider.Read();
|
||||
|
||||
x?.ActivePowerL1.WriteLine();
|
||||
x?.ActivePowerL2.WriteLine();
|
||||
x?.ActivePowerL3.WriteLine();
|
||||
|
||||
|
||||
var poller = schneiderStatus.Connect();
|
||||
|
||||
var properties = Config.DefaultProperties;
|
||||
|
||||
foreach (var p in properties)
|
||||
{
|
||||
p.WriteLine(" Signal");
|
||||
}
|
||||
|
||||
// Step 1: Access Config.Signals
|
||||
var signalsCollection = Config.Signals;
|
||||
|
||||
foreach (var s in signalsCollection)
|
||||
{
|
||||
s.WriteLine(" Signal");
|
||||
}
|
||||
|
||||
var signals = Config
|
||||
.Signals
|
||||
.Select(signal => schniederStatus.Select(signal.ToVeProperty))
|
||||
.Select(signal => schneiderStatus.Select(signal.ToVeProperty))
|
||||
.Merge()
|
||||
.Do(p => properties.Set(p));
|
||||
|
||||
// TODO: remove when possible
|
||||
// Apparently some VE services need to be periodically reminded that
|
||||
// this service is /Connected
|
||||
schniederStatus.Subscribe(_ => properties.Set("/Connected", 1));
|
||||
schneiderStatus.Subscribe(_ => properties.Set("/Connected", 1));
|
||||
|
||||
// Wait until status is read once to make sure all
|
||||
// properties are set when we go onto the bus.
|
||||
var dbus = schniederStatus
|
||||
var dbus = schneiderStatus
|
||||
.Skip(1)
|
||||
.Take(1)
|
||||
.SelectMany(_ => PublishPropertiesOnDBus(properties, dbusAddress));
|
||||
|
|
Loading…
Reference in New Issue