summaryrefslogtreecommitdiffstats
path: root/xml/test_pywrap
diff options
context:
space:
mode:
Diffstat (limited to 'xml/test_pywrap')
-rw-r--r--xml/test_pywrap/camera.xml4
-rw-r--r--xml/test_pywrap/props.xml5
-rw-r--r--xml/test_pywrap/test_prop_mt.py20
3 files changed, 28 insertions, 1 deletions
diff --git a/xml/test_pywrap/camera.xml b/xml/test_pywrap/camera.xml
index 4b31209..2018ae0 100644
--- a/xml/test_pywrap/camera.xml
+++ b/xml/test_pywrap/camera.xml
@@ -1,6 +1,8 @@
<?xml version="1.0"?>
<model xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<bank bar="0" size="0x0200" protocol="software_registers" read_address="0x9000" write_address="0x9000" word_size="32" endianess="little" format="0x%lx" name="fpga" description="IPECamera Registers">
- <register address="0x00" offset="0" size="32" default="0" rwmask="0" mode="RW" name="reg1"/>
+ <register address="0x00" offset="0" size="32" default="0" rwmask="0" mode="RW" name="reg1">
+ <field offset="0" size="16" mode="RW" name="sensor_temperature" min="5" max="15"><view view="formuu1"/><view view="formuu2"/><view view="enumm2"/></field>
+ </register>
</bank>
</model>
diff --git a/xml/test_pywrap/props.xml b/xml/test_pywrap/props.xml
index 0d0078b..dae83f9 100644
--- a/xml/test_pywrap/props.xml
+++ b/xml/test_pywrap/props.xml
@@ -16,4 +16,9 @@
unit="C"
script="test_prop3.py"
description="test python script #2"/>
+ <transform path="/test/prop_mt"
+ register="test_prop_mt"
+ unit="C"
+ script="test_prop_mt.py"
+ description="Example of thread safe python property"/>
</model>
diff --git a/xml/test_pywrap/test_prop_mt.py b/xml/test_pywrap/test_prop_mt.py
new file mode 100644
index 0000000..53ea797
--- /dev/null
+++ b/xml/test_pywrap/test_prop_mt.py
@@ -0,0 +1,20 @@
+import time
+import threading
+lock = threading.Lock()
+
+def read_from_register(ctx, value):
+ with lock:
+ ctx.lock('lock1')
+ cur = read_from_register.counter
+ read_from_register.counter += 1
+ for i in range (0, 5):
+ time.sleep(0.1)
+ print cur
+ out = ctx.get_property('/test/prop3') / 2
+ ctx.unlock('lock1')
+ return out
+read_from_register.counter = 0
+
+def write_to_register(ctx, value):
+ with lock:
+ ctx.set_property(value*2, '/test/prop3')