currentMeas

This commit is contained in:
Jakob Gegeniger committed 2026-09-12 00:18:54 +02:00
1 parent f93a8aaabd
commit d2b8e1de3c
9 files changed
+92 -27

No files matched your search

+16 -6
View File
@@ -1,10 +1,10 @@
#pragma once
#include "swordMain.hpp"
#include "defines.hpp"
#include "swordMain.hpp"
class MqttChannel {
public:
MqttChannel(string version, SwordConfig cfg, DeviceIoState& ioStat, SeqLogger& log)
MqttChannel(string name, string version, SwordConfig cfg, DeviceIoState& ioStat, SeqLogger& log)
: Config(cfg),
IoStat(ioStat),
Logger(log),
@@ -35,9 +35,7 @@ class MqttChannel {
{"promoDelay", ServiceCommands_e::SetConfigPromoDelay},
}),
subTopics{{runTopic, cfgTopic, resetTopic}},
client("Sword",
cfg.BrockerUrl,
subTopics,
client(name, cfg.BrockerUrl, subTopics,
{cfg.MqttUser, cfg.MqttPassword}) {
fmt::println("MQTT: Starting task:");
mqttCall = [this](string topic, string payload) {
@@ -86,7 +84,7 @@ class MqttChannel {
fmt::println("Input queue flushed, {} Messages discarted", cnt);
}
static void runMasterService(Thread::Context& ctx, MqttChannel& instance, function<void()> resetCall) {
static void runMasterService(Thread::Context& ctx, MqttChannel& instance, function<void()> resetCall, CurrMon& mon) {
while (true) {
auto serMsg = instance.MasterQueue.dequeue();
if (!serMsg) {
@@ -129,9 +127,21 @@ class MqttChannel {
switch (code) {
case ServiceCommands_e::SetLockOpen: {
instance.IoStat.SwordLatch.moveIn();
auto tE = std::chrono::steady_clock::now() + 6s;
while (std::chrono::steady_clock::now() < tE) {
Thread::sleep(100ms);
auto curr = mon.sampleCurrent();
}
auto currE = mon.sampleCurrent();
} break;
case ServiceCommands_e::SetLockClose: {
instance.IoStat.SwordLatch.moveOut();
auto tE = std::chrono::steady_clock::now() + 6s;
while (std::chrono::steady_clock::now() < tE) {
Thread::sleep(100ms);
auto curr = mon.sampleCurrent();
}
auto currE = mon.sampleCurrent();
} break;
case ServiceCommands_e::PlaySoundPromo: {
MediaPlayer::playWavFile(instance.Config.SoundPromo);