idx
int64
0
63k
question
stringlengths
53
5.28k
target
stringlengths
5
805
40,600
def run_to_states ( self ) : self . execution_engine_lock . acquire ( ) return_value = self . _run_to_states self . execution_engine_lock . release ( ) return return_value
Property for the _run_to_states field
40,601
def recursively_preempt_states ( self ) : super ( ContainerState , self ) . recursively_preempt_states ( ) self . _transitions_cv . acquire ( ) self . _transitions_cv . notify_all ( ) self . _transitions_cv . release ( ) for state in self . states . values ( ) : state . recursively_preempt_states ( )
Preempt the state and all of it child states .
40,602
def recursively_pause_states ( self ) : super ( ContainerState , self ) . recursively_pause_states ( ) for state in self . states . values ( ) : state . recursively_pause_states ( )
Pause the state and all of it child states .
40,603
def recursively_resume_states ( self ) : super ( ContainerState , self ) . recursively_resume_states ( ) for state in self . states . values ( ) : state . recursively_resume_states ( )
Resume the state and all of it child states .
40,604
def handle_no_transition ( self , state ) : transition = None while not transition : if self . preempted or state . final_outcome . outcome_id in [ - 2 , - 1 ] : if self . concurrency_queue : self . concurrency_queue . put ( self . state_id ) self . state_execution_status = StateExecutionStatus . WAIT_FOR_NEXT_STATE if...
This function handles the case that there is no transition for a specific outcome of a sub - state .
40,605
def handle_no_start_state ( self ) : start_state = self . get_start_state ( set_final_outcome = True ) while not start_state : execution_signal = state_machine_execution_engine . handle_execution_mode ( self ) if execution_signal is StateMachineExecutionStatus . STOPPED : return None self . _transitions_cv . acquire ( ...
Handles the situation when no start state exists during execution
40,606
def add_state ( self , state , storage_load = False ) : assert isinstance ( state , State ) while state . state_id == self . state_id or state . state_id in self . states : state . change_state_id ( ) if state . state_id in self . _states . keys ( ) : raise AttributeError ( "State id %s already exists in the container ...
Adds a state to the container state .
40,607
def remove_state ( self , state_id , recursive = True , force = False , destroy = True ) : if state_id not in self . states : raise AttributeError ( "State_id %s does not exist" % state_id ) if state_id == self . start_state_id : self . set_start_state ( None ) keys_to_delete = [ ] for key , transition in self . transi...
Remove a state from the container state .
40,608
def change_state_type ( self , state , new_state_class ) : from rafcon . gui . helpers . state import create_new_state_from_state_with_type state_id = state . state_id if state_id not in self . states : raise ValueError ( "State '{0}' with id '{1}' does not exist" . format ( state . name , state_id ) ) new_state = crea...
Changes the type of the state to another type
40,609
def set_start_state ( self , state ) : if state is None : self . start_state_id = None elif isinstance ( state , State ) : self . start_state_id = state . state_id else : self . start_state_id = state
Sets the start state of a container state
40,610
def get_start_state ( self , set_final_outcome = False ) : if self . get_path ( ) in state_machine_execution_engine . start_state_paths : for state_id , state in self . states . items ( ) : if state . get_path ( ) in state_machine_execution_engine . start_state_paths : state_machine_execution_engine . start_state_paths...
Get the start state of the container state
40,611
def check_transition_id ( self , transition_id ) : if transition_id is not None : if transition_id in self . _transitions . keys ( ) : raise AttributeError ( "The transition id %s already exists. Cannot add transition!" , transition_id ) else : transition_id = generate_transition_id ( ) while transition_id in self . _t...
Check the transition id and calculate a new one if its None
40,612
def check_if_outcome_already_connected ( self , from_state_id , from_outcome ) : for trans_key , transition in self . transitions . items ( ) : if transition . from_state == from_state_id : if transition . from_outcome == from_outcome : raise AttributeError ( "Outcome %s of state %s is already connected" % ( str ( from...
check if outcome of from state is not already connected
40,613
def create_transition ( self , from_state_id , from_outcome , to_state_id , to_outcome , transition_id ) : if from_state_id is not None : if from_state_id == self . state_id : from_state = self else : from_state = self . states [ from_state_id ] if from_outcome is not None : if from_outcome in from_state . outcomes : i...
Creates a new transition .
40,614
def add_transition ( self , from_state_id , from_outcome , to_state_id , to_outcome , transition_id = None ) : transition_id = self . check_transition_id ( transition_id ) if from_state_id == self . state_id and from_outcome is None : from_state_id = None new_transition = Transition ( from_state_id , from_outcome , to_...
Adds a transition to the container state
40,615
def get_transition_for_outcome ( self , state , outcome ) : if not isinstance ( state , State ) : raise TypeError ( "state must be of type State" ) if not isinstance ( outcome , Outcome ) : raise TypeError ( "outcome must be of type Outcome" ) result_transition = None for key , transition in self . transitions . items ...
Determines the next transition of a state .
40,616
def remove_transition ( self , transition_id , destroy = True ) : if transition_id == - 1 or transition_id == - 2 : raise AttributeError ( "The transition_id must not be -1 (Aborted) or -2 (Preempted)" ) if transition_id not in self . _transitions : raise AttributeError ( "The transition_id %s does not exist" % str ( t...
Removes a transition from the container state
40,617
def remove_outcome_hook ( self , outcome_id ) : for transition_id in list ( self . transitions . keys ( ) ) : transition = self . transitions [ transition_id ] if transition . to_outcome == outcome_id and transition . to_state == self . state_id : self . remove_transition ( transition_id )
Removes internal transition going to the outcome
40,618
def check_data_flow_id ( self , data_flow_id ) : if data_flow_id is not None : if data_flow_id in self . _data_flows . keys ( ) : raise AttributeError ( "The data_flow id %s already exists. Cannot add data_flow!" , data_flow_id ) else : data_flow_id = generate_data_flow_id ( ) while data_flow_id in self . _data_flows ....
Check the data flow id and calculate a new one if its None
40,619
def add_data_flow ( self , from_state_id , from_data_port_id , to_state_id , to_data_port_id , data_flow_id = None ) : data_flow_id = self . check_data_flow_id ( data_flow_id ) self . data_flows [ data_flow_id ] = DataFlow ( from_state_id , from_data_port_id , to_state_id , to_data_port_id , data_flow_id , self ) retur...
Adds a data_flow to the container state
40,620
def remove_data_flow ( self , data_flow_id , destroy = True ) : if data_flow_id not in self . _data_flows : raise AttributeError ( "The data_flow_id %s does not exist" % str ( data_flow_id ) ) self . _data_flows [ data_flow_id ] . parent = None return self . _data_flows . pop ( data_flow_id )
Removes a data flow from the container state
40,621
def remove_data_flows_with_data_port_id ( self , data_port_id ) : if not self . is_root_state and not self . is_root_state_of_library : data_flow_ids_to_remove = [ ] for data_flow_id , data_flow in self . parent . data_flows . items ( ) : if data_flow . from_state == self . state_id and data_flow . from_key == data_por...
Remove an data ports whose from_key or to_key equals the passed data_port_id
40,622
def get_scoped_variable_from_name ( self , name ) : for scoped_variable_id , scoped_variable in self . scoped_variables . items ( ) : if scoped_variable . name == name : return scoped_variable_id raise AttributeError ( "Name %s is not in scoped_variables dictionary" , name )
Get the scoped variable for a unique name
40,623
def add_scoped_variable ( self , name , data_type = None , default_value = None , scoped_variable_id = None ) : if scoped_variable_id is None : scoped_variable_id = generate_data_port_id ( self . get_data_port_ids ( ) ) self . _scoped_variables [ scoped_variable_id ] = ScopedVariable ( name , data_type , default_value ...
Adds a scoped variable to the container state
40,624
def remove_scoped_variable ( self , scoped_variable_id , destroy = True ) : if scoped_variable_id not in self . _scoped_variables : raise AttributeError ( "A scoped variable with id %s does not exist" % str ( scoped_variable_id ) ) if destroy : self . remove_data_flows_with_data_port_id ( scoped_variable_id ) self . _s...
Remove a scoped variable from the container state
40,625
def get_data_port ( self , state_id , port_id ) : if state_id == self . state_id : return self . get_data_port_by_id ( port_id ) for child_state_id , child_state in self . states . items ( ) : if state_id != child_state_id : continue port = child_state . get_data_port_by_id ( port_id ) if port : return port return None
Searches for a data port
40,626
def get_inputs_for_state ( self , state ) : result_dict = { } tmp_dict = self . get_default_input_values_for_state ( state ) result_dict . update ( tmp_dict ) for input_port_key , value in state . input_data_ports . items ( ) : actual_value = None actual_value_time = 0 for data_flow_key , data_flow in self . data_flows...
Retrieves all input data of a state . If several data flows are connected to an input port the most current data is used for the specific input port .
40,627
def add_input_data_to_scoped_data ( self , dictionary ) : for dict_key , value in dictionary . items ( ) : for input_data_port_key , data_port in list ( self . input_data_ports . items ( ) ) : if dict_key == data_port . name : self . scoped_data [ str ( input_data_port_key ) + self . state_id ] = ScopedData ( data_port...
Add a dictionary to the scoped data
40,628
def add_state_execution_output_to_scoped_data ( self , dictionary , state ) : for output_name , value in dictionary . items ( ) : for output_data_port_key , data_port in list ( state . output_data_ports . items ( ) ) : if output_name == data_port . name : if not isinstance ( value , data_port . data_type ) : if ( not (...
Add a state execution output to the scoped data
40,629
def add_default_values_of_scoped_variables_to_scoped_data ( self ) : for key , scoped_var in self . scoped_variables . items ( ) : self . scoped_data [ str ( scoped_var . data_port_id ) + self . state_id ] = ScopedData ( scoped_var . name , scoped_var . default_value , scoped_var . data_type , self . state_id , ScopedV...
Add the scoped variables default values to the scoped_data dictionary
40,630
def update_scoped_variables_with_output_dictionary ( self , dictionary , state ) : for key , value in dictionary . items ( ) : output_data_port_key = None for o_key , o_port in state . output_data_ports . items ( ) : if o_port . name == key : output_data_port_key = o_key break if output_data_port_key is None : if not k...
Update the values of the scoped variables with the output dictionary of a specific state .
40,631
def change_state_id ( self , state_id = None ) : old_state_id = self . state_id super ( ContainerState , self ) . change_state_id ( state_id ) for transition in self . transitions . values ( ) : if transition . from_state == old_state_id : transition . _from_state = self . state_id if transition . to_state == old_state...
Changes the id of the state to a new id . This functions replaces the old state_id with the new state_id in all data flows and transitions .
40,632
def get_state_for_transition ( self , transition ) : if not isinstance ( transition , Transition ) : raise TypeError ( "transition must be of type Transition" ) if transition . to_state == self . state_id or transition . to_state is None : return self else : return self . states [ transition . to_state ]
Calculate the target state of a transition
40,633
def write_output_data ( self , specific_output_dictionary = None ) : if isinstance ( specific_output_dictionary , dict ) : output_dict = specific_output_dictionary else : output_dict = self . output_data for output_name , value in self . output_data . items ( ) : output_port_id = self . get_io_data_port_id_from_name_an...
Write the scoped data to output of the state . Called before exiting the container state .
40,634
def check_data_port_connection ( self , check_data_port ) : for data_flow in self . data_flows . values ( ) : from_port = self . get_data_port ( data_flow . from_state , data_flow . from_key ) to_port = self . get_data_port ( data_flow . to_state , data_flow . to_key ) if check_data_port is from_port or check_data_port...
Checks the connection validity of a data port
40,635
def _check_data_flow_validity ( self , check_data_flow ) : valid , message = self . _check_data_flow_id ( check_data_flow ) if not valid : return False , message valid , message = self . _check_data_flow_ports ( check_data_flow ) if not valid : return False , message return self . _check_data_flow_types ( check_data_fl...
Checks the validity of a data flow
40,636
def _check_data_flow_id ( self , data_flow ) : data_flow_id = data_flow . data_flow_id if data_flow_id in self . data_flows and data_flow is not self . data_flows [ data_flow_id ] : return False , "data_flow_id already existing" return True , "valid"
Checks the validity of a data flow id
40,637
def _check_data_flow_ports ( self , data_flow ) : from_state_id = data_flow . from_state to_state_id = data_flow . to_state from_data_port_id = data_flow . from_key to_data_port_id = data_flow . to_key from_data_port = self . get_data_port ( from_state_id , from_data_port_id ) if not from_data_port : return False , "Da...
Checks the validity of the ports of a data flow
40,638
def _check_data_flow_types ( self , check_data_flow ) : from_data_port = self . get_data_port ( check_data_flow . from_state , check_data_flow . from_key ) to_data_port = self . get_data_port ( check_data_flow . to_state , check_data_flow . to_key ) if from_data_port . data_type is object : return True , "valid" if not...
Checks the validity of the data flow connection
40,639
def _check_transition_validity ( self , check_transition ) : valid , message = self . _check_transition_id ( check_transition ) if not valid : return False , message if check_transition . from_state is None : return self . _check_start_transition ( check_transition ) valid , message = self . _check_transition_origin ( ...
Checks the validity of a transition
40,640
def _check_transition_id ( self , transition ) : transition_id = transition . transition_id if transition_id in self . transitions and transition is not self . transitions [ transition_id ] : return False , "transition_id already existing" return True , "valid"
Checks the validity of a transition id
40,641
def _check_start_transition ( self , start_transition ) : for transition in self . transitions . values ( ) : if transition . from_state is None : if start_transition is not transition : return False , "Only one start transition is allowed" if start_transition . from_outcome is not None : return False , "from_outcome m...
Checks the validity of a start transition
40,642
def _check_transition_target ( self , transition ) : to_state_id = transition . to_state to_outcome_id = transition . to_outcome if to_state_id == self . state_id : if to_outcome_id not in self . outcomes : return False , "to_outcome is not existing" else : if to_state_id not in self . states : return False , "to_state...
Checks the validity of a transition target
40,643
def _check_transition_origin ( self , transition ) : from_state_id = transition . from_state from_outcome_id = transition . from_outcome if from_state_id == self . state_id : return False , "from_state_id of transition must not be the container state itself." " In the case of a start transition both the from state and ...
Checks the validity of a transition origin
40,644
def _check_transition_connection ( self , check_transition ) : from_state_id = check_transition . from_state from_outcome_id = check_transition . from_outcome to_state_id = check_transition . to_state to_outcome_id = check_transition . to_outcome for transition in self . transitions . values ( ) : if transition . from_...
Checks the validity of a transition connection
40,645
def states ( self , states ) : if not isinstance ( states , dict ) : raise TypeError ( "states must be of type dict" ) if [ state_id for state_id , state in states . items ( ) if not isinstance ( state , State ) ] : raise TypeError ( "element of container_state.states must be of type State" ) if [ state_id for state_id...
Setter for _states field
40,646
def transitions ( self , transitions ) : if not isinstance ( transitions , dict ) : raise TypeError ( "transitions must be of type dict" ) if [ t_id for t_id , transition in transitions . items ( ) if not isinstance ( transition , Transition ) ] : raise TypeError ( "element of transitions must be of type Transition" ) ...
Setter for _transitions field
40,647
def data_flows ( self , data_flows ) : if not isinstance ( data_flows , dict ) : raise TypeError ( "data_flows must be of type dict" ) if [ df_id for df_id , data_flow in data_flows . items ( ) if not isinstance ( data_flow , DataFlow ) ] : raise TypeError ( "element of data_flows must be of type DataFlow" ) if [ df_id...
Setter for _data_flows field
40,648
def start_state_id ( self ) : for transition_id in self . transitions : if self . transitions [ transition_id ] . from_state is None : to_state = self . transitions [ transition_id ] . to_state if to_state is not None : return to_state else : return self . state_id return None
The start state is the state to which the first transition goes to .
40,649
def start_state_id ( self , start_state_id , to_outcome = None ) : if start_state_id is not None and start_state_id not in self . states : raise ValueError ( "start_state_id does not exist" ) if start_state_id is None and to_outcome is not None : if to_outcome not in self . outcomes : raise ValueError ( "to_outcome doe...
Set the start state of the container state
40,650
def scoped_variables ( self , scoped_variables ) : if not isinstance ( scoped_variables , dict ) : raise TypeError ( "scoped_variables must be of type dict" ) if [ sv_id for sv_id , sv in scoped_variables . items ( ) if not isinstance ( sv , ScopedVariable ) ] : raise TypeError ( "element of scope variable must be of t...
Setter for _scoped_variables field
40,651
def _execute ( self , execute_inputs , execute_outputs , backward_execution = False ) : self . _script . build_module ( ) outcome_item = self . _script . execute ( self , execute_inputs , execute_outputs , backward_execution ) if backward_execution : return if self . preempted : return Outcome ( - 2 , "preempted" ) if ...
Calls the custom execute function of the script . py of the state
40,652
def run ( self ) : if self . is_root_state : self . execution_history . push_call_history_item ( self , CallType . EXECUTE , None , self . input_data ) logger . debug ( "Running {0}{1}" . format ( self , " (backwards)" if self . backward_execution else "" ) ) if self . backward_execution : self . setup_backward_run ( )...
This defines the sequence of actions that are taken when the execution state is executed
40,653
def register_view ( self , view ) : super ( StateMachineTreeController , self ) . register_view ( view ) self . view . connect ( 'button_press_event' , self . mouse_click ) self . view_is_registered = True self . update ( with_expand = True )
Called when the view was registered
40,654
def register ( self ) : self . _do_selection_update = True if self . __my_selected_sm_id is not None : self . relieve_model ( self . _selected_sm_model ) self . __my_selected_sm_id = self . model . selected_state_machine_id if self . __my_selected_sm_id is not None : self . _selected_sm_model = self . model . state_mac...
Change the state machine that is observed for new selected states to the selected state machine .
40,655
def selection_changed ( self , widget , event = None ) : if self . _state_which_is_updated : return super ( StateMachineTreeController , self ) . selection_changed ( widget , event )
Notify state machine about tree view selection
40,656
def redo_expansion_state ( self , ignore_not_existing_rows = False ) : def set_expansion_state ( state_path ) : state_row_iter = self . state_row_iter_dict_by_state_path [ state_path ] if state_row_iter : state_row_path = self . tree_store . get_path ( state_row_iter ) self . view . expand_to_path ( state_row_path ) if...
Considers the tree to be collapsed and expand into all tree item with the flag set True
40,657
def update ( self , changed_state_model = None , with_expand = False ) : if not self . view_is_registered : return if changed_state_model is None : parent_row_iter = None self . state_row_iter_dict_by_state_path . clear ( ) self . tree_store . clear ( ) if self . _selected_sm_model : changed_state_model = self . _selec...
Checks if all states are in tree and if tree has states which were deleted
40,658
def show_content ( self , state_model ) : upper_most_lib_state_m = None if isinstance ( state_model , LibraryStateModel ) : uppermost_library_root_state = state_model . state . get_uppermost_library_root_state ( ) if uppermost_library_root_state is None : upper_most_lib_state_m = state_model else : upper_lib_state = up...
Check state machine tree specific show content flag .
40,659
def get_state_machine_selection ( self ) : if self . _selected_sm_model : return self . _selected_sm_model . selection , self . _selected_sm_model . selection . states else : return None , set ( )
Getter state machine selection
40,660
def execute ( self , state , inputs = None , outputs = None , backward_execution = False ) : if not outputs : outputs = { } if not inputs : inputs = { } if backward_execution : if hasattr ( self . _compiled_module , "backward_execute" ) : return self . _compiled_module . backward_execute ( state , inputs , outputs , ra...
Execute the user execute function specified in the script
40,661
def _load_script ( self ) : script_text = filesystem . read_file ( self . path , self . filename ) if not script_text : raise IOError ( "Script file could not be opened or was empty: {0}" "" . format ( os . path . join ( self . path , self . filename ) ) ) self . script = script_text
Loads the script from the filesystem
40,662
def build_module ( self ) : try : imp . acquire_lock ( ) module_name = os . path . splitext ( self . filename ) [ 0 ] + str ( self . _script_id ) tmp_module = imp . new_module ( module_name ) code = compile ( self . script , '%s (%s)' % ( self . filename , self . _script_id ) , 'exec' ) try : exec ( code , tmp_module ....
Builds a temporary module from the script file
40,663
def _update_recently_opened_state_machines ( self ) : if not self . registered_view : return for item in self . view . sub_menu_open_recently . get_children ( ) : self . view . sub_menu_open_recently . remove ( item ) menu_item = gui_helper_label . create_menu_item ( "remove invalid paths" , constants . ICON_ERASE , gl...
Update the sub menu Open Recent in File menu
40,664
def point_left_of_line ( point , line_start , line_end ) : return ( ( line_end [ 0 ] - line_start [ 0 ] ) * ( point [ 1 ] - line_start [ 1 ] ) - ( line_end [ 1 ] - line_start [ 1 ] ) * ( point [ 0 ] - line_start [ 0 ] ) ) < 0
Determines whether a point is left of a line
40,665
def point_on_line ( point , line_start , line_end , accuracy = 50. ) : length = dist ( line_start , line_end ) ds = length / float ( accuracy ) if - ds < ( dist ( line_start , point ) + dist ( point , line_end ) - length ) < ds : return True return False
Checks whether a point lies on a line
40,666
def point_in_triangle ( p , v1 , v2 , v3 ) : def _test ( p1 , p2 , p3 ) : return ( p1 [ 0 ] - p3 [ 0 ] ) * ( p2 [ 1 ] - p3 [ 1 ] ) - ( p2 [ 0 ] - p3 [ 0 ] ) * ( p1 [ 1 ] - p3 [ 1 ] ) b1 = _test ( p , v1 , v2 ) < 0.0 b2 = _test ( p , v2 , v3 ) < 0.0 b3 = _test ( p , v3 , v1 ) < 0.0 return ( b1 == b2 ) and ( b2 == b3 )
Checks whether a point is within the given triangle
40,667
def equal ( t1 , t2 , digit = None ) : if not len ( t1 ) == len ( t2 ) : return False for idx in range ( len ( t1 ) ) : if digit is not None : if not round ( t1 [ idx ] , digit ) == round ( t2 [ idx ] , digit ) : return False else : if not t1 [ idx ] == t2 [ idx ] : return False return True
Compare two iterators and its elements on specific digit precision
40,668
def cal_dist_between_2_coord_frame_aligned_boxes ( box1_pos , box1_size , box2_pos , box2_size ) : box1_x_min , box1_y_min = box1_pos box1_x_max , box1_y_max = ( box1_pos [ 0 ] + box1_size [ 0 ] , box1_pos [ 1 ] + box1_size [ 1 ] ) box2_x_min , box2_y_min = box2_pos box2_x_max , box2_y_max = ( box2_pos [ 0 ] + box2_siz...
Calculate Euclidean distance between two boxes those edges are parallel to the coordinate axis
40,669
def get_history_item_for_tree_iter ( self , child_tree_iter ) : history_item = self . history_tree_store [ child_tree_iter ] [ self . HISTORY_ITEM_STORAGE_ID ] if history_item is None : if self . history_tree_store . iter_n_children ( child_tree_iter ) > 0 : child_iter = self . history_tree_store . iter_nth_child ( chi...
Hands history item for tree iter and compensate if tree item is a dummy item
40,670
def _store_expansion_state ( self ) : def store_tree_expansion ( child_tree_iter , expansion_state ) : tree_item_path = self . history_tree_store . get_path ( child_tree_iter ) history_item = self . get_history_item_for_tree_iter ( child_tree_iter ) if tree_item_path is not None : if history_item not in expansion_state...
Iter recursively all tree items and store expansion state
40,671
def _restore_expansion_state ( self ) : def restore_tree_expansion ( child_tree_iter , expansion_state ) : tree_item_path = self . history_tree_store . get_path ( child_tree_iter ) history_item = self . get_history_item_for_tree_iter ( child_tree_iter ) if tree_item_path and history_item in expansion_state : if expansi...
Iter recursively all tree items and restore expansion state
40,672
def notification_selected_sm_changed ( self , model , prop_name , info ) : selected_state_machine_id = self . model . selected_state_machine_id if selected_state_machine_id is None : return self . update ( )
If a new state machine is selected make sure expansion state is stored and tree updated
40,673
def notification_sm_changed ( self , model , prop_name , info ) : for state_machine_id in list ( self . _expansion_state . keys ( ) ) : if state_machine_id not in self . model . state_machines : del self . _expansion_state [ state_machine_id ]
Remove references to non - existing state machines
40,674
def execution_history_focus ( self , model , prop_name , info ) : if state_machine_execution_engine . status . execution_mode in [ StateMachineExecutionStatus . STARTED , StateMachineExecutionStatus . STOPPED , StateMachineExecutionStatus . FINISHED ] : if self . parent is not None and hasattr ( self . parent , "focus_...
Arranges to put execution - history widget page to become top page in notebook when execution starts and stops and resets the boolean of modification_history_was_focused to False each time this notification are observed .
40,675
def clean_history ( self , widget , event = None ) : self . history_tree_store . clear ( ) selected_sm_m = self . model . get_selected_state_machine_model ( ) if selected_sm_m : if state_machine_execution_engine . finished_or_stopped ( ) : selected_sm_m . state_machine . destroy_execution_histories ( ) self . update ( ...
Triggered when the Clean History button is clicked .
40,676
def insert_history_item ( self , parent , history_item , description , dummy = False ) : if not history_item . state_reference : logger . error ( "This must never happen! Current history_item is {}" . format ( history_item ) ) return None content = None if global_gui_config . get_config_value ( "SHOW_PATH_NAMES_IN_EXEC...
Enters a single history item into the tree store
40,677
def insert_execution_history ( self , parent , execution_history , is_root = False ) : current_parent = parent execution_history_iterator = iter ( execution_history ) for history_item in execution_history_iterator : if isinstance ( history_item , ConcurrencyItem ) : self . insert_concurrent_execution_histories ( curren...
Insert a list of history items into a the tree store
40,678
def insert_concurrent_execution_histories ( self , parent , concurrent_execution_histories ) : for execution_history in concurrent_execution_histories : if len ( execution_history ) >= 1 : first_history_item = execution_history [ 0 ] tree_item = self . insert_history_item ( parent , first_history_item , "Concurrency Br...
Adds the child execution histories of a concurrency state .
40,679
def select_open_state_machine_of_selected_library_element ( self ) : ( model , row_path ) = self . view . get_selection ( ) . get_selected ( ) if row_path : physical_library_path = model [ row_path ] [ self . ITEM_STORAGE_ID ] smm = gui_singletons . state_machine_manager_model . state_machine_manager sm = smm . get_ope...
Select respective state machine of selected library in state machine manager if already open
40,680
def menu_item_remove_libraries_or_root_clicked ( self , menu_item ) : menu_item_text = self . get_menu_item_text ( menu_item ) logger . info ( "Delete item '{0}' pressed." . format ( menu_item_text ) ) model , path = self . view . get_selection ( ) . get_selected ( ) if path : tree_m_row = self . tree_store [ path ] li...
Removes library from hard drive after request second confirmation
40,681
def extract_library_properties_from_selected_row ( self ) : ( model , row ) = self . view . get_selection ( ) . get_selected ( ) tree_item_key = model [ row ] [ self . ID_STORAGE_ID ] library_item = model [ row ] [ self . ITEM_STORAGE_ID ] library_path = model [ row ] [ self . LIB_PATH_STORAGE_ID ] if isinstance ( libr...
Extracts properties library_os_path library_path library_name and tree_item_key from tree store row
40,682
def _get_selected_library_state ( self ) : library_os_path , library_path , library_name , item_key = self . extract_library_properties_from_selected_row ( ) if library_path is None : return None logger . debug ( "Link library state '{0}' (with library tree path: {2} and file system path: {1}) into state " "machine." ....
Returns the LibraryState which was selected in the LibraryTree
40,683
def start ( self , execution_history , backward_execution = False , generate_run_id = True ) : self . execution_history = execution_history if generate_run_id : self . _run_id = run_id_generator ( ) self . backward_execution = copy . copy ( backward_execution ) self . thread = threading . Thread ( target = self . run )...
Starts the execution of the state in a new thread .
40,684
def join ( self ) : if self . thread : self . thread . join ( ) self . thread = None else : logger . debug ( "Cannot join {0}, as the state hasn't been started, yet or is already finished!" . format ( self ) )
Waits until the state finished execution .
40,685
def recursively_preempt_states ( self ) : self . preempted = True self . paused = False self . started = False
Preempt the state
40,686
def get_default_input_values_for_state ( self , state ) : from rafcon . core . states . library_state import LibraryState result_dict = { } for input_port_key , value in state . input_data_ports . items ( ) : if isinstance ( state , LibraryState ) : if state . use_runtime_value_input_data_ports [ input_port_key ] : def...
Computes the default input values for a state
40,687
def create_output_dictionary_for_state ( state ) : from rafcon . core . states . library_state import LibraryState result_dict = { } for key , data_port in state . output_data_ports . items ( ) : if isinstance ( state , LibraryState ) and state . use_runtime_value_output_data_ports [ key ] : result_dict [ data_port . n...
Return empty output dictionary for a state
40,688
def add_input_data_port ( self , name , data_type = None , default_value = None , data_port_id = None ) : if data_port_id is None : data_port_id = generate_data_port_id ( self . get_data_port_ids ( ) ) self . _input_data_ports [ data_port_id ] = InputDataPort ( name , data_type , default_value , data_port_id , self ) v...
Add a new input data port to the state .
40,689
def remove_input_data_port ( self , data_port_id , force = False , destroy = True ) : if data_port_id in self . _input_data_ports : if destroy : self . remove_data_flows_with_data_port_id ( data_port_id ) self . _input_data_ports [ data_port_id ] . parent = None return self . _input_data_ports . pop ( data_port_id ) el...
Remove an input data port from the state
40,690
def remove_data_flows_with_data_port_id ( self , data_port_id ) : if not self . is_root_state : data_flow_ids_to_remove = [ ] for data_flow_id , data_flow in self . parent . data_flows . items ( ) : if data_flow . from_state == self . state_id and data_flow . from_key == data_port_id or data_flow . to_state == self . s...
Remove all data flows whose from_key or to_key equals the passed data_port_id
40,691
def add_output_data_port ( self , name , data_type , default_value = None , data_port_id = None ) : if data_port_id is None : data_port_id = generate_data_port_id ( self . get_data_port_ids ( ) ) self . _output_data_ports [ data_port_id ] = OutputDataPort ( name , data_type , default_value , data_port_id , self ) valid...
Add a new output data port to the state
40,692
def remove_output_data_port ( self , data_port_id , force = False , destroy = True ) : if data_port_id in self . _output_data_ports : if destroy : self . remove_data_flows_with_data_port_id ( data_port_id ) self . _output_data_ports [ data_port_id ] . parent = None return self . _output_data_ports . pop ( data_port_id ...
Remove an output data port from the state
40,693
def get_io_data_port_id_from_name_and_type ( self , name , data_port_type ) : if data_port_type is InputDataPort : for ip_id , output_port in self . input_data_ports . items ( ) : if output_port . name == name : return ip_id raise AttributeError ( "Name '{0}' is not in input_data_ports" . format ( name ) ) elif data_po...
Returns the data_port_id of a data_port with a certain name and data port type
40,694
def get_path ( self , appendix = None , by_name = False ) : if by_name : state_identifier = self . name else : state_identifier = self . state_id if not self . is_root_state : if appendix is None : return self . parent . get_path ( state_identifier , by_name ) else : return self . parent . get_path ( state_identifier +...
Recursively create the path of the state .
40,695
def get_storage_path ( self , appendix = None ) : state_identifier = storage . get_storage_id_for_state ( self ) if not self . is_root_state : if appendix is None : return self . parent . get_storage_path ( state_identifier ) else : return self . parent . get_storage_path ( state_identifier + PATH_SEPARATOR + appendix ...
Recursively create the storage path of the state .
40,696
def get_state_machine ( self ) : if self . parent : if self . is_root_state : return self . parent else : return self . parent . get_state_machine ( ) return None
Get a reference of the state_machine the state belongs to
40,697
def file_system_path ( self , file_system_path ) : if not isinstance ( file_system_path , string_types ) : raise TypeError ( "file_system_path must be a string" ) self . _file_system_path = file_system_path
Setter for file_system_path attribute of state
40,698
def add_outcome ( self , name , outcome_id = None ) : if outcome_id is None : outcome_id = generate_outcome_id ( list ( self . outcomes . keys ( ) ) ) if name in self . _outcomes : logger . error ( "Two outcomes cannot have the same names" ) return if outcome_id in self . outcomes : logger . error ( "Two outcomes canno...
Add a new outcome to the state
40,699
def remove_outcome ( self , outcome_id , force = False , destroy = True ) : if outcome_id not in self . outcomes : raise AttributeError ( "There is no outcome_id %s" % str ( outcome_id ) ) if not force : if outcome_id == - 1 or outcome_id == - 2 : raise AttributeError ( "You cannot remove the outcomes with id -1 or -2 ...
Remove an outcome from the state