ALMA Computing Group

FridgeControl Class Reference
[ACS Components Examples]

FridgeControl shows BACI threads as well as a notification channel supplier. More...

#include <acsexmplFridgeImpl.h>

Collaboration diagram for FridgeControl:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 FridgeControl (const ACE_CString &name, maci::ContainerServices *containerServices)
 Constructor.
virtual ~FridgeControl ()
 Destructor.
virtual void cleanUp ()
 Called after the last functional call to the component has finished.
void updateTemperature ()
 Updates the temperature from the physical device.
virtual void on ()
 Turn on the fridge.
virtual void off ()
 Turn off the fridge.
virtual void open ()
 Open the door.
virtual void close ()
 Close the door.
virtual ACS::RWdouble_ptr refTemperature ()
 Property refTemperature is like a thermostat for the fridge.
virtual FRIDGE::ROOnOffStates_ptr powerStatus ()
 Property powerStatus shows whether the power is on or off.
virtual FRIDGE::ROOpClStates_ptr doorStatus ()
 Property doorStatus shows the position of the door.
virtual ACS::ROdouble_ptr currTemperature ()
 Property currTemperature shows the fridge's actual temperature.

Private Member Functions

virtual void loadData ()
 Converts this devices useful data into a temperatureDataBlockEvent structure and then publishes that onto an event channel.
void operator= (const FridgeControl &)
 ALMA C++ coding standards state copy operators should be disabled.

Private Attributes

baci::SmartPropertyPointer<
baci::RWdouble > 
m_refTemperature_sp
 m_refTemperature_sp is the temperature we want the fridge to be.
baci::SmartPropertyPointer<
ROEnumImpl< ACS_ENUM_T(FRIDGE::OnOffStates),
POA_FRIDGE::ROOnOffStates > 
m_powerStatus_sp )
 The fridge can be either turned on or off.
baci::SmartPropertyPointer<
ROEnumImpl< ACS_ENUM_T(FRIDGE::OpClStates),
POA_FRIDGE::ROOpClStates > 
m_doorStatus_sp )
 The fridge's door can be either opened or closed.
baci::SmartPropertyPointer<
baci::ROdouble > 
m_currTemperature_sp
 m_currTemperature_p is the temperature the fridge actually is.
FridgeThreadm_controlLoop_p
 m_controlLoop_p is only started once the fridge has been turned on().
nc::SimpleSupplier * m_FridgeSupplier_p
 This is the Supplier derived class used to publish data to the event channel.

Detailed Description

FridgeControl shows BACI threads as well as a notification channel supplier.

The class FridgeControl simulates the behaviour of a fridge. It provides four synchronous methods: on, off, open, and close. It also provides the properties: refTemperature, powerStatus, doorStatus, and currTemperature. powerStatus and doorStatus are both enums. Finally, FridgeControl is also a Supplier for the "fridge" notification channel.

Author:
Matej Sekoranja, Jozef Stefan Institute, Slovenia
Version:
"@(#) $Id: acsexmplFridgeImpl.h,v 1.115 2008/10/01 04:30:47 cparedes Exp $"

Definition at line 152 of file acsexmplFridgeImpl.h.


Constructor & Destructor Documentation

FridgeControl::FridgeControl 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 103 of file acsexmplFridgeImpl.cpp.

References m_FridgeSupplier_p.

FridgeControl::~FridgeControl  )  [virtual]
 

Destructor.

Definition at line 122 of file acsexmplFridgeImpl.cpp.

References m_controlLoop_p.


Member Function Documentation

void FridgeControl::cleanUp  )  [virtual]
 

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

The component should then orderly release resources etc.

As required by the CharacteristicComponentImpl class, I call explicitly the cleanUp() of the parent class. This makes sure that all threads are stopped and the Component's state set. Depending on what resources are used by a class implementing a Component and by the implementation of the parent class (if it does not inherit directly from acscomponent::ACSComponentImpl or baci:: CharacteristicComponentImpl) it might be necessary to call the cleanuUp() method of the base class AFTER having released resources allocated by the current class. This is demonstrated in this example where we want to make sure that the powerStatus is FRIDGE::OFF before letting the cleanUp() of the base class stopping all the threads, including the one that regulates the temperature. For an example where the cleanUp() of the parent class is called before any other step, see the Building class. Always check the documentation of the parent class and consider what resources are allocated by this class to extablish the requirements for the execution of lifecycle chained methods.

Returns:
void

Definition at line 136 of file acsexmplFridgeImpl.cpp.

References m_controlLoop_p, m_FridgeSupplier_p, off(), and powerStatus().

void FridgeControl::close  )  [virtual]
 

Close the door.

Returns:
void

Definition at line 265 of file acsexmplFridgeImpl.cpp.

