OMK::Controller Class Reference

Defining what a controller is. More...

#include <OMKController.h>

Inheritance diagram for OMK::Controller:

Inheritance graph
[legend]
Collaboration diagram for OMK::Controller:

Collaboration graph
[legend]
List of all members.

Public Types

typedef std::pair< Name, NameMigrationObjectPrm
typedef std::pair< ObjectDescriptor,
Name
CreateObjectPrm
 parameters to create object

Public Member Functions

 Controller (ObjectDescriptor &simulationTree, const Date &initialDate)
 constructor for a classic controller
virtual ~Controller ()
 destructor
virtual void init ()
 initialise the object.
virtual void run ()
 run Start the controller on a infinite loop which will be broken if system events are sent to the controller
template<typename Type>
std::list< const ObjectDescriptor * > * listDescendantsOfType (const Name &objectName)
 List the descendants of an object that are of a certain type.
template<typename Type>
std::list< const ObjectDescriptor * > * listBrothersOfType (const Name objectName)
 list brothers of objectName in the simulation tree of that are of type t
void processStartEventAfterMorphose (ReferenceObjectHandle *objectHandle)
 CHADI.
virtual void createLocalObject (const ObjectDescriptor &newLObjectDescription, const Name &fathersLName)
 create a local object
virtual int getMirrorsNbre ()
virtual bool isAMirror (const Name &name)
virtual std::vector< NamegetMirrorList ()
virtual std::vector< NamegetIsolatedMirrorList ()
virtual std::vector< NamegetNonIsolatedMirrorList ()
virtual bool testIfTroubleOccured ()
virtual void createNewSite (const Date &)
 DECLARE_TYPE_EVENT (MigrationObjectPrm, MigrationObject)
void migrateObjectToProcess (Name &nomObjet, Name &nomProcess)
virtual std::list< NamegetDisconnectedProcessusList ()
virtual std::map< Name, intgetDisconnectedProcessusMap ()
virtual Frequency computeAdequateFrequency (const Frequency &suggestedFrequency)
 compute an adequate Frequency for an object dynamically created Should be used to adapt the desired frequency when an simulated object is dynamically created so that the creation doesn't cause recomputation of the scheduling.
virtual void runControllersStep (ReferenceObjectHandle *objectHandle)
 run a controllers simulation step.
virtual void compute ()
 computes a new simulation step for all controlled objects, if the controller is in the running state, otherwise jsut react to system events sent to controlled objects
virtual void finish ()
 finish the simulation.
void showDateAndStepNumber (bool show=true)
 ask the controller to print (or not) to sdterr (cerr) the simulation date and the step number
virtual const DategetSimulatedDate () const
 Returns a reference to an allways accurate simulation date, in ms.
virtual int getCycleFrequency () const
 get the simulation cycle frequency
virtual int getCyclePeriod () const
 get the simulation cycle period, in simulated time (in ms)
 DECLARE_TYPE_EVENT (CreateObjectPrm, CreateObject)
virtual void createObject (const ObjectDescriptor &newObjectDescription, const Name &fathersName)
 creation of an object unknown of in the simulation tree.
virtual void destroyObject (const Name &name, bool recursively)
 destroy a simulated object.
virtual void changeObjectsFather (const Name &name, const Name &newFather)
 change the father of an object in the simulation tree.
virtual void changeObjectsFather (ObjectDescriptor *object, ObjectDescriptor *newFather)
 change the father of an object in the simulation tree.
virtual SimulatedObjectgetPointerToDuplicatedObjectNamed (const Name &name)
 get a pointer to a simulated object
virtual SimulatedObjectgetPointerToSimulatedObjectNamed (const Name &name)
 get a pointer to a simulated object After return from this method, it's possible to query any method of the simulated object that doesn't depend on the evolution of that object, as the object returned can have been created specially by the call.
virtual const ObjectDescriptorgetObjectDescriptorOfObject (const Name &objectName)
 get the object descriptor of a given simulated object
virtual std::vector< NamegetReferentielList ()
virtual void actOnSystemEvent (Event *event)
 called when a reference object receives a system event
virtual void reactToControlledObjectsSystemEvents ()
 process system events received by controlled objects
virtual void processStartEventOf (ReferenceObjectHandle *objectHandle)
 process MaskStart systemEvent for the object with handle
virtual void processDeleteEventOf (ReferenceObjectHandle *objectHandle)
 process MaskDelete systemEvent for object obj
virtual void hasEventsToProcess (ReferenceObjectHandle *referenceObjectHandle)
 add the object handled by referenceObjectHandle to the list of objects having events to process and therefore that need activation (and therefore possibly activated at the current simulation step).
virtual void postponeEventProcessing (ReferenceObjectHandle *referenceObjectHandle)
 add the object described by referenceObjectHandle to the list of object with events to process at the next simulation step.
virtual void noActivationNeededFor (ReferenceObjectHandle *referenceObjectHandle)
 remove object designated by referenceObjectHandle from the list of object needing activation by the controler because they have events pending.
virtual void addToPendingEvents (Event *)
 add the event to the list of pending events.
virtual bool addToPendingRegistrations (const EventIdentifier &sig, const Name &producer, const EventIdentifier &eventId, const Name &registrant)
 addToPendingRegistrations.
virtual bool removeFromPendingRegistrations (const EventIdentifier &sig, const Name &producer, const Name &registrant)
 removeFromPendingRegistrations.
virtual bool processEvent (Event *)
 process events sent to the controller
virtual void processEventsOfSuspendedObjects ()
 call processEvent for suspended objects having received events
virtual void broadcastEventsForSignal (Event &event, const EventIdentifier &sigId)
 broadcast events corresponding to a fired signal
virtual bool receiveRegistrationForSignal (const EventIdentifier &sigId, const Name &registrant, const EventIdentifier &eventId)
 register an object for a signal
virtual bool receiveCancellationForSignal (const EventIdentifier &sigId, const Name &registrant)
 cancel the registration of an object for a signal
template<typename Type>
Input< Type > * createInput (const Name &name, SimulatedObject &owner, bool makeConnectable, int requestedPrecisionLevel)
 create an input
template<typename Type>
SensitiveInput< Type > * createSensitiveInput (const Name &name, SimulatedObject &owner, bool makeConnectable, int requestedPrecisionLevel)
 create a sensitive input
template<typename Type>
SensitiveNotifyingInput< Type > * createSensitiveNotifyingInput (const Name &name, SimulatedObject &owner, bool makeConnectable, int requestedPrecisionLevel)
 create a sensitive notifying input
template<typename Type>
Output< Type > * createOutput (const Name &name, SimulatedObject &owner, OMK::Type::PolatorNT *polator)
 create an ouput
template<typename Type>
ControlParameter< Type > * createControlParameter (const Name &name, SimulatedObject &owner, OMK::Type::PolatorNT *polator)
 create a control parameter
template<typename Type>
InputAlias< Type > * createInputAlias (const Name &name, SimulatedObject &owner, AbstractInput< Type > *input, int requestedPrecisionLevel)
 create an input alias
template<typename Type>
SensitiveInputAlias< Type > * createSensitiveInputAlias (const Name &name, SimulatedObject &owner, AbstractInput< Type > *input, int requestedPrecisionLevel)
 create a sensitive input alias
template<typename Type>
SensitiveNotifyingInputAlias<
Type > * 
createSensitiveNotifyingInputAlias (const Name &name, SimulatedObject &owner, AbstractInput< Type > *input, int requestedPrecisionLevel)
 create a sensitive notifying input alias
template<typename Type>
OutputAlias< Type > * createOutputAlias (const Name &name, SimulatedObject &owner, Output< Type > *output, OMK::Type::PolatorNT *polator)
 create an ouput alias

Static Public Member Functions

static void error (const char *mess)
 included for ascendant compatibility : raises a OMKUserException with the message passed as parameter
static int lcm (const int a, const int b)
static int gcd (const int a, const int b)
static bool setKernelObjectFactory (KernelObjectAbstractFactory *aFactory)
 set the kernelObjectfactory for the controller of this adressing space is only effective once for each adress space to be called before creation of the controller to be effective return : change effective
static KernelObjectAbstractFactorygetKernelObjectFactory ()
 get the active kernelObjectFactory

Public Attributes

std::vector< Name_publicReferentielObjectsVector
 CHADI.

Static Public Attributes

static Date initialSimulationDate
 date at which simulation was initialised

Protected Member Functions

virtual void computeNextSimulationStep ()
 compute the next simulation step
virtual void scheduleObject (ReferenceObjectHandle *ref)
 add a simulated object to the appropriate execution frames, without flagging it as executable
MultipleConfigurationParametergetSchedulingParametersOfObject (ObjectDescriptor &)
 get a modifiable version of the scheduling parameters of an object.
SimulatedObjectcreateDescribedObject (const ObjectDescriptor *description)
 createDescribedObject.
virtual void setProcessOfDescriptor (ObjectDescriptor &objectDescription, const Name &newProcessName)
virtual void computeScheduling (bool fromOriginal)
 compute the scheduling data strucures.
virtual void sendInitialEventsTo (ReferenceObjectHandle &objectHandle, const Date &dateOfMaskStart)
 Send MaskStart to any created objects, and send any pending events which where stored (none by default) because send to an object before it was created.
virtual void deleteObject (ObjectDescriptor *objectDescription)
 delete an object.
virtual ObjectHandleremoveObjectFromDataStructures (const Name &)
 remove any reference to a simulated object from all the controller's data structures
virtual void processNewObjectDeclaration (ObjectDescriptor &declaration, const Date &declarationDate)
 processNewObjectDeclaration Once an object has been added to the simulation tree, this is called for creation and scheduling
virtual ReferenceObjectHandlecreateReferenceObject (const ObjectDescriptor *idObjet)
 createReferenceObject.
virtual SchedulercreateScheduler ()
 create the scheduler that is in charge of effective scheduling of the controlled objects
virtual void scheduleControlledObjects ()
 scheduleControlledObjects schedule all controlled reference objects
virtual void advanceSimulatedDate ()
 increment date and numberOfSimulatedSteps
virtual void createControlledObjects (const ObjectDescriptor *subTree)
 createControlledObjects Create a reference object for all objects of a simulation tree
virtual void setCycleFrequency (int newFrequency)
virtual void setComputingState (ReferenceObjectHandle *, ReferenceObjectHandle::SimulatedObjectComputingState) const
 change the computing state of a reference object handle
virtual void switchSystemEventList ()
 switch buffer of List Of Objects Needing Activation
virtual void purgeMemoryFromOldEvents (const Date &dateOfOldestKept)
 the method used to purge the data structures from all outdated kepts events.
virtual Date getPurgeDate ()
 get the date of the oldest event not purged by purgeMemoryFromOldEvents
virtual int getOutputHistorySize (void)
 get the minimum history length pertinant for this controller The value returned is the value of the environement variable MaskHISTORYLENGTH, or a default value calculated so that get(-4 dt) return an exact value if it has been produced
virtual ReferenceObjectHandlecreateReferenceObjectHandle (SimulatedObject &obj)
 create a reference object handler appropriate for this controller
virtual ReferenceObjectHandlenewOMKReferenceObjectHandle (SimulatedObject &object, Controller &controller, SignalDispatcher *signalDispatcher)
 The controller is an abstract factory for reference object handles.
virtual void deleteObjectHandle (ObjectHandle *objectHandle)
 as the controller is an abstract factory for object handlers, is should also be an abstract destroyer

Protected Attributes

NameToPointerMap< ReferenceObjectHandle_referenceObjectsMap
 data structure containing references to the ReferenceObjectHandlers
ObjectDescriptor_simulationTree
 the simulation tree this controller is root of This has to be a reference to a allready constructed simulation tree, because the root descriptor of that tree is used a parameter of the ancestors constructor wich keeps a reference of that descriptor.
unsigned long int _numberOfSimulatedSteps
 number of simulated steps up to now
Frequency _stepFrequency
 frequency of a simulation step
int _cycleFrequency
 the frequency at wich activation patterns repeat themselves
int _cyclePeriod
 duration in simulated time of a simualtion cycle
int _nbStepsByCycle
 number of simulation step by cycle : we have _cycleFrequency * stepFrequency = _nbStepsByCycle
int _stepPeriod
 _stepPeriod.
Date _date
 simulated date
bool _showDateAndStepNumber
 flag indicating if the date and simulation step number are printed
ReferenceObjectHandle::SimulatedObjectComputingState_computeStatePointer
 a pointer for easy access to th computationnel state of the controller : if the controller is controlling itsekg, this computationnal state should be : running
SignalDispatcher _controledObjectsSignalsDispatcher
 signal dispatcher for objects interested in a signal whatever it's producer
bool _forcedCompute
 to enable computations even in suspendedState, when the controller is controlled
Scheduler_scheduler
 the scheduler
std::list< ReferenceObjectHandle * > * _objectsNeedingActivationList [2]
 double buffered list of controlled object needing activation because they have received events Protect usage with _mutexForListEvt ;
int _currentListOfObjectsNeedingActivation
 1 - _currentListOfObjectsNeedingActivation is used to store new object needing activation
std::list< Event * > * _systemEventsList [2]
 double buffered system event list
unsigned int _currentWritableSystemEventsList
 _systemEventsList[_currentWritableSystemEventsList] is used to store system events sent to controlled objects
std::list< ReferenceObjectHandle * > _listOfObjectsWithPostPonedEvents
 list of objects with postponed events
std::map< Name, std::list<
Event * > > 
_pendingEventsList
 list of pending events (events sent to unknown objects)
std::map< Name, SignalDispatcher * > _pendingRegistrationRequests
 map of pending registration requests
std::list< std::pair< Date,
ObjectHandle * > > 
_deletedObjectHandles
 the list of recently deleted object handles.

Static Private Attributes

static KernelObjectAbstractFactorykernelObjectFactory
 the kernel object factory used to create attribute of controlled object

Friends

class InputNT
class OMK::SimulatedObject

Detailed Description

Defining what a controller is.

A controller is in charge of simulating time and activating objects whose evolution is time related.

Author:
David Margery
Version:

Definition at line 53 of file OMKController.h.


Member Typedef Documentation

typedef std::pair< Name,Name > OMK::Controller::MigrationObjectPrm

Definition at line 113 of file OMKController.h.

typedef std::pair< ObjectDescriptor,Name > OMK::Controller::CreateObjectPrm

parameters to create object

Definition at line 185 of file OMKController.h.


Constructor & Destructor Documentation

Controller::Controller ( ObjectDescriptor simulationTree,
const Date initialDate 
)

constructor for a classic controller

Parameters:
initialObjects the simulation tree describing the initial simulated objects to create. The root element of that tree is considered as describing the controller, and therfore it's class is ignored
initialDate the date at wich the simualtion is going to start

Definition at line 67 of file OMKController.cpp.

References _computeStatePointer, _currentListOfObjectsNeedingActivation, _currentWritableSystemEventsList, OMK::ObjectDescriptor::_destroySimulatedObject, OMK::SimulatedObject::_objectHandle, _objectsNeedingActivationList, OMK::ObjectDescriptor::_pointerToSimulatedObject, _simulationTree, _systemEventsList, OMK::Type::PolatorNT::Constant, OMK::Type::PolatorNT::ConstantContinuous, createReferenceObjectHandle(), OMK::Type::PolatorNT::Cubic, OMK::Type::PolatorNT::CubicContinuous, OMK::Type::PolatorNT::defaultPrecisionLevel, OMK::ParametersAccessor::get(), OMK::ConfigurationParameterDescriptor::getAssociatedString(), OMK::SimulatedObject::getConfigurationParameters(), OMK::ConfigurationParameterDescriptor::getSubDescriptorByName(), OMK::ReferenceObjectHandle::initial, initialSimulationDate, OMK::Type::PolatorNT::Linear, OMK::Type::PolatorNT::LinearContinuous, OMASSERT, OMERROR, OMK_DEBUG_ERROR, OMK_DEBUG_FATAL_ERROR, OMK_DEBUG_MESSAGE, OMK_DEBUG_WARNING, OMK::Type::PolatorNT::Quadratic, and OMK::Type::PolatorNT::QuadraticContinuous.

00069 : SimulatedObject(*this, initialObjects ), 
00070   _simulationTree( initialObjects ),
00071   _numberOfSimulatedSteps( 0 ),
00072   _nbStepsByCycle( 0 ),
00073   _date( initialDate ),
00074   _showDateAndStepNumber( false ),
00075   _controledObjectsSignalsDispatcher( *this ),
00076   _forcedCompute( false ),
00077   _scheduler( NULL )
00078 {
00079   // These flags are always traced
00080   OBT::Singleton<OBT::Tracer>::getInstance().registerId( OMK_DEBUG_WARNING ) ;
00081   OBT::Singleton<OBT::Tracer>::getInstance().registerId( OMK_DEBUG_FATAL_ERROR ) ;
00082   OBT::Singleton<OBT::Tracer>::getInstance().registerId( OMK_DEBUG_ERROR ) ;
00083   OBT::Singleton<OBT::Tracer>::getInstance().registerId( OMK_DEBUG_MESSAGE ) ;
00084 
00085   //--- Tracer initialisation
00086   // The file
00087   std::string traceFile ;
00088   if( ParametersAccessor::get( getConfigurationParameters(), "TraceFile", traceFile ) )
00089   {
00090     OBT::Singleton<OBT::Tracer>::getInstance().setFile( traceFile.c_str() ) ;
00091   }
00092   // The "trace all" flag
00093   bool traceAll = false ;
00094   if( ParametersAccessor::get( getConfigurationParameters(), "TraceAll", traceAll ) )
00095   {
00096     OBT::Singleton<OBT::Tracer>::getInstance().traceAll( traceAll ) ;
00097   }
00098   // The ids to register
00099   std::vector< std::string > traceIds ;
00100   if( ParametersAccessor::get( getConfigurationParameters(), "TraceIds", traceIds ) )
00101   {
00102     for( std::vector< std::string >::const_iterator i = traceIds.begin() ;
00103       i != traceIds.end() ;
00104       i++ )
00105     {
00106       OBT::Singleton<OBT::Tracer>::getInstance().registerId( i->c_str() ) ;
00107     }
00108   }
00109 
00110   if (getConfigurationParameters())
00111   {
00112     const ConfigurationParameterDescriptor* defaultPolatorParams= 
00113       getConfigurationParameters()->getSubDescriptorByName("defaultPolatorPrecisionLevel");
00114     if(defaultPolatorParams)
00115     {
00116       if(defaultPolatorParams->getAssociatedString()=="Constant")
00117         OMK::Type::PolatorNT::defaultPrecisionLevel=OMK::Type::PolatorNT::Constant;
00118       else if(defaultPolatorParams->getAssociatedString()=="Linear")
00119         OMK::Type::PolatorNT::defaultPrecisionLevel=OMK::Type::PolatorNT::Linear;
00120       else if(defaultPolatorParams->getAssociatedString()=="Quadratic")
00121         OMK::Type::PolatorNT::defaultPrecisionLevel=OMK::Type::PolatorNT::Quadratic;
00122       else if(defaultPolatorParams->getAssociatedString()=="Cubic")
00123         OMK::Type::PolatorNT::defaultPrecisionLevel=OMK::Type::PolatorNT::Cubic;
00124       else if(defaultPolatorParams->getAssociatedString()=="ConstantContinuous")
00125         OMK::Type::PolatorNT::defaultPrecisionLevel=OMK::Type::PolatorNT::ConstantContinuous;
00126       else if(defaultPolatorParams->getAssociatedString()=="LinearContinuous")
00127         OMK::Type::PolatorNT::defaultPrecisionLevel=OMK::Type::PolatorNT::LinearContinuous;
00128       else if(defaultPolatorParams->getAssociatedString()=="QuadraticContinuous")
00129         OMK::Type::PolatorNT::defaultPrecisionLevel=OMK::Type::PolatorNT::QuadraticContinuous;
00130       else if(defaultPolatorParams->getAssociatedString()=="CubicContinuous")
00131         OMK::Type::PolatorNT::defaultPrecisionLevel=OMK::Type::PolatorNT::CubicContinuous;
00132       else
00133         OMERROR( "This default polator is unknown: "
00134                  << defaultPolatorParams->getAssociatedString() ) ;
00135     }
00136   }
00137 
00138   initialSimulationDate = initialDate ;
00139 
00140   //as a controller created throught this constructor has no controller, create the illusion of being handled
00141   _objectHandle = createReferenceObjectHandle( *this ) ;
00142   _computeStatePointer = const_cast<ReferenceObjectHandle::SimulatedObjectComputingState *>(&(dynamic_cast<ReferenceObjectHandle *>(_objectHandle)->getComputingState () )) ;
00143 
00144   //connect the object description to the controller
00145   _simulationTree._pointerToSimulatedObject = this ;
00146   _simulationTree._destroySimulatedObject = false ;
00147 
00148   //create data structures for system events managed by the controller
00149   _systemEventsList[ 0 ] = new list< Event * >() ;
00150   _systemEventsList[ 1 ] = new list< Event * >() ;
00151   _currentWritableSystemEventsList = 0 ;
00152 
00153   //create data structures to keep track of objects needing activation because they have pending events
00154   _objectsNeedingActivationList[ 0 ] = new list< ReferenceObjectHandle * >() ;
00155   _objectsNeedingActivationList[ 1 ] = new list< ReferenceObjectHandle * >() ;
00156   _currentListOfObjectsNeedingActivation = 0 ;
00157 
00158   // initialisation of controller state
00159   OMASSERT( _computeStatePointer != 0 ) ;
00160   *_computeStatePointer = ReferenceObjectHandle::initial ;
00161 }

Controller::~Controller (  )  [virtual]

destructor

Definition at line 177 of file OMKController.cpp.

References _date, OMK::SimulatedObject::_objectHandle, _objectsNeedingActivationList, _pendingRegistrationRequests, _scheduler, _stepPeriod, _systemEventsList, and purgeMemoryFromOldEvents().

00178 {
00179   delete _scheduler ;
00180 
00181   // destruction of data structures related to event handling
00182   delete _systemEventsList[ 0 ] ;
00183   delete _systemEventsList[ 1 ] ;
00184   delete _objectsNeedingActivationList[ 0 ] ;
00185   delete _objectsNeedingActivationList[ 1 ] ;
00186 
00187   purgeMemoryFromOldEvents ( _date + _stepPeriod ) ;
00188 
00189   // destruction of pending registrations
00190   for( map< Name, SignalDispatcher * >::iterator i = _pendingRegistrationRequests.begin() ;
00191        i != _pendingRegistrationRequests.end() ;
00192        ++i )
00193   {
00194     // delete the signal dispatcher
00195     delete i->second ;
00196     // removal from the map omitted, because automatic at destruction of the data member
00197   }
00198   delete _objectHandle ;
00199 }


Member Function Documentation

void Controller::init (  )  [virtual]

initialise the object.

Use this member function for any initilisation than can only be done when all the simulated objects have been created. In particular, plugging the input of the objects should be done here. By default, this member function calls the initialisation of the associated computational object.

Reimplemented from OMK::SimulatedObject.

Reimplemented in OMK::PvmController.

Definition at line 476 of file OMKController.cpp.

References _date, _referenceObjectsMap, _simulationTree, _stepFrequency, _stepPeriod, advanceSimulatedDate(), computeScheduling(), createControlledObjects(), getCycleFrequency(), OMK::SimulatedObject::getName(), OMK::SimulatedObject::getObjectHandle(), initialSimulationDate, OMMESSAGE, scheduleControlledObjects(), and sendInitialEventsTo().

Referenced by OMK::PvmController::init(), and processEvent().

00476 {
00477 
00478   NameToPointerMap<ReferenceObjectHandle>::iterator pTab;
00479 
00480   computeScheduling(true) ;
00481 
00482   ostringstream warningMessage ;
00483   OMMESSAGE( "Controller::init :"<< endl 
00484     << "controler's cycle frequency : " << getCycleFrequency() <<" Hz"<< endl 
00485     << "controler's step frequency : " << _stepFrequency <<" Hz"<< endl
00486     << "stepPeriod " << _stepPeriod << endl
00487     ) ;
00488 
00489   createControlledObjects ( &_simulationTree ) ;
00490 
00491   scheduleControlledObjects() ;
00492 
00493   _referenceObjectsMap.addObjectWithIndex (getName(), (ReferenceObjectHandle *)getObjectHandle());
00494 
00495   NameToPointerMap<InputNT>::iterator i;
00496 
00497   //pretend init order was sent just before initialsimulationDate
00498   _date = Controller::initialSimulationDate - _stepPeriod ;
00499 
00500   //all initial simulation objects are started
00501   for ( pTab = _referenceObjectsMap.begin();
00502     pTab != _referenceObjectsMap.end(); 
00503     pTab++ )
00504   {
00505     sendInitialEventsTo ( *(*pTab).second, _date ) ;
00506   }
00507 
00508   advanceSimulatedDate() ;
00509 
00510   //only if initialisation happens at a different simulation date than the first simulation step
00511   //reactToControlledObjectsSystemEvents(); 
00512 }
00513 

void Controller::run (  )  [virtual]

run Start the controller on a infinite loop which will be broken if system events are sent to the controller

Reimplemented in OMK::PvmController.

Definition at line 516 of file OMKController.cpp.

References _computeStatePointer, OMK::SimulatedObject::_objectHandle, OMASSERT, runControllersStep(), and OMK::ReferenceObjectHandle::running.

Referenced by OMK::PvmController::run().

00516 {
00517   ReferenceObjectHandle * objectHandle = dynamic_cast<ReferenceObjectHandle *> ( _objectHandle ) ;
00518   OMASSERT ( objectHandle != NULL ) ;
00519   *_computeStatePointer = ReferenceObjectHandle::running ;
00520   while(*_computeStatePointer == ReferenceObjectHandle::running) 
00521   {
00522     runControllersStep (objectHandle) ;
00523   }//while
00524 }
00525 

template<typename Type>
std::list< const ObjectDescriptor * > * OMK::Controller::listDescendantsOfType ( const Name objectName  )  [inline]

List the descendants of an object that are of a certain type.

Parameters:
objectName : the ancestor object
Returns:
a list of the descendants of objectName that are of the type of the template parameter. The resulting list should be destroyed after usage

Definition at line 676 of file OMKController.h.

References OMK::ObjectDescriptor::findDescendantNamed(), and OMK::SimulatedObject::getObjectDescriptor().

00677 {
00678   const ObjectDescriptor * objectDescriptor = getObjectDescriptor ().findDescendantNamed ( objectName ) ;
00679   if ( objectDescriptor != NULL )
00680     {
00681       return objectDescriptor->template listDescendantsOfType<Type> () ; 
00682     }
00683   else
00684     {
00685       return new std::list<const ObjectDescriptor *>() ;
00686     }
00687 }

template<typename Type>
std::list< const ObjectDescriptor * > * OMK::Controller::listBrothersOfType ( const Name  objectName  )  [inline]

list brothers of objectName in the simulation tree of that are of type t

Parameters:
objectName : name of the brother
Returns:
a list of the brothers of objectName that are of the type of the template parameter. The resulting list should be destroyed after usage

Definition at line 695 of file OMKController.h.

References OMK::ObjectDescriptor::findDescendantNamed(), OMK::ObjectDescriptor::getFathersObjectDescriptor(), and OMK::SimulatedObject::getObjectDescriptor().

00696 {
00697   const ObjectDescriptor * objectDescriptor = getObjectDescriptor ().findDescendantNamed ( objectName ) ;
00698   if ( objectDescriptor != NULL )
00699     {
00700       objectDescriptor = objectDescriptor->getFathersObjectDescriptor() ;
00701       if ( objectDescriptor != NULL )
00702         {
00703           return objectDescriptor->template listBrothersOfType<Type> () ; 
00704         }
00705       else
00706         {
00707           return new std::list<const ObjectDescriptor *>() ;
00708         }
00709     }
00710   else
00711     {
00712       return new std::list<const ObjectDescriptor *>() ;
00713     }
00714 }

void Controller::computeNextSimulationStep (  )  [protected, virtual]

compute the next simulation step

Reimplemented in OMK::PvmController.

Definition at line 627 of file OMKController.cpp.

References _numberOfSimulatedSteps, _scheduler, OMK_DEBUG_OMK_EXEC, OMTRACEID, processEventsOfSuspendedObjects(), reactToControlledObjectsSystemEvents(), and OMK::Scheduler::runStep().

Referenced by compute(), and OMK::PvmController::computeNextSimulationStep().

00627 {
00628   OMTRACEID( OMK_DEBUG_OMK_EXEC, "Controller::computeNextSimulationStep calling reactToControlledObjectsSystemEvents " ) ;
00629   reactToControlledObjectsSystemEvents () ;
00630   OMTRACEID( OMK_DEBUG_OMK_EXEC, "done " ) ;
00631   _scheduler->runStep( (_numberOfSimulatedSteps - 1) % _nbStepsByCycle ) ;
00632 
00633   processEventsOfSuspendedObjects () ;
00634 
00635   OMTRACEID( OMK_DEBUG_OMK_EXEC,  "Controller::computeNextSimulationStep done" ) ;
00636 }
00637 

void Controller::scheduleObject ( ReferenceObjectHandle ref  )  [protected, virtual]

add a simulated object to the appropriate execution frames, without flagging it as executable

Parameters:
ref the object handle of the simulated object

Definition at line 387 of file OMKController.cpp.

Referenced by OMK::DistributedController::getPointerToSimulatedObjectNamed(), OMK::DistributedController::processEvent(), processNewObjectDeclaration(), reactToControlledObjectsSystemEvents(), and scheduleControlledObjects().

00398   {
00399     int nbFramesARaterPlusUn=int(_controller._stepFrequency/objectFrequency);
00400 
00401     for(int minor=0;minor<_nbStepsByCycle;minor++) 
00402     {
00403       if (minor%nbFramesARaterPlusUn==0) 
00404       {  //earliest execution 
00405         _scheduler->addToScheduable( ref , minor );
00406       }
00407     }
00408     if ( ref->getComputingState() == ReferenceObjectHandle::running ) 
00409     {
00410       _scheduler->schedule ( ref ) ;
00411     }   
00412   }
00413 }
00414 

void Controller::processStartEventAfterMorphose ( ReferenceObjectHandle objectHandle  ) 

CHADI.

Definition at line 1305 of file OMKController.cpp.

References _scheduler, OMK::ReferenceObjectHandle::getComputingState(), OMK::ReferenceObjectHandle::initial, noActivationNeededFor(), OMK::ReferenceObjectHandle::running, OMK::Scheduler::schedule(), and setComputingState().

Referenced by OMK::DistributedController::processEvent().

01305 {
01306 
01307   if(objectHandle->getComputingState() == ReferenceObjectHandle::initial) 
01308   {
01309     setComputingState (objectHandle, ReferenceObjectHandle::running ) ;
01310     noActivationNeededFor ( objectHandle );
01311 
01312     objectHandle->initAfterMorphose() ;
01313 
01314     _scheduler->schedule( objectHandle );
01315   }
01316 }

void Controller::createLocalObject ( const ObjectDescriptor newLObjectDescription,
const Name fathersLName 
) [virtual]

create a local object

Reimplemented in OMK::DistributedController.

Definition at line 653 of file OMKController.cpp.

References OMK::SimulatedObject::getName(), getSimulatedDate(), OMK::SystemEventIdentifier::MaskNewLocalObject, and OMK::SimulatedObject::sendEvent().

Referenced by OMK::DistributedController::createLocalObject().

00653 {
00654   //  cout<<"je suis createObject, fathersName est :"<<fathersName<<endl;
00655   CreateObjectEvent creationEvent( SystemEventIdentifier::MaskNewLocalObject,
00656     getSimulatedDate(),
00657     getName(),
00658     getName(),
00659     CreateObjectType( CreateObjectPrm( newLObjectDescription, fathersLName ) ) );
00660   sendEvent( creationEvent ) ;
00661 
00662 
00663 }
00664 //----------------------------------

virtual int OMK::Controller::getMirrorsNbre (  )  [inline, virtual]

Reimplemented in OMK::DistributedController.

Definition at line 107 of file OMKController.h.

00107 { return 1;};

virtual bool OMK::Controller::isAMirror ( const Name name  )  [inline, virtual]

Reimplemented in OMK::DistributedController.

Definition at line 108 of file OMKController.h.

00108 { return false ;};

virtual std::vector<Name> OMK::Controller::getMirrorList (  )  [inline, virtual]

Reimplemented in OMK::DistributedController.

Definition at line 109 of file OMKController.h.

00109 {return std::vector<Name>() ;};

virtual std::vector<Name> OMK::Controller::getIsolatedMirrorList (  )  [inline, virtual]

Reimplemented in OMK::DistributedController, and OMK::PvmController.

Definition at line 110 of file OMKController.h.

00110 {return std::vector<Name>() ;};

