step: hardening, major release
This commit is contained in:
1 parent
4fe0599988
commit
22dd3a3ea9
3 files changed
+24
-7
No files matched your search
@@ -24,6 +24,7 @@ enum GameModeCommands_e {
|
|||||||
GameNextTryLocked, // Lock sword on next try
|
GameNextTryLocked, // Lock sword on next try
|
||||||
GameNextTryRelease, // Release sword on next try
|
GameNextTryRelease, // Release sword on next try
|
||||||
GameAbortTry, // Abort this try
|
GameAbortTry, // Abort this try
|
||||||
|
GamePing, // Test
|
||||||
GameForceAbort // Abort current state
|
GameForceAbort // Abort current state
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ class MqttChannel {
|
|||||||
eventTopic(cfg.StationPath + "event"),
|
eventTopic(cfg.StationPath + "event"),
|
||||||
statTopic(cfg.StationPath + "stat"),
|
statTopic(cfg.StationPath + "stat"),
|
||||||
resetTopic(cfg.StationPath + "reset"),
|
resetTopic(cfg.StationPath + "reset"),
|
||||||
sendTimeout(std::chrono::seconds{10}),
|
sendTimeout(std::chrono::seconds{1}),
|
||||||
|
|
||||||
serviceCommands({
|
serviceCommands({
|
||||||
// cfg-topic
|
// cfg-topic
|
||||||
@@ -43,6 +43,7 @@ class MqttChannel {
|
|||||||
{"releaseLock", GameModeCommands_e::GameNextTryRelease},
|
{"releaseLock", GameModeCommands_e::GameNextTryRelease},
|
||||||
{"abortTry", GameModeCommands_e::GameAbortTry},
|
{"abortTry", GameModeCommands_e::GameAbortTry},
|
||||||
{"forceAbort", GameModeCommands_e::GameAbortTry},
|
{"forceAbort", GameModeCommands_e::GameAbortTry},
|
||||||
|
{"ping", GameModeCommands_e::GamePing},
|
||||||
}),
|
}),
|
||||||
subTopics{{setTopic, cfgTopic, resetTopic}},
|
subTopics{{setTopic, cfgTopic, resetTopic}},
|
||||||
client(name, cfg.BrockerUrl, subTopics,
|
client(name, cfg.BrockerUrl, subTopics,
|
||||||
|
|||||||
+21
-6
@@ -8,7 +8,7 @@ using namespace std::literals::string_view_literals;
|
|||||||
using namespace std::literals::chrono_literals;
|
using namespace std::literals::chrono_literals;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
const string Version = "V 0.10.1";
|
const string Version = "V 1.0.0";
|
||||||
|
|
||||||
unique_ptr<SwordConfig> SwordCfg;
|
unique_ptr<SwordConfig> SwordCfg;
|
||||||
unique_ptr<DeviceIoState> IoStat;
|
unique_ptr<DeviceIoState> IoStat;
|
||||||
@@ -47,6 +47,8 @@ int main(int argc, char* argv[]) {
|
|||||||
|
|
||||||
fmt::println("## Starting Sword Station {}", Version);
|
fmt::println("## Starting Sword Station {}", Version);
|
||||||
|
|
||||||
|
CLI11_PARSE(app, argc, argv);
|
||||||
|
|
||||||
OpMode mode{OpMode::Maintanance};
|
OpMode mode{OpMode::Maintanance};
|
||||||
fmt::println("{}", app.get_description());
|
fmt::println("{}", app.get_description());
|
||||||
if (modeArg == "game") {
|
if (modeArg == "game") {
|
||||||
@@ -56,7 +58,6 @@ int main(int argc, char* argv[]) {
|
|||||||
fmt::println("unknown {}", modeArg);
|
fmt::println("unknown {}", modeArg);
|
||||||
}
|
}
|
||||||
|
|
||||||
CLI11_PARSE(app, argc, argv);
|
|
||||||
std::ostringstream cmdline;
|
std::ostringstream cmdline;
|
||||||
for (int i = 0; i < argc; ++i) {
|
for (int i = 0; i < argc; ++i) {
|
||||||
if (i > 0)
|
if (i > 0)
|
||||||
@@ -241,6 +242,10 @@ void processProduction(MqttChannel& mqtt, SeqLogger& log) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch (code) {
|
switch (code) {
|
||||||
|
case GameModeCommands_e::GamePing: {
|
||||||
|
mqtt.sendEvent("pong");
|
||||||
|
} break;
|
||||||
|
|
||||||
case GameModeCommands_e::GameStarted: {
|
case GameModeCommands_e::GameStarted: {
|
||||||
fmt::println("Got GameStarted");
|
fmt::println("Got GameStarted");
|
||||||
log.sendEvent("Req", "GameStarted");
|
log.sendEvent("Req", "GameStarted");
|
||||||
@@ -259,6 +264,7 @@ void processProduction(MqttChannel& mqtt, SeqLogger& log) {
|
|||||||
bool abort = false;
|
bool abort = false;
|
||||||
fmt::println("Got NextTryLock");
|
fmt::println("Got NextTryLock");
|
||||||
log.sendEvent("Req", "StayLockded");
|
log.sendEvent("Req", "StayLockded");
|
||||||
|
IoStat->SwordLatch.moveOut(); // Lock
|
||||||
while (!abort) {
|
while (!abort) {
|
||||||
IoStat->SwordPulled.sample();
|
IoStat->SwordPulled.sample();
|
||||||
if (IoStat->SwordPulled.isPosEdge()) {
|
if (IoStat->SwordPulled.isPosEdge()) {
|
||||||
@@ -302,10 +308,21 @@ void processProduction(MqttChannel& mqtt, SeqLogger& log) {
|
|||||||
abort = testAbortCondition(mqtt, "abortTry");
|
abort = testAbortCondition(mqtt, "abortTry");
|
||||||
}
|
}
|
||||||
sendLogIfAborted(abort);
|
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?
|
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");
|
mqtt.sendEvent("pulled-out");
|
||||||
log.sendEvent("Game", "Pulled Out");
|
log.sendEvent("Game", "Pulled Out");
|
||||||
@@ -350,5 +367,3 @@ void processProduction(MqttChannel& mqtt, SeqLogger& log) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo send state in background
|
|
||||||
Reference in new issue
Block a user