step: hardening, major release

This commit is contained in:
Jakob Gegeniger committed 2026-11-03 21:30:02 +01:00
1 parent 4fe0599988
commit 0d550ae2ea
3 files changed
+24 -7

No files matched your search

+1
View File
@@ -24,6 +24,7 @@ enum GameModeCommands_e {
GameNextTryLocked, // Lock sword on next try
GameNextTryRelease, // Release sword on next try
GameAbortTry, // Abort this try
GamePing, // Test
GameForceAbort // Abort current state
};
+2 -1
View File
@@ -17,7 +17,7 @@ class MqttChannel {
eventTopic(cfg.StationPath + "event"),
statTopic(cfg.StationPath + "stat"),
resetTopic(cfg.StationPath + "reset"),
sendTimeout(std::chrono::seconds{10}),
sendTimeout(std::chrono::seconds{1}),
serviceCommands({
// cfg-topic
@@ -43,6 +43,7 @@ class MqttChannel {
{"releaseLock", GameModeCommands_e::GameNextTryRelease},
{"abortTry", GameModeCommands_e::GameAbortTry},
{"forceAbort", GameModeCommands_e::GameAbortTry},
{"ping", GameModeCommands_e::GamePing},
}),
subTopics{{setTopic, cfgTopic, resetTopic}},
client(name, cfg.BrockerUrl, subTopics,
+21 -6
View File
@@ -8,7 +8,7 @@ using namespace std::literals::string_view_literals;
using namespace std::literals::chrono_literals;
using namespace std;
const string Version = "V 0.10.1";
const string Version = "V 1.0.0";
unique_ptr<SwordConfig> SwordCfg;
unique_ptr<DeviceIoState> IoStat;
@@ -47,6 +47,8 @@ int main(int argc, char* argv[]) {
fmt::println("## Starting Sword Station {}", Version);
CLI11_PARSE(app, argc, argv);
OpMode mode{OpMode::Maintanance};
fmt::println("{}", app.get_description());
if (modeArg == "game") {
@@ -56,7 +58,6 @@ int main(int argc, char* argv[]) {
fmt::println("unknown {}", modeArg);
}
CLI11_PARSE(app, argc, argv);
std::ostringstream cmdline;
for (int i = 0; i < argc; ++i) {
if (i > 0)
@@ -241,6 +242,10 @@ void processProduction(MqttChannel& mqtt, SeqLogger& log) {
}
switch (code) {
case GameModeCommands_e::GamePing: {
mqtt.sendEvent("pong");
} break;
case GameModeCommands_e::GameStarted: {
fmt::println("Got GameStarted");
log.sendEvent("Req", "GameStarted");
@@ -259,6 +264,7 @@ void processProduction(MqttChannel& mqtt, SeqLogger& log) {
bool abort = false;
fmt::println("Got NextTryLock");
log.sendEvent("Req", "StayLockded");
IoStat->SwordLatch.moveOut(); // Lock
while (!abort) {
IoStat->SwordPulled.sample();
if (IoStat->SwordPulled.isPosEdge()) {
@@ -302,10 +308,21 @@ void processProduction(MqttChannel& mqtt, SeqLogger& log) {
abort = testAbortCondition(mqtt, "abortTry");
}
sendLogIfAborted(abort);
if (abort) break;
if (abort) {
IoStat->SwordEnd.sample();
if (IoStat->SwordEnd.isActive()) {
fmt::println("..lock after abort");
IoStat->SwordLatch.moveOut(); // Lock
log.sendEvent("Req", "Abort, Sword locked");
} else {
log.sendEvent("Req", "Abort, Sword not locked");
}
break;
}
IoStat->SwordEnd.sample(); // still stuck?
bool stuckSensor = (!IoStat->SwordEntry.isActive()) && (IoStat->SwordEnd.isActive());
bool stuckSensor = (!IoStat->SwordEntry.isActive()) &&
(IoStat->SwordEnd.isActive());
mqtt.sendEvent("pulled-out");
log.sendEvent("Game", "Pulled Out");
@@ -350,5 +367,3 @@ void processProduction(MqttChannel& mqtt, SeqLogger& log) {
}
}
}
// todo send state in background