virtual std::vector<Name> OMK::Controller::getNonIsolatedMirrorList (  )  [inline, virtual]

Reimplemented in OMK::DistributedController, and OMK::PvmController.

Definition at line 111 of file OMKController.h.

00111 {return std::vector<Name>() ;};

virtual bool OMK::Controller::testIfTroubleOccured (  )  [inline, virtual]

Reimplemented in OMK::DistributedController, and OMK::PvmController.

Definition at line 112 of file OMKController.h.

00112 {return false; } ;

virtual void OMK::Controller::createNewSite ( const Date  )  [inline, virtual]

Reimplemented in OMK::DistributedController, and OMK::PvmController.

Definition at line 113 of file OMKController.h.

00113 {} ;

OMK::Controller::DECLARE_TYPE_EVENT ( MigrationObjectPrm  ,
MigrationObject   
)

void Controller::migrateObjectToProcess ( Name nomObjet,
Name nomProcess 
)

Definition at line 666 of file OMKController.cpp.

References OMK::SimulatedObject::getName(), getSimulatedDate(), OMK::SystemEventIdentifier::MaskMetamorphoseMirToRef, and OMK::SimulatedObject::sendEvent().

00666 {
00667   // sendValuedEvent( objectName, 
00668   //               "SystemEventIdentifier::MaskMetamorphoseMirToRef",
00669   //               MigrationObjectType( MigrationObjectPrm( objectName, processName ) ) ) ;
00670 
00671   MigrationObjectEvent migrationEvent( SystemEventIdentifier::MaskMetamorphoseMirToRef,
00672     getSimulatedDate(),
00673     getName(),
00674     getName(),
00675     MigrationObjectType( MigrationObjectPrm( objectName, processName ) ) );
00676   sendEvent (migrationEvent) ;
00677 
00678 
00679 }
00680 //----------------------------------

virtual std::list<Name> OMK::Controller::getDisconnectedProcessusList (  )  [inline, virtual]

Reimplemented in OMK::PvmController.

Definition at line 117 of file OMKController.h.

00117 { return std::list<Name> () ;};

virtual std::map<Name, int> OMK::Controller::getDisconnectedProcessusMap (  )  [inline, virtual]

Reimplemented in OMK::PvmController.

Definition at line 118 of file OMKController.h.

00118 { return std::map<Name, int> () ;};

Frequency Controller::computeAdequateFrequency ( const Frequency suggestedFrequency  )  [virtual]

compute an adequate Frequency for an object dynamically created Should be used to adapt the desired frequency when an simulated object is dynamically created so that the creation doesn't cause recomputation of the scheduling.

the result is the closest frequency to suggestedFrequency that can be inserted into the scheduler without changing the scheduling data structures. If two frequencies are at the same distance to correct frequencies, the higher frequency will be chosen. note : this member function should be delegated to the scheduler

Definition at line 418 of file OMKController.cpp.

References _stepFrequency, and getCycleFrequency().

Referenced by OMK::DistributedController::getPointerToSimulatedObjectNamed(), processNewObjectDeclaration(), and reactToControlledObjectsSystemEvents().

00418 {
00419   Frequency result = 0 ;
00420   if ( suggestedFrequency != 0 )
00421   {
00422     list <Frequency> listOfAvailableFrequencies ;
00423 
00424     // construct the list of frequencies that can be scheduled without changing the frame structure
00425     for ( int i = 1 ; i <= _nbStepsByCycle ; ++i )
00426     {
00427       if ( _stepFrequency % i == 0 )
00428       {
00429         listOfAvailableFrequencies.push_back(_stepFrequency / i ) ;
00430       }
00431     }
00432 
00433     // find the closest frequency in listOfAvailableFrequencies to suggestedFrequency
00434 
00435     list<Frequency>::const_iterator frequencyIterator = listOfAvailableFrequencies.begin() ;
00436     while ( frequencyIterator != listOfAvailableFrequencies.end() && 
00437       ( suggestedFrequency <= *frequencyIterator ) )
00438     {
00439       ++frequencyIterator ;
00440     }
00441 
00442     if (frequencyIterator == listOfAvailableFrequencies.end() )
00443     { //the suggested frequency is < _cycleFrequency
00444       result = getCycleFrequency() ; //cannot schedule object slower than _cycleFrequency
00445     }
00446     else 
00447     { 
00448       if ( frequencyIterator == listOfAvailableFrequencies.begin() )
00449       { // *(listOfAvailableFrequencies.begin()) == _stepFrequency < suggestedFrequency
00450         result = _stepFrequency ; //cannot scheduleObject faster the _stepFrequency
00451       }
00452       else 
00453       { // *(frequencyIterator) < suggestedFrequency <= *(frequencyIterator--)
00454         Frequency lowerEstimate = *frequencyIterator ;
00455         -- frequencyIterator ;
00456         Frequency higherEstimate = *frequencyIterator ;
00457 
00458         // lowerEstimate < suggestedFrequency <= higherEstimate
00459         if ( (suggestedFrequency - lowerEstimate) < (higherEstimate - suggestedFrequency) )
00460         {
00461           result = lowerEstimate ;
00462         }
00463         else
00464         {
00465           result = higherEstimate ;
00466         }
00467       }
00468     }
00469   }
00470   return result ;
00471 }
00472 

void Controller::runControllersStep ( ReferenceObjectHandle objectHandle  )  [virtual]

run a controllers simulation step.

To be used by the code controlling the simulation loop (generally run or the interface

Definition at line 528 of file OMKController.cpp.

References _computeStatePointer, _forcedCompute, OMK::ReferenceObjectHandle::compute(), OMASSERT, OMK_DEBUG_OMK_EXEC, OMTRACEID, OMK::ReferenceObjectHandle::processEvents(), and OMK::ReferenceObjectHandle::running.

Referenced by run().

00528 {
00529   OMTRACEID( OMK_DEBUG_OMK_EXEC, "Controller::runControllersStep" ) ;
00530   OMASSERT ( objectHandle != NULL );
00531   _forcedCompute = true ;
00532 
00533   //the controller has to process system events adressed to itself
00534   objectHandle->processEvents() ;
00535 
00536   //the controller has schedule itself
00537   if( (*_computeStatePointer == ReferenceObjectHandle::running) ||
00538     _forcedCompute ) 
00539   {
00540     objectHandle->compute();
00541   }
00542   _forcedCompute = false ;
00543 }
00544 

void Controller::compute (  )  [virtual]

computes a new simulation step for all controlled objects, if the controller is in the running state, otherwise jsut react to system events sent to controlled objects

Reimplemented from OMK::SimulatedObject.

Definition at line 546 of file OMKController.cpp.

References advanceSimulatedDate(), computeNextSimulationStep(), getPurgeDate(), and purgeMemoryFromOldEvents().

00546 {
00547   computeNextSimulationStep();
00548   purgeMemoryFromOldEvents ( getPurgeDate() ) ;
00549   advanceSimulatedDate();
00550 }
00551 

void Controller::finish (  )  [virtual]

finish the simulation.

called when MaskStop is received by the controller

Reimplemented from OMK::SimulatedObject.

Reimplemented in OMK::PvmController.

Definition at line 163 of file OMKController.cpp.

References _simulationTree, destroyObject(), OMK::ObjectDescriptor::getSons(), OMASSERT, OMK_DEBUG_OMK_EXEC, and OMTRACEID.

Referenced by OMK::PvmController::finish(), processEvent(), and reactToControlledObjectsSystemEvents().

00164 {
00165   OMTRACEID( OMK_DEBUG_OMK_EXEC, "Controller::finish()" ) ;
00166   //call destroyObject on all the sons
00167   for ( ObjectDescriptor::SonsContainerType::iterator i = _simulationTree.getSons().begin() ;
00168     i !=  _simulationTree.getSons().end() ;
00169     ++i )
00170   {
00171     OMASSERT ( (*i) != NULL ) ;
00172     destroyObject ( (*i)->getName() ,true ) ;
00173   }
00174 }

MultipleConfigurationParameter * Controller::getSchedulingParametersOfObject ( ObjectDescriptor  )  [protected]

get a modifiable version of the scheduling parameters of an object.

Defined here for use by derived controllers

Definition at line 1608 of file OMKController.cpp.

References OMK::ObjectDescriptor::getSchedulingParameters().

Referenced by OMK::PvmController::PvmController().

01608 {
01609   return objectDescription.getSchedulingParameters () ;
01610 }
01611 

SimulatedObject * Controller::createDescribedObject ( const ObjectDescriptor description  )  [protected]

createDescribedObject.

Create a simulated object coresponding to the descriptor given as parameter, and update the descriptor accordingly object created are

Definition at line 952 of file OMKController.cpp.

References OMK::ObjectDescriptor::createDescribedObject().

Referenced by OMK::DistributedController::createDuplicatedObject(), OMK::DistributedController::createMirrorObject(), createReferenceObject(), and OMK::DistributedController::getPointerToSimulatedObjectNamed().

00952 {
00953   SimulatedObject * obj = description->createDescribedObject() ;
00954 
00955   return obj;
00956 }
00957 

void Controller::setProcessOfDescriptor ( ObjectDescriptor objectDescription,
const Name newProcessName 
) [protected, virtual]

Definition at line 1613 of file OMKController.cpp.

References OMK::ObjectDescriptor::setProcess().

Referenced by OMK::PvmController::PvmController().

01613 {
01614   objectDescription.setProcess ( newProcessName ) ;
01615 }
01616 }

void Controller::error ( const char *  mess  )  [static]

included for ascendant compatibility : raises a OMKUserException with the message passed as parameter

Parameters:
errorMessage the message associated to the user exception

Definition at line 1154 of file OMKController.cpp.

Referenced by OMK::SimulatedObject::addInputAlias(), OMK::PvmSvm::addNewWorkstation(), OMK::SimulatedObject::addOutputAlias(), OMK::SimulatedObject::addSensitiveInputAlias(), OMK::SimulatedObject::addSensitiveNotifyingInputAlias(), OMK::KernelObjectAbstractFactory::createControlParameter(), OMK::KernelObjectAbstractFactory::createInput(), OMK::KernelObjectAbstractFactory::createInputAlias(), OMK::KernelObjectAbstractFactory::createOutput(), OMK::KernelObjectAbstractFactory::createOutputAlias(), OMK::KernelObjectAbstractFactory::createSensitiveInput(), OMK::KernelObjectAbstractFactory::createSensitiveInputAlias(), OMK::KernelObjectAbstractFactory::createSensitiveNotifyingInput(), OMK::KernelObjectAbstractFactory::createSensitiveNotifyingInputAlias(), getPointerToDuplicatedObjectNamed(), OMK::ReferenceObjectHandle::insertInStream(), OMK::PvmReferenceObjectHandle::insertInStream(), OMK::PvmController::parseSynchronisationMessage(), and OMK::PvmSvm::spawnProcess().

01154 {
01155   throw UserException( Errormess ) ;
01156 }
01157 

void Controller::showDateAndStepNumber ( bool  show = true  ) 

ask the controller to print (or not) to sdterr (cerr) the simulation date and the step number

Parameters:
show if true information will be printed

Definition at line 1149 of file OMKController.cpp.

References _showDateAndStepNumber.

01149 {
01150   _showDateAndStepNumber = show ;
01151 }
01152 

const Date & Controller::getSimulatedDate (  )  const [virtual]

Returns a reference to an allways accurate simulation date, in ms.

Reimplemented from OMK::SimulatedObject.

Definition at line 1101 of file OMKController.cpp.

References _date.

Referenced by OMK::ReferenceObjectHandle::compute(), OMK::HumanoRecorder::computeParameters(), createLocalObject(), createObject(), OMK::SimulatedObject::getSimulatedDate(), OMK::Output< T >::localGet(), migrateObjectToProcess(), OMK::PvmController::parseSynchronisationMessage(), OMK::DistributedController::processEvent(), OMK::ReferenceObjectHandle::processEvents(), OMK::Svm::relaxedSynchroniseReceiveAndProcessMessages(), OMK::SimulatedObject::sendEvent(), OMK::PvmMirrorObjectHandle::sendRequestToReferenceObject(), OMK::SimulatedObject::sendValuedEvent(), OMK::Output< T >::suggest(), OMK::Svm::synchroniseReceiveAndProcessMessages(), OMK::PvmMirrorObjectHandle::unpack(), and OMK::PvmController::~PvmController().

01101 {
01102   return _date;
01103 }
01104 

int Controller::getCycleFrequency (  )  const [virtual]

get the simulation cycle frequency

Definition at line 1112 of file OMKController.cpp.

References _cycleFrequency.

Referenced by computeAdequateFrequency(), computeScheduling(), and init().

01112 {
01113   return _cycleFrequency ;
01114 }
01115 

int Controller::getCyclePeriod (  )  const [virtual]

get the simulation cycle period, in simulated time (in ms)

Definition at line 1118 of file OMKController.cpp.

References _cyclePeriod.

Referenced by OMK::PvmMirrorObjectHandle::unpack().

01118 {
01119   return _cyclePeriod ;
01120 }
01121 

OMK::Controller::DECLARE_TYPE_EVENT ( CreateObjectPrm  ,
CreateObject   
)

void Controller::createObject ( const ObjectDescriptor newObjectDescription,
const Name fathersName 
) [virtual]

creation of an object unknown of in the simulation tree.

this sends an appropriate valued event to the controller, which is interpreted at the next simulation step this interpretation will add the object in the simulation tree, and create it. The object will be inserted in the scheduling data structures with the specified frequency, wich could imply a call to computeScheduling (false) (

See also:
computeScheduling). To avoid this, the frequency specified can be adapted to the actual run-time data structure using computeAdequateFrequency (

computeAdequateFrequency)

Parameters:
fathersName the name of the father of the object in the simulation tree
newObjectDescription a description of the object to create

Reimplemented in OMK::DistributedController.

Definition at line 641 of file OMKController.cpp.

References OMK::SimulatedObject::getName(), getSimulatedDate(), OMK::SystemEventIdentifier::MaskNewObject, and OMK::SimulatedObject::sendEvent().

Referenced by OMK::DistributedController::createObject().

00641 {
00642   CreateObjectEvent creationEvent( SystemEventIdentifier::MaskNewObject,
00643     getSimulatedDate(),
00644     getName(),
00645     getName(),
00646     CreateObjectType( CreateObjectPrm( newObjectDescription, fathersName ) ) );
00647   sendEvent (creationEvent) ;
00648 }
00649 

void Controller::destroyObject ( const Name name,
bool  recursively 
) [virtual]

destroy a simulated object.

Delete any data structure related to the specified object, including its description in the simulation tree. Sends MaskStop then MaskDelete to the object, and optionnaly recursively to the sons of the object effective destruction takes place at the next simulation step

Parameters:
name : the name of the object to destroy
recursive : destroy recursively the sons in the simulation of the specified object

Definition at line 696 of file OMKController.cpp.

References _simulationTree, OMK::ObjectDescriptor::findDescendantNamed(), OMK::ObjectDescriptor::getSons(), OMK::SystemEventIdentifier::MaskDelete, OMK::SystemEventIdentifier::MaskStop, OMASSERT, OMERROR, and OMK::SimulatedObject::sendEvent().

Referenced by finish().

00696 {
00697   ObjectDescriptor * objectDescriptor = _simulationTree.findDescendantNamed ( name ) ;
00698 
00699   if( objectDescriptor != NULL )
00700   {
00701     if ( recursively ) 
00702     {
00703       for ( ObjectDescriptor::SonsContainerType::iterator i = objectDescriptor->getSons().begin() ;
00704         i !=  objectDescriptor->getSons().end() ;
00705         ++i )
00706       {
00707         OMASSERT ( (*i) != NULL ) ;
00708         destroyObject ( (*i)->getName() ,true ) ;
00709       }
00710     }
00711     sendEvent(name, SystemEventIdentifier::MaskStop);
00712     sendEvent(name, SystemEventIdentifier::MaskDelete);
00713   }
00714   else 
00715   {
00716     OMERROR("Controller::destroyObject \"" << name << "\" not found" ) ;
00717   }
00718 }
00719 

void Controller::changeObjectsFather ( const Name name,
const Name newFather 
) [virtual]

change the father of an object in the simulation tree.

Effective change at the next simulation step, but doesn't affect the scheduling data structures

Parameters:
name : the object which is changing father
newfather : the new father of the object

Definition at line 732 of file OMKController.cpp.

References _simulationTree, OMK::ObjectDescriptor::findDescendantNamed(), OMK_DEBUG_OMK_EXEC, OMTRACEID, and OMK::ObjectDescriptor::setFathersDescription().

Referenced by OMK::DistributedController::processEvent(), and processEvent().

00732 {
00733   ObjectDescriptor * object = _simulationTree.findDescendantNamed ( name ) ;
00734   if ( object != NULL )
00735   {
00736     ObjectDescriptor * father = _simulationTree.findDescendantNamed ( newFather ) ;
00737     if (father != NULL) 
00738     {
00739       object->setFathersDescription( father ) ;
00740     }
00741     else
00742     {
00743       OMTRACEID( OMK_DEBUG_OMK_EXEC, "Controller::changeObjectsFather new father (\""<<newFather
00744         <<"\") for object \""<<name<<"\" doesn't exist" ) ;
00745     }
00746   }
00747   else
00748   {
00749     OMTRACEID( OMK_DEBUG_OMK_EXEC, "Controller::changeObjectsFather object \""<<name<<"\" doesn't exist" ) ;
00750   }
00751 }
00752 

void Controller::changeObjectsFather ( ObjectDescriptor object,
ObjectDescriptor newFather 
) [virtual]

change the father of an object in the simulation tree.

Effective change at the next simulation step, but doesn't affect the scheduling data structures

Parameters:
object : the object which is changing father
newfather : the new father of the object

Definition at line 723 of file OMKController.cpp.

References OMASSERT, and OMK::ObjectDescriptor::setFathersDescription().

00723 {
00724   OMASSERT ( object != NULL ) ;
00725   OMASSERT ( newFather != NULL ) ;
00726   object->setFathersDescription( newFather ) ;
00727 }
00728 

void Controller::computeScheduling ( bool  fromOriginal  )  [protected, virtual]

compute the scheduling data strucures.

Parameters:
fromOriginal boolean indiscating if the scheduling has to be computed from the original scheduling information or from the current scheduling information This member function is called when
  • the controller creates its data structures at creation
  • an object with an inadequate frequency is created
  • the new frequency of an object is incompatible with the current scheduling data structures
  • at users demand (send MaskRecomputeScheduling to the controller), to recompute the data structures using the originaly specified frequencies (those existing in the object descriptors, and which could have changed since, or because objects have been deleted or moved inside the simulation tree causing the current data structures to be inefficient or inaccurate

Definition at line 226 of file OMKController.cpp.

References _date, _nbStepsByCycle, _referenceObjectsMap, _scheduler, _simulationTree, _stepFrequency, _stepPeriod, createScheduler(), OMK::SimulatedObject::fireSignal(), gcd(), getCycleFrequency(), OMK::ObjectDescriptor::getDescendants(), OMK::ObjectDescriptor::getFrequency(), OMK::SimulatedObject::getName(), OMK::ObjectDescriptor::getOriginalFrequency(), OMK::SystemEventIdentifier::MaskChangeObjectFrequency, OMK::SystemEventIdentifier::MaskControllerFrequencyChange, OMASSERT, OMK_DEBUG_OMK_EXEC, OMMESSAGE, OMTRACEID, OMK::ReferenceObjectHandle::receiveEvent(), setCycleFrequency(), and OMK::ObjectDescriptor::setFrequency().

Referenced by OMK::DistributedController::getPointerToSimulatedObjectNamed(), init(), processEvent(), processNewObjectDeclaration(), and reactToControlledObjectsSystemEvents().

00226 {
00227   OMMESSAGE( "Controller::computeScheduling at date " << _date ) ;
00228 
00229   std::list<ObjectDescriptor * > objectDescriptorList ;
00230   int freq;
00231 
00232   _simulationTree.getDescendants( &objectDescriptorList );
00233 
00234   list<ObjectDescriptor * >::iterator i ;
00235 
00236   //remove objects with no frequency from the list
00237   i = objectDescriptorList.begin () ;
00238 
00239   while ( i != objectDescriptorList.end() )
00240   {
00241     if ( fromOriginal )
00242     {
00243       if ((*i)->getOriginalFrequency() == 0 )
00244       {
00245         i = objectDescriptorList.erase ( i ) ;
00246       }
00247       else
00248       {
00249         ++i ;
00250       }
00251     }
00252     else
00253     {
00254       if ( (*i)->getFrequency() == 0 )
00255       {
00256         i = objectDescriptorList.erase ( i ) ;
00257       }
00258       else
00259       {
00260         ++i ;
00261       }
00262     }
00263   }
00264 
00265   i = objectDescriptorList.begin () ;
00266 
00267   if ( i == objectDescriptorList.end() ) 
00268   {
00269     //no objects need regular activation
00270     if ( fromOriginal )
00271     {
00272       _stepFrequency = _simulationTree.getOriginalFrequency() ;
00273     }
00274     else 
00275     {
00276       _stepFrequency = _simulationTree.getFrequency() ;
00277     }
00278     if ( _stepFrequency == 0 ) 
00279     {
00280       OMTRACEID( OMK_DEBUG_OMK_EXEC, "Controller needs a frequency: assigning 1" ) ;
00281       _stepFrequency = 1 ;
00282     }
00283     setCycleFrequency(_stepFrequency) ;
00284   }
00285   else 
00286   {
00287     //initialise the loop with coherant values
00288     if (fromOriginal)
00289     {
00290       setCycleFrequency ( (*i)->getOriginalFrequency() ) ;
00291     }
00292     else
00293     {
00294       setCycleFrequency ( (*i)->getFrequency() ) ; 
00295     }
00296     _stepFrequency = 1 ;
00297   }
00298 
00299   while ( i != objectDescriptorList.end() )
00300   {
00301     if (fromOriginal)
00302     {
00303       freq = (*i)->getOriginalFrequency() ;
00304 
00305       if ( freq != (*i)->getFrequency() ) //the objects frequency has changed previously,
00306       {
00307         //reset it:
00308         (*i)->setFrequency ( freq ) ;
00309 
00310         //send MaskChangeObjectFrequency to the object
00311         ReferenceObjectHandle * referenceObjectHandle = _referenceObjectsMap.getObjectOfIndex ((*i)->getName() ) ;
00312         if ( referenceObjectHandle != NULL )
00313         {
00314           //use receive event is sub optimal, because MaskChangeObjectFrequency is a system event, thus implying a copy is sent back to the controller, whithout effect
00315           referenceObjectHandle->receiveEvent ( new ValuedEvent<Frequency> (SystemEventIdentifier::MaskChangeObjectFrequency,
00316             _date,
00317             getName(),
00318             (*i)->getName(),
00319             (*i)->getFrequency() ) );
00320         }                  
00321       }
00322     }
00323     else
00324     {
00325       freq = (*i)->getFrequency() ; 
00326     }
00327 
00328 
00329     if (freq != 0) 
00330     {
00331       setCycleFrequency ( gcd( freq, getCycleFrequency() ) ) ;
00332       _stepFrequency=(int)((freq*_stepFrequency)/gcd(freq,_stepFrequency));  //lcm(freq,_stepFrequency);
00333     }
00334 
00335     ++ i ;
00336   }
00337 
00338   OMASSERT( _stepFrequency != 0 ) ;
00339 
00340   if ( _stepFrequency != _simulationTree.getFrequency() )
00341   {//the controller has changed frequency
00342 
00343     _simulationTree.setFrequency( _stepFrequency ) ;
00344 
00345     fireSignal(SystemEventIdentifier::MaskControllerFrequencyChange) ;
00346   }
00347 
00348   _stepPeriod = int(1000./_stepFrequency);
00349 
00350 
00351   _nbStepsByCycle = _stepFrequency/getCycleFrequency() ;
00352 
00353   if ( _scheduler != NULL ) delete _scheduler ;
00354 
00355   _scheduler = createScheduler() ;
00356 
00357 }
00358 

void Controller::sendInitialEventsTo ( ReferenceObjectHandle objectHandle,
const Date dateOfMaskStart 
) [protected, virtual]

Send MaskStart to any created objects, and send any pending events which where stored (none by default) because send to an object before it was created.

Definition at line 831 of file OMKController.cpp.

References _pendingEventsList, OMK::ObjectDescriptor::getFrequency(), OMK::SimulatedObject::getName(), OMK::ObjectDescriptor::getName(), OMK::SimulatedObject::getObjectDescriptor(), OMK::ObjectHandle::getSimulatedObject(), OMK::SystemEventIdentifier::MaskStart, OMK::SystemEventIdentifier::MaskSuspend, OMK_DEBUG_OMK_EXEC, OMTRACEID, and OMK::SimulatedObject::sendEvent().

Referenced by OMK::DistributedController::getPointerToSimulatedObjectNamed(), init(), and processNewObjectDeclaration().

00831 { 
00832   if( &objectHandle.getSimulatedObject() != this )
00833   {
00834     OMTRACEID( OMK_DEBUG_OMK_EXEC, "Sending init event to \""
00835                << objectHandle.getSimulatedObject().getObjectDescriptor().getName()
00836                << "\"" ) ; 
00837     Event *startEvent = new Event(
00838       SystemEventIdentifier::MaskStart, 
00839       dateOfMaskStart,
00840       getName(),
00841       objectHandle.getSimulatedObject().getObjectDescriptor().getName() ) ;
00842     sendEvent( startEvent ) ;
00843 
00844     //objects whose frequency is 0 must be suspended
00845     if( objectHandle.getSimulatedObject().getObjectDescriptor().getFrequency() == 0 ) 
00846     {
00847       sendEvent( &objectHandle.getSimulatedObject(),SystemEventIdentifier::MaskSuspend ) ;
00848     }
00849 
00850     //send any pending events 
00851     /* no mutex protection needed, because this is only called during
00852        controller's system event processing
00853     */
00854     map< Name, list< Event * > >::iterator pendingEvents =
00855       _pendingEventsList.find( objectHandle.getSimulatedObject().getObjectDescriptor().getName() ) ;
00856     if( pendingEvents != _pendingEventsList.end() )
00857     {
00858       OMTRACEID( OMK_DEBUG_OMK_EXEC,
00859                  "Found pending events for \""
00860                  << objectHandle.getSimulatedObject().getObjectDescriptor().getName()
00861                  << "\"" ) ;
00862       for( list< Event * >::iterator pendingEventsListIterator =
00863              pendingEvents->second.begin() ;
00864            pendingEventsListIterator != pendingEvents->second.end() ;
00865            ++pendingEventsListIterator )
00866       {
00867         OMTRACEID( OMK_DEBUG_OMK_EXEC, "sent" << std::endl
00868                    << **pendingEventsListIterator << std::endl 
00869                    << "to \""
00870                    << objectHandle.getSimulatedObject().getObjectDescriptor().getName()
00871                    << "\"" ) ;
00872         objectHandle.getSimulatedObject().sendEvent( *pendingEventsListIterator ) ;
00873       }
00874       _pendingEventsList.erase( pendingEvents ) ;
00875     }
00876   }
00877 }
00878 

void Controller::deleteObject ( ObjectDescriptor objectDescription  )  [protected, virtual]

delete an object.

This member function performs destruction when MaskDelete is received for that object by doing the following

Reimplemented in OMK::DistributedController.

Definition at line 923 of file OMKController.cpp.

References _date, _deletedObjectHandles, OMK::ObjectDescriptor::getFathersObjectDescriptor(), OMK::ObjectDescriptor::getName(), OMK::SimulatedObject::getObjectDescriptor(), OMASSERT, OMK_DEBUG_OMK_EXEC, OMTRACEID, removeObjectFromDataStructures(), and OMK::ObjectDescriptor::removeSon().

Referenced by OMK::DistributedController::deleteObject(), and processDeleteEventOf().

00923 {
00924   OMTRACEID( OMK_DEBUG_OMK_EXEC,  "Controller::deleteObject \"" << objectDescriptor->getName() << "\"" ) ;
00925 
00926 
00927   if (objectDescriptor != &getObjectDescriptor() )
00928     //shouldn't delete oneself !
00929   {   
00930     OMASSERT ( objectDescriptor != NULL) ;
00931 
00932     // remove from the kernel's data structures
00933     ObjectHandle * toDelete = removeObjectFromDataStructures( objectDescriptor->getName() ) ;
00934 
00935     //remove the object descriptor from the simulation tree
00936     if ( objectDescriptor->getFathersObjectDescriptor() != objectDescriptor )
00937     {
00938       objectDescriptor->getFathersObjectDescriptor()->removeSon ( objectDescriptor ) ;
00939     }
00940 
00941     if ( toDelete != NULL )
00942     {
00943       //put the object handle in the list of object to be deleted
00944       _deletedObjectHandles.push_back ( make_pair ( _date, toDelete) ) ;
00945     }
00946   }
00947 }
00948 

ObjectHandle * Controller::removeObjectFromDataStructures ( const Name  )  [protected, virtual]

remove any reference to a simulated object from all the controller's data structures

Returns:
an ObjectHandle that is the last object referencing the simulated object does not act on the simualtion tree

Reimplemented in OMK::PvmController.

Definition at line 883 of file OMKController.cpp.

References _objectsNeedingActivationList.

Referenced by deleteObject(), and OMK::PvmController::removeObjectFromDataStructures().

00888   {
00889     _objectsNeedingActivationList[i]->remove( referentiel );
00890   }
00891 
00892   _listOfObjectsWithPostPonedEvents.remove ( referentiel ) ;
00893 
00894   _referenceObjectsMap.erase(nom);
00895 
00896   _scheduler->unschedule( referentiel ) ;
00897 
00898   _scheduler->removeFromScheduable( referentiel ) ;
00899 
00900   return referentiel;
00901 }
00902 

SimulatedObject * Controller::getPointerToDuplicatedObjectNamed ( const Name name  )  [virtual]

get a pointer to a simulated object

Parameters:
name the name of the object
Returns:
a pointer to a simulated object corresponding to the description given in the simulation tree, NULL if object isn't described

Definition at line 1007 of file OMKController.cpp.

References _referenceObjectsMap, OMK::ObjectDescriptor::DUPLICATED_OBJECT, error(), OMK::Name::getCString(), OMK::ObjectDescriptor::getDistribution(), OMK::SimulatedObject::getObjectDescriptor(), and getPointerToSimulatedObjectNamed().

01007 {
01008   std::string errorMSg = "Controller::getPointerToDuplicatedObjectNamed ";
01009   // The object is a referential object or we need to make of it a referential object
01010   SimulatedObject * result = getPointerToSimulatedObjectNamed( name );
01011   if( !result ) 
01012   {
01013     ReferenceObjectHandle * ref = _referenceObjectsMap.getObjectOfIndex( name );
01014     if( !ref ) 
01015     {
01016       errorMSg += "\n No object " ;
01017       errorMSg += name.getCString() ;
01018       errorMSg += " in processus" ;
01019       Controller::error( errorMSg.c_str() );
01020     }   
01021   }
01022   else if ( result->getObjectDescriptor().getDistribution() == ObjectDescriptor::DUPLICATED_OBJECT ) 
01023   {
01024     errorMSg += ": Pointer to object : " ;
01025     errorMSg += name.getCString() ;
01026     errorMSg += " cannot be obtained : It is not a duplicated object" ;
01027     Controller::error( errorMSg.c_str() );
01028   }
01029   return result;
01030 }
01031 

SimulatedObject * Controller::getPointerToSimulatedObjectNamed ( const Name name  )  [virtual]

get a pointer to a simulated object After return from this method, it's possible to query any method of the simulated object that doesn't depend on the evolution of that object, as the object returned can have been created specially by the call.

of course, querying the interface of that object (outputs control parameters and event listeners should yield a correct result after a least one simulation step

Parameters:
name the name of the object
Returns:
a pointer to a simulated object corresponding to the description given in the simulation tree, NULL if object isn't described

Reimplemented in OMK::DistributedController.

Definition at line 1034 of file OMKController.cpp.

References _deletedObjectHandles, _referenceObjectsMap, OMK::SimulatedObject::getName(), and OMK::ObjectHandle::getSimulatedObject().

Referenced by OMK::SimulatedObject::addInputAlias(), OMK::SimulatedObject::addOutputAlias(), OMK::SimulatedObject::addSensitiveInputAlias(), OMK::SimulatedObject::addSensitiveNotifyingInputAlias(), OMK::SimulatedObject::cancelRegistrationForSignalBy(), OMK::OutputNT::connect(), OMK::Input< T >::connect(), OMK::Input< T >::connectToControlParameter(), OMK::SimulatedObject::getFather(), getPointerToDuplicatedObjectNamed(), OMK::EventSignalEmitterUtil::loadParametersUtil(), reactToControlledObjectsSystemEvents(), OMK::Vis::VisBase::registerEventPlug(), OMK::SimulatedObject::registerForSignalBy(), OMK::SimulatedObject::sendEvent(), OMK::SignalDispatcher::sendEventsForSignal(), and OMK::SimulatedObject::sendValuedEvent().

01034 {
01035   SimulatedObject * resul = NULL ;  
01036   //Two cases: object is already a referential or it is needed to make it a referential
01037   ReferenceObjectHandle * refe = _referenceObjectsMap.getObjectOfIndex(nom);
01038   if (refe==NULL) 
01039   {
01040     if ( nom == getName() ) 
01041     {
01042       resul = this ;
01043     }
01044     else 
01045     {
01046       //the object might have just been deleted : look for it in _deletedObjectHandles
01047       list <pair <Date, ObjectHandle *> >::iterator i = _deletedObjectHandles.begin() ;
01048       while ( i != _deletedObjectHandles.end() )
01049       {
01050         if (i->second->getSimulatedObject().getName() == nom )
01051         {
01052           resul = & i->second->getSimulatedObject() ;
01053           i = _deletedObjectHandles.end() ;
01054         }
01055         else
01056         {
01057           ++i ;
01058         }
01059       }
01060     }
01061   }
01062   else 
01063   {
01064     resul=&refe->getSimulatedObject();  
01065   }
01066   return resul;
01067 }
01068 

void Controller::processNewObjectDeclaration ( ObjectDescriptor declaration,
const Date declarationDate 
) [protected, virtual]

processNewObjectDeclaration Once an object has been added to the simulation tree, this is called for creation and scheduling

Reimplemented in OMK::DistributedController.

Definition at line 961 of file OMKController.cpp.

References computeAdequateFrequency(), computeScheduling(), createReferenceObject(), OMK::ObjectDescriptor::getFrequency(), OMASSERT, scheduleControlledObjects(), scheduleObject(), and sendInitialEventsTo().

Referenced by processEvent(), and OMK::DistributedController::processNewObjectDeclaration().

00961 {
00962   ReferenceObjectHandle * objectHandle = createReferenceObject (  & declaration ) ;
00963   OMASSERT ( objectHandle != NULL ) ;
00964   if ( declaration.getFrequency() != computeAdequateFrequency ( declaration.getFrequency() ) )
00965   {
00966     //the whole scheduling data structure needs recalculating
00967     computeScheduling ( false ) ;
00968 
00969     //the new object will therefore be scheduled with all the others
00970     scheduleControlledObjects() ;
00971   }
00972   else
00973   {
00974     scheduleObject ( objectHandle ) ;
00975   }
00976   sendInitialEventsTo ( *objectHandle, declarationDate ) ;
00977 }
00978 

ReferenceObjectHandle * Controller::createReferenceObject ( const ObjectDescriptor idObjet  )  [protected, virtual]

createReferenceObject.

Effective creation of a reference object

Definition at line 982 of file OMKController.cpp.

References _referenceObjectsMap, createDescribedObject(), createReferenceObjectHandle(), OMK::ObjectDescriptor::getName(), OMASSERT, OMERROR, OMK_DEBUG_OMK_OBJ, and OMTRACEID.

Referenced by OMK::DistributedController::createControlledObjects(), createControlledObjects(), and processNewObjectDeclaration().

00983 {
00984   OMASSERT (objectDescription != NULL );
00985   OMTRACEID( OMK_DEBUG_OMK_OBJ, "Controller::createReferenceObject " ) ;
00986   ReferenceObjectHandle * result = NULL ;
00987 
00988   SimulatedObject * createdObject = createDescribedObject ( objectDescription ) ;
00989 
00990   if (createdObject != NULL) 
00991   {
00992     result = createReferenceObjectHandle (*createdObject);
00993 
00994     _referenceObjectsMap.addObjectWithIndex (objectDescription->getName(), result);
00995 
00996   }
00997   else
00998   {
00999     OMERROR( "Controller::createReferenceObject unable to create" << endl << *objectDescription ) ;
01000   }
01001   OMTRACEID( OMK_DEBUG_OMK_OBJ, "Controller::createReferenceObject ended" ) ;
01002   return result;
01003 }
01004 

const ObjectDescriptor & Controller::getObjectDescriptorOfObject ( const Name objectName  )  [virtual]

get the object descriptor of a given simulated object

Parameters:
objectName the name of the given object
Returns:
the ObjectDescriptor corresponding to that object throw a UserException if a descriptor corresponding to name doesn't exist

Reimplemented in OMK::DistributedController.

Definition at line 1070 of file OMKController.cpp.

References _deletedObjectHandles, _simulationTree, and OMK::ObjectDescriptor::findDescendantNamed().

Referenced by OMK::ParametersAccessor::getAndCheckObject().

01070 {
01071   // Benoit Chanclou 2006-04-03 avoid to two calls to findDescendantNamed (search in a list)
01072   const ObjectDescriptor * p_objDescriptor = _simulationTree.findDescendantNamed( objectName ) ;
01073   if ( p_objDescriptor )
01074   {
01075     return *p_objDescriptor ;
01076   }
01077   else 
01078   {
01079     //the object might have just been deleted : look for it in _deletedObjectHandles
01080     list <pair <Date, ObjectHandle *> >::iterator i = _deletedObjectHandles.begin() ;
01081     while ( i != _deletedObjectHandles.end() )
01082     {
01083       if ( i->second->getSimulatedObject().getName() == objectName )
01084       {
01085         return i->second->getSimulatedObject().getObjectDescriptor() ;
01086       }
01087       ++i ;
01088     }
01089     UserException e( "UnknownObject :" ) ; 
01090     e << objectName ;
01091     throw e ;
01092   }
01093 }
01094 

int Controller::lcm ( const int  a,
const int  b 
) [static]

Definition at line 1125 of file OMKController.cpp.

Referenced by OMK::Process::Process(), and OMK::PvmController::PvmController().

int Controller::gcd ( const int  a,
const int  b 
) [static]

Definition at line 1129 of file OMKController.cpp.

Referenced by computeScheduling().

01130                   {
01131   //     res = gcd (b, a % b) ;
01132   //  }
01133   if ( b == 0 )
01134   {
01135     if ( a == 0 )
01136     {
01137       return 1 ;
01138     }
01139     return a ;
01140   }
01141   if ( a < b )
01142   {
01143     return gcd( b, a ) ;
01144   }
01145   return gcd( b, a % b ) ;
01146 }
01147 

vector< Name > Controller::getReferentielList (  )  [virtual]

Definition at line 682 of file OMKController.cpp.

References _publicReferentielObjectsVector, and _referenceObjectsMap.

00682 {
00683   _publicReferentielObjectsVector.clear () ;
00684   for ( NameToPointerMap<ReferenceObjectHandle>::iterator i = _referenceObjectsMap.begin(); i!= _referenceObjectsMap.end(); i++ )
00685   {
00686     _publicReferentielObjectsVector.push_back( i->first) ;
00687   }
00688 
00689   return  _publicReferentielObjectsVector;
00690 }

Scheduler * Controller::createScheduler (  )  [protected, virtual]

create the scheduler that is in charge of effective scheduling of the controlled objects

Definition at line 361 of file OMKController.cpp.

References _nbStepsByCycle.

Referenced by computeScheduling().

00361 {
00362 
00363   return new FrameScheduler ( _nbStepsByCycle ) ;
00364 
00365 }
00366 

void Controller::scheduleControlledObjects (  )  [protected, virtual]

scheduleControlledObjects schedule all controlled reference objects

Definition at line 370 of file OMKController.cpp.

References _referenceObjectsMap, OMK::SimulatedObject::getObjectHandle(), and scheduleObject().

Referenced by OMK::DistributedController::getPointerToSimulatedObjectNamed(), init(), processEvent(), processNewObjectDeclaration(), and reactToControlledObjectsSystemEvents().

00370 {
00371   NameToPointerMap<ReferenceObjectHandle>::iterator pTab;
00372 
00373   //for all controlled objects
00374   for (pTab=_referenceObjectsMap.begin(); pTab!= _referenceObjectsMap.end(); pTab++)
00375   {
00376     if ((*pTab).second != getObjectHandle() ) //a controller shouldn't schedule itself. 
00377     {
00378       //schedule object correctly on the each frame of a cycle
00379       scheduleObject((*pTab).second);
00380     } 
00381   } 
00382 }
00383 

void Controller::advanceSimulatedDate (  )  [protected, virtual]

increment date and numberOfSimulatedSteps

Reimplemented in OMK::PvmController.

Definition at line 613 of file OMKController.cpp.

References _date, _numberOfSimulatedSteps, _showDateAndStepNumber, _stepPeriod, and OMMESSAGE.

Referenced by OMK::PvmController::advanceSimulatedDate(), compute(), and init().

00613 {
00614 
00615   _numberOfSimulatedSteps++;  
00616 
00617   _date = _date + _stepPeriod;  
00618 
00619   if (_showDateAndStepNumber) 
00620   {
00621     OMMESSAGE( "Controller starting simulation step number : " << _numberOfSimulatedSteps
00622       << " with date being "<<_date ) ;
00623   }
00624 }
00625 

void Controller::createControlledObjects ( const ObjectDescriptor subTree  )  [protected, virtual]

createControlledObjects Create a reference object for all objects of a simulation tree

Reimplemented in OMK::DistributedController.

Definition at line 202 of file OMKController.cpp.

References createReferenceObject(), OMK::ObjectDescriptor::getSons(), OMASSERT, OMK_DEBUG_OMK_OBJ, and OMTRACEID.

Referenced by init().

00203 {
00204   OMASSERT( subTree != NULL ) ;
00205   //go through the simulation tree to find all objects that have to be created
00206   list<ObjectDescriptor *>::const_iterator i = subTree->getSons()->begin() ;
00207 
00208   while ( i != subTree->getSons()->end() )
00209   {
00210     OMASSERT( *i != NULL ) ;
00211     OMTRACEID( OMK_DEBUG_OMK_OBJ, "Controller::createControlledObjects Creating \""<< (*i)->getName() << "\"" ) ;
00212     //create the object
00213     createReferenceObject ( *i ) ;
00214 
00215     //create the subTree of that object
00216     createControlledObjects ( *i ) ;
00217 
00218     OMTRACEID( OMK_DEBUG_OMK_OBJ, "Controller::createControlledObjects Created \""<< (*i)->getName() << "\"" ) ;
00219     ++i ;
00220   }
00221 }
00222 

void Controller::setCycleFrequency ( int  newFrequency  )  [protected, virtual]

Definition at line 1106 of file OMKController.cpp.

References _cycleFrequency, and _cyclePeriod.

Referenced by computeScheduling().

01106 {
01107   _cycleFrequency = newFreq ;
01108   _cyclePeriod = 1000/newFreq ; 
01109 }
01110 

void Controller::actOnSystemEvent ( Event event  )  [virtual]

called when a reference object receives a system event

Definition at line 1164 of file OMKController.cpp.

References _currentWritableSystemEventsList, _systemEventsList, actOnSystemEvent(), OMK::Event::clone(), OMK::SimulatedObject::getController(), OMK::SimulatedObject::getName(), OMK::Event::insertInList(), and OMK::Event::receiver.

Referenced by actOnSystemEvent(), and OMK::ReferenceObjectHandle::receiveEvent().

01164 {
01165   // do not send a copy of a system event to oneself (avoids redundancy), except
01166   // if the controller is being controlled
01167   if( event->receiver != getName() )
01168   {
01169 #ifdef _OMK_MUTEX_
01170     _mutexSystemEventsList.protect() ;
01171 #endif
01172     Event::insertInList( _systemEventsList[ _currentWritableSystemEventsList ],
01173                          event->clone() ) ;
01174 #ifdef _OMK_MUTEX_
01175     _mutexSystemEventsList.unprotect() ;
01176 #endif
01177   }
01178   else if( this != & getController() )
01179   {
01180     //the controller is being controlled : send a copy of the event to the
01181     // controllers controller
01182     getController().actOnSystemEvent( event ) ;
01183   }
01184 }
01185 

void Controller::reactToControlledObjectsSystemEvents (  )  [virtual]

process system events received by controlled objects

Definition at line 1332 of file OMKController.cpp.

References _currentWritableSystemEventsList, _referenceObjectsMap, _scheduler, _simulationTree, _systemEventsList, computeAdequateFrequency(), computeScheduling(), OMK::Event::eventId, OMK::ObjectDescriptor::findDescendantNamed(), finish(), OMK::ReferenceObjectHandle::getComputingState(), getPointerToSimulatedObjectNamed(), hasEventsToProcess(), OMK::SystemEventIdentifier::MaskChangeObjectFrequency, OMK::SystemEventIdentifier::MaskDelete, OMK::SystemEventIdentifier::MaskRestart, OMK::SystemEventIdentifier::MaskResume, OMK::SystemEventIdentifier::MaskStart, OMK::SystemEventIdentifier::MaskStop, OMK::SystemEventIdentifier::MaskSuspend, noActivationNeededFor(), OMASSERT, OMK_DEBUG_OMK_EVENT, OMK_DEBUG_OMK_EXEC, OMTRACEID, processDeleteEventOf(), OMK::ReferenceObjectHandle::processEvents(), processStartEventOf(), OMK::Event::receiver, OMK::Scheduler::removeFromScheduable(), OMK::ReferenceObjectHandle::running, OMK::Scheduler::schedule(), scheduleControlledObjects(), scheduleObject(), setComputingState(), OMK::ObjectDescriptor::setFrequency(), OMK::ReferenceObjectHandle::stopped, OMK::ReferenceObjectHandle::suspended, switchSystemEventList(), OMK::Scheduler::unschedule(), and OMK::ValuedEvent< UserType >::value.

Referenced by computeNextSimulationStep().

01332 {
01333   switchSystemEventList() ;
01334   list< Event * > & myEventList = *_systemEventsList [ 1 - _currentWritableSystemEventsList ] ;
01335   list< Event * >::iterator i = myEventList.begin() ;
01336   while ( i != myEventList.end() )
01337   {
01338     SimulatedObject *receiverObject = getPointerToSimulatedObjectNamed( (*i)->receiver ) ;
01339     Event *currentEvent = (*i) ;
01340 
01341     if( receiverObject == 0 ) 
01342     {
01343       OMTRACEID( OMK_DEBUG_OMK_EXEC,
01344                  "WARNING : object \"" << currentEvent ->receiver.getCString() 
01345                  <<"\", who has received event" << endl
01346                  << *currentEvent << endl
01347                  <<" doesn't exist (anymore)" ) ;
01348     }
01349     else
01350     {
01351       ReferenceObjectHandle *receiverReferential = dynamic_cast< ReferenceObjectHandle * >( receiverObject->getObjectHandle() );
01352       OMASSERT( receiverReferential != 0 ) ;
01353       OMTRACEID( OMK_DEBUG_OMK_EVENT, *currentEvent << endl << " received by \"" <<receiverObject->getName() << "\"" ) ;
01354       if( currentEvent->eventId == SystemEventIdentifier::MaskStart ) 
01355       {
01356         processStartEventOf ( receiverReferential );
01357       }
01358       else if( currentEvent->eventId == SystemEventIdentifier::MaskStop )
01359       {
01360         OMTRACEID( OMK_DEBUG_OMK_EVENT, "\"" << currentEvent->receiver <<"\" will be stopped " ) ;
01361         if( receiverReferential->getComputingState() == ReferenceObjectHandle::running ||
01362             receiverReferential->getComputingState() == ReferenceObjectHandle::suspended ) 
01363         {
01364           setComputingState( receiverReferential, ReferenceObjectHandle::stopped );
01365           receiverReferential->processEvents() ;
01366           receiverObject -> finish() ;
01367           _scheduler->unschedule( receiverReferential ); 
01368         }
01369       }
01370       else if( currentEvent->eventId == SystemEventIdentifier::MaskSuspend )
01371       {
01372         OMTRACEID( OMK_DEBUG_OMK_EVENT, "\"" << currentEvent->receiver <<"\" will be suspended" ) ;
01373         if( receiverReferential->getComputingState() == ReferenceObjectHandle::running )
01374         {
01375           setComputingState( receiverReferential, ReferenceObjectHandle::suspended ) ;
01376           // MaskSuspend will be treated at the end of the time step + with present events
01377           hasEventsToProcess( receiverReferential ) ;
01378           _scheduler->unschedule( receiverReferential );
01379         }
01380         else
01381         {
01382           OMASSERT( receiverReferential->getComputingState() == ReferenceObjectHandle::suspended ) ;
01383         }
01384       }
01385       else if( currentEvent->eventId == SystemEventIdentifier::MaskResume ) 
01386       {
01387         OMTRACEID( OMK_DEBUG_OMK_EVENT, "\"" << currentEvent->receiver <<"\" will resume execution" ) ;
01388         if( receiverReferential->getComputingState() == ReferenceObjectHandle::suspended ) 
01389         {
01390           setComputingState( receiverReferential, ReferenceObjectHandle::running );
01391           // treating event is useless because coming computes will do that
01392           noActivationNeededFor( receiverReferential ) ;
01393           _scheduler->schedule( static_cast< ReferenceObjectHandle * >( receiverObject->getObjectHandle() ) );
01394         }
01395       }
01396       else if( currentEvent->eventId == SystemEventIdentifier::MaskDelete ) 
01397       {
01398         processDeleteEventOf( receiverReferential ) ;
01399       }
01400       else if( currentEvent->eventId == SystemEventIdentifier::MaskRestart )
01401       {
01402         OMTRACEID( OMK_DEBUG_OMK_EVENT, "\"" << currentEvent->receiver <<"\" will be restarted" ) ;
01403         if( receiverReferential->getComputingState() == ReferenceObjectHandle::stopped )
01404         {
01405           setComputingState( receiverReferential, ReferenceObjectHandle::running ) ;
01406           // treating event is useless because coming computes will do that
01407           noActivationNeededFor( receiverReferential );
01408 
01409           receiverObject->init() ;
01410           // we know it is a referential
01411           _scheduler->schedule( receiverReferential ) ;
01412         }
01413       }
01414       else if( currentEvent->eventId == SystemEventIdentifier::MaskChangeObjectFrequency )
01415       {
01416         ValuedEvent< Frequency > *realEvent = dynamic_cast< ValuedEvent< Frequency > * >( currentEvent ) ;
01417         OMASSERT( realEvent != 0 ) ;
01418         ObjectDescriptor *objectDescription = _simulationTree.findDescendantNamed( realEvent->receiver ) ;
01419         if( objectDescription != 0 )
01420         {
01421           objectDescription->setFrequency( realEvent->value ) ;
01422           if( realEvent->value == computeAdequateFrequency ( realEvent->value ) )
01423           {
01424             ReferenceObjectHandle *referenceObjectHandle = _referenceObjectsMap.getObjectOfIndex( realEvent->receiver ) ;
01425             if ( referenceObjectHandle != 0 )
01426             {
01427               _scheduler->unschedule( referenceObjectHandle ) ;
01428               _scheduler->removeFromScheduable( referenceObjectHandle ) ;
01429               scheduleObject( _referenceObjectsMap.getObjectOfIndex( realEvent->receiver ) ) ;
01430             }
01431           }
01432           else 
01433           {
01434             computeScheduling( false ) ; //false necessary because otherwise no change would happen
01435             scheduleControlledObjects() ;
01436           }
01437         }
01438         else
01439         {
01440           OMTRACEID( OMK_DEBUG_OMK_EXEC,
01441                      "Controller received MaskChangeObjectFrequency for \"" << realEvent->receiver << "\" which is unknown " ) ;
01442         }
01443       }
01444     }
01445     list< Event * >::iterator toErase = i ;
01446     i++ ;
01447     Event *eventToDelete = *toErase ;
01448     myEventList.erase( toErase ) ;
01449     delete eventToDelete ;
01450   }
01451 }
01452 

void Controller::processStartEventOf ( ReferenceObjectHandle objectHandle  )  [virtual]

process MaskStart systemEvent for the object with handle

Reimplemented in OMK::DistributedController.

Definition at line 1288 of file OMKController.cpp.

References _scheduler, OMK::ReferenceObjectHandle::getComputingState(), OMK::ReferenceObjectHandle::initial, noActivationNeededFor(), OMK_DEBUG_OMK_EVENT, OMTRACEID, OMK::ReferenceObjectHandle::running, OMK::Scheduler::schedule(), and setComputingState().

Referenced by OMK::DistributedController::processStartEventOf(), and reactToControlledObjectsSystemEvents().

01288 {
01289 
01290   if(objectHandle->getComputingState() == ReferenceObjectHandle::initial) 
01291   {
01292     setComputingState (objectHandle, ReferenceObjectHandle::running ) ;
01293     noActivationNeededFor ( objectHandle );
01294     OMTRACEID( OMK_DEBUG_OMK_EVENT, "Controller::processStartEventOf Init of \"" << objectHandle->getSimulatedObject().getName() << "\"" ) ;
01295     objectHandle->init() ;
01296     OMTRACEID( OMK_DEBUG_OMK_EVENT, "Controller::processStartEventOf end of init of \"" << objectHandle->getSimulatedObject().getName() << "\"" ) ;
01297 
01298     _scheduler->schedule( objectHandle );
01299 
01300   }
01301 }
01302 

void Controller::processDeleteEventOf ( ReferenceObjectHandle objectHandle  )  [virtual]

process MaskDelete systemEvent for object obj

Definition at line 1321 of file OMKController.cpp.

References deleteObject(), OMK::ReferenceObjectHandle::destroyed, OMK::SimulatedObject::fireValuedSignal(), OMK::ReferenceObjectHandle::getComputingState(), OMK::ObjectDescriptor::getName(), OMK::SimulatedObject::getName(), OMK::SimulatedObject::getObjectDescriptor(), OMK::ObjectHandle::getSimulatedObject(), OMK::SystemEventIdentifier::MaskObjectDestroyed, OMK_DEBUG_OMK_EXEC, OMTRACEID, setComputingState(), and OMK::ReferenceObjectHandle::stopped.

Referenced by reactToControlledObjectsSystemEvents().

01321 {
01322   OMTRACEID( OMK_DEBUG_OMK_EXEC, " Controller::processDeleteEventOf \""<<objectHandle->getSimulatedObject().getName()<< "\"" ) ;
01323   if(objectHandle->getComputingState() == ReferenceObjectHandle::stopped) 
01324   {
01325     fireValuedSignal( SystemEventIdentifier::MaskObjectDestroyed, objectHandle->getSimulatedObject().getObjectDescriptor().getName() ) ;
01326     setComputingState ( objectHandle, ReferenceObjectHandle::destroyed );
01327     deleteObject(const_cast<ObjectDescriptor *>(&objectHandle->getSimulatedObject().getObjectDescriptor()) );
01328   }         
01329 }
01330 

void Controller::hasEventsToProcess ( ReferenceObjectHandle referenceObjectHandle  )  [virtual]

add the object handled by referenceObjectHandle to the list of objects having events to process and therefore that need activation (and therefore possibly activated at the current simulation step).

Behaviour is unspecified if the referenceObject is in running state

Parameters:
referenceObjectHandle objectHandle added

Definition at line 1461 of file OMKController.cpp.

References _currentListOfObjectsNeedingActivation, _date, OMK::ReferenceObjectHandle::_isInObjectNeedingActivationList, OMK::SimulatedObject::_objectHandle, _objectsNeedingActivationList, _stepPeriod, OMK::SimulatedObject::getController(), OMK::SimulatedObject::getName(), OMK::ObjectHandle::getSimulatedObject(), hasEventsToProcess(), OMASSERT, OMK_DEBUG_OMK_EVENT, and OMTRACEID.

Referenced by hasEventsToProcess(), processEventsOfSuspendedObjects(), reactToControlledObjectsSystemEvents(), and OMK::ReferenceObjectHandle::receiveEvent().

01461 {
01462   // the object handle should be correct (because this member function is called by it)
01463   OMASSERT ( dynamic_cast<ReferenceObjectHandle *>(_objectHandle) != NULL ) ;
01464 
01465   //the controller shouldn't try and schedule itself if it isn't controlled
01466   if (refObjet != _objectHandle)
01467   {
01468 
01469     if (!refObjet->_isInObjectNeedingActivationList[ _currentListOfObjectsNeedingActivation ]) 
01470     {
01471       OMTRACEID( OMK_DEBUG_OMK_EVENT, "Controller::hasEventsToProcess of \"" << refObjet->getSimulatedObject().getName() 
01472         << "\" at date "<< _date + _stepPeriod ) ;
01473       _objectsNeedingActivationList[ _currentListOfObjectsNeedingActivation ]->push_back ( refObjet );
01474       refObjet->_isInObjectNeedingActivationList[ _currentListOfObjectsNeedingActivation ] = true ;
01475     } 
01476     else 
01477     {
01478       OMTRACEID( OMK_DEBUG_OMK_EVENT, "Controller::hasEventsToProcess of \"" << refObjet->getSimulatedObject().getName() 
01479         << "\" at date "<< _date + _stepPeriod << " not necessary " ) ;
01480     }
01481   }
01482   else if ( & getController() != this )
01483   {
01484     getController().hasEventsToProcess( refObjet ) ;
01485   }
01486 }
01487 

void Controller::postponeEventProcessing ( ReferenceObjectHandle referenceObjectHandle  )  [virtual]

add the object described by referenceObjectHandle to the list of object with events to process at the next simulation step.

Definition at line 1489 of file OMKController.cpp.

References _listOfObjectsWithPostPonedEvents.

Referenced by OMK::ReferenceObjectHandle::processEvents().

01489 {
01490   _listOfObjectsWithPostPonedEvents.push_back(refObjet) ;
01491 }
01492 

void Controller::noActivationNeededFor ( ReferenceObjectHandle referenceObjectHandle  )  [virtual]

remove object designated by referenceObjectHandle from the list of object needing activation by the controler because they have events pending.

removal should occur if the reference object is becomming active

Parameters:
referenceObjectHandle : reference handle of object wich doesn't need acivation any more.

Definition at line 1454 of file OMKController.cpp.

References _currentListOfObjectsNeedingActivation, OMK::ReferenceObjectHandle::_isInObjectNeedingActivationList, _objectsNeedingActivationList, and OMASSERT.

Referenced by processStartEventAfterMorphose(), processStartEventOf(), and reactToControlledObjectsSystemEvents().

01454 {
01455   _objectsNeedingActivationList[ _currentListOfObjectsNeedingActivation ]->remove( refObjet );
01456   refObjet->_isInObjectNeedingActivationList[ _currentListOfObjectsNeedingActivation ] = false ;
01457   OMASSERT ( refObjet->_isInObjectNeedingActivationList[ 1 - _currentListOfObjectsNeedingActivation ] == false );
01458 }
01459 

void Controller::addToPendingEvents ( Event  )  [virtual]

add the event to the list of pending events.

Responsability for memory occupied by the event is transfered to the controller.

Definition at line 807 of file OMKController.cpp.

References _pendingEventsList, OMK_DEBUG_OMK_EXEC, OMTRACEID, and OMK::Event::receiver.

Referenced by OMK::SimulatedObject::sendEvent(), and OMK::SimulatedObject::sendValuedEvent().

00807 {
00808   if (event != NULL)
00809   {
00810     OMTRACEID( OMK_DEBUG_OMK_EXEC, "Controller::addToPendingEvents : Adding the following event to pending events of yet unexisting object: " << event->receiver << "\": "<< endl << *event  ) ;
00811 #ifdef _OMK_MUTEX_
00812     _mutexPendingDataStructures.protect() ;
00813 #endif
00814     map<Name, list <Event *> >::iterator pendingEventsMapIterator = _pendingEventsList.find( event->receiver ) ;
00815     if ( pendingEventsMapIterator != _pendingEventsList.end() )
00816     {
00817       pendingEventsMapIterator->second.push_back(event) ;
00818     }
00819     else
00820     {
00821       _pendingEventsList.insert (pair<Name, list<Event *> > (event->receiver, list<Event *>(1,event) ) ) ;
00822     }
00823 #ifdef _OMK_MUTEX_
00824     _mutexPendingDataStructures.unprotect() ;
00825 #endif
00826   }
00827 }
00828 

bool Controller::addToPendingRegistrations ( const EventIdentifier sig,
const Name producer,
const EventIdentifier eventId,
const Name registrant 
) [virtual]

addToPendingRegistrations.

Add a registration request for an object not created yet

Parameters:
sig the signal to register for
producer the object producing the signal
eventId the event to send if producer fires signal
registrant the object registering for sig
Returns:
registration succeeded

Definition at line 756 of file OMKController.cpp.

References _pendingRegistrationRequests.

Referenced by OMK::SimulatedObject::registerForSignalBy().

00759 {
00760 #ifdef _OMK_MUTEX_
00761   _mutexPendingDataStructures.protect() ;
00762 #endif
00763   map<Name, SignalDispatcher *>::iterator i = _pendingRegistrationRequests.find (producer) ;
00764   if ( i == _pendingRegistrationRequests.end() )
00765   {
00766     i = _pendingRegistrationRequests.insert ( pair <Name,SignalDispatcher *> (producer,
00767       new SignalDispatcher(*this) ) ).first ;
00768   }
00769 
00770   i->second->registerForSignal( sig, registrant, eventId ) ;
00771 
00772 #ifdef _OMK_MUTEX_
00773   _mutexPendingDataStructures.unprotect() ;
00774 #endif
00775 
00776   return true ;
00777 }
00778 

bool Controller::removeFromPendingRegistrations ( const EventIdentifier sig,
const Name producer,
const Name registrant 
) [virtual]

removeFromPendingRegistrations.

Remove a pending registration

Parameters:
sig the signal to cancel registration for
producer the object producing the signal
registrant the object cancelling registration for sig
Returns:
cancellation succeeded

Definition at line 780 of file OMKController.cpp.

References _pendingRegistrationRequests.

Referenced by OMK::SimulatedObject::cancelRegistrationForSignalBy().

00782 {
00783   bool result ;
00784 #ifdef _OMK_MUTEX_
00785   _mutexPendingDataStructures.protect() ;
00786 #endif
00787   map<Name, SignalDispatcher *>::iterator i = _pendingRegistrationRequests.find (producer) ;
00788   if ( i == _pendingRegistrationRequests.end() )
00789   {
00790     result = false ;
00791   }
00792   else 
00793   {
00794     result = i->second->cancelRegistrationForSignal ( sig, registrant ) ;
00795   }
00796 
00797 #ifdef _OMK_MUTEX_
00798   _mutexPendingDataStructures.unprotect() ;
00799 #endif
00800 
00801   return result ;
00802 }
00803 

bool Controller::processEvent ( Event  )  [virtual]

process events sent to the controller

Reimplemented from OMK::SimulatedObject.

Reimplemented in OMK::DistributedController.

Definition at line 1187 of file OMKController.cpp.

References _computeStatePointer, _forcedCompute, _simulationTree, changeObjectsFather(), computeScheduling(), OMK::Event::date, OMK::ReferenceObjectHandle::destroyed, OMK::Event::eventId, OMK::ObjectDescriptor::findDescendantNamed(), finish(), OMK::SimulatedObject::fireValuedSignal(), OMK::SimulatedObject::getName(), OMK::ObjectDescriptor::getName(), init(), OMK::ReferenceObjectHandle::initial, OMK::SystemEventIdentifier::MaskDelete, OMK::SystemEventIdentifier::MaskNewObject, OMK::SystemEventIdentifier::MaskObjectCreated, OMK::SystemEventIdentifier::MaskRecomputeScheduling, OMK::SystemEventIdentifier::MaskRestart, OMK::SystemEventIdentifier::MaskResume, OMK::SystemEventIdentifier::MaskStart, OMK::SystemEventIdentifier::MaskStop, OMK::SystemEventIdentifier::MaskSuspend, OMASSERT, OMK_DEBUG_OMK_EXEC, OMTRACEID, processNewObjectDeclaration(), OMK::ReferenceObjectHandle::running, scheduleControlledObjects(), OMK::ReferenceObjectHandle::stopped, and OMK::ReferenceObjectHandle::suspended.

Referenced by OMK::DistributedController::processEvent().

01187 {
01188   const EventIdentifier & eventId ( event->eventId ) ;
01189   if (eventId == SystemEventIdentifier::MaskRestart) 
01190   {
01191     if (*_computeStatePointer == ReferenceObjectHandle::stopped)
01192     {
01193       *_computeStatePointer = ReferenceObjectHandle::initial ;
01194       //implementation very difficult, because the original simulation tree has been modified
01195       init() ;
01196       OMASSERT (false) ; 
01197     }
01198     else
01199     {
01200       OMTRACEID( OMK_DEBUG_OMK_EXEC, "Controller::processEvent should be stopped before restarted" );
01201     }
01202   }
01203   else if ( eventId ==  SystemEventIdentifier::MaskResume ) 
01204   {
01205     *_computeStatePointer = ReferenceObjectHandle::running;
01206   } 
01207   else if ( eventId == SystemEventIdentifier::MaskSuspend ) 
01208   {
01209     if (*_computeStatePointer != ReferenceObjectHandle::suspended )
01210     {
01211       // moving in suspended mode
01212       // stop computations, even forced
01213       _forcedCompute = false ;
01214       *_computeStatePointer = ReferenceObjectHandle::suspended ;
01215     }
01216   } 
01217   else if ( eventId == SystemEventIdentifier::MaskStop ) 
01218   {
01219     if (*_computeStatePointer != ReferenceObjectHandle::stopped )
01220     {
01221       *_computeStatePointer=ReferenceObjectHandle::stopped ;
01222 
01223       finish() ;
01224     }
01225 
01226   } 
01227   else if ( eventId == SystemEventIdentifier::MaskStart ) 
01228   {
01229 
01230     *_computeStatePointer=ReferenceObjectHandle::running;
01231     //this produces incorrect behaviour from the point of view of an object controlling the controller
01232     //if(_date==Controller::initialSimulationDate) advanceSimulatedDate();
01233 
01234   } 
01235   else if (eventId == SystemEventIdentifier::MaskDelete ) 
01236   {
01237     *_computeStatePointer=ReferenceObjectHandle::destroyed;
01238   } 
01239   else if ( eventId == SystemEventIdentifier::MaskNewObject ) 
01240   {
01241     CreateObjectEvent * creationEvent = dynamic_cast< CreateObjectEvent* >( event ) ;
01242 
01243     OMASSERT (creationEvent != NULL ) ;
01244 
01245     // add the described object in the simulation tree : this is a declaration
01246     ObjectDescriptor * objectDescriptor = _simulationTree.findDescendantNamed( creationEvent->value.getValue().first.getName() );
01247     if ( objectDescriptor == NULL )
01248     {
01249       ObjectDescriptor * newObjectDescriptor = new ObjectDescriptor(creationEvent->value.getValue().first) ;
01250       ObjectDescriptor * fathersDescription = _simulationTree.findDescendantNamed ( creationEvent->value.getValue().second ) ;
01251       if (fathersDescription == NULL)
01252       {
01253         fathersDescription = & _simulationTree ;
01254         OMTRACEID( OMK_DEBUG_OMK_EXEC, "Attached new object named \"" << newObjectDescriptor->getName() 
01255           << "\" to \"" << getName()
01256           << "\" because object \""<<creationEvent->value.getValue().second<<"\" is unknown" );
01257       }
01258       changeObjectsFather (newObjectDescriptor, fathersDescription) ;
01259 
01260       //create the described object
01261       processNewObjectDeclaration ( *newObjectDescriptor, event->date ) ;
01262 
01263       // notify other objects that an object has been created
01264       fireValuedSignal(SystemEventIdentifier::MaskObjectCreated,creationEvent->value.getValue().first.getName() ) ;
01265     }
01266     else
01267     {
01268       OMTRACEID( OMK_DEBUG_OMK_EXEC, "WARNING: an object of name \"" << creationEvent->value.getValue().first.getName()
01269         << "\" already exists" ) ;
01270     }
01271   }
01272   else if ( eventId == SystemEventIdentifier::MaskRecomputeScheduling)
01273   {
01274     computeScheduling( true ) ;
01275 
01276     scheduleControlledObjects() ;
01277   }
01278   else 
01279   {
01280     OMTRACEID( OMK_DEBUG_OMK_EXEC, "WARNING:Controller::ProcessEvent unable to process system event " ) ;
01281   } 
01282   return true ;
01283 }
01284 

void Controller::processEventsOfSuspendedObjects (  )  [virtual]

call processEvent for suspended objects having received events

Definition at line 1494 of file OMKController.cpp.

References _currentListOfObjectsNeedingActivation, _date, OMK::ReferenceObjectHandle::_isInObjectNeedingActivationList, _listOfObjectsWithPostPonedEvents, _objectsNeedingActivationList, hasEventsToProcess(), OMK_DEBUG_OMK_EVENT, OMTRACEID, and OMK::ReferenceObjectHandle::processEvents().

Referenced by computeNextSimulationStep().

01494 {   
01495   OMTRACEID( OMK_DEBUG_OMK_EVENT, "Controller::processEventsOfSuspendedObjects "<< _date ) ;
01496   while ( ! _objectsNeedingActivationList[ _currentListOfObjectsNeedingActivation ]->empty() ) {
01497     //using a iteration to be able to process ASAP events generated throught this phase
01498     int indiceFile = _currentListOfObjectsNeedingActivation ;
01499     _currentListOfObjectsNeedingActivation = 1 - _currentListOfObjectsNeedingActivation ;
01500     ReferenceObjectHandle * courant;
01501     list<ReferenceObjectHandle *>::iterator i;
01502     i=_objectsNeedingActivationList[indiceFile]->begin();
01503     while(i!=_objectsNeedingActivationList[indiceFile]->end()) {
01504       list<ReferenceObjectHandle *>::iterator needsDelete;
01505       courant=(*i);
01506       courant->processEvents () ;
01507       courant->_isInObjectNeedingActivationList[indiceFile]= false ;
01508       needsDelete=i;
01509       i++; 
01510       _objectsNeedingActivationList[indiceFile]->erase(needsDelete);
01511     }
01512   }
01513   list < ReferenceObjectHandle * >::iterator j =  _listOfObjectsWithPostPonedEvents.begin() ;
01514   list < ReferenceObjectHandle * >::iterator toErase ;
01515   while ( j != _listOfObjectsWithPostPonedEvents.end() ) {
01516     hasEventsToProcess (*j) ;
01517     toErase = j ;
01518     j++ ;
01519     _listOfObjectsWithPostPonedEvents.erase( toErase ) ;
01520   }
01521   OMTRACEID( OMK_DEBUG_OMK_EVENT, "Controller::processEventsOfSuspendedObjects end "<< _date ) ;
01522 }
01523 

void Controller::broadcastEventsForSignal ( Event event,
const EventIdentifier sigId 
) [virtual]

broadcast events corresponding to a fired signal

Parameters:
sigId the signal fired
event the event prototype to send to registered objects

Reimplemented in OMK::DistributedController.

Definition at line 1546 of file OMKController.cpp.

References _controledObjectsSignalsDispatcher, OMK_DEBUG_OMK_EVENT, OMTRACEID, and OMK::SignalDispatcher::sendEventsForSignal().

Referenced by OMK::DistributedController::broadcastEventsForSignal(), OMK::SimulatedObject::fireSignal(), OMK::SimulatedObject::fireValuedSignal(), and OMK::ReferenceObjectHandle::sendEventsForSignal().

01546 {
01547   OMTRACEID( OMK_DEBUG_OMK_EVENT, "Controller::broadcastEventsForSignal \"" << sigId << "\"" ) ;
01548   _controledObjectsSignalsDispatcher.sendEventsForSignal( event , sigId ) ;
01549 }
01550 

bool Controller::receiveRegistrationForSignal ( const EventIdentifier sigId,
const Name registrant,
const EventIdentifier eventId 
) [virtual]

register an object for a signal

Parameters:
sigId the signal to react to
registrant the simulated object registering to signal sigId
eventId the eventId to send to registrant when sigId is emitted

Reimplemented in OMK::DistributedController.

Definition at line 1553 of file OMKController.cpp.

References _controledObjectsSignalsDispatcher, OMK_DEBUG_OMK_EVENT, OMTRACEID, and OMK::SignalDispatcher::registerForSignal().

Referenced by OMK::SimulatedObject::registerForSignal().

01555 {
01556   OMTRACEID( OMK_DEBUG_OMK_EVENT, "Controller::receiveRegistrationForSignal \"" << sig
01557     << "\" by \"" << registrant
01558     << "\" for \"" << eventId << "\"" ) ;
01559   return _controledObjectsSignalsDispatcher.registerForSignal(sig , registrant , eventId) ;
01560 }
01561 

bool Controller::receiveCancellationForSignal ( const EventIdentifier sigId,
const Name registrant 
) [virtual]

cancel the registration of an object for a signal

Parameters:
sigId the signal for wich there is a cancellation
registrant the object cancelling registration

Reimplemented in OMK::DistributedController.

Definition at line 1564 of file OMKController.cpp.

References _controledObjectsSignalsDispatcher, and OMK::SignalDispatcher::cancelRegistrationForSignal().

Referenced by OMK::SimulatedObject::cancelRegistrationForSignal().

01564 {
01565   return _controledObjectsSignalsDispatcher.cancelRegistrationForSignal (sigId , registrant) ;
01566 }
01567 

void Controller::setComputingState ( ReferenceObjectHandle ,
ReferenceObjectHandle::SimulatedObjectComputingState   
) const [protected, virtual]

change the computing state of a reference object handle

Definition at line 1601 of file OMKController.cpp.

References OMK::ReferenceObjectHandle::_computingState.

Referenced by processDeleteEventOf(), processStartEventAfterMorphose(), OMK::DistributedController::processStartEventOf(), processStartEventOf(), and reactToControlledObjectsSystemEvents().

01602 {
01603   handle->_computingState = state ;
01604 }
01605 

void Controller::switchSystemEventList (  )  [protected, virtual]

switch buffer of List Of Objects Needing Activation

Definition at line 1159 of file OMKController.cpp.

References _currentWritableSystemEventsList.

Referenced by reactToControlledObjectsSystemEvents().

void Controller::purgeMemoryFromOldEvents ( const Date dateOfOldestKept  )  [protected, virtual]

the method used to purge the data structures from all outdated kepts events.

For example, an event sent to an uncreated object would be purged if no object claims the event

Reimplemented in OMK::DistributedController.

Definition at line 561 of file OMKController.cpp.

References _deletedObjectHandles, _pendingEventsList, deleteObjectHandle(), OMK_DEBUG_OMK_EXEC, and OMTRACEID.

Referenced by compute(), OMK::DistributedController::purgeMemoryFromOldEvents(), and ~Controller().

00561 {
00562   // purge old events with no known receiver
00563   map<Name, list <Event *> >::iterator pendingEventsMapIterator = _pendingEventsList.begin() ;
00564   while ( pendingEventsMapIterator != _pendingEventsList.end() )
00565   {
00566     list<Event *>::iterator eventListIterator = pendingEventsMapIterator->second.begin() ;
00567     while ( eventListIterator != pendingEventsMapIterator->second.end() )
00568     {
00569       if ( (*eventListIterator)->date < dateOfOldestKept )
00570       {
00571         delete *eventListIterator ;
00572         eventListIterator = pendingEventsMapIterator->second.erase ( eventListIterator ) ;
00573       }
00574       else 
00575       {
00576         ++ eventListIterator ;
00577       }
00578     }
00579     if ( pendingEventsMapIterator->second.empty() )
00580     {
00581       _pendingEventsList.erase ( pendingEventsMapIterator++ ) ;
00582     }
00583     else
00584     {
00585       pendingEventsMapIterator++ ;
00586     }
00587   }
00588 
00589 
00590   //purge deleted objects, objects handles and object descriptors
00591   bool disposableElements = !_deletedObjectHandles.empty() ;
00592   pair <Date, ObjectHandle *> examinedObjectHandle ;
00593   while ( disposableElements )
00594   {
00595     examinedObjectHandle = _deletedObjectHandles.front() ;
00596     if ( examinedObjectHandle.first < dateOfOldestKept )
00597     {
00598       OMTRACEID( OMK_DEBUG_OMK_EXEC, "Controller::purgeMemoryFromOldEvents: deleting \""
00599         << examinedObjectHandle.second->getSimulatedObject().getName() << "\"" ) ;
00600       if ( &examinedObjectHandle.second->getSimulatedObject() != this )
00601         deleteObjectHandle ( examinedObjectHandle.second ) ;
00602       _deletedObjectHandles.pop_front() ;
00603       disposableElements = !_deletedObjectHandles.empty() ;
00604     }
00605     else 
00606     {
00607       disposableElements = false ;
00608     }
00609   }
00610 }
00611 

Date Controller::getPurgeDate (  )  [protected, virtual]

get the date of the oldest event not purged by purgeMemoryFromOldEvents

Reimplemented in OMK::PvmController.

Definition at line 555 of file OMKController.cpp.

References _date, and _stepPeriod.

Referenced by compute(), and OMK::PvmController::getPurgeDate().

00555 {
00556   return _date - _stepPeriod ;
00557 }
00558 

int Controller::getOutputHistorySize ( void   )  [protected, virtual]

get the minimum history length pertinant for this controller The value returned is the value of the environement variable MaskHISTORYLENGTH, or a default value calculated so that get(-4 dt) return an exact value if it has been produced

Reimplemented in OMK::PvmController.

Definition at line 1527 of file OMKController.cpp.

Referenced by createControlParameter(), createOutput(), createOutputAlias(), and OMK::PvmController::getOutputHistorySize().

01534   {
01535     result = _nbStepsByCycle*4+1 ;
01536   }
01537   else 
01538   {
01539     result = atoi (environementValue) ;
01540   }
01541   return result ;
01542 }  
01543 

ReferenceObjectHandle * Controller::createReferenceObjectHandle ( SimulatedObject obj  )  [protected, virtual]

create a reference object handler appropriate for this controller

Parameters:
obj the object to handle the reference object created

Definition at line 1581 of file OMKController.cpp.

References _pendingRegistrationRequests, OMK::SimulatedObject::getName(), newOMKReferenceObjectHandle(), OMK_DEBUG_OMK_OBJ, and OMTRACEID.

Referenced by Controller(), createReferenceObject(), and OMK::DistributedController::processEvent().

01581 {
01582   /* no mutex protection needed, because this member function is only called by the controller during system event processing */
01583   OMTRACEID( OMK_DEBUG_OMK_OBJ, "Controller::createReferenceObjectHandle" ) ;
01584   ReferenceObjectHandle * result ;
01585   map<Name, SignalDispatcher *>::iterator i = _pendingRegistrationRequests.find( obj.getName() ) ;
01586   if ( i == _pendingRegistrationRequests.end() )
01587   {
01588     result = newOMKReferenceObjectHandle(obj,*this, new SignalDispatcher (*this) );
01589   }
01590   else 
01591   {
01592     result = newOMKReferenceObjectHandle(obj,*this, i->second) ;
01593     _pendingRegistrationRequests.erase ( i ) ;
01594   }
01595   OMTRACEID( OMK_DEBUG_OMK_OBJ, "Controller::createReferenceObjectHandle ended" ) ;
01596   return result ;
01597 }
01598 

ReferenceObjectHandle * Controller::newOMKReferenceObjectHandle ( SimulatedObject object,
Controller controller,
SignalDispatcher signalDispatcher 
) [protected, virtual]

The controller is an abstract factory for reference object handles.

Parameters:
obj the object to handle
controller the controller of that object
the signal dispatche used by that object the reference object created

Reimplemented in OMK::PvmController.

Definition at line 1572 of file OMKController.cpp.

Referenced by createReferenceObjectHandle().

01574 {
01575   return new ReferenceObjectHandle(object, controller, signalDispatcher) ;
01576 }
01577 

void Controller::deleteObjectHandle ( ObjectHandle objectHandle  )  [protected, virtual]

as the controller is an abstract factory for object handlers, is should also be an abstract destroyer

Definition at line 905 of file OMKController.cpp.

References OMK::ObjectDescriptor::_pointerToSimulatedObject, OMK::ObjectDescriptor::getName(), OMK::SimulatedObject::getObjectDescriptor(), OMK::ObjectHandle::getSimulatedObject(), OMK_DEBUG_OMK_EXEC, and OMTRACEID.

Referenced by OMK::DistributedController::processEvent(), and purgeMemoryFromOldEvents().

00905 {
00906 
00907   ObjectDescriptor * objectDescriptor  = const_cast<ObjectDescriptor *>(& objectHandle->getSimulatedObject().getObjectDescriptor() ) ;
00908 
00909   delete objectHandle ;
00910 
00911   //The object description is referenced by the simulation tree and the simulated object
00912   //delete the object description only if it isn't referenced by its simulated object 
00913   if ( objectDescriptor->_pointerToSimulatedObject == NULL ) 
00914   {
00915     OMTRACEID( OMK_DEBUG_OMK_EXEC, "Controller::deleteObject: deleting object descriptor of object \"" << objectDescriptor->getName() << "\"" ) ;
00916     OMTRACEID( "Deleting", "Controller::deleteObject: deleting object descriptor of object \"" << objectDescriptor->getName() << "\"" ) ;
00917     delete objectDescriptor;
00918   }
00919 }
00920 

