pythonModule.py
script is responsible for the Services subscription in the Python environmentpythonUtils.py
script is an utility script usable by the user Python scriptpythonModule
element. For example:<pythonModule name="FlightManagementSystem">
pythonImplementation
element declares the Python script file which implements the script, and specifies the associated properties.<pythonModule name="FlightManagementSystem" > <pythonImplementation protocol="tcp" path="pythonAppli" inputSize="1024" outputSize="5000"/> </pythonModule>Another example, where available free local ports are used for
inputPort
and outputPort
, and 1024 is used for both inputSize
and outputSize
:<pythonModule name="FlightManagementSystem" > <pythonImplementation protocol="tcp" path="pythonAppli" /> </pythonModule>
pythonModule.py
and pythonUtils.py
scripts must change when the communication between Java and Python is upgraded.pythonModule.py
script check if its own version is compatible with the version proviced by Java. This means that you normally should replace the pythonModule.py
and pythonUtils.py
scripts if the Python modules version changes.
pythonModule.py
scriptpythonUtils.py
scriptFlightManagementSystem
module:position
publish servicedirectTo
event servicecomputeFlightPlan
request-response service<pythonModule name="FlightManagementSystem" > <pythonImplementation protocol="tcp" path="pythonAppli"/> <interfaces> <subscribe service="position" /> <eventReceived service="directTo"/> <requestReceived service="computeFlightPlan"/> </interfaces> </pythonModule>Another way to specify the Python module is to explictly specify the ports and port sizes for the Java / Python communication:
<pythonModule name="FlightManagementSystem" > <pythonImplementation protocol="tcp" path="pythonAppli" inputPort="6000" outputPort="6005" inputSize="1024" outputSize="1024"/> <interfaces> <subscribe service="position" /> <eventReceived service="directTo"/> <requestReceived service="computeFlightPlan"/> </interfaces> </pythonModule>
from pythonUtils import PythonUtils class PythonAppli: def subscribe(self, pythonUtils, serviceName): service = pythonUtils.getService(serviceName) if serviceName == "position": // get position ... elif serviceName == "directTo": // compute directTo ... elif serviceName == "computeFlightPlan": // compute FlightPlan and sends the response ...
Copyright 2017-2020 Dassault Aviation. All Rights Reserved. Documentation and source under the LGPL v3 licence