eventReceived
, requestSend
and subscribe
notificationseventSend
, requestReceived
and push
invocationsnotify(self, name, instanceId=0)
and invoke(self, name)
calls are not blocking because the response of the http request is sent back to the Python script as soon as the request has been received, which means that the flow of the Python script will continue even if there is still code to execute in other modules.blocking
optional attribute can be set to specify that the Python script must wait after the notify(self, name, instanceId=0)
call that the response is received from the frameworkwaitFor
optional element child can be set to specify that the Python script must wait after the notify(self, name, instanceId=0)
call that the the service specified in the waitFor
element have been received<interfaces> <eventReceived service="init" blocking="onChange"/> <eventReceived service="tick" blocking="onChange"> <waitFor service="init" type="onlyOnce" /> </eventReceived> </interfaces>
blocking
optional attribute can be set to specify that the Python script must wait after the invoke(self, name)
call that the response is received from the frameworkwaitFor
optional element child can be set to specify that the Python script must wait after the invoke(self, name)
call that the the service specified in the waitFor
element have been received<interfaces> <eventReceived service="init" blocking="onChange"/> <eventSend service="tick" blocking="onChange"> <waitFor service="init" type="onlyOnce" /> <eventSend> </interfaces>
blocking
optional attribute for a service has the following values:false
(the default value): the call is not blockingtrue
or default
: the call is blocking. The flow of the Python script execution will be blocked until the service has been received. For this state of the parameter, it will consider that the service has been received at the start of the frameworkonChange
: the call is blocking. The flow of the Python script execution will be blocked until the service has been received. For this state of the parameter, it will consider that the service has not been received at the start of the framework<interfaces> <lt;eventReceived service="tick" blocking="onChange" /> </interfaces>
waitFor
optional element has a type
attribute which has the following values:onlyOnce
(the default value): the flow of the Python script execution will be blocked until the waitFor
service has been received. For this state of the parameter, as soon as the waitFor
service has been received once, the flow of the Python script execution will not be any more blockedonChange
: the flow of the Python script execution will be blocked until the waitFor
service has been received. For this state of the parameter, the waitFor
service must be received each time after the call to unlock the block<interfaces> <eventReceived service="init"/> <eventSend service="tick" blocking="onChange"> <waitFor service="init" type="onlyOnce" /> <eventSend> </interfaces>
tick
servicetick
service invocation<pythonHttpModule name="PublishModule" pythonModuleType="http"> <pythonImplementation path="pythonAppli" port="8080"/> <interfaces> <eventReceived service="tick"/> </interfaces> </pythonHttpModule>We have this code for the Python script:
from pythonHttpUtils import PythonHttpUtils class PythonAppli: step = 1 def start(self): while (True): self.pythonHttpUtils.notify("tick") self.pythonHttpUtils.echo(self.step) self.step = self.step + 1By default the loop will execute without waiting for the
tick
service invocation from the userInput
module, which is not what we want. We will see all the steps in a loop even without invoking the tick
service once:blocking
attribute for the tick
service interface:<pythonHttpModule name="PublishModule" pythonModuleType="http"> <pythonImplementation path="pythonAppli" port="8080"/> <interfaces> <eventReceived service="tick" blocking="onChange"/> </interfaces> </pythonHttpModule>Now the response from the GET http request will be sent back only after the
tick
service has been notified. The result is that we will have only one step per each tick
service invocation: Copyright 2017-2020 Dassault Aviation. All Rights Reserved. Documentation and source under the LGPL v3 licence