Compare commits
No commits in common. "f46a43d7fd79020ec6b9d4cae46fc341d3614fc5" and "d0076f336d395de8cbd0e30e4a85a34f4c38e6e0" have entirely different histories.
f46a43d7fd
...
d0076f336d
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.3"
|
__version__ = "0.2"
|
||||||
|
|
||||||
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,11 +87,6 @@ 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",
|
||||||
|
|
@ -99,11 +94,9 @@ 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": category,
|
"category": f"{device.upper()} Page {page_no}",
|
||||||
"capabilities": {device.lower(): "true"},
|
"capabilities": {device.lower(): "true"},
|
||||||
"condition": {
|
"condition": [{"visiblePages": vp} for vp in range(page_no, no_of_pages + 1)],
|
||||||
"visiblePages": visiblepages
|
|
||||||
},
|
|
||||||
#"fields": [],
|
#"fields": [],
|
||||||
}
|
}
|
||||||
output.append(page_data)
|
output.append(page_data)
|
||||||
|
|
@ -115,16 +108,17 @@ 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": category,
|
"category": f"{device.upper()} Page {page_no}",
|
||||||
"capabilities": capabilities,
|
"capabilities": {device.lower(): "true"},
|
||||||
"condition": {
|
"condition": [
|
||||||
f"page{page_no}type": [ p for p in pages if pagedata[p] >= field_no ]
|
{f"page{page_no}type": page}
|
||||||
,"visiblePages": visiblepages
|
for page in pages
|
||||||
}
|
if pagedata[page] >= field_no
|
||||||
|
],
|
||||||
}
|
}
|
||||||
output.append(field_data)
|
output.append(field_data)
|
||||||
|
|
||||||
fluid_data = {
|
fluid_data ={
|
||||||
"name": f"page{page_no}fluid",
|
"name": f"page{page_no}fluid",
|
||||||
"label": "Fluid type",
|
"label": "Fluid type",
|
||||||
"type": "list",
|
"type": "list",
|
||||||
|
|
@ -139,35 +133,14 @@ 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": category,
|
"category": f"{device.upper()} Page {page_no}",
|
||||||
"capabilities": capabilities,
|
"capabilities": {
|
||||||
"condition": {
|
device.lower(): "true"
|
||||||
f"page{page_no}type": "Fluid",
|
},
|
||||||
"visiblePages": visiblepages
|
"condition":[{f"page{page_no}type":"Fluid"}]
|
||||||
}
|
|
||||||
}
|
}
|
||||||
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