1 / 13

ACS Training

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.

Télécharger la présentation

ACS Training

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ACS Training Developing Python Components

  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 ACS Training

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

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

  5. Example (continued) #------------------------------------------------------------ #--Override ComponentLifecycle methods----------------------- #------------------------------------------------------------ def initialize(self): ''' Override this method inherited from ComponentLifecycle ''' self.getLogger().logInfo("Not much to see here!") 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..." 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. ACS Training

  8. What methods does ContainerServices have? Too many to cover in the short time given for this presentation! 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. 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. ACS Training

  11. Package.module CDB entry < _ Name="MOUNT_PY_1“ Code="ACSCOURSE_MOUNTImpl.Mount1" Type="IDL:alma/ACSCOURSE_MOUNT/Mount1:1.0" Container="mountPython" /> ACS Training

  12. Questions about Python Servants??? ACS Training

  13. Demo ACS Training

More Related