Skip to content

Commit

Permalink
added support for the SSM datagram
Browse files Browse the repository at this point in the history
  • Loading branch information
giumas committed Feb 4, 2024
1 parent 9550c07 commit c56cc7e
Show file tree
Hide file tree
Showing 4 changed files with 157 additions and 53 deletions.
46 changes: 21 additions & 25 deletions hyo2/ssm2/app/gui/soundspeedsettings/widgets/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,45 +265,45 @@ def __init__(self, main_win, db):
vbox.addWidget(self.use_sis5)
vbox.addStretch()

# - use sippican
# - use nmea
hbox = QtWidgets.QHBoxLayout()
self.right_layout.addLayout(hbox)
# -- label
vbox = QtWidgets.QVBoxLayout()
hbox.addLayout(vbox)
vbox.addStretch()
label = QtWidgets.QLabel("Listen Sippican:")
label = QtWidgets.QLabel("Listen NMEA 0183:")
label.setFixedWidth(lbl_width)
vbox.addWidget(label)
vbox.addStretch()
# -- value
vbox = QtWidgets.QVBoxLayout()
hbox.addLayout(vbox)
vbox.addStretch()
self.use_sippican = QtWidgets.QComboBox()
self.use_sippican.addItems(["True", "False"])
vbox.addWidget(self.use_sippican)
self.use_nmea_0183 = QtWidgets.QComboBox()
self.use_nmea_0183.addItems(["True", "False"])
vbox.addWidget(self.use_nmea_0183)
vbox.addStretch()

# - use nmea
# - use sippican
hbox = QtWidgets.QHBoxLayout()
self.right_layout.addLayout(hbox)
# -- label
vbox = QtWidgets.QVBoxLayout()
hbox.addLayout(vbox)
vbox.addStretch()
label = QtWidgets.QLabel("Listen NMEA 0183:")
label = QtWidgets.QLabel("Listen Sippican:")
label.setFixedWidth(lbl_width)
vbox.addWidget(label)
vbox.addStretch()
# -- value
vbox = QtWidgets.QVBoxLayout()
hbox.addLayout(vbox)
vbox.addStretch()
self.use_nmea_0183 = QtWidgets.QComboBox()
self.use_nmea_0183.addItems(["True", "False"])
vbox.addWidget(self.use_nmea_0183)
vbox.addStretch()
self.use_sippican = QtWidgets.QComboBox()
self.use_sippican.addItems(["True", "False"])
vbox.addWidget(self.use_sippican)
vbox.addStretch()

# - use mvp
hbox = QtWidgets.QHBoxLayout()
Expand Down Expand Up @@ -414,9 +414,9 @@ def __init__(self, main_win, db):
# noinspection PyUnresolvedReferences
self.use_sis5.currentIndexChanged.connect(self.apply_use_sis)
# noinspection PyUnresolvedReferences
self.use_sippican.currentIndexChanged.connect(self.apply_use_sippican)
self.use_nmea_0183.currentIndexChanged.connect(self.apply_use_sis)
# noinspection PyUnresolvedReferences
self.use_nmea_0183.currentIndexChanged.connect(self.apply_use_nmea_0183)
self.use_sippican.currentIndexChanged.connect(self.apply_use_sippican)
# noinspection PyUnresolvedReferences
self.use_mvp.currentIndexChanged.connect(self.apply_use_mvp)
# noinspection PyUnresolvedReferences
Expand Down Expand Up @@ -495,33 +495,29 @@ def apply_use_sis(self):
self.db.use_sis4 = use_value
if use_value:
self.use_sis5.setCurrentText("False")
self.use_nmea_0183.setCurrentText("False")
elif self.sender() is self.use_sis5:
use_value = self.use_sis5.currentText() == "True"
self.db.use_sis5 = use_value
if use_value:
self.use_sis4.setCurrentText("False")
self.use_nmea_0183.setCurrentText("False")
elif self.sender() is self.use_nmea_0183:
use_value = self.use_nmea_0183.currentText() == "True"
self.db.use_nmea_0183 = use_value
if use_value:
self.use_sis4.setCurrentText("False")
self.use_sis5.setCurrentText("False")

self.setup_changed()
self.main_win.reload_settings()

def apply_use_sis5(self):
# logger.debug("apply use SIS")
self.db.use_sis5 = self.use_sis5.currentText() == "True"
self.setup_changed()
self.main_win.reload_settings()

