11 throw std::runtime_error(
"Environmental config assertion failed");
14std::string
board(
const std::string& name,
const std::string&
id,
bool enabled =
true) {
15 return "[boards." + name +
"]\ntype = \"ENVIRONMENTAL\"\n" +
id +
16 "\nenabled = " + (enabled ?
"true" :
"false") +
"\nactive_connectors = [1]\n";
21 {
"board_id = 0",
"board_id = -1",
"board_id = 256",
"board_id = 4294967321",
22 "board_id = 25.5",
"board_id = 25.0",
"board_id = \"25\"",
"board_id = true",
""}) {
23 bool rejected =
false;
26 }
catch (
const std::invalid_argument& e) {
27 rejected = std::string(e.what()).find(
"integer from 1 to 255") != std::string::npos;
31 bool duplicate_rejected =
false;
34 }
catch (
const std::invalid_argument& e) {
35 duplicate_rejected = std::string(e.what()).find(
"claimed by both") != std::string::npos;
40 board(
"first",
"board_id = 25") +
board(
"second",
"board_id = 35") +
41 board(
"disabled",
"board_id = 25",
false) +
42 board(
"invalid_disabled",
"board_id = 256",
false));
44 for (
auto&
b : cfg.boards)
49 bool narrowing_rejected =
false;
52 }
catch (
const std::invalid_argument&) {
53 narrowing_rejected =
true;
56 std::cout <<
"Environmental ID validation passed\n";
*brief create JSON pointer *sa reference_tokens const string_t const string_t & b
T & at(const key_type &key)
std::map< ActiveBoardKind, std::vector< elodin::BoardChannels > > active_boards(const Config &cfg)
Derive the active-board table (enabled boards -> Elodin BoardChannels), with the same slot-collision ...
Config load_from_string(const std::string &text)
Parse config from an in-memory TOML string (SequencerService / ActuatorCommander hold it so).
std::string board(const std::string &name, const std::string &id, bool enabled=true)
void require(bool condition)