Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • software_public/passoft/sohstationviewer
1 result
Show changes
Commits on Source (4)
import re
import os
from pathlib import Path
from sohstationviewer.conf.constants import (WF_1ST, WF_2ND, WF_3RD)
"""
......@@ -42,3 +44,20 @@ dbConf = {
"If D is not defined, dots won't be displayed.\n"
"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):
self.require_valuecolors_plottypes = [
p for p in plot_functions.keys()
if 'ValueColors' in plot_functions[p][0]]
if 'ValueColors' in plot_functions[p]['description']]
super().__init__(
parent,
['No.', 'Param', 'Plot Type', 'ValueColors', 'Height '],
......
......@@ -32,4 +32,5 @@ class PlotTypeDialog(UiDBInfoDialog):
"""
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):
return
chan_db_info = c_data['chan_db_info']
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['ax'] = ax
ax.chan = chan_id
......
......@@ -49,7 +49,8 @@ class WaveformWidget(MultiThreadedPlottingWidget):
plot_type = chan_db_info['plotType']
# 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['ax_wf'] = ax
ax.chan = chan_id
......
plot_functions = {
'linesDots': (
"Lines, one color dots. Dot or line/color mapping defined by "
"ValueColors with available colors: RYGMCW.\n"
"Ex: L:G|D:W\n"
" means \tLines are plotted with color G\n"
"\tDots are plotted with color W\n"
"If D is not defined, dots won't be displayed.\n"
"If L is not defined, lines will be plotted with color G",
"plot_lines_dots"),
'linesSRate': (
"Lines, one color dots, bitweight info. ",
"plot_lines_s_rate"),
'linesMasspos': (
"multi-line mass position, multi-color dots. ",
"plot_lines_mass_pos"),
'triColorLines': (
"Three lines with three different colors for values -1, 0, 1.",
"plot_tri_colors"),
'dotForTime': (
"Dots according to timestamp.\n"
"Color defined by ValueColors with available colors: RYGMCW.\n"
"Ex: G",
"plot_time_dots"),
'multiColorDotsEqualOnUpperBound': (
("Multicolor dots in center with value/colors mapping defined by "
"ValueColors with available colors: RYGMCW.\n"
"Value from low to high.\n"
"Ex: *:W in which all values represent by white dots.\n"
"Ex: -1:_|0:R|2.3:Y|+2.3:G\n"
" in which \tvalue <= -1 => not plot\n"
"\tvalue <= 0 => plot with R color\n"
"\tvalue <= 2.3 => plot with Y color\n"
"\tvalue > 2.3 => plot with G color\n"),
"plot_multi_color_dots_equal_on_upper_bound"
),
'multiColorDotsEqualOnLowerBound': (
("Multicolor dots in center with value/colors mapping defined by "
"ValueColors with available colors: RYGMCW.\n"
"Value from low to high.\n"
"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_multi_color_dots_equal_on_lower_bound"
),
'upDownDots': (
("Show data with 2 different values: first down/ second up. "
"Colors defined by ValueColors.\nEx: 1:R|0:Y"),
'plot_up_down_dots'
)
'linesDots': {
"description": (
"Lines, one color dots. Dot or line/color mapping defined by "
"ValueColors with available colors: RYGMCW.\n"
"Ex: L:G|D:W\n"
" means \tLines are plotted with color G\n"
"\tDots are plotted with color W\n"
"If D is not defined, dots won't be displayed.\n"
"If L is not defined, lines will be plotted with color G"),
"plot_function": "plot_lines_dots"
},
'linesSRate': {
"description": "Lines, one color dots, bitweight info. ",
"plot_function": "plot_lines_s_rate"
},
'linesMasspos': {
"description": "multi-line mass position, multi-color dots. ",
"plot_function": "plot_lines_mass_pos"
},
'triColorLines': {
"description": "Three lines with three different colors for "
"values -1, 0, 1.",
"plot_function": "plot_tri_colors"
},
'dotForTime': {
"description": (
"Dots according to timestamp.\n"
"Color defined by ValueColors with available colors: RYGMCW.\n"
"Ex: G"),
"plot_function": "plot_time_dots"
},
'multiColorDotsEqualOnUpperBound': {
"description": (
"Multicolor dots in center with value/colors mapping defined "
"by ValueColors with available colors: RYGMCW.\n"
"Value from low to high.\n"
"Ex: *:W in which all values represent by white dots.\n"
"Ex: -1:_|0:R|2.3:Y|+2.3:G\n"
" in which \tvalue <= -1 => not plot\n"
"\tvalue <= 0 => plot with R color\n"
"\t0 < value <= 2.3 => plot with Y color\n"
"\t2.3 < value => plot with G color\n"),
"plot_function": "plot_multi_color_dots_equal_on_upper_bound"
},
'multiColorDotsEqualOnLowerBound': {
"description": (
"Multicolor dots in center with value/colors mapping defined "
"by ValueColors with available colors: RYGMCW.\n"
"Value from low to high.\n"
"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'
}
}