Skip to content

Commit

Permalink
Updated air blade logic
Browse files Browse the repository at this point in the history
  • Loading branch information
giuseppe-carboni committed May 18, 2024
1 parent a35e397 commit cfcad0b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 9 deletions.
26 changes: 17 additions & 9 deletions simulators/minor_servos/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ def _setup(self, args):
gregorian_cap_position = configuration['GREGORIAN_CAP'][0]
if (gregorian_cap_position
and self.gregorian_cap.value != gregorian_cap_position):
self.cover_timer.cancel()
_change_atomic_value(self.gregorian_cap, 0)
self.cover_timer = Timer(
self.timer_value,
Expand All @@ -231,14 +232,21 @@ def _stow(self, args):
if stow_pos not in range(5):
return self.bad
if self.gregorian_cap.value != stow_pos:
_change_atomic_value(self.gregorian_cap, 0)
self.cover_timer = Timer(
self.timer_value,
_change_atomic_value,
args=(self.gregorian_cap, stow_pos)
)
self.cover_timer.daemon = True
self.cover_timer.start()
self.cover_timer.cancel()
if self.gregorian_cap.value <= 1 or stow_pos == 1:
_change_atomic_value(self.gregorian_cap, 0)
self.cover_timer = Timer(
self.timer_value,
_change_atomic_value,
args=(self.gregorian_cap, stow_pos)
)
self.cover_timer.daemon = True
self.cover_timer.start()
else:
_change_atomic_value(
self.gregorian_cap,
stow_pos
)
else:
servo = self.servos.get(servo_id)
servo.operative_mode_timer.cancel()
Expand Down Expand Up @@ -497,7 +505,7 @@ def get_status(self, now):

def set_coords(self, coords):
for index, value in enumerate(coords):
if not value:
if value is None:
continue
self.coords[index] = value + self.offsets[index]

Expand Down
13 changes: 13 additions & 0 deletions tests/test_minor_servos.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,19 @@ def test_stow_gregorian_cap(self):
time.sleep(TIMER_VALUE + 0.1)
self.assertEqual(self.system.gregorian_cap.value, stow_pos)

def test_stow_gregorian_air_blade(self):
cmd = f'STOW=GREGORIAN_CAP,2{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, 2)
cmd = f'STOW=GREGORIAN_CAP,3{tail}'
for byte in cmd[:-1]:
self.assertTrue(self.system.parse(byte))
self.assertRegex(self.system.parse(cmd[-1]), f'{good}{tail}$')
self.assertEqual(self.system.gregorian_cap.value, 3)

def test_stow_gregorian_cap_wrong_pos(self):
cmd = f'STOW=GREGORIAN_CAP,5{tail}'
for byte in cmd[:-1]:
Expand Down

0 comments on commit cfcad0b

Please sign in to comment.