Skip to content

Commit

Permalink
improved Kongsberg support
Browse files Browse the repository at this point in the history
  • Loading branch information
giumas committed Feb 25, 2024
1 parent df70061 commit f25f031
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 31 deletions.
6 changes: 5 additions & 1 deletion hyo2/ssm2/app/gui/soundspeedmanager/mainwin.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,8 @@ def __init__(self):
"background-color:rgba(255,163,102);}"
self.purple_stylesheet = "QStatusBar{color:rgba(0,0,0,128);font-size: 8pt;" \
"background-color:rgba(221,160,221,128);}"
self.khaki_stylesheet = "QStatusBar{color:rgba(0,0,0,128);font-size: 8pt;" \
"background-color:rgba(240,230,140,128);}"
self.red_stylesheet = "QStatusBar{color:rgba(0,0,0,128);font-size: 8pt;" \
"background-color:rgba(255,0,0,128);}"
self.yellow_stylesheet = "QStatusBar{color:rgba(0,0,0,128);font-size: 8pt;" \
Expand Down Expand Up @@ -778,8 +780,10 @@ def update_gui(self):
if self.lib.has_mvp_to_process() or self.lib.has_sippican_to_process():
self.statusBar().setStyleSheet(self.orange_stylesheet)
else:
if self.old_sis_nav_data or self.old_sis_xyz_data or self.old_nmea_nav_data:
if self.old_sis_nav_data or self.old_nmea_nav_data:
self.statusBar().setStyleSheet(self.purple_stylesheet)
elif self.old_sis_xyz_data:
self.statusBar().setStyleSheet(self.khaki_stylesheet)
else:
self.statusBar().setStyleSheet(self.normal_stylesheet)

Expand Down
73 changes: 51 additions & 22 deletions hyo2/ssm2/lib/formats/kmall.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,31 +88,60 @@ def __init__(self, data, debug: bool = False):
# 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.inactive_navigation = (common_sensor_status & 1) != 1
self.inactive_pinging = (common_sensor_status & 2) != 2
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))
if debug:
if self.invalid_data:
logger.debug("common part -> sensor status: %s (invalid data: %s)"
% (common_sensor_status, 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))
if self.inactive_pinging:

if debug:
logger.debug("common part -> sensor status: %s (inactive pinging: %s)"
% (common_sensor_status, self.inactive_pinging))

self.tss = None
self.transducer_depth = None
self.mean_depth = None

else:

self.tss = data_blk[0]
if debug:
logger.debug('TSS: %s m/s' % self.tss)
self.transducer_depth = data_blk[1]
if debug:
logger.debug('transducer depth re WL: %s 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]
if debug:
logger.debug('ping avg depth: %s' % self.mean_depth)

if self.inactive_navigation:

if debug:
logger.debug("common part -> sensor status: %s (inactive navigation: %s)"
% (common_sensor_status, self.inactive_navigation))

self.latitude = None
self.longitude = None

else:

# 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
Expand Down
17 changes: 9 additions & 8 deletions hyo2/ssm2/lib/listener/sis/sis.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,19 +338,20 @@ def _parse_sis5(self) -> None:

if self.cur_id not in self.sis5.datagrams:
if self.debug:
logger.debug("Ignoring received datagram")
logger.debug("%s: Ignoring received datagram" % self.cur_id)
return

if self.cur_id == b'#SSM':
ssm = kmall.KmallSSM(this_data, self.debug)
if ssm.invalid_data or ssm.inactive_sensor:
if ssm.invalid_data or ssm.inactive_navigation:
return
self.sis5.ssm = ssm
self.sis5.ssm_count += 1
self.nav_last_time = datetime.utcnow()
self.xyz_last_time = datetime.utcnow()
if not ssm.inactive_pinging:
self.xyz_last_time = datetime.utcnow()
if self.debug:
logger.debug("Parsed")
logger.debug("%s: Parsed" % self.cur_id)

elif self.cur_id == b'#MRZ':
partition = struct.unpack("<2H", this_data[20:24])
Expand All @@ -361,10 +362,10 @@ def _parse_sis5(self) -> None:
self.sis5.mrz_count += 1
self.xyz_last_time = datetime.utcnow()
if self.debug:
logger.info("%d/%d -> Parsed" % (datagram_nr, nr_of_datagrams))
logger.info("%s: %d/%d -> Parsed" % (self.cur_id, datagram_nr, nr_of_datagrams))
else:
if self.debug:
logger.info("%d/%d -> Ignored" % (datagram_nr, nr_of_datagrams))
logger.info("%s: %d/%d -> Ignored" % (self.cur_id, datagram_nr, nr_of_datagrams))

elif self.cur_id == b'#SPO':
spo = kmall.KmallSPO(this_data, self.debug)
Expand All @@ -374,13 +375,13 @@ def _parse_sis5(self) -> None:
self.sis5.spo_count += 1
self.nav_last_time = datetime.utcnow()
if self.debug:
logger.debug("Parsed")
logger.debug("%s: Parsed" % self.cur_id)

elif self.cur_id == b'#SVP':
self.sis5.svp = kmall.KmallSVP(this_data, self.debug)
self.sis5.svp_count += 1
if self.debug:
logger.debug("Parsed")
logger.debug("%s: Parsed" % self.cur_id)

else:
logger.error("Missing parser for datagram type: %s" % self.cur_id)
Expand Down

0 comments on commit f25f031

Please sign in to comment.