def push_sm_running_dialog(): message_string = "The state machine is still running. Are you sure you want to close?" dialog = RAFCONButtonDialog(message_string, ["Stop and close", "Cancel"], message_type=gtk.MESSAGE_QUESTION, parent=self.get_root_window()) response_id = dialog.run() dialog.destroy() if response_id == 1: logger.debug("State machine execution is being stopped") state_machine_execution_engine.stop() remove_state_machine_m() return True elif response_id == 2: logger.debug("State machine execution will keep running") return False
def push_sm_running_dialog(): message_string = "The state machine is still running. Are you sure you want to close?" dialog = RAFCONButtonDialog(message_string, ["Stop and close", "Cancel"], message_type=Gtk.MessageType.QUESTION, parent=self.get_root_window()) response_id = dialog.run() dialog.destroy() if response_id == 1: logger.debug("State machine execution is being stopped") state_machine_execution_engine.stop() state_machine_execution_engine.join() # wait for gui is needed; otherwise the signals related to the execution engine cannot # be processed properly by the state machine under destruction rafcon.gui.utils.wait_for_gui() remove_state_machine_m() return True elif response_id == 2: logger.debug("State machine execution will keep running") return False
def test_run_this_state(caplog): # run_selected # Initialize testing environment testing_utils.initialize_environment_core() # Load State Machine sm = storage.load_state_machine_from_path( testing_utils.get_test_sm_path( os.path.join("unit_test_state_machines", "test_run_this_state"))) rafcon.core.singleton.state_machine_manager.add_state_machine(sm) # Run selected state machine rafcon.core.singleton.global_variable_manager.set_variable("test_value", 1) state_machine_execution_engine.run_selected_state("BTWFZQ/EPQSTG", sm.state_machine_id) wait_for_execution_engine_sync_counter(1, logger) state_machine_execution_engine.stop() rafcon.core.singleton.state_machine_execution_engine.join() # assert variable state try: assert rafcon.core.singleton.global_variable_manager.get_variable( "test_value") == 2 # Shutdown testing environment finally: testing_utils.shutdown_environment_only_core(caplog=caplog)
def execute(self, inputs, outputs, gvm): self.logger.info("Stopping state machine") smee.stop() return "success"
def monitoring_data_received_function(self, message, address): """ This functions receives all messages sent by the remote RAFCON server. :param message: the received message :param address: the address (port, ip-address) of the remote server :return: """ logger.info("Received datagram {0} from address: {1}".format(str(message), str(address))) assert isinstance(message, Protocol) network_manager_model.add_to_message_list(message.message_content, address, "received") if message.message_type is MessageType.REGISTER: ident = message.message_content.split("@") if 2 < ident: ident.append(None) network_manager_model.set_connected_ip_port(address) network_manager_model.set_connected_id(address, ident[1]) network_manager_model.set_connected_status(address, "connected") if ident[1]: protocol = Protocol(MessageType.ID, global_network_config.get_config_value("SERVER_ID")) self.send_message_non_acknowledged(protocol, address) network_manager_model.add_to_message_list(protocol, address, "send") thread = Thread(target=ping_endpoint, args=(address, )) thread.daemon = True thread.start() elif message.message_type is MessageType.COMMAND and network_manager_model.get_connected_status(address) is not "disabled": received_command = message.message_content.split("@") execution_mode = StateMachineExecutionStatus(int(received_command[0])) # currently the monitoring plugin cannot select the target state machine sm_key, sm = state_machine_manager.state_machines.items()[0] if execution_mode is StateMachineExecutionStatus.STARTED: # as there is no dedicated RUN_TO_STATE execution status the message has to be checked for an optional # start state path if len(received_command) == 2: print "start state machine from state " + received_command[1] state_machine_execution_engine.start(sm.state_machine_id, start_state_path=received_command[1]) else: state_machine_execution_engine.start(sm.state_machine_id) elif execution_mode is StateMachineExecutionStatus.STOPPED: state_machine_execution_engine.stop() elif execution_mode is StateMachineExecutionStatus.PAUSED: state_machine_execution_engine.pause() elif execution_mode is StateMachineExecutionStatus.FORWARD_INTO: state_machine_execution_engine.step_into() elif execution_mode is StateMachineExecutionStatus.FORWARD_OVER: state_machine_execution_engine.step_over() elif execution_mode is StateMachineExecutionStatus.FORWARD_OUT: state_machine_execution_engine.step_out() elif execution_mode is StateMachineExecutionStatus.BACKWARD: state_machine_execution_engine.backward_step() elif execution_mode is StateMachineExecutionStatus.RUN_TO_SELECTED_STATE: state_machine_execution_engine.run_to_selected_state(received_command[1], state_machine_id=sm.state_machine_id) elif message.message_type is MessageType.UNREGISTER: network_manager_model.set_connected_status(address, "disconnected") network_manager_model.delete_connection(address) logger.info("Received datagram {0} from address: {1}".format(str(message), str(address)))