Makefile
The Makefile is provided with the module generated from getTemplateForDirectory. In the case of Python server implementation, you need to configure the compilation and installation of a Python Package:
Code Block |
---|
|
PY_PACKAGES:=<PackageName> |
Implementation
The first thing needed to implement a server, is to import the required modules and classes:
Code Block |
---|
language | py |
---|
title | Python Imports |
---|
|
#Client stubs and definitions, such as structs, enums, etc.
import <Module>
#Skeleton infrastructure for server implementation
import <Module>__POA
#Base component implementation
from Acspy.Servants.ACSComponent import ACSComponent
#Services provided by the container to the component
from Acspy.Servants.ContainerServices import ContainerServices
#Basic component lifecycle (initialize, execute, cleanUp and aboutToAbort methods)
from Acspy.Servants.ComponentLifecycle import ComponentLifecycle
#Error definitions for catching exceptions
import ServiceErr
import <Interface>Err
#Error definitions for creating and raising exceptions
import ServiceErrImpl
import <Interface>ErrImpl |
...
Code Block |
---|
language | py |
---|
title | Python Types Usage |
---|
|
#From IDL <Module>::<EnumName>::READY<VALUE>
<Module>.READY<VALUE>
#From IDL <Module>::<Interface>::<Enumname>::OFFLINE<VALUE>
Observatory<Module>.Service<Interface>.OFFLINE<VALUE> |
To retrieve a component to interact with, simply do the following:
...
Code Block |
---|
language | py |
---|
title | Python Error Handling |
---|
|
#For catching exceptions
except <Interface>Err.<ExceptionName>Ex as e:
#For raising exceptions
raise <Interface>ErrImpl.<ExceptionName>ExImpl().get<ExceptionName>Ex()
#For raising exceptions with parameters
err = <Interface>ErrImpl.<ExceptionName>ExImpl()
err.set<ParamName>(<Value>)
raise err.get<ExceptionName>Ex()
#For logging an error message from the exceptions
err = <Interface>ErrImpl.<ExceptionName>ExImpl()
err.log()
raise err.get<ExceptionName>Ex() |