ACS Training
-
Upload
imani-watson -
Category
Documents
-
view
18 -
download
0
description
Transcript of ACS Training
AtacamaAtacamaLargeLargeMillimeterMillimeterArrayArray
ACS Training
Developing Python Components
NRAO - Socorro, July, 2004 ACS Training 2
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
NRAO - Socorro, July, 2004 ACS Training 3
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
Py CORBA StubsACSCOURSE_MOUNT__POA
Developer
ACSCOURSE_MOUNTImpl/Mount1.py
NRAO - Socorro, July, 2004 ACS Training 4
Example (continued)
#--CORBA STUBS--------------------------------------------------------import ACSCOURSE_MOUNT__POA#--ACS Imports--------------------------------------------------------from Acspy.Servants.ContainerServices import ContainerServicesfrom Acspy.Servants.ComponentLifecycle import ComponentLifecyclefrom 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
NRAO - Socorro, July, 2004 ACS Training 5
Example (continued)
#------------------------------------------------------------
#--Override ComponentLifecycle methods----------------------- #------------------------------------------------------------ def initialize(self): ''' Override this method inherited from ComponentLifecycle ''' self.getLogger().logInfo("Not much to see here!")
NRAO - Socorro, July, 2004 ACS Training 6
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..."
NRAO - Socorro, July, 2004 ACS Training 7
What methods does ACSComponent have?
In general, many methods are provided but
only a couple should ever be invoked by your
code.
NRAO - Socorro, July, 2004 ACS Training 8
What methods does ContainerServices have?
Too many to cover in the short time given for
this presentation!
NRAO - Socorro, July, 2004 ACS Training 9
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.
NRAO - Socorro, July, 2004 ACS Training 10
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.
NRAO - Socorro, July, 2004 ACS Training 11
CDB entry
< _ Name="MOUNT_PY_1“
Code="ACSCOURSE_MOUNTImpl.Mount1"
Type="IDL:alma/ACSCOURSE_MOUNT/Mount1:1.0"
Container="mountPython"
/>
Package.module
NRAO - Socorro, July, 2004 ACS Training 12
Questions about Python Servants???
NRAO - Socorro, July, 2004 ACS Training 13
Demo