demoImpl.LampCallback
index
/diska/alma_tmp/ACS/LGPL/CommonSoftware/acspyexmpl/src/demoImpl/LampCallback.py

DESCRIPTION
LampCallback is fairly complicated as far as Python components are concerned.
As its name implies, it creates a callback in the form of a BACI monitor on
one of a <a href="../../idl/html/interfaceacsexmplLamp_1_1Lamp.html">Lamp</a> components
BACI properties.
 
WHAT CAN I GAIN FROM THIS EXAMPLE?
- an example derived from the <a href="../../idl/html/interfaceACS_1_1ACSComponent.html">ACS::ACSComponent</a>
IDL interface.
- using ContainerServices to obtain references to other components.
- utilizing callback helper classes to create BACI monitors.
- synchronously retrieving the values of BACI properties.
- an introduction to the Python ACS Error System API.
- limited ACS logging macros.
 
LINKS
- <a href="classLampCallback_1_1LampCallback.html">Lamp Callback Class Reference</a>
- <a href="../../idl/html/interfacedemo_1_1LampCallback.html">Lamp Callback IDL Documentation</a>

 
Modules
       
ACS
demo
demo__POA

 
Classes
       
Acspy.Servants.ACSComponent.ACSComponent
LampCallback(demo__POA.LampCallback, Acspy.Servants.ACSComponent.ACSComponent, Acspy.Servants.ContainerServices.ContainerServices, Acspy.Servants.ComponentLifecycle.ComponentLifecycle)
Acspy.Servants.ComponentLifecycle.ComponentLifecycle
LampCallback(demo__POA.LampCallback, Acspy.Servants.ACSComponent.ACSComponent, Acspy.Servants.ContainerServices.ContainerServices, Acspy.Servants.ComponentLifecycle.ComponentLifecycle)
Acspy.Servants.ContainerServices.ContainerServices
LampCallback(demo__POA.LampCallback, Acspy.Servants.ACSComponent.ACSComponent, Acspy.Servants.ContainerServices.ContainerServices, Acspy.Servants.ComponentLifecycle.ComponentLifecycle)
demo__POA.LampCallback(ACS__POA.ACSComponent)
LampCallback(demo__POA.LampCallback, Acspy.Servants.ACSComponent.ACSComponent, Acspy.Servants.ContainerServices.ContainerServices, Acspy.Servants.ComponentLifecycle.ComponentLifecycle)

 
class LampCallback(demo__POA.LampCallback, Acspy.Servants.ACSComponent.ACSComponent, Acspy.Servants.ContainerServices.ContainerServices, Acspy.Servants.ComponentLifecycle.ComponentLifecycle)
    Simple component implementation provided as a reference for developers.
 
 
Method resolution order:
LampCallback
demo__POA.LampCallback
ACS__POA.ACSComponent
omniORB.PortableServer.Servant
Acspy.Servants.ACSComponent.ACSComponent
Acspy.Servants.ContainerServices.ContainerServices
Acspy.Servants.ComponentLifecycle.ComponentLifecycle

Methods defined here:
__init__(self)
Just call superclass constructors here and declare members.
acsExceptionMethodDouble(self)
Python implementation of IDL method.
double acsExceptionMethodDouble() raises (ACSErr::ACSException);
acsExceptionMethodVoid(self)
Python implementation of IDL method.
void acsExceptionMethodVoid() raises (ACSErr::ACSException);
cleanUp(self)
Override this method inherited from ComponentLifecycle
exceptionMethod(self)
Python implementation of IDL method.
void exceptionMethod() raises (LampUnavailable);
monitorLampBrightness(self)
Python implementation of IDL method.
double monitorLampBrightness() raises (LampUnavailable);
stopMonitor(self)
Python implementation of IDL method.
void stopMonitor() raises (LampUnavailable);

Methods inherited from Acspy.Servants.ACSComponent.ACSComponent:
setComponentState(self, state)
The developer should feel free to invoke this method.
 
Params: state is quite literally the sate of this component.  It can be
any of the enumerations for ACS::ComponentStates
 
Returns: Nothing.
 
Raises: Nothing.
setName(self, name)
Only the container should invoke this method.
 
Params: name is the name of this component
 
Returns: Nothing.
 
Raises: Nothing.

Methods inherited from Acspy.Servants.ContainerServices.ContainerServices:
activateOffShoot(self, py_obj)
Activates an OffShoot derived object as a CORBA object.
 
Parameters:
- py_obj is (non-CORBA) Python object.
 
Return: a reference to the CORBA object that almost definitely needs to
be narrowed to the correct type.  If anything goes wrong though, returns
None.
 
Raises: ???
availableComponents(self, name_wildcard='*', type_wildcard='*', activated=0)
Returns a list of ComponentInfos consisting of all Components known 
to manager.
 
Parameters:
- name_wildcard is a wildcard that the components name must match in 
order for its information to be returned
- type_wildcard is a wildcard that the components type must match in
order for its information to be returned.
- activated is a boolean value which specifies whether the search 
should be limited to components which have already been activated.
 
Returns: a list consisting of ComponentInfo structures for every
component manager knows of
 
Raises: ???
corbaObjectFromString(self, obj_uri)
Converts a string to a CORBA object reference.
 
Parameters:
- obj_uri is the address to the CORBA object
 
Return: a CORBA reference to obj_uri
 
Raises: ???
corbaObjectToString(self, comp_ref)
Converts a CORBA object its string representation.
 
Parameters: comp_ref is a reference to the CORBA object.
 
Return: the string representation (an IOR)
 
Raises: ???
findComponents(self, curl_wildcard='*', type_wildcard='*', activated=0)
Finds components by their instance name and/or by their type.
 
    Wildcards can be used for the curl and type.
    This method returns a possibly empty array of component curls; 
    for each curl, you may use getComponent to obtain the reference.
 
Parameters:
- name_wildcard (None is understood as "*")
- type_wildcard (None is understood as "*")
- activated is a boolean value which specifies whether the search 
should be limited to components which have already been activated.
 
Return: the curls of the component(s) that match the search.
 
Raises: ???
forceReleaseComponent(self, comp_name)
Forcefully releases the component defined by comp_name.
 
Parameter: comp_name is the name of the component to be released.
 
Returns: The number of objects still attached to the released component
 
Raises: Nothing
getCDBElement(self, record_name, ele_name)
This method returns all of the attributes in the form of a dictionary
for a given XML element within an XML file.
 
Parameters:
- record_name is the name of the XML file (e.g., "alma/MOUNT1")
- ele_name is the name of the element (e.g, "MOUNT/actAz")
- element_name is the name of the element (e.g, "MOUNT/actAz",
  where acsAz is an XML element contianing all attributes
  representing the characteristics of a BACI property).
 
Return: a dictionary
 
Raises: ???
getCDBRecord(self, record_name)
Returns the stringified version of an XML record in the ACS
configuration database defined by record_name.
 
Parameters:
- record_name is the full name of an XML record in the CDB.  An
example would be "alma/MOUNT1".
 
Return: the stringified XML record 
 
Raises: ???
getCollocatedComp(self, comp_spec, mark_as_default, target_comp)
Activation of a component so that it runs in the same process as
another given component.
 
Parameters:
- comp_spec (maci.ComponentSpec) Component to be obtained.
- mark_as_default (bool) Mark component as default component of its type
- target_comp Name of the target component (where to activate component)
 
Returns: a narrowed reference to the component or None if
that reference cannot be obtained.
 
Raises:
- IncompleteComponentSpec
- InvalidComponentSpec
- ComponentSpecIncompatibleWithActiveComponent
getComponent(self, comp_name=None, activate=1, comp_idl_type=None, comp_code=None, container_name=None, is_dynamic=0)
NOTE: all keyword parameters with the exception of comp_name are
deprecated!
 
Get a component reference from the Manager.
 
This seemingly simple method is actually quite complicated. First, its
important to note that this method narrows the reference for the
developer and even imports the proper IDL Python stub. Under certain
circumstances though, the IDL Python stub may NOT exist in the correct
place which has led some developers to believe this method was broken
in the past. So if you see an error message beginning with
"Unable to import...", please check that you really CAN import the
CORBA stubs for the component you are trying to access using the
infamous "python -i" command.
 
The next important thing to realize is this method does not just
retrieve named components as its own name implies - based on the
parameters passed it could return default and dynamic components
also.
 
