Compare commits

..

No commits in common. "f46a43d7fd79020ec6b9d4cae46fc341d3614fc5" and "d0076f336d395de8cbd0e30e4a85a34f4c38e6e0" have entirely different histories.

3 changed files with 2710 additions and 2526 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -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,59 +108,39 @@ 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",
"default": "0", "default": "0",
"list": [ "list": [
{"l":"Fuel (0)","v":"0"}, {"l":"Fuel (0)","v":"0"},
{"l":"Water (1)","v":"1"}, {"l":"Water (1)","v":"1"},
{"l":"Gray Water (2)","v":"2"}, {"l":"Gray Water (2)","v":"2"},
{"l":"Live Well (3)","v":"3"}, {"l":"Live Well (3)","v":"3"},
{"l":"Oil (4)","v":"4"}, {"l":"Oil (4)","v":"4"},
{"l":"Black Water (5)","v":"5"}, {"l":"Black Water (5)","v":"5"},
{"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():