Home
Categories
Dictionary
Glossary
Download
Project Details
Changes Log
What Links Here
FAQ
License

Python modules service interface



This article explains how to interface with services in the Python socket modules implementation.

Python http modules notifications do not work as for regular Python socket modules because these modules use http requests, which means that they need to send a GET request to receive a notification from a service. See Python http modules service interface for more information.

Entry points

Being notified from a Service is performed through an entry point method which is called by the framework. The method will be called each time the module is notified from the reception of the Service.

For example, in the following case, the receive(ServiceInstance service) method will be called each time the module is notified from the position service:
      <applications>
         <application name="application">
            <modules>
               <pythonModule name="FMS">
                  <pythonImplementation path="pythonAppli">
                     <initEntryPoint method="init" />
                     <defaultReceiveEntryPoint method="receive" />
                  <pythonImplementation>
                  <interfaces>
                     <subscribe service="position" />
                  </interfaces>
               </pythonModule>
            </modules>
         </application>
      </applications>
Also, if a publish Service is called cyclically by the framework, the service entry point will be called each time the service is automatically invoked by the framework.

      <applications>
         <application name="application">
            <modules>
               <pythonModule name="Aircraft">
                  <pythonImplementation path="pythonAppli">
                     <initEntryPoint method="init" />
                     <defaultReceiveEntryPoint method="receive" />
                  <pythonImplementation>
                  <interfaces>
                     <cyclic service="position" frequency="200ms "/>
                  </interfaces>
               </pythonModule>
            </modules>
         </application>
      </applications>

Getting a specific service

When taking into account only the Service name:
      def subscribe(self, pythonUtils, serviceName) {
        if serviceName == "myService":
          ...
      }

Getting a data

Getting the service of a specified name is performed with:
      service = pythonUtils.getService(serviceName)
Getting the value of a Data for a Service is performed with:
      dataValue = service[<data_name>]

Invoking a Service

Invoking a Service is performed with:

For example:
      # getting the service of a specified name
      publishService = pythonUtils.getService("<service_name>")
      # set the value for a data
      pythonUtils.setValue(publishService, "<data_name>", value)
      # invoke the service
      pythonUtils.send("<service_name>")

See also


Categories: concepts | development | python

Copyright 2017-2020 Dassault Aviation. All Rights Reserved. Documentation and source under the LGPL v3 licence