Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 36 additions & 20 deletions src/WIECApplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,17 @@ WIECApplication::generate_modules(std::shared_ptr<appmodel::ConfigurationHelper>
throw(BadConf(ERS_HERE, fmt::format("WEICApplication requires NWDetDataReceiver, found {} of class {}", det_receiver->UID(), det_receiver->class_name())));
}

// Loop over senders
// Note on how to exclude the senders.
// The hardware interface requires that all the physical links be configured, even if not used for a run.
// Consequently, at the configuration level, we should never remove senders from a detector to daq connection.
// At most, we should exclude them at the level of the session.
// For the same reason, in this code, we create a map of control hosts to senders, without checking if the senders are excluded.
// Once the map is created, if all the senders associated to a control hosts are excluded, then we skip the creation of all related modules.

// Loop over senders to create the map of control hosts to senders.
for (const auto* sender : det_senders) {

if (helper->is_excluded(sender)) {
TLOG() << "Skipping excluded sender: " << sender->UID();
continue;
}

// Check the sender type, must me a HermesSender
// Check the sender type, must be a HermesSender
const auto* hrms_sender = sender->cast<appmodel::HermesDataSender>();
if (!hrms_sender ) {
throw(BadConf(ERS_HERE, fmt::format("DataSender {} is not a appmodel::HermesDataSender", sender->UID())));
Expand All @@ -105,6 +107,20 @@ WIECApplication::generate_modules(std::shared_ptr<appmodel::ConfigurationHelper>

for( const auto& [ctrlhost, senders] : ctrlhost_sender_map ) {

// If all senders for this control host are excluded, skip creating related modules.
// Of course the opposite logic is faster: check if any sender is included.
bool any_included = false;
for ( const auto* sender : senders ){
if ( helper->is_included(sender) ) {
any_included = true;
break;
}
}
if (!any_included) {
TLOG_DEBUG(6) << "Skipping control host " << ctrlhost << " whose senders are all excluded.";
continue;
}

// Create WIBModule
if ( this->get_wib_module_conf() ) {

Expand All @@ -119,21 +135,20 @@ WIECApplication::generate_modules(std::shared_ptr<appmodel::ConfigurationHelper>

// std::cout << std::format("stream {} -> femb {}", stream_id, femb_id) << std::endl;

// Enable the femb if any of the associated streams is enabld
// Senders in this senders list should be enabled, but better safe than sorry.
// Enable the femb if any of the associated streams is enabled
enable_fembs[femb_id] |= helper->is_included(det_stream);
}
}
} // loop over streams
} // loop over senders for this control host

std::string wib_uid = fmt::format("wib-ctrl-{}-{}", this->UID(), ctrlhost);
conffwk::ConfigObject wib_obj = obj_fac.create("WIBModule", wib_uid);
wib_obj.set_by_val<std::string>("wib_addr", fmt::format("{}://{}:{}", this->get_wib_module_conf()->get_communication_type(), ctrlhost, this->get_wib_module_conf()->get_communication_port()));
wib_obj.set_by_val<bool>("enabled_femb0", enable_fembs[0]);
wib_obj.set_by_val<bool>("enabled_femb1", enable_fembs[1]);
wib_obj.set_by_val<bool>("enabled_femb2", enable_fembs[2]);
wib_obj.set_by_val<bool>("enabled_femb3", enable_fembs[3]);
for (int i=0; i<4; ++i) {
wib_obj.set_by_val<bool>(fmt::format("enabled_femb{}", i), enable_fembs[i]);
}
wib_obj.set_obj("conf", &this->get_wib_module_conf()->get_settings()->config_object());
modules.push_back(config->get<appmodel::WIBModule>(wib_obj));
}
} // if we have a module configuration for the WIB module

// Create Hermes Modules
if (this->get_hermes_module_conf()) {
Expand All @@ -146,17 +161,18 @@ WIECApplication::generate_modules(std::shared_ptr<appmodel::ConfigurationHelper>

std::vector< const conffwk::ConfigObject * > links_obj;
for ( const auto* sndr : senders ){
// Note that it is OK that some of these senders might be excluded
// The hardware interface in HermesModule requires that all links be configured, even if not used for a run
links_obj.push_back(&sndr->config_object());
}
hermes_obj.set_objs("links", links_obj);

modules.push_back(config->get<appmodel::HermesModule>(hermes_obj));
}

} // If we have a module configuration for the Hermes module

}
} // loop over control hosts

}
} // loop over detector to daq connections

obj_fac.update_modules(modules);
}
Expand Down
Loading