def __init__(self, robot_num, sim=False): super(Core, self).__init__(robot_num, sim) StateMachine.__init__(self) self.CC = Chase() self.AC = Attack() self.BC = Behavior() self.sim = sim
def __init__(self, sim = False): super(Core, self).__init__(sim) StateMachine.__init__(self) self.CC = Chase() self.BC = Behavior() self.block = 0 dsrv = DynamicReconfigureServer(PassingConfig, self.Callback)
def __init__(self, _id=None, level=None, room=None, speed=50, chance_to_hit=0.5, weapon_damage=5, healing=0, max_health=100, health=100, ammo=0, morale=100): self._id = _id if _id else str(uuid.uuid4()) self.level = level self.room = room self.speed = speed self.chance_to_hit = chance_to_hit self.weapon_damage = weapon_damage # Note: should depend on equipment self.fight_cooldown = 1.0 self.healing = healing self.health = health self.ammo = ammo self.morale = morale self._path = deque() # the current path the entity is on self._vision = set() # the rooms currently visible to the entity self._timeout = 0 self._fight_timeout = 0 def log_state_change(a, b): self.log("%s -> %s" % (a, b)) StateMachine.__init__(self, ["IDLE", "MOVING", "FIGHTING", "DEAD"], on_state_change=log_state_change)
def __init__(self, sim=False): super(Core, self).__init__(sim) StateMachine.__init__(self) self.BC = Behavior() self.BK = Block() self.left_ang = 0 self.cp_value = 0 dsrv = DynamicReconfigureServer(RobotConfig, self.Callback)
def __init__(self, fromContainer, toContainer, maxRate=float('inf')): self.fromContainer = fromContainer self.toContainer = toContainer self.maxRate = maxRate StateMachine.__init__(self, self.states, self.initial, self.transitions)
def __init__(self, sim=False): super(MyStateMachine, self).__init__(sim) StateMachine.__init__(self) dsrv = DynamicReconfigureServer(RobotConfig, self.callback) self.dclient = DynamicReconfigureClient("core", timeout=30, config_callback=None) self.mir = MIR(HOST)
def __init__(self, sim=False): super(Core, self).__init__(sim) StateMachine.__init__(self) self.CC = Chase() self.AC = Attack() self.BC = Behavior() self.left_ang = 0 self.dest_angle = 0 dsrv = DynamicReconfigureServer(RobotConfig, self.Callback)
def __init__(self, robot_num, sim = False): super(Core, self).__init__(robot_num, sim) StateMachine.__init__(self) self.CC = Chase() self.AC = Attack() self.BC = Behavior() self.goal_dis = 0 self.tStart = time.time() self.block = 0 dsrv = DynamicReconfigureServer(RobotConfig, self.Callback)
def __init__(self, camera, button, led, recording_folder): StateMachine.__init__(self) self._folder = recording_folder self._camera = camera self._button = button self._led = led self._tape = Tape() self._events = queue.Queue() self._conversion_queue = queue.Queue() self._button.add_pressed_cb(self._add_toggle_event)
def __init__(self, eventController, capacity=float('inf'), qty=0): self.capacity = capacity self.qty = qty self.inputs = set() self.outputs = set() self.lastupdate = 0 StateMachine.__init__(self, self.states, self.initial, self.transitions, prepare_event='prepare') EventMember.__init__(self, eventController)
def __init__(self, dummy): self.dummy = dummy self.count = 0 # ---- # | | # V | # INIT ----> STEP_01 ----> DONE # ^ | # | V # STEP_02 states = ["INIT", "STEP_01", "STEP_02", "DONE"] StateMachine.__init__(self, states) # first state, "when" statement is evaluate at each loop tic. # If it return true, go to step_01 self.INIT.when(lambda: self.dummy.is_step_finished).goto(self.STEP_01) # Setup an action that will be executed each time we enter in STEP_01 # state (from another state) self.STEP_01.set_action(self.action_01) # Setup a recurring action that will be executed each time we will # explicitly request to go into step_01 from step_01 # (inner state looping) self.STEP_01.set_recurring_action(self.action_recursive) # Go to next state if "when" statement is true self.STEP_01.when(lambda: self.dummy.is_step_finished).goto(self.DONE) # Execute change state machine to the current state (will execute # recurring action) if when statement is True one_to_one = lambda: not self.dummy.is_step_finished and self.count < 3 self.STEP_01.when(one_to_one).goto(self.STEP_01) # If "when" statement is true, execute action 2 and change state one_to_two = lambda: self.dummy.is_specific_action self.STEP_01.when(one_to_two).do(self.action_02).goto(self.STEP_02) # Go to step 01 if trigger next step and execute action 03 two_to_one = lambda: self.dummy.is_step_finished self.STEP_02.when(two_to_one).goto(self.STEP_01).do(self.action_03) # last step action self.DONE.set_action(self.done)
def __init__(self): StateMachine.__init__(self, GitLogParser.lookForGitCommitId) GitLogParser.logposts = []
def __init__(self, sim=False): super(MyStateMachine, self).__init__(sim) StateMachine.__init__(self) self.CC = Chase() self.AC = Attack() dsrv = DynamicReconfigureServer(RobotConfig, self.Callback)
def __init__(self): StateMachine.__init__(self, states, initial, transitions, prepare_event='prepare')
def __init__(self, person): StateMachine.__init__(self) self.person = person self.env = self.person.env
def __init__(self, runner, ctx): RequestQueue.__init__(self, runner) StateMachine.__init__(self) self.ctx = None self.set_context(ctx) # Do early. States might depend on ctx. self.states = { QUIESCENT: Quiescent(self, QUIESCENT), # Justing inverting INVERTING_URI: InvertingUri(self, INVERTING_URI, QUIESCENT, FAILING), # Requesting previous graph in order to do insert. INVERTING_URI_4_INSERT: InvertingUri(self, INVERTING_URI_4_INSERT, REQUESTING_URI_4_INSERT, FAILING), REQUESTING_URI_4_INSERT: RequestingUri(self, REQUESTING_URI_4_INSERT, REQUESTING_GRAPH, FAILING), REQUESTING_GRAPH: RequestingGraph(self, REQUESTING_GRAPH, INSERTING_BUNDLES, FAILING), # Inserting INSERTING_BUNDLES: InsertingBundles(self, INSERTING_BUNDLES), INSERTING_GRAPH: InsertingGraph(self, INSERTING_GRAPH, INSERTING_URI, FAILING), INSERTING_URI: InsertingUri(self, INSERTING_URI, FINISHING, FAILING), CANCELING: CleaningUp(self, CANCELING, QUIESCENT), FAILING: CleaningUp(self, FAILING, QUIESCENT), # Requesting REQUESTING_URI: RequestingUri(self, REQUESTING_URI, REQUESTING_BUNDLES, FAILING), REQUESTING_BUNDLES: RequestingBundles(self, REQUESTING_BUNDLES, FINISHING, FAILING), FINISHING: CleaningUp(self, FINISHING, QUIESCENT), # Requesting head info from freenet REQUESTING_URI_4_HEADS: RequestingUri(self, REQUESTING_URI_4_HEADS, REQUIRES_GRAPH_4_HEADS, FAILING), REQUIRES_GRAPH_4_HEADS: RequiresGraph(self, REQUIRES_GRAPH_4_HEADS, REQUESTING_GRAPH_4_HEADS, FINISHING), REQUESTING_GRAPH_4_HEADS: RequestingGraph(self, REQUESTING_GRAPH_4_HEADS, FINISHING, FAILING), # Run and arbitrary StatefulRequest. RUNNING_SINGLE_REQUEST: RunningSingleRequest(self, RUNNING_SINGLE_REQUEST, FINISHING, FAILING), # Copying. # This doesn't verify that the graph chk(s) are fetchable. REQUESTING_URI_4_COPY: RequestingUri(self, REQUESTING_URI_4_COPY, INSERTING_URI, FAILING), } self.current_state = self.get_state(QUIESCENT) self.params = {} # Must not change any state! self.monitor_callback = lambda parent, client, msg: None runner.add_queue(self)
def __init__(self, model=None, state_field='state', start_value=None): StateMachine.__init__(self, model, state_field, start_value) self.stack = []
def __init__(self, comp): StateMachine.__init__(self) self.comp = comp
def __init__(self, runner, ctx): RequestQueue.__init__(self, runner) StateMachine.__init__(self) self.ctx = None self.set_context(ctx) # Do early. States might depend on ctx. self.states = { QUIESCENT:Quiescent(self, QUIESCENT), # Justing inverting INVERTING_URI:InvertingUri(self, INVERTING_URI, QUIESCENT, FAILING), # Requesting previous graph in order to do insert. INVERTING_URI_4_INSERT:InvertingUri(self, INVERTING_URI_4_INSERT, REQUESTING_URI_4_INSERT, FAILING), REQUESTING_URI_4_INSERT:RequestingUri(self, REQUESTING_URI_4_INSERT, REQUESTING_GRAPH, FAILING), REQUESTING_GRAPH:RequestingGraph(self, REQUESTING_GRAPH, INSERTING_BUNDLES, FAILING), # Inserting INSERTING_BUNDLES:InsertingBundles(self, INSERTING_BUNDLES), INSERTING_GRAPH:InsertingGraph(self, INSERTING_GRAPH, INSERTING_URI, FAILING), INSERTING_URI:InsertingUri(self,INSERTING_URI, FINISHING, FAILING), CANCELING:CleaningUp(self, CANCELING, QUIESCENT), FAILING:CleaningUp(self, FAILING, QUIESCENT), # Requesting REQUESTING_URI:RequestingUri(self, REQUESTING_URI, REQUESTING_BUNDLES, FAILING), REQUESTING_BUNDLES:RequestingBundles(self, REQUESTING_BUNDLES, FINISHING, FAILING), FINISHING:CleaningUp(self, FINISHING, QUIESCENT), # Requesting head info from freenet REQUESTING_URI_4_HEADS:RequestingUri(self, REQUESTING_URI_4_HEADS, REQUIRES_GRAPH_4_HEADS, FAILING), REQUIRES_GRAPH_4_HEADS:RequiresGraph(self, REQUIRES_GRAPH_4_HEADS, REQUESTING_GRAPH_4_HEADS, FINISHING), REQUESTING_GRAPH_4_HEADS:RequestingGraph(self, REQUESTING_GRAPH_4_HEADS, FINISHING, FAILING), # Run and arbitrary StatefulRequest. RUNNING_SINGLE_REQUEST:RunningSingleRequest(self, RUNNING_SINGLE_REQUEST, FINISHING, FAILING), # Copying. # This doesn't verify that the graph chk(s) are fetchable. REQUESTING_URI_4_COPY:RequestingUri(self, REQUESTING_URI_4_COPY, INSERTING_URI, FAILING), } self.current_state = self.get_state(QUIESCENT) self.params = {} # Must not change any state! self.monitor_callback = lambda parent, client, msg: None runner.add_queue(self)