Skip to content
This repository was archived by the owner on May 16, 2024. It is now read-only.

Commit c8c709a

Browse files
committed
Use recorded installation date as start date
1 parent 904d66c commit c8c709a

5 files changed

Lines changed: 15 additions & 7 deletions

File tree

src/CodeCaster.PVBridge.GoodWe/GoodWeInputConfiguration.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public string? InverterSerialNumber
3737
[JsonIgnore]
3838
public DateTime? InstallDate
3939
{
40-
get => Options.TryGetValue(nameof(InstallDate), out var s) && DateTime.TryParse(s, out var d) ? d : null;
40+
get => base.GetOptionDateTime(nameof(InstallDate));
4141
set => Options[nameof(InstallDate)] = value?.ToString("O");
4242
}
4343
}

src/CodeCaster.PVBridge.Logic/InputToOutputLoopStatus.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -231,10 +231,7 @@ public StateMachine UpdateState()
231231

232232
private DateTime CalculateBacklogStart()
233233
{
234-
// TODO: start from install date, save last synced day in JSON somewhere (not config), see #10
235-
var minDate = _syncStart;
236-
237-
var backlogStart = DateTime.Today.AddDays(-13);
234+
var backlogStart = _syncStart;
238235

239236
var days = (int)Math.Ceiling((DateTime.Now - backlogStart).TotalDays) + 1;
240237

src/CodeCaster.PVBridge.Service/PvBridgeService.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,13 @@ private List<IInputToOutputLoop> GetNewTasks(BridgeConfiguration? configuration)
252252
// TODO: further back, see #10
253253
var syncStart = DateTime.Today.AddDays(-14);
254254

255+
// TODO: partial quickfix for #23, don't sync before install date or it hangs until 14 days since have passed.
256+
var installDate = input.GetOptionDateTime("InstallDate");
257+
if (installDate > syncStart)
258+
{
259+
syncStart = installDate.Value.Date;
260+
}
261+
255262
var loop = new InputToOutputLoop(_loopLogger, _ioWriter, input, outputs, syncStart);
256263

257264
_messageBroker.StatusSyncRequested += loop.StatusSyncRequested;

src/CodeCaster.PVBridge/CachingSummaryProvider.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ namespace CodeCaster.PVBridge
1414
/// <summary>
1515
/// Caches day summaries per configuration.
1616
///
17-
/// TODO: implement cache invalidation beyond retention limit (14 or 90 days).
17+
/// TODO: implement cache invalidation beyond retention limit (14 or 90 days) for long uptimes.
18+
/// TODO: save in JSON in AppData for all other occasions, see #10.
1819
/// </summary>
1920
public abstract class CachingSummaryProvider : IDataProvider
2021
{

src/CodeCaster.PVBridge/Configuration/DataProviderConfiguration.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Linq;
1+
using System;
2+
using System.Linq;
23
using System.Text.Json.Serialization;
34
using CodeCaster.PVBridge.Utils;
45

@@ -30,6 +31,8 @@ public class DataProviderConfiguration
3031
/// </devdoc>
3132
public string Type { get; set; }
3233

34+
public DateTime? GetOptionDateTime(string key) => Options.TryGetValue(key, out var s) && DateTime.TryParse(s, out var d) ? d : null;
35+
3336
/// <summary>
3437
/// Either the name or the type.
3538
/// </summary>

0 commit comments

Comments
 (0)