Skip to content

Commit

Permalink
Fix #35, fix #351, updated minor_servos
Browse files Browse the repository at this point in the history
This branch will not be merged until the component is updated as well
  • Loading branch information
giuseppe-carboni committed May 17, 2024
1 parent 1a8db89 commit a77beb9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
16 changes: 8 additions & 8 deletions simulators/minor_servos/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
20 changes: 10 additions & 10 deletions tests/test_minor_servos.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -210,15 +210,15 @@ 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}$')
time.sleep(TIMER_VALUE + 0.1)
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)
Expand Down

0 comments on commit a77beb9

Please sign in to comment.