make use of "required" with "init" (.net 7)
This commit is contained in:
parent
10eebd3961
commit
7f97ab8e14
|
@ -7,9 +7,6 @@ namespace InnovEnergy.App.Backend;
|
||||||
|
|
||||||
public static class Program
|
public static class Program
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static void Main(String[] args)
|
public static void Main(String[] args)
|
||||||
{
|
{
|
||||||
//Db.CreateFakeRelations();
|
//Db.CreateFakeRelations();
|
||||||
|
|
|
@ -12,20 +12,20 @@ namespace InnovEnergy.App.SaliMax.Ess;
|
||||||
|
|
||||||
public record StatusRecord
|
public record StatusRecord
|
||||||
{
|
{
|
||||||
public AcDcDevicesRecord AcDc { get; init; } = null!;
|
public required AcDcDevicesRecord AcDc { get; init; }
|
||||||
public DcDcDevicesRecord DcDc { get; init; } = null!;
|
public required DcDcDevicesRecord DcDc { get; init; }
|
||||||
public Battery48TlRecords Battery { get; init; } = null!;
|
public required Battery48TlRecords Battery { get; init; }
|
||||||
public EmuMeterRegisters? GridMeter { get; init; }
|
public required EmuMeterRegisters? GridMeter { get; init; }
|
||||||
public EmuMeterRegisters? LoadOnAcIsland { get; init; }
|
public required EmuMeterRegisters? LoadOnAcIsland { get; init; }
|
||||||
public AcPowerDevice? LoadOnAcGrid { get; init; } = null!;
|
public required AcPowerDevice? LoadOnAcGrid { get; init; }
|
||||||
public AcPowerDevice? PvOnAcGrid { get; init; } = null!;
|
public required AcPowerDevice? PvOnAcGrid { get; init; }
|
||||||
public AcPowerDevice? PvOnAcIsland { get; init; } = null!;
|
public required AcPowerDevice? PvOnAcIsland { get; init; }
|
||||||
public AcPowerDevice? AcGridToAcIsland { get; init; } = null!;
|
public required AcPowerDevice? AcGridToAcIsland { get; init; }
|
||||||
public DcPowerDevice? LoadOnDc { get; init; } = null!;
|
public required DcPowerDevice? LoadOnDc { get; init; }
|
||||||
public RelaysRecord? Relays { get; init; }
|
public required RelaysRecord? Relays { get; init; }
|
||||||
public AmptStatus PvOnDc { get; init; } = null!;
|
public required AmptStatus PvOnDc { get; init; }
|
||||||
public Config Config { get; init; } = null!;
|
public required Config Config { get; init; }
|
||||||
public EssControl EssControl { get; set; } = null!;
|
public required EssControl EssControl { get; init; }
|
||||||
public StateMachine StateMachine { get; } = new StateMachine();
|
public required StateMachine StateMachine { get; init; }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,12 +9,12 @@ namespace InnovEnergy.App.SaliMax;
|
||||||
|
|
||||||
public record S3Config
|
public record S3Config
|
||||||
{
|
{
|
||||||
public String Bucket { get; init; } = "";
|
public required String Bucket { get; init; }
|
||||||
public String Region { get; init; } = "";
|
public required String Region { get; init; }
|
||||||
public String Provider { get; init; } = "";
|
public required String Provider { get; init; }
|
||||||
public String Key { get; init; } = "";
|
public required String Key { get; init; }
|
||||||
public String Secret { get; init; } = "";
|
public required String Secret { get; init; }
|
||||||
public String ContentType { get; init; } = "";
|
public required String ContentType { get; init; }
|
||||||
|
|
||||||
public String Host => $"{Bucket}.{Region}.{Provider}";
|
public String Host => $"{Bucket}.{Region}.{Provider}";
|
||||||
public String Url => $"https://{Host}";
|
public String Url => $"https://{Host}";
|
||||||
|
|
|
@ -4,8 +4,8 @@ namespace InnovEnergy.Lib.Channels.Stages;
|
||||||
|
|
||||||
public class Channel<Tx, Rx>
|
public class Channel<Tx, Rx>
|
||||||
{
|
{
|
||||||
public AsyncAction<Tx> Write { get; init; } = _ => throw new NotImplementedException(nameof(Write));
|
public required AsyncAction<Tx> Write { get; init; }
|
||||||
public Async<Rx> Read { get; init; } = () => throw new NotImplementedException(nameof(Read));
|
public required Async<Rx> Read { get; init; }
|
||||||
|
|
||||||
public Channel<T, R> Map<T, R>(Stage<T, Tx, Rx, R> stage)
|
public Channel<T, R> Map<T, R>(Stage<T, Tx, Rx, R> stage)
|
||||||
{
|
{
|
||||||
|
|
|
@ -4,9 +4,9 @@ namespace InnovEnergy.Lib.Channels.Stages;
|
||||||
|
|
||||||
public class ConnectedChannel<Tx, Rx> : Channel<Tx,Rx>, IAsyncDisposable
|
public class ConnectedChannel<Tx, Rx> : Channel<Tx,Rx>, IAsyncDisposable
|
||||||
{
|
{
|
||||||
public Func<Boolean> IsOpen { get; init; } = () => throw new NotImplementedException(nameof(IsOpen));
|
public required Func<Boolean> IsOpen { get; init; }
|
||||||
public AsyncAction Open { get; init; } = () => throw new NotImplementedException(nameof(Open));
|
public required AsyncAction Open { get; init; }
|
||||||
public AsyncAction Close { get; init; } = () => throw new NotImplementedException(nameof(Close));
|
public required AsyncAction Close { get; init; }
|
||||||
|
|
||||||
public async ValueTask DisposeAsync() => await Close();
|
public async ValueTask DisposeAsync() => await Close();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +1,18 @@
|
||||||
namespace InnovEnergy.Lib.Devices.AMPT;
|
namespace InnovEnergy.Lib.Devices.AMPT;
|
||||||
|
|
||||||
|
|
||||||
|
// not used ATM
|
||||||
public class AmptCommunicationUnitStatus
|
public class AmptCommunicationUnitStatus
|
||||||
{
|
{
|
||||||
public UInt32 Sid { get; init; } // A well-known value 0x53756e53, uniquely identifies this as a SunSpec Modbus Map
|
public required UInt32 Sid { get; init; } // A well-known value 0x53756e53, uniquely identifies this as a SunSpec Modbus Map
|
||||||
public UInt16 IdSunSpec { get; init; } // A well-known value 1, uniquely identifies this as a SunSpec Common Model
|
public required UInt16 IdSunSpec { get; init; } // A well-known value 1, uniquely identifies this as a SunSpec Common Model
|
||||||
|
|
||||||
public String Manufacturer { get; init; } = "undefined"; // A well-known value registered with SunSpec for compliance: "Ampt"
|
public required String Manufacturer { get; init; } // A well-known value registered with SunSpec for compliance: "Ampt"
|
||||||
public String Model { get; init; } = "undefined"; // Manufacturer specific value "Communication Unit"
|
public required String Model { get; init; } // Manufacturer specific value "Communication Unit"
|
||||||
public String Version { get; init; } = "undefined"; // Software Version
|
public required String Version { get; init; } // Software Version
|
||||||
public String SerialNumber { get; init; } = "undefined"; // Manufacturer specific value
|
public required String SerialNumber { get; init; } // Manufacturer specific value
|
||||||
public Int16 DeviceAddress { get; init; } // Modbus Device ID
|
public required Int16 DeviceAddress { get; init; } // Modbus Device ID
|
||||||
public UInt16 IdVendor { get; init; } // Ampt SunSpec Vendor Code 64050
|
public required UInt16 IdVendor { get; init; } // Ampt SunSpec Vendor Code 64050
|
||||||
|
|
||||||
public IReadOnlyList<AmptStatus> Devices { get; init; } = Array.Empty<AmptStatus>();
|
public required IReadOnlyList<AmptStatus> Devices { get; init; }
|
||||||
}
|
}
|
|
@ -21,13 +21,13 @@ public interface IMatchRule
|
||||||
|
|
||||||
public record MatchRule : IMatchRule
|
public record MatchRule : IMatchRule
|
||||||
{
|
{
|
||||||
public MessageType? Type { get; init; } = default;
|
public MessageType? Type { get; init; }
|
||||||
public String? Interface { get; init; } = default;
|
public String? Interface { get; init; }
|
||||||
public String? Member { get; init; } = default;
|
public String? Member { get; init; }
|
||||||
public ObjectPath? Path { get; init; } = default;
|
public ObjectPath? Path { get; init; }
|
||||||
public ObjectPath? PathNamespace { get; init; } = default;
|
public ObjectPath? PathNamespace { get; init; }
|
||||||
public String? Sender { get; init; } = default;
|
public String? Sender { get; init; }
|
||||||
public String? Destination { get; init; } = default;
|
public String? Destination { get; init; }
|
||||||
public Boolean Eavesdrop { get; init; } = false;
|
public Boolean Eavesdrop { get; init; } = false;
|
||||||
|
|
||||||
public override String ToString() => this.Rule();
|
public override String ToString() => this.Rule();
|
||||||
|
|
|
@ -5,10 +5,10 @@ public sealed class Ac1Bus
|
||||||
private Ac1Bus()
|
private Ac1Bus()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
public Voltage Voltage { get; private init; } = null!;
|
public required Voltage Voltage { get; init; }
|
||||||
public Current Current { get; private init; } = null!;
|
public required Current Current { get; init; }
|
||||||
public AcPower Power { get; private init; } = null!;
|
public required AcPower Power { get; init; }
|
||||||
public Frequency Frequency { get; private init; } = null!;
|
public required Frequency Frequency { get; init; }
|
||||||
|
|
||||||
public static Ac1Bus FromVoltageCurrentFrequencyPhi(Double voltageRms,
|
public static Ac1Bus FromVoltageCurrentFrequencyPhi(Double voltageRms,
|
||||||
Double currentRms,
|
Double currentRms,
|
||||||
|
|
|
@ -6,11 +6,11 @@ public sealed class Ac3Bus
|
||||||
{
|
{
|
||||||
private Ac3Bus() {}
|
private Ac3Bus() {}
|
||||||
|
|
||||||
public AcPhase L1 { get; private init; } = null!;
|
public required AcPhase L1 { get; init; }
|
||||||
public AcPhase L2 { get; private init; } = null!;
|
public required AcPhase L2 { get; init; }
|
||||||
public AcPhase L3 { get; private init; } = null!;
|
public required AcPhase L3 { get; init; }
|
||||||
public AcPower Power { get; private init; } = null!;
|
public required AcPower Power { get; init; }
|
||||||
public Frequency Frequency { get; private init; } = null!;
|
public required Frequency Frequency { get; init; }
|
||||||
|
|
||||||
public static Ac3Bus FromPhasesAndFrequency(AcPhase l1,
|
public static Ac3Bus FromPhasesAndFrequency(AcPhase l1,
|
||||||
AcPhase l2,
|
AcPhase l2,
|
||||||
|
|
|
@ -7,9 +7,9 @@ public sealed class AcPhase
|
||||||
{
|
{
|
||||||
private AcPhase(){}
|
private AcPhase(){}
|
||||||
|
|
||||||
public Voltage Voltage { get; private init; } = null!;
|
public required Voltage Voltage { get; init; }
|
||||||
public Current Current { get; private init; } = null!;
|
public required Current Current { get; init; }
|
||||||
public AcPower Power { get; private init; } = null!;
|
public required AcPower Power { get; init; }
|
||||||
|
|
||||||
public static AcPhase FromVoltageCurrentPhi(Voltage voltageRms,
|
public static AcPhase FromVoltageCurrentPhi(Voltage voltageRms,
|
||||||
Current currentRms,
|
Current currentRms,
|
||||||
|
|
|
@ -8,11 +8,11 @@ public sealed class AcPower
|
||||||
{
|
{
|
||||||
private AcPower(){}
|
private AcPower(){}
|
||||||
|
|
||||||
public ApparentPower Apparent { get; private init; } = null!;
|
public required ApparentPower Apparent { get; init; }
|
||||||
public ActivePower Active { get; private init; } = null!;
|
public required ActivePower Active { get; init; }
|
||||||
public ReactivePower Reactive { get; private init; } = null!;
|
public required ReactivePower Reactive { get; init; }
|
||||||
public Angle Phi { get; private init; } = null!;
|
public required Angle Phi { get; init; }
|
||||||
public Double CosPhi { get; private init; }
|
public required Double CosPhi { get; init; }
|
||||||
|
|
||||||
public static AcPower FromActiveReactiveApparent(ActivePower activePower, ReactivePower reactivePower, ApparentPower apparentPower)
|
public static AcPower FromActiveReactiveApparent(ActivePower activePower, ReactivePower reactivePower, ApparentPower apparentPower)
|
||||||
{
|
{
|
||||||
|
|
|
@ -6,9 +6,9 @@ public sealed class DcBus
|
||||||
{
|
{
|
||||||
private DcBus() {}
|
private DcBus() {}
|
||||||
|
|
||||||
public Voltage Voltage { get; private init; } = null!;
|
public required Voltage Voltage { get; init; }
|
||||||
public Current Current { get; private init; } = null!;
|
public required Current Current { get; init; }
|
||||||
public ActivePower Power { get; private init; } = null!;
|
public required ActivePower Power { get; init; }
|
||||||
|
|
||||||
public static DcBus FromVoltageCurrent(Voltage voltage, Current current) => new()
|
public static DcBus FromVoltageCurrent(Voltage voltage, Current current) => new()
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,7 +2,7 @@ namespace InnovEnergy.Lib.Units;
|
||||||
|
|
||||||
public sealed class Energy : Unit
|
public sealed class Energy : Unit
|
||||||
{
|
{
|
||||||
public override String Symbol => "kWh";
|
public override String Symbol => "Wh";
|
||||||
|
|
||||||
public Energy(Double value) : base(value)
|
public Energy(Double value) : base(value)
|
||||||
{
|
{
|
||||||
|
|
|
@ -12,7 +12,6 @@ public sealed class ActivePower : AcPower
|
||||||
public static implicit operator ActivePower(Double d) => new ActivePower(d);
|
public static implicit operator ActivePower(Double d) => new ActivePower(d);
|
||||||
public static implicit operator Double(ActivePower d) => d.Value;
|
public static implicit operator Double(ActivePower d) => d.Value;
|
||||||
|
|
||||||
|
|
||||||
public static ActivePower operator -(ActivePower d) => -d.Value;
|
public static ActivePower operator -(ActivePower d) => -d.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,8 @@ public static class Units
|
||||||
public static Frequency Hz (this Double value) => value;
|
public static Frequency Hz (this Double value) => value;
|
||||||
public static Angle Rad (this Double value) => value;
|
public static Angle Rad (this Double value) => value;
|
||||||
public static Temperature Celsius(this Double value) => value;
|
public static Temperature Celsius(this Double value) => value;
|
||||||
public static Energy KWh (this Double value) => value;
|
public static Energy KWh (this Double value) => value * 1000;
|
||||||
|
public static Energy Wh (this Double value) => value;
|
||||||
|
|
||||||
public static String ToCsv(this Object thing)
|
public static String ToCsv(this Object thing)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue