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 (2)
......@@ -249,3 +249,22 @@ def get_unit_bitweight(chan_db_info: Dict, bitweight_opt: str) -> str:
else:
unit_bitweight = "{}%s" % unit
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 (
FigureCanvasQTAgg as Canvas)
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.view.util.color import clr
......@@ -299,6 +299,13 @@ class PlottingAxes:
:param max_y: maximum of y values
: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':
# 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
......
......@@ -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.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
......@@ -329,7 +331,9 @@ class PlottingWidget(QtWidgets.QScrollArea):
display_tracking_info(self.tracking_box, "Point not found.")
return
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)
formatted_clicked_time = format_time(
clicked_time, self.date_mode, 'HH:MM:SS')
......