Remove timestamps from heartbit,
update configuration for discharge
This commit is contained in:
parent
7510ee0ce2
commit
bea24fde97
|
|
@ -6,9 +6,12 @@ public class Configuration
|
||||||
public Double GridSetPoint { get; set; }
|
public Double GridSetPoint { get; set; }
|
||||||
public CalibrationChargeType CalibrationChargeState { get; set; }
|
public CalibrationChargeType CalibrationChargeState { get; set; }
|
||||||
public DateTime CalibrationChargeDate { get; set; }
|
public DateTime CalibrationChargeDate { get; set; }
|
||||||
|
public CalibrationChargeType CalibrationDischargeState { get; set; }
|
||||||
|
public DateTime CalibrationDischargeDate { get; set; }
|
||||||
public String GetConfigurationString()
|
public String GetConfigurationString()
|
||||||
{
|
{
|
||||||
return $"MinimumSoC: {MinimumSoC}, GridSetPoint: {GridSetPoint}, CalibrationChargeState: {CalibrationChargeState}, CalibrationChargeDate: {CalibrationChargeDate}";
|
return $"MinimumSoC: {MinimumSoC}, GridSetPoint: {GridSetPoint}, CalibrationChargeState: {CalibrationChargeState}, CalibrationChargeDate: {CalibrationChargeDate}, " +
|
||||||
|
$"CalibrationDischargeState: {CalibrationDischargeState}, CalibrationDischargeDate: {CalibrationDischargeDate}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -235,7 +235,7 @@ public static class UserMethods
|
||||||
public static Task SendPasswordResetEmail(this User user, String token)
|
public static Task SendPasswordResetEmail(this User user, String token)
|
||||||
{
|
{
|
||||||
const String subject = "Reset the password of your Inesco Energy Account";
|
const String subject = "Reset the password of your Inesco Energy Account";
|
||||||
const String resetLink = "https://monitor.innov.energy/api/ResetPassword"; // TODO: move to settings file
|
const String resetLink = "https://monitor.inesco.energy/api/ResetPassword"; // TODO: move to settings file
|
||||||
var encodedToken = HttpUtility.UrlEncode(token);
|
var encodedToken = HttpUtility.UrlEncode(token);
|
||||||
|
|
||||||
var body = $"Dear {user.Name}\n" +
|
var body = $"Dear {user.Name}\n" +
|
||||||
|
|
@ -249,7 +249,7 @@ public static class UserMethods
|
||||||
{
|
{
|
||||||
const String subject = "Your new Inesco Energy Account";
|
const String subject = "Your new Inesco Energy Account";
|
||||||
|
|
||||||
var resetLink = $"https://monitor.innov.energy/?username={user.Email}"; // TODO: move to settings file
|
var resetLink = $"https://monitor.inesco.energy/?username={user.Email}"; // TODO: move to settings file
|
||||||
|
|
||||||
var body = $"Dear {user.Name}\n" +
|
var body = $"Dear {user.Name}\n" +
|
||||||
$"To set your password and log in to your " +
|
$"To set your password and log in to your " +
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ public static class Program
|
||||||
WebsocketManager.MonitorSodistoreInstallationTable().SupressAwaitWarning();
|
WebsocketManager.MonitorSodistoreInstallationTable().SupressAwaitWarning();
|
||||||
|
|
||||||
|
|
||||||
Task.Run(() => DeleteOldDataFromS3.DeleteOldData());
|
// Task.Run(() => DeleteOldDataFromS3.DeleteOldData());
|
||||||
|
|
||||||
builder.Services.AddControllers();
|
builder.Services.AddControllers();
|
||||||
builder.Services.AddProblemDetails(setup =>
|
builder.Services.AddProblemDetails(setup =>
|
||||||
|
|
|
||||||
|
|
@ -93,17 +93,17 @@ public static class RabbitMqManager
|
||||||
if (installation.Product == (int)ProductType.Salimax)
|
if (installation.Product == (int)ProductType.Salimax)
|
||||||
{
|
{
|
||||||
monitorLink =
|
monitorLink =
|
||||||
$"https://monitor.innov.energy/installations/list/installation/{installation.S3BucketId}/batteryview";
|
$"https://monitor.inesco.energy/installations/list/installation/{installation.S3BucketId}/batteryview";
|
||||||
}
|
}
|
||||||
else if (installation.Product == (int)ProductType.SodiStoreMax)
|
else if (installation.Product == (int)ProductType.SodiStoreMax)
|
||||||
{
|
{
|
||||||
monitorLink =
|
monitorLink =
|
||||||
$"https://monitor.innov.energy/sodistore_installations/list/installation/{installation.S3BucketId}/batteryview";
|
$"https://monitor.inesco.energy/sodistore_installations/list/installation/{installation.S3BucketId}/batteryview";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
monitorLink =
|
monitorLink =
|
||||||
$"https://monitor.innov.energy/salidomo_installations/list/installation/{installation.S3BucketId}/batteryview";
|
$"https://monitor.inesco.energy/salidomo_installations/list/installation/{installation.S3BucketId}/batteryview";
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var alarm in receivedStatusMessage.Alarms)
|
foreach (var alarm in receivedStatusMessage.Alarms)
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,6 @@ public class StatusMessage
|
||||||
public required MessageType Type { get; set; }
|
public required MessageType Type { get; set; }
|
||||||
public List<AlarmOrWarning>? Warnings { get; set; }
|
public List<AlarmOrWarning>? Warnings { get; set; }
|
||||||
public List<AlarmOrWarning>? Alarms { get; set; }
|
public List<AlarmOrWarning>? Alarms { get; set; }
|
||||||
public Int32 Timestamp { get; set; }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum MessageType
|
public enum MessageType
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,6 @@ public class StatusMessage
|
||||||
public required MessageType Type { get; set; }
|
public required MessageType Type { get; set; }
|
||||||
public List<AlarmOrWarning>? Warnings { get; set; }
|
public List<AlarmOrWarning>? Warnings { get; set; }
|
||||||
public List<AlarmOrWarning>? Alarms { get; set; }
|
public List<AlarmOrWarning>? Alarms { get; set; }
|
||||||
public Int32 Timestamp { get; set; }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum MessageType
|
public enum MessageType
|
||||||
|
|
|
||||||
|
|
@ -338,16 +338,6 @@ internal static class Program
|
||||||
if (s3Bucket != null)
|
if (s3Bucket != null)
|
||||||
RabbitMqManager.InformMiddleware(currentSalimaxState);
|
RabbitMqManager.InformMiddleware(currentSalimaxState);
|
||||||
}
|
}
|
||||||
// else if (_subscribedToQueue && _heartBitInterval >= 30)
|
|
||||||
// {
|
|
||||||
// //Send a heartbit to the backend
|
|
||||||
// Console.WriteLine("----------------------------------------Sending Heartbit----------------------------------------");
|
|
||||||
// _heartBitInterval = 0;
|
|
||||||
// currentSalimaxState.Type = MessageType.Heartbit;
|
|
||||||
//
|
|
||||||
// if (s3Bucket != null)
|
|
||||||
// RabbitMqManager.InformMiddleware(currentSalimaxState);
|
|
||||||
// }
|
|
||||||
|
|
||||||
//If there is an available message from the RabbitMQ Broker, apply the configuration file
|
//If there is an available message from the RabbitMQ Broker, apply the configuration file
|
||||||
Configuration? config = SetConfigurationFile();
|
Configuration? config = SetConfigurationFile();
|
||||||
|
|
@ -868,20 +858,16 @@ internal static class Program
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(line)) continue;
|
if (string.IsNullOrWhiteSpace(line)) continue;
|
||||||
|
|
||||||
string[] parts = line.Split(';');
|
var parts = line.Split(';');
|
||||||
//if (parts.Length < 2) continue;
|
var keyPath = parts[0];
|
||||||
|
var value = parts[1];
|
||||||
string keyPath = parts[0];
|
var unit = parts.Length > 2 ? parts[2].Trim() : "";
|
||||||
string value = parts[1];
|
|
||||||
string unit = parts.Length > 2 ? parts[2].Trim() : "";
|
|
||||||
//Console.WriteLine(line);
|
//Console.WriteLine(line);
|
||||||
// Console.WriteLine($"Key: {keyPath}, Value: {value}, Unit: {unit}");
|
// Console.WriteLine($"Key: {keyPath}, Value: {value}, Unit: {unit}");
|
||||||
|
|
||||||
InsertIntoJson(jsonData, keyPath.Split('/'), value);
|
InsertIntoJson(jsonData, keyPath.Split('/'), value);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
string jsonOutput = JsonConvert.SerializeObject(jsonData, Formatting.None);
|
var jsonOutput = JsonConvert.SerializeObject(jsonData, Formatting.None);
|
||||||
jsonOutput.LogInfo();
|
jsonOutput.LogInfo();
|
||||||
|
|
||||||
await RestApiSavingFile(csv);
|
await RestApiSavingFile(csv);
|
||||||
|
|
@ -927,24 +913,23 @@ internal static class Program
|
||||||
Console.WriteLine("ERROR: PUT");
|
Console.WriteLine("ERROR: PUT");
|
||||||
var error = await response.GetStringAsync();
|
var error = await response.GetStringAsync();
|
||||||
Console.WriteLine(error);
|
Console.WriteLine(error);
|
||||||
Heartbit(new DateTime(0));
|
Heartbit();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Console.WriteLine("----------------------------------------Sending Heartbit----------------------------------------");
|
Console.WriteLine("----------------------------------------Sending Heartbit----------------------------------------");
|
||||||
|
|
||||||
Heartbit(timeStamp);
|
Heartbit();
|
||||||
}
|
}
|
||||||
_counterOfFile++;
|
_counterOfFile++;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void Heartbit(DateTime timeStamp)
|
private static void Heartbit()
|
||||||
{
|
{
|
||||||
var s3Bucket = Config.Load().S3?.Bucket;
|
var s3Bucket = Config.Load().S3?.Bucket;
|
||||||
var tryParse = TryParse(s3Bucket?.Split("-")[0], out var installationId);
|
var tryParse = TryParse(s3Bucket?.Split("-")[0], out var installationId);
|
||||||
var parse = TryParse(timeStamp.ToUnixTime().ToString(), out var nameOfCsvFile);
|
|
||||||
|
|
||||||
if (tryParse)
|
if (tryParse)
|
||||||
{
|
{
|
||||||
|
|
@ -954,7 +939,6 @@ internal static class Program
|
||||||
Product = 0, // Salimax is always 0
|
Product = 0, // Salimax is always 0
|
||||||
Status = _salimaxAlarmState,
|
Status = _salimaxAlarmState,
|
||||||
Type = MessageType.Heartbit,
|
Type = MessageType.Heartbit,
|
||||||
Timestamp = nameOfCsvFile
|
|
||||||
};
|
};
|
||||||
if (s3Bucket != null)
|
if (s3Bucket != null)
|
||||||
RabbitMqManager.InformMiddleware(returnedStatus);
|
RabbitMqManager.InformMiddleware(returnedStatus);
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,6 @@ public class StatusMessage
|
||||||
public required MessageType Type { get; set; }
|
public required MessageType Type { get; set; }
|
||||||
public List<AlarmOrWarning>? Warnings { get; set; }
|
public List<AlarmOrWarning>? Warnings { get; set; }
|
||||||
public List<AlarmOrWarning>? Alarms { get; set; }
|
public List<AlarmOrWarning>? Alarms { get; set; }
|
||||||
public Int32 Timestamp { get; set; }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum MessageType
|
public enum MessageType
|
||||||
|
|
|
||||||
|
|
@ -859,24 +859,23 @@ internal static class Program
|
||||||
Console.WriteLine("ERROR: PUT");
|
Console.WriteLine("ERROR: PUT");
|
||||||
var error = await response.GetStringAsync();
|
var error = await response.GetStringAsync();
|
||||||
Console.WriteLine(error);
|
Console.WriteLine(error);
|
||||||
Heartbit(new DateTime(0));
|
Heartbit();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Console.WriteLine("----------------------------------------Sending Heartbit----------------------------------------");
|
Console.WriteLine("----------------------------------------Sending Heartbit----------------------------------------");
|
||||||
|
|
||||||
Heartbit(timeStamp);
|
Heartbit();
|
||||||
}
|
}
|
||||||
_fileCounter++;
|
_fileCounter++;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void Heartbit(DateTime timeStamp)
|
private static void Heartbit()
|
||||||
{
|
{
|
||||||
var s3Bucket = Config.Load().S3?.Bucket;
|
var s3Bucket = Config.Load().S3?.Bucket;
|
||||||
var tryParse = int.TryParse(s3Bucket?.Split("-")[0], out var installationId);
|
var tryParse = int.TryParse(s3Bucket?.Split("-")[0], out var installationId);
|
||||||
var parse = int.TryParse(timeStamp.ToUnixTime().ToString(), out var nameOfJsonFile);
|
|
||||||
|
|
||||||
if (tryParse)
|
if (tryParse)
|
||||||
{
|
{
|
||||||
|
|
@ -886,7 +885,6 @@ internal static class Program
|
||||||
Product = 3, // Salimax is always 0
|
Product = 3, // Salimax is always 0
|
||||||
Status = _salimaxAlarmState,
|
Status = _salimaxAlarmState,
|
||||||
Type = MessageType.Heartbit,
|
Type = MessageType.Heartbit,
|
||||||
Timestamp = nameOfJsonFile
|
|
||||||
};
|
};
|
||||||
if (s3Bucket != null)
|
if (s3Bucket != null)
|
||||||
RabbitMqManager.InformMiddleware(returnedStatus);
|
RabbitMqManager.InformMiddleware(returnedStatus);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue