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

Merge branch 'master' into i140_bug_gps_path_name

parents 05f82f78 268f28ec
No related branches found
No related tags found
1 merge request!162fix bug for path's name when saving GPS file
Pipeline #2953 passed with stage
in 3 minutes and 3 seconds
...@@ -249,3 +249,22 @@ def get_unit_bitweight(chan_db_info: Dict, bitweight_opt: str) -> str: ...@@ -249,3 +249,22 @@ def get_unit_bitweight(chan_db_info: Dict, bitweight_opt: str) -> str:
else: else:
unit_bitweight = "{}%s" % unit unit_bitweight = "{}%s" % unit
return unit_bitweight return unit_bitweight
def get_disk_size_format(value: float) -> str:
"""
Break down unit in byte system.
:param value: size in KiB
:return: size with unit
"""
size = value * 1024.
if size >= 1024. ** 4:
return "%.2fTiB" % (size / 1024. ** 4)
elif size >= 1024. ** 3:
return "%.2fGiB" % (size / 1024. ** 3)
elif size >= 1024. ** 2:
return "%.2fMiB" % (size / 1024. ** 2)
elif size >= 1024.:
return "%.2fKiB" % (size / 1024.)
else:
return "%dB" % size
...@@ -9,7 +9,7 @@ from matplotlib.backends.backend_qt5agg import ( ...@@ -9,7 +9,7 @@ from matplotlib.backends.backend_qt5agg import (
FigureCanvasQTAgg as Canvas) FigureCanvasQTAgg as Canvas)
from sohstationviewer.controller.plotting_data import ( from sohstationviewer.controller.plotting_data import (
get_time_ticks, get_unit_bitweight) get_time_ticks, get_unit_bitweight, get_disk_size_format)
from sohstationviewer.conf import constants from sohstationviewer.conf import constants
from sohstationviewer.view.util.color import clr from sohstationviewer.view.util.color import clr
...@@ -299,6 +299,13 @@ class PlottingAxes: ...@@ -299,6 +299,13 @@ class PlottingAxes:
:param max_y: maximum of y values :param max_y: maximum of y values
:param chan_db_info: info of channel from database :param chan_db_info: info of channel from database
""" """
if chan_db_info['channel'].startswith('Disk Usage'):
ax.set_yticks([org_min_y, org_max_y])
min_y_label = get_disk_size_format(org_min_y)
max_y_label = get_disk_size_format(org_max_y)
ax.set_yticklabels([min_y_label, max_y_label])
return
if chan_db_info['channel'] == 'GPS Lk/Unlk': if chan_db_info['channel'] == 'GPS Lk/Unlk':
# to avoid case that the channel doesn't have Lk or Unlk # to avoid case that the channel doesn't have Lk or Unlk
# preset min, max value so that GPS Clock Power is always in the # preset min, max value so that GPS Clock Power is always in the
......
...@@ -21,7 +21,9 @@ from sohstationviewer.view.plotting.plotting_widget.plotting_axes import ( ...@@ -21,7 +21,9 @@ from sohstationviewer.view.plotting.plotting_widget.plotting_axes import (
from sohstationviewer.view.plotting.plotting_widget.plotting import Plotting from sohstationviewer.view.plotting.plotting_widget.plotting import Plotting
from sohstationviewer.view.save_plot_dialog import SavePlotDialog from sohstationviewer.view.save_plot_dialog import SavePlotDialog
from sohstationviewer.controller.plotting_data import format_time from sohstationviewer.controller.plotting_data import (
format_time, get_disk_size_format
)
from sohstationviewer.controller.util import display_tracking_info from sohstationviewer.controller.util import display_tracking_info
...@@ -329,7 +331,9 @@ class PlottingWidget(QtWidgets.QScrollArea): ...@@ -329,7 +331,9 @@ class PlottingWidget(QtWidgets.QScrollArea):
display_tracking_info(self.tracking_box, "Point not found.") display_tracking_info(self.tracking_box, "Point not found.")
return return
clicked_data = chan_data['data'][0][real_idx] clicked_data = chan_data['data'][0][real_idx]
if hasattr(ax, 'unit_bw'): if chan_id.startswith('Disk Usage'):
clicked_data = get_disk_size_format(clicked_data)
elif hasattr(ax, 'unit_bw'):
clicked_data = ax.unit_bw.format(clicked_data) clicked_data = ax.unit_bw.format(clicked_data)
formatted_clicked_time = format_time( formatted_clicked_time = format_time(
clicked_time, self.date_mode, 'HH:MM:SS') clicked_time, self.date_mode, 'HH:MM:SS')
......
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