ALMA Computing Group

LampWheel Class Reference
[ACS Components Examples]

The class LampWheel class simulates the behavior of a very simple lamp wheel using an asynchronous method to rotate it. More...

#include <acsexmplLampWheelImpl.h>

List of all members.

Public Member Functions

 LampWheel (const ACE_CString &name, maci::ContainerServices *containerServices)
 Constructor.
virtual ~LampWheel ()
 Destructor.
virtual void initialize ()
 Called to give the component time to initialize itself.
virtual void execute ()
 Called after initialize to tell the component that it has to be ready to accept incoming functional calls any time.
virtual void cleanUp ()
 Called after the last functional call to the component has finished.
virtual void aboutToAbort ()
 Called when due to some error condition the component is about to be forcefully removed some unknown amount of time later (usually not very much...).
virtual baci::ActionRequest invokeAction (int function, baci::BACIComponent *cob_p, const int &callbackID, const CBDescIn &descIn, baci::BACIValue *value_p, Completion &completion, CBDescOut &descOut)
 Action dispatcher function This function is called whenever an asynchronous request has to be handled.
virtual baci::ActionRequest moveAction (baci::BACIComponent *cob_p, const int &callbackID, const CBDescIn &descIn, baci::BACIValue *value_p, Completion &completion, CBDescOut &descOut)
 Implementation of asynchrnous acsexmplLamp::Lamp::off() method This is the function that actually switches off the Lamp and, when completed, invokes the callback installed by the client when it requested the action.
virtual void move (CORBA::Short, ACS::CBvoid_ptr, const ACS::CBDescIn &)
 Move the lamp wheel to a specification slot.
virtual ACS::ROdouble_ptr position ()
 Returns a reference to the position property Implementation of IDL interface for the property.
virtual ACS::ROstring_ptr desc ()
 Returns a reference to the desc property Implementation of IDL interface for the property.
virtual ACS::ROlong_ptr slots ()
 Returns a reference to the descavailableSlots property Implementation of IDL interface for the property.

Private Member Functions

void operator= (const LampWheel &)
 ALMA C++ coding standards state copy operators should be disabled.
int retrieveConfigurationFromCDB (std::list< SlotDescriptor > &config)
 Read the CDB and fill the list with the actual configuration of each slot.

Static Private Member Functions

void start_hndl (void *data, const XML_Char *el, const XML_Char **attr)
 The handler for the start element.
void end_hndl (void *data, const XML_Char *el)
 The handler for the end element.
void char_hndl (void *data, const XML_Char *s, int len)
 The handler for the char element.

Private Attributes

ACE_CString m_fullName
baci::SmartPropertyPointer<
baci::ROdouble > 
m_position_sp
 m_position_sp is the position of the wheel.
baci::SmartPropertyPointer<
baci::ROstring > 
m_desc_sp
 m_desc_sp is the description of the wheel.
baci::SmartPropertyPointer<
baci::ROlong > 
m_slots_sp
 m_slots_sp is the number of available slots in the wheel
std::list< SlotDescriptorm_lampWheelConfiguration
 The list of descriptions of each slot of the wheel: it is the configuration of the lampWheel It is built reading the CDB.


Detailed Description

The class LampWheel class simulates the behavior of a very simple lamp wheel using an asynchronous method to rotate it.

The component reads the wheel data from the CDB. The lamp wheel is caracterized by a description, a number of available slots and a description of the used slots. All these data reside on the CDB. In particular, the number of defined slots is not defined a priori but is retrieved by parsing the CDB record for the component.

At startup, the component read the description of the wheel from the CDB and stores the configuration into a list. The move method moves the wheel to the position defined for the passed slot number. The position is read from the list (i.e. from the CDB). A log message inform the user about the selected lamp.

Author:
Alessandro Caproni,
Version:
"@(#) $Id: acsexmplLampWheelImpl.h,v 1.16 2008/10/09 08:41:11 cparedes Exp $"

Definition at line 121 of file acsexmplLampWheelImpl.h.


Constructor & Destructor Documentation

LampWheel::LampWheel const ACE_CString &  name,
maci::ContainerServices *  containerServices
 

Constructor.

Parameters:
poa Poa which will activate this and also all other components.
name component's name. This is also the name that will be used to find the configuration data for the component in the Configuration Database.
Definition at line 49 of file acsexmplLampWheelImpl.cpp.

LampWheel::~LampWheel  )  [virtual]
 

Destructor.

Definition at line 64 of file acsexmplLampWheelImpl.cpp.


Member Function Documentation

void LampWheel::aboutToAbort  )  [virtual]
 

Called when due to some error condition the component is about to be forcefully removed some unknown amount of time later (usually not very much...).

The component should make an effort to die as neatly as possible. Because of its urgency, this method will be called asynchronously to the execution of any other method of the component. If this method is overwritten in a chain of subclasses, the developer might need to make sure that all activities performed by the implementation of the base class take place. Check the documentation of direct parent class to know if this is necessary (and do not forget to document each class for the need to chain lifecycle methods in subclasses). The best way to do this is to call the implementation of the base itself explicitly, as would be done implicitly in a constructor chain. In this class the default implementation only sets the state of the component to acscomponent::ACS::ACS::COMPSTATE_ABORTING

