From de39b1d6c78d7572008423cccc1e48abc1013422 Mon Sep 17 00:00:00 2001 From: Robert Jensen Date: Thu, 8 May 2025 14:33:14 +0200 Subject: [PATCH 1/5] Teach databasebackend to separate between as_function_of's --- sym-files2/databasebackend.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/sym-files2/databasebackend.py b/sym-files2/databasebackend.py index c312bd1..ace6575 100755 --- a/sym-files2/databasebackend.py +++ b/sym-files2/databasebackend.py @@ -347,6 +347,16 @@ def _plugin_single(self, name, settings, sys, plugins): return outstr def _as_function_of(self): + # If several as_function_of's are defined, func_type will tell which one + # - in the legacy case of only one, func type will just be the default + # value and not match a key - root key is (which is the only one in + # the classic case) is then used + func_type = self.o['as_function_of'] + if func_type in self.ggs['as_function_of']: + settings = self.ggs['as_function_of'][func_type] + else: + settings = self.ggs['as_function_of'] + # Get the datetime of the measurement for dat in self.data['left'] + self.data['right']: query = ('SELECT {0} FROM {1} where id = {2}' @@ -358,7 +368,7 @@ def _as_function_of(self): # Fetch all sets of id and label that is from the same time query = ('SELECT id, {0} FROM {1} WHERE TIME = \"{2}\"' - ''.format(self.ggs['as_function_of']['column'], + ''.format(settings['column'], self.ggs['measurements_table'], timestamp.strftime("%Y-%m-%d %H:%M:%S"))) measurements = self._result_from_query(query) @@ -367,8 +377,7 @@ def _as_function_of(self): # e.g.: "temperature" new_x_id = None for measurement in measurements: - search = re.search(self.ggs['as_function_of']['reg_match'], - measurement[1]) + search = re.search(settings['reg_match'], measurement[1]) try: if len(search.group(0)) > 0: new_x_id = measurement[0] @@ -379,7 +388,7 @@ def _as_function_of(self): if new_x_id: # Change the x-axis label self.data['data_treatment']['xlabel'] =\ - self.ggs['as_function_of']['xlabel'] + settings['xlabel'] # Fetch the pertaining temperature data new_x = self.__get_data_xyplot_single(new_x_id) """ Assumes both dat and new_x contains a common From 96ff1010e1e1cddf508eba07ea3fa789c3cf7107 Mon Sep 17 00:00:00 2001 From: Robert Jensen Date: Thu, 8 May 2025 14:41:04 +0200 Subject: [PATCH 2/5] The handle the special case that as-function-of is not always bool --- sym-files2/plot.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sym-files2/plot.py b/sym-files2/plot.py index 017ede3..9cc450f 100755 --- a/sym-files2/plot.py +++ b/sym-files2/plot.py @@ -85,6 +85,10 @@ def __init__(self): for pair in options.boolean_options.split(',')[1:]: key, value = pair.split(':') self.o[key] = True if value == 'checked' else False + if key == 'as_function_of': + if value: + self.o['as_function_of'] = value + # Parse bounds bkeys = [s + '_bounding' for s in ['xscale', 'left_yscale', 'right_yscale']] for bound in bkeys: From 504f39a1cb44071000e5a8cba17afa6fd1c177ed Mon Sep 17 00:00:00 2001 From: Robert Jensen Date: Tue, 20 May 2025 11:45:21 +0200 Subject: [PATCH 3/5] Allow export_data to understand multiple as_function_of's --- sym-files2/export_data.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sym-files2/export_data.py b/sym-files2/export_data.py index 765d866..72c930c 100755 --- a/sym-files2/export_data.py +++ b/sym-files2/export_data.py @@ -59,6 +59,10 @@ def __init__(self): for pair in options.boolean_options.split(',')[1:]: key, value = pair.split(':') self.o[key] = True if value == 'checked' else False + if key == 'as_function_of': + if value: + self.o['as_function_of'] = value + # Parse bounds bkeys = [s + '_bounding' for s in ['xscale', 'left_yscale', 'right_yscale']] for bound in bkeys: @@ -168,7 +172,7 @@ def _print_out_header_xy_data(self, data): for n, d in enumerate(data['left'] + data['right']): # Only make output if the current warning key is present in the # current datasets graphsettings - if d['lgs'].has_key(warning): + if warning in d['lgs']: out += ['"' + warning + '"', '"' + d['lgs'][warning] + '"'] else: out += ['', ''] From caa259b0a9f433b5e0270359c6ae041138e8f90c Mon Sep 17 00:00:00 2001 From: Robert Jensen Date: Tue, 20 May 2025 11:49:21 +0200 Subject: [PATCH 4/5] Almost-functional version of xyplot The current version has an error, this will be fixed real-soon-now(tm) --- sym-files2/xyplot.php | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/sym-files2/xyplot.php b/sym-files2/xyplot.php index f990799..5e2683c 100755 --- a/sym-files2/xyplot.php +++ b/sym-files2/xyplot.php @@ -53,7 +53,7 @@ $matplotlib = isset($_GET["matplotlib"]) ? "checked" : ""; $plot_options = isset($_GET["plot_options"]) ? "checked" : ""; $flip_x = isset($_GET["flip_x"]) ? "checked" : ""; -$as_function_of = isset($_GET["as_function_of"]) ? "checked" : ""; +$as_function_of = isset($_GET["as_function_of"]) ? $_GET["as_function_of"] : ""; $diff_left_y = isset($_GET["diff_left_y"]) ? "checked" : ""; $diff_right_y = isset($_GET["diff_right_y"]) ? "checked" : ""; $linscale_x0 = isset($_GET["linscale_x0"]) ? "checked" : ""; @@ -246,8 +246,23 @@ function microtime_float() echo($settings["flip_x"]["gui"] . "
"); } if(in_array("as_function_of",array_keys($settings)) == "1"){ - echo($settings["as_function_of"]["gui"] . "
"); + $checked = ""; + if ($as_function_of == 'default'){ + $checked = "checked"; + } + echo($settings["as_function_of"]["gui"] . "
"); + } + # WARNING - THIS NEEDS TO BY CHECKED AND FIXED !!!!! THE OUTER IF IS ENDED TOO SOON! + foreach ($settings["as_function_of"] as $key => $value){ + if (is_array($value)){ + $checked = ""; + if ($as_function_of == $key){ + $checked = "checked"; + } + echo($value["gui"] . "
"); + } } + if(in_array("diff_left_y",array_keys($settings)) == "1"){ echo($settings["diff_left_y"]["gui"] . "
"); } From 83f64f823bbe6bfcd7905b3426a039e4b8c57969 Mon Sep 17 00:00:00 2001 From: Robert Jensen Date: Thu, 12 Jun 2025 08:57:46 +0200 Subject: [PATCH 5/5] Removed warning, the code seems to be ok --- sym-files2/xyplot.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/sym-files2/xyplot.php b/sym-files2/xyplot.php index 5e2683c..f6c2b1d 100755 --- a/sym-files2/xyplot.php +++ b/sym-files2/xyplot.php @@ -237,14 +237,15 @@ function microtime_float() } else { $show_plot_options = "display:none"; } - ?> - -
- + +
+
"); } + if(in_array("as_function_of",array_keys($settings)) == "1"){ $checked = ""; if ($as_function_of == 'default'){ @@ -252,7 +253,6 @@ function microtime_float() } echo($settings["as_function_of"]["gui"] . "
"); } - # WARNING - THIS NEEDS TO BY CHECKED AND FIXED !!!!! THE OUTER IF IS ENDED TOO SOON! foreach ($settings["as_function_of"] as $key => $value){ if (is_array($value)){ $checked = "";