update and uncomment the needed file
This commit is contained in:
parent
b424643213
commit
c0030d7795
|
|
@ -114,36 +114,8 @@ public static class Program
|
||||||
await DataLogging(statusrecord, timestamp); // save a csv file locally
|
await DataLogging(statusrecord, timestamp); // save a csv file locally
|
||||||
await SaveModbusTcpFile(statusrecord); // save the json file for modbuscTCP
|
await SaveModbusTcpFile(statusrecord); // save the json file for modbuscTCP
|
||||||
|
|
||||||
/* statusrecord.AcDcGrowatt.RemotePowerControl.WriteLine(" = RemotePowerControl");
|
|
||||||
|
|
||||||
statusrecord.AcDcGrowatt.EnableCommand.WriteLine(" = EnableCommand");
|
|
||||||
statusrecord.AcDcGrowatt.ControlPermession.WriteLine(" ControlPermession");*/
|
|
||||||
statusrecord.AcDcGrowatt.GridMeterPower.WriteLine(" GridMeterPower");
|
|
||||||
statusrecord.AcDcGrowatt.InverterActivePower.WriteLine(" InverterActivePower");
|
|
||||||
statusrecord.AcDcGrowatt.PhaseACurrent.WriteLine(" PhaseACurrent "); //30409 we set power here
|
|
||||||
statusrecord.AcDcGrowatt.GridAbLineVoltage.WriteLine(" GridAbLineVoltage "); //30409 we set power here
|
|
||||||
// statusrecord.AcDcGrowatt.RemotePowerControlChargeDuration.WriteLine(" = RemotePowerControlChargeDuration");
|
|
||||||
statusrecord.AcDcGrowatt.Batteries[0].Soc.WriteLine(" SOC");
|
|
||||||
statusrecord.AcDcGrowatt.Batteries[0].Power.WriteLine(" Battery Power");
|
|
||||||
statusrecord.AcDcGrowatt.Batteries[0].Current.WriteLine(" Battery Current");
|
|
||||||
statusrecord.AcDcGrowatt.Batteries[0].Voltage.WriteLine(" Battery Voltage");
|
|
||||||
/* statusrecord.AcDcGrowatt.BatteryMaxChargePower.WriteLine(" BatteryMaxChargePower "); //30409 we set power here
|
|
||||||
statusrecord.AcDcGrowatt.BatteryMaxDischargePower.WriteLine(" BatteryMaxDischargePower "); //30409 we set power here*/
|
|
||||||
|
|
||||||
statusrecord.AcDcGrowatt.SystemOperatingMode.WriteLine(" = SystemOperatingMode");
|
EssModeControl(statusrecord,EssMode.LoadPriority); // this should moved to config file
|
||||||
statusrecord.AcDcGrowatt.BatteryOperatingMode.WriteLine(" = BatteryOperatingMode");
|
|
||||||
statusrecord.AcDcGrowatt.OperatingPriority.WriteLine(" = OperatingPriority"); // 30408 this the duration
|
|
||||||
|
|
||||||
statusrecord.AcDcGrowatt.FaultMainCode.WriteLine(" = FaultMainCode"); // 30408 this the duration
|
|
||||||
statusrecord.AcDcGrowatt.FaultSubCode.WriteLine(" = FaultSubCode"); // 30408 this the duration
|
|
||||||
statusrecord.AcDcGrowatt.WarningMainCode.WriteLine(" = WarningMainCode"); // 30408 this the duration
|
|
||||||
statusrecord.AcDcGrowatt.WarningSubCode.WriteLine(" = WarningSubCode"); // 30408 this the duration
|
|
||||||
|
|
||||||
var stopTime = DateTime.Now;
|
|
||||||
Console.WriteLine(stopTime.ToString("HH:mm:ss.fff"));
|
|
||||||
Console.WriteLine("***************************** Finish Battery Data *********************************************");
|
|
||||||
|
|
||||||
EssModeControl(statusrecord,EssMode.LoadPriority);
|
|
||||||
|
|
||||||
statusrecord.ApplyDefaultSettings();
|
statusrecord.ApplyDefaultSettings();
|
||||||
|
|
||||||
|
|
@ -182,7 +154,7 @@ public static class Program
|
||||||
switch (mode)
|
switch (mode)
|
||||||
{
|
{
|
||||||
case EssMode.Off:
|
case EssMode.Off:
|
||||||
return "no mode";/*
|
return "no mode";
|
||||||
case EssMode.GridPriority:
|
case EssMode.GridPriority:
|
||||||
statusrecord.AcDcGrowatt.RemotePowerControl = true;
|
statusrecord.AcDcGrowatt.RemotePowerControl = true;
|
||||||
statusrecord.AcDcGrowatt.RemotePowerControlChargeDuration = 0; // 30408 this the duration
|
statusrecord.AcDcGrowatt.RemotePowerControlChargeDuration = 0; // 30408 this the duration
|
||||||
|
|
@ -201,7 +173,7 @@ public static class Program
|
||||||
return "Battery priority mode active";
|
return "Battery priority mode active";
|
||||||
case EssMode.LoadPriority:
|
case EssMode.LoadPriority:
|
||||||
statusrecord.AcDcGrowatt.RemotePowerControl = false;
|
statusrecord.AcDcGrowatt.RemotePowerControl = false;
|
||||||
return "Load priority mode active";*/
|
return "Load priority mode active";
|
||||||
default:
|
default:
|
||||||
throw new ArgumentOutOfRangeException(nameof(mode), mode, null);
|
throw new ArgumentOutOfRangeException(nameof(mode), mode, null);
|
||||||
}
|
}
|
||||||
|
|
@ -259,7 +231,7 @@ public static class Program
|
||||||
Warnings = warningList
|
Warnings = warningList
|
||||||
};
|
};
|
||||||
|
|
||||||
return returnedStatus;
|
return returnedStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Int32 GetInstallationId(String s3Bucket)
|
private static Int32 GetInstallationId(String s3Bucket)
|
||||||
|
|
@ -302,7 +274,7 @@ public static class Program
|
||||||
{
|
{
|
||||||
if (st is null)
|
if (st is null)
|
||||||
return;
|
return;
|
||||||
/*
|
|
||||||
st.AcDcGrowatt.BatteryMaxChargeCurrent = st.Config.MaximumChargingCurrent;
|
st.AcDcGrowatt.BatteryMaxChargeCurrent = st.Config.MaximumChargingCurrent;
|
||||||
st.AcDcGrowatt.BatteryMaxdischargeCurrent = st.Config.MaximumDischargingCurrent;
|
st.AcDcGrowatt.BatteryMaxdischargeCurrent = st.Config.MaximumDischargingCurrent;
|
||||||
st.AcDcGrowatt.EmsCommunicationFailureTime = 20; // 20 sec
|
st.AcDcGrowatt.EmsCommunicationFailureTime = 20; // 20 sec
|
||||||
|
|
@ -312,7 +284,7 @@ public static class Program
|
||||||
st.AcDcGrowatt.BatteryChargeCutoffVoltage = 100; //st.Config.BatteryChargeCutoffVoltage;
|
st.AcDcGrowatt.BatteryChargeCutoffVoltage = 100; //st.Config.BatteryChargeCutoffVoltage;
|
||||||
st.AcDcGrowatt.BatteryDischargeCutoffVoltage = 20; //st.Config.BatteryDischargeCutoffVoltage;
|
st.AcDcGrowatt.BatteryDischargeCutoffVoltage = 20; //st.Config.BatteryDischargeCutoffVoltage;
|
||||||
st.AcDcGrowatt.BatteryMaxChargeCurrent = 200; //st.Config.BatteryChargeCutoffVoltage;
|
st.AcDcGrowatt.BatteryMaxChargeCurrent = 200; //st.Config.BatteryChargeCutoffVoltage;
|
||||||
st.AcDcGrowatt.BatteryMaxdischargeCurrent = 200; //st.Config.BatteryChargeCutoffVoltage;*/
|
st.AcDcGrowatt.BatteryMaxdischargeCurrent = 200; //st.Config.BatteryChargeCutoffVoltage;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -354,13 +326,13 @@ public static class Program
|
||||||
private static async Task SaveModbusTcpFile(StatusRecord status)
|
private static async Task SaveModbusTcpFile(StatusRecord status)
|
||||||
{
|
{
|
||||||
var modbusData = new Dictionary<String, UInt16>();
|
var modbusData = new Dictionary<String, UInt16>();
|
||||||
var protcolNumber = 2.0;
|
const Double protcolNumber = 1.1;
|
||||||
var pv1Power = status.AcDcGrowatt.Pv1Current * status.AcDcGrowatt.Pv1Voltage;
|
var pv1Power = status.AcDcGrowatt.Pv1Current * status.AcDcGrowatt.Pv1Voltage;
|
||||||
var pv2Power = status.AcDcGrowatt.Pv2Current * status.AcDcGrowatt.Pv2Voltage;
|
var pv2Power = status.AcDcGrowatt.Pv2Current * status.AcDcGrowatt.Pv2Voltage;
|
||||||
|
|
||||||
// SYSTEM DATA
|
// SYSTEM DATA
|
||||||
var result1 = ConvertToModbusRegisters((protcolNumber * 10), "UInt16", 30000); // this to be updated to modbusTCP version
|
var result1 = ConvertToModbusRegisters((protcolNumber * 10), "UInt16", 30000); // this to be updated to modbusTCP version
|
||||||
// var result2 = ConvertToModbusRegisters(status.AcDcGrowatt.SystemDateTime.ToUnixTime(), "UInt32", 30001);
|
var result2 = ConvertToModbusRegisters(status.AcDcGrowatt.SystemDateTime.ToUnixTime(), "UInt32", 30001);
|
||||||
var result3 = ConvertToModbusRegisters(status.AcDcGrowatt.SystemOperatingMode, "UInt16", 30003);
|
var result3 = ConvertToModbusRegisters(status.AcDcGrowatt.SystemOperatingMode, "UInt16", 30003);
|
||||||
var result17 = ConvertToModbusRegisters(status.AcDcGrowatt.OperatingPriority, "UInt16", 30004);
|
var result17 = ConvertToModbusRegisters(status.AcDcGrowatt.OperatingPriority, "UInt16", 30004);
|
||||||
|
|
||||||
|
|
@ -388,7 +360,7 @@ public static class Program
|
||||||
// Merge all results into one dictionary
|
// Merge all results into one dictionary
|
||||||
var allResults = new[]
|
var allResults = new[]
|
||||||
{
|
{
|
||||||
result1,/* result2, */result3, result17, result4, result5, result6, result7, result8,
|
result1,result2, result3, result17, result4, result5, result6, result7, result8,
|
||||||
result9, result10, result11, result12, result13, result14, result15, result16, result18, result19
|
result9, result10, result11, result12, result13, result14, result15, result16, result18, result19
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,6 @@ public partial class WITGrowatRecord
|
||||||
|
|
||||||
public Int32 MeterPower => _MeterPower;
|
public Int32 MeterPower => _MeterPower;
|
||||||
public ActivePower GridMeterPower => _GridPower;
|
public ActivePower GridMeterPower => _GridPower;
|
||||||
|
|
||||||
public Int32 BatteryPower1
|
public Int32 BatteryPower1
|
||||||
{
|
{
|
||||||
get => _BatteryPower1;
|
get => _BatteryPower1;
|
||||||
|
|
@ -56,7 +55,7 @@ public partial class WITGrowatRecord
|
||||||
public DcPower Pv1InpuPower => _Pv1InpuPower;
|
public DcPower Pv1InpuPower => _Pv1InpuPower;
|
||||||
|
|
||||||
// ********************************** Holding Registers (Control) *************************************************************
|
// ********************************** Holding Registers (Control) *************************************************************
|
||||||
/*
|
|
||||||
// public UInt16 DeviceModel => _DeviceModel;
|
// public UInt16 DeviceModel => _DeviceModel;
|
||||||
public UInt32 RatedPower
|
public UInt32 RatedPower
|
||||||
{
|
{
|
||||||
|
|
@ -93,23 +92,24 @@ public partial class WITGrowatRecord
|
||||||
{
|
{
|
||||||
get => _EnableCommand;
|
get => _EnableCommand;
|
||||||
set => _EnableCommand = value;
|
set => _EnableCommand = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public DateTime SystemDateTime
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
var systemTime1 = _SystemTime1 + 2000; // We add 2000 years to fit a correct epoch time
|
||||||
|
return new DateTime(systemTime1, _SystemTime2, _SystemTime3, _SystemTime4, _SystemTime5,
|
||||||
|
_SystemTime6);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public DateTime SystemDateTime
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
var systemTime1 = _SystemTime1 + 2000; // We add 2000 years to fit a correct epoch time
|
|
||||||
return new DateTime(systemTime1, _SystemTime2, _SystemTime3, _SystemTime4, _SystemTime5,
|
|
||||||
_SystemTime6);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* public Boolean EnableSyn
|
/* public Boolean EnableSyn
|
||||||
{
|
{
|
||||||
get => _EnableSyn ;
|
get => _EnableSyn ;
|
||||||
set => _EnableSyn = value;
|
set => _EnableSyn = value;
|
||||||
}*/
|
}*/
|
||||||
/*
|
|
||||||
public Percent ActivePowerPercentDerating
|
public Percent ActivePowerPercentDerating
|
||||||
{
|
{
|
||||||
get => _ActivePowerPercentDerating;
|
get => _ActivePowerPercentDerating;
|
||||||
|
|
@ -234,7 +234,7 @@ public partial class WITGrowatRecord
|
||||||
set => _BatteryMaxdischargeCurrent = (UInt16) value;
|
set => _BatteryMaxdischargeCurrent = (UInt16) value;
|
||||||
}
|
}
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
public IReadOnlyList<BatteryRecord> Batteries => new List<BatteryRecord>
|
public IReadOnlyList<BatteryRecord> Batteries => new List<BatteryRecord>
|
||||||
|
|
@ -255,7 +255,7 @@ public partial class WITGrowatRecord
|
||||||
AccumulatedDischargeEnergy = _AccumulatedDishargeEnergy1,
|
AccumulatedDischargeEnergy = _AccumulatedDishargeEnergy1,
|
||||||
BatteryAmbientTemperature = _BatteryAmbientTemperature1
|
BatteryAmbientTemperature = _BatteryAmbientTemperature1
|
||||||
|
|
||||||
},
|
}
|
||||||
/*
|
/*
|
||||||
new BatteryRecord
|
new BatteryRecord
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -129,7 +129,7 @@ public partial class WITGrowatRecord
|
||||||
/****************************** Holding registers ****************************/
|
/****************************** Holding registers ****************************/
|
||||||
|
|
||||||
// [HoldingRegister(30000)] private UInt16 _DeviceModel;
|
// [HoldingRegister(30000)] private UInt16 _DeviceModel;
|
||||||
/* [HoldingRegister<UInt32>(30016, Scale = 0.1)] private UInt32 _RatedPower;
|
[HoldingRegister<UInt32>(30016, Scale = 0.1)] private UInt32 _RatedPower;
|
||||||
[HoldingRegister<UInt32>(30018, Scale = 0.1)] private UInt32 _MaxActivePower;
|
[HoldingRegister<UInt32>(30018, Scale = 0.1)] private UInt32 _MaxActivePower;
|
||||||
[HoldingRegister<UInt32>(30028, Scale = 0.1)] private UInt32 _PvInputMaxPower;
|
[HoldingRegister<UInt32>(30028, Scale = 0.1)] private UInt32 _PvInputMaxPower;
|
||||||
[HoldingRegister(30030)] private UInt16 _BatteryType;
|
[HoldingRegister(30030)] private UInt16 _BatteryType;
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ public class ModbusDevice<[DynamicallyAccessedMembers(All)] R> where R : notnull
|
||||||
foreach (var batch in _Batches)
|
foreach (var batch in _Batches)
|
||||||
{
|
{
|
||||||
batch.Read(record);
|
batch.Read(record);
|
||||||
//Thread.Sleep(50); // this added mainly for Growatt reading
|
Thread.Sleep(50); // this added mainly for Growatt reading
|
||||||
}
|
}
|
||||||
return record;
|
return record;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue