Presentation is loading. Please wait.

Presentation is loading. Please wait.

AtacamaLargeMillimeterArray ACS Training Developing Python Components.

Similar presentations


Presentation on theme: "AtacamaLargeMillimeterArray ACS Training Developing Python Components."— Presentation transcript:

1 AtacamaLargeMillimeterArray ACS Training Developing Python Components

2 NRAO - Socorro, July, 2004ACS Training2 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

3 NRAO - Socorro, July, 2004ACS Training3 Example #ifndef _ACSCOURSE_MOUNT_IDL_ #define _ACSCOURSE_MOUNT_IDL_ #include /* */ #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 Py CORBA Stubs ACSCOURSE_MOUNT__POA Developer ACSCOURSE_MOUNTImpl/Mount1.py

4 NRAO - Socorro, July, 2004ACS Training4 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

5 NRAO - Socorro, July, 2004ACS Training5 Example (continued) #------------------------------------------------------------ #--Override ComponentLifecycle methods----------------------- #------------------------------------------------------------ def initialize(self): ''' Override this method inherited from ComponentLifecycle ''' self.getLogger().logInfo("Not much to see here!")

6 NRAO - Socorro, July, 2004ACS Training6 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..."

7 NRAO - Socorro, July, 2004ACS Training7 What methods does ACSComponent have? In general, many methods are provided but only a couple should ever be invoked by yourcouple code.

8 NRAO - Socorro, July, 2004ACS Training8 What methods does ContainerServices have? Too manyToo many to cover in the short time given for this presentation!

9 NRAO - Socorro, July, 2004ACS Training9 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.here

10 NRAO - Socorro, July, 2004ACS Training10 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.

11 NRAO - Socorro, July, 2004ACS Training11 CDB entry <_ Name="MOUNT_PY_1“ Code="ACSCOURSE_MOUNTImpl.Mount1" Type="IDL:alma/ACSCOURSE_MOUNT/Mount1:1.0" Container="mountPython" /> Package.module

12 NRAO - Socorro, July, 2004ACS Training12 Questions about Python Servants???

13 NRAO - Socorro, July, 2004ACS Training13 Demo


Download ppt "AtacamaLargeMillimeterArray ACS Training Developing Python Components."

Similar presentations


Ads by Google