From 910ad768db632a49d80e201ff5d020467d72e0d1 Mon Sep 17 00:00:00 2001 From: atef Date: Tue, 31 Dec 2024 16:22:27 +0100 Subject: [PATCH] Add IRelay interface to be inherited by combined class and Amax class --- .../src/SaliMaxRelays/IRelaysRecord.cs | 78 ++++++++++ .../src/SaliMaxRelays/RelaysDeviceADAM6360.cs | 40 ++++++ .../src/SaliMaxRelays/RelaysDeviceAdam6060.cs | 38 +++++ .../{RelaysDevice.cs => RelaysDeviceAmax.cs} | 37 +---- .../SaliMax/src/SaliMaxRelays/RelaysRecord.cs | 100 ------------- .../src/SaliMaxRelays/RelaysRecordAdam6060.cs | 24 ++++ .../SaliMaxRelays/RelaysRecordAdam6360D.cs | 81 +++++++++++ .../src/SaliMaxRelays/RelaysRecordAmax.cs | 134 ++++++++++++++++++ 8 files changed, 396 insertions(+), 136 deletions(-) create mode 100644 csharp/App/SaliMax/src/SaliMaxRelays/IRelaysRecord.cs create mode 100644 csharp/App/SaliMax/src/SaliMaxRelays/RelaysDeviceADAM6360.cs create mode 100644 csharp/App/SaliMax/src/SaliMaxRelays/RelaysDeviceAdam6060.cs rename csharp/App/SaliMax/src/SaliMaxRelays/{RelaysDevice.cs => RelaysDeviceAmax.cs} (50%) delete mode 100644 csharp/App/SaliMax/src/SaliMaxRelays/RelaysRecord.cs create mode 100644 csharp/App/SaliMax/src/SaliMaxRelays/RelaysRecordAdam6060.cs create mode 100644 csharp/App/SaliMax/src/SaliMaxRelays/RelaysRecordAdam6360D.cs create mode 100644 csharp/App/SaliMax/src/SaliMaxRelays/RelaysRecordAmax.cs diff --git a/csharp/App/SaliMax/src/SaliMaxRelays/IRelaysRecord.cs b/csharp/App/SaliMax/src/SaliMaxRelays/IRelaysRecord.cs new file mode 100644 index 000000000..df89c283e --- /dev/null +++ b/csharp/App/SaliMax/src/SaliMaxRelays/IRelaysRecord.cs @@ -0,0 +1,78 @@ +namespace InnovEnergy.App.SaliMax.SaliMaxRelays; + + +public interface IRelaysRecord +{ + Boolean K1GridBusIsConnectedToGrid { get; } + Boolean K2IslandBusIsConnectedToGridBus { get; } + IEnumerable K3InverterIsConnectedToIslandBus { get; } + Boolean FiWarning { get; } + Boolean FiError { get; } + Boolean K2ConnectIslandBusToGridBus { get; set; } + + // Boolean Inverter1WagoRelay { get; set; } // to add in the future + // Boolean Inverter2WagoRelay { get; set; } // to add in the future + // Boolean Inverter3WagoRelay { get; set; } // to add in the future + // Boolean Inverter4WagoRelay { get; set; } // to add in the future + + Boolean Inverter1WagoStatus { get; } + Boolean Inverter2WagoStatus { get; } + Boolean Inverter3WagoStatus { get; } + Boolean Inverter4WagoStatus { get; } + + Boolean Dc1WagoStatus { get; } // to test + Boolean Dc2WagoStatus { get; } // to test + Boolean Dc3WagoStatus { get; } // to test + Boolean Dc4WagoStatus { get; } // to test + + Boolean DcSystemControlWagoStatus { get; } // to test + + Boolean LedGreen { get; set; } + Boolean LedRed { get; } + Boolean Harvester1Step { get; } + Boolean Harvester2Step { get; } + Boolean Harvester3Step { get; } + Boolean Harvester4Step { get; } + + Boolean Do0StartPulse { get; set; } + Boolean Do1StartPulse { get; set; } + Boolean Do2StartPulse { get; set; } + Boolean Do3StartPulse { get; set; } + Boolean Do4StartPulse { get; set; } + Boolean Do5StartPulse { get; set; } + + UInt16 DigitalOutput0Mode { get; set; } + UInt16 DigitalOutput1Mode { get; set; } + UInt16 DigitalOutput2Mode { get; set; } + UInt16 DigitalOutput3Mode { get; set; } + UInt16 DigitalOutput4Mode { get; set; } + UInt16 DigitalOutput5Mode { get; set; } + + UInt16 PulseOut0LowTime { get; set; } + UInt16 PulseOut1LowTime { get; set; } + UInt16 PulseOut2LowTime { get; set; } + UInt16 PulseOut3LowTime { get; set; } + UInt16 PulseOut4LowTime { get; set; } + UInt16 PulseOut5LowTime { get; set; } + + UInt16 PulseOut0HighTime { get; set; } + UInt16 PulseOut1HighTime { get; set; } + UInt16 PulseOut2HighTime { get; set; } + UInt16 PulseOut3HighTime { get; set; } + UInt16 PulseOut4HighTime { get; set; } + UInt16 PulseOut5HighTime { get; set; } + + void PerformSolidGreenLed(); + void PerformSlowFlashingGreenLed(); + void PerformFastFlashingGreenLed(); + + + void PerformSolidOrangeLed(); + void PerformSlowFlashingOrangeLed(); + void PerformFastFlashingOrangeLed(); + + void PerformSolidRedLed(); + void PerformSlowFlashingRedLed(); + void PerformFastFlashingRedLed(); + +} \ No newline at end of file diff --git a/csharp/App/SaliMax/src/SaliMaxRelays/RelaysDeviceADAM6360.cs b/csharp/App/SaliMax/src/SaliMaxRelays/RelaysDeviceADAM6360.cs new file mode 100644 index 000000000..221646d7c --- /dev/null +++ b/csharp/App/SaliMax/src/SaliMaxRelays/RelaysDeviceADAM6360.cs @@ -0,0 +1,40 @@ +using InnovEnergy.Lib.Devices.Adam6360D; +using InnovEnergy.Lib.Protocols.Modbus.Channels; + +namespace InnovEnergy.App.SaliMax.SaliMaxRelays; + +public class RelaysDeviceAdam6360 +{ + private Adam6360DDevice AdamDevice6360D { get; } + + public RelaysDeviceAdam6360(String hostname) => AdamDevice6360D = new Adam6360DDevice(hostname, 2); + public RelaysDeviceAdam6360(Channel channel) => AdamDevice6360D = new Adam6360DDevice(channel, 2); + + + public RelaysRecordAdam6360D? Read() + { + try + { + return AdamDevice6360D.Read(); + } + catch (Exception e) + { + $"Failed to read from {nameof(RelaysDeviceAdam6360)}\n{e}".LogError(); + return null; + } + } + + public void Write(RelaysRecordAdam6360D r) + { + try + { + AdamDevice6360D.Write(r); + } + catch (Exception e) + { + $"Failed to write to {nameof(RelaysDeviceAdam6360)}\n{e}".LogError(); + } + } +} + + diff --git a/csharp/App/SaliMax/src/SaliMaxRelays/RelaysDeviceAdam6060.cs b/csharp/App/SaliMax/src/SaliMaxRelays/RelaysDeviceAdam6060.cs new file mode 100644 index 000000000..2533cbd70 --- /dev/null +++ b/csharp/App/SaliMax/src/SaliMaxRelays/RelaysDeviceAdam6060.cs @@ -0,0 +1,38 @@ +using InnovEnergy.Lib.Devices.Adam6060; +using InnovEnergy.Lib.Protocols.Modbus.Channels; + +namespace InnovEnergy.App.SaliMax.SaliMaxRelays; + +public class RelaysDeviceAdam6060 +{ + private Adam6060Device AdamDevice6060 { get; } + + public RelaysDeviceAdam6060(String hostname) => AdamDevice6060 = new Adam6060Device(hostname, 2); + public RelaysDeviceAdam6060(Channel channel) => AdamDevice6060 = new Adam6060Device(channel, 2); + + + public RelaysRecordAdam6060? Read() + { + try + { + return AdamDevice6060.Read(); + } + catch (Exception e) + { + $"Failed to read from {nameof(RelaysDeviceAdam6060)}\n{e}".LogError(); + return null; + } + } + + public void Write(RelaysRecordAdam6060 r) + { + try + { + AdamDevice6060.Write(r); + } + catch (Exception e) + { + $"Failed to write to {nameof(RelaysDeviceAdam6060)}\n{e}".LogError(); + } + } +} \ No newline at end of file diff --git a/csharp/App/SaliMax/src/SaliMaxRelays/RelaysDevice.cs b/csharp/App/SaliMax/src/SaliMaxRelays/RelaysDeviceAmax.cs similarity index 50% rename from csharp/App/SaliMax/src/SaliMaxRelays/RelaysDevice.cs rename to csharp/App/SaliMax/src/SaliMaxRelays/RelaysDeviceAmax.cs index 1136a7c92..9ea91cb83 100644 --- a/csharp/App/SaliMax/src/SaliMaxRelays/RelaysDevice.cs +++ b/csharp/App/SaliMax/src/SaliMaxRelays/RelaysDeviceAmax.cs @@ -1,44 +1,9 @@ -using InnovEnergy.Lib.Devices.Adam6360D; using InnovEnergy.Lib.Devices.Amax5070; using InnovEnergy.Lib.Protocols.Modbus.Channels; + namespace InnovEnergy.App.SaliMax.SaliMaxRelays; -public class RelaysDevice -{ - private Adam6360DDevice AdamDevice { get; } - - public RelaysDevice(String hostname) => AdamDevice = new Adam6360DDevice(hostname, 2); - public RelaysDevice(Channel channel) => AdamDevice = new Adam6360DDevice(channel, 2); - - - public RelaysRecord? Read() - { - try - { - return AdamDevice.Read(); - } - catch (Exception e) - { - $"Failed to read from {nameof(RelaysDevice)}\n{e}".LogError(); - return null; - } - } - - public void Write(RelaysRecord r) - { - try - { - AdamDevice.Write(r); - } - catch (Exception e) - { - $"Failed to write to {nameof(RelaysDevice)}\n{e}".LogError(); - } - } -} - - public class RelaysDeviceAmax { private Amax5070Device AmaxDevice { get; } diff --git a/csharp/App/SaliMax/src/SaliMaxRelays/RelaysRecord.cs b/csharp/App/SaliMax/src/SaliMaxRelays/RelaysRecord.cs deleted file mode 100644 index 488df207c..000000000 --- a/csharp/App/SaliMax/src/SaliMaxRelays/RelaysRecord.cs +++ /dev/null @@ -1,100 +0,0 @@ -using InnovEnergy.Lib.Devices.Adam6360D; -using InnovEnergy.Lib.Devices.Amax5070; - -namespace InnovEnergy.App.SaliMax.SaliMaxRelays; - -public interface IRelaysRecord -{ - Boolean K1GridBusIsConnectedToGrid { get; } - Boolean K2IslandBusIsConnectedToGridBus { get; } - IEnumerable K3InverterIsConnectedToIslandBus { get; } - Boolean FiWarning { get; } - Boolean FiError { get; } - Boolean K2ConnectIslandBusToGridBus { get; set; } - Boolean Wago1Status { get; } //need to assign names to the Wago 1,2 ... - Boolean Wago2Status { get; } //need to assign names to the Wago 1,2 ... - Boolean Wago3Status { get; } //need to assign names to the Wago 1,2 ... - Boolean Wago4Status { get; } //need to assign names to the Wago 1,2 ... - -} - -public class RelaysRecord : IRelaysRecord -{ - private readonly Adam6360DRegisters _Regs; - - private RelaysRecord(Adam6360DRegisters regs) => _Regs = regs; - - public Boolean K1GridBusIsConnectedToGrid => _Regs.DigitalInput6; - public Boolean K2IslandBusIsConnectedToGridBus => !_Regs.DigitalInput4; - - public Boolean Wago1Status => _Regs.DigitalInput8; - public Boolean Wago2Status => _Regs.DigitalInput9; - public Boolean Wago3Status => _Regs.DigitalInput10; - public Boolean Wago4Status => _Regs.DigitalInput11; - - public IEnumerable K3InverterIsConnectedToIslandBus - { - get - { - yield return K3Inverter1IsConnectedToIslandBus; - yield return K3Inverter2IsConnectedToIslandBus; - yield return K3Inverter3IsConnectedToIslandBus; - yield return K3Inverter4IsConnectedToIslandBus; - } - } - - private Boolean K3Inverter1IsConnectedToIslandBus => !_Regs.DigitalInput0; // change it to private should be ok - private Boolean K3Inverter2IsConnectedToIslandBus => !_Regs.DigitalInput1; - private Boolean K3Inverter3IsConnectedToIslandBus => !_Regs.DigitalInput2; - private Boolean K3Inverter4IsConnectedToIslandBus => !_Regs.DigitalInput3; - - public Boolean FiWarning => !_Regs.DigitalInput5; - public Boolean FiError => !_Regs.DigitalInput7; - - public Boolean K2ConnectIslandBusToGridBus { get => _Regs.Relay0; set => _Regs.Relay0 = value;} - - public static implicit operator Adam6360DRegisters(RelaysRecord d) => d._Regs; - public static implicit operator RelaysRecord(Adam6360DRegisters d) => new RelaysRecord(d); - -} - - -public class RelaysRecordAmax : IRelaysRecord -{ - private readonly Amax5070Registers _Regs; - - private RelaysRecordAmax(Amax5070Registers regs) => _Regs = regs; - - public Boolean K1GridBusIsConnectedToGrid => _Regs.DigitalInput22; - public Boolean K2IslandBusIsConnectedToGridBus => !_Regs.DigitalInput20; - - public Boolean Wago1Status => _Regs.DigitalInput0; - public Boolean Wago2Status => _Regs.DigitalInput1; - public Boolean Wago3Status => _Regs.DigitalInput2; - public Boolean Wago4Status => _Regs.DigitalInput3; - - public IEnumerable K3InverterIsConnectedToIslandBus - { - get - { - yield return K3Inverter1IsConnectedToIslandBus; - yield return K3Inverter2IsConnectedToIslandBus; - yield return K3Inverter3IsConnectedToIslandBus; - yield return K3Inverter4IsConnectedToIslandBus; - } - } - - public Boolean K3Inverter1IsConnectedToIslandBus => !_Regs.DigitalInput16; - public Boolean K3Inverter2IsConnectedToIslandBus => !_Regs.DigitalInput17; - public Boolean K3Inverter3IsConnectedToIslandBus => !_Regs.DigitalInput18; - public Boolean K3Inverter4IsConnectedToIslandBus => !_Regs.DigitalInput19; - - public Boolean FiWarning => !_Regs.DigitalInput21; - public Boolean FiError => !_Regs.DigitalInput23; - - public Boolean K2ConnectIslandBusToGridBus { get => _Regs.Relay23; set => _Regs.Relay23 = value;} - - public static implicit operator Amax5070Registers(RelaysRecordAmax d) => d._Regs; - public static implicit operator RelaysRecordAmax(Amax5070Registers d) => new RelaysRecordAmax(d); - -} diff --git a/csharp/App/SaliMax/src/SaliMaxRelays/RelaysRecordAdam6060.cs b/csharp/App/SaliMax/src/SaliMaxRelays/RelaysRecordAdam6060.cs new file mode 100644 index 000000000..2882736fa --- /dev/null +++ b/csharp/App/SaliMax/src/SaliMaxRelays/RelaysRecordAdam6060.cs @@ -0,0 +1,24 @@ +using InnovEnergy.Lib.Devices.Adam6060; + + +namespace InnovEnergy.App.SaliMax.SaliMaxRelays; + +public class RelaysRecordAdam6060 +{ + private readonly Adam6060Registers _Regs; + + private RelaysRecordAdam6060(Adam6060Registers regs) => _Regs = regs; + + + public Boolean Dc1WagoStatus => _Regs.DigitalInput0; // to test + public Boolean Dc2WagoStatus => _Regs.DigitalInput1; // to test + public Boolean Dc3WagoStatus => _Regs.DigitalInput4; // to test + public Boolean Dc4WagoStatus => _Regs.DigitalInput5; // to test + + public Boolean DcSystemControlWagoStatus => _Regs.DigitalInput3; // to test + + + public static implicit operator Adam6060Registers(RelaysRecordAdam6060 d) => d._Regs; + public static implicit operator RelaysRecordAdam6060(Adam6060Registers d) => new RelaysRecordAdam6060(d); + +} \ No newline at end of file diff --git a/csharp/App/SaliMax/src/SaliMaxRelays/RelaysRecordAdam6360D.cs b/csharp/App/SaliMax/src/SaliMaxRelays/RelaysRecordAdam6360D.cs new file mode 100644 index 000000000..1adba57a9 --- /dev/null +++ b/csharp/App/SaliMax/src/SaliMaxRelays/RelaysRecordAdam6360D.cs @@ -0,0 +1,81 @@ +using InnovEnergy.Lib.Devices.Adam6360D; + +namespace InnovEnergy.App.SaliMax.SaliMaxRelays; + +public class RelaysRecordAdam6360D +{ + private readonly Adam6360DRegisters _Regs; + + private RelaysRecordAdam6360D(Adam6360DRegisters regs) => _Regs = regs; + + public Boolean K1GridBusIsConnectedToGrid => _Regs.DigitalInput6; + public Boolean K2IslandBusIsConnectedToGridBus => !_Regs.DigitalInput4; + + public Boolean Inverter1WagoStatus => _Regs.DigitalInput8; + public Boolean Inverter2WagoStatus => _Regs.DigitalInput9; + public Boolean Inverter3WagoStatus => _Regs.DigitalInput10; + public Boolean Inverter4WagoStatus => _Regs.DigitalInput11; + + public IEnumerable K3InverterIsConnectedToIslandBus + { + get + { + yield return K3Inverter1IsConnectedToIslandBus; + yield return K3Inverter2IsConnectedToIslandBus; + yield return K3Inverter3IsConnectedToIslandBus; + yield return K3Inverter4IsConnectedToIslandBus; + } + } + + private Boolean K3Inverter1IsConnectedToIslandBus => !_Regs.DigitalInput0; // change it to private should be ok + private Boolean K3Inverter2IsConnectedToIslandBus => !_Regs.DigitalInput1; + private Boolean K3Inverter3IsConnectedToIslandBus => !_Regs.DigitalInput2; + private Boolean K3Inverter4IsConnectedToIslandBus => !_Regs.DigitalInput3; + + public Boolean FiWarning => !_Regs.DigitalInput5; + public Boolean FiError => !_Regs.DigitalInput7; + + public Boolean Harvester1Step =>_Regs.DigitalOutput2; + public Boolean Harvester2Step =>_Regs.DigitalOutput3; + public Boolean Harvester3Step =>_Regs.DigitalOutput4; + public Boolean Harvester4Step =>_Regs.DigitalOutput5; + + public Boolean LedGreen { get =>_Regs.DigitalOutput0; set => _Regs.DigitalOutput0 = value;} + public Boolean LedRed { get =>_Regs.DigitalOutput1; set => _Regs.DigitalOutput1 = value;} + + public Boolean Do0Pulse { get => _Regs.Do0Pulse; set => _Regs.Do0Pulse = value;} + public Boolean Do1Pulse { get => _Regs.Do1Pulse; set => _Regs.Do1Pulse = value;} + public Boolean Do2Pulse { get => _Regs.Do2Pulse; set => _Regs.Do2Pulse = value;} + public Boolean Do3Pulse { get => _Regs.Do3Pulse; set => _Regs.Do3Pulse = value;} + public Boolean Do4Pulse { get => _Regs.Do4Pulse; set => _Regs.Do4Pulse = value;} + public Boolean Do5Pulse { get => _Regs.Do5Pulse; set => _Regs.Do5Pulse = value;} + + public UInt16 PulseOut0LowTime { get => _Regs.PulseOut0LowTime; set => _Regs.PulseOut0LowTime = value;} //in milleseconds + public UInt16 PulseOut1LowTime { get => _Regs.PulseOut1LowTime; set => _Regs.PulseOut1LowTime = value;} + public UInt16 PulseOut2LowTime { get => _Regs.PulseOut2LowTime; set => _Regs.PulseOut2LowTime = value;} + public UInt16 PulseOut3LowTime { get => _Regs.PulseOut3LowTime; set => _Regs.PulseOut3LowTime = value;} + public UInt16 PulseOut4LowTime { get => _Regs.PulseOut4LowTime; set => _Regs.PulseOut4LowTime = value;} + public UInt16 PulseOut5LowTime { get => _Regs.PulseOut5LowTime; set => _Regs.PulseOut5LowTime = value;} + + public UInt16 PulseOut0HighTime { get => _Regs.PulseOut0HighTime; set => _Regs.PulseOut0HighTime = value;} // in milleseconds + public UInt16 PulseOut1HighTime { get => _Regs.PulseOut1HighTime; set => _Regs.PulseOut1HighTime = value;} + public UInt16 PulseOut2HighTime { get => _Regs.PulseOut2HighTime; set => _Regs.PulseOut2HighTime = value;} + public UInt16 PulseOut3HighTime { get => _Regs.PulseOut3HighTime; set => _Regs.PulseOut3HighTime = value;} + public UInt16 PulseOut4HighTime { get => _Regs.PulseOut4HighTime; set => _Regs.PulseOut4HighTime = value;} + public UInt16 PulseOut5HighTime { get => _Regs.PulseOut5HighTime; set => _Regs.PulseOut5HighTime = value;} + + public UInt16 DigitalOutput0Mode { get => _Regs.DigitalOutput0Mode; set => _Regs.DigitalOutput0Mode = value;} // To test: 0, 1 or 2 + public UInt16 DigitalOutput1Mode { get => _Regs.DigitalOutput1Mode; set => _Regs.DigitalOutput1Mode = value;} + public UInt16 DigitalOutput2Mode { get => _Regs.DigitalOutput2Mode; set => _Regs.DigitalOutput2Mode = value;} + public UInt16 DigitalOutput3Mode { get => _Regs.DigitalOutput3Mode; set => _Regs.DigitalOutput3Mode = value;} + public UInt16 DigitalOutput4Mode { get => _Regs.DigitalOutput4Mode; set => _Regs.DigitalOutput4Mode = value;} + public UInt16 DigitalOutput5Mode { get => _Regs.DigitalOutput5Mode; set => _Regs.DigitalOutput5Mode = value;} + + public Boolean K2ConnectIslandBusToGridBus { get => _Regs.Relay0; set => _Regs.Relay0 = value;} + + public static implicit operator Adam6360DRegisters(RelaysRecordAdam6360D d) => d._Regs; + public static implicit operator RelaysRecordAdam6360D(Adam6360DRegisters d) => new RelaysRecordAdam6360D(d); + +} + + diff --git a/csharp/App/SaliMax/src/SaliMaxRelays/RelaysRecordAmax.cs b/csharp/App/SaliMax/src/SaliMaxRelays/RelaysRecordAmax.cs new file mode 100644 index 000000000..cc02cab48 --- /dev/null +++ b/csharp/App/SaliMax/src/SaliMaxRelays/RelaysRecordAmax.cs @@ -0,0 +1,134 @@ +using InnovEnergy.Lib.Devices.Amax5070; + +namespace InnovEnergy.App.SaliMax.SaliMaxRelays; + +public class RelaysRecordAmax : IRelaysRecord +{ + private readonly Amax5070Registers _Regs; + + private RelaysRecordAmax(Amax5070Registers regs) => _Regs = regs; + + public Boolean K1GridBusIsConnectedToGrid => _Regs.DigitalInput22; + public Boolean K2IslandBusIsConnectedToGridBus => !_Regs.DigitalInput20; + + public Boolean Inverter1WagoStatus => _Regs.DigitalInput0; + public Boolean Inverter2WagoStatus => _Regs.DigitalInput1; + public Boolean Inverter3WagoStatus => _Regs.DigitalInput2; + public Boolean Inverter4WagoStatus => _Regs.DigitalInput3; + + public Boolean Dc1WagoStatus => _Regs.DigitalInput6; + public Boolean Dc2WagoStatus => _Regs.DigitalInput7; + public Boolean Dc3WagoStatus => _Regs.DigitalInput10; + public Boolean Dc4WagoStatus => _Regs.DigitalInput11; + public Boolean DcSystemControlWagoStatus => _Regs.DigitalInput9; + + public Boolean LedGreen + { + get => _Regs.DigitalOutput0; + set => _Regs.DigitalOutput0 = value; + } + + public Boolean LedRed => _Regs.DigitalOutput1; + public Boolean Harvester1Step => _Regs.DigitalOutput2; + public Boolean Harvester2Step => _Regs.DigitalOutput3; + public Boolean Harvester3Step => _Regs.DigitalOutput4; + public Boolean Harvester4Step => _Regs.DigitalOutput5; + public Boolean Do0StartPulse { get; set; } + public Boolean Do1StartPulse { get; set; } + public Boolean Do2StartPulse { get; set; } + public Boolean Do3StartPulse { get; set; } + public Boolean Do4StartPulse { get; set; } + public Boolean Do5StartPulse { get; set; } + public UInt16 DigitalOutput0Mode { get; set; } + public UInt16 DigitalOutput1Mode { get; set; } + public UInt16 DigitalOutput2Mode { get; set; } + public UInt16 DigitalOutput3Mode { get; set; } + public UInt16 DigitalOutput4Mode { get; set; } + public UInt16 DigitalOutput5Mode { get; set; } + public UInt16 PulseOut0LowTime { get; set; } + public UInt16 PulseOut1LowTime { get; set; } + public UInt16 PulseOut2LowTime { get; set; } + public UInt16 PulseOut3LowTime { get; set; } + public UInt16 PulseOut4LowTime { get; set; } + public UInt16 PulseOut5LowTime { get; set; } + public UInt16 PulseOut0HighTime { get; set; } + public UInt16 PulseOut1HighTime { get; set; } + public UInt16 PulseOut2HighTime { get; set; } + public UInt16 PulseOut3HighTime { get; set; } + public UInt16 PulseOut4HighTime { get; set; } + public UInt16 PulseOut5HighTime { get; set; } + + public void PerformSolidGreenLed() + { + Console.WriteLine("Solid Green: This is not yet implemented "); + } + + public void PerformSlowFlashingGreenLed() + { + Console.WriteLine("Slow Flashing Green: This is not yet implemented "); + } + + public void PerformFastFlashingGreenLed() + { + Console.WriteLine("Fast Flashing Green: This is not yet implemented "); + } + + public void PerformSolidOrangeLed() + { + Console.WriteLine("Solid Orange: This is not yet implemented "); + } + + public void PerformSlowFlashingOrangeLed() + { + Console.WriteLine("Slow Flashing Orange: This is not yet implemented "); + } + + public void PerformFastFlashingOrangeLed() + { + Console.WriteLine("Fast Flashing Orange: This is not yet implemented "); + } + + public void PerformSolidRedLed() + { + Console.WriteLine("Solid Red: This is not yet implemented "); + } + + public void PerformSlowFlashingRedLed() + { + Console.WriteLine("Slow Flashing Red: This is not yet implemented "); + } + + public void PerformFastFlashingRedLed() + { + Console.WriteLine("Fast Flashing Red: This is not yet implemented "); + } + + public IEnumerable K3InverterIsConnectedToIslandBus + { + get + { + yield return K3Inverter1IsConnectedToIslandBus; + yield return K3Inverter2IsConnectedToIslandBus; + yield return K3Inverter3IsConnectedToIslandBus; + yield return K3Inverter4IsConnectedToIslandBus; + } + } + + private Boolean K3Inverter1IsConnectedToIslandBus => !_Regs.DigitalInput16; + private Boolean K3Inverter2IsConnectedToIslandBus => !_Regs.DigitalInput17; + private Boolean K3Inverter3IsConnectedToIslandBus => !_Regs.DigitalInput18; + private Boolean K3Inverter4IsConnectedToIslandBus => !_Regs.DigitalInput19; + + public Boolean FiWarning => !_Regs.DigitalInput21; + public Boolean FiError => !_Regs.DigitalInput23; + + public Boolean K2ConnectIslandBusToGridBus + { + get => _Regs.Relay23; + set => _Regs.Relay23 = value; + } + + public static implicit operator Amax5070Registers(RelaysRecordAmax d) => d._Regs; + public static implicit operator RelaysRecordAmax(Amax5070Registers d) => new RelaysRecordAmax(d); + +}