Add MQTT runtime control and device data pipeline
This commit is contained in:
1 parent
96d8309793
commit
8a0aa8f7cb
31 files changed
+30842
-20
No files matched your search
@@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
|
||||
namespace HHWMS.Web.Services
|
||||
{
|
||||
public class MqttRuntimeState
|
||||
{
|
||||
private int _enabled;
|
||||
|
||||
public bool Enabled => Volatile.Read(ref _enabled) == 1;
|
||||
|
||||
public DateTime? LastChangedAt { get; private set; }
|
||||
|
||||
public string LastChangedBy { get; private set; }
|
||||
|
||||
public void Update(bool enabled, string changedBy = null)
|
||||
{
|
||||
var oldEnabled = Enabled;
|
||||
Volatile.Write(ref _enabled, enabled ? 1 : 0);
|
||||
if (oldEnabled != enabled || string.IsNullOrEmpty(LastChangedBy))
|
||||
{
|
||||
LastChangedAt = DateTime.Now;
|
||||
LastChangedBy = changedBy;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user