ChimeraTK-ApplicationCore
04.01.00
|
#include <DeviceModule.h>
Public Member Functions | |
DeviceModule (ModuleGroup *owner, const std::string &deviceAliasOrCDD, const std::string &triggerPath={}, std::function< void(ChimeraTK::Device &)> initialisationHandler=nullptr, const std::string &pathInDevice="/") | |
Create ConnectingDeviceModule which is connected to the control system at the path of the owner. More... | |
DeviceModule (DeviceModule &&other) noexcept | |
Move operation with the move constructor. More... | |
DeviceModule & | operator= (DeviceModule &&other) noexcept |
Move assignment. More... | |
DeviceManager & | getDeviceManager () |
Return the corresponding DeviceManager. More... | |
const DeviceManager & | getDeviceManager () const |
Model::DeviceModuleProxy | getModel () |
const std::string & | getDeviceAliasOrURI () const |
void | addInitialisationHandler (std::function< void(ChimeraTK::Device &)> initialisationHandler) |
void | reportException (std::string errMsg) |
Use this function to report an exception. More... | |
const std::string & | getTriggerPath () const |
ModuleGroup (ModuleGroup *owner, const std::string &name, const std::string &description, const std::unordered_set< std::string > &tags={}) | |
Constructor: Create ModuleGroup by the given name with the given description and register it with its owner. More... | |
ModuleGroup ()=default | |
Default constructor to allow late initialisation of module groups. More... | |
ModuleGroup (ModuleGroup &&other) noexcept | |
Move constructor. More... | |
Public Member Functions inherited from ChimeraTK::ModuleGroup | |
ModuleGroup (ModuleGroup *owner, const std::string &name, const std::string &description, const std::unordered_set< std::string > &tags={}) | |
Constructor: Create ModuleGroup by the given name with the given description and register it with its owner. More... | |
ModuleGroup ()=default | |
Default constructor to allow late initialisation of module groups. More... | |
ModuleGroup (ModuleGroup &&other) noexcept | |
Move constructor. More... | |
ModuleGroup & | operator= (ModuleGroup &&other) noexcept |
Move assignment. 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... | |
ChimeraTK::Model::ModuleGroupProxy | 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... | |
virtual void | run () |
Execute the module. More... | |
virtual void | terminate () |
Terminate 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 Attributes | |
boost::weak_ptr< DeviceManager > | _dm |
The corresponding DeviceManager. More... | |
Model::DeviceModuleProxy | _model |
std::string | _triggerPath |
std::string | _pathInDevice |
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 20 of file DeviceModule.h.
ChimeraTK::DeviceModule::DeviceModule | ( | ModuleGroup * | owner, |
const std::string & | deviceAliasOrCDD, | ||
const std::string & | triggerPath = {} , |
||
std::function< void(ChimeraTK::Device &)> | initialisationHandler = nullptr , |
||
const std::string & | pathInDevice = "/" |
||
) |
Create ConnectingDeviceModule which is connected to the control system at the path of the owner.
deviceAliasOrURI: identifies the device by either the alias found in the DMAP file or directly a CDD.
triggerPath specifies a control system variable which is used as a trigger where needed.
initialisationHandler specifies a callback function to initialise the device (optional, default is none).
pathInDevice specifies a module in the device register hierarchy which should be used and connected to the control system (optional, default is "/" which connects the entire device).
Note about typical usage: A DeviceModule constructed with this constructor is often owned by the ModuleGroup which is using this device. The device should be a logical name mapped device so the variable hierarchy of the ModuleGroup and the Device can be matched. The logical device may be subdivided into several parts, e.g. if different parts of the device are used by independent ModuleGroups, or if different triggers are required. This is possible by use of the pathInDevice prefix.
To avoid the creation of multiple DeviceBackends for the same device (which may not even be possible for some transport protocols) make sure that the device CDD is identical for all instances (the alias name does not matter, so multiple DMAP file entries pointing to the same device are possible if needed).
create subdirectory if necessary
Definition at line 17 of file DeviceModule.cc.
|
inlinenoexcept |
Move operation with the move constructor.
Definition at line 50 of file DeviceModule.h.
void ChimeraTK::DeviceModule::addInitialisationHandler | ( | std::function< void(ChimeraTK::Device &)> | initialisationHandler | ) |
const std::string & ChimeraTK::DeviceModule::getDeviceAliasOrURI | ( | ) | const |
const DeviceManager & ChimeraTK::DeviceModule::getDeviceManager | ( | ) |
Return the corresponding DeviceManager.
Definition at line 136 of file DeviceModule.cc.
const DeviceManager& ChimeraTK::DeviceModule::getDeviceManager | ( | ) | const |
Model::DeviceModuleProxy ChimeraTK::DeviceModule::getModel | ( | ) |
|
inline |
Definition at line 74 of file DeviceModule.h.
|
default |
Default constructor to allow late initialisation of module groups.
|
inlinenoexcept |
Move constructor.
Definition at line 32 of file ModuleGroup.h.
ChimeraTK::ModuleGroup::ModuleGroup |
Constructor: Create ModuleGroup by the given name with the given description and register it with its owner.
The specified list of tags will be added to all elements directly or indirectly owned by this instance.
Note: ModuleGroups may only be owned by the Application or other ModuleGroups.
Definition at line 12 of file ModuleGroup.cc.
|
noexcept |
Move assignment.
Definition at line 75 of file DeviceModule.cc.
void ChimeraTK::DeviceModule::reportException | ( | std::string | errMsg | ) |
Use this function to report an exception.
It should be called whenever a ChimeraTK::runtime_error has been caught when trying to interact with this device. It is primarily used by the ExceptionHandlingDecorator, but also user modules can report exception and trigger the recovery mechanism like this.
Definition at line 166 of file DeviceModule.cc.
|
friend |
Definition at line 81 of file DeviceModule.h.
|
protected |
The corresponding DeviceManager.
Definition at line 78 of file DeviceModule.h.
|
protected |
Definition at line 80 of file DeviceModule.h.
|
protected |
Definition at line 85 of file DeviceModule.h.
|
protected |
Definition at line 83 of file DeviceModule.h.