Update Emu meter driver for Victron

This commit is contained in:
atef 2024-11-26 11:20:34 +01:00
parent d6172e6fa8
commit a5c6d7ecb2
4 changed files with 69 additions and 8 deletions

View File

@ -28,12 +28,12 @@ public static class Config
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(s => (s.Ac.L1.Voltage + s.Ac.L2.Voltage + s.Ac.L3.Voltage) / 3, "/Ac/Voltage", "0.0 A"),
new(s => s.Ac.L1.ActivePower, "/Ac/L1/Power", "0 W"),
new(s => s.Ac.L2.ActivePower, "/Ac/L2/Power", "0 W"),
new(s => s.Ac.L3.ActivePower, "/Ac/L3/Power", "0 W"),
new(s => s.Ac.ActivePower, "/Ac/Power", "0 W"),
new(s => s.Ac.L1.Power.Active, "/Ac/L1/Power", "0 W"),
new(s => s.Ac.L2.Power.Active, "/Ac/L2/Power", "0 W"),
new(s => s.Ac.L3.Power.Active, "/Ac/L3/Power", "0 W"),
new(s => s.Ac.Power.Active, "/Ac/Power", "0 W"),
// new(s => s.EnergyImportL123, "Ac/Energy/Forward", "0.00 kWh"),
// new(s => s.EnergyExportL123, "Ac/Energy/Reverse", "0.00 kWh"),

View File

@ -25,7 +25,7 @@ public static class EmuMeterDriver
var meterStatus = Observable
.Interval(Config.UpdatePeriod)
.Select(_ => emuMeter.ReadStatus())
.Select(_ => emuMeter.Read())
.Publish();
var poller = meterStatus.Connect();

View File

@ -6,9 +6,9 @@ namespace InnovEnergy.App.EmuMeterDriver;
// TODO: Does not compile
public record Signal(Func<EmuMeterStatus, Object> Source, ObjectPath Path, String Format = "")
public record Signal(Func<EmuMeterRegisters, Object> Source, ObjectPath Path, String Format = "")
{
public VeProperty ToVeProperty(EmuMeterStatus status)
public VeProperty ToVeProperty(EmuMeterRegisters status)
{
var value = Source(status);
return new VeProperty(Path, value, String.Format($"{{0:{Format}}}", value));

View File

@ -0,0 +1,61 @@
#!/bin/bash
csproj="SchneiderMeterDriver.csproj"
exe="SchneiderMeterDriver"
remote="10.2.4.114"
platform="linux-arm"
netVersion="net6.0"
config="Release"
host="root@$remote"
dir="/opt/innovenergy/$exe"
log_dir="/var/log/SchneiderMeterDriver"
set -e
# Publish the project locally
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
# Sync the published files to the remote server
rsync -av "bin/$config/$netVersion/$platform/publish/" "$host:$dir"
# Execute commands on the remote server
ssh "$host" << 'EOF'
set -e
# Remount the root filesystem with read and write permissions
mount -o remount,rw /
# Create service and log directories
mkdir -p /opt/innovenergy/SchneiderMeterDriver/service
mkdir -p /opt/innovenergy/SchneiderMeterDriver/service/log
mkdir -p /var/log/SchneiderMeterDriver
# Create the service run script
cat << 'EOL' > /opt/innovenergy/SchneiderMeterDriver/service/run
#!/bin/sh
exec 2>&1
exec softlimit -d 200000000 -s 2000000 -a 200000000 /opt/innovenergy/SchneiderMeterDriver/SchniederDriver
EOL
chmod +x /opt/innovenergy/SchneiderMeterDriver/service/run
# Create the log run script
cat << 'EOL' > /opt/innovenergy/SchneiderMeterDriver/service/log/run
#!/bin/sh
exec 2>&1
exec multilog t s25000 n4 /var/log/SchneiderMeterDriver
EOL
chmod +x /opt/innovenergy/SchneiderMeterDriver/service/log/run
# Create the symbolic link for the service
ln -sf /opt/innovenergy/SchneiderMeterDriver/service /service/SchneiderMeterDriver
# Wait a bit for the symlink to be recognized
sleep 2
# Start the service
start SchneiderMeterDriver
EOF
echo "Deployment and service setup completed successfully."