170 lines
5.5 KiB
C#
170 lines
5.5 KiB
C#
|
// using System.Collections.Immutable;
|
||
|
// using InnovEnergy.WireFormat.VictronV1;
|
||
|
// using VeDBus;
|
||
|
//
|
||
|
// namespace InnovEnergy.VenusLogger.Parsers;
|
||
|
//
|
||
|
// using Props = ImmutableDictionary<String, VeProperty>;
|
||
|
//
|
||
|
// public static class System
|
||
|
// {
|
||
|
// private static AcDeviceType GetAcConnectionType(this Props props) => props.TryGetProperty<AcDeviceType>("/Ac/ActiveIn/Source");
|
||
|
//
|
||
|
// public static VictronTopologyV1 GetSystemTopology(this IReadOnlyList<ServiceProperties> systemSv)
|
||
|
// {
|
||
|
// return systemSv.Any()
|
||
|
// ? systemSv[0].Properties.GetSystemTopology()
|
||
|
// : new VictronTopologyV1();
|
||
|
// }
|
||
|
//
|
||
|
// public static VictronTopologyV1 GetSystemTopology(this Props props)
|
||
|
// {
|
||
|
// var connectionType = props.GetAcConnectionType();
|
||
|
//
|
||
|
//
|
||
|
// var grid = props.GetAcInDevice(connectionType);
|
||
|
// var acInBus = props.GetAcInBus(connectionType);
|
||
|
// var acOutBus = props.GetAcOutBus();
|
||
|
// var dcBus = props.GetDcBus();
|
||
|
//
|
||
|
//
|
||
|
//
|
||
|
// return new VictronTopologyV1
|
||
|
// {
|
||
|
// Grid = { grid },
|
||
|
// AcIn = acInBus.NoneIfEmpty(),
|
||
|
// AcOut = acOutBus.NoneIfEmpty(),
|
||
|
// DcBus = dcBus.NoneIfEmpty(),
|
||
|
// Battery = battery,
|
||
|
// };
|
||
|
// }
|
||
|
//
|
||
|
// private static DcBus GetDcBus(this Props props)
|
||
|
// {
|
||
|
// var pv = props.GetPvCharger();
|
||
|
// var load = props.GetDcLoad();
|
||
|
//
|
||
|
// return new DcBus
|
||
|
// {
|
||
|
// Pv = { pv },
|
||
|
// Load = { load }
|
||
|
// };
|
||
|
// }
|
||
|
//
|
||
|
// private static AcBus GetAcOutBus(this Props props)
|
||
|
// {
|
||
|
// var pv = props.GetAcOutDevice(AcDeviceType.PvInverter);
|
||
|
// var load = props.GetAcOutDevice(AcDeviceType.AcLoad);
|
||
|
//
|
||
|
// return new AcBus
|
||
|
// {
|
||
|
// Pv = { pv },
|
||
|
// Load = { load },
|
||
|
// };
|
||
|
// }
|
||
|
//
|
||
|
// private static AcBus GetAcInBus(this Props props, AcDeviceType acProsumerType)
|
||
|
// {
|
||
|
// var pv = props.GetAcInDevice(AcDeviceType.PvInverter, acProsumerType);
|
||
|
// var load = props.GetAcInDevice(AcDeviceType.AcLoad, acProsumerType);
|
||
|
//
|
||
|
// return new AcBus
|
||
|
// {
|
||
|
// Pv = { pv },
|
||
|
// Load = { load },
|
||
|
// };
|
||
|
// }
|
||
|
//
|
||
|
//
|
||
|
// private static IEnumerable<AcDevice> GetAcInDevice(this Props props,
|
||
|
// AcDeviceType deviceType,
|
||
|
// AcDeviceType busType = AcDeviceType.Unknown)
|
||
|
// {
|
||
|
// var deviceName = GetDeviceName(deviceType);
|
||
|
//
|
||
|
// if (busType != AcDeviceType.Unknown)
|
||
|
// {
|
||
|
// deviceName += deviceType == AcDeviceType.AcLoad
|
||
|
// ? "OnInput"
|
||
|
// : "On" + GetDeviceName(busType);
|
||
|
// }
|
||
|
//
|
||
|
// var acPhases = props.GetPhases(deviceName).ToList();
|
||
|
//
|
||
|
// if (acPhases.Count > 0 && acPhases.Any(p => p.Power != 0))
|
||
|
// yield return new Device { Phases = { acPhases } };
|
||
|
// }
|
||
|
//
|
||
|
// private static Battery GetBattery(this Props props)
|
||
|
// {
|
||
|
// return new Battery
|
||
|
// {
|
||
|
// Power = props.GetBatteryProp("Power"),
|
||
|
// Current = props.GetBatteryProp("Current"),
|
||
|
// Voltage = props.GetBatteryProp("Voltage"),
|
||
|
// Soc = props.GetBatteryProp("Soc"),
|
||
|
// Temperature = props.GetBatteryProp("Temperature")
|
||
|
// };
|
||
|
// }
|
||
|
//
|
||
|
// private static Single GetBatteryProp(this Props props, String prop) => props.TryGetProperty<Single>("/Dc/Battery/" + prop);
|
||
|
//
|
||
|
//
|
||
|
// private static IEnumerable<Device> GetPvCharger(this Props props)
|
||
|
// {
|
||
|
// var power = props.TryGetProperty<Single>("/Dc/Pv/Power");
|
||
|
//
|
||
|
// if (power == 0)
|
||
|
// yield break;
|
||
|
//
|
||
|
// yield return new Device
|
||
|
// {
|
||
|
// ProducerType = ProducerType.Mppt,
|
||
|
// Phases = { new Phase { Power = power } }
|
||
|
// };
|
||
|
// }
|
||
|
//
|
||
|
// private static IEnumerable<DcDevice> GetDcLoad(this Props props)
|
||
|
// {
|
||
|
// var power = props.TryGetProperty<Single>("/Dc/System/Power");
|
||
|
//
|
||
|
// if (power != 0)
|
||
|
// yield return new DcDevice { Power = power };
|
||
|
// }
|
||
|
//
|
||
|
// private static IEnumerable<Device> GetAcOutDevice(this Props props, AcDeviceType deviceType)
|
||
|
// {
|
||
|
// var deviceName = GetDeviceName(deviceType) + "OnOutput";
|
||
|
// var acPhases = props.GetPhases(deviceName);
|
||
|
//
|
||
|
// if (acPhases.Count > 0 && acPhases.Any(p => p.Power != 0))
|
||
|
// yield return new AcDevice { Phases = { acPhases } };
|
||
|
// }
|
||
|
//
|
||
|
// private static String GetDeviceName(AcDeviceType deviceType) => deviceType switch
|
||
|
// {
|
||
|
// AcDeviceType.Grid => "Grid",
|
||
|
// AcDeviceType.Shore => "Grid",
|
||
|
// AcDeviceType.AcLoad => "Consumption",
|
||
|
// AcDeviceType.Generator => "Genset",
|
||
|
// AcDeviceType.PvInverter => "Pv",
|
||
|
// _ => "Unknown"
|
||
|
// };
|
||
|
//
|
||
|
//
|
||
|
// private static Int32 GetNbOfPhases(this Props props, String deviceName)
|
||
|
// {
|
||
|
// return props.TryGetProperty("/Ac/" + deviceName + "/NumberOfPhases", 0);
|
||
|
// }
|
||
|
//
|
||
|
// private static IEnumerable<Phase> GetPhases(this Props props, String path)
|
||
|
// {
|
||
|
// var nPhases = props.GetNbOfPhases(path);
|
||
|
//
|
||
|
// Phase GetPhase(Int32 p) => new Phase { Power = props.TryGetProperty($"/Ac/{path}/L{p}/Power", 0.0f) };
|
||
|
//
|
||
|
// return Enumerable
|
||
|
// .Range(1, nPhases)
|
||
|
// .Select(GetPhase);
|
||
|
// }
|
||
|
// }
|