bool Controller::setKernelObjectFactory ( KernelObjectAbstractFactory aFactory  )  [static]

set the kernelObjectfactory for the controller of this adressing space is only effective once for each adress space to be called before creation of the controller to be effective return : change effective

Definition at line 42 of file OMKController.cpp.

References kernelObjectFactory.

00043 {
00044   if ( kernelObjectFactory != NULL ) 
00045   {
00046     kernelObjectFactory = aFactory ;
00047     return true ;
00048   }
00049   else 
00050   {
00051     return false ;
00052   }
00053 }

KernelObjectAbstractFactory * Controller::getKernelObjectFactory (  )  [static]

get the active kernelObjectFactory

Definition at line 55 of file OMKController.cpp.

References kernelObjectFactory.

Referenced by createControlParameter(), createInput(), createInputAlias(), createOutput(), createOutputAlias(), createSensitiveInput(), createSensitiveInputAlias(), createSensitiveNotifyingInput(), and createSensitiveNotifyingInputAlias().

00056 {
00057   if ( kernelObjectFactory == NULL ) 
00058   {
00059     kernelObjectFactory = new KernelObjectClassicFactory () ;
00060   }
00061 
00062   return kernelObjectFactory ;
00063 }

template<typename Type>
Input< Type > * OMK::Controller::createInput ( const Name name,
SimulatedObject owner,
bool  makeConnectable,
int  requestedPrecisionLevel 
) [inline]

create an input

Parameters:
t the type of input created
name the name of the input created
owner the owner of the input
requestedPrecisionLevel the polation level that willl be used by that input
Returns:
the requested input

Definition at line 725 of file OMKController.h.

References getKernelObjectFactory().

00729 {
00730   return getKernelObjectFactory ()->template createInput<Type> (name,owner,makeConnectable,requestedPrecisionLevel);
00731 }

template<typename Type>
SensitiveInput< Type > * OMK::Controller::createSensitiveInput ( const Name name,
SimulatedObject owner,
bool  makeConnectable,
int  requestedPrecisionLevel 
) [inline]

create a sensitive input

Parameters:
t the type of sensitive input created
name the name of the sensitive input created
owner the owner of the sensitive input
requestedPrecisionLevel the polation level that willl be used by that input
Returns:
the requested sensitive input

Definition at line 742 of file OMKController.h.

References getKernelObjectFactory().

00746 {
00747   return getKernelObjectFactory ()->template createSensitiveInput<Type>(name,owner,makeConnectable,requestedPrecisionLevel);
00748 }

template<typename Type>
SensitiveNotifyingInput< Type > * OMK::Controller::createSensitiveNotifyingInput ( const Name name,
SimulatedObject owner,
bool  makeConnectable,
int  requestedPrecisionLevel 
) [inline]

create a sensitive notifying input

Parameters:
t the type of sensitive notifying input created
name the name of the sensitive notifying input created
owner the owner of the sensitive notifying input
requestedPrecisionLevel the polation level that willl be used by that sensitive notifying input
Returns:
the requested sensitive notifying input

Definition at line 758 of file OMKController.h.

References getKernelObjectFactory().

00762 {
00763   return getKernelObjectFactory ()->template createSensitiveNotifyingInput<Type>(name,owner,makeConnectable,requestedPrecisionLevel);
00764 }

template<typename Type>
Output< Type > * OMK::Controller::createOutput ( const Name name,
SimulatedObject owner,
OMK::Type::PolatorNT polator 
) [inline]

create an ouput

Parameters:
t the type of the output created
name the name of the output created
owner the owner of the output
polator the associated polator
Returns:
the requested output

Definition at line 775 of file OMKController.h.

References getKernelObjectFactory(), and getOutputHistorySize().

00778 {
00779   return getKernelObjectFactory ()->template createOutput<Type>(name,owner,getOutputHistorySize(),polator);
00780 }

template<typename Type>
ControlParameter< Type > * OMK::Controller::createControlParameter ( const Name name,
SimulatedObject owner,
OMK::Type::PolatorNT polator 
) [inline]

create a control parameter

Parameters:
t the type of the control parameter created
name the name of the control parameter created
owner the owner of the control parameter
Returns:
the requested control parameter

Definition at line 790 of file OMKController.h.

References getKernelObjectFactory(), and getOutputHistorySize().

00793 {
00794   return getKernelObjectFactory ()->template createControlParameter<Type>(name,owner,getOutputHistorySize(),polator);
00795 }

template<typename Type>
InputAlias< Type > * OMK::Controller::createInputAlias ( const Name name,
SimulatedObject owner,
AbstractInput< Type > *  input,
int  requestedPrecisionLevel 
) [inline]

create an input alias

Parameters:
t the type of input alias created
name the name of the input alias created
owner the owner of the input alias
input the aliased input
requestedPrecisionLevel the polation level that willl be used by that input alias
Returns:
the requested input

Definition at line 807 of file OMKController.h.

References getKernelObjectFactory().

00811 {   
00812   return getKernelObjectFactory ()->template createInputAlias<Type>(name,owner,input,requestedPrecisionLevel);
00813 }

template<typename Type>
SensitiveInputAlias< Type > * OMK::Controller::createSensitiveInputAlias ( const Name name,
SimulatedObject owner,
AbstractInput< Type > *  input,
int  requestedPrecisionLevel 
) [inline]

create a sensitive input alias

Parameters:
t the type of sensitive input alias created
name the name of the sensitive input alias created
owner the owner of the sensitive input alias
input the aliased input
requestedPrecisionLevel the polation level that willl be used by that sensitive input alias
Returns:
the requested sensitive input

Definition at line 825 of file OMKController.h.

References getKernelObjectFactory().

00829 {
00830   return getKernelObjectFactory ()->template createSensitiveInputAlias<Type>(name,owner,input,requestedPrecisionLevel);
00831 }

template<typename Type>
SensitiveNotifyingInputAlias< Type > * OMK::Controller::createSensitiveNotifyingInputAlias ( const Name name,
SimulatedObject owner,
AbstractInput< Type > *  input,
int  requestedPrecisionLevel 
) [inline]

create a sensitive notifying input alias

Parameters:
t the type of sensitive notifying input alias created
name the name of the sensitive notifying input alias created
owner the owner of the sensitive notifying input alias
input the aliased input
requestedPrecisionLevel the polation level that willl be used by that sensitive notifying input alias
Returns:
the requested sensitive notifying input

Definition at line 843 of file OMKController.h.

References getKernelObjectFactory().

00847 {   
00848   return getKernelObjectFactory ()->template createSensitiveNotifyingInputAlias<Type>(name,owner,input,requestedPrecisionLevel);
00849 }

template<typename Type>
OutputAlias< Type > * OMK::Controller::createOutputAlias ( const Name name,
SimulatedObject owner,
Output< Type > *  output,
OMK::Type::PolatorNT polator 
) [inline]

create an ouput alias

Parameters:
t the type of the output alias created
name the name of the output alias created
owner the owner of the output alias
output the aliased output
polator the associated polator
Returns:
the requested output alias

Definition at line 861 of file OMKController.h.

References getKernelObjectFactory(), and getOutputHistorySize().

00865 {
00866   return getKernelObjectFactory ()->template createOutputAlias<Type>(name,owner,output,getOutputHistorySize(),polator);
00867 }


Friends And Related Function Documentation

friend class InputNT [friend]

Reimplemented from OMK::SimulatedObject.

Definition at line 264 of file OMKController.h.

friend class OMK::SimulatedObject [friend]

Definition at line 265 of file OMKController.h.


Member Data Documentation

Date Controller::initialSimulationDate [static]

date at which simulation was initialised

Definition at line 168 of file OMKController.h.

Referenced by OMK::PvmController::advanceSimulatedDate(), Controller(), init(), OMK::SimulatedObject::insertInStream(), OMK::SimulatedObject::pack(), and OMK::ReferenceObjectHandle::ReferenceObjectHandle().

std::vector<Name> OMK::Controller::_publicReferentielObjectsVector

CHADI.

Definition at line 292 of file OMKController.h.

Referenced by getReferentielList().

NameToPointerMap<ReferenceObjectHandle> OMK::Controller::_referenceObjectsMap [protected]

data structure containing references to the ReferenceObjectHandlers

Definition at line 315 of file OMKController.h.

Referenced by OMK::PvmController::computeNextSimulationStep(), computeScheduling(), OMK::DistributedController::createDuplicatedObject(), createReferenceObject(), OMK::DistributedController::dispatchEvent(), getPointerToDuplicatedObjectNamed(), OMK::DistributedController::getPointerToSimulatedObjectNamed(), getPointerToSimulatedObjectNamed(), getReferentielList(), init(), OMK::PvmController::parseSynchronisationMessage(), OMK::DistributedController::processEvent(), reactToControlledObjectsSystemEvents(), OMK::PvmController::removeObjectFromDataStructures(), OMK::PvmController::run(), scheduleControlledObjects(), and OMK::PvmController::sendInitialValuesToMirror().

ObjectDescriptor& OMK::Controller::_simulationTree [protected]

the simulation tree this controller is root of This has to be a reference to a allready constructed simulation tree, because the root descriptor of that tree is used a parameter of the ancestors constructor wich keeps a reference of that descriptor.

Therefore, problems will arise if _simulationTree is a copy

Definition at line 320 of file OMKController.h.

Referenced by changeObjectsFather(), computeScheduling(), Controller(), destroyObject(), finish(), OMK::DistributedController::getObjectDescriptorOfObject(), getObjectDescriptorOfObject(), OMK::DistributedController::getPointerToSimulatedObjectNamed(), init(), OMK::DistributedController::processEvent(), processEvent(), OMK::PvmController::PvmController(), and reactToControlledObjectsSystemEvents().

unsigned long int OMK::Controller::_numberOfSimulatedSteps [protected]

number of simulated steps up to now

Definition at line 323 of file OMKController.h.

Referenced by advanceSimulatedDate(), and computeNextSimulationStep().

Frequency OMK::Controller::_stepFrequency [protected]

frequency of a simulation step

Definition at line 328 of file OMKController.h.

Referenced by computeAdequateFrequency(), computeScheduling(), and init().

int OMK::Controller::_cycleFrequency [protected]

the frequency at wich activation patterns repeat themselves

Definition at line 331 of file OMKController.h.

Referenced by getCycleFrequency(), and setCycleFrequency().

int OMK::Controller::_cyclePeriod [protected]

duration in simulated time of a simualtion cycle

Definition at line 334 of file OMKController.h.

Referenced by getCyclePeriod(), and setCycleFrequency().

int OMK::Controller::_nbStepsByCycle [protected]

number of simulation step by cycle : we have _cycleFrequency * stepFrequency = _nbStepsByCycle

Definition at line 338 of file OMKController.h.

Referenced by computeScheduling(), and createScheduler().

int OMK::Controller::_stepPeriod [protected]

_stepPeriod.

Duration in simulated time of a simulated step

Definition at line 343 of file OMKController.h.

Referenced by advanceSimulatedDate(), computeScheduling(), OMK::PvmController::getOutputHistorySize(), getPurgeDate(), hasEventsToProcess(), init(), OMK::PvmController::run(), ~Controller(), and OMK::DistributedController::~DistributedController().

Date OMK::Controller::_date [protected]

simulated date

Definition at line 346 of file OMKController.h.

Referenced by OMK::PvmController::advanceSimulatedDate(), advanceSimulatedDate(), OMK::DistributedController::broadcastEventsForSignal(), computeScheduling(), OMK::DistributedController::deleteObject(), deleteObject(), OMK::DistributedController::getPointerToSimulatedObjectNamed(), getPurgeDate(), getSimulatedDate(), hasEventsToProcess(), OMK::PvmController::init(), init(), OMK::PvmController::makeSynchronisationMessage(), processEventsOfSuspendedObjects(), OMK::DistributedController::receiveCancellationForSignal(), OMK::DistributedController::receiveRegistrationForSignal(), OMK::PvmController::run(), OMK::PvmController::sendInitialValuesToMirror(), ~Controller(), and OMK::DistributedController::~DistributedController().

bool OMK::Controller::_showDateAndStepNumber [protected]

flag indicating if the date and simulation step number are printed

Definition at line 349 of file OMKController.h.

Referenced by advanceSimulatedDate(), and showDateAndStepNumber().

ReferenceObjectHandle::SimulatedObjectComputingState* OMK::Controller::_computeStatePointer [protected]

a pointer for easy access to th computationnel state of the controller : if the controller is controlling itsekg, this computationnal state should be : running

Definition at line 352 of file OMKController.h.

Referenced by Controller(), processEvent(), OMK::PvmController::PvmController(), run(), and runControllersStep().

SignalDispatcher OMK::Controller::_controledObjectsSignalsDispatcher [protected]

signal dispatcher for objects interested in a signal whatever it's producer

Definition at line 439 of file OMKController.h.

Referenced by broadcastEventsForSignal(), OMK::DistributedController::processEvent(), receiveCancellationForSignal(), and receiveRegistrationForSignal().

bool OMK::Controller::_forcedCompute [protected]

to enable computations even in suspendedState, when the controller is controlled

Definition at line 446 of file OMKController.h.

Referenced by processEvent(), and runControllersStep().

Scheduler* OMK::Controller::_scheduler [protected]

the scheduler

Definition at line 449 of file OMKController.h.

Referenced by computeNextSimulationStep(), computeScheduling(), OMK::DistributedController::processEvent(), processStartEventAfterMorphose(), processStartEventOf(), reactToControlledObjectsSystemEvents(), and ~Controller().

std::list<ReferenceObjectHandle *>* OMK::Controller::_objectsNeedingActivationList[2] [protected]

double buffered list of controlled object needing activation because they have received events Protect usage with _mutexForListEvt ;

Definition at line 454 of file OMKController.h.

Referenced by Controller(), hasEventsToProcess(), noActivationNeededFor(), processEventsOfSuspendedObjects(), removeObjectFromDataStructures(), and ~Controller().

int OMK::Controller::_currentListOfObjectsNeedingActivation [protected]

1 - _currentListOfObjectsNeedingActivation is used to store new object needing activation

Definition at line 457 of file OMKController.h.

Referenced by Controller(), hasEventsToProcess(), noActivationNeededFor(), and processEventsOfSuspendedObjects().

std::list<Event *>* OMK::Controller::_systemEventsList[2] [protected]

double buffered system event list

Definition at line 463 of file OMKController.h.

Referenced by actOnSystemEvent(), Controller(), reactToControlledObjectsSystemEvents(), and ~Controller().

unsigned int OMK::Controller::_currentWritableSystemEventsList [protected]

_systemEventsList[_currentWritableSystemEventsList] is used to store system events sent to controlled objects

Definition at line 466 of file OMKController.h.

Referenced by actOnSystemEvent(), Controller(), reactToControlledObjectsSystemEvents(), and switchSystemEventList().

std::list<ReferenceObjectHandle * > OMK::Controller::_listOfObjectsWithPostPonedEvents [protected]

list of objects with postponed events

Definition at line 469 of file OMKController.h.

Referenced by postponeEventProcessing(), and processEventsOfSuspendedObjects().

std::map<Name, std::list<Event *> > OMK::Controller::_pendingEventsList [protected]

list of pending events (events sent to unknown objects)

Definition at line 476 of file OMKController.h.

Referenced by addToPendingEvents(), OMK::DistributedController::processNewObjectDeclaration(), purgeMemoryFromOldEvents(), and sendInitialEventsTo().

std::map<Name, SignalDispatcher *> OMK::Controller::_pendingRegistrationRequests [protected]

map of pending registration requests

Definition at line 484 of file OMKController.h.

Referenced by addToPendingRegistrations(), createReferenceObjectHandle(), removeFromPendingRegistrations(), and ~Controller().

std::list<std::pair <Date, ObjectHandle *> > OMK::Controller::_deletedObjectHandles [protected]

the list of recently deleted object handles.

Deleted objects pass through purge because

Definition at line 496 of file OMKController.h.

Referenced by deleteObject(), getObjectDescriptorOfObject(), getPointerToSimulatedObjectNamed(), purgeMemoryFromOldEvents(), and OMK::PvmController::sendInitialValuesToMirror().

KernelObjectAbstractFactory * Controller::kernelObjectFactory [static, private]

the kernel object factory used to create attribute of controlled object

Definition at line 658 of file OMKController.h.

Referenced by getKernelObjectFactory(), and setKernelObjectFactory().


logo OpenMask

Documentation generated on Mon Jun 9 11:46:02 2008

Generated with doxygen by Dimitri van Heesch ,   1997-2007