From e2550e6df11558ccd6e8b95f489c0988b34347af Mon Sep 17 00:00:00 2001 From: Vasilii Chernov Date: Fri, 26 Feb 2016 10:19:58 +0100 Subject: 1. pywrap: - fix get_registers_list crash with bank != NULL - set correct python version in cmake install step 2. html_server: - merge set and get value boxes into one box - add registers bank view mode - read registers/properties values in bank/branch view mode 3. xml/test - remove cmosis registers - add multithread safe property example --- html_server/html_server.py | 43 ++++-- html_server/static/check_err.js | 4 + html_server/templates/base.html | 54 +++++--- html_server/templates/property_info.html | 30 ++--- html_server/templates/register_info.html | 145 +-------------------- html_server/templates/registers/table_cell.html | 99 ++++++++++++++ html_server/templates/registers/table_header.html | 9 ++ html_server/templates/registers/table_scripts.html | 42 ++++++ html_server/templates/registers_list.html | 24 +--- 9 files changed, 242 insertions(+), 208 deletions(-) create mode 100644 html_server/static/check_err.js create mode 100644 html_server/templates/registers/table_cell.html create mode 100644 html_server/templates/registers/table_header.html create mode 100644 html_server/templates/registers/table_scripts.html (limited to 'html_server') diff --git a/html_server/html_server.py b/html_server/html_server.py index 2e0af72..dba24e9 100644 --- a/html_server/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,18 +162,26 @@ 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, branch = branch, - properties = prop_info + properties = prop_info, + json = json ) @app.route("/") @@ -187,8 +210,6 @@ if __name__ == "__main__": device = opts.device model = opts.model - app.debug = True - pcilib = pcipywrap.Pcipywrap(device, model) pcipywrap.__redirect_logs_to_exeption() app.run(host = HOST_NAME, port = PORT_NUMBER) 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/html_server/templates/base.html b/html_server/templates/base.html index 639dc00..39f8d00 100644 --- a/html_server/templates/base.html +++ b/html_server/templates/base.html @@ -58,6 +58,37 @@ 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 @@ -86,28 +117,12 @@ } if(!created) { - regTree.insertNewItem(0, json[i].bank, json[i].bank, 0); + setbankField(json[i].bank ) created = 1 } //insert register info to bank - function loadRegisterInfo(bank, name) { - var pathToGetProperty = "{{ url_for('get_register_info') }}" - var completePath = pathToGetProperty + '?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() - } setRegisterField(json[i].bank, json[i].bank, json[i].name) } @@ -121,12 +136,12 @@ function doOnLoad() { propsTree = new dhtmlXTreeObject("treeboxbox_tree","100%","100%",0); - propsTree.setImagePath("codebase/imgs/dhxtree_skyblue/"); + 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("codebase/imgs/dhxtree_skyblue/"); + regTree.setImagePath("{{ url_for('static', filename='codebase/imgs/dhxtree_skyblue/') }}"); createRegistersList() } @@ -137,7 +152,6 @@

Device {{ device }} model={{ model }} control page

{% endblock %} -