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)
...@@ -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
...@@ -190,7 +190,7 @@ class GPSDialog(QtWidgets.QWidget): ...@@ -190,7 +190,7 @@ class GPSDialog(QtWidgets.QWidget):
super().__init__() super().__init__()
self.parent = parent self.parent = parent
self.data_path: Optional[Path] = None self.data_path: Optional[Path, str] = None
# The directory the GPS will be exported to. By default, this will be # The directory the GPS will be exported to. By default, this will be
# the folder that contains the data set. # the folder that contains the data set.
self.export_path: Path = Path.home() self.export_path: Path = Path.home()
...@@ -353,8 +353,10 @@ class GPSDialog(QtWidgets.QWidget): ...@@ -353,8 +353,10 @@ class GPSDialog(QtWidgets.QWidget):
msg = 'There is no GPS data to export.' msg = 'There is no GPS data to export.'
display_tracking_info(self.info_text_browser, msg, LogType.ERROR) display_tracking_info(self.info_text_browser, msg, LogType.ERROR)
return return
try:
folder_name = self.data_path.name folder_name = self.data_path.name
except AttributeError:
folder_name = self.data_path.split(os.sep)[-1]
export_file_path = self.export_path / f'{folder_name}.gps.dat' export_file_path = self.export_path / f'{folder_name}.gps.dat'
try: try:
......
...@@ -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')
......