DUECA/DUSIME
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
dueca::Module Class Referenceabstract

Base class for user-created self contained objects in DUECA. More...

#include <Module.hxx>

Inheritance diagram for dueca::Module:
Inheritance graph
[legend]
Collaboration diagram for dueca::Module:
Collaboration graph
[legend]

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 ModuleStategetState ()
 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 NameSetgetNameSet () const
 This returns the complete name set.
 
const GlobalIdgetId () 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
 

Detailed Description

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.

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.

Member Function Documentation

◆ complete()

virtual bool dueca::Module::complete ( )
virtual

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!)

Returns
True if all initialisation successful

Reimplemented in dueca::GLSweeper, dueca::hdf5log::HDF5Logger, dueca::hdf5log::HDF5Replayer, dueca::ActivityView, dueca::ConfigStorage, dueca::websock::WebSocketsServer< Encoder, Decoder >, and dueca::ActivityViewBase.

◆ isPrepared()

virtual bool dueca::Module::isPrepared ( )
pure virtual

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.

Returns
True if ready for running

Implemented in dueca::ActivityViewBase, dueca::TimingView, dueca::hdf5log::HDF5Replayer, dueca::ConfigStorage, and dueca::websock::WebSocketsServerBase.

◆ isInitialPrepared()

virtual bool dueca::Module::isInitialPrepared ( )
virtual

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.

Returns
True if ready for next phase

◆ getObjectType()

ObjectType dueca::Module::getObjectType ( ) const
inlinevirtual

The object type within DUECA.

Implements dueca::NamedObject.

◆ startModule()

virtual void dueca::Module::startModule ( const TimeSpec & time)
pure virtual

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.

Parameters
timeStart time for any activities

Implemented in dueca::ActivityViewBase, dueca::TimingView, dueca::hdf5log::HDF5Replayer, dueca::ConfigStorage, and dueca::websock::WebSocketsServerBase.

◆ stopModule()

virtual void dueca::Module::stopModule ( const TimeSpec & time)
pure virtual

Stop the module's activity (activities)

This is called with some lead time, back to "safe" phase on the control panel.

Parameters
timeStop time for any activities

Implemented in dueca::ActivityViewBase, dueca::TimingView, dueca::hdf5log::HDF5Replayer, dueca::ConfigStorage, and dueca::websock::WebSocketsServerBase.

◆ initialStartModule()

virtual void dueca::Module::initialStartModule ( const TimeSpec & time)
virtual

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.

Parameters
timeStart time for any activities

◆ finalStopModule()

virtual void dueca::Module::finalStopModule ( const TimeSpec & time)
virtual

Final stop command.

Transition from "safe" to "off"

Parameters
timeStop time for any activities

The documentation for this class was generated from the following file: