4
4
<title>{% block title %}Device {{ device }}{% endblock %}</title>
5
5
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
6
6
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
7
<link rel="stylesheet" type="text/css" href="codebase/dhtmlx.css"/>
7
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='codebase/dhtmlx.css') }}"/>
8
8
<script type=text/javascript src="{{ url_for('static', filename='jquery-2.2.1.js') }}"></script>
9
<script src="codebase/dhtmlx.js"></script>
10
<script src="pcilib_tree.js"></script>
9
<script src="{{ url_for('static', filename='codebase/dhtmlx.js') }}"></script>
10
<script src="{{ url_for('static', filename='check_err.js') }}"></script>
14
function checkError(json)
17
alert('Error:\n' + json.error)
20
function createPropertyTree(branch, id)
22
function getPropertyItemsOnLevel(branch, id)
13
function createPropertyTree(branch, id) {
15
function getPropertyItemsOnLevel(branch, id) {
24
16
pathToProperties = "{{ url_for('get_property_list_json') }}"
25
17
completePath = pathToProperties + '?branch=' + branch
27
19
$.getJSON(completePath,
30
parsePropertyItems(json, branch, id)
22
parsePropertyItems(json, branch, id)
34
function parsePropertyItems(json, branch, id)
36
function updatePropertyValue(id, path)
38
pathToGetProperty = "{{ url_for('get_property_json') }}"
39
completePath = pathToGetProperty + '?prop=' + path
41
$.getJSON(completePath, function(json){
43
propsTree.updateItem(id, 'value: ' + json.value);
47
function writePropertyValue(id, path)
49
value = window.prompt("Enter new property value");
53
pathToGetProperty = "{{ url_for('set_property_json') }}"
54
completePath = pathToGetProperty + '?prop=' + path +'&val=' + value
56
$.getJSON(completePath,
59
updatePropertyValue(id, path)
63
updatePropertyValue(id, path)
66
function setCurrentValueField(id, path, mode)
68
var propValId = id + 'CurrVal'
72
func = function(){writePropertyValue(propValId, path)}
74
func = function(){updatePropertyValue(propValId, path)}
76
propsTree.insertNewItem(id, propValId,
80
updatePropertyValue(propValId, path)
83
for(var i = 0; i < json.length; i++)
85
propsTree.insertNewItem(id, json[i].path, json[i].name, 0);
26
function parsePropertyItems(json, branch, id) {
28
function loadPropertyInfo(branch) {
30
var pathToProperties = "{{ url_for('get_property_list') }}"
31
var completePath = pathToProperties + '?branch=' + branch
33
$("#prop_info_place").load(completePath)
37
function setPropertyField(id, name, branch) {
39
var func = function(){loadPropertyInfo(branch)}
40
propsTree.insertNewItem(id, branch,
43
propsTree.closeAllItems()
46
for(var i = 0; i < json.length; i++) {
48
setPropertyField(id, json[i].name, json[i].path)
87
49
if(json[i].flags.indexOf("childs") != -1)
89
50
getPropertyItemsOnLevel(json[i].path, json[i].path)
93
if(json[i].mode.indexOf("R") != -1)
95
var mode = (json[i].mode.indexOf("W") != -1)
96
setCurrentValueField(json[i].path, json[i].path, mode)
101
if(json[i].description)
102
propsTree.insertNewItem(json[i].path, json[i].path + 'Desc',
103
'description:\n' + json[i].description, 0);
105
propsTree.insertNewItem(json[i].path, json[i].path + 'Type',
106
'type: ' + json[i].type, 0);
108
propsTree.insertNewItem(json[i].path, json[i].path + 'Unit',
109
'unit: ' + json[i].unit, 0);
113
var modeId = json[i].path + 'Mode'
114
propsTree.insertNewItem(json[i].path, modeId,
117
for(var j = 0; j < json[i].mode.length; j++)
118
propsTree.insertNewItem(modeId, modeId + j,
120
propsTree.closeItem(modeId)
124
propsTree.insertNewItem(json[i].path, json[i].path + 'Path',
125
'path: ' + json[i].path, 0);
127
propsTree.closeItem(json[i].path);
131
54
getPropertyItemsOnLevel(branch, id)
135
function createRegistersList()
137
function parseJsonRegisterList(json)
58
function createRegistersList() {
59
function parseJsonRegisterList(json) {
141
function compareRegistersByBank(a,b)
65
//sort registers by bank
66
function compareRegistersByBank(a,b) {
143
67
if (a.bank < b.bank)
145
69
else if (a.bank > b.bank)
154
//sort registers by bank
155
74
json.sort(compareRegistersByBank)
157
77
//create bank dirs
158
78
var curBankName = json[0].bank
160
for(var i = 0; i < json.length; i++)
80
for(var i = 0; i < json.length; i++) {
162
82
//create new bank tab if it has not created already
163
if(json[i].bank != curBankName)
83
if(json[i].bank != curBankName) {
165
84
curBankName = json[i].bank
170
89
regTree.insertNewItem(0, json[i].bank, json[i].bank, 0);
174
94
//insert register info to bank
175
var itemId = json[i].bank + "_" + json[i].name
176
regTree.insertNewItem(json[i].bank, itemId, json[i].name)
178
function updateRegisterValue(id, bank, name)
180
pathToGetProperty = "{{ url_for('read_register_json') }}"
181
completePath = pathToGetProperty + '?bank=' + bank +
95
function loadRegisterInfo(bank, name) {
96
var pathToGetProperty = "{{ url_for('get_register_info') }}"
97
var completePath = pathToGetProperty + '?bank=' + bank +
184
$.getJSON(completePath, function(json){
186
regTree.updateItem(id, 'value: ' + json.value);
191
function writeRegisterValue(id, bank, name)
193
value = window.prompt("Enter new register value");
197
pathToGetProperty = "{{ url_for('write_register_json') }}"
198
completePath = pathToGetProperty + '?bank=' + bank +
199
'&name=' + name + '&val=' + value;
201
$.getJSON(completePath,
204
updateRegisterValue(id, bank, name)
208
updateRegisterValue(id, bank, name)
211
function setCurrentValueField(id, bank, name, mode)
213
var regValId = id + 'CurrVal'
217
func = function(){writeRegisterValue(regValId, bank, name)}
219
func = function(){updateRegisterValue(regValId, bank, name)}
221
regTree.insertNewItem(id, regValId,
224
updateRegisterValue(regValId, bank, name)
227
if(json[i].mode.indexOf("R") != -1)
229
var mode = (json[i].mode.indexOf("W") != -1)
230
setCurrentValueField(itemId, json[i].bank, json[i].name, mode)
234
if(json[i].description)
235
regTree.insertNewItem(itemId, itemId + 'Desc',
236
'description:\n' + json[i].description, 0);
238
regTree.insertNewItem(itemId, itemId + 'Defvalue',
239
'defvalue: ' + json[i].defvalue, 0);
243
var modeId = itemId + 'Mode'
244
regTree.insertNewItem(itemId, modeId,
247
for(var j = 0; j < json[i].mode.length; j++)
248
regTree.insertNewItem(modeId, modeId + j,
250
regTree.closeItem(modeId)
255
var rangeId = itemId + 'Range'
256
regTree.insertNewItem(itemId, rangeId,
258
regTree.insertNewItem(rangeId, rangeId + 'Min',
259
'min: ' + json[i].range.min, 0);
260
regTree.insertNewItem(rangeId, rangeId + 'Max',
261
'max: ' + json[i].range.max, 0);
262
regTree.closeItem(rangeId)
267
var valuesId = itemId + 'Values'
268
regTree.insertNewItem(itemId, valuesId,
271
function addValueInfo(valuesId, value)
273
var valueId = valuesId + value.name
274
regTree.insertNewItem(valuesId, valueId, value.name, 0);
276
if(value.description)
277
regTree.insertNewItem(valueId, valueId + 'Desc',
278
'description: ' + value.description, 0);
280
regTree.insertNewItem(valueId, valueId + 'Value',
281
'value: ' + value.value, 0);
283
regTree.insertNewItem(valueId, valueId + 'Min',
284
'min: ' + value.min, 0);
286
regTree.insertNewItem(valueId, valueId + 'Max',
287
'max: ' + value.max, 0);
290
for(var j = 0; j < json[i].values.length; j++)
292
addValueInfo(valuesId, json[i].values[j])
294
regTree.closeItem(valuesId)
297
propsTree.closeItem(json[i].path);
299
regTree.closeItem(itemId);
100
$("#reg_info_place").load(completePath)
103
function setRegisterField(id, bank, name) {
105
var itemId = bank + "_" + name
106
var func = function(){loadRegisterInfo(bank, name)}
108
regTree.insertNewItem(id, itemId, name, func)
109
regTree.closeAllItems()
112
setRegisterField(json[i].bank, json[i].bank, json[i].name)
321
134
<body onload="doOnLoad()">
323
<h2>Device {{ device }} model={{ model }} control page </h2>
136
<div class="block1" >
137
<h2>Device {{ device }} model={{ model }} control page </h2>
142
.tabs > div, .tabs > input { display: none; }
146
border: 1px solid #aaa;
154
.tabs input[type="radio"]:checked + label { border-bottom: 2px solid #fff; }
156
.tabs > input:nth-of-type(1):checked ~ div:nth-of-type(1),
157
.tabs > input:nth-of-type(2):checked ~ div:nth-of-type(2) {
166
border: 1px solid #aaa;
178
border: 1px solid #aaa;
191
<input type="radio" name="current" checked="checked" id="props_id"/>
192
<label for="props_id">Properties</label>
193
<input type="radio" name="current" id="labels_id"/>
194
<label for="labels_id">Registers</label>
199
<div id="treeboxbox_tree" class = "tree"></div>
201
<td valign="top" id="prop_info_place" />
209
<div id="treeboxbox_tree2" class="tree"></div>
211
<td valign="top" id="reg_info_place" />
326
216
{% block content %}
331
<h3>Properties Tree</h3>
334
<h3>Registers Tree</h3>
339
<div id="treeboxbox_tree" style="background-color:#f5f5f5;border :1px solid Silver; overflow:auto;"></div>
342
<div id="treeboxbox_tree2" style="background-color:#f5f5f5;border :1px solid Silver; overflow:auto;"></div>