diff --git a/csharp/App/SaliMax/src/Program.cs b/csharp/App/SaliMax/src/Program.cs index c73a7980d..5122351f9 100644 --- a/csharp/App/SaliMax/src/Program.cs +++ b/csharp/App/SaliMax/src/Program.cs @@ -1,4 +1,4 @@ -#undef Amax +#define Amax #undef GridLimit using System.IO.Compression; diff --git a/csharp/App/SaliMax/src/SaliMaxRelays/CombinedAdamRelaysRecord.cs b/csharp/App/SaliMax/src/SaliMaxRelays/CombinedAdamRelaysRecord.cs index e69de29bb..23f777169 100644 --- a/csharp/App/SaliMax/src/SaliMaxRelays/CombinedAdamRelaysRecord.cs +++ b/csharp/App/SaliMax/src/SaliMaxRelays/CombinedAdamRelaysRecord.cs @@ -0,0 +1,211 @@ +using System.Reflection.Metadata; + +namespace InnovEnergy.App.SaliMax.SaliMaxRelays; +#pragma warning disable CS8602 // Dereference of a possibly null reference. + +public class CombinedAdamRelaysRecord : IRelaysRecord +{ + private const UInt16 SlowFreq = 3000; + private const UInt16 HighFreq = 1000; + + public CombinedAdamRelaysRecord(RelaysRecordAdam6060? relaysRecordAdam6060, RelaysRecordAdam6360D? relaysRecordAdam6360D) + { + _recordAdam6060 = relaysRecordAdam6060; + _recordAdam6360D = relaysRecordAdam6360D; + } + + private static RelaysRecordAdam6060? _recordAdam6060; + private static RelaysRecordAdam6360D? _recordAdam6360D; + + public static IRelaysRecord Instance { get; } = new CombinedAdamRelaysRecord(_recordAdam6060, _recordAdam6360D); + + + public Boolean K1GridBusIsConnectedToGrid => _recordAdam6360D.K1GridBusIsConnectedToGrid; + + public Boolean K2IslandBusIsConnectedToGridBus => _recordAdam6360D.K2IslandBusIsConnectedToGridBus; + public Boolean FiWarning => _recordAdam6360D.FiWarning; + public Boolean FiError => _recordAdam6360D.FiError; + public Boolean K2ConnectIslandBusToGridBus + { + get => _recordAdam6360D.K2ConnectIslandBusToGridBus; + set => _recordAdam6360D.K2ConnectIslandBusToGridBus = value; + } + + public Boolean Inverter1WagoStatus => _recordAdam6360D.Inverter1WagoStatus; + public Boolean Inverter2WagoStatus => _recordAdam6360D.Inverter2WagoStatus; + public Boolean Inverter3WagoStatus => _recordAdam6360D.Inverter3WagoStatus; + public Boolean Inverter4WagoStatus => _recordAdam6360D.Inverter4WagoStatus; + + public Boolean Dc1WagoStatus => _recordAdam6060.Dc1WagoStatus; + public Boolean Dc2WagoStatus => _recordAdam6060.Dc2WagoStatus; + public Boolean Dc3WagoStatus => _recordAdam6060.Dc3WagoStatus; + public Boolean Dc4WagoStatus => _recordAdam6060.Dc4WagoStatus; + public Boolean DcSystemControlWagoStatus => _recordAdam6060.DcSystemControlWagoStatus; + + public Boolean LedGreen { get => _recordAdam6360D.LedGreen; set => _recordAdam6360D.LedGreen = value;} + public Boolean LedRed { get => _recordAdam6360D.LedRed; set => _recordAdam6360D.LedRed = value;} + public Boolean Harvester1Step => _recordAdam6360D.Harvester1Step; + public Boolean Harvester2Step => _recordAdam6360D.Harvester2Step; + public Boolean Harvester3Step => _recordAdam6360D.Harvester3Step; + public Boolean Harvester4Step => _recordAdam6360D.Harvester4Step; + + public UInt16 DigitalOutput0Mode { get => _recordAdam6360D.DigitalOutput0Mode; set => _recordAdam6360D.DigitalOutput0Mode = value; } + + public UInt16 DigitalOutput1Mode + { + get => _recordAdam6360D.DigitalOutput1Mode; + set => _recordAdam6360D.DigitalOutput1Mode = value; + } + + public UInt16 DigitalOutput2Mode + { + get => _recordAdam6360D.DigitalOutput2Mode; + set => _recordAdam6360D.DigitalOutput2Mode = value; + } + + public UInt16 DigitalOutput3Mode + { + get => _recordAdam6360D.DigitalOutput3Mode; + set => _recordAdam6360D.DigitalOutput3Mode = value; + } + + public UInt16 DigitalOutput4Mode + { + get => _recordAdam6360D.DigitalOutput4Mode; + set => _recordAdam6360D.DigitalOutput4Mode = value; + } + + public UInt16 DigitalOutput5Mode + { + get => _recordAdam6360D.DigitalOutput5Mode; + set => _recordAdam6360D.DigitalOutput5Mode = value; + } + + public Boolean Do0StartPulse { get => _recordAdam6360D.Do0Pulse; set => _recordAdam6360D.Do0Pulse = value; } + public Boolean Do1StartPulse { get => _recordAdam6360D.Do1Pulse; set => _recordAdam6360D.Do1Pulse = value; } + public Boolean Do2StartPulse { get => _recordAdam6360D.Do2Pulse; set => _recordAdam6360D.Do2Pulse = value; } + public Boolean Do3StartPulse { get => _recordAdam6360D.Do3Pulse; set => _recordAdam6360D.Do3Pulse = value; } + public Boolean Do4StartPulse { get => _recordAdam6360D.Do4Pulse; set => _recordAdam6360D.Do4Pulse = value; } + public Boolean Do5StartPulse { get => _recordAdam6360D.Do5Pulse; set => _recordAdam6360D.Do5Pulse = value; } + + + public UInt16 PulseOut0LowTime { get => _recordAdam6360D.PulseOut0LowTime; set => _recordAdam6360D.PulseOut0LowTime = value; } + public UInt16 PulseOut1LowTime { get => _recordAdam6360D.PulseOut1LowTime; set => _recordAdam6360D.PulseOut1LowTime = value; } + public UInt16 PulseOut2LowTime { get => _recordAdam6360D.PulseOut2LowTime; set => _recordAdam6360D.PulseOut2LowTime = value; } + public UInt16 PulseOut3LowTime { get => _recordAdam6360D.PulseOut3LowTime; set => _recordAdam6360D.PulseOut3LowTime = value; } + public UInt16 PulseOut4LowTime { get => _recordAdam6360D.PulseOut4LowTime; set => _recordAdam6360D.PulseOut4LowTime = value; } + public UInt16 PulseOut5LowTime { get => _recordAdam6360D.PulseOut5LowTime; set => _recordAdam6360D.PulseOut5LowTime = value; } + + public UInt16 PulseOut0HighTime { get => _recordAdam6360D.PulseOut0HighTime; set => _recordAdam6360D.PulseOut0HighTime = value; } + public UInt16 PulseOut1HighTime { get => _recordAdam6360D.PulseOut1HighTime; set => _recordAdam6360D.PulseOut1HighTime = value; } + public UInt16 PulseOut2HighTime { get => _recordAdam6360D.PulseOut2HighTime; set => _recordAdam6360D.PulseOut2HighTime = value; } + public UInt16 PulseOut3HighTime { get => _recordAdam6360D.PulseOut3HighTime; set => _recordAdam6360D.PulseOut3HighTime = value; } + public UInt16 PulseOut4HighTime { get => _recordAdam6360D.PulseOut4HighTime; set => _recordAdam6360D.PulseOut4HighTime = value; } + public UInt16 PulseOut5HighTime { get => _recordAdam6360D.PulseOut5HighTime; set => _recordAdam6360D.PulseOut5HighTime = value; } + + /**************************** Green LED *********************************/ + + public void PerformSolidGreenLed() + { + DigitalOutput0Mode = 0; + DigitalOutput1Mode = 0; + LedGreen = true; + LedRed = false; + } + + public void PerformSlowFlashingGreenLed() + { + PulseOut0HighTime = SlowFreq; + PulseOut0LowTime = SlowFreq; + DigitalOutput0Mode = 2; + Do0StartPulse = true; + Do1StartPulse = false; // make sure the red LED is off + + Console.WriteLine("Green Slow Flashing Starting"); + } + + public void PerformFastFlashingGreenLed() + { + PulseOut0HighTime = HighFreq; + PulseOut0LowTime = HighFreq; + DigitalOutput0Mode = 2; + Do0StartPulse = true; + Do1StartPulse = false;// make sure the red LED is off + + Console.WriteLine("Green Slow Flashing Starting"); + } + + /**************************** Orange LED *********************************/ + + public void PerformSolidOrangeLed() + { + DigitalOutput0Mode = 0; + DigitalOutput1Mode = 0; + LedGreen = true; + LedRed = true; + } + + public void PerformSlowFlashingOrangeLed() + { + PerformSlowFlashingGreenLed(); + PerformSlowFlashingRedLed(); + Do0StartPulse = true; + Do1StartPulse = true; + + Console.WriteLine("Orange Slow Flashing Starting"); + } + + public void PerformFastFlashingOrangeLed() + { + PerformFastFlashingGreenLed(); + PerformFastFlashingRedLed(); + Do0StartPulse = true; + Do1StartPulse = true; + Console.WriteLine("Orange Fast Flashing Starting"); + } + + /**************************** RED LED *********************************/ + + public void PerformSolidRedLed() + { + DigitalOutput0Mode = 0; + DigitalOutput1Mode = 0; + LedGreen = false; + LedRed = true; + } + + public void PerformSlowFlashingRedLed() + { + PulseOut1HighTime = SlowFreq; + PulseOut1LowTime = SlowFreq; + DigitalOutput1Mode = 2; + Do0StartPulse = false; // make sure the green LED is off + Do1StartPulse = true; + + Console.WriteLine("Red Slow Flashing Starting"); + } + + public void PerformFastFlashingRedLed() + { + PulseOut1HighTime = HighFreq; + PulseOut1LowTime = HighFreq; + DigitalOutput1Mode = 2; + Do0StartPulse = false; // make sure the green LED is off + Do1StartPulse = true; + + Console.WriteLine("Red Fast Flashing Starting"); + } + + public RelaysRecordAdam6360D? GetAdam6360DRecord() + { + return _recordAdam6360D; + } + + public RelaysRecordAdam6060? GetAdam6060Record() + { + return _recordAdam6060; + } + + public IEnumerable K3InverterIsConnectedToIslandBus => _recordAdam6360D.K3InverterIsConnectedToIslandBus; + +} \ No newline at end of file diff --git a/csharp/App/SaliMax/src/SaliMaxRelays/IRelaysRecord.cs b/csharp/App/SaliMax/src/SaliMaxRelays/IRelaysRecord.cs index e69de29bb..1e7f8c089 100644 --- a/csharp/App/SaliMax/src/SaliMaxRelays/IRelaysRecord.cs +++ 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 index e69de29bb..cc94dce66 100644 --- a/csharp/App/SaliMax/src/SaliMaxRelays/RelaysDeviceADAM6360.cs +++ b/csharp/App/SaliMax/src/SaliMaxRelays/RelaysDeviceADAM6360.cs @@ -0,0 +1,38 @@ +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(); + } + } +} \ No newline at end of file diff --git a/csharp/App/SaliMax/src/SaliMaxRelays/RelaysDeviceAdam6060.cs b/csharp/App/SaliMax/src/SaliMaxRelays/RelaysDeviceAdam6060.cs index e69de29bb..2533cbd70 100644 --- a/csharp/App/SaliMax/src/SaliMaxRelays/RelaysDeviceAdam6060.cs +++ 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/RelaysDeviceAmax.cs b/csharp/App/SaliMax/src/SaliMaxRelays/RelaysDeviceAmax.cs index e69de29bb..30a95e3de 100644 --- a/csharp/App/SaliMax/src/SaliMaxRelays/RelaysDeviceAmax.cs +++ b/csharp/App/SaliMax/src/SaliMaxRelays/RelaysDeviceAmax.cs @@ -0,0 +1,38 @@ +using InnovEnergy.Lib.Devices.Amax5070; +using InnovEnergy.Lib.Protocols.Modbus.Channels; + + +namespace InnovEnergy.App.SaliMax.SaliMaxRelays; + +public class RelaysDeviceAmax +{ + private Amax5070Device AmaxDevice { get; } + + public RelaysDeviceAmax(String hostname) => AmaxDevice = new Amax5070Device(hostname); + public RelaysDeviceAmax(Channel channel) => AmaxDevice = new Amax5070Device(channel); + + public RelaysRecordAmax? Read() + { + try + { + return AmaxDevice.Read(); + } + catch (Exception e) + { + $"Failed to read from {nameof(RelaysDeviceAmax)}\n{e}".LogError(); + return null; + } + } + + public void Write(RelaysRecordAmax r) + { + try + { + AmaxDevice.Write(r); + } + catch (Exception e) + { + $"Failed to write to {nameof(RelaysDeviceAmax)}\n{e}".LogError(); + } + } +} \ No newline at end of file diff --git a/csharp/App/SaliMax/src/SaliMaxRelays/RelaysRecordAdam6060.cs b/csharp/App/SaliMax/src/SaliMaxRelays/RelaysRecordAdam6060.cs index e69de29bb..2882736fa 100644 --- a/csharp/App/SaliMax/src/SaliMaxRelays/RelaysRecordAdam6060.cs +++ 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 index e69de29bb..46625fdc2 100644 --- a/csharp/App/SaliMax/src/SaliMaxRelays/RelaysRecordAdam6360D.cs +++ b/csharp/App/SaliMax/src/SaliMaxRelays/RelaysRecordAdam6360D.cs @@ -0,0 +1,79 @@ +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); + +} \ No newline at end of file diff --git a/csharp/App/SaliMax/src/SaliMaxRelays/RelaysRecordAmax.cs b/csharp/App/SaliMax/src/SaliMaxRelays/RelaysRecordAmax.cs index e69de29bb..b840dbeb2 100644 --- a/csharp/App/SaliMax/src/SaliMaxRelays/RelaysRecordAmax.cs +++ 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; + } + } + + 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); + +} \ No newline at end of file