Example #1
0
 def __init__(self):
     proc.Proc.__init__(self, self.__class__.__name__ + "Script")
     self.options = self.get_options()
     self.debug = self.Debug()
     self.task_name = self.options._task_name
     self.auv = control.AUV(self.node)
     self.node.subMessage(msg.SetTaskStateMessage())
Example #2
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)
Example #3
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
Example #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)
Example #5
0
    def test_script(self):
        with tp.TempProcessEnv(True) as env:
            env.start_process([
                os.path.join(test_dir, 'test_script.py'), '--wait_seconds',
                '2', '--task-name', 'test'
            ])

            time.sleep(1)
            default_opts = test_script.Script.DefaultOptions()
            default_opts.succeed = True
            default_opts.nest.c = 6434576
            opts = default_opts.to_flat_dict()
            env.node.send(msg.SetTaskStateMessage("test", [], {}, opts))
            time.sleep(1.5)

            log = env.get_log('log/test_script.py.log')
            self.relevant_log = log
            self.assertTrue(tp.grep_log(log, "Script completed successfully"))
            self.assertTrue(tp.grep_log(log, "Nested C: 6434576"))
Example #6
0
def set_task_conditions(ainode):
    task_id = str(raw_input('Enter task id: '))
    conditions = input('Enter conditions (as list): ')
    ainode.node.send(messaging.SetTaskStateMessage(task_id, conditions, {},
                                                   {}))
Example #7
0
def set_script_options(ainode):
    task_id = str(raw_input('Enter task id: '))
    script_options = input('Enter script options (as dict): ')
    ainode.node.send(
        messaging.SetTaskStateMessage(task_id, [], {}, script_options))
Example #8
0
def set_task_options(ainode):
    task_id = str(raw_input('Enter task id: '))
    task_options = input('Enter task options (as dict): ')
    ainode.node.send(
        messaging.SetTaskStateMessage(task_id, [], task_options, {}))
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]))
p_TaskStateMessage = pp.Group(l \
    + p_str + c \
    + p_stringVec + c \
    + p_stringParamValueMap + c \
    + p_stringParamValueMap + c \
    + p_stringParamValueMap + c \
    + p_bool \
    + r).streamline()
p_TaskStateMessage.setParseAction(lambda x: messaging.TaskStateMessage(*x[0]))
p_ScriptStateMessage = pp.Group(l \
    + p_str + c \