@@ -77,6 +77,7 @@ std::tuple<OccLite::nopb::TransitionResponse, ::grpc::Status> doTransition(fair:
7777 auto onDeviceStateChange = [&](fair::mq::PluginServices::DeviceState reachedState) {
7878 // CONFIGURE arguments must be pushed during InitializingDevice
7979 if (reachedState == fair::mq::PluginServices::DeviceState::InitializingDevice) {
80+ OLOG (debug) << " INITIALIZING_DEVICE reached, pushing configuration parameters" ;
8081
8182 // FIXME: workaround which special cases a stoi for certain properties
8283 // which must be pushed as int.
@@ -92,38 +93,42 @@ std::tuple<OccLite::nopb::TransitionResponse, ::grpc::Status> doTransition(fair:
9293 for (auto it = arguments.cbegin (); it != arguments.cend (); ++it) {
9394 std::string key = it->key ;
9495 std::string value = it->value ;
95- if (boost::starts_with (key, " chans." )) {
96- std::vector<std::string> split;
97- boost::split (split, key, std::bind (std::equal_to<>(), ' .' , std::placeholders::_1));
98- if (std::find (intKeys.begin (), intKeys.end (), split.back ()) != intKeys.end ()) {
99- auto intValue = std::stoi (value);
100- m_pluginServices->SetProperty (key, intValue);
101- OLOG (debug) << " SetProperty(chan int) called " << key << " :" << intValue;
102- }
103- else {
96+ try {
97+ if (boost::starts_with (key, " chans." )) {
98+ std::vector<std::string> split;
99+ boost::split (split, key, std::bind (std::equal_to<>(), ' .' , std::placeholders::_1));
100+ if (std::find (intKeys.begin (), intKeys.end (), split.back ()) != intKeys.end ()) {
101+ auto intValue = std::stoi (value);
102+ m_pluginServices->SetProperty (key, intValue);
103+ OLOG (debug) << " SetProperty(chan int) called " << key << " :" << intValue;
104+ } else {
105+ m_pluginServices->SetProperty (key, value);
106+ OLOG (debug) << " SetProperty(chan string) called " << key << " :" << value;
107+ }
108+ } else if (boost::starts_with (key, " __ptree__:" )) {
109+ // we need to ptreefy whatever payload we got under this kind of key, on a best-effort basis
110+ auto [newKey, newValue] = propMapEntryToPtree (key, value);
111+ if (newKey ==
112+ key) { // Means something went wrong and the called function already printed out the message
113+ continue ;
114+ }
115+
116+ m_pluginServices->SetProperty (newKey, newValue);
117+ OLOG (debug) << " SetProperty(ptree) called " << newKey << " :" << value;
118+ } else { // default case, 1 k-v ==> 1 SetProperty
104119 m_pluginServices->SetProperty (key, value);
105- OLOG (debug) << " SetProperty(chan string) called " << key << " :" << value;
106- }
107- }
108- else if (boost::starts_with (key, " __ptree__:" )) {
109- // we need to ptreefy whatever payload we got under this kind of key, on a best-effort basis
110- auto [newKey, newValue] = propMapEntryToPtree (key, value);
111- if (newKey == key) { // Means something went wrong and the called function already printed out the message
112- continue ;
120+ OLOG (debug) << " SetProperty(string) called " << key << " :" << value;
113121 }
114-
115- m_pluginServices->SetProperty (newKey, newValue);
116- OLOG (debug) << " SetProperty(ptree) called " << newKey << " :" << value;
117122 }
118- else { // default case, 1 k-v ==> 1 SetProperty
119- m_pluginServices->SetProperty (key, value);
120- OLOG (debug) << " SetProperty(string) called " << key << " :" << value;
123+ catch (std::runtime_error &e) {
124+ OLOG (warning) << " SetProperty call failed for key " + key + " with reason: " << e.what ();
121125 }
122126 }
123127 auto chInfo = m_pluginServices->GetPropertiesAsStringStartingWith (" chans." );
124128 for (auto it = chInfo.cbegin (); it != chInfo.cend (); ++it) {
125- OLOG (debug) << " Written chan cfg: " << it->first << " :" << it->second ;
129+ OLOG (debug) << " Written chan cfg: " << it->first << " : " << it->second ;
126130 }
131+ OLOG (debug) << " INITIALIZING_DEVICE configuration push DONE" ;
127132 }
128133
129134 std::unique_lock<std::mutex> lk (cv_mu);
0 commit comments