From 3218bcabb9eec4540c25940831ba7958b26a7b66 Mon Sep 17 00:00:00 2001 From: atef Date: Tue, 31 Dec 2024 16:14:01 +0100 Subject: [PATCH] Create combined class for Adam6060 and Adam6360D --- .../SaliMaxRelays/CombinedAdamRelaysRecord.cs | 211 ++++++++++++++++++ 1 file changed, 211 insertions(+) create mode 100644 csharp/App/SaliMax/src/SaliMaxRelays/CombinedAdamRelaysRecord.cs diff --git a/csharp/App/SaliMax/src/SaliMaxRelays/CombinedAdamRelaysRecord.cs b/csharp/App/SaliMax/src/SaliMaxRelays/CombinedAdamRelaysRecord.cs new file mode 100644 index 000000000..23f777169 --- /dev/null +++ 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