ChimeraTK-ApplicationCore 04.06.00
Loading...
Searching...
No Matches
testPythonSimpleApp.py
Go to the documentation of this file.
1#!/usr/bin/python3
2
3import sys
4import os
5import os.path
6import time
7
8# fmt: off
9# Hack to insert the python path for the locally compiled module in the
10# test script
11sys.path.insert(0, os.path.abspath(os.path.join(os.curdir, "..")))
12import PyApplicationCore # NOQA
13# fmt: on
14
15class MyMod(PyApplicationCore.ApplicationModule) :
16
17 def __init__(self, owner, name, description) :
18 super().__init__(owner, name, description)
19 # can we do this somehow in the class definition instead of the constructor body?
20 self.myOutput = PyApplicationCore.ScalarOutput(PyApplicationCore.DataType.float32, self, "/Var1" ,"unit", "description")
21 self.myInput = PyApplicationCore.ScalarPushInput(PyApplicationCore.DataType.int32, self, "/Var2","unit", "description")
22
23 def mainLoop(self) :
24 val = 0
25 while True:
26 self.myOutput.setAndWrite(val + 0.5)
27 val = self.myInput.readAndGet()
28
29
30# create instance of test module
31PyApplicationCore.app.myMod = MyMod(PyApplicationCore.app, "SomeName", "Description")
32
33# Show that getting the appConfig also works on module level
34c = PyApplicationCore.appConfig()
35tickers = []
36
37# And have an example for passing on a default value
38for t in range(0, c.get(PyApplicationCore.DataType.uint32, "numberOfTickers", 0)):
39 tickers.append(Foo(f"Ticker{t}", "A Ticker module"))
__init__(self, owner, name, description)
void mainLoop() override