Add dashboard device data push pipeline
This commit is contained in:
1 parent
8a0aa8f7cb
commit
0c4077f181
7 files changed
+800
-1
No files matched your search
@@ -64,10 +64,15 @@ namespace HHWMS.Web.Services.DeviceData
|
||||
var currentState = unitwork.Find<DeviceCurrentState>(x => x.DeviceId == deviceId).FirstOrDefault();
|
||||
if (IsDeadbandHit(currentState, status, currentA, currentB, currentC))
|
||||
{
|
||||
TouchCurrentState(unitwork, currentState, payloadTime, realtimeJson);
|
||||
return new ProcessingResult
|
||||
{
|
||||
Handled = true,
|
||||
Updated = false,
|
||||
Updated = true,
|
||||
DeviceId = deviceId,
|
||||
DeviceType = "power",
|
||||
Status = status,
|
||||
PayloadTime = payloadTime,
|
||||
Message = "Power cabinet ignored by deadband",
|
||||
ParsedData = realtimeJson
|
||||
};
|
||||
@@ -86,6 +91,10 @@ namespace HHWMS.Web.Services.DeviceData
|
||||
{
|
||||
Handled = true,
|
||||
Updated = true,
|
||||
DeviceId = deviceId,
|
||||
DeviceType = "power",
|
||||
Status = status,
|
||||
PayloadTime = payloadTime,
|
||||
Message = "Power cabinet state updated",
|
||||
ParsedData = realtimeJson
|
||||
};
|
||||
@@ -119,6 +128,19 @@ namespace HHWMS.Web.Services.DeviceData
|
||||
unitwork.Update(currentState);
|
||||
}
|
||||
|
||||
private static void TouchCurrentState(IUnitWork unitwork, DeviceCurrentState currentState, DateTime payloadTime, string realtimeJson)
|
||||
{
|
||||
if (currentState == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
currentState.LastPayloadTime = payloadTime;
|
||||
currentState.LastUpdateTime = DateTime.Now;
|
||||
currentState.RealtimeJson = realtimeJson;
|
||||
unitwork.Update(currentState);
|
||||
}
|
||||
|
||||
private static void UpsertTrendPoint(IUnitWork unitwork, string deviceId, string metricName, DateTime payloadTime, decimal? value)
|
||||
{
|
||||
if (value == null)
|
||||
|
||||
Reference in new issue
Block a user