DUECA/DUSIME
|
Base class for user-created self contained objects in DUECA. More...
#include <Module.hxx>
Public Member Functions | |
virtual | ~Module () |
Destructor. | |
virtual bool | complete () |
Inform the module that all parameters have now been passed. | |
virtual bool | isPrepared ()=0 |
To check whether the module is ready for work. | |
virtual bool | isInitialPrepared () |
To check whether the module is prepared to be prepared. | |
ObjectType | getObjectType () const |
The object type within DUECA. | |
virtual void | startModule (const TimeSpec &time)=0 |
Start the module's activity (activities) | |
virtual void | stopModule (const TimeSpec &time)=0 |
Stop the module's activity (activities) | |
virtual void | initialStartModule (const TimeSpec &time) |
Initial start opportunity. | |
virtual void | finalStopModule (const TimeSpec &time) |
Final stop command. | |
const Entity * | getMyEntity () |
Return a pointer to the entity to which this module belongs. | |
const ModuleState & | getState () |
Return the module state. | |
Public Member Functions inherited from dueca::NamedObject | |
const std::string | getEntity () const |
Returns the "entity" part of the name. | |
const std::string | getClass () const |
Returns the "class" part of the name. | |
const std::string | getPart () const |
Returns the sub-entity or "part" part of the name. | |
const NameSet & | getNameSet () const |
This returns the complete name set. | |
const GlobalId & | getId () const |
This returns the id. | |
Protected Member Functions | |
Module (const Entity *e, const char *m_class, const char *part) | |
Constructor. | |
virtual void | setSafetyStop () |
Put a brake on this module's activities. | |
Protected Member Functions inherited from dueca::NamedObject | |
NamedObject (const GlobalId &id) | |
Reserve for AssociateObject. | |
NamedObject (const NameSet &ns) | |
Normal constructor, protected, because it has no use to create a NamedObject by itself. | |
virtual | ~NamedObject () |
Destructor. | |
Protected Attributes | |
ModuleState | state |
Flag to remember whether we are stopped due to some error with hardware device manipulation. | |
Friends | |
class | CriticalActivity |
class | Entity |
Base class for user-created self contained objects in DUECA.
A Module is a class that basically obeys to some simple DUECA rules (it listens to its Entity), and which can be created from Scheme or Python, one of the scripting languages used in DUECA. Note that for simulations, often the SimulationModule class – derived from Module – is used as a base class for application code.
A Module can register one or more activities, and supply the conditions on which the activities must be invoked. In the activities the module's work is done; simulation, control, data processing, etc.
For certain situations, it is good to know from which thread a module's method is called.
Modules are created from the main thread of DUECA. This thread handles script (Scheme or Python) interaction, thus the constructor and any methods listed in the ParameterTable are called from this thread. There is access to your data, but not much more at this phase.
After creation of all initial modules in DUECA, applicable graphics code is initialized. Typically a windowing toolkit like GTK2, gtk3, glut may be started. After that, the Module::complete() method is called. At this stage, windows using the graphics code may be opened.
Module control is done from the "admin" or priority 0 thread. This thread commonly also does the gtk interface code, if a gtk interface is present. So the startModule, stopModule, initialStartModule and finalStopModule methods are called from this thread.
It is common for a module to have one or sometimes more activities; the priority for these activities can be freely chosen, and is often configurable. So you should take care when sharing data between these activities and the module control callbacks.
However, module control callbacks are called with a time specification that gives you some lead. In general it is safe to access the module's data, and then set the activity active.
Inform the module that all parameters have now been passed.
Override this complete method if you have non-trivial work to do before starting to run. Examples are reading large databases, opening graphic (especially accelerated GL) windows, etc. Return false if something in the parameters is wrong (by the way, it would help if you printed what!)
Reimplemented in dueca::GLSweeper, dueca::hdf5log::HDF5Logger, dueca::hdf5log::HDF5Replayer, dueca::ActivityView, dueca::ConfigStorage, dueca::websock::WebSocketsServer< Encoder, Decoder >, and dueca::ActivityViewBase.
To check whether the module is ready for work.
In this phase, typically check that channel tokens needed for communication are valid. May be called repeatedly.
Implemented in dueca::ActivityViewBase, dueca::TimingView, dueca::hdf5log::HDF5Replayer, dueca::ConfigStorage, and dueca::websock::WebSocketsServerBase.
To check whether the module is prepared to be prepared.
This method may be overloaded (e.g. by HardwareModule derived classes) to indicate that the hardware may be started. Typically isInitialPrepared checks all DUECA-independent conditions for running (hardware, datafiles, etc.) and isPrepared checks DUECA communication.
|
inlinevirtual |
The object type within DUECA.
Implements dueca::NamedObject.
Start the module's activity (activities)
This is called only after isPrepared has returned true. This is called with some lead time, typically start activities at the time passed in. Associated with the "work" phase of the control panel.
time | Start time for any activities |
Implemented in dueca::ActivityViewBase, dueca::TimingView, dueca::hdf5log::HDF5Replayer, dueca::ConfigStorage, and dueca::websock::WebSocketsServerBase.
Stop the module's activity (activities)
This is called with some lead time, back to "safe" phase on the control panel.
time | Stop time for any activities |
Implemented in dueca::ActivityViewBase, dueca::TimingView, dueca::hdf5log::HDF5Replayer, dueca::ConfigStorage, and dueca::websock::WebSocketsServerBase.
Initial start opportunity.
This is called after isInitialPrepared returned true, associated with the "safe" phase on the control panel. This is typically used by hardware modules that need to actively control a hardware device; use a CriticalActivity to control the phase transitions between safe and work.
time | Start time for any activities |
Final stop command.
Transition from "safe" to "off"
time | Stop time for any activities |