bringup
This commit is contained in:
1 parent
e7393389b8
commit
c1e8f2a7a4
4 files changed
+121
-60
No files matched your search
+57
-2
@@ -12,6 +12,7 @@
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <filesystem>
|
||||
#include <functional>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
@@ -29,6 +30,7 @@
|
||||
#include "queue.hpp"
|
||||
#include "textUtils.hpp"
|
||||
#include "thread.hpp"
|
||||
#include "defines.hpp"
|
||||
|
||||
class LinMot {
|
||||
public:
|
||||
@@ -69,7 +71,7 @@ class CurrMon {
|
||||
|
||||
float sampleCurrent() {
|
||||
auto val = sampe() - _refVal;
|
||||
val = val / 0.264;
|
||||
val = val / 0.264;
|
||||
fmt::println("{:.2} A", val);
|
||||
return val;
|
||||
}
|
||||
@@ -103,6 +105,7 @@ class DeviceIoState {
|
||||
SwordPulled.sample();
|
||||
}
|
||||
|
||||
OpMode Mode{OpMode::Maintanance};
|
||||
pal::InputTransAware& SwordEntry;
|
||||
pal::InputTransAware& SwordEnd;
|
||||
pal::InputTransAware& SwordPulled;
|
||||
@@ -125,7 +128,25 @@ struct SwordConfig {
|
||||
BrockerUrl(brocker),
|
||||
StationPath(topic),
|
||||
MqttUser(user),
|
||||
MqttPassword(passwd) {}
|
||||
MqttPassword(passwd) {
|
||||
using namespace std::filesystem;
|
||||
|
||||
try {
|
||||
for (const auto& entry : directory_iterator(base)) {
|
||||
if (!entry.is_regular_file()) {
|
||||
continue;
|
||||
}
|
||||
const std::string filename = entry.path().filename().string();
|
||||
if (filename.find("Excalibur_LOSE") != std::string::npos) {
|
||||
SoundsDeny.push_back(entry.path().string());
|
||||
} else if (filename.find("Excalibur_WIN_") != std::string::npos) {
|
||||
SoundsAllow.push_back(entry.path().string());
|
||||
}
|
||||
}
|
||||
} catch (const filesystem_error& e) {
|
||||
std::cerr << "Filesystem error: " << e.what() << '\n';
|
||||
}
|
||||
}
|
||||
|
||||
const std::string AssetBase;
|
||||
|
||||
@@ -134,10 +155,44 @@ struct SwordConfig {
|
||||
const std::string SoundDeny;
|
||||
const std::string SoundAllow;
|
||||
|
||||
const std::vector<std::string>& getSoundsAllow() { return SoundsAllow; }
|
||||
const std::vector<std::string>& getSoundsDeny() { return SoundsDeny; }
|
||||
|
||||
const std::string getNextAllow() {
|
||||
if (SoundsAllow.size() < 1) {
|
||||
return "";
|
||||
}
|
||||
|
||||
auto ret = SoundsAllow[idxAllow];
|
||||
idxAllow++;
|
||||
if (idxAllow >= SoundsAllow.size()) {
|
||||
idxAllow = 0;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
const std::string getNextDeny() {
|
||||
if (SoundsDeny.size() < 1) {
|
||||
return "";
|
||||
}
|
||||
|
||||
auto ret = SoundsDeny[idxDeny];
|
||||
idxDeny++;
|
||||
if (idxDeny >= SoundsDeny.size()) {
|
||||
idxDeny = 0;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
const std::string BrockerUrl;
|
||||
const std::string StationPath;
|
||||
const std::string MqttUser;
|
||||
const std::string MqttPassword;
|
||||
|
||||
private:
|
||||
std::vector<std::string> SoundsAllow;
|
||||
std::vector<std::string> SoundsDeny;
|
||||
int idxAllow{};
|
||||
int idxDeny{};
|
||||
};
|
||||
|
||||
class MediaPlayer {
|
||||
|
||||
Reference in new issue
Block a user