diff --git a/csharp/App/SaliMax/src/Program.cs b/csharp/App/SaliMax/src/Program.cs index e54ddb987..98af9657c 100644 --- a/csharp/App/SaliMax/src/Program.cs +++ b/csharp/App/SaliMax/src/Program.cs @@ -319,7 +319,7 @@ internal static class Program if (s3Bucket != null) RabbitMqManager.InformMiddleware(currentSalimaxState); } - else if (_subscribedToQueue && _heartBitInterval >= 15) + else if (_subscribedToQueue && _heartBitInterval >= 30) { //Send a heartbit to the backend Console.WriteLine("----------------------------------------Sending Heartbit----------------------------------------"); @@ -676,38 +676,39 @@ internal static class Program var s3Path = timeStamp.ToUnixTime() + ".csv"; var request = s3Config.CreatePutRequest(s3Path); - // This is temporary for Wittman, but now it's for all Instalattion + // This is temporary for Wittman, but now it's for all Installation await File.WriteAllTextAsync("/var/www/html/status.csv", csv.SplitLines().Where(l => !l.Contains("Secret")).JoinLines()); - var response = await request.PutAsync(new StringContent(csv)); + //Use this for no compression + //var response = await request.PutAsync(new StringContent(csv)); + + //Compress CSV data to a byte array + byte[] compressedBytes; + using (var memoryStream = new MemoryStream()) + { + //Create a zip directory and put the compressed file inside + using (var archive = new ZipArchive(memoryStream, ZipArchiveMode.Create, true)) + { + var entry = archive.CreateEntry("data.csv", CompressionLevel.SmallestSize); // Add CSV data to the ZIP archive + using (var entryStream = entry.Open()) + using (var writer = new StreamWriter(entryStream)) + { + writer.Write(csv); + } + } + + compressedBytes = memoryStream.ToArray(); + } + + // Encode the compressed byte array as a Base64 string + string base64String = Convert.ToBase64String(compressedBytes); + + // Create StringContent from Base64 string + var stringContent = new StringContent(base64String, Encoding.UTF8, "application/base64"); + + // Upload the compressed data (ZIP archive) to S3 + var response = await request.PutAsync(stringContent); - // Compress CSV data to a byte array - // byte[] compressedBytes; - // using (var memoryStream = new MemoryStream()) - // { - // //Create a zip directory and put the compressed file inside - // using (var archive = new ZipArchive(memoryStream, ZipArchiveMode.Create, true)) - // { - // var entry = archive.CreateEntry("data.csv", CompressionLevel.SmallestSize); // Add CSV data to the ZIP archive - // using (var entryStream = entry.Open()) - // using (var writer = new StreamWriter(entryStream)) - // { - // writer.Write(csv); - // } - // } - // - // compressedBytes = memoryStream.ToArray(); - // } - // - // // Encode the compressed byte array as a Base64 string - // string base64String = Convert.ToBase64String(compressedBytes); - // - // // Create StringContent from Base64 string - // var stringContent = new StringContent(base64String, Encoding.UTF8, "application/base64"); - // - // // Upload the compressed data (ZIP archive) to S3 - // var response = await request.PutAsync(stringContent); - // if (response.StatusCode != 200) { Console.WriteLine("ERROR: PUT"); diff --git a/csharp/App/SaliMax/src/S3Config.cs b/csharp/App/SaliMax/src/S3Config.cs index cbf2a92f9..48ff5c218 100644 --- a/csharp/App/SaliMax/src/S3Config.cs +++ b/csharp/App/SaliMax/src/S3Config.cs @@ -62,16 +62,9 @@ public record S3Config String contentType = "application/base64", String md5Hash = "") { - // StringToSign = HTTP-Verb + "\n" + - // Content-MD5 + "\n" + - // Content-Type + "\n" + - // Date + "\n" + - // CanonicalizedAmzHeaders + - // CanonicalizedResource; - - - //contentType = "application/base64; charset=utf-8"; - contentType = "text/plain; charset=utf-8"; + + contentType = "application/base64; charset=utf-8"; + //contentType = "text/plain; charset=utf-8"; var payload = $"{method}\n{md5Hash}\n{contentType}\n{date}\n/{bucket.Trim('/')}/{s3Path.Trim('/')}"; using var hmacSha1 = new HMACSHA1(UTF8.GetBytes(s3Secret)); diff --git a/csharp/App/SchneiderMeterDriver/Config.cs b/csharp/App/SchneiderMeterDriver/Config.cs index dbe60ebf8..eb127b489 100644 --- a/csharp/App/SchneiderMeterDriver/Config.cs +++ b/csharp/App/SchneiderMeterDriver/Config.cs @@ -19,33 +19,33 @@ public static class Config public static readonly TimeSpan UpdatePeriod = TimeSpan.FromSeconds(1); public static readonly IReadOnlyList Signals = new List - { - // new(s => s..CurrentL1, "/Ac/L1/Current", "0.0 A"), - // new(s => s..CurrentL2, "/Ac/L2/Current", "0.0 A"), - // new(s => s..CurrentL3, "/Ac/L3/Current", "0.0 A"), - // new(s => s..CurrentL1 + s.Ac.L2.Current + s.Ac.L3.Current, "/Ac/Current", "0.0 A"), + { + new Signal(s => s._CurrentL1, "/Ac/L1/Current", "0.0 A"), + new Signal(s => s._CurrentL2, "/Ac/L2/Current", "0.0 A"), + new Signal(s => s._CurrentL3, "/Ac/L3/Current", "0.0 A"), + new Signal(s => s._CurrentL1 + s._CurrentL2 + s._CurrentL3, "/Ac/Current", "0.0 A"), - // new(s => s.Ac.L1.Voltage, "/Ac/L1/Voltage", "0.0 A"), - // new(s => s.Ac.L2.Voltage, "/Ac/L2/Voltage", "0.0 A"), - // new(s => s.Ac.L3.Voltage, "/Ac/L3/Voltage", "0.0 A"), - // new(s => (s.Ac.L1.Voltage + s.Ac.L2.Voltage + s.Ac.L3.Voltage) / 3.0m, "/Ac/Voltage", "0.0 A"), + new Signal(s => s._VoltageL1N, "/Ac/L1/Voltage", "0.0 V"), + new Signal(s => s._VoltageL2N, "/Ac/L2/Voltage", "0.0 V"), + new Signal(s => s._VoltageL3N, "/Ac/L3/Voltage", "0.0 V"), + new Signal(s => (s._VoltageL1N + s._VoltageL2N + s._VoltageL3N) / 3.0f, "/Ac/Voltage", "0.0 V"), new Signal(s => s.ActivePowerL1, "/Ac/L1/Power", "0 W"), new Signal(s => s.ActivePowerL2, "/Ac/L2/Power", "0 W"), new Signal(s => s.ActivePowerL3, "/Ac/L3/Power", "0 W"), - new Signal(s => s.ActivePowerL1 + s.ActivePowerL2 + s.ActivePowerL3, "/Ac/Power", "0 W"), - - // new(s => s.EnergyImportL123, "Ac/Energy/Forward", "0.00 kWh"), - // new(s => s.EnergyExportL123, "Ac/Energy/Reverse", "0.00 kWh"), - // - // new(s => s.EnergyImportL1, "Ac/L1/Energy/Forward", "0.00 kWh"), - // new(s => s.EnergyExportL1, "Ac/L1/Energy/Reverse", "0.00 kWh"), - // - // new(s => s.EnergyImportL2, "Ac/L2/Energy/Forward", "0.00 kWh"), - // new(s => s.EnergyExportL2, "Ac/L2/Energy/Reverse", "0.00 kWh"), - // - // new(s => s.EnergyImportL3, "Ac/L3/Energy/Forward", "0.00 kWh"), - // new(s => s.EnergyExportL3, "Ac/L3/Energy/Reverse", "0.00 kWh"), + new Signal(s => s.ActivePowerL1 + s.ActivePowerL2 + s.ActivePowerL3, "/Ac/Power", "0 W"), + + + new Signal(s => s.TotalActiveImport, "Ac/Energy/Forward", "0.00 kWh"), + new Signal(s => s.TotalActiveExport, "Ac/Energy/Reverse", "0.00 kWh"), + new Signal(s => s.ActiveEnergyImportL1, "Ac/L1/Energy/Forward", "0.00 kWh"), + // new(s => s.EnergyExportL1, "Ac/L1/Energy/Reverse", "0.00 kWh"), + // + new Signal(s => s.ActiveEnergyImportL2, "Ac/L2/Energy/Forward", "0.00 kWh"), + // new(s => s.EnergyExportL2, "Ac/L2/Energy/Reverse", "0.00 kWh"), + // + new Signal(s => s.ActiveEnergyImportL3, "Ac/L3/Energy/Forward", "0.00 kWh"), + // new(s => s.EnergyExportL3, "Ac/L3/Energy/Reverse", "0.00 kWh"), }; public static VeProperties DefaultProperties => new VeProperties diff --git a/csharp/App/SchneiderMeterDriver/Program.cs b/csharp/App/SchneiderMeterDriver/Program.cs index b447c8933..404068d21 100644 --- a/csharp/App/SchneiderMeterDriver/Program.cs +++ b/csharp/App/SchneiderMeterDriver/Program.cs @@ -13,10 +13,26 @@ Console.WriteLine("Starting Schneider Driver " + Config.Version); var networkInterfaces = await Nic.GetNetworkInterfaces(); +Console.WriteLine("Retrieved network interfaces"); + +// Log all network interfaces and their properties +foreach (var nic in networkInterfaces) +{ + Console.WriteLine($"Interface: {nic.Name}"); + Console.WriteLine($" IsUp: {nic.IsUp}"); + Console.WriteLine($" IsEthernet: {nic.IsEthernet}"); + Console.WriteLine($" IP4 Addresses: {string.Join(", ", nic.Ip4Addresses)}"); +} + var candidates = networkInterfaces.Where(n => n.IsUp && n.IsEthernet && (!n.Ip4Addresses.Any() || n.Ip4Addresses.Contains(Config.OwnAddress))); +if (!candidates.Any()) +{ + Console.WriteLine("No suitable network interfaces found."); +} + foreach (var nic in candidates) { Console.WriteLine($"Found new network interface: {nic.Name}"); @@ -43,7 +59,10 @@ foreach (var nic in candidates) if (ping) { Console.WriteLine($"Got answer from {Config.PeerAddress}"); - var ex = await SchneiderMeterDriver.Run($"{Config.PeerAddress}:{Config.PeerPort}", Bus.System); + //SchneiderMeterDriver.Run(Config.PeerAddress, Config.PeerPort, Bus.System); + + //Console.WriteLine($"{nameof(SchneiderMeterDriver)} FAILED with\n"); + var ex = await SchneiderMeterDriver.Run(Config.PeerAddress, Config.PeerPort, Bus.System); Console.WriteLine($"{nameof(SchneiderMeterDriver)} FAILED with\n{ex}"); } diff --git a/csharp/App/SchneiderMeterDriver/SchneiderMeterDriver.cs b/csharp/App/SchneiderMeterDriver/SchneiderMeterDriver.cs index 2953e9cd4..5a5fb4280 100644 --- a/csharp/App/SchneiderMeterDriver/SchneiderMeterDriver.cs +++ b/csharp/App/SchneiderMeterDriver/SchneiderMeterDriver.cs @@ -1,4 +1,4 @@ -/*using System.Reactive.Linq; +using System.Reactive.Linq; using InnovEnergy.Lib.Devices.IEM3kGridMeter; using InnovEnergy.Lib.Protocols.DBus; using InnovEnergy.Lib.Protocols.Modbus.Clients; @@ -10,11 +10,11 @@ namespace InnovEnergy.App.SchneiderDriver; public static class SchneiderMeterDriver { + public static Task Run(String hostName, Bus dbusAddress) { return Run(hostName, ModbusTcpClient.DefaultPort, dbusAddress); } - public static async Task Run(String hostName, UInt16 port, Bus dbusAddress) { // var ep = new UnixDomainSocketEndPoint("/home/eef/graber_dbus.sock"); @@ -30,39 +30,72 @@ public static class SchneiderMeterDriver .Publish(); var x = schneider.Read(); - - x?.ActivePowerL1.WriteLine(); - x?.ActivePowerL2.WriteLine(); - x?.ActivePowerL3.WriteLine(); + // Print the output of schneider.Read() + if (x != null) + { + Console.WriteLine("Schneider Read Output:"); + Console.WriteLine($"ActivePowerL1: {x.ActivePowerL1}"); + Console.WriteLine($"ActivePowerL2: {x.ActivePowerL2}"); + Console.WriteLine($"ActivePowerL3: {x.ActivePowerL3}"); + // Add more properties if needed + } + else + { + Console.WriteLine("Failed to read data from Schneider device."); + } var poller = schneiderStatus.Connect(); var properties = Config.DefaultProperties; - - foreach (var p in properties) - { - p.WriteLine(" Signal"); - } + // Step 1: Access Config.Signals var signalsCollection = Config.Signals; - - foreach (var s in signalsCollection) - { - s.WriteLine(" Signal"); - } - var signals = Config + /*var signals = Config .Signals .Select(signal => schneiderStatus.Select(signal.ToVeProperty)) .Merge() - .Do(p => properties.Set(p)); + .Do(p => properties.Set(p));*/ + + var signals = Config + .Signals + .Select(signal => schneiderStatus + .Select(reading => + { + var property = signal.ToVeProperty(reading); + if (property == null) + { + Console.WriteLine($"Warning: Signal {signal} produced a null property."); + } + else + { + Console.WriteLine($"Transformed Signal to Property: {property}"); + } + return property; + }) + .Where(property => property != null)) + .Merge() + .Do(p => + { + Console.WriteLine($"Setting property: {p}"); + properties.Set(p); + }); + + // Log initial signals + /*Console.WriteLine("Initial Signals:"); + foreach (var signal in signalsCollection) + { + Console.WriteLine($"Signal: {signal}"); + }*/ // TODO: remove when possible // Apparently some VE services need to be periodically reminded that // this service is /Connected + Console.WriteLine("Goes to subscribe"); schneiderStatus.Subscribe(_ => properties.Set("/Connected", 1)); + Console.WriteLine("Subscribed successfully"); // Wait until status is read once to make sure all // properties are set when we go onto the bus. @@ -72,9 +105,9 @@ public static class SchneiderMeterDriver .SelectMany(_ => PublishPropertiesOnDBus(properties, dbusAddress)); return await signals - .MergeErrors(dbus) - .Finally(poller.Dispose) - .SelectErrors(); + .MergeErrors(dbus) + .Finally(poller.Dispose) + .SelectErrors(); } @@ -84,70 +117,6 @@ public static class SchneiderMeterDriver Console.WriteLine($"Connecting to DBus {bus}"); return properties.PublishOnDBus(bus, Config.BusName); } -}*/ - -using System; -using System.Reactive.Linq; -using InnovEnergy.Lib.Devices.IEM3kGridMeter; -using InnovEnergy.Lib.Protocols.DBus; -using InnovEnergy.Lib.Protocols.Modbus.Clients; -using InnovEnergy.Lib.Utils; -using InnovEnergy.Lib.Victron.VeDBus; - -namespace InnovEnergy.App.SchneiderDriver -{ - public static class SchneiderMeterDriver - { - public static Task Run(string hostName, Bus dbusAddress) - { - return Run(hostName, ModbusTcpClient.DefaultPort, dbusAddress); - } - - public static async Task Run(string hostName, ushort port, Bus dbusAddress) - { - var schneider = new Iem3KGridMeterDevice(hostName, port, Config.ModbusNodeId); - var schneiderStatus = Observable - .Interval(Config.UpdatePeriod) - .Select(_ => - { - var status = schneider.Read(); - if (status == null) - { - Console.WriteLine("Failed to read data from Iem3KGridMeterDevice"); - } - return status; - }) - .Where(status => status != null) // Ignore null readings - .Publish(); - - var poller = schneiderStatus.Connect(); - var properties = Config.DefaultProperties; - - var signals = Config - .Signals - .Select(signal => schneiderStatus.Select(signal.ToVeProperty)) - .Merge() - .Do(p => properties.Set(p)); - - schneiderStatus.Subscribe(_ => properties.Set("/Connected", 1)); - - var dbus = schneiderStatus - .Skip(1) - .Take(1) - .SelectMany(_ => PublishPropertiesOnDBus(properties, dbusAddress)); - - return await signals - .MergeErrors(dbus) - .Finally(poller.Dispose) - .SelectErrors(); - } - - private static Task PublishPropertiesOnDBus(VeProperties properties, Bus bus) - { - Console.WriteLine($"Connecting to DBus {bus}"); - return properties.PublishOnDBus(bus, Config.BusName); - } - } } diff --git a/csharp/App/SchneiderMeterDriver/Signal.cs b/csharp/App/SchneiderMeterDriver/Signal.cs index e7eba2bec..a6354878e 100644 --- a/csharp/App/SchneiderMeterDriver/Signal.cs +++ b/csharp/App/SchneiderMeterDriver/Signal.cs @@ -20,7 +20,45 @@ using InnovEnergy.Lib.Protocols.DBus.Protocol.DataTypes; using InnovEnergy.Lib.Victron.VeDBus; using System; + namespace InnovEnergy.App.SchneiderDriver +{ + public record Signal(Func Source, ObjectPath Path, string Format = "") + { + // Converts the status object to a VeProperty, handling null status gracefully + public VeProperty ToVeProperty(Iem3KGridMeterRegisters status) + { + // Check if status is null and log a message + if (status == null) + { + Console.WriteLine($"Status is null for path: {Path}"); + // Return a default VeProperty if status is null + return new VeProperty(Path, default(double), string.Format($"{{0:{Format}}}", default(double))); + } + + // Retrieve the value using the provided source function + var value = Source(status); + + // Handle the case where the value itself might be null + if (value == null) + { + Console.WriteLine($"Value is null for path: {Path}"); + // Return a default VeProperty if value is null + return new VeProperty(Path, default(double), string.Format($"{{0:{Format}}}", default(double))); + } + + if (value is float floatValue) + { + value = (double)floatValue; + } + + // Create and return the VeProperty with the actual value and format + return new VeProperty(Path, value, string.Format($"{{0:{Format}}}", value)); + } + } +} + +/*namespace InnovEnergy.App.SchneiderDriver { public record Signal(Func Source, ObjectPath Path, string Format = "") { @@ -37,7 +75,7 @@ namespace InnovEnergy.App.SchneiderDriver return new VeProperty(Path, value, String.Format($"{{0:{Format}}}", value)); } } -} +}*/ diff --git a/csharp/App/SchneiderMeterDriver/debug.sh b/csharp/App/SchneiderMeterDriver/debug.sh index e68489b70..a274b1111 100755 --- a/csharp/App/SchneiderMeterDriver/debug.sh +++ b/csharp/App/SchneiderMeterDriver/debug.sh @@ -4,15 +4,21 @@ csproj="SchneiderMeterDriver.csproj" exe="SchneiderMeterDriver" #remote="10.2.1.6" remote="10.2.4.155" - -netVersion="net6.0" platform="linux-arm" +netVersion="net6.0" config="Release" host="root@$remote" dir="/opt/innovenergy/$exe" set -e +# Detect the current platform +#if uname -m | grep -i 'arm' > /dev/null; then + +#else + # platform="linux-x64" +#fi + dotnet publish "$csproj" -c $config -r $platform -p:SuppressTrimmAnalysisWarnings=true -p:PublishSingleFile=true -p:PublishTrimmed=true -p:DebugType=None -p:DebugSymbols=false --self-contained true rsync -av "bin/$config/$netVersion/$platform/publish/" "$host:$dir" #clear diff --git a/csharp/Lib/Devices/IEM3kGridMeter/IEM3kGridMeterDevice.cs b/csharp/Lib/Devices/IEM3kGridMeter/IEM3kGridMeterDevice.cs index 863a30c9f..e93e75cb0 100644 --- a/csharp/Lib/Devices/IEM3kGridMeter/IEM3kGridMeterDevice.cs +++ b/csharp/Lib/Devices/IEM3kGridMeter/IEM3kGridMeterDevice.cs @@ -49,4 +49,7 @@ public class Iem3KGridMeterDevice: ModbusDevice } -} \ No newline at end of file +} + + + diff --git a/csharp/Lib/Devices/IEM3kGridMeter/IEM3kGridMeterRegisters.cs b/csharp/Lib/Devices/IEM3kGridMeter/IEM3kGridMeterRegisters.cs index fb0183b76..b6e16b630 100644 --- a/csharp/Lib/Devices/IEM3kGridMeter/IEM3kGridMeterRegisters.cs +++ b/csharp/Lib/Devices/IEM3kGridMeter/IEM3kGridMeterRegisters.cs @@ -22,13 +22,24 @@ public class Iem3KGridMeterRegisters //: IAc3Meter [HoldingRegister(3056)] public Float32 ActivePowerL2; [HoldingRegister(3058)] public Float32 ActivePowerL3; - //[HoldingRegister(3000)] private Float32 _CurrentL1; - //[HoldingRegister(3002)] private Float32 _CurrentL2; - //[HoldingRegister(3004)] private Float32 _CurrentL3; + [HoldingRegister(3000)] public Float32 _CurrentL1; + [HoldingRegister(3002)] public Float32 _CurrentL2; + [HoldingRegister(3004)] public Float32 _CurrentL3; // - //[HoldingRegister(3028)] private Float32 _VoltageL1N; - //[HoldingRegister(3030)] private Float32 _VoltageL2N; - //[HoldingRegister(3032)] private Float32 _VoltageL3N; + [HoldingRegister(3028)] public Float32 _VoltageL1N; + [HoldingRegister(3030)] public Float32 _VoltageL2N; + [HoldingRegister(3032)] public Float32 _VoltageL3N; + + [HoldingRegister(3518)] public Float32 ActiveEnergyImportL1; + [HoldingRegister(3522)] public Float32 ActiveEnergyImportL2; + [HoldingRegister(3526)] public Float32 ActiveEnergyImportL3; + + [HoldingRegister(45100)] public Float32 TotalActiveImport; + [HoldingRegister(45102)] public Float32 TotalActiveExport; + + + + // //[HoldingRegister(3110)] private Float32 _Frequency; @@ -36,10 +47,6 @@ public class Iem3KGridMeterRegisters //: IAc3Meter //[HoldingRegister(9014)] private Float32 _ReactivePowerL2; //[HoldingRegister(9016)] private Float32 _ReactivePowerL3; - //[HoldingRegister(9012)] private Float32 _ReactivePowerL1; - //[HoldingRegister(9014)] private Float32 _ReactivePowerL2; - //[HoldingRegister(9016)] private Float32 _ReactivePowerL3; - //[HoldingRegister(9022)] private Float32 _ApparentPowerL1; //[HoldingRegister(9024)] private Float32 _ApparentPowerL2; //[HoldingRegister(9026)] private Float32 _ApparentPowerL3; diff --git a/csharp/Lib/Protocols/Modbus/Channels/RemoteSerialChannel.cs b/csharp/Lib/Protocols/Modbus/Channels/RemoteSerialChannel.cs index c42299221..98ecd1cd5 100644 --- a/csharp/Lib/Protocols/Modbus/Channels/RemoteSerialChannel.cs +++ b/csharp/Lib/Protocols/Modbus/Channels/RemoteSerialChannel.cs @@ -4,7 +4,7 @@ using System.Reactive.Linq; using CliWrap; using InnovEnergy.Lib.Utils; -/*namespace InnovEnergy.Lib.Protocols.Modbus.Channels; +namespace InnovEnergy.Lib.Protocols.Modbus.Channels; public record RemoteSerialConnection ( @@ -207,93 +207,4 @@ public class RemoteSerialChannel : ConnectionChannel { connection.Write(data); } -}*/ - -using System; -using System.IO.Ports; -using CliWrap; -using InnovEnergy.Lib.Utils; - -namespace InnovEnergy.Lib.Protocols.Modbus.Channels -{ - public class RemoteSerialChannel : ConnectionChannel, IDisposable - { - private readonly Command _Command; - private readonly TcpChannel _TcpChannel; - - const string SsDir = "/opt/victronenergy/serial-starter"; - const string KillTasks = "kill $!"; - - private CancellationTokenSource _CancellationTokenSource = new CancellationTokenSource(); - - private CommandTask? _CommandTask; - - public RemoteSerialChannel(SshHost host, string tty, int baudRate, Parity parity, int dataBits, int stopBits) - { - const int port = 6855; - - tty = tty.EnsureStartsWith("/dev/"); - - var configureTty = ConfigureTty(tty, baudRate, parity, stopBits, dataBits); - - var stopTty = $"{SsDir}/stop-tty.sh {tty}"; - var startTty = $"{SsDir}/start-tty.sh {tty}"; - - var socat = $"socat TCP-LISTEN:{port},nodelay {tty},raw"; - - var script = $"{configureTty} && {socat}"; - - _Command = host.Command.AppendArgument(script); - _TcpChannel = new TcpChannel(host.HostName, port); - } - - private static string ConfigureTty(string tty, int baudRate, Parity parity, int stopBits, int dataBits) - { - var oParity = parity switch - { - Parity.Even => "parenb -parodd", - Parity.Odd => "parenb parodd", - Parity.None => "-parenb", - _ => throw new NotImplementedException() - }; - - var oStopBits = stopBits switch - { - 1 => "-cstopb", - 2 => "cstopb", - _ => throw new NotImplementedException() - }; - - var oDataBits = "cs" + dataBits; - - return $"stty -F {tty} {baudRate} {oDataBits} {oStopBits} {oParity}"; - } - - protected override TcpChannel Open() - { - return _TcpChannel; - } - - protected override void Close(TcpChannel connection) - { - _CancellationTokenSource.Cancel(); - connection.Dispose(); - _CancellationTokenSource = new CancellationTokenSource(); - } - - protected override IReadOnlyList Read(TcpChannel connection, int nBytes) - { - return connection.Read(nBytes); - } - - protected override void Write(TcpChannel connection, IReadOnlyList data) - { - connection.Write(data); - } - - public void Dispose() - { - Close(_TcpChannel); - } - } -} +} \ No newline at end of file diff --git a/csharp/Lib/Protocols/Modbus/Clients/ModbusTcpClient.cs b/csharp/Lib/Protocols/Modbus/Clients/ModbusTcpClient.cs index 41baf7fcb..ff206717f 100644 --- a/csharp/Lib/Protocols/Modbus/Clients/ModbusTcpClient.cs +++ b/csharp/Lib/Protocols/Modbus/Clients/ModbusTcpClient.cs @@ -184,4 +184,4 @@ public class ModbusTcpClient : ModbusClient return new MbData(rxFrm.RegistersRead.RawData, readAddress, Endian); } -} +} \ No newline at end of file diff --git a/csharp/Lib/Protocols/Modbus/Slaves/ModbusSlave.cs b/csharp/Lib/Protocols/Modbus/Slaves/ModbusSlave.cs index 8c78dbb31..622de280e 100644 --- a/csharp/Lib/Protocols/Modbus/Slaves/ModbusSlave.cs +++ b/csharp/Lib/Protocols/Modbus/Slaves/ModbusSlave.cs @@ -1,7 +1,7 @@ using InnovEnergy.Lib.Protocols.Modbus.Channels; using InnovEnergy.Lib.Protocols.Modbus.Clients; -/*namespace InnovEnergy.Lib.Protocols.Modbus.Slaves; +namespace InnovEnergy.Lib.Protocols.Modbus.Slaves; public static class ModbusSlave { @@ -52,58 +52,4 @@ public static class ModbusSlave return new ModbusDevice(modbusClient); } -}*/ - -using InnovEnergy.Lib.Protocols.Modbus.Channels; -using InnovEnergy.Lib.Protocols.Modbus.Clients; - -namespace InnovEnergy.Lib.Protocols.Modbus.Slaves -{ - public static class ModbusSlave - { - public static Func ModbusTcp(this Channel channel) - { - ModbusTcpClient SlaveId(byte slaveId) => new ModbusTcpClient((TcpChannel)channel, slaveId); - return SlaveId; - } - - public static Func ModbusRtu(this Channel channel) - { - ModbusRtuClient SlaveId(byte slaveId) => new ModbusRtuClient(channel, slaveId); - return SlaveId; - } - - public static Func ModbusTcp(this Channel channel) where R : notnull, new() - { - ModbusTcpClient SlaveId(byte slaveId) - { - return new ModbusTcpClient((TcpChannel)channel, slaveId); - } - - return SlaveId; - } - - public static Func ModbusRtu(this Channel channel) where R : notnull, new() - { - ModbusRtuClient SlaveId(byte slaveId) => new ModbusRtuClient(channel, slaveId); - return SlaveId; - } - - public static ModbusDevice TcpSlave(this Channel channel, byte slaveId) where T : notnull, new() - { - var client = new ModbusTcpClient((TcpChannel)channel, slaveId); - return new ModbusDevice(client); - } - - public static ModbusDevice RtuSlave(this Channel channel, byte slaveId) where T : notnull, new() - { - var client = new ModbusRtuClient(channel, slaveId); - return new ModbusDevice(client); - } - - public static ModbusDevice Slave(this ModbusClient modbusClient) where T : notnull, new() - { - return new ModbusDevice(modbusClient); - } - } } diff --git a/python/dbus-fz-sonick-48tl-with-s3/.dbus-fzsonick-48tl.py.kate-swp b/python/dbus-fz-sonick-48tl-with-s3/.dbus-fzsonick-48tl.py.kate-swp new file mode 100644 index 000000000..e7169fea2 Binary files /dev/null and b/python/dbus-fz-sonick-48tl-with-s3/.dbus-fzsonick-48tl.py.kate-swp differ diff --git a/python/dbus-fz-sonick-48tl-with-s3/dbus-fzsonick-48tl.py b/python/dbus-fz-sonick-48tl-with-s3/dbus-fzsonick-48tl.py index cec68cd43..3caef9188 100755 --- a/python/dbus-fz-sonick-48tl-with-s3/dbus-fzsonick-48tl.py +++ b/python/dbus-fz-sonick-48tl-with-s3/dbus-fzsonick-48tl.py @@ -193,17 +193,19 @@ def update_state_from_dictionaries(current_warnings, current_alarms, node_number alarms_number_list = [] for node_number in node_numbers: cnt = 0 - for alarm_value in current_alarms.values(): - if alarm_value: - cnt+=1 + for i, alarm_value in enumerate(current_alarms.values()): + if list(current_alarms.keys())[i].split("/")[3] == node_number: + if alarm_value: + cnt+=1 alarms_number_list.append(cnt) warnings_number_list = [] for node_number in node_numbers: cnt = 0 - for warning_value in current_warnings.values(): - if warning_value: - cnt+=1 + for i, alarm_value in enumerate(current_warnings.values()): + if list(current_warnings.keys())[i].split("/")[3] == node_number: + if warning_value: + cnt+=1 warnings_number_list.append(cnt) # Evaluate alarms diff --git a/typescript/frontend-marios2/src/content/dashboards/History/History.tsx b/typescript/frontend-marios2/src/content/dashboards/History/History.tsx index 86923395e..25de1adce 100644 --- a/typescript/frontend-marios2/src/content/dashboards/History/History.tsx +++ b/typescript/frontend-marios2/src/content/dashboards/History/History.tsx @@ -124,7 +124,7 @@ function HistoryOfActions(props: HistoryProps) {
+
{action.userName} @@ -203,7 +202,6 @@ function HistoryOfActions(props: HistoryProps) { fontWeight="bold" color="text.primary" gutterBottom - noWrap > {datePart} @@ -222,7 +220,6 @@ function HistoryOfActions(props: HistoryProps) { fontWeight="bold" color="text.primary" gutterBottom - noWrap > {timePart} @@ -230,7 +227,7 @@ function HistoryOfActions(props: HistoryProps) {
{action.description}
- +
); })}