PublishModule
module increments or decrements a value cyclicallyPublishModule
by setting the factor by using a property.
applications.xml
XML file will be modified to specify an init EntryPoint. We will also define an int property for the factor.
<properties> <application name="publishAppli" > <module name="PublishModule" > <moduleProperty key="factor" value="10" /> </module> </application> </properties>This file must be specified in the filelist configuration:
<files> <file url="applications.xml" /> <file url="services.xml" /> <file url="types.xml" /> <file url="properties.xml" /> <property key="debugScripts" value="true" /> <pythonRuntime path="<my_python_path>/python.exe" /> </files>
applications.xml
XML file, by modifying the PublishModule
configuration:<application name="publishAppli"> <modules> <pythonModule name="PublishModule"> <pythonImplementation path="pythonAppli"> <initEntryPoint method="init" /> <defaultSendEntryPoint method="publish" /> </pythonImplementation> <interfaces> <eventReceived service="event"/> <cyclic service="published" frequency="200ms" attach="attach"/> </interfaces> <properties> <property key="factor" type="int" /> </properties> </pythonModule> </modules> </application>
start
method to set the step.from pythonUtils import PythonUtils class PythonAppli: step = 1 count = 1 factor = 1; def init(self, pythonUtils): self.factor = pythonUtils.getProperty("factor") def subscribe(self, pythonUtils, serviceName): eventService = pythonUtils.getService("event"); eventValue = eventService["event"] if eventValue: self.step = -1 else: self.step = 1 def publish(self, pythonUtils, serviceName): publishService = pythonUtils.getService("published"); pythonUtils.setValue(publishService, "value", self.count) self.count = self.count + self.step * self.factor pythonUtils.send("published")
Copyright 2017-2020 Dassault Aviation. All Rights Reserved. Documentation and source under the LGPL v3 licence