-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
changes to support the new Sis class
- Loading branch information
Showing
18 changed files
with
234 additions
and
593 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,115 +1,99 @@ | ||
import time | ||
import logging | ||
from typing import TYPE_CHECKING | ||
|
||
from hyo2.soundspeed.listener.sis.sis4 import Sis4 | ||
from hyo2.soundspeed.listener.sis.sis5 import Sis5 | ||
from hyo2.soundspeed.listener.sis.sis import Sis | ||
from hyo2.soundspeed.listener.sippican.sippican import Sippican | ||
from hyo2.soundspeed.listener.mvp.mvp import Mvp | ||
if TYPE_CHECKING: | ||
from hyo2.soundspeed.soundspeed import SoundSpeedLibrary | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class Listeners: | ||
"""A collection of listening processes""" | ||
|
||
def __init__(self, prj): | ||
def __init__(self, prj: 'SoundSpeedLibrary'): | ||
super(Listeners, self).__init__() | ||
# data folder | ||
self.prj = prj | ||
|
||
# available listeners | ||
self.sis4 = Sis4(port=self.prj.setup.sis_listen_port, datagrams=[0x50, 0x52, 0x55, 0x58], | ||
timeout=self.prj.setup.sis_listen_timeout) | ||
self.sis5 = Sis5(ip="localhost", port=self.prj.setup.sis_listen_port, | ||
datagrams=[b'#MRZ', b'#SPO', b'#SVP'], | ||
timeout=self.prj.setup.sis_listen_timeout) | ||
self.sis = Sis(port=self.prj.setup.sis_listen_port, | ||
timeout=self.prj.setup.sis_listen_timeout, | ||
use_sis5=self.prj.setup.use_sis5) | ||
self.sippican = Sippican(port=self.prj.setup.sippican_listen_port, prj=prj) | ||
self.mvp = Mvp(port=self.prj.setup.mvp_listen_port, prj=prj) | ||
|
||
@property | ||
def sippican_to_process(self): | ||
def sippican_to_process(self) -> bool: | ||
return self.sippican.new_ssp.is_set() | ||
|
||
@sippican_to_process.setter | ||
def sippican_to_process(self, to_process): | ||
def sippican_to_process(self, to_process: bool) -> None: | ||
if not to_process: | ||
self.sippican.new_ssp.clear() | ||
|
||
@property | ||
def mvp_to_process(self): | ||
def mvp_to_process(self) -> bool: | ||
return self.mvp.new_ssp.is_set() | ||
|
||
@mvp_to_process.setter | ||
def mvp_to_process(self, to_process): | ||
def mvp_to_process(self, to_process: bool) -> None: | ||
if not to_process: | ||
self.mvp.new_ssp.clear() | ||
|
||
def listen_sis4(self): | ||
if not self.sis4.is_alive(): | ||
self.sis4.start() | ||
def listen_sis(self) -> bool: | ||
if not self.sis.is_alive(): | ||
self.sis.start() | ||
time.sleep(0.1) | ||
logger.debug("start") | ||
return self.sis4.is_alive() | ||
return self.sis.is_alive() | ||
|
||
def stop_listen_sis4(self): | ||
if self.sis4.is_alive(): | ||
self.sis4.stop() | ||
self.sis4.join(2) | ||
def stop_listen_sis(self) -> bool: | ||
if self.sis.is_alive(): | ||
self.sis.stop() | ||
self.sis.join(2) | ||
logger.debug("stop") | ||
return not self.sis4.is_alive() | ||
return not self.sis.is_alive() | ||
|
||
def listen_sis5(self): | ||
if not self.sis5.is_alive(): | ||
self.sis5.start() | ||
time.sleep(0.1) | ||
logger.debug("start") | ||
return self.sis5.is_alive() | ||
|
||
def stop_listen_sis5(self): | ||
if self.sis5.is_alive(): | ||
self.sis5.stop() | ||
self.sis5.join(2) | ||
logger.debug("stop") | ||
return not self.sis5.is_alive() | ||
|
||
def listen_sippican(self): | ||
def listen_sippican(self) -> bool: | ||
if not self.sippican.is_alive(): | ||
self.sippican.start() | ||
time.sleep(0.1) | ||
logger.debug("start") | ||
return self.sippican.is_alive() | ||
|
||
def stop_listen_sippican(self): | ||
def stop_listen_sippican(self) -> bool: | ||
if self.sippican.is_alive(): | ||
self.sippican.stop() | ||
self.sippican.join(2) | ||
logger.debug("stop") | ||
return not self.sippican.is_alive() | ||
|
||
def listen_mvp(self): | ||
def listen_mvp(self) -> bool: | ||
if not self.mvp.is_alive(): | ||
self.mvp.start() | ||
time.sleep(0.1) | ||
logger.debug("start") | ||
return self.mvp.is_alive() | ||
|
||
def stop_listen_mvp(self): | ||
def stop_listen_mvp(self) -> bool: | ||
if self.mvp.is_alive(): | ||
self.mvp.stop() | ||
self.mvp.join(2) | ||
logger.debug("stop") | ||
return not self.mvp.is_alive() | ||
|
||
def stop(self): | ||
self.stop_listen_sis4() | ||
self.stop_listen_sis5() | ||
def stop(self) -> None: | ||
self.stop_listen_sis() | ||
self.stop_listen_sippican() | ||
self.stop_listen_mvp() | ||
|
||
def __repr__(self): | ||
def __repr__(self) -> str: | ||
msg = "<Listeners>\n" | ||
msg += "%s" % self.sis4 | ||
msg += "%s" % self.sis5 | ||
msg += "%s" % self.sis | ||
msg += "%s" % self.sippican | ||
msg += "%s" % self.mvp | ||
return msg |
Oops, something went wrong.