Parameters:
- name is the components name. If not None and the rest of the
default parameters are left as-is, this is assumed to be a static
component.
- activate tells manager whether the component should be activated
if it has not already been instantiated. Not too useful.
- comp_idl_type is the interface repository IDL location of the
component. If not None and the rest of the default parameters are
left as-is, it is assumed the developer wants a default component.
- comp_code is a shared library implementing component. If not
None, it is assumed the developer wants a dynamic component.
- container_name is the name of the container to activate component.
If not None, it is assumed the developer wants a dynamic component.
- is_dynamic states whether a component should be retrieved as
default or dynamic. In simple terms, when this parameter and
comp_idl_type are the only params that have been changed from their
original values, this is the difference between retrieving a reference
to a dynamic component or a default component.
 
Returns: a narrowed reference to the component or None if
that reference cannot be obtained.
 
Raises: CannotGetComponentExImpl if the component stubs cannot be loaded
        or found
getComponentNonSticky(self, comp_name)
Gets the component in a non stick way.
The comp_name is a name of the component.
 
Parameters:
- comp_name is the name of the component.
 
Returns: a narrowed reference to the component or None if
that reference cannot be obtained.
 
Raises: CannotGetComponentExImpl if the component stubs cannot be loaded
        or found
getContName(self)
Returns our container name.
 
Parameters: None
 
Return: name of the container the component was started by.
 
Raises: Nothing
getDefaultComponent(self, comp_type)
Gets the default component specified by the component type.
The type is the IDL type, such as "IDL:alma/PS/PowerSupply:1.0"
 
Parameters:
- comp_type is the interface repository IDL location of the
component.
 
Returns: a narrowed reference to the component or None if
that reference cannot be obtained.
 
Raises: CannotGetComponentExImpl if the component stubs cannot be loaded
        or found
getDynamicComponent(self, name, comp_type, code, container)
Gets a component whose instance is not registered in the CDB 
at deployment time.
 
Parameters:
- name is the components name in string format
- comp_type is the interface repository IDL location of the component
- code is a shared library implementing component
- container is the name of the container to activate component.
 
Returns: a narrowed reference to the component or None if
that reference cannot be obtained.
 
Raises: CannotGetComponentExImpl if the component stubs cannot be loaded
        or found
getLogger(self)
Returns the component/client logger.
 
Parameters: None
 
Return: a logger
 
Raises: Nothing
getName(self)
Returns our name.
 
Parameters: None
 
Return: name of the component or client derived from ContainerServices.
 
Raises: Nothing
getThread(self, target, name, args=None, kwargs=None)
This method returns a Python threading.Thread object.
 
Parameters:
- target callable object to be invoked by the run() method
- name the thread name. Must be unique
- args is the argument tuple for the target invocation. Defaults to ()
- kwargs is a dictionary of keyword arguments for the target
invocation. Defaults to {}
 
Return: a threading.Thread object
 
Raises: ???
makeCompImmortal(self, comp_name, state)
Change mortality state of a component.
Compnent must be already active.
The caller must be owner of the component or have administator rights.
 
Parameters:
- comp_name name of the component
- state new mortality state
 
Returns: None
 
Raises: ???
releaseComponent(self, comp_name)
Release the component defined by comp_name.
 
Parameter: comp_name is the name of the component to be released.
 
Returns: The number of objects still attached to the released component
 
Raises: Nothing
restartComp(self, comp_name)
Restarts a component.
 
Parameters:
- comp_name name of the component
 
Returns: Reference to the restarted component.
 
Raises: ???
setAll(self, name, token, handle, activate_offshoot_method, contname=None)
This method should only be invoked by the container and provides the
component with all container services. DO NOT INVOKE FROM YOUR CODE!!!

Methods inherited from Acspy.Servants.ComponentLifecycle.ComponentLifecycle:
aboutToAbort(self)
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.
 
Container will catch all exceptions.
 
Params: None.
 
Returns: Nothing.
execute(self)
Called after initialize to tell the component that it has to be ready
to accept incoming functional calls at any time. 
 
Examples:
- last-minute initializations for which initialize seemed too early
- component could start actions which arent triggered by any functional
call, e.g. the Scheduler could start to rank SBs in a separate thread.
 
Must be implemented as a synchronous (blocking) call (can spawn threads
though).
 
Container will catch and log ComponentLifecycleExceptions raised by
this method.
 
Params: None.
 
Returns: Nothing.
initialize(self)
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.
 
Container will catch and log ComponentLifecycleExceptions raised by
this method.
 
Params: None.
 
Returns: Nothing.