def apply_use_sippican(self):
# logger.debug("apply use Sippican")
self.db.use_sippican = self.use_sippican.currentText() == "True"
self.setup_changed()
self.main_win.reload_settings()

def apply_use_nmea_0183(self):
# logger.debug("apply use Nmea")
self.db.use_nmea_0183 = self.use_nmea_0183.currentText() == "True"
self.setup_changed()
self.main_win.reload_settings()

def apply_use_mvp(self):
# logger.debug("apply use MVP")
self.db.use_mvp = self.use_mvp.currentText() == "True"
Expand Down
44 changes: 22 additions & 22 deletions hyo2/ssm2/app/gui/soundspeedsettings/widgets/listeners.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,75 +81,75 @@ def __init__(self, main_win, db):

self.left_layout.addSpacing(12)

# SIPPICAN
# NMEA
hbox = QtWidgets.QHBoxLayout()
self.left_layout.addLayout(hbox)
hbox.addStretch()
self.label = QtWidgets.QLabel("Sippican(*):")
self.label = QtWidgets.QLabel("NMEA 0183(*):")
hbox.addWidget(self.label)
hbox.addStretch()
hbox.addStretch()

# - sippican_listen_port
# - nmea_listen_port
hbox = QtWidgets.QHBoxLayout()
self.left_layout.addLayout(hbox)
# -- label
label = QtWidgets.QLabel("Listen port:")
label.setFixedWidth(lbl_width)
hbox.addWidget(label)
# -- value
self.sippican_listen_port = QtWidgets.QLineEdit()
self.nmea_listen_port = QtWidgets.QLineEdit()
validator = QtGui.QIntValidator(0, 99999)
self.sippican_listen_port.setValidator(validator)
hbox.addWidget(self.sippican_listen_port)
self.nmea_listen_port.setValidator(validator)
hbox.addWidget(self.nmea_listen_port)

# - sippican_listen_timeout
# - nmea_listen_timeout
hbox = QtWidgets.QHBoxLayout()
self.left_layout.addLayout(hbox)
# -- label
label = QtWidgets.QLabel("Listen timeout:")
label.setFixedWidth(lbl_width)
hbox.addWidget(label)
# -- value
self.sippican_listen_timeout = QtWidgets.QLineEdit()
self.nmea_listen_timeout = QtWidgets.QLineEdit()
validator = QtGui.QIntValidator(0, 99999)
self.sippican_listen_timeout.setValidator(validator)
hbox.addWidget(self.sippican_listen_timeout)
self.nmea_listen_timeout.setValidator(validator)
hbox.addWidget(self.nmea_listen_timeout)

self.left_layout.addSpacing(12)

# NMEA
# SIPPICAN
hbox = QtWidgets.QHBoxLayout()
self.left_layout.addLayout(hbox)
hbox.addStretch()
self.label = QtWidgets.QLabel("NMEA 0183(*):")
self.label = QtWidgets.QLabel("Sippican(*):")
hbox.addWidget(self.label)
hbox.addStretch()
hbox.addStretch()

# - nmea_listen_port
# - sippican_listen_port
hbox = QtWidgets.QHBoxLayout()
self.left_layout.addLayout(hbox)
# -- label
label = QtWidgets.QLabel("Listen port:")
label.setFixedWidth(lbl_width)
hbox.addWidget(label)
# -- value
self.nmea_listen_port = QtWidgets.QLineEdit()
self.sippican_listen_port = QtWidgets.QLineEdit()
validator = QtGui.QIntValidator(0, 99999)
self.nmea_listen_port.setValidator(validator)
hbox.addWidget(self.nmea_listen_port)
self.sippican_listen_port.setValidator(validator)
hbox.addWidget(self.sippican_listen_port)

# - nmea_listen_timeout
# - sippican_listen_timeout
hbox = QtWidgets.QHBoxLayout()
self.left_layout.addLayout(hbox)
# -- label
label = QtWidgets.QLabel("Listen timeout:")
label.setFixedWidth(lbl_width)
hbox.addWidget(label)
# -- value
self.nmea_listen_timeout = QtWidgets.QLineEdit()
self.sippican_listen_timeout = QtWidgets.QLineEdit()
validator = QtGui.QIntValidator(0, 99999)
self.nmea_listen_timeout.setValidator(validator)
hbox.addWidget(self.nmea_listen_timeout)
self.sippican_listen_timeout.setValidator(validator)
hbox.addWidget(self.sippican_listen_timeout)

self.left_layout.addStretch()

