1 #include "otsdaq-core/ConfigurationPluginDataFormats/IterateConfiguration.h"
2 #include "otsdaq-core/Macros/ConfigurationPluginMacros.h"
3 #include "otsdaq-core/ConfigurationInterface/ConfigurationManager.h"
12 const std::string IterateConfiguration::COMMAND_BEGIN_LABEL =
"BEGIN_LABEL";
13 const std::string IterateConfiguration::COMMAND_CHOOSE_FSM =
"CHOOSE_FSM";
14 const std::string IterateConfiguration::COMMAND_CONFIGURE_ACTIVE_GROUP =
"CONFIGURE_ACTIVE_GROUP";
15 const std::string IterateConfiguration::COMMAND_CONFIGURE_ALIAS =
"CONFIGURE_ALIAS";
16 const std::string IterateConfiguration::COMMAND_CONFIGURE_GROUP =
"CONFIGURE_GROUP";
17 const std::string IterateConfiguration::COMMAND_EXECUTE_FE_MACRO =
"EXECUTE_FE_MACRO";
18 const std::string IterateConfiguration::COMMAND_EXECUTE_MACRO =
"EXECUTE_MACRO";
19 const std::string IterateConfiguration::COMMAND_MODIFY_ACTIVE_GROUP =
"MODIFY_ACTIVE_GROUP";
20 const std::string IterateConfiguration::COMMAND_REPEAT_LABEL =
"REPEAT_LABEL";
21 const std::string IterateConfiguration::COMMAND_RUN =
"RUN";
23 const std::string IterateConfiguration::ITERATE_TABLE =
"IterateConfiguration";
24 const std::string IterateConfiguration::PLAN_TABLE =
"IterationPlanConfiguration";
25 const std::string IterateConfiguration::TARGET_TABLE =
"IterationTargetConfiguration";
27 const std::map<std::string,std::string> IterateConfiguration::commandToTableMap_ = IterateConfiguration::createCommandToTableMap();
50 IterateConfiguration::IterateConfiguration(
void)
56 IterateConfiguration::~IterateConfiguration(
void)
64 __COUT__ <<
"*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*" << std::endl;
65 __COUT__ << configManager->__SELF_NODE__ << std::endl;
68 auto childrenMap = configManager->__SELF_NODE__.getChildren();
69 for(
auto &childPair: childrenMap)
72 __COUT__ << childPair.first << std::endl;
79 std::vector<IterateConfiguration::Command> IterateConfiguration::getPlanCommands(
82 __COUT__ << configManager->__SELF_NODE__ << std::endl;
86 if(!planNode.getNode(IterateConfiguration::planTableCols_.Status_).getValue<
bool>())
88 __SS__ <<
"Error! Attempt to access disabled plan (Status=FALSE)." << std::endl;
89 __COUT_ERR__ << ss.str();
90 throw std::runtime_error(ss.str());
93 std::vector<IterateConfiguration::Command> commands;
95 auto commandChildren = planNode.getNode(
96 IterateConfiguration::iterateTableCols_.PlanLink_).getChildren();
98 for(
auto &commandChild: commandChildren)
100 __COUT__ <<
"Command \t" << commandChild.first << std::endl;
102 __COUT__ <<
"\t\tStatus \t" << commandChild.second.getNode(
103 IterateConfiguration::planTableCols_.Status_) << std::endl;
105 __COUT__ <<
"\t\tType \t" << commandChild.second.getNode(
106 IterateConfiguration::planTableCols_.CommandType_) << std::endl;
108 if(!commandChild.second.getNode(
109 IterateConfiguration::planTableCols_.Status_).getValue<
bool>())
113 commands.back().type_ = commandChild.second.getNode(
114 IterateConfiguration::planTableCols_.CommandType_).getValue<std::string>();
116 if(commandChild.second.getNode(
117 IterateConfiguration::planTableCols_.CommandLink_).isDisconnected())
120 auto commandSpecificFields = commandChild.second.getNode(
121 IterateConfiguration::planTableCols_.CommandLink_).getChildren();
123 for(
unsigned int i=0; i<commandSpecificFields.size()-3; ++i)
125 __COUT__ <<
"\t\tParameter \t" << commandSpecificFields[i].first <<
" = \t" <<
126 commandSpecificFields[i].second << std::endl;
128 if(commandSpecificFields[i].first ==
129 IterateConfiguration::commandTargetCols_.TargetsLink_)
131 __COUT__ <<
"Extracting targets..." << __E__;
132 auto targets = commandSpecificFields[i].second.getChildren();
133 for(
auto& target:targets)
135 __COUT__ <<
"\t\t\tTarget \t" << target.first << __E__;
138 target.second.getNode(
139 IterateConfiguration::targetCols_.TargetLink_);
140 if(targetNode.isDisconnected())
142 __COUT_ERR__ <<
"Disconnected target!?" << __E__;
146 __COUT__ <<
"\t\t = \t" <<
148 targetNode.getConfigurationName() <<
150 targetNode.getValueAsString() << std::endl;
151 commands.back().addTarget();
152 commands.back().targets_.back().table_ = targetNode.getConfigurationName();
153 commands.back().targets_.back().UID_ = targetNode.getValueAsString();
157 commands.back().params_.emplace(std::pair<
160 commandSpecificFields[i].first,
161 commandSpecificFields[i].second.getValueAsString()));