Skip to content

Commit

Permalink
pass sigan for gps through method calls instead of constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
jhazentia committed Mar 27, 2024
1 parent 9e600f8 commit 91e3eff
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 10 deletions.
4 changes: 2 additions & 2 deletions scos_actions/actions/sync_gps.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ def __init__(self, parameters: dict):
def __call__(self, sensor: Sensor, schedule_entry: dict, task_id: int):
logger.debug("Syncing to GPS")
self.sensor = sensor
dt = self.sensor.gps.get_gps_time()
dt = self.sensor.gps.get_gps_time(self.sensor.signal_analyzer)
date_cmd = ["date", "-s", "{:}".format(dt.strftime("%Y/%m/%d %H:%M:%S"))]
subprocess.check_output(date_cmd, shell=True)
logger.info(f"Set system time to GPS time {dt.ctime()}")

location = sensor.gps.get_location()
location = sensor.gps.get_location(self.sensor.signal_analyzer)
if location is None:
raise RuntimeError("Unable to synchronize to GPS")

Expand Down
2 changes: 1 addition & 1 deletion scos_actions/discover/tests/test_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"""

sigan = MockSignalAnalyzer()
gps = MockGPS(sigan)
gps = MockGPS()


def test_load_from_yaml_existing():
Expand Down
4 changes: 2 additions & 2 deletions scos_actions/hardware/gps_iface.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

class GPSInterface(ABC):
@abstractmethod
def get_location(self, timeout_s=1):
def get_location(self, sigan, timeout_s=1):
pass

@abstractmethod
def get_gps_time(self):
def get_gps_time(self, sigan):
pass
6 changes: 2 additions & 4 deletions scos_actions/hardware/mocks/mock_gps.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@


class MockGPS(GPSInterface):
def __init__(self, sigan):
self.sigan = sigan

def get_location(timeout_s=1):
def get_location(self, sigan, timeout_s=1):
logger.warning("Using mock GPS!")
return 39.995118, -105.261572, 1651.0

def get_gps_time(self):
def get_gps_time(self, sigan):
logger.warning("Using mock GPS!")
return datetime.now()
2 changes: 1 addition & 1 deletion scos_actions/hardware/tests/test_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def test_set_get_preselector():

def test_set_get_gps():
sigan = MockSignalAnalyzer()
gps = MockGPS(sigan)
gps = MockGPS()
sensor = Sensor(signal_analyzer=sigan, capabilities={})
sensor.gps = gps
assert sensor.gps == gps
Expand Down

0 comments on commit 91e3eff

Please sign in to comment.