ChimeraTK-ApplicationCore
04.01.00
|
#include <ApplicationModule.h>
Public Member Functions | |
ApplicationModule (ModuleGroup *owner, const std::string &name, const std::string &description, const std::unordered_set< std::string > &tags={}) | |
Create ApplicationModule and register it with its owner. More... | |
ApplicationModule ()=default | |
Default constructor: Allows late initialisation of modules (e.g. More... | |
ApplicationModule (ApplicationModule &&other) noexcept | |
Move operation with the move constructor. More... | |
ApplicationModule & | operator= (ApplicationModule &&other) noexcept |
Move assignment. More... | |
~ApplicationModule () override | |
Destructor. More... | |
virtual void | mainLoop ()=0 |
To be implemented by the user: function called in a separate thread executing the main loop of the module. More... | |
void | run () override |
Execute the module. More... | |
void | terminate () override |
Terminate the module. More... | |
ModuleType | getModuleType () const override |
Return the module type of this module, or in case of a VirtualModule the module type this VirtualModule was derived from. More... | |
VersionNumber | getCurrentVersionNumber () const override |
Return the current version number which has been received with the last push-type read operation. More... | |
DataValidity | getDataValidity () const override |
Return the data validity flag. More... | |
void | incrementDataFaultCounter () override |
Set the data validity flag to fault and increment the fault counter. More... | |
void | decrementDataFaultCounter () override |
Decrement the fault counter and set the data validity flag to ok if the counter has reached 0. More... | |
size_t | getDataFaultCounter () const |
Get the Number of inputs which report DataValidity::faulty. More... | |
void | setCurrentVersionNumber (VersionNumber versionNumber) override |
Set the current version number. More... | |
std::list< EntityOwner * > | getInputModulesRecursively (std::list< EntityOwner * > startList) override |
Use pointer to the module as unique identifier. More... | |
size_t | getCircularNetworkHash () const override |
Get the ID of the circular dependency network (0 if none). More... | |
void | setCircularNetworkHash (size_t circularNetworkHash) |
Set the ID of the circular dependency network. More... | |
ChimeraTK::Model::ApplicationModuleProxy | getModel () |
Return the application model proxy representing this module. More... | |
void | unregisterModule (Module *module) override |
Unregister another module as a sub-module. More... | |
Logger::StreamProxy | logger (Logger::Severity severity) |
Convenicene function to obtain a logger stream with the given Severity. More... | |
Public Member Functions inherited from ChimeraTK::VariableGroup | |
VariableGroup (VariableGroup *owner, const std::string &name, const std::string &description, const std::unordered_set< std::string > &tags={}) | |
Constructor: Create VariableGroup register it with its owner. More... | |
VariableGroup ()=default | |
Default constructor: Allows late initialisation of VariableGroups (e.g. More... | |
VariableGroup (VariableGroup &&other) noexcept | |
Move constructor. More... | |
VariableGroup (const VariableGroup &other) noexcept=delete | |
VariableGroup & | operator= (VariableGroup &&other) noexcept |
Move assignment. More... | |
VariableGroup & | operator= (const VariableGroup &other) noexcept=delete |
ModuleType | getModuleType () const override |
Return the module type of this module, or in case of a VirtualModule the module type this VirtualModule was derived from. More... | |
ChimeraTK::Model::VariableGroupProxy | getModel () |
Return the application model proxy representing this module. More... | |
std::string | getVirtualQualifiedName () const override |
void | unregisterModule (Module *module) override |
Unregister another module as a sub-module. More... | |
Public Member Functions inherited from ChimeraTK::Module | |
Module (EntityOwner *owner, const std::string &name, const std::string &description, const std::unordered_set< std::string > &tags={}) | |
Constructor: Create Module by the given name with the given description and register it with its owner. More... | |
Module ()=default | |
Default constructor: Allows late initialisation of modules (e.g. More... | |
~Module () override | |
Destructor. More... | |
Module (Module &&other) noexcept | |
Move constructor. More... | |
Module & | operator= (Module &&other) noexcept |
Move assignment operator. More... | |
virtual void | prepare () |
Prepare the execution of the module. More... | |
ChimeraTK::ReadAnyGroup | readAnyGroup () |
Create a ChimeraTK::ReadAnyGroup for all readable variables in this Module. More... | |
void | readAll (bool includeReturnChannels=false) |
Read all readable variables in the group. More... | |
void | readAllNonBlocking (bool includeReturnChannels=false) |
Just call readNonBlocking() on all readable variables in the group. More... | |
void | readAllLatest (bool includeReturnChannels=false) |
Just call readLatest() on all readable variables in the group. More... | |
void | writeAll (bool includeReturnChannels=false) |
Just call write() on all writable variables in the group. More... | |
void | writeAllDestructively (bool includeReturnChannels=false) |
Just call writeDestructively() on all writable variables in the group. More... | |
std::string | getQualifiedName () const override |
Get the fully qualified name of the module instance, i.e. More... | |
std::string | getFullDescription () const override |
Obtain the full description including the full description of the owner. More... | |
void | setOwner (EntityOwner *newOwner) |
Set a new owner. More... | |
EntityOwner * | getOwner () const |
VersionNumber | getCurrentVersionNumber () const override |
Return the current version number which has been received with the last push-type read operation. More... | |
void | setCurrentVersionNumber (VersionNumber version) override |
Set the current version number. More... | |
DataValidity | getDataValidity () const override |
Return the data validity flag. More... | |
void | incrementDataFaultCounter () override |
Set the data validity flag to fault and increment the fault counter. More... | |
void | decrementDataFaultCounter () override |
Decrement the fault counter and set the data validity flag to ok if the counter has reached 0. More... | |
std::list< EntityOwner * > | getInputModulesRecursively (std::list< EntityOwner * > startList) override |
Use pointer to the module as unique identifier. More... | |
size_t | getCircularNetworkHash () const override |
Get the ID of the circular dependency network (0 if none). More... | |
Module * | findApplicationModule () |
Find ApplicationModule owner. More... | |
void | disable () |
Disable the module such that it is not part of the Application. More... | |
Public Member Functions inherited from ChimeraTK::EntityOwner | |
EntityOwner (std::string name, std::string description, std::unordered_set< std::string > tags={}) | |
Constructor: Create EntityOwner by the given name with the given description. More... | |
EntityOwner () | |
Default constructor just for late initialisation. More... | |
virtual | ~EntityOwner ()=default |
Virtual destructor to make the type polymorphic. More... | |
EntityOwner (EntityOwner &&other) noexcept | |
Move constructor. More... | |
EntityOwner (const EntityOwner &other)=delete | |
EntityOwner & | operator= (EntityOwner &&other) noexcept |
Move assignment operator. More... | |
EntityOwner & | operator= (const EntityOwner &other)=delete |
const std::string & | getName () const |
Get the name of the module instance. More... | |
std::string | getQualifiedNameWithType () const |
Get the fully qualified name of the module instance, followed by the C++ data type (in pointy brackets) More... | |
const std::string & | getDescription () const |
Get the description of the module instance. More... | |
std::list< VariableNetworkNode > | getAccessorList () const |
Obtain the list of accessors/variables directly associated with this instance. More... | |
std::list< Module * > | getSubmoduleList () const |
Obtain the list of submodules associated with this instance. More... | |
std::list< VariableNetworkNode > | getAccessorListRecursive () const |
Obtain the list of accessors/variables associated with this instance and any submodules. More... | |
std::list< Module * > | getSubmoduleListRecursive () const |
Obtain the list of submodules associated with this instance and any submodules. More... | |
void | registerAccessor (VariableNetworkNode accessor) |
Called inside the constructor of Accessor: adds the accessor to the list. More... | |
void | unregisterAccessor (const VariableNetworkNode &accessor) |
Called inside the destructor of Accessor: removes the accessor from the list. More... | |
void | registerModule (Module *module, bool addTags=true) |
Register another module as a sub-module. More... | |
void | addTag (const std::string &tag) |
Add a tag to all Application-type nodes inside this group. More... | |
void | dump (const std::string &prefix="", std::ostream &stream=std::cout) const |
Print the full hierarchy to given stream. More... | |
bool | hasReachedTestableMode () |
Check whether this module has declared that it reached the testable mode. More... | |
template<typename T > | |
std::string | constant (T value) |
Create a variable name which will be automatically connected with a constant value. More... | |
Protected Member Functions | |
void | mainLoopWrapper () |
Wrapper around mainLoop(), to execute additional tasks in the thread before entering the main loop. More... | |
std::string | className () |
Name of the module class, used for logging and debugging purposes. More... | |
Protected Attributes | |
boost::thread | _moduleThread |
The thread executing mainLoop() More... | |
VersionNumber | _currentVersionNumber {nullptr} |
Version number of last push-type read operation - will be passed on to any write operations. More... | |
std::atomic< size_t > | _dataFaultCounter {0} |
Number of inputs which report DataValidity::faulty. More... | |
size_t | _circularNetworkHash {0} |
Unique ID for the circular dependency network. More... | |
detail::CircularDependencyDetectionRecursionStopper | _recursionStopper |
Helper needed to stop the recursion when detecting circular dependency networks. More... | |
ChimeraTK::Model::ApplicationModuleProxy | _model |
Protected Attributes inherited from ChimeraTK::VariableGroup | |
ChimeraTK::Model::VariableGroupProxy | _model |
Protected Attributes inherited from ChimeraTK::Module | |
EntityOwner * | _owner {nullptr} |
Owner of this instance. More... | |
Protected Attributes inherited from ChimeraTK::EntityOwner | |
std::string | _name |
The name of this instance. More... | |
std::string | _description |
The description of this instance. More... | |
std::list< VariableNetworkNode > | _accessorList |
List of accessors owned by this instance. More... | |
std::list< Module * > | _moduleList |
List of modules owned by this instance. More... | |
std::unordered_set< std::string > | _tags |
List of tags to be added to all accessors and modules inside this module. More... | |
std::atomic< bool > | _testableModeReached {false} |
Flag used by the testable mode to identify whether a thread within the EntityOwner has reached the point where the testable mode lock is acquired. More... | |
Friends | |
class | ChimeraTK::Model::Impl |
Additional Inherited Members | |
Public Types inherited from ChimeraTK::EntityOwner | |
enum | ModuleType { ModuleType::ApplicationModule, ModuleType::ModuleGroup, ModuleType::VariableGroup, ModuleType::ControlSystem, ModuleType::Device, ModuleType::Invalid } |
Static Public Member Functions inherited from ChimeraTK::Module | |
static ConfigReader & | appConfig () |
Obtain the ConfigReader instance of the application. More... | |
Static Public Attributes inherited from ChimeraTK::EntityOwner | |
static constexpr std::string_view | namePrefixConstant {"/@CONST@"} |
Prefix for constants created by constant(). More... | |
Definition at line 24 of file ApplicationModule.h.
ChimeraTK::ApplicationModule::ApplicationModule | ( | ModuleGroup * | owner, |
const std::string & | name, | ||
const std::string & | description, | ||
const std::unordered_set< std::string > & | tags = {} |
||
) |
Create ApplicationModule and register it with its owner.
The specified list of tags will be added to all elements directly or indirectly owned by this instance.
owner | The owner to register the ApplicationMoule with (ModuleGroup or Application) |
name | The name of the new ApplicationModule |
description | A description visible to the control system |
tags | List of tags to be added to all child variables (default: empty) |
ChimeraTK::logic_error | thrown if owner is of the wrong type or name is illegal. |
Definition at line 19 of file ApplicationModule.cc.
|
default |
Default constructor: Allows late initialisation of modules (e.g.
when creating arrays of modules).
|
inlinenoexcept |
Move operation with the move constructor.
Definition at line 45 of file ApplicationModule.h.
|
override |
Destructor.
Definition at line 83 of file ApplicationModule.cc.
|
inlineprotected |
Name of the module class, used for logging and debugging purposes.
Definition at line 128 of file ApplicationModule.h.
|
overridevirtual |
Decrement the fault counter and set the data validity flag to ok if the counter has reached 0.
This function will be called by all input accessors when receiving the an ok update if the previous update was faulty. The caller of this function must ensure that calles to this function are paired to a previous call to incrementDataFaultCounter().
Implements ChimeraTK::EntityOwner.
Reimplemented in Tests::testDataValidityPropagation::TestModule1, and ChimeraTK::DeviceManager.
Definition at line 155 of file ApplicationModule.cc.
|
overridevirtual |
Get the ID of the circular dependency network (0 if none).
This information is only available after the Application has finalised all connections.
Implements ChimeraTK::EntityOwner.
Reimplemented in ChimeraTK::DeviceManager.
Definition at line 213 of file ApplicationModule.cc.
|
inlineoverridevirtual |
Return the current version number which has been received with the last push-type read operation.
Implements ChimeraTK::EntityOwner.
Definition at line 63 of file ApplicationModule.h.
|
inline |
Get the Number of inputs which report DataValidity::faulty.
Definition at line 71 of file ApplicationModule.h.
|
overridevirtual |
Return the data validity flag.
If any This function will be called by all output accessors in their write functions.
Implements ChimeraTK::EntityOwner.
Reimplemented in ChimeraTK::StatusAggregator, and ChimeraTK::DeviceManager.
Definition at line 232 of file ApplicationModule.cc.
|
overridevirtual |
Use pointer to the module as unique identifier.
Implements ChimeraTK::EntityOwner.
Reimplemented in ChimeraTK::DeviceManager.
Definition at line 162 of file ApplicationModule.cc.
|
inline |
Return the application model proxy representing this module.
Definition at line 85 of file ApplicationModule.h.
|
inlineoverridevirtual |
Return the module type of this module, or in case of a VirtualModule the module type this VirtualModule was derived from.
Implements ChimeraTK::EntityOwner.
Definition at line 61 of file ApplicationModule.h.
|
overridevirtual |
Set the data validity flag to fault and increment the fault counter.
This function will be called by all input accessors when receiving the a faulty update if the previous update was ok. The caller of this function must ensure that calls to this function are paired to a subsequent call to decrementDataFaultCounter().
Implements ChimeraTK::EntityOwner.
Reimplemented in Tests::testDataValidityPropagation::TestModule1, and ChimeraTK::DeviceManager.
Definition at line 151 of file ApplicationModule.cc.
|
inline |
Convenicene function to obtain a logger stream with the given Severity.
The context string will be obtained from the class name of the module.
Definition at line 139 of file ApplicationModule.h.
|
pure virtual |
To be implemented by the user: function called in a separate thread executing the main loop of the module.
Implemented in Tests::testApplicationPVModel::RogueModule, Tests::testModules::MultiSlashVarModule::SomeModule, Tests::testModules::MultiSlashModule::SomeModule, Tests::testModules::OnlySlashModuleName::SomeModule, Tests::testModules::OnlySlashNameArrayApp::SomeModule, Tests::testModules::VariableSlashArrayApp::SomeModule, Tests::testModules::VariableSlashScalarApp::SomeModule, Tests::testModules::SlashModule, Tests::testPropagateDataFaultFlag::TestModule3, Tests::testPropagateDataFaultFlag::Module3, Tests::testBidirectionalVariables::ModuleY, Tests::testBidirectionalVariables::ModuleX, Tests::testCircularDependencyFaultyFlags::GG, Tests::testInitialValues::WriterModule, Tests::testTrigger::TestModule, Tests::testCircularDependencyFaultyFlags::AA, Tests::testBidirectionalVariables::TestApplication2::Module< ACCESSOR >, Tests::testBidirectionalVariables::TestApplication2::Module< ChimeraTK::ScalarOutputPushRB< int > >, Tests::testBidirectionalVariables::TestApplication2::Module< ChimeraTK::ScalarPushInputWB< int > >, Tests::testCircularDependencyFaultyFlags::TestModuleBase2, Tests::testInitialValues::TestModule, Tests::testAppModuleConnections::SelfUnregisteringModule, Tests::testInitialValues::ConstantModule, Tests::testPropagateDataFaultFlag::Module2, Tests::testPropagateDataFaultFlag::Module1, Tests::testAppModuleConnections::ConstantTestModule< T >, Tests::testDeviceAccessors::Deeper2::Hierarchies, Tests::testInitialValues::TriggerModule, Tests::testDeviceAccessors::Deeper, Tests::testDeviceAccessors::TestModule2, Tests::testHierarchyModifyingGroup::TestApplicationEmpty::TestModule, Tests::testInitialValues::PushModuleD92, Tests::testInitialValues::PushModuleD91, ChimeraTK::ExactMonitor< T >, Tests::testIllegalNetworks::CircularConnectionModuleWithIntermediateGroup, Tests::testIllegalNetworks::CircularConnectionModule, Tests::testTestFacilities::PollingThroughFanoutsModule, ChimeraTK::RangeMonitor< T >, ChimeraTK::RangeMonitor< double >, Tests::testBidirectionalVariables::ModuleC, Tests::testVersionpropagation::TheOutputModule, Tests::testVersionpropagation::ThePushModule, Tests::testInitialValues::ScalarOutputModule, Tests::testTestFacilities::PollingReadModule, ChimeraTK::MinMonitor< T >, Tests::testBidirectionalVariables::ModuleFunnel, Tests::testDataValidityPropagation::TriggerModule, ChimeraTK::ConfigReader, Tests::testModules::VectorModule, ChimeraTK::Divider< InputType, OutputType, NELEMS >, Tests::testUserInputValidator::UpstreamTwinOut, Tests::testCircularDependencyFaultyFlags::ModuleC, Tests::testBidirectionalVariables::ModuleD, Tests::testDataValidityPropagation::TestModule2, ChimeraTK::MaxMonitor< T >, Tests::testProcessVariableRecovery::ReadOnlyTestApplication::TestModule, Tests::testAppModuleConnections::TestModuleConsume< T >, Tests::testTestFacilities::ReadAnyTestModule, Tests::testUserInputValidator::UpstreamSingleOut, OutputModule, Tests::testConfigReader::TestModule, ChimeraTK::StatusAggregator, ChimeraTK::Multiplier< InputType, OutputType, NELEMS >, Tests::testPropagateDataFaultFlag::TestModule2, ChimeraTK::ArrayPipe< Type >, Tests::testBidirectionalVariables::ModuleB, PushModuleForTrigger, Tests::testCircularDependencyFaultyFlags::ModuleA, Tests::testDeviceExceptionFlagPropagation::TestApplication::Module, Tests::testVariableGroup::OutputModule, Tests::testStatusAggregator::StatusWithMessageGenerator, Tests::testDataValidityPropagation::TestModule1, Tests::testHierarchyModifyingGroup::TestApplication::TestModule, ChimeraTK::PeriodicTrigger, Tests::testAppModuleConnections::TestModuleFeed< T >, Tests::testControlSystemAccessors::TestModule< T >, Tests::testDeviceAccessors::TestModule, Tests::testInitialValues::InputModule< INPUT_TYPE >, Tests::testInitialValues::InputModule< ChimeraTK::ScalarPushInput< int > >, Tests::testInitialValues::InputModule< ChimeraTK::ScalarPollInput< int > >, PushModuleForFanOut, ArrayInputModule, Tests::testApplicationPVModel::TestModule, Tests::testModules::TestModule, Tests::testProcessVariableRecovery::TestModule, Tests::testTestFacilities::BlockingReadTestModule, ChimeraTK::ScriptedInitHandler, ChimeraTK::DataLossCounter< TRIGGERTYPE >, Tests::testCircularDependencyFaultyFlags::TestModuleBase, Tests::testPropagateDataFaultFlag::TestModule1, Tests::testVariableGroup::InputModule, ChimeraTK::DeviceManager, ScalarInputModule, Tests::testBidirectionalVariables::ModuleA, Tests::testDeviceExceptionFlagPropagation::TestApplication::Name, PushModule, ChimeraTK::PythonApplicationModuleTrampoline, Tests::testDataValidityPropagation::TestModule0, Tests::testStatusAggregator::StatusGenerator, Tests::testUserInputValidator::ModuleA, ChimeraTK::ScalarPipe< Type >, Tests::testApplicationPVModel::MyModule, ChimeraTK::ScalarPipe< double >, ChimeraTK::ScalarPipe< std::string >, Tests::testInitialValues::NotifyingModule, ArrayOutputModule, Tests::testFanoutConnections::TestModule1, PollModule, ScalarOutputModule, ChimeraTK::ConstMultiplier< InputType, OutputType, NELEMS >, ChimeraTK::ConstMultiplier< double >, ChimeraTK::ConstMultiplier< uint16_t, uint16_t, 120 >, Tests::testTestFaciliy2::MyModule, Tests::testPeriodicTrigger::TestModule, ChimeraTK::InvalidityTracer, ChimeraTK::ReadSplitArrayModule< TYPE >, ChimeraTK::FixedLimitValue< UserType, min, max >, ChimeraTK::LimitValue< UserType >, ChimeraTK::WriteSplitArrayModule< TYPE >, and SimulationModule.
|
protected |
Wrapper around mainLoop(), to execute additional tasks in the thread before entering the main loop.
Definition at line 97 of file ApplicationModule.cc.
|
noexcept |
Move assignment.
Definition at line 35 of file ApplicationModule.cc.
|
overridevirtual |
Execute the module.
Reimplemented from ChimeraTK::Module.
Reimplemented in Tests::testTestFacilities::PollingThroughFanoutsModule, and ChimeraTK::PyApplicationModule.
Definition at line 55 of file ApplicationModule.cc.
void ChimeraTK::ApplicationModule::setCircularNetworkHash | ( | size_t | circularNetworkHash | ) |
Set the ID of the circular dependency network.
This function can be called multiple times and throws if the value is not identical.
Definition at line 219 of file ApplicationModule.cc.
|
overridevirtual |
Set the current version number.
This function is called by the push-type input accessors in their read functions.
Implements ChimeraTK::EntityOwner.
Definition at line 89 of file ApplicationModule.cc.
|
overridevirtual |
Terminate the module.
Must/will be called before destruction, if run() was called previously.
Reimplemented from ChimeraTK::Module.
Reimplemented in ChimeraTK::DeviceManager, and ChimeraTK::PyApplicationModule.
Definition at line 63 of file ApplicationModule.cc.
|
overridevirtual |
Unregister another module as a sub-module.
Will be called automatically by all modules in their destructors.
Reimplemented from ChimeraTK::EntityOwner.
Definition at line 250 of file ApplicationModule.cc.
|
friend |
Definition at line 134 of file ApplicationModule.h.
|
protected |
Unique ID for the circular dependency network.
0 if the EntityOwner is not in a circular dependency network. Only write when in LifeCycleState::initialisation (so getDataValidity() is thread safe, required by InvalidityTracer).
Definition at line 118 of file ApplicationModule.h.
|
protected |
Version number of last push-type read operation - will be passed on to any write operations.
Definition at line 105 of file ApplicationModule.h.
|
protected |
Number of inputs which report DataValidity::faulty.
This is atomic to allow the InvalidityTracer module to access this information.
Definition at line 111 of file ApplicationModule.h.
|
protected |
Definition at line 133 of file ApplicationModule.h.
|
protected |
The thread executing mainLoop()
Definition at line 101 of file ApplicationModule.h.
|
protected |
Helper needed to stop the recursion when detecting circular dependency networks.
Only used in the setup phase.
Definition at line 123 of file ApplicationModule.h.