Skip to content
Snippets Groups Projects
Commit a0dd4112 authored by Lan Dam's avatar Lan Dam
Browse files

Merge branch 'master' into i69-add-edit-single-channel-dialog

parents 045e0df7 b176fed0
No related branches found
No related tags found
1 merge request!211Implement dialog to add/edit a single channel in database
Pipeline #3214 passed with stage
in 3 minutes and 13 seconds
import re import re
import os
from pathlib import Path
from sohstationviewer.conf.constants import (WF_1ST, WF_2ND, WF_3RD) from sohstationviewer.conf.constants import (WF_1ST, WF_2ND, WF_3RD)
""" """
...@@ -42,3 +44,20 @@ dbConf = { ...@@ -42,3 +44,20 @@ dbConf = {
"If D is not defined, dots won't be displayed.\n" "If D is not defined, dots won't be displayed.\n"
"If L is not defined, lines will be plotted with color G")} "If L is not defined, lines will be plotted with color G")}
} }
def modify_db_path():
"""
Modify dbpath to absolute path.
This function is called in case database needs to be used when the working
directory is a sub folder of root, sohstationviewer/. The following lines
need to be added:
from sohstationviewer.conf.dbSettings import modify_db_path
modify_db_path()
"""
global dbConf
current_file_path = os.path.abspath(__file__)
root = Path(current_file_path).parent.parent
db_path = [x for x in root.glob('**/soh.db')][0]
dbConf['dbpath'] = db_path.as_posix()
...@@ -28,7 +28,7 @@ class ParamDialog(UiDBInfoDialog): ...@@ -28,7 +28,7 @@ class ParamDialog(UiDBInfoDialog):
self.require_valuecolors_plottypes = [ self.require_valuecolors_plottypes = [
p for p in plot_functions.keys() p for p in plot_functions.keys()
if 'ValueColors' in plot_functions[p][0]] if 'ValueColors' in plot_functions[p]['description']]
super().__init__( super().__init__(
parent, parent,
['No.', 'Param', 'Plot Type', 'ValueColors', 'Height '], ['No.', 'Param', 'Plot Type', 'ValueColors', 'Height '],
......
...@@ -32,4 +32,5 @@ class PlotTypeDialog(UiDBInfoDialog): ...@@ -32,4 +32,5 @@ class PlotTypeDialog(UiDBInfoDialog):
""" """
Get list of data to fill self.data_table_widgets' content Get list of data to fill self.data_table_widgets' content
""" """
return [[key, val[0]] for key, val in plot_functions.items()] return [[key, val['description']]
for key, val in plot_functions.items()]
...@@ -68,7 +68,8 @@ class SOHWidget(MultiThreadedPlottingWidget): ...@@ -68,7 +68,8 @@ class SOHWidget(MultiThreadedPlottingWidget):
return return
chan_db_info = c_data['chan_db_info'] chan_db_info = c_data['chan_db_info']
plot_type = chan_db_info['plotType'] plot_type = chan_db_info['plotType']
ax = getattr(self.plotting, plot_functions[plot_type][1])( ax = getattr(
self.plotting, plot_functions[plot_type]['plot_function'])(
c_data, chan_db_info, chan_id) c_data, chan_db_info, chan_id)
c_data['ax'] = ax c_data['ax'] = ax
ax.chan = chan_id ax.chan = chan_id
......
...@@ -49,7 +49,8 @@ class WaveformWidget(MultiThreadedPlottingWidget): ...@@ -49,7 +49,8 @@ class WaveformWidget(MultiThreadedPlottingWidget):
plot_type = chan_db_info['plotType'] plot_type = chan_db_info['plotType']
# refer to doc string for mass_pos_data to know the reason for 'ax_wf' # refer to doc string for mass_pos_data to know the reason for 'ax_wf'
ax = getattr(self.plotting, plot_functions[plot_type][1])( ax = getattr(
self.plotting, plot_functions[plot_type]['plot_function'])(
c_data, chan_db_info, chan_id) c_data, chan_db_info, chan_id)
c_data['ax_wf'] = ax c_data['ax_wf'] = ax
ax.chan = chan_id ax.chan = chan_id
......
plot_functions = { plot_functions = {
'linesDots': ( 'linesDots': {
"Lines, one color dots. Dot or line/color mapping defined by " "description": (
"ValueColors with available colors: RYGMCW.\n" "Lines, one color dots. Dot or line/color mapping defined by "
"Ex: L:G|D:W\n" "ValueColors with available colors: RYGMCW.\n"
" means \tLines are plotted with color G\n" "Ex: L:G|D:W\n"
"\tDots are plotted with color W\n" " means \tLines are plotted with color G\n"
"If D is not defined, dots won't be displayed.\n" "\tDots are plotted with color W\n"
"If L is not defined, lines will be plotted with color G", "If D is not defined, dots won't be displayed.\n"
"plot_lines_dots"), "If L is not defined, lines will be plotted with color G"),
'linesSRate': ( "plot_function": "plot_lines_dots"
"Lines, one color dots, bitweight info. ", },
"plot_lines_s_rate"), 'linesSRate': {
'linesMasspos': ( "description": "Lines, one color dots, bitweight info. ",
"multi-line mass position, multi-color dots. ", "plot_function": "plot_lines_s_rate"
"plot_lines_mass_pos"), },
'triColorLines': ( 'linesMasspos': {
"Three lines with three different colors for values -1, 0, 1.", "description": "multi-line mass position, multi-color dots. ",
"plot_tri_colors"), "plot_function": "plot_lines_mass_pos"
'dotForTime': ( },
"Dots according to timestamp.\n" 'triColorLines': {
"Color defined by ValueColors with available colors: RYGMCW.\n" "description": "Three lines with three different colors for "
"Ex: G", "values -1, 0, 1.",
"plot_time_dots"), "plot_function": "plot_tri_colors"
'multiColorDotsEqualOnUpperBound': ( },
("Multicolor dots in center with value/colors mapping defined by " 'dotForTime': {
"ValueColors with available colors: RYGMCW.\n" "description": (
"Value from low to high.\n" "Dots according to timestamp.\n"
"Ex: *:W in which all values represent by white dots.\n" "Color defined by ValueColors with available colors: RYGMCW.\n"
"Ex: -1:_|0:R|2.3:Y|+2.3:G\n" "Ex: G"),
" in which \tvalue <= -1 => not plot\n" "plot_function": "plot_time_dots"
"\tvalue <= 0 => plot with R color\n" },
"\tvalue <= 2.3 => plot with Y color\n" 'multiColorDotsEqualOnUpperBound': {
"\tvalue > 2.3 => plot with G color\n"), "description": (
"plot_multi_color_dots_equal_on_upper_bound" "Multicolor dots in center with value/colors mapping defined "
), "by ValueColors with available colors: RYGMCW.\n"
'multiColorDotsEqualOnLowerBound': ( "Value from low to high.\n"
("Multicolor dots in center with value/colors mapping defined by " "Ex: *:W in which all values represent by white dots.\n"
"ValueColors with available colors: RYGMCW.\n" "Ex: -1:_|0:R|2.3:Y|+2.3:G\n"
"Value from low to high.\n" " in which \tvalue <= -1 => not plot\n"
"Ex: 3.:R|3.3:Y|=3.3:G\n" "\tvalue <= 0 => plot with R color\n"
" in which" "\t0 < value <= 2.3 => plot with Y color\n"
"\tvalue < 3. => plot with R color\n" "\t2.3 < value => plot with G color\n"),
"\t3 <= value < 3.3 => plot with Y color\n" "plot_function": "plot_multi_color_dots_equal_on_upper_bound"
"\tvalue = 3.3 => plot with G color\n"), },
"plot_multi_color_dots_equal_on_lower_bound" 'multiColorDotsEqualOnLowerBound': {
), "description": (
'upDownDots': ( "Multicolor dots in center with value/colors mapping defined "
("Show data with 2 different values: first down/ second up. " "by ValueColors with available colors: RYGMCW.\n"
"Colors defined by ValueColors.\nEx: 1:R|0:Y"), "Value from low to high.\n"
'plot_up_down_dots' "Ex: 3.:R|3.3:Y|=3.3:G\n"
) " in which"
"\tvalue < 3. => plot with R color\n"
"\t3. <= value < 3.3 => plot with Y color\n"
"\tvalue = 3.3 => plot with G color\n"),
"plot_function": "plot_multi_color_dots_equal_on_lower_bound"
},
'upDownDots': {
"description": (
"Show data with 2 different values: first down/ second up. "
"Colors defined by ValueColors.\nEx: 1:R|0:Y"),
"plot_function": 'plot_up_down_dots'
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment