using date time instead of unixtime

This commit is contained in:
atef 2023-10-23 11:05:18 +02:00
parent 1654d6f4dd
commit 66f6fbb878
1 changed files with 4 additions and 5 deletions

View File

@ -16,7 +16,6 @@ using InnovEnergy.Lib.Devices.Trumpf.TruConvertAc.DataTypes;
using InnovEnergy.Lib.Devices.Trumpf.TruConvertDc; using InnovEnergy.Lib.Devices.Trumpf.TruConvertDc;
using InnovEnergy.Lib.Devices.Trumpf.TruConvertDc.Control; using InnovEnergy.Lib.Devices.Trumpf.TruConvertDc.Control;
using InnovEnergy.Lib.Protocols.Modbus.Channels; using InnovEnergy.Lib.Protocols.Modbus.Channels;
using InnovEnergy.Lib.Time.Unix;
using InnovEnergy.Lib.Units; using InnovEnergy.Lib.Units;
using InnovEnergy.Lib.Utils; using InnovEnergy.Lib.Utils;
using static InnovEnergy.Lib.Devices.Trumpf.SystemControl.DataTypes.SystemConfig; using static InnovEnergy.Lib.Devices.Trumpf.SystemControl.DataTypes.SystemConfig;
@ -170,7 +169,7 @@ internal static class Program
await Observable await Observable
.Interval(UpdateInterval) .Interval(UpdateInterval)
.Select(_ => RunIteration()) .Select(_ => RunIteration())
.SelectMany(r => UploadCsv(r, UnixTime.Now.RoundTo(UpdateInterval))) .SelectMany(r => UploadCsv(r, DateTime.Now.Round(UpdateInterval)))
.SelectError() .SelectError()
.ToTask(); .ToTask();
} }
@ -216,7 +215,7 @@ internal static class Program
record.ControlConstants(); record.ControlConstants();
record.ControlSystemState(); record.ControlSystemState();
$"{UnixTime.Now} : {record.StateMachine.State}: {record.StateMachine.Message}".WriteLine().LogInfo(); $"{DateTime.Now.ToUnixTime()} : {record.StateMachine.State}: {record.StateMachine.Message}".WriteLine().LogInfo();
var essControl = record.ControlEss().WriteLine().LogInfo(); var essControl = record.ControlEss().WriteLine().LogInfo();
@ -344,14 +343,14 @@ internal static class Program
sc.ResetAlarmsAndWarnings = true; sc.ResetAlarmsAndWarnings = true;
} }
private static async Task<Boolean> UploadCsv(StatusRecord status, UnixTime timeStamp) private static async Task<Boolean> UploadCsv(StatusRecord status, DateTime timeStamp)
{ {
var s3Config = status.Config.S3; var s3Config = status.Config.S3;
var csv = status.ToCsv().LogInfo(); var csv = status.ToCsv().LogInfo();
if (s3Config is null) if (s3Config is null)
return false; return false;
var s3Path = timeStamp + ".csv"; var s3Path = timeStamp.ToUnixTime() + ".csv";
var request = s3Config.CreatePutRequest(s3Path); var request = s3Config.CreatePutRequest(s3Path);
var response = await request.PutAsync(new StringContent(csv)); var response = await request.PutAsync(new StringContent(csv));