References m_doorStatus_sp.

ACS::ROdouble_ptr FridgeControl::currTemperature  )  [virtual]
 

Property currTemperature shows the fridge's actual temperature.

Returns:
Reference to the BACI property

Definition at line 311 of file acsexmplFridgeImpl.cpp.

References m_currTemperature_sp.

Referenced by loadData().

FRIDGE::ROOpClStates_ptr FridgeControl::doorStatus  )  [virtual]
 

Property doorStatus shows the position of the door.

Returns:
Reference to the BACI property

Definition at line 299 of file acsexmplFridgeImpl.cpp.

References m_doorStatus_sp.

void FridgeControl::loadData  )  [private, virtual]
 

Converts this devices useful data into a temperatureDataBlockEvent structure and then publishes that onto an event channel.

Returns:
void

Definition at line 323 of file acsexmplFridgeImpl.cpp.

References FRIDGE::temperatureDataBlockEvent::absoluteDiff, currTemperature(), m_FridgeSupplier_p, refTemperature(), and FRIDGE::temperatureDataBlockEvent::status.

Referenced by updateTemperature().

void FridgeControl::off  )  [virtual]
 

Turn off the fridge.

Returns:
void

Definition at line 240 of file acsexmplFridgeImpl.cpp.

References m_controlLoop_p, and m_powerStatus_sp.

Referenced by cleanUp().

void FridgeControl::on  )  [virtual]
 

Turn on the fridge.

Returns:
void

Definition at line 217 of file acsexmplFridgeImpl.cpp.

References m_controlLoop_p, and m_powerStatus_sp.

void FridgeControl::open  )  [virtual]
 

Open the door.

Returns:
void

Definition at line 255 of file acsexmplFridgeImpl.cpp.

References m_doorStatus_sp.

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

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

FRIDGE::ROOnOffStates_ptr FridgeControl::powerStatus  )  [virtual]
 

Property powerStatus shows whether the power is on or off.

Returns:
Reference to the BACI property

Definition at line 287 of file acsexmplFridgeImpl.cpp.

References m_powerStatus_sp.

Referenced by cleanUp().

ACS::RWdouble_ptr FridgeControl::refTemperature  )  [virtual]
 

Property refTemperature is like a thermostat for the fridge.

Returns:
Reference to the BACI property

Definition at line 275 of file acsexmplFridgeImpl.cpp.

References m_refTemperature_sp.

Referenced by loadData().

void FridgeControl::updateTemperature  ) 
 

Updates the temperature from the physical device.

Returns:
void

Definition at line 181 of file acsexmplFridgeImpl.cpp.

References loadData(), LOCAL_LOGGING_LEVEL, m_currTemperature_sp, and m_refTemperature_sp.


Member Data Documentation

FridgeThread* FridgeControl::m_controlLoop_p [private]
 

m_controlLoop_p is only started once the fridge has been turned on().

This thread is used to simulate the fridge's temperature trying to reach equillibrium with the reference temperature. Once the fridge has been turned off(), this thread is suspended. Definition at line 337 of file acsexmplFridgeImpl.h.

Referenced by cleanUp(), off(), on(), and ~FridgeControl().

baci::SmartPropertyPointer<baci::ROdouble> FridgeControl::m_currTemperature_sp [private]
 

m_currTemperature_p is the temperature the fridge actually is.

Definition at line 329 of file acsexmplFridgeImpl.h.

Referenced by currTemperature(), and updateTemperature().

baci::SmartPropertyPointer< ROEnumImpl<ACS_ENUM_T(FRIDGE::OpClStates), POA_FRIDGE::ROOpClStates> FridgeControl::m_doorStatus_sp) [private]
 

The fridge's door can be either opened or closed.

Definition at line 324 of file acsexmplFridgeImpl.h.

Referenced by close(), doorStatus(), and open().

nc::SimpleSupplier* FridgeControl::m_FridgeSupplier_p [private]
 

This is the Supplier derived class used to publish data to the event channel.

Definition at line 342 of file acsexmplFridgeImpl.h.

Referenced by cleanUp(), FridgeControl(), and loadData().

baci::SmartPropertyPointer<ROEnumImpl< ACS_ENUM_T(FRIDGE::OnOffStates), POA_FRIDGE::ROOnOffStates> FridgeControl::m_powerStatus_sp) [private]
 

The fridge can be either turned on or off.

Definition at line 317 of file acsexmplFridgeImpl.h.

Referenced by off(), on(), and powerStatus().

baci::SmartPropertyPointer<baci::RWdouble> FridgeControl::m_refTemperature_sp [private]
 

m_refTemperature_sp is the temperature we want the fridge to be.

Definition at line 310 of file acsexmplFridgeImpl.h.

Referenced by refTemperature(), and updateTemperature().


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