atacamalargemillimeterarray acs training developing python components

13
Atacama Atacama Large Large Millimeter Millimeter Array Array ACS Training Developing Python Components

Upload: imogen-white

Post on 04-Jan-2016

215 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: AtacamaLargeMillimeterArray ACS Training Developing Python Components

AtacamaAtacamaLargeLargeMillimeterMillimeterArrayArray

ACS Training

Developing Python Components

Page 2: AtacamaLargeMillimeterArray 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

Page 3: AtacamaLargeMillimeterArray ACS Training Developing Python Components

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

Page 4: AtacamaLargeMillimeterArray ACS Training Developing Python Components

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

Page 5: AtacamaLargeMillimeterArray ACS Training Developing Python Components

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!")

Page 6: AtacamaLargeMillimeterArray ACS Training Developing Python Components

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..."

Page 7: AtacamaLargeMillimeterArray ACS Training Developing Python Components

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.

Page 8: AtacamaLargeMillimeterArray ACS Training Developing Python Components

NRAO - Socorro, July, 2004 ACS Training 8

What methods does ContainerServices have?

Too many to cover in the short time given for

this presentation!

Page 9: AtacamaLargeMillimeterArray ACS Training Developing Python Components

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.

Page 10: AtacamaLargeMillimeterArray ACS Training Developing Python Components

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.

Page 11: AtacamaLargeMillimeterArray ACS Training Developing Python Components

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

Page 12: AtacamaLargeMillimeterArray ACS Training Developing Python Components

NRAO - Socorro, July, 2004 ACS Training 12

Questions about Python Servants???

Page 13: AtacamaLargeMillimeterArray ACS Training Developing Python Components

NRAO - Socorro, July, 2004 ACS Training 13

Demo