Compare commits
2 Commits
d0076f336d
...
f46a43d7fd
| Author | SHA1 | Date |
|---|---|---|
|
|
f46a43d7fd | |
|
|
84e99365f7 |
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
|
@ -20,7 +20,7 @@ import getopt
|
||||||
import re
|
import re
|
||||||
import json
|
import json
|
||||||
|
|
||||||
__version__ = "0.2"
|
__version__ = "0.3"
|
||||||
|
|
||||||
def detect_pages(filename):
|
def detect_pages(filename):
|
||||||
# returns a dictionary with page name and the number of gui fields
|
# returns a dictionary with page name and the number of gui fields
|
||||||
|
|
@ -87,6 +87,11 @@ def create_json(device, no_of_pages, pagedata):
|
||||||
output = []
|
output = []
|
||||||
|
|
||||||
for page_no in range(1, no_of_pages + 1):
|
for page_no in range(1, no_of_pages + 1):
|
||||||
|
|
||||||
|
category = f"{device.upper()} Page {page_no}"
|
||||||
|
capabilities = {device.lower(): "true"}
|
||||||
|
visiblepages = [str(vp) for vp in range(page_no, no_of_pages + 1)]
|
||||||
|
|
||||||
page_data = {
|
page_data = {
|
||||||
"name": f"page{page_no}type",
|
"name": f"page{page_no}type",
|
||||||
"label": "Type",
|
"label": "Type",
|
||||||
|
|
@ -94,9 +99,11 @@ def create_json(device, no_of_pages, pagedata):
|
||||||
"default": get_default_page(page_no),
|
"default": get_default_page(page_no),
|
||||||
"description": f"Type of page for page {page_no}",
|
"description": f"Type of page for page {page_no}",
|
||||||
"list": pages,
|
"list": pages,
|
||||||
"category": f"{device.upper()} Page {page_no}",
|
"category": category,
|
||||||
"capabilities": {device.lower(): "true"},
|
"capabilities": {device.lower(): "true"},
|
||||||
"condition": [{"visiblePages": vp} for vp in range(page_no, no_of_pages + 1)],
|
"condition": {
|
||||||
|
"visiblePages": visiblepages
|
||||||
|
},
|
||||||
#"fields": [],
|
#"fields": [],
|
||||||
}
|
}
|
||||||
output.append(page_data)
|
output.append(page_data)
|
||||||
|
|
@ -108,13 +115,12 @@ def create_json(device, no_of_pages, pagedata):
|
||||||
"type": "boatData",
|
"type": "boatData",
|
||||||
"default": "",
|
"default": "",
|
||||||
"description": "The display for field {}".format(number_to_text(field_no)),
|
"description": "The display for field {}".format(number_to_text(field_no)),
|
||||||
"category": f"{device.upper()} Page {page_no}",
|
"category": category,
|
||||||
"capabilities": {device.lower(): "true"},
|
"capabilities": capabilities,
|
||||||
"condition": [
|
"condition": {
|
||||||
{f"page{page_no}type": page}
|
f"page{page_no}type": [ p for p in pages if pagedata[p] >= field_no ]
|
||||||
for page in pages
|
,"visiblePages": visiblepages
|
||||||
if pagedata[page] >= field_no
|
}
|
||||||
],
|
|
||||||
}
|
}
|
||||||
output.append(field_data)
|
output.append(field_data)
|
||||||
|
|
||||||
|
|
@ -133,14 +139,35 @@ def create_json(device, no_of_pages, pagedata):
|
||||||
{"l":"Fuel Gasoline (6)","v":"6"}
|
{"l":"Fuel Gasoline (6)","v":"6"}
|
||||||
],
|
],
|
||||||
"description": "Fluid type in tank",
|
"description": "Fluid type in tank",
|
||||||
"category": f"{device.upper()} Page {page_no}",
|
"category": category,
|
||||||
"capabilities": {
|
"capabilities": capabilities,
|
||||||
device.lower(): "true"
|
"condition": {
|
||||||
},
|
f"page{page_no}type": "Fluid",
|
||||||
"condition":[{f"page{page_no}type":"Fluid"}]
|
"visiblePages": visiblepages
|
||||||
|
}
|
||||||
}
|
}
|
||||||
output.append(fluid_data)
|
output.append(fluid_data)
|
||||||
|
|
||||||
|
if device.upper() == 'OBP40':
|
||||||
|
windsource = {
|
||||||
|
"name": f"page{page_no}wndsrc",
|
||||||
|
"label": "Wind source",
|
||||||
|
"type": "list",
|
||||||
|
"default": "True wind",
|
||||||
|
"description": f"Wind source for page {page_no}: [true|apparent]",
|
||||||
|
"list": [
|
||||||
|
"True wind",
|
||||||
|
"Apparant wind"
|
||||||
|
],
|
||||||
|
"category": category,
|
||||||
|
"capabilities": capabilities,
|
||||||
|
"condition": {
|
||||||
|
f"page{page_no}type": "WindPlot",
|
||||||
|
"visiblePages": visiblepages
|
||||||
|
}
|
||||||
|
}
|
||||||
|
output.append(windsource)
|
||||||
|
|
||||||
return json.dumps(output, indent=4)
|
return json.dumps(output, indent=4)
|
||||||
|
|
||||||
def usage():
|
def usage():
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue