From 5a3da7434bcc912767c69912af534102b0da9802 Mon Sep 17 00:00:00 2001 From: ig Date: Tue, 13 Jun 2023 13:01:48 +0200 Subject: [PATCH] Trumpf V2 --- .../Doc/Zustandsdiagramm_IBN_Standard.graphml | 503 ++++++++++++++++++ .../SaliMax/Doc/Zustandsmatrix_Salimax.xlsx | Bin 0 -> 10911 bytes csharp/App/SaliMax/run (Salimax 0001).sh | 33 ++ .../SaliMax/run (SalimnaxProto Meiringen).sh | 34 ++ csharp/App/SaliMax/src/DeviceConfig.cs | 42 ++ csharp/App/SaliMax/src/Logfile.cs | 67 +++ csharp/App/SaliMax/tunnelsToProto.sh | 44 ++ csharp/App/SaliMax/tunnelstoSalimax0001.sh | 45 ++ 8 files changed, 768 insertions(+) create mode 100644 csharp/App/SaliMax/Doc/Zustandsdiagramm_IBN_Standard.graphml create mode 100644 csharp/App/SaliMax/Doc/Zustandsmatrix_Salimax.xlsx create mode 100755 csharp/App/SaliMax/run (Salimax 0001).sh create mode 100755 csharp/App/SaliMax/run (SalimnaxProto Meiringen).sh create mode 100644 csharp/App/SaliMax/src/DeviceConfig.cs create mode 100644 csharp/App/SaliMax/src/Logfile.cs create mode 100755 csharp/App/SaliMax/tunnelsToProto.sh create mode 100755 csharp/App/SaliMax/tunnelstoSalimax0001.sh diff --git a/csharp/App/SaliMax/Doc/Zustandsdiagramm_IBN_Standard.graphml b/csharp/App/SaliMax/Doc/Zustandsdiagramm_IBN_Standard.graphml new file mode 100644 index 000000000..1968f44f8 --- /dev/null +++ b/csharp/App/SaliMax/Doc/Zustandsdiagramm_IBN_Standard.graphml @@ -0,0 +1,503 @@ + + + + + + + + + + + + + + + + + + + + + + + 2 +Aus (mit Netz) + + + + + + + + + + + 3 + + + + + + + + + + + 4 + + + + + + + + + + + 5 + + + + + + + + + + + 6 + + + + + + + + + + + 7 + + + + + + + + + + + 8 + + + + + + + + + + + 9 + + + + + + + + + + + 4 + + + + + + + + + + + 11 + + + + + + + + + + + 12 + + + + + + + + + + + 13 + + + + + + + + + + + 14 + + + + + + + + + + + 15 + + + + + + + + + + + 16 +Netzparallel + + + + + + + + + + + 17 + + + + + + + + + + + 18 + + + + + + + + + + + 19 + + + + + + + + + + + 20 + + + + + + + + + + + 21 +Inselbetrieb + + + + + + + + + + + 22 + + + + + + + + + + + 23 + + + + + + + + + + + 24 + + + + + + + + + + + 1 + + + + + + + + + + + 9 + + + + + + + + + + + 13 + + + + + + + + + + + 15 + + + + + + + + + + + 17 + + + + + + + + + + + 1 +Aus (ohne Netz) + + + + + + + + + + + K1 schliesst + + + + + + + + + + + Uebergang nach Off + + + + + + + + + + + Uebergang nach Netzparallel + + + + + + + + + + + K3 öffnet + + + + + + + + + + + K2 schliesst + + + + + + + + + + + K3 schliesst + + + + + + + + + + + K1 öffnet + + + + + + + + + + + K2 öffnet + + + + + + + + + + + K3 öffnet + + + + + + + + + + + K3 schliesst + + + + + + + + + + + Uebergang nach Off + + + + + + + + + + + Uebergan nach Inselbetrieb + + + + + + + + + + + + K1 Schliesst + + + + + + + + + + + + + + + Turnoff The inverter + + + + + + + + + diff --git a/csharp/App/SaliMax/Doc/Zustandsmatrix_Salimax.xlsx b/csharp/App/SaliMax/Doc/Zustandsmatrix_Salimax.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..6cd1ceb13a707d2d3da83d8bccfdb5ab1293cc68 GIT binary patch literal 10911 zcmbVy1y~$g(oBz9a z_t_d`dZy3YUDD^gr>bNnARsZoU}0gw)ODql!G05X(EE=z`ewEa^v{1wqS~c90SJD_ zu0hmStjhwh8M%#;qK$7@2--+3@Tvo|y1Y*>-=U)+gjRHhS$lkX1m>(rTF|Zl$R)G_ zmDB>ko5^+E^STBft(_UzhBG~SP&wYqTfU{X36~K+A6ge2$ab}h5P$jYOiE(>#jfsw z9vH8Hzm2AnBh#Z^z>bgFK?s_)p>pQjC&(rrDRWa+3o$}`7e3|<72@bO4t?U1S#Eh8 zO=yVvelML@^xf+RSC3b6CTqjqJj4v{B_yCX)bH3>0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Aq5~zUw z7s0edrkr^gCOLB>Yl!ijy7VN%mh!3A@+@H^9f=1UFQT~=r{(5-(Qk;|IB!nAvpz^5 z>8&1LuUNiuHP7-eT*Q8Uh}UPpKF5RZ`ULd*&y70Ida1v)w6N2+u=}X!Y^86j`K(vB za{u%C1>!?;rAojxStTWKfBIgmf^&^Ty{NjbV6(UD$K2AC!Vy9w#2jj2yL8N(WaCcV z5|(fa04m@oluLKycf<yCM+tfi?h3*^Zp^1Jmn zl*LG--x`O3#S<^vVw7gr7`pGeCgB$UN6HiZEe7q7$Wm%?N% zv^r-Gmuq?vbWWJ40#;ez#EQ#BgI)ZP;oWYJe{bSA7eMz(g0Pe3CV#Qam7IPGRzVhV zFL~N&*1_YIL%qy(nVla+9znwj0;VziLn(W^n0uF0l_K;{ol* z?;Tms?P-6P-W}uVKL`I_^L}pC`6VWxwjR*nUyVC|4*k7s z{9F|OCEOtO{<`kJmB{}D{JkFgcR*$kd;3SgU$y5y0e?@?J||*-3C+tt0e=;B|3vwH z)An~1W3>N@@{_;(iSql#=6QqnOTK^(LCXEZcJEJ|-wEwAZT%&!ct3Ie$EN5{gx`7D z-w}`rej@zN#eN$1PlVrz#orNv2>%Ddf3?Q%%iJ>o`6cjg{tF%X^9FvO?4Q@dU(!na z+wi|u#y>~@KBYcSoWJB66n4M3(EnK;{sj2_G5$Ni80mkVhh-(8pr5aT40;`ao~tk9 H&qx0Y*M#@I literal 0 HcmV?d00001 diff --git a/csharp/App/SaliMax/run (Salimax 0001).sh b/csharp/App/SaliMax/run (Salimax 0001).sh new file mode 100755 index 000000000..a138c3067 --- /dev/null +++ b/csharp/App/SaliMax/run (Salimax 0001).sh @@ -0,0 +1,33 @@ +#!/bin/bash + +dotnet_version='net6.0' +salimax_ip= '10.2.3.104' +username='ie-entwicklung@' + +set -e + +echo -e "\n============================ Build ============================\n" + +dotnet publish \ + ./SaliMax.csproj \ + -c Release \ + -r linux-x64 + +echo -e "\n============================ Deploy ============================\n" + +rsync -v \ + ./bin/Release/$dotnet_version/linux-x64/publish/* \ + ie-entwicklung@10.2.3.104:~/salimax + +echo -e "\n============================ Restart Salimax sevice ============================\n" + +ssh -tt \ + ie-entwicklung@10.2.3.104 \ + sudo systemctl restart salimax.service + + +echo -e "\n============================ Print service output ============================\n" + +ssh -tt \ + ie-entwicklung@10.2.3.104 \ + journalctl -f -u salimax.service diff --git a/csharp/App/SaliMax/run (SalimnaxProto Meiringen).sh b/csharp/App/SaliMax/run (SalimnaxProto Meiringen).sh new file mode 100755 index 000000000..7c2defe21 --- /dev/null +++ b/csharp/App/SaliMax/run (SalimnaxProto Meiringen).sh @@ -0,0 +1,34 @@ +#!/bin/bash + + +dotnet_version='net6.0' +salimax_ip= '10.2.3.115' +username='ie-entwicklung@' + +set -e + +echo -e "\n============================ Build ============================\n" + +dotnet publish \ + ./SaliMax.csproj \ + -c Release \ + -r linux-x64 + +echo -e "\n============================ Deploy ============================\n" + +rsync -v \ + ./bin/Release/$dotnet_version/linux-x64/publish/* \ + ie-entwicklung@10.2.3.115:~/salimax + +echo -e "\n============================ Restart Salimax sevice ============================\n" + +ssh -tt \ + ie-entwicklung@10.2.3.115 \ + sudo systemctl restart salimax.service + + +echo -e "\n============================ Print service output ============================\n" + +ssh -tt \ + ie-entwicklung@10.2.3.115 \ + journalctl -f -u salimax.service diff --git a/csharp/App/SaliMax/src/DeviceConfig.cs b/csharp/App/SaliMax/src/DeviceConfig.cs new file mode 100644 index 000000000..ca7982760 --- /dev/null +++ b/csharp/App/SaliMax/src/DeviceConfig.cs @@ -0,0 +1,42 @@ +using Newtonsoft.Json; + +namespace InnovEnergy.App.SaliMax; + +public class DeviceConfig +{ + public String RelaysIp { get; set; } + public String TruConvertAcIp { get; set; } + public String TruConvertDcIp { get; set; } + public String GridMeterIp { get; set; } + public String InternalMeter { get; set; } + public String AmptIp { get; set; } + public byte[] BatteryNodes { get; set; } + public String BatteryTty { get; set; } + + [JsonConstructor] + public DeviceConfig(string relaysIp, string truConvertAcIp, string truConvertDcIp, string gridMeterIp, string internalMeter, string amptIp, byte[] batteryNodes, string batteryTty) + { + RelaysIp = relaysIp; + TruConvertAcIp = truConvertAcIp; + TruConvertDcIp = truConvertDcIp; + GridMeterIp = gridMeterIp; + InternalMeter = internalMeter; + AmptIp = amptIp; + BatteryNodes = batteryNodes; + BatteryTty = batteryTty; + } + + public static DeviceConfig? LoadDeviceConfig(String configFilePath) + { + try + { + var json = File.ReadAllText(configFilePath); + return JsonConvert.DeserializeObject(json); + } + catch (Exception e) + { + Console.WriteLine(e); + throw; + } + } +} \ No newline at end of file diff --git a/csharp/App/SaliMax/src/Logfile.cs b/csharp/App/SaliMax/src/Logfile.cs new file mode 100644 index 000000000..295d7729b --- /dev/null +++ b/csharp/App/SaliMax/src/Logfile.cs @@ -0,0 +1,67 @@ +using InnovEnergy.Lib.Time.Unix; +using Microsoft.Extensions.Logging; + +namespace InnovEnergy.App.SaliMax; + +public class CustomLogger : ILogger +{ + private readonly String _logFilePath; + private readonly Int64 _maxFileSizeBytes; + private readonly Int32 _maxLogFileCount; + private Int64 _currentFileSizeBytes; + + public CustomLogger(String logFilePath, Int64 maxFileSizeBytes, Int32 maxLogFileCount) + { + _logFilePath = logFilePath; + _maxFileSizeBytes = maxFileSizeBytes; + _maxLogFileCount = maxLogFileCount; + _currentFileSizeBytes = File.Exists(logFilePath) ? new FileInfo(logFilePath).Length : 0; + } + + public IDisposable BeginScope(TState state) + { + throw new NotImplementedException(); + } + + public Boolean IsEnabled(LogLevel logLevel) + { + return true; // Enable logging for all levels + } + + public void Log(LogLevel logLevel, EventId eventId, TState state, Exception? exception, Func formatter) + { + var logMessage = formatter(state, exception!); + + // Check the file size and rotate the log file if necessary + if (_currentFileSizeBytes + logMessage.Length >= _maxFileSizeBytes) + { + RotateLogFile(); + _currentFileSizeBytes = 0; + } + + // Write the log message to the file + File.AppendAllText(_logFilePath, logMessage + Environment.NewLine); + _currentFileSizeBytes += logMessage.Length; + } + + private void RotateLogFile() + { + // Check the log file count and delete the oldest file if necessary + var logFileDir = Path.GetDirectoryName(_logFilePath)!; + var logFileExt = Path.GetExtension(_logFilePath); + var logFileBaseName = Path.GetFileNameWithoutExtension(_logFilePath); + + var logFiles = Directory.GetFiles(logFileDir, $"{logFileBaseName}_*{logFileExt}") + .OrderBy(file => file) + .ToList(); + + if (logFiles.Count >= _maxLogFileCount) + { + File.Delete(logFiles.First()); + } + + // Rename the current log file with a timestamp + var logFileBackupPath = Path.Combine(logFileDir, $"{logFileBaseName}_{UnixTime.Now}{logFileExt}"); + File.Move(_logFilePath, logFileBackupPath); + } +} diff --git a/csharp/App/SaliMax/tunnelsToProto.sh b/csharp/App/SaliMax/tunnelsToProto.sh new file mode 100755 index 000000000..0a136e54b --- /dev/null +++ b/csharp/App/SaliMax/tunnelsToProto.sh @@ -0,0 +1,44 @@ +#!/bin/bash + +host=ie-entwicklung@10.2.3.115 + +tunnel() { + name=$1 + ip=$2 + rPort=$3 + lPort=$4 + + echo -n "localhost:$lPort $name " + ssh -nNTL "$lPort:$ip:$rPort" "$host" 2> /dev/null & + + until nc -vz 127.0.0.1 $lPort 2> /dev/null + do + echo -n . + sleep 0.3 + done + + echo "ok" +} + +echo "" + +tunnel "Trumpf Inverter (http) " 10.0.2.1 80 8001 +tunnel "Trumpf DCDC (http) " 10.0.3.1 80 8002 +tunnel "Ext Emu Meter (http) " 10.0.4.1 80 8003 +tunnel "Int Emu Meter (http) " 10.0.4.2 80 8004 +tunnel "AMPT (http) " 10.0.5.1 8080 8005 + +tunnel "Trumpf Inverter (modbus)" 10.0.2.1 502 5001 +tunnel "Trumpf DCDC (modbus) " 10.0.3.1 502 5002 +tunnel "Ext Emu Meter (modbus) " 10.0.4.1 502 5003 +tunnel "Int Emu Meter " 10.0.4.2 502 5004 +tunnel "AMPT (modbus) " 10.0.5.1 502 5005 +tunnel "Adam " 10.0.1.1 502 5006 +tunnel "Batteries " 127.0.0.1 6855 5007 + + +echo +echo "press any key to close the tunnels ..." +read -r -n 1 -s +kill $(jobs -p) +echo "done" diff --git a/csharp/App/SaliMax/tunnelstoSalimax0001.sh b/csharp/App/SaliMax/tunnelstoSalimax0001.sh new file mode 100755 index 000000000..2f5ed3520 --- /dev/null +++ b/csharp/App/SaliMax/tunnelstoSalimax0001.sh @@ -0,0 +1,45 @@ +j#!/bin/bash + +host=ie-entwicklung@10.2.3.104 + +tunnel() { + name=$1 + ip=$2 + rPort=$3 + lPort=$4 + + echo -n "localhost:$lPort $name " + ssh -nNTL "$lPort:$ip:$rPort" "$host" 2> /dev/null & + + until nc -vz 127.0.0.1 $lPort 2> /dev/null + do + echo -n . + sleep 0.3 + done + + echo "ok" +} + +echo "" + +tunnel "Trumpf Inverter (http) " 10.0.2.1 80 8001 +tunnel "Trumpf DCDC (http) " 10.0.3.1 80 8002 +tunnel "Ext Emu Meter (http) " 10.0.4.1 80 8003 +tunnel "Int Emu Meter (http) " 10.0.4.2 80 8004 +tunnel "AMPT (http) " 10.0.5.1 8080 8005 + + +tunnel "Trumpf Inverter (modbus)" 10.0.2.1 502 5001 +tunnel "Trumpf DCDC (modbus) " 10.0.3.1 502 5002 +tunnel "Ext Emu Meter (modbus) " 10.0.4.1 502 5003 +tunnel "Int Emu Meter " 10.0.4.2 502 5004 +tunnel "AMPT (modbus) " 10.0.5.1 502 5005 +tunnel "Adam " 10.0.1.1 502 5006 + + + +echo +echo "press any key to close the tunnels ..." +read -r -n 1 -s +kill $(jobs -p) +echo "done"