Merge branch 'main' of https://git.innov.energy/Innovenergy/git_trunk
This commit is contained in:
commit
ba9b134f07
|
@ -5,20 +5,20 @@ namespace InnovEnergy.App.SaliMax;
|
||||||
|
|
||||||
public class CustomLogger : ILogger
|
public class CustomLogger : ILogger
|
||||||
{
|
{
|
||||||
private readonly String _logFilePath;
|
private readonly String _LogFilePath;
|
||||||
private readonly Int64 _maxFileSizeBytes;
|
private readonly Int64 _MaxFileSizeBytes;
|
||||||
private readonly Int32 _maxLogFileCount;
|
private readonly Int32 _MaxLogFileCount;
|
||||||
private Int64 _currentFileSizeBytes;
|
private Int64 _CurrentFileSizeBytes;
|
||||||
|
|
||||||
public CustomLogger(String logFilePath, Int64 maxFileSizeBytes, Int32 maxLogFileCount)
|
public CustomLogger(String logFilePath, Int64 maxFileSizeBytes, Int32 maxLogFileCount)
|
||||||
{
|
{
|
||||||
_logFilePath = logFilePath;
|
_LogFilePath = logFilePath;
|
||||||
_maxFileSizeBytes = maxFileSizeBytes;
|
_MaxFileSizeBytes = maxFileSizeBytes;
|
||||||
_maxLogFileCount = maxLogFileCount;
|
_MaxLogFileCount = maxLogFileCount;
|
||||||
_currentFileSizeBytes = File.Exists(logFilePath) ? new FileInfo(logFilePath).Length : 0;
|
_CurrentFileSizeBytes = File.Exists(logFilePath) ? new FileInfo(logFilePath).Length : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IDisposable BeginScope<TState>(TState state)
|
public IDisposable? BeginScope<TState>(TState state) where TState : notnull
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
@ -33,35 +33,34 @@ public class CustomLogger : ILogger
|
||||||
var logMessage = formatter(state, exception!);
|
var logMessage = formatter(state, exception!);
|
||||||
|
|
||||||
// Check the file size and rotate the log file if necessary
|
// Check the file size and rotate the log file if necessary
|
||||||
if (_currentFileSizeBytes + logMessage.Length >= _maxFileSizeBytes)
|
if (_CurrentFileSizeBytes + logMessage.Length >= _MaxFileSizeBytes)
|
||||||
{
|
{
|
||||||
RotateLogFile();
|
RotateLogFile();
|
||||||
_currentFileSizeBytes = 0;
|
_CurrentFileSizeBytes = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write the log message to the file
|
// Write the log message to the file
|
||||||
File.AppendAllText(_logFilePath, logMessage + Environment.NewLine);
|
File.AppendAllText(_LogFilePath, logMessage + Environment.NewLine);
|
||||||
_currentFileSizeBytes += logMessage.Length;
|
_CurrentFileSizeBytes += logMessage.Length;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RotateLogFile()
|
private void RotateLogFile()
|
||||||
{
|
{
|
||||||
// Check the log file count and delete the oldest file if necessary
|
// Check the log file count and delete the oldest file if necessary
|
||||||
var logFileDir = Path.GetDirectoryName(_logFilePath)!;
|
var logFileDir = Path.GetDirectoryName(_LogFilePath)!;
|
||||||
var logFileExt = Path.GetExtension(_logFilePath);
|
var logFileExt = Path.GetExtension(_LogFilePath);
|
||||||
var logFileBaseName = Path.GetFileNameWithoutExtension(_logFilePath);
|
var logFileBaseName = Path.GetFileNameWithoutExtension(_LogFilePath);
|
||||||
|
|
||||||
var logFiles = Directory.GetFiles(logFileDir, $"{logFileBaseName}_*{logFileExt}")
|
var logFiles = Directory
|
||||||
.OrderBy(file => file)
|
.GetFiles(logFileDir, $"{logFileBaseName}_*{logFileExt}")
|
||||||
.ToList();
|
.OrderBy(file => file)
|
||||||
|
.ToList();
|
||||||
|
|
||||||
if (logFiles.Count >= _maxLogFileCount)
|
if (logFiles.Count >= _MaxLogFileCount)
|
||||||
{
|
|
||||||
File.Delete(logFiles.First());
|
File.Delete(logFiles.First());
|
||||||
}
|
|
||||||
|
|
||||||
// Rename the current log file with a timestamp
|
// Rename the current log file with a timestamp
|
||||||
var logFileBackupPath = Path.Combine(logFileDir, $"{logFileBaseName}_{UnixTime.Now}{logFileExt}");
|
var logFileBackupPath = Path.Combine(logFileDir, $"{logFileBaseName}_{UnixTime.Now}{logFileExt}");
|
||||||
File.Move(_logFilePath, logFileBackupPath);
|
File.Move(_LogFilePath, logFileBackupPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -241,11 +241,11 @@ internal static class Program
|
||||||
// Voltage Measurement Values
|
// Voltage Measurement Values
|
||||||
//var inverterVoltage = new Voltage [(Int32)s.AcDc.Ac.L1.Voltage, (Int32)s.AcDc.Ac.L2.Voltage, (Int32)s.AcDc.Ac.L3.Voltage];
|
//var inverterVoltage = new Voltage [(Int32)s.AcDc.Ac.L1.Voltage, (Int32)s.AcDc.Ac.L2.Voltage, (Int32)s.AcDc.Ac.L3.Voltage];
|
||||||
//var dcLinkVoltage = s.DcDc.Dc.Link.Voltage;
|
//var dcLinkVoltage = s.DcDc.Dc.Link.Voltage;
|
||||||
var dc48Voltage = s.DcDc.Dc.Battery.Voltage;
|
var dc48Voltage = s.DcDc.Dc.Battery.Voltage.ToDisplayString();
|
||||||
var batteryVoltage = s.Battery.Dc.Voltage;
|
var batteryVoltage = s.Battery.Dc.Voltage.ToDisplayString();
|
||||||
var batterySoc = s.Battery.Soc;
|
var batterySoc = s.Battery.Soc.ToDisplayString();
|
||||||
var batteryCurrent = s.Battery.Dc.Current;
|
var batteryCurrent = s.Battery.Dc.Current.ToDisplayString();
|
||||||
var batteryTemp = s.Battery.Temperature;
|
var batteryTemp = s.Battery.Temperature.ToDisplayString();
|
||||||
|
|
||||||
var gridBusColumn = ColumnBox("Pv", "Grid Bus", "Load" , gridVoltageByPhase , gridLoadPower);
|
var gridBusColumn = ColumnBox("Pv", "Grid Bus", "Load" , gridVoltageByPhase , gridLoadPower);
|
||||||
var islandBusColumn = ColumnBox("Pv", "Island Bus", "Load" , inverterPowerByPhase, islandLoadPower);
|
var islandBusColumn = ColumnBox("Pv", "Island Bus", "Load" , inverterPowerByPhase, islandLoadPower);
|
||||||
|
@ -260,10 +260,10 @@ internal static class Program
|
||||||
var gridBox = TextBlock.AlignLeft(gridPowerByPhase).TitleBox("Grid");
|
var gridBox = TextBlock.AlignLeft(gridPowerByPhase).TitleBox("Grid");
|
||||||
var inverterBox = TextBlock.AlignLeft(inverterPowerByAcDc).TitleBox("Inverter");
|
var inverterBox = TextBlock.AlignLeft(inverterPowerByAcDc).TitleBox("Inverter");
|
||||||
var dcDcBox = TextBlock.AlignLeft(dc48Voltage).TitleBox("DC/DC");
|
var dcDcBox = TextBlock.AlignLeft(dc48Voltage).TitleBox("DC/DC");
|
||||||
var batteryAvgBox = TextBlock.AlignLeft(batteryVoltage.ToDisplayString(),
|
var batteryAvgBox = TextBlock.AlignLeft(batteryVoltage,
|
||||||
batterySoc.ToDisplayString(),
|
batterySoc,
|
||||||
batteryCurrent.ToDisplayString(),
|
batteryCurrent,
|
||||||
batteryTemp.ToDisplayString())
|
batteryTemp)
|
||||||
.TitleBox("Battery");
|
.TitleBox("Battery");
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<Import Project="../../InnovEnergy.Lib.props"/>
|
<Import Project="../../InnovEnergy.Lib.props" />
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<RootNamespace>InnovEnergy.Lib.Devices.AMPT</RootNamespace>
|
<RootNamespace>InnovEnergy.Lib.Devices.AMPT</RootNamespace>
|
||||||
|
@ -8,11 +8,7 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="../../Protocols/Modbus/Modbus.csproj" />
|
<ProjectReference Include="../../Protocols/Modbus/Modbus.csproj" />
|
||||||
<ProjectReference Include="../../Utils/Utils.csproj" />
|
<ProjectReference Include="../../Utils/Utils.csproj" />
|
||||||
<ProjectReference Include="../../StatusApi/StatusApi.csproj" />
|
<ProjectReference Include="../../Units/Units.csproj" />
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="DecimalMath.DecimalEx" Version="1.0.2" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
@ -1,28 +0,0 @@
|
||||||
using InnovEnergy.Lib.Protocols.Modbus.Channels;
|
|
||||||
using InnovEnergy.Lib.Protocols.Modbus.Clients;
|
|
||||||
using InnovEnergy.Lib.Units;
|
|
||||||
using InnovEnergy.Lib.Utils;
|
|
||||||
|
|
||||||
namespace InnovEnergy.Lib.Devices.AMPT;
|
|
||||||
|
|
||||||
public static class Program
|
|
||||||
{
|
|
||||||
public static Task Main(string[] args)
|
|
||||||
{
|
|
||||||
var ch = new TcpChannel("localhost", 5005);
|
|
||||||
var cl = new ModbusTcpClient(ch, 1);
|
|
||||||
var d = new AmptDevices(cl);
|
|
||||||
|
|
||||||
while (true)
|
|
||||||
{
|
|
||||||
AmptStatus x = d.Read();
|
|
||||||
|
|
||||||
x.ToCsv().WriteLine();
|
|
||||||
|
|
||||||
//Console.WriteLine(x);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//Console.WriteLine(x);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,20 +0,0 @@
|
||||||
using InnovEnergy.Lib.Units;
|
|
||||||
using InnovEnergy.Lib.Utils;
|
|
||||||
|
|
||||||
namespace InnovEnergy.Lib.Devices.Adam6360D;
|
|
||||||
|
|
||||||
public static class Program
|
|
||||||
{
|
|
||||||
public static Task Main(String[] args)
|
|
||||||
{
|
|
||||||
var d = new Adam6360DDevice("localhost", 2, 5006);
|
|
||||||
|
|
||||||
while (true)
|
|
||||||
{
|
|
||||||
var x = d.Read();
|
|
||||||
x.ToCsv().WriteLine();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,35 +0,0 @@
|
||||||
using InnovEnergy.Lib.Protocols.Modbus.Channels;
|
|
||||||
using InnovEnergy.Lib.Units;
|
|
||||||
using InnovEnergy.Lib.Utils;
|
|
||||||
using static InnovEnergy.Lib.Devices.Battery48TL.Battery48TlDevice;
|
|
||||||
|
|
||||||
namespace InnovEnergy.Lib.Devices.Battery48TL;
|
|
||||||
|
|
||||||
public static class Program
|
|
||||||
{
|
|
||||||
public static Task Main(string[] args)
|
|
||||||
{
|
|
||||||
var host = new SshHost("10.2.3.115", "ie-entwicklung");
|
|
||||||
var channel = new RemoteSerialChannel(host, "ttyUSB0", BaudRate, Parity, DataBits, StopBits);
|
|
||||||
|
|
||||||
var nodes = new Byte[] { 2 };
|
|
||||||
|
|
||||||
var devices = nodes
|
|
||||||
.Select(n => new Battery48TlDevice(channel, n))
|
|
||||||
.ToList();
|
|
||||||
|
|
||||||
var d = new Battery48TlDevices(devices);
|
|
||||||
|
|
||||||
//var options = new JsonSerializerOptions { WriteIndented = true, Converters = { new JsonStringEnumConverter() }};
|
|
||||||
|
|
||||||
|
|
||||||
while (true)
|
|
||||||
{
|
|
||||||
var x = d.Read();
|
|
||||||
x.ToCsv().WriteLine();
|
|
||||||
|
|
||||||
//(x, options).Apply(JsonSerializer.Serialize).WriteLine();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,24 +0,0 @@
|
||||||
using InnovEnergy.Lib.Protocols.Modbus.Channels;
|
|
||||||
using InnovEnergy.Lib.Protocols.Modbus.Clients;
|
|
||||||
using InnovEnergy.Lib.Units;
|
|
||||||
using InnovEnergy.Lib.Utils;
|
|
||||||
|
|
||||||
namespace InnovEnergy.Lib.Devices.EmuMeter;
|
|
||||||
|
|
||||||
public static class Program
|
|
||||||
{
|
|
||||||
public static Task Main(string[] args)
|
|
||||||
{
|
|
||||||
var ch = new TcpChannel("localhost", 5004);
|
|
||||||
var cl = new ModbusTcpClient(ch, 1);
|
|
||||||
var d = new EmuMeterDevice(cl);
|
|
||||||
|
|
||||||
while (true)
|
|
||||||
{
|
|
||||||
var x = d.Read();
|
|
||||||
x.ToCsv().WriteLine();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,61 +0,0 @@
|
||||||
// using InnovEnergy.Lib.Devices.Trumpf.SystemControl;
|
|
||||||
// using InnovEnergy.Lib.Devices.Trumpf.SystemControl.DataTypes;
|
|
||||||
// using InnovEnergy.Lib.Units;
|
|
||||||
// using InnovEnergy.Lib.Utils;
|
|
||||||
//
|
|
||||||
// namespace InnovEnergy.Lib.Devices.Trumpf.TruConvertAc;
|
|
||||||
//
|
|
||||||
// // TODO :remove
|
|
||||||
//
|
|
||||||
// public static class Program
|
|
||||||
// {
|
|
||||||
// public static void Main(String[] args)
|
|
||||||
// {
|
|
||||||
// var sc = new SystemControlDevice("localhost", 5001);
|
|
||||||
// var acDc1 = sc.AcDcSlave(1);
|
|
||||||
// var acDc2 = sc.AcDcSlave(2);
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// while (true)
|
|
||||||
// {
|
|
||||||
// "================================================".WriteLine();
|
|
||||||
//
|
|
||||||
// var r = sc.Read();
|
|
||||||
//
|
|
||||||
// Console.WriteLine(DateTime.Now);
|
|
||||||
// r.ToString().Replace(",", "\n").Replace(" {", "\n").WriteLine("\n");
|
|
||||||
//
|
|
||||||
// var c = r with
|
|
||||||
// {
|
|
||||||
// UseSlaveIdForAddressing = true,
|
|
||||||
// ReferenceFrame = ReferenceFrame.Consumer,
|
|
||||||
// GridType = GridType.GridTied400V50Hz,
|
|
||||||
// SystemConfig = SystemConfig.AcDcAndDcDc,
|
|
||||||
// CommunicationTimeout = null,
|
|
||||||
// SlaveErrorHandling = SlaveErrorHandling.Relaxed,
|
|
||||||
// SubSlaveErrorHandling = SubSlaveErrorHandling.Off
|
|
||||||
// };
|
|
||||||
//
|
|
||||||
// sc.Write(c);
|
|
||||||
//
|
|
||||||
// var s1 = acDc1.Read();
|
|
||||||
//
|
|
||||||
// s1.ToCsv().Replace(",", "\n").Replace(" {", "\n").WriteLine("\n");
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// s1.ResetAlarmsAndWarnings = true;
|
|
||||||
// s1.PowerStageEnable = true;
|
|
||||||
//
|
|
||||||
// acDc1.Write(s1);
|
|
||||||
//
|
|
||||||
// var s2 = acDc2.Read();
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// s2.ToString().Replace(",", "\n").Replace(" {", "\n").WriteLine("\n");
|
|
||||||
//
|
|
||||||
// acDc2.Write(s2 with { ResetAlarmsAndWarnings = true, PowerStageEnable = true });
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
// }
|
|
Loading…
Reference in New Issue