Expand Down
57 changes: 55 additions & 2 deletions hyo2/ssm2/lib/formats/kmall.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ class Kmall:
b'#SDE': 'Sensor (S) data from depth (DE) sensor',
b'#SHI': 'Sensor (S) data for height (HI)',

b'#SSM': 'Sound Speed Manager (SSM) datagram',

b'#CPO': 'Compatibility (C) data for position (PO)',
b'#CHE': 'Compatibility (C) data for heave (HE)',
}
Expand Down Expand Up @@ -76,6 +78,57 @@ def __str__(self):
% (self.id, self.dg_time, self.sounder_id)


class KmallSSM(Kmall):
def __init__(self, data, debug: bool = False):
super().__init__(data)

common = struct.unpack("<4H", self.data[20:28])
# common_length = common[0]
# logger.debug("common part -> length: %d/%d" % (common_length, self.length))
# common_sensor_system = common[1]
# logger.debug("common part -> sensor system: %d" % common_sensor_system)
common_sensor_status = common[2]
self.inactive_sensor = (common_sensor_status & 1) != 1
self.invalid_data = (common_sensor_status & 16) == 16
# if self.inactive_sensor or self.invalid_data:
# logger.debug("common part -> sensor status: %s (inactive: %s, invalid: %s)"
# % (common_sensor_status, self.inactive_sensor, self.invalid_data))

data_blk = struct.unpack("<2fIfI2d", self.data[28:64])
self.tss = data_blk[0]
# logger.debug('TSS: %s m/s' % (self.tss, ))
self.transducer_depth = data_blk[1]
# logger.debug('transducer depth re WL: %.3f m' % (self.transducer_depth))
# ping_time_sec = data_blk[2]
# logger.debug('ping time sec: %s' % ping_time_sec)
# ping_datetime = Kmall.kmall_datetime(ping_time_sec, 0)
# logger.debug('ping datetime: %s' % ping_datetime.strftime('%Y-%m-%d %H:%M:%S.%f'))
self.mean_depth = data_blk[3]
# logger.debug('ping avg depth: %s' % self.mean_depth)
# nav_time_sec = data_blk[4]
# logger.debug('nav time sec: %s' % nav_time_sec)
# nav_datetime = Kmall.kmall_datetime(nav_time_sec, 0)
# logger.debug('nav datetime: %s' % nav_datetime.strftime('%Y-%m-%d %H:%M:%S.%f'))
self.latitude = data_blk[5]
self.longitude = data_blk[6]
if debug:
logger.debug('SSM -> pos: %.7f, %.7f' % (self.latitude, self.longitude))

final_length = struct.unpack("<I", self.data[-4:])
self.is_valid = final_length != self.length
# logger.debug('#SPO is valid: %s' % self.is_valid)
if not self.is_valid:
logger.warning('SSM -> Invalid length: %s != %s' % (final_length, self.length))

def __str__(self):
output = Kmall.__str__(self)
output += '\tTSS: %.2f m/s\n\tTransducer depth: %.2f m.\n' % (self.tss, self.transducer_depth)
output += '\tLat/Lon: %lf %lf\n' % (self.latitude, self.longitude)
output += '\tMean depth: %.2f m\n' % self.mean_depth

return output


class KmallMRZ(Kmall):
def __init__(self, data, debug: bool = False):
super().__init__(data)
Expand Down Expand Up @@ -117,7 +170,7 @@ def __init__(self, data, debug: bool = False):
self.tss = ping_info[36]
# logger.debug('TSS: %s m/s' % (self.tss, ))
transducer_depth_m = ping_info[37]
z_water_level_re_ref_point_m = ping_info[38]
# z_water_level_re_ref_point_m = ping_info[38]
# logger.debug('WL re RP: %.3f m, transducer depth re WL: %.3f m'
# % (z_water_level_re_ref_point_m, transducer_depth_m))
self.transducer_depth = transducer_depth_m
Expand Down Expand Up @@ -155,7 +208,7 @@ def __init__(self, data, debug: bool = False):
# % (i, len(self.data[start_sounding:end_sounding])))
break
sounding = struct.unpack(sounding_struct, self.data[start_sounding:end_sounding])
sounding_idx = sounding[0]
# sounding_idx = sounding[0]
# logger.debug("sounding -> #%d" % (sounding_idx, ))
sounding_detection_type = sounding[2]
# logger.debug("sounding -> detection type: %s" % (sounding_detection_type, ))
Expand Down
Loading

0 comments on commit c56cc7e

Please sign in to comment.