Skip to content
4 changes: 4 additions & 0 deletions schema/appmodel/application.schema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,10 @@
<method name="generate_modules" description="Generate dal objects for streams of thie ReadoutApplication on the fly">
<method-implementation language="c++" prototype="void generate_modules(std::shared_ptr&lt;appmodel::ConfigurationHelper&gt;) const override" body=""/>
</method>
<method name="is_disabled" description="Generate dal objects for streams of thie ReadoutApplication on the fly">
<method-implementation language="c++" prototype="bool is_disabled(const dunedaq::confmodel::ResourceTree&amp; session) const" body=""/>
</method>

</class>

<class name="TPStreamWriterConf">
Expand Down
40 changes: 38 additions & 2 deletions src/TPWriterApplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@
#include "conffwk/Configuration.hpp"
#include "oks/kernel.hpp"
#include "confmodel/Connection.hpp"
#include "confmodel/Service.hpp"
#include "confmodel/NetworkConnection.hpp"
#include "appmodel/ReadoutApplication.hpp"
#include "confmodel/Service.hpp"
#include "appmodel/SourceIDConf.hpp"
#include "appmodel/TPStreamWriterApplication.hpp"
#include "appmodel/TPStreamWriterModule.hpp"
#include "appmodel/TPStreamWriterConf.hpp"
#include "appmodel/NetworkConnectionRule.hpp"
#include "appmodel/NetworkConnectionDescriptor.hpp"
#include "appmodel/SourceIDConf.hpp"
#include "appmodel/appmodelIssues.hpp"
#include "logging/Logging.hpp"

Expand Down Expand Up @@ -79,5 +80,40 @@ TPStreamWriterApplication::generate_modules(std::shared_ptr<appmodel::Configurat
obj_fac.update_modules(modules);
}

bool TPStreamWriterApplication::is_disabled(const dunedaq::confmodel::ResourceTree& holder) const {
/* Disabled if:
1. I am explicitly disabled
2. All ReadoutApplications are disabled
3. TPGeneration is disabled in all readout applications
*/

// First we can just check if the application itself is disabled
if (!holder.disabled_components().is_enabled(this)){
return true;
}

// Now for the tricky bit, we need to loop over the connections

for(auto& rule : get_network_rules()){
/// HACK (minor): We assume TPs will always contain this exact rule
if(rule->UID()!="tpset-net-rule"){continue;}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use the same logic as at line 50 where you will at least be consistent

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah because I was being silly! Will fix in a moment


// We now loop over the parents
for(auto parent : configuration().referenced_by(*rule)){

// Safer than blindly casting to ReadoutApplication (RA)
if(!parent->castable("ReadoutApplication")) continue;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think casting and checking for nullptr is just as safe. The continue should really be on a line of its own, surrounded by braces. If statements without braces are against the coding conventions and really screw up my reading of code.

auto casted = parent->cast<appmodel::ReadoutApplication>();

/// If the RA is disabled then so is its TP
if(casted->is_disabled(holder)){continue;}
// If the TP is enabled on ANY RA then we're enabled
if(casted->get_tp_generation_enabled()){return false;}
}
}

return true;
}

} // namespace appmodel
} // namespace dunedaq
Loading