summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt20
-rw-r--r--html_server/html_server.py (renamed from pywrap/html_server.py)44
-rw-r--r--html_server/static/check_err.js4
-rw-r--r--html_server/static/codebase/dhtmlx.css (renamed from pywrap/static/codebase/dhtmlx.css)0
-rw-r--r--html_server/static/codebase/dhtmlx.js (renamed from pywrap/static/codebase/dhtmlx.js)0
-rw-r--r--html_server/static/codebase/dhtmlx_deprecated.js (renamed from pywrap/static/codebase/dhtmlx_deprecated.js)0
-rw-r--r--html_server/static/codebase/ext/dhxupload.xap (renamed from pywrap/static/codebase/ext/dhxupload.xap)bin23436 -> 23436 bytes
-rw-r--r--html_server/static/codebase/ext/swfobject.js (renamed from pywrap/static/codebase/ext/swfobject.js)0
-rw-r--r--html_server/static/codebase/ext/uploader.swf (renamed from pywrap/static/codebase/ext/uploader.swf)bin3646 -> 3646 bytes
-rw-r--r--html_server/static/codebase/imgs/dhxtree_skyblue/blank.gif (renamed from pywrap/static/codebase/imgs/dhxtree_skyblue/blank.gif)bin56 -> 56 bytes
-rw-r--r--html_server/static/codebase/imgs/dhxtree_skyblue/but_cut.gif (renamed from pywrap/static/codebase/imgs/dhxtree_skyblue/but_cut.gif)bin87 -> 87 bytes
-rw-r--r--html_server/static/codebase/imgs/dhxtree_skyblue/folderClosed.gif (renamed from pywrap/static/codebase/imgs/dhxtree_skyblue/folderClosed.gif)bin579 -> 579 bytes
-rw-r--r--html_server/static/codebase/imgs/dhxtree_skyblue/folderOpen.gif (renamed from pywrap/static/codebase/imgs/dhxtree_skyblue/folderOpen.gif)bin571 -> 571 bytes
-rw-r--r--html_server/static/codebase/imgs/dhxtree_skyblue/iconCheckAll.gif (renamed from pywrap/static/codebase/imgs/dhxtree_skyblue/iconCheckAll.gif)bin155 -> 155 bytes
-rw-r--r--html_server/static/codebase/imgs/dhxtree_skyblue/iconCheckDis.gif (renamed from pywrap/static/codebase/imgs/dhxtree_skyblue/iconCheckDis.gif)bin155 -> 155 bytes
-rw-r--r--html_server/static/codebase/imgs/dhxtree_skyblue/iconCheckGray.gif (renamed from pywrap/static/codebase/imgs/dhxtree_skyblue/iconCheckGray.gif)bin155 -> 155 bytes
-rw-r--r--html_server/static/codebase/imgs/dhxtree_skyblue/iconUncheckAll.gif (renamed from pywrap/static/codebase/imgs/dhxtree_skyblue/iconUncheckAll.gif)bin92 -> 92 bytes
-rw-r--r--html_server/static/codebase/imgs/dhxtree_skyblue/iconUncheckDis.gif (renamed from pywrap/static/codebase/imgs/dhxtree_skyblue/iconUncheckDis.gif)bin878 -> 878 bytes
-rw-r--r--html_server/static/codebase/imgs/dhxtree_skyblue/leaf.gif (renamed from pywrap/static/codebase/imgs/dhxtree_skyblue/leaf.gif)bin361 -> 361 bytes
-rw-r--r--html_server/static/codebase/imgs/dhxtree_skyblue/line.gif (renamed from pywrap/static/codebase/imgs/dhxtree_skyblue/line.gif)bin79 -> 79 bytes
-rw-r--r--html_server/static/codebase/imgs/dhxtree_skyblue/line1.gif (renamed from pywrap/static/codebase/imgs/dhxtree_skyblue/line1.gif)bin79 -> 79 bytes
-rw-r--r--html_server/static/codebase/imgs/dhxtree_skyblue/line1_rtl.gif (renamed from pywrap/static/codebase/imgs/dhxtree_skyblue/line1_rtl.gif)bin79 -> 79 bytes
-rw-r--r--html_server/static/codebase/imgs/dhxtree_skyblue/line2.gif (renamed from pywrap/static/codebase/imgs/dhxtree_skyblue/line2.gif)bin74 -> 74 bytes
-rw-r--r--html_server/static/codebase/imgs/dhxtree_skyblue/line2_rtl.gif (renamed from pywrap/static/codebase/imgs/dhxtree_skyblue/line2_rtl.gif)bin76 -> 76 bytes
-rw-r--r--html_server/static/codebase/imgs/dhxtree_skyblue/line3.gif (renamed from pywrap/static/codebase/imgs/dhxtree_skyblue/line3.gif)bin81 -> 81 bytes
-rw-r--r--html_server/static/codebase/imgs/dhxtree_skyblue/line3_rtl.gif (renamed from pywrap/static/codebase/imgs/dhxtree_skyblue/line3_rtl.gif)bin81 -> 81 bytes
-rw-r--r--html_server/static/codebase/imgs/dhxtree_skyblue/line4.gif (renamed from pywrap/static/codebase/imgs/dhxtree_skyblue/line4.gif)bin67 -> 67 bytes
-rw-r--r--html_server/static/codebase/imgs/dhxtree_skyblue/line4_rtl.gif (renamed from pywrap/static/codebase/imgs/dhxtree_skyblue/line4_rtl.gif)bin69 -> 69 bytes
-rw-r--r--html_server/static/codebase/imgs/dhxtree_skyblue/lock.gif (renamed from pywrap/static/codebase/imgs/dhxtree_skyblue/lock.gif)bin208 -> 208 bytes
-rw-r--r--html_server/static/codebase/imgs/dhxtree_skyblue/minus.gif (renamed from pywrap/static/codebase/imgs/dhxtree_skyblue/minus.gif)bin107 -> 107 bytes
-rw-r--r--html_server/static/codebase/imgs/dhxtree_skyblue/minus1.gif (renamed from pywrap/static/codebase/imgs/dhxtree_skyblue/minus1.gif)bin107 -> 107 bytes
-rw-r--r--html_server/static/codebase/imgs/dhxtree_skyblue/minus2.gif (renamed from pywrap/static/codebase/imgs/dhxtree_skyblue/minus2.gif)bin119 -> 119 bytes
-rw-r--r--html_server/static/codebase/imgs/dhxtree_skyblue/minus2_rtl.gif (renamed from pywrap/static/codebase/imgs/dhxtree_skyblue/minus2_rtl.gif)bin121 -> 121 bytes
-rw-r--r--html_server/static/codebase/imgs/dhxtree_skyblue/minus3.gif (renamed from pywrap/static/codebase/imgs/dhxtree_skyblue/minus3.gif)bin125 -> 125 bytes
-rw-r--r--html_server/static/codebase/imgs/dhxtree_skyblue/minus3_rtl.gif (renamed from pywrap/static/codebase/imgs/dhxtree_skyblue/minus3_rtl.gif)bin125 -> 125 bytes
-rw-r--r--html_server/static/codebase/imgs/dhxtree_skyblue/minus4.gif (renamed from pywrap/static/codebase/imgs/dhxtree_skyblue/minus4.gif)bin117 -> 117 bytes
-rw-r--r--html_server/static/codebase/imgs/dhxtree_skyblue/minus4_rtl.gif (renamed from pywrap/static/codebase/imgs/dhxtree_skyblue/minus4_rtl.gif)bin117 -> 117 bytes
-rw-r--r--html_server/static/codebase/imgs/dhxtree_skyblue/minus5.gif (renamed from pywrap/static/codebase/imgs/dhxtree_skyblue/minus5.gif)bin111 -> 111 bytes
-rw-r--r--html_server/static/codebase/imgs/dhxtree_skyblue/minus5_rtl.gif (renamed from pywrap/static/codebase/imgs/dhxtree_skyblue/minus5_rtl.gif)bin111 -> 111 bytes
-rw-r--r--html_server/static/codebase/imgs/dhxtree_skyblue/plus.gif (renamed from pywrap/static/codebase/imgs/dhxtree_skyblue/plus.gif)bin111 -> 111 bytes
-rw-r--r--html_server/static/codebase/imgs/dhxtree_skyblue/plus1.gif (renamed from pywrap/static/codebase/imgs/dhxtree_skyblue/plus1.gif)bin111 -> 111 bytes
-rw-r--r--html_server/static/codebase/imgs/dhxtree_skyblue/plus2.gif (renamed from pywrap/static/codebase/imgs/dhxtree_skyblue/plus2.gif)bin123 -> 123 bytes
-rw-r--r--html_server/static/codebase/imgs/dhxtree_skyblue/plus2_rtl.gif (renamed from pywrap/static/codebase/imgs/dhxtree_skyblue/plus2_rtl.gif)bin124 -> 124 bytes
-rw-r--r--html_server/static/codebase/imgs/dhxtree_skyblue/plus3.gif (renamed from pywrap/static/codebase/imgs/dhxtree_skyblue/plus3.gif)bin128 -> 128 bytes
-rw-r--r--html_server/static/codebase/imgs/dhxtree_skyblue/plus3_rtl.gif (renamed from pywrap/static/codebase/imgs/dhxtree_skyblue/plus3_rtl.gif)bin128 -> 128 bytes
-rw-r--r--html_server/static/codebase/imgs/dhxtree_skyblue/plus4.gif (renamed from pywrap/static/codebase/imgs/dhxtree_skyblue/plus4.gif)bin120 -> 120 bytes
-rw-r--r--html_server/static/codebase/imgs/dhxtree_skyblue/plus4_rtl.gif (renamed from pywrap/static/codebase/imgs/dhxtree_skyblue/plus4_rtl.gif)bin119 -> 119 bytes
-rw-r--r--html_server/static/codebase/imgs/dhxtree_skyblue/plus5.gif (renamed from pywrap/static/codebase/imgs/dhxtree_skyblue/plus5.gif)bin114 -> 114 bytes
-rw-r--r--html_server/static/codebase/imgs/dhxtree_skyblue/plus5_rtl.gif (renamed from pywrap/static/codebase/imgs/dhxtree_skyblue/plus5_rtl.gif)bin113 -> 113 bytes
-rw-r--r--html_server/static/codebase/imgs/dhxtree_skyblue/radio_off.gif (renamed from pywrap/static/codebase/imgs/dhxtree_skyblue/radio_off.gif)bin213 -> 213 bytes
-rw-r--r--html_server/static/codebase/imgs/dhxtree_skyblue/radio_on.gif (renamed from pywrap/static/codebase/imgs/dhxtree_skyblue/radio_on.gif)bin223 -> 223 bytes
-rw-r--r--html_server/static/codebase/thirdparty/excanvas/AUTHORS (renamed from pywrap/static/codebase/thirdparty/excanvas/AUTHORS)0
-rw-r--r--html_server/static/codebase/thirdparty/excanvas/COPYING (renamed from pywrap/static/codebase/thirdparty/excanvas/COPYING)0
-rw-r--r--html_server/static/codebase/thirdparty/excanvas/README (renamed from pywrap/static/codebase/thirdparty/excanvas/README)0
-rw-r--r--html_server/static/codebase/thirdparty/excanvas/excanvas.js (renamed from pywrap/static/codebase/thirdparty/excanvas/excanvas.js)0
-rw-r--r--html_server/static/jquery-2.2.1.js (renamed from pywrap/static/jquery-2.2.1.js)0
-rw-r--r--html_server/templates/base.html233
-rw-r--r--html_server/templates/property_info.html91
-rw-r--r--html_server/templates/register_info.html9
-rw-r--r--html_server/templates/registers/table_cell.html100
-rw-r--r--html_server/templates/registers/table_header.html10
-rw-r--r--html_server/templates/registers/table_scripts.html42
-rw-r--r--html_server/templates/registers_list.html12
-rw-r--r--pcilib/py.c242
-rw-r--r--pywrap/CMakeLists.txt9
-rw-r--r--pywrap/pcipywrap.c27
-rw-r--r--pywrap/pcipywrap.h2
-rw-r--r--pywrap/templates/base.html347
-rw-r--r--pywrap/templates/property_info.html91
-rw-r--r--pywrap/templates/register_info.html106
-rw-r--r--pywrap/templates/registers_list.html26
-rw-r--r--pywrap/test_pcipywrap.py4
-rw-r--r--xml/test/cmosis.xml50
-rw-r--r--xml/test/props.xml5
-rw-r--r--xml/test/test_prop_mt.py24
75 files changed, 716 insertions, 782 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ee73a1a..dfbd50a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -41,6 +41,7 @@ if (NOT DISABLE_PYTHON)
find_package(PythonLibs 2.7 REQUIRED)
find_package(SWIG REQUIRED)
set(HAVE_PYTHON TRUE)
+ include(FindPythonInterp)
endif (NOT DISABLE_PYTHON)
set(EXTRA_SYSTEM_LIBS -lrt)
@@ -112,15 +113,16 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/pcilib/version.h.in ${CMAKE_CURRENT_B
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/docs/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/docs/Doxyfile)
if (NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
- file(COPY ${CMAKE_SOURCE_DIR}/xml DESTINATION ${CMAKE_BINARY_DIR})
- file(COPY ${CMAKE_SOURCE_DIR}/pci
- DESTINATION ${CMAKE_BINARY_DIR}
- FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
- )
- file(COPY ${CMAKE_SOURCE_DIR}/run
- DESTINATION ${CMAKE_BINARY_DIR}
- FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
- )
+ file(COPY ${CMAKE_SOURCE_DIR}/xml DESTINATION ${CMAKE_BINARY_DIR})
+ file(COPY ${CMAKE_SOURCE_DIR}/html_server DESTINATION ${CMAKE_BINARY_DIR})
+ file(COPY ${CMAKE_SOURCE_DIR}/pci
+ DESTINATION ${CMAKE_BINARY_DIR}
+ FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
+ )
+ file(COPY ${CMAKE_SOURCE_DIR}/run
+ DESTINATION ${CMAKE_BINARY_DIR}
+ FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
+ )
endif(NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
install(FILES
diff --git a/pywrap/html_server.py b/html_server/html_server.py
index 76d132a..dba24e9 100644
--- a/pywrap/html_server.py
+++ b/html_server/html_server.py
@@ -13,7 +13,7 @@ from flask import send_from_directory
app = Flask(__name__)
pcilib = 0;
device = '/dev/fpga0'
-model = 'test_pywrap'
+model = ''
# property json api
@app.route("/property_info_json")
@@ -113,10 +113,10 @@ def get_register_info():
bank = request.args.get('bank')
reg_info = 0
- value = 0
+ value = dict()
try:
reg_info = pcilib.get_register_info(str(name), str(bank))
- value = pcilib.read_register(str(name), str(bank))
+ value[name] = pcilib.read_register(str(name), str(bank))
except Exception as e:
return str(e)
return render_template('register_info.html',
@@ -125,14 +125,29 @@ def get_register_info():
@app.route("/registers_list")
def get_registers_list():
+ bank = request.args.get('bank')
+ if not bank is None:
+ bank = str(bank)
+
reg_list = 0
try:
- reg_list = pcilib.get_registers_list()
+ reg_list = pcilib.get_registers_list(bank)
except Exception as e:
return str(e)
+
+ value = dict()
+ for reg in reg_list:
+ print reg
+ try:
+ value[reg['name']] = pcilib.read_register(str(reg['name']),
+ str(reg['bank']))
+ except Exception as e:
+ value[reg['name']] = str(e)
return render_template('registers_list.html',
- registers=reg_list,
+ registers = reg_list,
+ render_template = render_template,
+ value = value
)
@app.route("/property_info")
@@ -147,13 +162,20 @@ def get_property_list():
except Exception as e:
return str(e)
- value = -1
+ value = dict()
if (len(prop_info) == 1) and not ('childs' in (prop_info[0])['flags']):
try:
branch = (prop_info[0])['path']
- value = pcilib.get_property(branch)
+ value[branch] = pcilib.get_property(branch)
except Exception as e:
- return str(e)
+ return str(e)
+ else:
+ for prop in prop_info:
+ try:
+ path = prop['path']
+ value[path] = pcilib.get_property(path)
+ except Exception as e:
+ value[path] = str(e)
return render_template('property_info.html',
value = value,
@@ -168,12 +190,8 @@ def greet():
device = device,
model = model)
-@app.route('/<path:path>')
-def send_file(path):
- return send_from_directory('static', path)
-
if __name__ == "__main__":
- #parce command line options
+ #parse command line options
parser = OptionParser()
parser.add_option("-p", "--port", action="store",
type="int", dest="port", default=5000,
diff --git a/html_server/static/check_err.js b/html_server/static/check_err.js
new file mode 100644
index 0000000..a63d7bc
--- /dev/null
+++ b/html_server/static/check_err.js
@@ -0,0 +1,4 @@
+function checkError(json) {
+ if(json.error)
+ alert('Error: ' + json.error)
+}
diff --git a/pywrap/static/codebase/dhtmlx.css b/html_server/static/codebase/dhtmlx.css
index 9b89ec5..9b89ec5 100644
--- a/pywrap/static/codebase/dhtmlx.css
+++ b/html_server/static/codebase/dhtmlx.css
diff --git a/pywrap/static/codebase/dhtmlx.js b/html_server/static/codebase/dhtmlx.js
index 5e560b1..5e560b1 100644
--- a/pywrap/static/codebase/dhtmlx.js
+++ b/html_server/static/codebase/dhtmlx.js
diff --git a/pywrap/static/codebase/dhtmlx_deprecated.js b/html_server/static/codebase/dhtmlx_deprecated.js
index 5731d3f..5731d3f 100644
--- a/pywrap/static/codebase/dhtmlx_deprecated.js
+++ b/html_server/static/codebase/dhtmlx_deprecated.js
diff --git a/pywrap/static/codebase/ext/dhxupload.xap b/html_server/static/codebase/ext/dhxupload.xap
index f2deecd..f2deecd 100644
--- a/pywrap/static/codebase/ext/dhxupload.xap
+++ b/html_server/static/codebase/ext/dhxupload.xap
Binary files differ
diff --git a/pywrap/static/codebase/ext/swfobject.js b/html_server/static/codebase/ext/swfobject.js
index 7a9d26f..7a9d26f 100644
--- a/pywrap/static/codebase/ext/swfobject.js
+++ b/html_server/static/codebase/ext/swfobject.js
diff --git a/pywrap/static/codebase/ext/uploader.swf b/html_server/static/codebase/ext/uploader.swf
index 2fa8674..2fa8674 100644
--- a/pywrap/static/codebase/ext/uploader.swf
+++ b/html_server/static/codebase/ext/uploader.swf
Binary files differ
diff --git a/pywrap/static/codebase/imgs/dhxtree_skyblue/blank.gif b/html_server/static/codebase/imgs/dhxtree_skyblue/blank.gif
index d7ae406..d7ae406 100644
--- a/pywrap/static/codebase/imgs/dhxtree_skyblue/blank.gif
+++ b/html_server/static/codebase/imgs/dhxtree_skyblue/blank.gif
Binary files differ
diff --git a/pywrap/static/codebase/imgs/dhxtree_skyblue/but_cut.gif b/html_server/static/codebase/imgs/dhxtree_skyblue/but_cut.gif
index 942bd18..942bd18 100644
--- a/pywrap/static/codebase/imgs/dhxtree_skyblue/but_cut.gif
+++ b/html_server/static/codebase/imgs/dhxtree_skyblue/but_cut.gif
Binary files differ
diff --git a/pywrap/static/codebase/imgs/dhxtree_skyblue/folderClosed.gif b/html_server/static/codebase/imgs/dhxtree_skyblue/folderClosed.gif
index e0a88ce..e0a88ce 100644
--- a/pywrap/static/codebase/imgs/dhxtree_skyblue/folderClosed.gif
+++ b/html_server/static/codebase/imgs/dhxtree_skyblue/folderClosed.gif
Binary files differ
diff --git a/pywrap/static/codebase/imgs/dhxtree_skyblue/folderOpen.gif b/html_server/static/codebase/imgs/dhxtree_skyblue/folderOpen.gif
index 1680dbc..1680dbc 100644
--- a/pywrap/static/codebase/imgs/dhxtree_skyblue/folderOpen.gif
+++ b/html_server/static/codebase/imgs/dhxtree_skyblue/folderOpen.gif
Binary files differ
diff --git a/pywrap/static/codebase/imgs/dhxtree_skyblue/iconCheckAll.gif b/html_server/static/codebase/imgs/dhxtree_skyblue/iconCheckAll.gif
index a61302a..a61302a 100644
--- a/pywrap/static/codebase/imgs/dhxtree_skyblue/iconCheckAll.gif
+++ b/html_server/static/codebase/imgs/dhxtree_skyblue/iconCheckAll.gif
Binary files differ
diff --git a/pywrap/static/codebase/imgs/dhxtree_skyblue/iconCheckDis.gif b/html_server/static/codebase/imgs/dhxtree_skyblue/iconCheckDis.gif
index 42447b8..42447b8 100644
--- a/pywrap/static/codebase/imgs/dhxtree_skyblue/iconCheckDis.gif
+++ b/html_server/static/codebase/imgs/dhxtree_skyblue/iconCheckDis.gif
Binary files differ
diff --git a/pywrap/static/codebase/imgs/dhxtree_skyblue/iconCheckGray.gif b/html_server/static/codebase/imgs/dhxtree_skyblue/iconCheckGray.gif
index 0350b2a..0350b2a 100644
--- a/pywrap/static/codebase/imgs/dhxtree_skyblue/iconCheckGray.gif
+++ b/html_server/static/codebase/imgs/dhxtree_skyblue/iconCheckGray.gif
Binary files differ
diff --git a/pywrap/static/codebase/imgs/dhxtree_skyblue/iconUncheckAll.gif b/html_server/static/codebase/imgs/dhxtree_skyblue/iconUncheckAll.gif
index 9f3fe50..9f3fe50 100644
--- a/pywrap/static/codebase/imgs/dhxtree_skyblue/iconUncheckAll.gif
+++ b/html_server/static/codebase/imgs/dhxtree_skyblue/iconUncheckAll.gif
Binary files differ
diff --git a/pywrap/static/codebase/imgs/dhxtree_skyblue/iconUncheckDis.gif b/html_server/static/codebase/imgs/dhxtree_skyblue/iconUncheckDis.gif
index f15d9f7..f15d9f7 100644
--- a/pywrap/static/codebase/imgs/dhxtree_skyblue/iconUncheckDis.gif
+++ b/html_server/static/codebase/imgs/dhxtree_skyblue/iconUncheckDis.gif
Binary files differ
diff --git a/pywrap/static/codebase/imgs/dhxtree_skyblue/leaf.gif b/html_server/static/codebase/imgs/dhxtree_skyblue/leaf.gif
index 9c3e531..9c3e531 100644
--- a/pywrap/static/codebase/imgs/dhxtree_skyblue/leaf.gif
+++ b/html_server/static/codebase/imgs/dhxtree_skyblue/leaf.gif
Binary files differ
diff --git a/pywrap/static/codebase/imgs/dhxtree_skyblue/line.gif b/html_server/static/codebase/imgs/dhxtree_skyblue/line.gif
index b4f560c..b4f560c 100644
--- a/pywrap/static/codebase/imgs/dhxtree_skyblue/line.gif
+++ b/html_server/static/codebase/imgs/dhxtree_skyblue/line.gif
Binary files differ
diff --git a/pywrap/static/codebase/imgs/dhxtree_skyblue/line1.gif b/html_server/static/codebase/imgs/dhxtree_skyblue/line1.gif
index b4f560c..b4f560c 100644
--- a/pywrap/static/codebase/imgs/dhxtree_skyblue/line1.gif
+++ b/html_server/static/codebase/imgs/dhxtree_skyblue/line1.gif
Binary files differ
diff --git a/pywrap/static/codebase/imgs/dhxtree_skyblue/line1_rtl.gif b/html_server/static/codebase/imgs/dhxtree_skyblue/line1_rtl.gif
index bf32db2..bf32db2 100644
--- a/pywrap/static/codebase/imgs/dhxtree_skyblue/line1_rtl.gif
+++ b/html_server/static/codebase/imgs/dhxtree_skyblue/line1_rtl.gif
Binary files differ
diff --git a/pywrap/static/codebase/imgs/dhxtree_skyblue/line2.gif b/html_server/static/codebase/imgs/dhxtree_skyblue/line2.gif
index 23b2ce3..23b2ce3 100644
--- a/pywrap/static/codebase/imgs/dhxtree_skyblue/line2.gif
+++ b/html_server/static/codebase/imgs/dhxtree_skyblue/line2.gif
Binary files differ
diff --git a/pywrap/static/codebase/imgs/dhxtree_skyblue/line2_rtl.gif b/html_server/static/codebase/imgs/dhxtree_skyblue/line2_rtl.gif
index 6ec17b5..6ec17b5 100644
--- a/pywrap/static/codebase/imgs/dhxtree_skyblue/line2_rtl.gif
+++ b/html_server/static/codebase/imgs/dhxtree_skyblue/line2_rtl.gif
Binary files differ
diff --git a/pywrap/static/codebase/imgs/dhxtree_skyblue/line3.gif b/html_server/static/codebase/imgs/dhxtree_skyblue/line3.gif
index 43152c5..43152c5 100644
--- a/pywrap/static/codebase/imgs/dhxtree_skyblue/line3.gif
+++ b/html_server/static/codebase/imgs/dhxtree_skyblue/line3.gif
Binary files differ
diff --git a/pywrap/static/codebase/imgs/dhxtree_skyblue/line3_rtl.gif b/html_server/static/codebase/imgs/dhxtree_skyblue/line3_rtl.gif
index 74a874c..74a874c 100644
--- a/pywrap/static/codebase/imgs/dhxtree_skyblue/line3_rtl.gif
+++ b/html_server/static/codebase/imgs/dhxtree_skyblue/line3_rtl.gif
Binary files differ
diff --git a/pywrap/static/codebase/imgs/dhxtree_skyblue/line4.gif b/html_server/static/codebase/imgs/dhxtree_skyblue/line4.gif
index 907fe7a..907fe7a 100644
--- a/pywrap/static/codebase/imgs/dhxtree_skyblue/line4.gif
+++ b/html_server/static/codebase/imgs/dhxtree_skyblue/line4.gif
Binary files differ
diff --git a/pywrap/static/codebase/imgs/dhxtree_skyblue/line4_rtl.gif b/html_server/static/codebase/imgs/dhxtree_skyblue/line4_rtl.gif
index 5c7e162..5c7e162 100644
--- a/pywrap/static/codebase/imgs/dhxtree_skyblue/line4_rtl.gif
+++ b/html_server/static/codebase/imgs/dhxtree_skyblue/line4_rtl.gif
Binary files differ
diff --git a/pywrap/static/codebase/imgs/dhxtree_skyblue/lock.gif b/html_server/static/codebase/imgs/dhxtree_skyblue/lock.gif
index 67456b1..67456b1 100644
--- a/pywrap/static/codebase/imgs/dhxtree_skyblue/lock.gif
+++ b/html_server/static/codebase/imgs/dhxtree_skyblue/lock.gif
Binary files differ
diff --git a/pywrap/static/codebase/imgs/dhxtree_skyblue/minus.gif b/html_server/static/codebase/imgs/dhxtree_skyblue/minus.gif
index caa3f57..caa3f57 100644
--- a/pywrap/static/codebase/imgs/dhxtree_skyblue/minus.gif
+++ b/html_server/static/codebase/imgs/dhxtree_skyblue/minus.gif
Binary files differ
diff --git a/pywrap/static/codebase/imgs/dhxtree_skyblue/minus1.gif b/html_server/static/codebase/imgs/dhxtree_skyblue/minus1.gif
index 2ab1070..2ab1070 100644
--- a/pywrap/static/codebase/imgs/dhxtree_skyblue/minus1.gif
+++ b/html_server/static/codebase/imgs/dhxtree_skyblue/minus1.gif
Binary files differ
diff --git a/pywrap/static/codebase/imgs/dhxtree_skyblue/minus2.gif b/html_server/static/codebase/imgs/dhxtree_skyblue/minus2.gif
index 036e5b3..036e5b3 100644
--- a/pywrap/static/codebase/imgs/dhxtree_skyblue/minus2.gif
+++ b/html_server/static/codebase/imgs/dhxtree_skyblue/minus2.gif
Binary files differ
diff --git a/pywrap/static/codebase/imgs/dhxtree_skyblue/minus2_rtl.gif b/html_server/static/codebase/imgs/dhxtree_skyblue/minus2_rtl.gif
index b4672bf..b4672bf 100644
--- a/pywrap/static/codebase/imgs/dhxtree_skyblue/minus2_rtl.gif
+++ b/html_server/static/codebase/imgs/dhxtree_skyblue/minus2_rtl.gif
Binary files differ
diff --git a/pywrap/static/codebase/imgs/dhxtree_skyblue/minus3.gif b/html_server/static/codebase/imgs/dhxtree_skyblue/minus3.gif
index 3242cca..3242cca 100644
--- a/pywrap/static/codebase/imgs/dhxtree_skyblue/minus3.gif
+++ b/html_server/static/codebase/imgs/dhxtree_skyblue/minus3.gif
Binary files differ
diff --git a/pywrap/static/codebase/imgs/dhxtree_skyblue/minus3_rtl.gif b/html_server/static/codebase/imgs/dhxtree_skyblue/minus3_rtl.gif
index 8c279e0..8c279e0 100644
--- a/pywrap/static/codebase/imgs/dhxtree_skyblue/minus3_rtl.gif
+++ b/html_server/static/codebase/imgs/dhxtree_skyblue/minus3_rtl.gif
Binary files differ
diff --git a/pywrap/static/codebase/imgs/dhxtree_skyblue/minus4.gif b/html_server/static/codebase/imgs/dhxtree_skyblue/minus4.gif
index 1c7c0a7..1c7c0a7 100644
--- a/pywrap/static/codebase/imgs/dhxtree_skyblue/minus4.gif
+++ b/html_server/static/codebase/imgs/dhxtree_skyblue/minus4.gif
Binary files differ
diff --git a/pywrap/static/codebase/imgs/dhxtree_skyblue/minus4_rtl.gif b/html_server/static/codebase/imgs/dhxtree_skyblue/minus4_rtl.gif
index 70992fe..70992fe 100644
--- a/pywrap/static/codebase/imgs/dhxtree_skyblue/minus4_rtl.gif
+++ b/html_server/static/codebase/imgs/dhxtree_skyblue/minus4_rtl.gif
Binary files differ
diff --git a/pywrap/static/codebase/imgs/dhxtree_skyblue/minus5.gif b/html_server/static/codebase/imgs/dhxtree_skyblue/minus5.gif
index 031c160..031c160 100644
--- a/pywrap/static/codebase/imgs/dhxtree_skyblue/minus5.gif
+++ b/html_server/static/codebase/imgs/dhxtree_skyblue/minus5.gif
Binary files differ
diff --git a/pywrap/static/codebase/imgs/dhxtree_skyblue/minus5_rtl.gif b/html_server/static/codebase/imgs/dhxtree_skyblue/minus5_rtl.gif
index 47e25cd..47e25cd 100644
--- a/pywrap/static/codebase/imgs/dhxtree_skyblue/minus5_rtl.gif
+++ b/html_server/static/codebase/imgs/dhxtree_skyblue/minus5_rtl.gif
Binary files differ
diff --git a/pywrap/static/codebase/imgs/dhxtree_skyblue/plus.gif b/html_server/static/codebase/imgs/dhxtree_skyblue/plus.gif
index 019cfbd..019cfbd 100644
--- a/pywrap/static/codebase/imgs/dhxtree_skyblue/plus.gif
+++ b/html_server/static/codebase/imgs/dhxtree_skyblue/plus.gif
Binary files differ
diff --git a/pywrap/static/codebase/imgs/dhxtree_skyblue/plus1.gif b/html_server/static/codebase/imgs/dhxtree_skyblue/plus1.gif
index 34dee94..34dee94 100644
--- a/pywrap/static/codebase/imgs/dhxtree_skyblue/plus1.gif
+++ b/html_server/static/codebase/imgs/dhxtree_skyblue/plus1.gif
Binary files differ
diff --git a/pywrap/static/codebase/imgs/dhxtree_skyblue/plus2.gif b/html_server/static/codebase/imgs/dhxtree_skyblue/plus2.gif
index d57afa9..d57afa9 100644
--- a/pywrap/static/codebase/imgs/dhxtree_skyblue/plus2.gif
+++ b/html_server/static/codebase/imgs/dhxtree_skyblue/plus2.gif
Binary files differ
diff --git a/pywrap/static/codebase/imgs/dhxtree_skyblue/plus2_rtl.gif b/html_server/static/codebase/imgs/dhxtree_skyblue/plus2_rtl.gif
index fde3a58..fde3a58 100644
--- a/pywrap/static/codebase/imgs/dhxtree_skyblue/plus2_rtl.gif
+++ b/html_server/static/codebase/imgs/dhxtree_skyblue/plus2_rtl.gif
Binary files differ
diff --git a/pywrap/static/codebase/imgs/dhxtree_skyblue/plus3.gif b/html_server/static/codebase/imgs/dhxtree_skyblue/plus3.gif
index 2b6546b..2b6546b 100644
--- a/pywrap/static/codebase/imgs/dhxtree_skyblue/plus3.gif
+++ b/html_server/static/codebase/imgs/dhxtree_skyblue/plus3.gif
Binary files differ
diff --git a/pywrap/static/codebase/imgs/dhxtree_skyblue/plus3_rtl.gif b/html_server/static/codebase/imgs/dhxtree_skyblue/plus3_rtl.gif
index 863d34c..863d34c 100644
--- a/pywrap/static/codebase/imgs/dhxtree_skyblue/plus3_rtl.gif
+++ b/html_server/static/codebase/imgs/dhxtree_skyblue/plus3_rtl.gif
Binary files differ
diff --git a/pywrap/static/codebase/imgs/dhxtree_skyblue/plus4.gif b/html_server/static/codebase/imgs/dhxtree_skyblue/plus4.gif
index a4fe8c0..a4fe8c0 100644
--- a/pywrap/static/codebase/imgs/dhxtree_skyblue/plus4.gif
+++ b/html_server/static/codebase/imgs/dhxtree_skyblue/plus4.gif
Binary files differ
diff --git a/pywrap/static/codebase/imgs/dhxtree_skyblue/plus4_rtl.gif b/html_server/static/codebase/imgs/dhxtree_skyblue/plus4_rtl.gif
index 635e6f6..635e6f6 100644
--- a/pywrap/static/codebase/imgs/dhxtree_skyblue/plus4_rtl.gif
+++ b/html_server/static/codebase/imgs/dhxtree_skyblue/plus4_rtl.gif
Binary files differ
diff --git a/pywrap/static/codebase/imgs/dhxtree_skyblue/plus5.gif b/html_server/static/codebase/imgs/dhxtree_skyblue/plus5.gif
index 88c35a4..88c35a4 100644
--- a/pywrap/static/codebase/imgs/dhxtree_skyblue/plus5.gif
+++ b/html_server/static/codebase/imgs/dhxtree_skyblue/plus5.gif
Binary files differ
diff --git a/pywrap/static/codebase/imgs/dhxtree_skyblue/plus5_rtl.gif b/html_server/static/codebase/imgs/dhxtree_skyblue/plus5_rtl.gif
index 2ae5444..2ae5444 100644
--- a/pywrap/static/codebase/imgs/dhxtree_skyblue/plus5_rtl.gif
+++ b/html_server/static/codebase/imgs/dhxtree_skyblue/plus5_rtl.gif
Binary files differ
diff --git a/pywrap/static/codebase/imgs/dhxtree_skyblue/radio_off.gif b/html_server/static/codebase/imgs/dhxtree_skyblue/radio_off.gif
index a050afd..a050afd 100644
--- a/pywrap/static/codebase/imgs/dhxtree_skyblue/radio_off.gif
+++ b/html_server/static/codebase/imgs/dhxtree_skyblue/radio_off.gif
Binary files differ
diff --git a/pywrap/static/codebase/imgs/dhxtree_skyblue/radio_on.gif b/html_server/static/codebase/imgs/dhxtree_skyblue/radio_on.gif
index 4d594b5..4d594b5 100644
--- a/pywrap/static/codebase/imgs/dhxtree_skyblue/radio_on.gif
+++ b/html_server/static/codebase/imgs/dhxtree_skyblue/radio_on.gif
Binary files differ
diff --git a/pywrap/static/codebase/thirdparty/excanvas/AUTHORS b/html_server/static/codebase/thirdparty/excanvas/AUTHORS
index 90decb3..90decb3 100644
--- a/pywrap/static/codebase/thirdparty/excanvas/AUTHORS
+++ b/html_server/static/codebase/thirdparty/excanvas/AUTHORS
diff --git a/pywrap/static/codebase/thirdparty/excanvas/COPYING b/html_server/static/codebase/thirdparty/excanvas/COPYING
index 75b5248..75b5248 100644
--- a/pywrap/static/codebase/thirdparty/excanvas/COPYING
+++ b/html_server/static/codebase/thirdparty/excanvas/COPYING
diff --git a/pywrap/static/codebase/thirdparty/excanvas/README b/html_server/static/codebase/thirdparty/excanvas/README
index eb7c42f..eb7c42f 100644
--- a/pywrap/static/codebase/thirdparty/excanvas/README
+++ b/html_server/static/codebase/thirdparty/excanvas/README
diff --git a/pywrap/static/codebase/thirdparty/excanvas/excanvas.js b/html_server/static/codebase/thirdparty/excanvas/excanvas.js
index 66310a8..66310a8 100644
--- a/pywrap/static/codebase/thirdparty/excanvas/excanvas.js
+++ b/html_server/static/codebase/thirdparty/excanvas/excanvas.js
diff --git a/pywrap/static/jquery-2.2.1.js b/html_server/static/jquery-2.2.1.js
index b7c491f..b7c491f 100644
--- a/pywrap/static/jquery-2.2.1.js
+++ b/html_server/static/jquery-2.2.1.js
diff --git a/html_server/templates/base.html b/html_server/templates/base.html
new file mode 100644
index 0000000..39f8d00
--- /dev/null
+++ b/html_server/templates/base.html
@@ -0,0 +1,233 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>{% block title %}Device {{ device }}{% endblock %}</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
+ <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
+ <link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='codebase/dhtmlx.css') }}"/>
+ <script type=text/javascript src="{{ url_for('static', filename='jquery-2.2.1.js') }}"></script>
+ <script src="{{ url_for('static', filename='codebase/dhtmlx.js') }}"></script>
+ <script src="{{ url_for('static', filename='check_err.js') }}"></script>
+ <script>
+ var propsTree
+ function createPropertyTree(branch, id) {
+
+ function getPropertyItemsOnLevel(branch, id) {
+ pathToProperties = "{{ url_for('get_property_list_json') }}"
+ completePath = pathToProperties + '?branch=' + branch
+
+ $.getJSON(completePath,
+ function(json) {
+ checkError(json)
+ parsePropertyItems(json, branch, id)
+ });
+ }
+
+ function parsePropertyItems(json, branch, id) {
+
+ function loadPropertyInfo(branch) {
+
+ var pathToProperties = "{{ url_for('get_property_list') }}"
+ var completePath = pathToProperties + '?branch=' + branch
+
+ $("#prop_info_place").load(completePath)
+ }
+
+
+ function setPropertyField(id, name, branch) {
+
+ var func = function(){loadPropertyInfo(branch)}
+ propsTree.insertNewItem(id, branch,
+ name,
+ func);
+ propsTree.closeAllItems()
+ }
+
+ for(var i = 0; i < json.length; i++) {
+
+ setPropertyField(id, json[i].name, json[i].path)
+ if(json[i].flags.indexOf("childs") != -1)
+ getPropertyItemsOnLevel(json[i].path, json[i].path)
+ }
+ }
+
+ getPropertyItemsOnLevel(branch, id)
+ }
+
+ var regTree
+ function createRegistersList() {
+ function parseJsonRegisterList(json) {
+
+ function loadRegistersList(bank) {
+ var pathToGetRegisterList = "{{ url_for('get_registers_list') }}"
+ var completePath = pathToGetRegisterList + '?bank=' + bank
+
+ $("#reg_info_place").load(completePath)
+ }
+
+ function loadRegisterInfo(bank, name) {
+ var pathToGetRegister = "{{ url_for('get_register_info') }}"
+ var completePath = pathToGetRegister + '?bank=' + bank +
+ '&name=' + name
+
+ $("#reg_info_place").load(completePath)
+ }
+
+ function setRegisterField(id, bank, name) {
+
+ var itemId = bank + "_" + name
+ var func = function(){loadRegisterInfo(bank, name)}
+
+ regTree.insertNewItem(id, itemId, name, func)
+ regTree.closeAllItems()
+ }
+
+ function setbankField(bank) {
+
+ var func = function(){loadRegistersList(bank)}
+ regTree.insertNewItem(0, bank, bank, func);
+ regTree.closeAllItems()
+ }
+
+ checkError(json)
+ if(json.lenght <= 0)
+ return
+
+ //sort registers by bank
+ function compareRegistersByBank(a,b) {
+ if (a.bank < b.bank)
+ return -1;
+ else if (a.bank > b.bank)
+ return 1;
+ else
+ return 0;
+ }
+ json.sort(compareRegistersByBank)
+
+
+ //create bank dirs
+ var curBankName = json[0].bank
+ var created = 0
+ for(var i = 0; i < json.length; i++) {
+
+ //create new bank tab if it has not created already
+ if(json[i].bank != curBankName) {
+ curBankName = json[i].bank
+ created = 0
+ }
+
+ if(!created) {
+ setbankField(json[i].bank )
+ created = 1
+ }
+
+
+ //insert register info to bank
+
+ setRegisterField(json[i].bank, json[i].bank, json[i].name)
+ }
+ }
+
+ //get registers json list
+ getRegistersListPath = "{{ url_for('get_registers_list_json') }}"
+ $.getJSON(getRegistersListPath, parseJsonRegisterList);
+ }
+
+ function doOnLoad()
+ {
+ propsTree = new dhtmlXTreeObject("treeboxbox_tree","100%","100%",0);
+ propsTree.setImagePath("{{ url_for('static', filename='codebase/imgs/dhxtree_skyblue/') }}");
+ //generating properties list
+ createPropertyTree('', 0)
+
+ regTree = new dhtmlXTreeObject("treeboxbox_tree2","100%","100%",0,0,0,0,'SELECT')
+ regTree.setImagePath("{{ url_for('static', filename='codebase/imgs/dhxtree_skyblue/') }}");
+ createRegistersList()
+ }
+ </script>
+</head>
+<body onload="doOnLoad()">
+ {% block info %}
+ <div class="block1" >
+ <h2>Device {{ device }} model={{ model }} control page </h2>
+ </div>
+ {% endblock %}
+ <style>
+ .tabs > div, .tabs > input { display: none; }
+
+ .tabs label {
+ padding: 5px;
+ border: 1px solid #aaa;
+ line-height: 28px;
+ cursor: pointer;
+ position: relative;
+ bottom: 1px;
+ background: #fff;
+ }
+
+ .tabs input[type="radio"]:checked + label { border-bottom: 2px solid #fff; }
+
+ .tabs > input:nth-of-type(1):checked ~ div:nth-of-type(1),
+ .tabs > input:nth-of-type(2):checked ~ div:nth-of-type(2) {
+ display: block;
+ padding: 5px;
+ border:
+ 1px solid #aaa;
+ }
+ .tree {
+ height: 85vh;
+ padding: 5px;
+ border: 1px solid #aaa;
+ line-height: 28px;
+ cursor: pointer;
+ position: relative;
+ bottom: 1px;
+ background: #fff;
+ overflow:auto;
+ }
+
+ .infoTable {
+ padding: 5px;
+
+ border: 1px solid #aaa;
+ line-height: 28px;
+ cursor: pointer;
+ position: relative;
+ background: #fff;
+ overflow:auto;
+ bottom: 1px;
+
+ text-align: left;
+ }
+ </style>
+
+ <div class="tabs">
+ <input type="radio" name="current" checked="checked" id="props_id"/>
+ <label for="props_id">Properties</label>
+ <input type="radio" name="current" id="labels_id"/>
+ <label for="labels_id">Registers</label>
+ <div>
+ <table>
+ <tr>
+ <td valign="top">
+ <div id="treeboxbox_tree" class = "tree"></div>
+ </td>
+ <td valign="top" id="prop_info_place" />
+ </tr>
+ </table>
+ </div>
+ <div>
+ <table>
+ <tr>
+ <td valign="top">
+ <div id="treeboxbox_tree2" class="tree"></div>
+ </td>
+ <td valign="top" id="reg_info_place" />
+ </tr>
+ </table>
+ </div>
+ </div>
+ {% block content %}
+ {% endblock %}
+</body>
+</html>
diff --git a/html_server/templates/property_info.html b/html_server/templates/property_info.html
new file mode 100644
index 0000000..4e7c92f
--- /dev/null
+++ b/html_server/templates/property_info.html
@@ -0,0 +1,91 @@
+{% block content %}
+
+{% if standalone %}
+<script src="{{ url_for('static', filename='codebase/dhtmlx.js') }}"></script>
+<script src="{{ url_for('static', filename='check_err.js') }}"></script>
+{% endif %}
+
+<script>
+ function updateProperty(prop) {
+ var pathToGetProperty = "{{ url_for('get_property_json') }}"
+ var completePath = pathToGetProperty + '?prop=' + prop
+
+ $.getJSON(completePath, function(json){
+ checkError(json)
+ var valFieldId = "#set_val_" + prop.split('/').join("_")
+ $(valFieldId).val(json.value)
+ })
+ }
+
+ function setProperty(prop)
+ {
+ var value = document.getElementById("set_val_" + prop.split('/').join("_")).value;
+ if(value == "")
+ return
+
+ var pathToGetProperty = "{{ url_for('set_property_json') }}"
+ var completePath = pathToGetProperty + '?prop=' + prop +
+ '&val=' + value;
+
+ $.getJSON(completePath,
+ function(json) {
+ checkError(json)
+ updateProperty(prop)
+ })
+ };
+</script>
+
+<table class="infoTable">
+ <tr class="infoTable">
+ <td class="infoTable">Name</td>
+ <td class="infoTable">Description</td>
+ <td class="infoTable">Value</td>
+ <td class="infoTable">Mode</td>
+ <td class="infoTable">Type</td>
+ <td class="infoTable">Unit</td>
+ <td class="infoTable">Path</td>
+ </tr>
+ {% for property in properties %}
+ <tr class="infoTable">
+ <td class="infoTable">{{ property.name }}</td>
+ <td class="infoTable">
+ {% if 'description' in property %}
+ {{ property.description }}
+ {% endif %}
+ </td>
+ <td class="infoTable">
+ <table>
+ {% if 'R' in property.mode %}
+ <tr>
+ <td>
+ <input type="text"
+ name="set_val_{{ property.path.replace('/', '_') }}"
+ id="set_val_{{ property.path.replace('/', '_') }}"
+ value="{{ value[property.path] }}" />
+ </td>
+ {% if 'W' in property.mode %}
+ <td>
+ <input type="button" value="set" style="width:100%;height:100%" onclick="setProperty('{{ property.path }}')">
+ </td>
+ {% endif %}
+ <td>
+ <input type="button" value="update" style="width:100%;height:100%" onclick="updateProperty('{{ property.path }}')">
+ </td>
+ </tr>
+ {% endif %}
+ </table>
+ </td>
+ <td class="infoTable">
+ <ul>
+ {% for m in property.mode %}
+ {{ m + '; '}}
+ {% endfor %}
+ </ul>
+ </td>
+ <td class="infoTable"> {{ property.type }} </td>
+ <td class="infoTable"> {{ property.unit }} </td>
+ <td class="infoTable"> {{ property.path }} </td>
+ </tr>
+ {% endfor %}
+</table>
+{% endblock %}
diff --git a/html_server/templates/register_info.html b/html_server/templates/register_info.html
new file mode 100644
index 0000000..3efebd7
--- /dev/null
+++ b/html_server/templates/register_info.html
@@ -0,0 +1,9 @@
+{% block content %}
+
+{% include 'registers/table_scripts.html' %}
+
+<table class="infoTable">
+ {% include 'registers/table_header.html' %}
+ {% include 'registers/table_cell.html' %}
+</table>
+{% endblock %}
diff --git a/html_server/templates/registers/table_cell.html b/html_server/templates/registers/table_cell.html
new file mode 100644
index 0000000..d394d42
--- /dev/null
+++ b/html_server/templates/registers/table_cell.html
@@ -0,0 +1,100 @@
+<tr class="infoTable">
+ <td class="infoTable"> {{ register.name }} </td>
+ {% if 'description' in register %}
+ <td class="infoTable"> {{ register.description }} </td>
+ {% else %}
+ <td class="infoTable"> </td>
+ {% endif %}
+ <td class="infoTable">
+ <table>
+ {% if 'R' in register.mode %}
+ <tr class="infoTable">
+ <td>
+ <input type="text"
+ name="set_val_box_{{ register.bank }}_{{ register.name }}"
+ id="set_val_box_{{ register.bank }}_{{ register.name }}"
+ value="{{ value[register.name] }}" />
+ </td>
+ {% if 'W' in register.mode %}
+ <td>
+ <input type="button" value="set"
+ style="width:100%;height:100%"
+ onclick="writeRegister('{{ register.bank }}', '{{ register.name }}')">
+ </td>
+ {% endif %}
+ <td>
+ <input type="button" value="update"
+ style="width:100%;height:100%"
+ onclick="updateRegister('{{ register.bank }}', '{{ register.name }}')">
+ </td>
+ </tr>
+ {% endif %}
+ </table>
+ </td>
+ <td class="infoTable">{{ register.defvalue }}</td>
+ <td class="infoTable">{{ register.bank }}</td>
+ <td class="infoTable">
+ <ul>
+ {% for m in register.mode %}
+ {{ m + '; '}}
+ {% endfor %}
+ </ul>
+ </td>
+ {% if 'range' in register %}
+ <td class="infoTable">
+ <table>
+ <tr class="infoTable">
+ <td class="infoTable"> min </td>
+ <td class="infoTable"> max </td>
+ </tr>
+ <tr class="infoTable">
+ <td class="infoTable"> {{ register.range.min }} </td>
+ <td class="infoTable"> {{ register.range.max }} </td>
+ </tr>
+ </table>
+ </td>
+ {% else %}
+ <td class="infoTable"> </td>
+ {% endif %}
+ {% if 'values' in register %}
+ <td class="infoTable">
+ <table>
+ <tr>
+ {% for v in register['values'] %}
+ <td>
+ <table>
+ {% if 'name' in v %}
+ <tr class="infoTable">
+ <td class="infoTable"> Name </td>
+ <td class="infoTable"> {{v.name}} </td>
+ </tr>
+ {% endif %}
+ {% if 'description' in v %}
+ <tr class="infoTable">
+ <td class="infoTable"> Description </td>
+ <td class="infoTable"> {{ v.description }} </td>
+ </tr>
+ {% endif %}
+ <tr class="infoTable">
+ <td class="infoTable"> Min </td>
+ <td class="infoTable"> {{ v.min }} </td>
+ </tr>
+ <tr class="infoTable">
+ <td class="infoTable"> Max </td>
+ <td class="infoTable"> {{ v.max }} </td>
+ </tr>
+ <tr class="infoTable">
+ <td class="infoTable"> Value </td>
+ <td class="infoTable"> {{ v.value }} </td>
+ </tr>
+ </table>
+ </td>
+ {% endfor %}
+ </tr>
+ </table>
+ </td>
+ {% else %}
+ <td class="infoTable"> </td>
+ {% endif %}
+</tr>
+
diff --git a/html_server/templates/registers/table_header.html b/html_server/templates/registers/table_header.html
new file mode 100644
index 0000000..4c46713
--- /dev/null
+++ b/html_server/templates/registers/table_header.html
@@ -0,0 +1,10 @@
+<tr class="infoTable">
+ <td class="infoTable"> Name </td>
+ <td class="infoTable"> Description </td>
+ <td class="infoTable"> Value </td>
+ <td class="infoTable">Default value</td>
+ <td class="infoTable">Bank</td>
+ <td class="infoTable">Mode</td>
+ <td class="infoTable">Range</td>
+ <td class="infoTable">Values</td>
+</tr>
diff --git a/html_server/templates/registers/table_scripts.html b/html_server/templates/registers/table_scripts.html
new file mode 100644
index 0000000..017c910
--- /dev/null
+++ b/html_server/templates/registers/table_scripts.html
@@ -0,0 +1,42 @@
+{% if standalone %}
+<script src="{{ url_for('static', filename='codebase/dhtmlx.js') }}"></script>
+<script src="{{ url_for('static', filename='check_err.js') }}"></script>
+{% endif %}
+
+<script>
+ /*
+ $("#set_val_box").keyup(function(event){
+ if(event.keyCode == 13){
+ $("#set_val_button").click();
+ }
+ });
+ */
+
+ function updateRegister(bank, name) {
+ var pathToReadRegister = "{{ url_for('read_register_json') }}"
+ var completePath = pathToReadRegister + '?bank=' + bank +
+ '&name=' + name
+
+ $.getJSON(completePath, function(json){
+ checkError(json)
+ $("#set_val_box_" + bank + "_" + name).val(json.value)
+ })
+ }
+
+ function writeRegister(bank, name)
+ {
+ var value = document.getElementById("set_val_box_" + bank + "_" + name).value;
+ if(value == "")
+ return
+
+ var pathToReadRegister = "{{ url_for('write_register_json') }}"
+ var completePath = pathToReadRegister + '?bank=' + bank +
+ '&name=' + name + '&val=' + value;
+
+ $.getJSON(completePath,
+ function(json) {
+ checkError(json)
+ updateRegister(bank, name)
+ })
+ };
+</script>
diff --git a/html_server/templates/registers_list.html b/html_server/templates/registers_list.html
new file mode 100644
index 0000000..26a6721
--- /dev/null
+++ b/html_server/templates/registers_list.html
@@ -0,0 +1,12 @@
+{% block content %}
+{% include 'registers/table_scripts.html' %}
+
+<table class="infoTable">
+{% include 'registers/table_header.html' %}
+{% for register in registers %}
+ {% include 'registers/table_cell.html' %}
+{% endfor %}
+</table>
+{% endblock %}
+
+
diff --git a/pcilib/py.c b/pcilib/py.c
index 3e1f38d..6cf9fdc 100644
--- a/pcilib/py.c
+++ b/pcilib/py.c
@@ -48,37 +48,37 @@ void pcilib_log_python_error(const char *file, int line, pcilib_log_flags_t flag
gstate = PyGILState_Ensure();
if (PyErr_Occurred()) {
- PyErr_Fetch(&pytype, &pyval, &pytraceback);
- type = PyString_AsString(pytype);
- val = PyString_AsString(pyval);
+ PyErr_Fetch(&pytype, &pyval, &pytraceback);
+ type = PyString_AsString(pytype);
+ val = PyString_AsString(pyval);
}
PyGILState_Release(gstate);
#endif /* HAVE_PYTHON */
va_start(va, msg);
if (type) {
- char *str;
- size_t len = 32;
-
- if (msg) len += strlen(msg);
- if (type) len += strlen(type);
- if (val) len += strlen(val);
-
- str = alloca(len * sizeof(char));
- if (str) {
- if (msg&&val)
- sprintf(str, "%s <%s: %s>", msg, type, val);
- else if (msg)
- sprintf(str, "%s <%s>", msg, type);
- else if (val)
- sprintf(str, "Python error %s: %s", type, val);
- else
- sprintf(str, "Python error %s", type);
-
- pcilib_log_vmessage(file, line, flags, prio, str, va);
- }
+ char *str;
+ size_t len = 32;
+
+ if (msg) len += strlen(msg);
+ if (type) len += strlen(type);
+ if (val) len += strlen(val);
+
+ str = alloca(len * sizeof(char));
+ if (str) {
+ if (msg&&val)
+ sprintf(str, "%s <%s: %s>", msg, type, val);
+ else if (msg)
+ sprintf(str, "%s <%s>", msg, type);
+ else if (val)
+ sprintf(str, "Python error %s: %s", type, val);
+ else
+ sprintf(str, "Python error %s", type);
+
+ pcilib_log_vmessage(file, line, flags, prio, str, va);
+ }
} else {
- pcilib_log_vmessage(file, line, flags, prio, msg, va);
+ pcilib_log_vmessage(file, line, flags, prio, msg, va);
}
va_end(va);
@@ -104,25 +104,25 @@ int pcilib_init_py(pcilib_t *ctx) {
// Since python is being initializing from c programm, it needs to initialize threads to work properly with c threads
PyEval_InitThreads();
PyEval_ReleaseLock();
- ctx->py->finalyze = 1;
+ ctx->py->finalyze = 1;
}
ctx->py->main_module = PyImport_AddModule("__parser__");
if (!ctx->py->main_module) {
- pcilib_python_error("Error importing python parser");
- return PCILIB_ERROR_FAILED;
+ pcilib_python_error("Error importing python parser");
+ return PCILIB_ERROR_FAILED;
}
ctx->py->global_dict = PyModule_GetDict(ctx->py->main_module);
if (!ctx->py->global_dict) {
- pcilib_python_error("Error locating global python dictionary");
- return PCILIB_ERROR_FAILED;
+ pcilib_python_error("Error locating global python dictionary");
+ return PCILIB_ERROR_FAILED;
}
PyObject *pywrap = PyImport_ImportModule("pcipywrap");
if (!pywrap) {
- pcilib_python_error("Error importing pcilib python wrapper");
- return PCILIB_ERROR_FAILED;
+ pcilib_python_error("Error importing pcilib python wrapper");
+ return PCILIB_ERROR_FAILED;
}
PyObject *mod_name = PyString_FromString("Pcipywrap");
@@ -132,8 +132,8 @@ int pcilib_init_py(pcilib_t *ctx) {
Py_XDECREF(mod_name);
if (!ctx->py->pcilib_pywrap) {
- pcilib_python_error("Error initializing python wrapper");
- return PCILIB_ERROR_FAILED;
+ pcilib_python_error("Error initializing python wrapper");
+ return PCILIB_ERROR_FAILED;
}
#endif /* HAVE_PYTHON */
@@ -153,53 +153,53 @@ int pcilib_py_add_script_dir(pcilib_t *ctx, const char *dir) {
if (!dir) dir = ctx->model;
if (*dir == '/') {
- script_dir = (char*)dir;
+ script_dir = (char*)dir;
} else {
- script_dir = alloca(strlen(model_dir) + strlen(dir) + 2);
- if (!script_dir) return PCILIB_ERROR_MEMORY;
- sprintf(script_dir, "%s/%s", model_dir, dir);
+ script_dir = alloca(strlen(model_dir) + strlen(dir) + 2);
+ if (!script_dir) return PCILIB_ERROR_MEMORY;
+ sprintf(script_dir, "%s/%s", model_dir, dir);
}
pypath = PySys_GetObject("path");
if (!pypath) {
- pcilib_python_error("Can't get python path");
- return PCILIB_ERROR_FAILED;
+ pcilib_python_error("Can't get python path");
+ return PCILIB_ERROR_FAILED;
}
pynewdir = PyString_FromString(script_dir);
if (!pynewdir) {
- pcilib_python_error("Can't create python string");
- return PCILIB_ERROR_MEMORY;
+ pcilib_python_error("Can't create python string");
+ return PCILIB_ERROR_MEMORY;
}
- // Checking if the directory already in the path?
+ // Checking if the directory already in the path
pydict = PyDict_New();
if (pydict) {
- pystr = PyString_FromString("cur");
+ pystr = PyString_FromString("cur");
if (pystr) {
- PyDict_SetItem(pydict, pystr, pynewdir);
- Py_DECREF(pystr);
- }
-
- pystr = PyString_FromString("path");
- if (pystr) {
- PyDict_SetItem(pydict, pystr, pypath);
- Py_DECREF(pystr);
- }
-
- pyret = PyRun_String("cur in path", Py_eval_input, ctx->py->global_dict, pydict);
- Py_DECREF(pydict);
+ PyDict_SetItem(pydict, pystr, pynewdir);
+ Py_DECREF(pystr);
+ }
+
+ pystr = PyString_FromString("path");
+ if (pystr) {
+ PyDict_SetItem(pydict, pystr, pypath);
+ Py_DECREF(pystr);
+ }
+
+ pyret = PyRun_String("cur in path", Py_eval_input, ctx->py->global_dict, pydict);
+ Py_DECREF(pydict);
}
if ((pyret == Py_False)&&(PyList_Append(pypath, pynewdir) == -1))
- err = PCILIB_ERROR_FAILED;
+ err = PCILIB_ERROR_FAILED;
if (pyret) Py_DECREF(pyret);
Py_DECREF(pynewdir);
if (err) {
- pcilib_python_error("Can't add directory (%s) to python path", script_dir);
- return err;
+ pcilib_python_error("Can't add directory (%s) to python path", script_dir);
+ return err;
}
#endif /* HAVE_PYTHON */
@@ -211,24 +211,24 @@ void pcilib_free_py(pcilib_t *ctx) {
int finalyze = 0;
if (ctx->py) {
- if (ctx->py->finalyze) finalyze = 1;
-
- if (ctx->py->script_hash) {
- pcilib_script_t *script, *script_tmp;
-
- HASH_ITER(hh, ctx->py->script_hash, script, script_tmp) {
- Py_DECREF(script->module);
- HASH_DEL(ctx->py->script_hash, script);
- free(script);
- }
- ctx->py->script_hash = NULL;
- }
-
- if (ctx->py->pcilib_pywrap)
- Py_DECREF(ctx->py->pcilib_pywrap);
-
- free(ctx->py);
- ctx->py = NULL;
+ if (ctx->py->finalyze) finalyze = 1;
+
+ if (ctx->py->script_hash) {
+ pcilib_script_t *script, *script_tmp;
+
+ HASH_ITER(hh, ctx->py->script_hash, script, script_tmp) {
+ Py_DECREF(script->module);
+ HASH_DEL(ctx->py->script_hash, script);
+ free(script);
+ }
+ ctx->py->script_hash = NULL;
+ }
+
+ if (ctx->py->pcilib_pywrap)
+ Py_DECREF(ctx->py->pcilib_pywrap);
+
+ free(ctx->py);
+ ctx->py = NULL;
}
if (finalyze)
@@ -247,8 +247,8 @@ int pcilib_py_load_script(pcilib_t *ctx, const char *script_name) {
char *py = strrchr(module_name, '.');
if ((!py)||(strcasecmp(py, ".py"))) {
- pcilib_error("Invalid script name (%s) is specified", script_name);
- return PCILIB_ERROR_INVALID_ARGUMENT;
+ pcilib_error("Invalid script name (%s) is specified", script_name);
+ return PCILIB_ERROR_INVALID_ARGUMENT;
}
*py = 0;
@@ -257,8 +257,8 @@ int pcilib_py_load_script(pcilib_t *ctx, const char *script_name) {
pymodule = PyImport_ImportModule(module_name);
if (!pymodule) {
- pcilib_python_error("Error importing script (%s)", script_name);
- return PCILIB_ERROR_FAILED;
+ pcilib_python_error("Error importing script (%s)", script_name);
+ return PCILIB_ERROR_FAILED;
}
module = (pcilib_script_t*)malloc(sizeof(pcilib_script_t));
@@ -282,26 +282,26 @@ int pcilib_py_get_transform_script_properties(pcilib_t *ctx, const char *script_
HASH_FIND_STR(ctx->py->script_hash, script_name, module);
if(!module) {
- pcilib_error("Script (%s) is not loaded yet", script_name);
- return PCILIB_ERROR_NOTFOUND;
+ pcilib_error("Script (%s) is not loaded yet", script_name);
+ return PCILIB_ERROR_NOTFOUND;
}
dict = PyModule_GetDict(module->module);
if (!dict) {
- pcilib_python_error("Error getting dictionary for script (%s)", script_name);
- return PCILIB_ERROR_FAILED;
+ pcilib_python_error("Error getting dictionary for script (%s)", script_name);
+ return PCILIB_ERROR_FAILED;
}
pystr = PyString_FromString("read_from_register");
if (pystr) {
- if (PyDict_Contains(dict, pystr)) mode |= PCILIB_ACCESS_R;
- Py_DECREF(pystr);
+ if (PyDict_Contains(dict, pystr)) mode |= PCILIB_ACCESS_R;
+ Py_DECREF(pystr);
}
pystr = PyString_FromString("write_to_register");
if (pystr) {
- if (PyDict_Contains(dict, pystr)) mode |= PCILIB_ACCESS_W;
- Py_DECREF(pystr);
+ if (PyDict_Contains(dict, pystr)) mode |= PCILIB_ACCESS_W;
+ Py_DECREF(pystr);
}
#endif /* HAVE_PYTHON */
@@ -320,28 +320,28 @@ pcilib_py_object *pcilib_get_value_as_pyobject(pcilib_t* ctx, pcilib_value_t *va
gstate = PyGILState_Ensure();
switch(val->type) {
- case PCILIB_TYPE_LONG:
- ival = pcilib_get_value_as_int(ctx, val, &err);
- if (!err) res = (PyObject*)PyInt_FromLong(ival);
- break;
- case PCILIB_TYPE_DOUBLE:
- fval = pcilib_get_value_as_float(ctx, val, &err);
- if (!err) res = (PyObject*)PyFloat_FromDouble(fval);
- break;
- default:
- PyGILState_Release(gstate);
- pcilib_error("Can't convert pcilib value of type (%lu) to PyObject", val->type);
- if (ret) *ret = PCILIB_ERROR_NOTSUPPORTED;
- return NULL;
+ case PCILIB_TYPE_LONG:
+ ival = pcilib_get_value_as_int(ctx, val, &err);
+ if (!err) res = (PyObject*)PyInt_FromLong(ival);
+ break;
+ case PCILIB_TYPE_DOUBLE:
+ fval = pcilib_get_value_as_float(ctx, val, &err);
+ if (!err) res = (PyObject*)PyFloat_FromDouble(fval);
+ break;
+ default:
+ PyGILState_Release(gstate);
+ pcilib_error("Can't convert pcilib value of type (%lu) to PyObject", val->type);
+ if (ret) *ret = PCILIB_ERROR_NOTSUPPORTED;
+ return NULL;
}
PyGILState_Release(gstate);
if (err) {
- if (ret) *ret = err;
- return NULL;
+ if (ret) *ret = err;
+ return NULL;
} else if (!res) {
- if (ret) *ret = PCILIB_ERROR_MEMORY;
- return res;
+ if (ret) *ret = PCILIB_ERROR_MEMORY;
+ return res;
}
if (ret) *ret = 0;
@@ -425,7 +425,7 @@ static char *pcilib_py_parse_string(pcilib_t *ctx, const char *codestr, pcilib_v
strcpy(dst + offset, cur);
offset += reg - cur;
- // find the end of the register name
+ // find the end of the register name
reg++;
if (*reg == '{') {
reg++;
@@ -441,7 +441,7 @@ static char *pcilib_py_parse_string(pcilib_t *ctx, const char *codestr, pcilib_v
save = reg[i];
reg[i] = 0;
- // determine replacement value
+ // determine replacement value
if (!strcasecmp(reg, "value")) {
if (!value) {
pcilib_error("Python formula (%s) relies on the value of register, but it is not provided", codestr);
@@ -469,7 +469,7 @@ static char *pcilib_py_parse_string(pcilib_t *ctx, const char *codestr, pcilib_v
if (save == '}') i++;
else reg[i] = save;
- // Advance to the next register if any
+ // Advance to the next register if any
cur = reg + i;
reg = strchr(cur, '$');
}
@@ -479,8 +479,8 @@ static char *pcilib_py_parse_string(pcilib_t *ctx, const char *codestr, pcilib_v
free(src);
if (err) {
- free(dst);
- return NULL;
+ free(dst);
+ return NULL;
}
return dst;
@@ -534,22 +534,22 @@ int pcilib_py_eval_func(pcilib_t *ctx, const char *script_name, const char *func
HASH_FIND_STR(ctx->py->script_hash, script_name, module);
if (!module) {
- pcilib_error("Script (%s) is not loaded", script_name);
- return PCILIB_ERROR_NOTFOUND;
+ pcilib_error("Script (%s) is not loaded", script_name);
+ return PCILIB_ERROR_NOTFOUND;
}
if (val) {
- pyval = pcilib_get_value_as_pyobject(ctx, val, &err);
- if (err) return err;
+ pyval = pcilib_get_value_as_pyobject(ctx, val, &err);
+ if (err) return err;
}
PyGILState_STATE gstate = PyGILState_Ensure();
pyfunc = PyUnicode_FromString(func_name);
if (!pyfunc) {
- if (pyval) Py_DECREF(pyval);
- PyGILState_Release(gstate);
- return PCILIB_ERROR_MEMORY;
+ if (pyval) Py_DECREF(pyval);
+ PyGILState_Release(gstate);
+ return PCILIB_ERROR_MEMORY;
}
pyret = PyObject_CallMethodObjArgs(module->module, pyfunc, ctx->py->pcilib_pywrap, pyval, NULL);
@@ -558,13 +558,13 @@ int pcilib_py_eval_func(pcilib_t *ctx, const char *script_name, const char *func
Py_DECREF(pyval);
if (!pyret) {
- PyGILState_Release(gstate);
- pcilib_python_error("Error executing function (%s) of python script (%s)", func_name, script_name);
- return PCILIB_ERROR_FAILED;
+ PyGILState_Release(gstate);
+ pcilib_python_error("Error executing function (%s) of python script (%s)", func_name, script_name);
+ return PCILIB_ERROR_FAILED;
}
if ((val)&&(pyret != Py_None))
- err = pcilib_set_value_from_pyobject(ctx, val, pyret);
+ err = pcilib_set_value_from_pyobject(ctx, val, pyret);
Py_DECREF(pyret);
PyGILState_Release(gstate);
diff --git a/pywrap/CMakeLists.txt b/pywrap/CMakeLists.txt
index 988546b..b00fdb0 100644
--- a/pywrap/CMakeLists.txt
+++ b/pywrap/CMakeLists.txt
@@ -17,15 +17,14 @@ set(CMAKE_SWIG_FLAGS "")
swig_add_module(pcipywrap python pcipywrap.i pcipywrap.c)
swig_link_libraries(pcipywrap ${PYTHON_LIBRARIES} pcilib)
-execute_process ( COMMAND python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()" OUTPUT_VARIABLE PYTHON_SITE_PACKAGES OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+#install pcilib python wrapper into Python site packages folder
+execute_process ( COMMAND python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()" OUTPUT_VARIABLE PYTHON_SITE_PACKAGES OUTPUT_STRIP_TRAILING_WHITESPACE)
+
install(TARGETS ${SWIG_MODULE_pcipywrap_REAL_NAME} DESTINATION ${PYTHON_SITE_PACKAGES})
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/pcipywrap.py DESTINATION ${PYTHON_SITE_PACKAGES})
if (NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/server.py DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/test_pcipywrap.py DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
-
- file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/templates DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
- file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/static DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
- file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/html_server.py DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
endif(NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
diff --git a/pywrap/pcipywrap.c b/pywrap/pcipywrap.c
index ceb0835..391bdf4 100644
--- a/pywrap/pcipywrap.c
+++ b/pywrap/pcipywrap.c
@@ -458,17 +458,22 @@ PyObject* Pcipywrap_set_property(Pcipywrap *self, PyObject* val, const char *pro
PyObject* Pcipywrap_get_registers_list(Pcipywrap *self, const char *bank)
{
- pcilib_register_info_t *list = pcilib_get_register_list(self->ctx, bank, PCILIB_LIST_FLAGS_DEFAULT);
- PyObject* pyList = PyList_New(0);
- for(int i = 0; i < ((pcilib_t*)self->ctx)->num_reg; i++)
- {
- //serialize item attributes
- PyObject* pylistItem = pcilib_convert_register_info_to_pyobject(self->ctx, list[i]);
- pcilib_pylist_append(pyList, pylistItem);
- //Py_DECREF(pylistItem);
- }
- pcilib_free_register_info(self->ctx, list);
- return pyList;
+ pcilib_register_info_t *list = pcilib_get_register_list(self->ctx, bank, PCILIB_LIST_FLAGS_DEFAULT);
+
+ if(!list) {
+ set_python_exception("pcilib_get_register_list return NULL");
+ return NULL;
+ }
+
+ PyObject* pyList = PyList_New(0);
+ for(int i = 0; list[i].name; i++)
+ {
+ //serialize item attributes
+ PyObject* pylistItem = pcilib_convert_register_info_to_pyobject(self->ctx, list[i]);
+ pcilib_pylist_append(pyList, pylistItem);
+ }
+ pcilib_free_register_info(self->ctx, list);
+ return pyList;
}
PyObject* Pcipywrap_get_register_info(Pcipywrap *self, const char* reg,const char *bank)
diff --git a/pywrap/pcipywrap.h b/pywrap/pcipywrap.h
index 5876a06..dcce245 100644
--- a/pywrap/pcipywrap.h
+++ b/pywrap/pcipywrap.h
@@ -74,7 +74,7 @@ void Pcipywrap_unlock_global(Pcipywrap *self);
* \brief Wrap for pcilib_lock
* \param lock_id lock identificator
* \warning This function should be called only under Python standart threading lock.
- * Otherwise it will stuck with more than 1 threads. See /xml/test_pywrap/test_prop_mt.py
+ * Otherwise it will stuck with more than 1 threads. See /xml/test/test_prop_mt.py
* for example.
* \return 1, serialized to PyObject or NULL with exeption text, if failed.
*/
diff --git a/pywrap/templates/base.html b/pywrap/templates/base.html
deleted file mode 100644
index fdb95e8..0000000
--- a/pywrap/templates/base.html
+++ /dev/null
@@ -1,347 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
- <title>{% block title %}Device {{ device }}{% endblock %}</title>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
- <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
- <link rel="stylesheet" type="text/css" href="codebase/dhtmlx.css"/>
- <script type=text/javascript src="{{ url_for('static', filename='jquery-2.2.1.js') }}"></script>
- <script src="codebase/dhtmlx.js"></script>
- <script src="pcilib_tree.js"></script>
- <script>
- var propsTree
-
- function checkError(json)
- {
- if(json.error)
- alert('Error:\n' + json.error)
- }
-
- function createPropertyTree(branch, id)
- {
- function getPropertyItemsOnLevel(branch, id)
- {
- pathToProperties = "{{ url_for('get_property_list_json') }}"
- completePath = pathToProperties + '?branch=' + branch
-
- $.getJSON(completePath,
- function(json) {
- checkError(json)
- parsePropertyItems(json, branch, id)
- });
- }
-
- function parsePropertyItems(json, branch, id)
- {
- function updatePropertyValue(id, path)
- {
- pathToGetProperty = "{{ url_for('get_property_json') }}"
- completePath = pathToGetProperty + '?prop=' + path
-
- $.getJSON(completePath, function(json){
- checkError(json)
- propsTree.updateItem(id, 'value: ' + json.value);
- })
- }
-
- function writePropertyValue(id, path)
- {
- value = window.prompt("Enter new property value");
-
- if(value != null)
- {
- pathToGetProperty = "{{ url_for('set_property_json') }}"
- completePath = pathToGetProperty + '?prop=' + path +'&val=' + value
-
- $.getJSON(completePath,
- function(json) {
- checkError(json)
- updatePropertyValue(id, path)
- })
- }
- else
- updatePropertyValue(id, path)
- }
-
- function setCurrentValueField(id, path, mode)
- {
- var propValId = id + 'CurrVal'
- var func = 0
-
- if(mode)
- func = function(){writePropertyValue(propValId, path)}
- else
- func = function(){updatePropertyValue(propValId, path)}
-
- propsTree.insertNewItem(id, propValId,
- 'value: ',
- func);
-
- updatePropertyValue(propValId, path)
- }
-
- for(var i = 0; i < json.length; i++)
- {
- propsTree.insertNewItem(id, json[i].path, json[i].name, 0);
-
- if(json[i].flags.indexOf("childs") != -1)
- {
- getPropertyItemsOnLevel(json[i].path, json[i].path)
- }
- else
- {
- if(json[i].mode.indexOf("R") != -1)
- {
- var mode = (json[i].mode.indexOf("W") != -1)
- setCurrentValueField(json[i].path, json[i].path, mode)
- }
- }
-
- //show aviable info
- if(json[i].description)
- propsTree.insertNewItem(json[i].path, json[i].path + 'Desc',
- 'description:\n' + json[i].description, 0);
- if(json[i].type)
- propsTree.insertNewItem(json[i].path, json[i].path + 'Type',
- 'type: ' + json[i].type, 0);
- if(json[i].unit)
- propsTree.insertNewItem(json[i].path, json[i].path + 'Unit',
- 'unit: ' + json[i].unit, 0);
-
- if(json[i].mode)
- {
- var modeId = json[i].path + 'Mode'
- propsTree.insertNewItem(json[i].path, modeId,
- 'mode', 0);
-
- for(var j = 0; j < json[i].mode.length; j++)
- propsTree.insertNewItem(modeId, modeId + j,
- json[i].mode[j], 0);
- propsTree.closeItem(modeId)
- }
-
- if(json[i].path)
- propsTree.insertNewItem(json[i].path, json[i].path + 'Path',
- 'path: ' + json[i].path, 0);
-
- propsTree.closeItem(json[i].path);
- }
- }
-
- getPropertyItemsOnLevel(branch, id)
- }
-
- var regTree
- function createRegistersList()
- {
- function parseJsonRegisterList(json)
- {
- checkError(json)
-
- function compareRegistersByBank(a,b)
- {
- if (a.bank < b.bank)
- return -1;
- else if (a.bank > b.bank)
- return 1;
- else
- return 0;
- }
-
- if(json.lenght <= 0)
- return
-
- //sort registers by bank
- json.sort(compareRegistersByBank)
-
- //create bank dirs
- var curBankName = json[0].bank
- var created = 0
- for(var i = 0; i < json.length; i++)
- {
- //create new bank tab if it has not created already
- if(json[i].bank != curBankName)
- {
- curBankName = json[i].bank
- created = 0
- }
- if(!created)
- {
- regTree.insertNewItem(0, json[i].bank, json[i].bank, 0);
- created = 1
- }
-
- //insert register info to bank
- var itemId = json[i].bank + "_" + json[i].name
- regTree.insertNewItem(json[i].bank, itemId, json[i].name)
-
- function updateRegisterValue(id, bank, name)
- {
- pathToGetProperty = "{{ url_for('read_register_json') }}"
- completePath = pathToGetProperty + '?bank=' + bank +
- '&name=' + name
-
- $.getJSON(completePath, function(json){
- checkError(json)
- regTree.updateItem(id, 'value: ' + json.value);
- })
- }
-
-
- function writeRegisterValue(id, bank, name)
- {
- value = window.prompt("Enter new register value");
-
- if(value != null)
- {
- pathToGetProperty = "{{ url_for('write_register_json') }}"
- completePath = pathToGetProperty + '?bank=' + bank +
- '&name=' + name + '&val=' + value;
-
- $.getJSON(completePath,
- function(json) {
- checkError(json)
- updateRegisterValue(id, bank, name)
- })
- }
- else
- updateRegisterValue(id, bank, name)
- }
-
- function setCurrentValueField(id, bank, name, mode)
- {
- var regValId = id + 'CurrVal'
- var func = 0
-
- if(mode)
- func = function(){writeRegisterValue(regValId, bank, name)}
- else
- func = function(){updateRegisterValue(regValId, bank, name)}
-
- regTree.insertNewItem(id, regValId,
- 'value: ',
- func);
- updateRegisterValue(regValId, bank, name)
- }
-
- if(json[i].mode.indexOf("R") != -1)
- {
- var mode = (json[i].mode.indexOf("W") != -1)
- setCurrentValueField(itemId, json[i].bank, json[i].name, mode)
- }
-
- //show aviable info
- if(json[i].description)
- regTree.insertNewItem(itemId, itemId + 'Desc',
- 'description:\n' + json[i].description, 0);
- if(json[i].defvalue)
- regTree.insertNewItem(itemId, itemId + 'Defvalue',
- 'defvalue: ' + json[i].defvalue, 0);
-
- if(json[i].mode)
- {
- var modeId = itemId + 'Mode'
- regTree.insertNewItem(itemId, modeId,
- 'mode', 0);
-
- for(var j = 0; j < json[i].mode.length; j++)
- regTree.insertNewItem(modeId, modeId + j,
- json[i].mode[j], 0);
- regTree.closeItem(modeId)
- }
-
- if(json[i].range)
- {
- var rangeId = itemId + 'Range'
- regTree.insertNewItem(itemId, rangeId,
- 'range', 0);
- regTree.insertNewItem(rangeId, rangeId + 'Min',
- 'min: ' + json[i].range.min, 0);
- regTree.insertNewItem(rangeId, rangeId + 'Max',
- 'max: ' + json[i].range.max, 0);
- regTree.closeItem(rangeId)
- }
-
- if(json[i].values)
- {
- var valuesId = itemId + 'Values'
- regTree.insertNewItem(itemId, valuesId,
- 'values', 0);
-
- function addValueInfo(valuesId, value)
- {
- var valueId = valuesId + value.name
- regTree.insertNewItem(valuesId, valueId, value.name, 0);
-
- if(value.description)
- regTree.insertNewItem(valueId, valueId + 'Desc',
- 'description: ' + value.description, 0);
- if(value.value)
- regTree.insertNewItem(valueId, valueId + 'Value',
- 'value: ' + value.value, 0);
- if(value.min)
- regTree.insertNewItem(valueId, valueId + 'Min',
- 'min: ' + value.min, 0);
- if(value.max)
- regTree.insertNewItem(valueId, valueId + 'Max',
- 'max: ' + value.max, 0);
- }
-
- for(var j = 0; j < json[i].values.length; j++)
- {
- addValueInfo(valuesId, json[i].values[j])
- }
- regTree.closeItem(valuesId)
- }
-
- propsTree.closeItem(json[i].path);
-
- regTree.closeItem(itemId);
- }
- }
-
- //get registers json list
- getRegistersListPath = "{{ url_for('get_registers_list_json') }}"
- $.getJSON(getRegistersListPath, parseJsonRegisterList);
- }
-
- function doOnLoad()
- {
- propsTree = new dhtmlXTreeObject("treeboxbox_tree","100%","100%",0);
- propsTree.setImagePath("codebase/imgs/dhxtree_skyblue/");
- //generating properties list
- createPropertyTree('', 0)
-
- regTree = new dhtmlXTreeObject("treeboxbox_tree2","100%","100%",0,0,0,0,'SELECT')
- regTree.setImagePath("codebase/imgs/dhxtree_skyblue/");
- createRegistersList()
- }
- </script>
-</head>
-<body onload="doOnLoad()">
- {% block info %}
- <h2>Device {{ device }} model={{ model }} control page </h2>
- {% endblock %}
-
- {% block content %}
- {% endblock %}
- <table>
- <tr>
- <td>
- <h3>Properties Tree</h3>
- </td>
- <td>
- <h3>Registers Tree</h3>
- </td>
- </tr>
- <tr>
- <td valign="top">
- <div id="treeboxbox_tree" style="background-color:#f5f5f5;border :1px solid Silver; overflow:auto;"></div>
- </td>
- <td valign="top">
- <div id="treeboxbox_tree2" style="background-color:#f5f5f5;border :1px solid Silver; overflow:auto;"></div>
- </td>
- </tr>
- </table>
-</body>
-</html>
diff --git a/pywrap/templates/property_info.html b/pywrap/templates/property_info.html
deleted file mode 100644
index 912d3d5..0000000
--- a/pywrap/templates/property_info.html
+++ /dev/null
@@ -1,91 +0,0 @@
-{% extends "base.html" %}
-{% block title %}Property list{% endblock %}
-{% block info %}
-<h1>List of properties in branch {{ branch }}</h1>
-{% endblock %}
-
-{% block content %}
-
- <script>
- function set_property()
- {
- var value = document.getElementById("set_val_box").value;
- window.location.href = "{{ url_for('set_property') }}?prop={{ branch }}&"+
- 'val='+value;
- };
- </script>
-
-<table border="1" style="width:100%">
- <tr>
- <th>Name</th>
- <th>Description</th>
- </tr>
- {% for property in properties %}
- <tr>
- {% if ('childs' in property.flags) or (properties|length != 1) %}
- <td><a href="{{ url_for('get_property_list', branch = property.path) }}">"{{ property.name }}"</td>
- {% if 'description' in property %}
- <script>
- function set_property()
- {
- var value = document.getElementById("set_val_box").value;
- window.location.href = "{{ url_for('set_property') }}?prop={{ branch }}&"+
- 'val='+value;
- };
- </script>
- <td>{{ property.description }}</td>
- {% else %}
- <td></td>
- {% endif %}
- {% else %}
- <td>{{ property.name }}"</td>
- <td>
- <table border="1" style="width:100%">
- {% if 'description' in property %}
- <tr>
- <th> Description </th>
- <td> {{ property.description }} </td>
- </tr>
- {% endif %}
- <tr>
- <th> Current value </th>
- <td> {{ value }} </td>
- </tr>
- {% if 'W' in property.mode %}
- <tr>
- <th> Set value</th>
- <td>
- <input type="text" name="set_val_box" id="set_val_box" value="" />
- <input type="button" value="set" onclick="set_property()">
- </td>
- </tr>
- {% endif %}
- <tr>
- <th>Mode</th>
- <td>
- <ul>
- {% for m in property.mode %}
- <li>{{ m }}</li>
- {% endfor %}
- </ul>
- </td>
- </tr>
- <tr>
- <th>Type</th>
- <td> {{ property.type }} </td>
- </tr>
- <tr>
- <th>Unit</th>
- <td> {{ property.unit }} </td>
- </tr>
- <tr>
- <th>Path</th>
- <td> {{ property.path }} </td>
- </tr>
- </table>
- </td>
- {% endif %}
- </tr>
- {% endfor %}
- </table>
-{% endblock %}
diff --git a/pywrap/templates/register_info.html b/pywrap/templates/register_info.html
deleted file mode 100644
index a7f11dc..0000000
--- a/pywrap/templates/register_info.html
+++ /dev/null
@@ -1,106 +0,0 @@
-{% extends "base.html" %}
-{% block title %}Register info{% endblock %}
-{% block info %}
-<h1>Register '{{ register.name }}' info</h1>
-{% endblock %}
-
-{% block content %}
- <script>
- function write_register()
- {
- var value = document.getElementById("set_val_box").value;
- window.location.href = "{{ url_for('write_register') }}?name={{ register.name }}&"+
- 'bank={{ register.bank }}&val='+value;
- };
- </script>
-
- <table border="1" style="width:100%">
- {% if 'description' in register %}
- <tr>
- <th> Description </th>
- <td> {{ register.description }} </td>
- </tr>
- {% endif %}
- <tr>
- <th> Current value </th>
- <td> {{ value }} </td>
- </tr>
- {% if 'W' in register.mode %}
- <tr>
- <th> Set value</th>
- <td>
- <input type="text" name="set_val_box" id="set_val_box" value="" />
- <input type="button" value="set" onclick="write_register()">
- </td>
- </tr>
- {% endif %}
- <tr>
- <th>Bank</th>
- <td>{{ register.bank }}</td>
- </tr>
- <tr>
- <th>Default value</th>
- <td>{{ register.defvalue }}</td>
- </tr>
- <tr>
- <th>Mode</th>
- <td>
- <ul>
- {% for m in register.mode %}
- <li>{{ m }}</li>
- {% endfor %}
- </ul>
- </td>
- </tr>
- {% if 'range' in register %}
- <tr>
- <th>
- Range
- </th>
- <td>
- <table>
- <tr>
- <th> min </th>
- <td> {{ register.range.min }} </td>
- </tr>
- <tr>
- <th> max </th>
- <td> {{ register.range.max }} </td>
- </tr>
- </table>
- </td>
- </tr>
- {% endif %}
- {% if 'values' in register %}
- {% for v in register['values'] %}
- <tr>
- {% if 'name' in v %}
- <th> {{v.name}} </th>
- {% endif %}
- <td>
- <table>
- {% if 'description' in v %}
- <tr>
- <th> description </th>
- <td> {{ v.description }} </td>
- </tr>
- {% endif %}
- <tr>
- <th> min </th>
- <td> {{ v.min }} </td>
- </tr>
- <tr>
- <th> max </th>
- <td> {{ v.max }} </td>
- </tr>
- <tr>
- <th> value </th>
- <td> {{ v.value }} </td>
- </tr>
- </table>
- </td>
- </tr>
- {% endfor %}
- {% endif %}
- </table>
-{% endblock %}
diff --git a/pywrap/templates/registers_list.html b/pywrap/templates/registers_list.html
deleted file mode 100644
index 199475b..0000000
--- a/pywrap/templates/registers_list.html
+++ /dev/null
@@ -1,26 +0,0 @@
-{% extends "base.html" %}
-{% block title %}Registers list{% endblock %}
-{% block info %}
-<h1>List of aviable registers</h1>
-{% endblock %}
-
-{% block content %}
-<table border="1" style="width:100%">
- <tr>
- <th>Name</th>
- <th>Description</th>
- </tr>
-{% for register in registers %}
- <tr>
- <td><a href="{{ url_for('get_register_info', bank=register.bank, name=register.name) }}">{{ register.name }}</td>
- {% if 'description' in register %}
- <td>{{ register.description }}</td>
- {% else %}
- <td></td>
- {% endif %}
- </tr>
-{% endfor %}
-</table>
-{% endblock %}
-
-
diff --git a/pywrap/test_pcipywrap.py b/pywrap/test_pcipywrap.py
index 91780ec..809a81a 100644
--- a/pywrap/test_pcipywrap.py
+++ b/pywrap/test_pcipywrap.py
@@ -87,10 +87,10 @@ class test_pcipywrap():
print self.pcilib.get_property_list(self.branch)
print self.pcilib.get_register_info(self.register)
print self.pcilib.get_registers_list();
- print self.pcilib.read_register(self.register)
print self.pcilib.write_register(val, self.register)
- print self.pcilib.get_property(self.prop)
+ print self.pcilib.read_register(self.register)
print self.pcilib.set_property(val, self.prop)
+ print self.pcilib.get_property(self.prop)
except KeyboardInterrupt:
print 'testing done'
pass
diff --git a/xml/test/cmosis.xml b/xml/test/cmosis.xml
deleted file mode 100644
index 45d2f6e..0000000
--- a/xml/test/cmosis.xml
+++ /dev/null
@@ -1,50 +0,0 @@
-<?xml version="1.0"?>
-<model xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <bank bar="0" size="128" protocol="software_registers" read_address="0x9010" write_address="0x9000" word_size="8" endianess="little" format="%lu" name="cmosis" description="CMOSIS CMV2000 Registers">
- <register address="1" offset="0" size="16" default="1088" rwmask="0" mode="RW" name="cmosis_number_lines" description="test"/>
- <register address="3" offset="0" size="16" default="0" rwmask="0" mode="RW" name="cmosis_start1"/>
- <register address="5" offset="0" size="16" default="0" rwmask="0" mode="RW" name="cmosis_start2"/>
- <register address="7" offset="0" size="16" default="0" rwmask="0" mode="RW" name="cmosis_start3"/>
- <register address="9" offset="0" size="16" default="0" rwmask="0" mode="RW" name="cmosis_start4"/>
- <register address="11" offset="0" size="16" default="0" rwmask="0" mode="RW" name="cmosis_start5"/>
- <register address="13" offset="0" size="16" default="0" rwmask="0" mode="RW" name="cmosis_start6"/>
- <register address="15" offset="0" size="16" default="0" rwmask="0" mode="RW" name="cmosis_start7"/>
- <register address="17" offset="0" size="16" default="0" rwmask="0" mode="RW" name="cmosis_start8"/>
- <register address="19" offset="0" size="16" default="0" rwmask="0" mode="RW" name="cmosis_number_lines1"/>
- <register address="21" offset="0" size="16" default="0" rwmask="0" mode="RW" name="cmosis_number_lines2"/>
- <register address="23" offset="0" size="16" default="0" rwmask="0" mode="RW" name="cmosis_number_lines3"/>
- <register address="25" offset="0" size="16" default="0" rwmask="0" mode="RW" name="cmosis_number_lines4"/>
- <register address="27" offset="0" size="16" default="0" rwmask="0" mode="RW" name="cmosis_number_lines5"/>
- <register address="29" offset="0" size="16" default="0" rwmask="0" mode="RW" name="cmosis_number_lines6"/>
- <register address="31" offset="0" size="16" default="0" rwmask="0" mode="RW" name="cmosis_number_lines7"/>
- <register address="33" offset="0" size="16" default="0" rwmask="0" mode="RW" name="cmosis_number_lines8"/>
- <register address="35" offset="0" size="16" default="0" rwmask="0" mode="RW" name="cmosis_sub_s"/>
- <register address="37" offset="0" size="16" default="0" rwmask="0" mode="RW" name="cmosis_sub_a"/>
- <register address="39" offset="0" size="1" default="1" rwmask="0" mode="RW" name="cmosis_color"/>
- <register address="40" offset="0" size="2" default="0" rwmask="0" mode="RW" name="cmosis_image_flipping"/>
- <register address="41" offset="0" size="2" default="0" rwmask="0" mode="RW" name="cmosis_exp_flags"/>
- <register address="42" offset="0" size="24" default="1088" rwmask="0" mode="RW" name="cmosis_exp_time"><view view="formuu3"/><view view="enumm3"/></register>
- <register address="45" offset="0" size="24" default="1088" rwmask="0" mode="RW" name="cmosis_exp_step"/>
- <register address="48" offset="0" size="24" default="1" rwmask="0" mode="RW" name="cmosis_exp_kp1"/>
- <register address="51" offset="0" size="24" default="1" rwmask="0" mode="RW" name="cmosis_exp_kp2"/>
- <register address="54" offset="0" size="2" default="1" rwmask="0" mode="RW" name="cmosis_nr_slopes"/>
- <register address="55" offset="0" size="8" default="1" rwmask="0" mode="RW" name="cmosis_exp_seq"/>
- <register address="56" offset="0" size="24" default="1088" rwmask="0" mode="RW" name="cmosis_exp_time2"/>
- <register address="59" offset="0" size="24" default="1088" rwmask="0" mode="RW" name="cmosis_exp_step2"/>
- <register address="68" offset="0" size="2" default="1" rwmask="0" mode="RW" name="cmosis_nr_slopes2"/>
- <register address="69" offset="0" size="8" default="1" rwmask="0" mode="RW" name="cmosis_exp_seq2"/>
- <register address="70" offset="0" size="16" default="1" rwmask="0" mode="RW" name="cmosis_number_frames"/>
- <register address="72" offset="0" size="2" default="0" rwmask="0" mode="RW" name="cmosis_output_mode"/>
- <register address="78" offset="0" size="12" default="85" rwmask="0" mode="RW" name="cmosis_training_pattern"/>
- <register address="80" offset="0" size="18" default="0x3FFFF" rwmask="0" mode="RW" name="cmosis_channel_en"/>
- <register address="82" offset="0" size="3" default="7" rwmask="0" mode="RW" name="cmosis_special_82"/>
- <register address="89" offset="0" size="8" default="96" rwmask="0" mode="RW" name="cmosis_vlow2"/>
- <register address="90" offset="0" size="8" default="96" rwmask="0" mode="RW" name="cmosis_vlow3"/>
- <register address="100" offset="0" size="14" default="16260" rwmask="0" mode="RW" name="cmosis_offset"/>
- <register address="102" offset="0" size="2" default="0" rwmask="0" mode="RW" name="cmosis_pga"/>
- <register address="103" offset="0" size="8" default="32" rwmask="0" mode="RW" name="cmosis_adc_gain"/>
- <register address="111" offset="0" size="1" default="1" rwmask="0" mode="RW" name="cmosis_bit_mode"/>
- <register address="112" offset="0" size="2" default="0" rwmask="0" mode="RW" name="cmosis_adc_resolution"/>
- <register address="115" offset="0" size="1" default="1" rwmask="0" mode="RW" name="cmosis_special_115"/>
- </bank>
-</model>
diff --git a/xml/test/props.xml b/xml/test/props.xml
index 57702e2..dc08cbe 100644
--- a/xml/test/props.xml
+++ b/xml/test/props.xml
@@ -3,4 +3,9 @@
<transform path="/test/prop1" register="test_prop1" unit="C" read_from_register="(503975./1024000)*${/registers/fpga/sensor_temperature:C} - 27315./100" description="formula to get real fpga temperature from the fpga_temperature register in decimal"/>
<transform path="/test/prop2" register="test_prop2" unit="C" script="test_prop2.py" description="test python script #1" write_verification="0" />
<transform path="/test/prop3" register="test_prop3" 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/test_prop_mt.py b/xml/test/test_prop_mt.py
new file mode 100644
index 0000000..f8c63d0
--- /dev/null
+++ b/xml/test/test_prop_mt.py
@@ -0,0 +1,24 @@
+import time
+import threading
+lock = threading.Lock()
+
+def read_from_register(ctx, value):
+ with lock:
+ ctx.lock('lock5')
+
+ 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('lock5')
+
+ return out
+
+
+read_from_register.counter = 0
+
+def write_to_register(ctx, value):
+ with lock:
+ ctx.set_property(value*2, '/test/prop3')