130 likes | 245 Views
ACS Training. Developing Python Components. What’s Available in Python?. Python implementation of the Component IDL interface May implement IDL interfaces derived from ACS::ACSComponent May not implement IDL interfaces derived from ACS::CharacteristicComponent. Py CORBA Stubs.
E N D
ACS Training Developing Python Components
What’s Available in Python? Python implementation of the Component IDL interface • May implement IDL interfaces derived from ACS::ACSComponent • May not implement IDL interfaces derived from ACS::CharacteristicComponent ACS Training
Py CORBA Stubs Developer Example #ifndef _ACSCOURSE_MOUNT_IDL_ #define _ACSCOURSE_MOUNT_IDL_ #include <baci.idl> /* <acscomponent.idl> */ #pragma prefix "alma" module ACSCOURSE_MOUNT { interface Mount1 : ACS::ACSComponent { /* (Pre)sets a new non-moving position for the antenna. * @param az position azimuth (degree) * @param elev position elevation (degree) */ void objfix (in double az, in double elev); }; }; #endif IDL ACSCOURSE_MOUNTImpl/Mount1.py ACSCOURSE_MOUNT__POA ACS Training
Example (continued) #--CORBA STUBS-------------------------------------------------------- import ACSCOURSE_MOUNT__POA #--ACS Imports-------------------------------------------------------- from Acspy.Servants.ContainerServices import ContainerServices from Acspy.Servants.ComponentLifecycle import ComponentLifecycle from Acspy.Servants.ACSComponent import ACSComponent class Mount1(ACSCOURSE_MOUNT__POA.Mount1, #CORBA stubs for IDL Int. ACSComponent, #Base IDL interface ContainerServices, #Developer niceties ComponentLifecycle): #HLA stuff def __init__(self): '''Just call superclass constructors here.''' ACSComponent.__init__(self) ContainerServices.__init__(self) return ACS Training
Example (continued) #------------------------------------------------------------ #--Override ComponentLifecycle methods----------------------- #------------------------------------------------------------ def initialize(self): ''' Override this method inherited from ComponentLifecycle ''' self.getLogger().logInfo("Not much to see here!") ACS Training
Example (continued) #----------------------------------------------------------------- #--Implementation of IDL methods---------------------------------- #------------------------------------------------------------------ def objfix(self, az, el): '''Python implementation of IDL method''' self.getLogger().logInfo("objfix called with az="+str(az)+ " and el="+str(el)) #---------------------------------------------------------------------- #--Main defined only for generic testing------------------------------- #---------------------------------------------------------------------- if __name__ == "__main__": print "Creating an object" g = Mount1() print "Done..." ACS Training
What methods does ACSComponent have? In general, many methods are provided but only a couple should ever be invoked by your code. ACS Training
What methods does ContainerServices have? Too many to cover in the short time given for this presentation! ACS Training
What methods does ComponentLifecycle have? The same as Java although they’re nicer to work with in Python because we’re not limited to single inheritance. Descriptions of these methods can be found here. ACS Training
Python-related Makefile Targets • PY_SCRIPTS - Specifies Python scripts without the .py extension that will be installed into $INTROOT/bin. • PY_MODULES – Specifies Python modules with the .py extension that will be installed into $INTROOT/lib/python/site-packages. • PY_PACKAGES – Specifies Python packages to be installed into $INTROOT/lib/python/site-packages. Really these are just directories containing Python scripts. ACS Training
Package.module CDB entry < _ Name="MOUNT_PY_1“ Code="ACSCOURSE_MOUNTImpl.Mount1" Type="IDL:alma/ACSCOURSE_MOUNT/Mount1:1.0" Container="mountPython" /> ACS Training
Questions about Python Servants??? ACS Training
Demo ACS Training