00001 #include "otsdaq-core/ConfigurationPluginDataFormats/IterateConfiguration.h"
00002 #include "otsdaq-core/Macros/ConfigurationPluginMacros.h"
00003 #include "otsdaq-core/ConfigurationInterface/ConfigurationManager.h"
00004
00005 #include <iostream>
00006 #include <string>
00007
00008 using namespace ots;
00009
00010
00011
00012 const std::string IterateConfiguration::COMMAND_BEGIN_LABEL = "BEGIN_LABEL";
00013 const std::string IterateConfiguration::COMMAND_CHOOSE_FSM = "CHOOSE_FSM";
00014 const std::string IterateConfiguration::COMMAND_CONFIGURE_ACTIVE_GROUP = "CONFIGURE_ACTIVE_GROUP";
00015 const std::string IterateConfiguration::COMMAND_CONFIGURE_ALIAS = "CONFIGURE_ALIAS";
00016 const std::string IterateConfiguration::COMMAND_CONFIGURE_GROUP = "CONFIGURE_GROUP";
00017 const std::string IterateConfiguration::COMMAND_EXECUTE_FE_MACRO = "EXECUTE_FE_MACRO";
00018 const std::string IterateConfiguration::COMMAND_EXECUTE_MACRO = "EXECUTE_MACRO";
00019 const std::string IterateConfiguration::COMMAND_MODIFY_ACTIVE_GROUP = "MODIFY_ACTIVE_GROUP";
00020 const std::string IterateConfiguration::COMMAND_REPEAT_LABEL = "REPEAT_LABEL";
00021 const std::string IterateConfiguration::COMMAND_RUN = "RUN";
00022
00023 const std::string IterateConfiguration::ITERATE_TABLE = "IterateConfiguration";
00024 const std::string IterateConfiguration::PLAN_TABLE = "IterationPlanConfiguration";
00025 const std::string IterateConfiguration::TARGET_TABLE = "IterationTargetConfiguration";
00026
00027 const std::map<std::string,std::string> IterateConfiguration::commandToTableMap_ = IterateConfiguration::createCommandToTableMap();
00028
00029 IterateConfiguration::PlanTableColumns IterateConfiguration::planTableCols_;
00030 IterateConfiguration::IterateTableColumns IterateConfiguration::iterateTableCols_;
00031
00032 IterateConfiguration::CommandBeginLabelParams IterateConfiguration::commandBeginLabelParams_;
00033 IterateConfiguration::CommandConfigureActiveParams IterateConfiguration::commandConfigureActiveParams_;
00034 IterateConfiguration::CommandConfigureAliasParams IterateConfiguration::commandConfigureAliasParams_;
00035 IterateConfiguration::CommandConfigureGroupParams IterateConfiguration::commandConfigureGroupParams_;
00036 IterateConfiguration::CommandExecuteFEMacroParams IterateConfiguration::commandExecuteFEMacroParams_;
00037 IterateConfiguration::CommandExecuteMacroParams IterateConfiguration::commandExecuteMacroParams_;
00038 IterateConfiguration::CommandModifyActiveParams IterateConfiguration::commandModifyActiveParams_;
00039 IterateConfiguration::CommandRepeatLabelParams IterateConfiguration::commandRepeatLabelParams_;
00040 IterateConfiguration::CommandRunParams IterateConfiguration::commandRunParams_;
00041 IterateConfiguration::CommandChooseFSMParams IterateConfiguration::commandChooseFSMParams_;
00042
00043 IterateConfiguration::TargetParams IterateConfiguration::targetParams_;
00044 IterateConfiguration::TargetColumns IterateConfiguration::targetCols_;
00045
00046
00047
00048
00049 IterateConfiguration::IterateConfiguration(void)
00050 : ConfigurationBase(IterateConfiguration::ITERATE_TABLE)
00051 {
00052 }
00053
00054
00055 IterateConfiguration::~IterateConfiguration(void)
00056 {
00057 }
00058
00059
00060 void IterateConfiguration::init(ConfigurationManager *configManager)
00061 {
00062
00063 __COUT__ << "*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*" << std::endl;
00064 __COUT__ << configManager->__SELF_NODE__ << std::endl;
00065
00066 std::string value;
00067 auto childrenMap = configManager->__SELF_NODE__.getChildren();
00068 for(auto &childPair: childrenMap)
00069 {
00070
00071 __COUT__ << childPair.first << std::endl;
00072
00073
00074 }
00075 }
00076
00077
00078 std::vector<IterateConfiguration::Command> IterateConfiguration::getPlanCommands(
00079 ConfigurationManager *configManager, const std::string& plan) const
00080 {
00081 __COUT__ << configManager->__SELF_NODE__ << std::endl;
00082
00083 ConfigurationTree planNode = configManager->__SELF_NODE__.getNode(plan);
00084
00085 if(!planNode.getNode(IterateConfiguration::planTableCols_.Status_).getValue<bool>())
00086 {
00087 __SS__ << "Error! Attempt to access disabled plan (Status=FALSE)." << std::endl;
00088 __COUT_ERR__ << ss.str();
00089 throw std::runtime_error(ss.str());
00090 }
00091
00092 std::vector<IterateConfiguration::Command> commands;
00093
00094 auto commandChildren = planNode.getNode(
00095 IterateConfiguration::iterateTableCols_.PlanLink_).getChildren();
00096
00097 for(auto &commandChild: commandChildren)
00098 {
00099 __COUT__ << "Command \t" << commandChild.first << std::endl;
00100
00101 __COUT__ << "\t\tStatus \t" << commandChild.second.getNode(
00102 IterateConfiguration::planTableCols_.Status_) << std::endl;
00103
00104 __COUT__ << "\t\tType \t" << commandChild.second.getNode(
00105 IterateConfiguration::planTableCols_.CommandType_) << std::endl;
00106
00107 if(!commandChild.second.getNode(
00108 IterateConfiguration::planTableCols_.Status_).getValue<bool>())
00109 continue;
00110
00111 commands.push_back(IterateConfiguration::Command());
00112 commands.back().type_ = commandChild.second.getNode(
00113 IterateConfiguration::planTableCols_.CommandType_).getValue<std::string>();
00114
00115 auto commandSpecificFields = commandChild.second.getNode(
00116 IterateConfiguration::planTableCols_.CommandLink_).getChildren();
00117
00118 for(unsigned int i=0; i<commandSpecificFields.size()-3; ++i)
00119 {
00120 __COUT__ << "\t\tParameter \t" << commandSpecificFields[i].first << " = \t" <<
00121 commandSpecificFields[i].second << std::endl;
00122
00123 commands.back().params_.emplace(std::pair<
00124 std::string ,
00125 std::string >(
00126 commandSpecificFields[i].first,
00127 commandSpecificFields[i].second.getValueAsString()));
00128 }
00129 }
00130
00131 return commands;
00132 }
00133
00134 DEFINE_OTS_CONFIGURATION(IterateConfiguration)