From dfc79c80dc6e2baf9f96064c686014780dafbc9e Mon Sep 17 00:00:00 2001 From: Tobias E Date: Sun, 12 Jan 2025 21:40:39 +0000 Subject: [PATCH 1/4] Add SixValues and fix Fluid in gen_set.py --- lib/obp60task/gen_set.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/obp60task/gen_set.py b/lib/obp60task/gen_set.py index d0ff7e5..a0f7b6d 100755 --- a/lib/obp60task/gen_set.py +++ b/lib/obp60task/gen_set.py @@ -5,14 +5,14 @@ import json # List of all pages and the number of parameters they expect. no_of_fields_per_page = { - "ApparentWind": 0, + "Wind": 0, "XTETrack": 0, "Battery2": 0, "Battery": 0, "BME280": 0, "Clock": 0, "DST810": 0, - "Fluid": 0, + "Fluid": 1, "FourValues2": 4, "FourValues": 4, "Generator": 0, @@ -27,6 +27,7 @@ no_of_fields_per_page = { "White": 0, "WindRose": 0, "WindRoseFlex": 6, + "SixValues" : 6, } # No changes needed beyond this point From 24386d4d4274fd3742d30a81be7e672233c8fa39 Mon Sep 17 00:00:00 2001 From: Tobias E Date: Fri, 17 Jan 2025 19:23:26 +0000 Subject: [PATCH 2/4] add explanation to gen_set.py --- lib/obp60task/gen_set.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/obp60task/gen_set.py b/lib/obp60task/gen_set.py index a0f7b6d..c848a91 100755 --- a/lib/obp60task/gen_set.py +++ b/lib/obp60task/gen_set.py @@ -1,5 +1,9 @@ #!/usr/bin/env python3 # A tool to generate that part of config.json that deals with pages and fields. +# +#Usage: 1. modify this script (e.g.add a page, change number of fields, etc.) +# 2. Delete all lines from config.json from the curly backet before "name": "page1type" to o the end of the file (as of today, delete from line 917 to the end of the File) +# 3. run ./gen_set.py >> config.json import json @@ -120,5 +124,5 @@ for page_no in range(1, no_of_pages + 1): json_output = json.dumps(output, indent=4) # print omitting first and last line containing [ ] of JSON array -print(json_output[1:-1]) +print(json_output[1:]) # print(",") \ No newline at end of file From 10552763fbc3b485ff1581aa73492968eed1097d Mon Sep 17 00:00:00 2001 From: Tobias E Date: Fri, 17 Jan 2025 19:24:16 +0000 Subject: [PATCH 3/4] add explanation to gen_set.py --- lib/obp60task/gen_set.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/obp60task/gen_set.py b/lib/obp60task/gen_set.py index c848a91..bf40b6c 100755 --- a/lib/obp60task/gen_set.py +++ b/lib/obp60task/gen_set.py @@ -124,5 +124,7 @@ for page_no in range(1, no_of_pages + 1): json_output = json.dumps(output, indent=4) # print omitting first and last line containing [ ] of JSON array +#print(json_output[1:-1]) +# print omitting first line containing [ of JSON array print(json_output[1:]) # print(",") \ No newline at end of file From 27b02c4860a84cbec4e3453c8ace1d1b5d7815ac Mon Sep 17 00:00:00 2001 From: Tobias E Date: Sat, 18 Jan 2025 13:59:37 +0000 Subject: [PATCH 4/4] removed obsolete perl script gen_set.pl --- lib/obp60task/Create_new_pages.txt | 2 +- lib/obp60task/gen_set.pl | 112 ----------------------------- 2 files changed, 1 insertion(+), 113 deletions(-) delete mode 100755 lib/obp60task/gen_set.pl diff --git a/lib/obp60task/Create_new_pages.txt b/lib/obp60task/Create_new_pages.txt index 5ad71fd..b318985 100644 --- a/lib/obp60task/Create_new_pages.txt +++ b/lib/obp60task/Create_new_pages.txt @@ -2,5 +2,5 @@ Craete new page for OBP60 1. Create page under /lib/obp60task/PageXXXX.cpp 2. Set page name in PageXXXX.cpp on file name 3. Register new page in /lib/obp60task/obp60task.cpp line 242 (registerAllPages) -4. Add new page in /lib/obp60task/config.json for each page type or add new page to gen_set.pl and run it to auto-generate the relevant section of config.json +4. Add new page in /lib/obp60task/config.json for each page type or add new page to gen_set.py and run it to auto-generate the relevant section of config.json diff --git a/lib/obp60task/gen_set.pl b/lib/obp60task/gen_set.pl deleted file mode 100755 index 3c74904..0000000 --- a/lib/obp60task/gen_set.pl +++ /dev/null @@ -1,112 +0,0 @@ -#!/bin/perl -w -#A tool to generate the part of config.json that deals with pages and fields. -#DEPRECATED, moved to get_set.py -die "Please use gen_set.py instead"; -#List of all pages and the number of parameters they expect. -%NoOfFieldsPerPage=qw( - ApparentWind 0 - XTETrack 0 - Battery2 0 - Battery 0 - BME280 0 - Clock 0 - DST810 0 - FourValues2 4 - FourValues 4 - Generator 0 - KeelPosition 0 - OneValue 1 - RollPitch 0 - RudderPosition 0 - Solar 0 - ThreeValues 3 - TwoValues 2 - Voltage 0 - White 0 - WindRose 0 - WindRoseFlex 6 - ); -# No changes needed beyond this point -#max number of pages supported by OBP60 -$NoOfPages=10; -#Default selection for each page -@Defaults=qw(Voltage WindRose OneValue TwoValues ThreeValues FourValues FourValues2 Clock RollPitch Battery2); -@Numbers=qw(one two three four five six seven eight nine ten); -@Pages=sort(keys(%NoOfFieldsPerPage)); -$MaxNoOfFieldsPerPage=0; # inital value, gets updated with maximum entry from %NoOfFieldsPerPage - - -#find max. number of fields without additional modules - foreach (values(%NoOfFieldsPerPage)){ - if ($_ > $MaxNoOfFieldsPerPage){ - $MaxNoOfFieldsPerPage=$_; - } - } - -for ($PageNo=1;$PageNo<=$NoOfPages;$PageNo++){ - print "{\n"; - print "\t","\"name\": \"page", $PageNo,"type\",\n"; - print "\t","\"label\": \"Type\",\n"; - print "\t",'"type": "list",',"\n"; - print "\t",'"default": "'; - print "$Defaults[$PageNo-1]"; - print'"',"\n"; - print "\t",'"description": "Type of page for page ',$PageNo,'",',"\n"; - print "\t",'"list": ['; - for ($p=0;$p<=$#Pages;$p++) { - print '"', $Pages[$p], '"' ; - if ($p < $#Pages){print ","} - } - print "]\n"; - print "\t",'"category": "OBP60 Page ',$PageNo,'",',"\n"; - print "\t",'"capabilities": {',"\n"; - print "\t\t",'"obp60":"true"',"\n"; - print "\t",'}',"\n"; - print "\t",'"condition":['; - for ($vp=$PageNo;$vp<=$NoOfPages;$vp++){ - print '"{visiblePages":"',$vp,'"},'; - } - print "\b",']',"\n"; - print '},',"\n"; - for ($FieldNo=1; $FieldNo<=$MaxNoOfFieldsPerPage;$FieldNo++){ - print "{\n"; - print "\t",'"name": "page',$PageNo,'value',$FieldNo,'",',"\n"; - print "\t",'"label": "Field ',$FieldNo,'",',"\n"; - print "\t",'"type": "boatData",',"\n"; - print "\t",'"default": "",',"\n"; - print "\t",'"description": "The display for field ',$Numbers[$FieldNo-1],'",',"\n"; - print "\t",'"category": "OBP60 Page ',$PageNo,'",',"\n"; - print "\t",'"capabilities": {',"\n"; - print "\t",' "obp60":"true"',"\n"; - print "\t",'}, ',"\n"; - print "\t",'"condition":['; - foreach $page (@Pages) { - if($NoOfFieldsPerPage{$page}>=$FieldNo){ - print '{"page',$PageNo,'type":"',$page,'"},'; - } - } - print "\b],\n"; - print '},',"\n"; - } - print "{\n"; - print "\t","\"name\": \"page", $PageNo,"fluid\",\n"; - print "\t",'"label": "Fluid type",',"\n"; - print "\t",'"type": "list",',"\n"; - print "\t",'"default": "0",',"\n"; - print "\t",'"list": [',"\n"; - print "\t",'{"l":"Fuel (0)","v":"0"},',"\n"; - print "\t",'{"l":"Water (1)","v":"1"},',"\n"; - print "\t",'{"l":"Gray Water (2)","v":"2"},',"\n"; - print "\t",'{"l":"Live Well (3)","v":"3"},',"\n"; - print "\t",'{"l":"Oil (4)","v":"4"},',"\n"; - print "\t",'{"l":"Black Water (5)","v":"5"},',"\n"; - print "\t",'{"l":"Fuel Gasoline (6)","v":"6"}',"\n"; - print "\t",'],',"\n"; - print "\t",'"description": "Fluid type in tank",',"\n"; - print "\t",'"category": "OBP60 Page ',$PageNo,'",',"\n"; - print "\t",'"capabilities": {',"\n"; - print "\t",'"obp60":"true"',"\n"; - print "\t",'},',"\n"; - print "\t",'"condition":[{"page',$PageNo,'type":"Fluid"}]',"\n"; - print '},',"\n"; -}