Returns:
void *

*
Definition at line 361 of file acsexmplLampWheelImpl.cpp.

void LampWheel::char_hndl void *  data,
const XML_Char *  s,
int  len
[static, private]
 

The handler for the char element.

See also:
libexpat documentation for further info
Definition at line 256 of file acsexmplLampWheelImpl.cpp.

References ParserStruct::actualTag, SlotDescriptor::pos, POS_TAG, ParserStruct::slotDescr, SlotDescriptor::warmUpTime, SlotDescriptor::watt, WATT_TAG, and WUT_TAG.

Referenced by retrieveConfigurationFromCDB().

void LampWheel::cleanUp  )  [virtual]
 

Called after the last functional call to the component has finished.

The component should then orderly release resources etc. If this method is overwritten in a subclass, the developer has to make sure that all cleanup performed by the implementation of the base class take place. The best way to do this is to call the implementation of the base itself explicitly, as would be done implicitly in a destructor chain. If this method is overwritten in a chain of subclasses, the developer might need to make sure that all activities performed by the implementation of the base class take place. Check the documentation of direct parent class to know if this is necessary (and do not forget to document each class for the need to chain lifecycle methods in subclasses). The best way to do this is to call the implementation of the base itself explicitly, as would be done implicitly in a destructor chain. In this class the default implementation only sets the state of the component to acscomponent::ACS::COMPSTATE_DESTROYING

Returns:
void *

*
Definition at line 354 of file acsexmplLampWheelImpl.cpp.

References m_lampWheelConfiguration.

ACS::ROstring_ptr LampWheel::desc  )  [virtual]
 

Returns a reference to the desc property Implementation of IDL interface for the property.



Definition at line 475 of file acsexmplLampWheelImpl.cpp.

References m_desc_sp.

void LampWheel::end_hndl void *  data,
const XML_Char *  el
[static, private]
 

The handler for the end element.

See also:
libexpat documentation for further info
Definition at line 235 of file acsexmplLampWheelImpl.cpp.

References ParserStruct::actualTag, NO_TAG, ParserStruct::slotDescr, and ParserStruct::wheelDescriptor.

Referenced by retrieveConfigurationFromCDB().

void LampWheel::execute  )  [virtual]
 

Called after initialize to tell the component that it has to be ready to accept incoming functional calls any time.

Must be implemented as a synchronous (blocking) call (can spawn threads though). If this method is overwritten in a chain of subclasses, the developer might need to make sure that all activities performed by the implementation of the base class take place. Check the documentation of direct parent class to know if this is necessary (and do not forget to document each class for the need to chain lifecycle methods in subclasses). The best way to do this is to call the implementation of the base itself explicitly, as would be done implicitly in a constructor chain. In this class the default implementation only sets the state of the component to acscomponent::ACS::COMPSTATE_OPERATIONAL

Returns:
void
Exceptions:
ACSErr::ACSbaseExImpl  *

*
Definition at line 342 of file acsexmplLampWheelImpl.cpp.

References m_lampWheelConfiguration, and retrieveConfigurationFromCDB().

void LampWheel::initialize  )  [virtual]
 

Called to give the component time to initialize itself.

For instance, the component could retrieve connections, read in configuration files/parameters, build up in-memory tables, ... Called before execute. In fact, this method might be called quite some time before functional requests can be sent to the component. Must be implemented as a synchronous (blocking) call. If this method is overwritten in a chain of subclasses, the developer has to make sure that all initialisations performed by the implementation of the base class take place. Check the documentation of direct parent class to know if this is necessary (and do not forget to document each class for the need to chain lifecycle methods in subclasses). If necessary, the best way to do this is to call the implementation of the base itself explicitly, as would be done implicitly in a constructor chain. In this class the default implementation only sets the state of the component first to acscomponent::ACS::COMPSTATE_INITIALIZING and then to acscomponent::ACS::COMPSTATE_INITIALIZED.

Returns:
void
Exceptions:
ACSErr::ACSbaseExImpl  *

*
Definition at line 277 of file acsexmplLampWheelImpl.cpp.

References m_desc_sp, m_fullName, m_position_sp, and m_slots_sp.

ActionRequest LampWheel::invokeAction int  function,
baci::BACIComponent *  cob_p,
const int &  callbackID,
const CBDescIn &  descIn,
baci::BACIValue *  value_p,
Completion &  completion,
CBDescOut &  descOut
[virtual]
 

Action dispatcher function This function is called whenever an asynchronous request has to be handled.

It receives (as parameters) the description of the function and selects the proper implementation to call.

Parameters:
function Action funtion to be invoked.
cob Owner of the action.
callbackID ID of the callback to be notified.
descIn Callback descriptor (passed by client).
value Action data (e.g. value to be set).
completion Error handing structure.
descOut Callback descriptor which will be passed to client.
Returns:
Request to be performed by BACI
  • reqNone - Do nothing (action will be kept in queue).
  • reqInvokeWorking - Invoke <type>Callback::working.
  • reqInvokeDone - Invoke <type>Callback::done and destroy callback.
  • reqDestroy - Destroy callback (callback should have been called already by function).


Definition at line 368 of file acsexmplLampWheelImpl.cpp.

References MOVE_ACTION, and moveAction().

void LampWheel::move CORBA::Short  ,
ACS::CBvoid_ptr  ,
const ACS::CBDescIn & 
[virtual]
 

Move the lamp wheel to a specification slot.

The position of the slot is read from the database Implementation of IDL move(...) interface. The actual action will be invoked asyncronously by the asynchonous call manager by calling LampWhell::moveAction The given callback is used to inform the caller when the action is performed.

Parameters:
n The number of the slot to move to
callBack Callback when action has finished.
desc Callback used for holding information on timeout periods.

Definition at line 453 of file acsexmplLampWheelImpl.cpp.

References MOVE_ACTION.

ActionRequest LampWheel::moveAction baci::BACIComponent *  cob_p,
const int &  callbackID,
const CBDescIn &  descIn,
baci::BACIValue *  value_p,
Completion &  completion,
CBDescOut &  descOut
[virtual]
 

Implementation of asynchrnous acsexmplLamp::Lamp::off() method This is the function that actually switches off the Lamp and, when completed, invokes the callback installed by the client when it requested the action.

Parameters:
cob Owner of the action.
callbackID ID of the callback to be notified.
descIn Callback descriptor (passed by client).
value Action data (e.g. value to be set).
completion Error handing structure.
descOut Callback descriptor which will be passed to client.
Returns:
Request to be performed by BACI.
  • reqNone - Do nothing (action will be kept in queue).
  • reqInvokeWorking - Invoke <type>Callback::working.
  • reqInvokeDone - Invoke <type>Callback::done and destroy callback.
  • reqDestroy - Destroy callback (callback should has been called already by function).


Definition at line 398 of file acsexmplLampWheelImpl.cpp.

References m_lampWheelConfiguration, and m_position_sp.

Referenced by invokeAction().

void LampWheel::operator= const LampWheel  )  [private]
 

ALMA C++ coding standards state copy operators should be disabled.

ACS::ROdouble_ptr LampWheel::position  )  [virtual]
 

Returns a reference to the position property Implementation of IDL interface for the property.



Definition at line 463 of file acsexmplLampWheelImpl.cpp.

References m_position_sp.

int LampWheel::retrieveConfigurationFromCDB std::list< SlotDescriptor > &  config  )  [private]
 

Read the CDB and fill the list with the actual configuration of each slot.

Parameters:
config The list describing the configuration
Returns:
The number of slots found in the CDB
Definition at line 113 of file acsexmplLampWheelImpl.cpp.

References char_hndl(), end_hndl(), m_fullName, start_hndl(), and ParserStruct::wheelDescriptor.

Referenced by execute().

ACS::ROlong_ptr LampWheel::slots  )  [virtual]
 

Returns a reference to the descavailableSlots property Implementation of IDL interface for the property.



Definition at line 487 of file acsexmplLampWheelImpl.cpp.

References m_slots_sp.

void LampWheel::start_hndl void *  data,
const XML_Char *  el,
const XML_Char **  attr
[static, private]
 

The handler for the start element.

See also:
libexpat documentation for further info
Definition at line 197 of file acsexmplLampWheelImpl.cpp.

References ParserStruct::actualTag, LAMP_TAG, SlotDescriptor::lampName, NO_TAG, SlotDescriptor::num, SlotDescriptor::pos, POS_TAG, SLOT_TAG, ParserStruct::slotDescr, UNDEF_TAG, SlotDescriptor::warmUpTime, SlotDescriptor::watt, WATT_TAG, and WUT_TAG.

Referenced by retrieveConfigurationFromCDB().


Member Data Documentation

baci::SmartPropertyPointer<baci::ROstring> LampWheel::m_desc_sp [private]
 

m_desc_sp is the description of the wheel.

Definition at line 370 of file acsexmplLampWheelImpl.h.

Referenced by desc(), and initialize().

ACE_CString LampWheel::m_fullName [private]
 

Definition at line 359 of file acsexmplLampWheelImpl.h.

Referenced by initialize(), and retrieveConfigurationFromCDB().

std::list<SlotDescriptor> LampWheel::m_lampWheelConfiguration [private]
 

The list of descriptions of each slot of the wheel: it is the configuration of the lampWheel It is built reading the CDB.

Definition at line 383 of file acsexmplLampWheelImpl.h.

Referenced by cleanUp(), execute(), and moveAction().

baci::SmartPropertyPointer<baci::ROdouble> LampWheel::m_position_sp [private]
 

m_position_sp is the position of the wheel.

Definition at line 365 of file acsexmplLampWheelImpl.h.

Referenced by initialize(), moveAction(), and position().

baci::SmartPropertyPointer<baci::ROlong> LampWheel::m_slots_sp [private]
 

m_slots_sp is the number of available slots in the wheel

Definition at line 376 of file acsexmplLampWheelImpl.h.

Referenced by initialize(), and slots().


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