From a77beb907aa33234c924b930bb93fd91e80a71a2 Mon Sep 17 00:00:00 2001 From: Giuseppe Carboni Date: Fri, 17 May 2024 21:11:15 +0000 Subject: [PATCH] Fix #35, fix #351, updated minor_servos This branch will not be merged until the component is updated as well --- simulators/minor_servos/__init__.py | 16 ++++++++-------- tests/test_minor_servos.py | 20 ++++++++++---------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/simulators/minor_servos/__init__.py b/simulators/minor_servos/__init__.py index 6c9ff51..7eab8c8 100644 --- a/simulators/minor_servos/__init__.py +++ b/simulators/minor_servos/__init__.py @@ -91,10 +91,10 @@ def __init__(self): 'SRP': SRP(), 'M3R': M3R(), 'GFR': GFR(), - 'DerotatoreGFR1': Derotator('GFR1'), - 'DerotatoreGFR2': Derotator('GFR2'), - 'DerotatoreGFR3': Derotator('GFR3'), - 'DerotatorePFP': Derotator('PFP'), + 'DR_GFR1': Derotator('GFR1'), + 'DR_GFR2': Derotator('GFR2'), + 'DR_GFR3': Derotator('GFR3'), + 'DR_PFP': Derotator('PFP'), } self.stop = Value(c_bool, False) self.update_thread = Thread( @@ -212,14 +212,14 @@ def _stow(self, args): if len(args) != 2: return self.bad servo_id = args[0] - if servo_id not in list(self.servos) + ['Gregoriano']: + if servo_id not in list(self.servos) + ['GREGORIAN_CAP']: return self.bad try: stow_pos = int(args[1]) # STOW POSITION except ValueError: return self.bad - if servo_id == 'Gregoriano': - if stow_pos not in [1, 2]: + if servo_id == 'GREGORIAN_CAP': + if stow_pos not in range(5): return self.bad if self.gregorian_cap.value != stow_pos: _change_atomic_value(self.gregorian_cap, 0) @@ -618,7 +618,7 @@ def __init__(self, name): self.max_coord = [220.0] self.min_coord = [-220.0] self.max_delta = [3.3] - super().__init__(name) + super().__init__(f'DR_{name}') def get_status(self, now): answer = super().get_status(now) diff --git a/tests/test_minor_servos.py b/tests/test_minor_servos.py index 5f2ef12..550922f 100644 --- a/tests/test_minor_servos.py +++ b/tests/test_minor_servos.py @@ -149,15 +149,15 @@ def test_status_GFR(self): def test_status_derotators(self): derotators = ['GFR1', 'GFR2', 'GFR3', 'PFP'] for derotator in derotators: - cmd = fr'STATUS=Derotatore{derotator}{tail}' + cmd = fr'STATUS=DR_{derotator}{tail}' regex = good - regex += fr',{derotator}_ENABLED=1\|' - regex += fr'{derotator}_STATUS=1\|' - regex += fr'{derotator}_BLOCK=2\|' - regex += fr'{derotator}_OPERATIVE_MODE=0\|' - regex += fr'{derotator}_ROTARY_AXIS_ENABLED=1\|' - regex += fr'{derotator}_ROTATION=[\-]?[0-9]+\.[0-9]+\|' - regex += fr'{derotator}_OFFSET=[0-9]+\.[0-9]+' + regex += fr',DR_{derotator}_ENABLED=1\|' + regex += fr'DR_{derotator}_STATUS=1\|' + regex += fr'DR_{derotator}_BLOCK=2\|' + regex += fr'DR_{derotator}_OPERATIVE_MODE=0\|' + regex += fr'DR_{derotator}_ROTARY_AXIS_ENABLED=1\|' + regex += fr'DR_{derotator}_ROTATION=[\-]?[0-9]+\.[0-9]+\|' + regex += fr'DR_{derotator}_OFFSET=[0-9]+\.[0-9]+' regex += fr'{tail}$' for byte in cmd[:-1]: self.assertTrue(self.system.parse(byte)) @@ -210,7 +210,7 @@ def test_stow(self): def test_stow_gregorian_cap(self): for stow_pos in [1, 2]: - cmd = f'STOW=Gregoriano,{stow_pos}{tail}' + cmd = f'STOW=GREGORIAN_CAP,{stow_pos}{tail}' for byte in cmd[:-1]: self.assertTrue(self.system.parse(byte)) self.assertRegex(self.system.parse(cmd[-1]), f'{good}{tail}$') @@ -218,7 +218,7 @@ def test_stow_gregorian_cap(self): self.assertEqual(self.system.gregorian_cap.value, stow_pos) def test_stow_gregorian_cap_wrong_pos(self): - cmd = f'STOW=Gregoriano,3{tail}' + cmd = f'STOW=GREGORIAN_CAP,5{tail}' for byte in cmd[:-1]: self.assertTrue(self.system.parse(byte)) self.assertRegex(self.system.parse(cmd[-1]), bad)