ChimeraTK-ApplicationCore 04.08.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
15
16class MyMod(PyApplicationCore.ApplicationModule):
17
18 def __init__(self, owner, name, description):
19 super().__init__(owner, name, description)
20 # can we do this somehow in the class definition instead of the constructor body?
21 self.myOutput = PyApplicationCore.ScalarOutput(
22 PyApplicationCore.DataType.float32, self, "/Var1", "unit", "description")
23 self.myInput = PyApplicationCore.ScalarPushInput(
24 PyApplicationCore.DataType.int32, self, "/Var2", "unit", "description")
25
26 def mainLoop(self):
27 val = 0
28 while True:
29 self.myOutput.setAndWrite(val + 0.5)
30 val = self.myInput.readAndGet()
31
32
33# create instance of test module
34PyApplicationCore.app.myMod = MyMod(PyApplicationCore.app, "SomeName", "Description")
35
36# Show that getting the appConfig also works on module level
37c = PyApplicationCore.appConfig()
38tickers = []
39
40# And have an example for passing on a default value
41for t in range(0, c.get(PyApplicationCore.DataType.uint32, "numberOfTickers", 0)):
42 tickers.append(Foo(f"Ticker{t}", "A Ticker module"))
__init__(self, owner, name, description)
void mainLoop() override