Пример #1
0
 def __init__(self, opts):
     super(TaskManager, self).__init__()
     self.node = cauv.node.Node("task_manager")
     self.node.subMessage(messaging.AddTaskMessage())
     self.node.subMessage(messaging.RemoveTaskMessage())
     self.node.subMessage(messaging.SetTaskStateMessage())
     self.node.subMessage(messaging.AddConditionMessage())
     self.node.subMessage(messaging.RemoveConditionMessage())
     self.node.subMessage(messaging.SetConditionStateMessage())
     self.node.subMessage(messaging.RequestAIStateMessage())
     self.node.subMessage(messaging.ScriptControlMessage())
     self.node.subMessage(messaging.AIControlMessage())
     self.node.subMessage(messaging.ProcessEndedMessage())
     self.node.subMessage(messaging.DetectorFiredMessage())
     self.node.subMessage(messaging.ScriptExitMessage())
     self.all_paused = not opts.unpaused
     self.ai_state = AIState(self)
     #Tasks - list of tasks that (in right conditions) should be called
     self.tasks = NameDict()
     self.conditions = NameDict()
     self.detector_fire_timeouts = collections.defaultdict(int)
     #currently running task
     self.last_available_tasks = []
     self.last_active_tasks = []
     self.mission_name = opts.mission_name
     if opts.mission_save:
         self.load_mission(open(opts.mission_save))
     self.gui_send_all()
     self.node.addObserver(self)
Пример #2
0
 def add_test_condition(self, tm):
     tm.onAddConditionMessage.func(msg.AddConditionMessage("State"))
     cond_name = tm.node.messages[-1].conditionId
     self.assertTrue(cond_name.startswith("State"))
     tm.onAddTaskMessage.func(msg.AddTaskMessage("test"))
     task_name = tm.node.messages[-1].taskId
     self.assertTrue(task_name.startswith("test"))
     tm.onSetTaskStateMessage.func(
         msg.SetTaskStateMessage(task_name, [cond_name], {}, {}))
     condition = tm.conditions[cond_name]
     self.assertIn(condition, tm.tasks[task_name].conditions)
     return cond_name, task_name
Пример #3
0
 def test_start_script(self):
     tm = self.get_tm()
     tm.onAddTaskMessage.func(msg.AddTaskMessage("test"))
     task_state = tm.node.last_msg(msg.TaskStateMessage)
     task_name = task_state.taskId
     tm.onAIControlMessage.func(
         msg.AIControlMessage(msg.AICommand.ResumeAll))
     tm.start_script(tm.tasks[task_name])
     edit_process = tm.node.last_msg(msg.EditProcessMessage)
     start_process = tm.node.last_msg(msg.ProcessControlMessage)
     self.assertEqual(edit_process.command[0], "python2.7")
     self.assertTrue(edit_process.command[1].endswith("test_script.pyc"))
     self.assertIsNot(start_process, None)
Пример #4
0
 def test_set_task_options(self):
     tm = self.get_tm()
     tm.onAddTaskMessage.func(msg.AddTaskMessage("test"))
     task_state = tm.node.last_msg(msg.TaskStateMessage)
     task_name = task_state.taskId
     options = task_state.taskOptions
     self.assertIn('crash_limit', options)
     self.assertIn('priority', options)
     options['crash_limit'] = 666
     tm.onSetTaskStateMessage.func(
         msg.SetTaskStateMessage(task_name, [], options, {}))
     self.assertEqual(tm.tasks[task_name].options.crash_limit, 666)
     task_state = tm.node.last_msg(msg.TaskStateMessage)
     options = BoostMapToDict(task_state.taskOptions)
     self.assertEqual(options['crash_limit'], 666)
Пример #5
0
 def test_add_task(self):
     tm = self.get_tm()
     tm.onAddTaskMessage.func(msg.AddTaskMessage("test"))
     self.assertIn("test", {k.split("_")[0] for k in tm.tasks})
Пример #6
0
def add_task(ainode):
    task_type = raw_input('Enter task type: ')
    ainode.node.send(messaging.AddTaskMessage(task_type))
    + p_int + c \
    + p_int \
    + r).streamline()
p_PressureMessage.setParseAction(lambda x: messaging.PressureMessage(*x[0]))
p_AIMessage = pp.Group(l \
    + p_str \
    + r).streamline()
p_AIMessage.setParseAction(lambda x: messaging.AIMessage(*x[0]))
p_AIlogMessage = pp.Group(l \
    + p_str \
    + r).streamline()
p_AIlogMessage.setParseAction(lambda x: messaging.AIlogMessage(*x[0]))
p_AddTaskMessage = pp.Group(l \
    + p_str \
    + r).streamline()
p_AddTaskMessage.setParseAction(lambda x: messaging.AddTaskMessage(*x[0]))
p_RemoveTaskMessage = pp.Group(l \
    + p_str \
    + r).streamline()
p_RemoveTaskMessage.setParseAction(lambda x: messaging.RemoveTaskMessage(*x[0]))
p_SetTaskStateMessage = pp.Group(l \
    + p_str + c \
    + p_stringVec + c \
    + p_stringParamValueMap + c \
    + p_stringParamValueMap \
    + r).streamline()
p_SetTaskStateMessage.setParseAction(lambda x: messaging.SetTaskStateMessage(*x[0]))
p_TaskRemovedMessage = pp.Group(l \
    + p_str \
    + r).streamline()
p_TaskRemovedMessage.setParseAction(lambda x: messaging.TaskRemovedMessage(*x[0]))