Update workstation UI, ROS task control and device integration
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
"""Only commands writing the same device conflict; all functions are fake."""
|
||||
import threading
|
||||
import time
|
||||
from unittest import TestCase
|
||||
from station.command_policy import resources_for
|
||||
from station.tasks import TaskManager
|
||||
|
||||
|
||||
class ModuleIndependenceTest(TestCase):
|
||||
def test_four_modules_execute_concurrently(self):
|
||||
manager=TaskManager();release=threading.Event();started={}
|
||||
def operation(name,event):
|
||||
started[name].set();release.wait(2)
|
||||
return {'ok':True}
|
||||
try:
|
||||
tokens=[]
|
||||
for name in ('real_up','camera_refresh','gripper_open','tactile_refresh'):
|
||||
started[name]=threading.Event()
|
||||
tokens.append(manager.submit(name,resources_for(name,'89'),lambda event,name=name:operation(name,event)))
|
||||
self.assertTrue(all(flag.wait(1) for flag in started.values()))
|
||||
self.assertTrue(all(manager.snapshot(t)['state']=='running' for t in tokens))
|
||||
with self.assertRaises(RuntimeError):
|
||||
manager.submit('gripper_close',resources_for('gripper_close','89'),lambda event:{'ok':True})
|
||||
finally:
|
||||
release.set();manager.close()
|
||||
|
||||
def test_only_composite_a7_workflow_also_owns_gripper(self):
|
||||
grip=resources_for('gripper_open','89')
|
||||
for action in ('real_up','reset_home','teach_goto','stage_track','stage_locate'):
|
||||
self.assertFalse(resources_for(action,'89') & grip,action)
|
||||
for action in ('stage_screw','pipeline'):
|
||||
self.assertTrue(resources_for(action,'89') & grip,action)
|
||||
self.assertFalse(resources_for(action,'89') & resources_for('tactile_reset','89'),action)
|
||||
self.assertFalse(resources_for(action,'89') & resources_for('camera_refresh','89'),action)
|
||||
Reference in New Issue
Block a user