Esempio n. 1
0
 def open_run_button_clicked(self, widget):
     from rafcon.core.singleton import state_machine_execution_engine
     state_machine = self.open_library_as_state_machine()
     if state_machine:
         state_machine_execution_engine.start(state_machine.state_machine_id)
 def run_state_machine(self):
     sms = state_machine_manager.state_machines
     state_machine_execution_engine.start(
         sms[sms.keys()[0]].state_machine_id)
     state_machine_execution_engine.join()
Esempio n. 3
0
    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)))