Esempio n. 1
0
def create_barrier_concurrency_state(number_child_states=10, number_childs_per_child=10):
    barrier_state = BarrierConcurrencyState("barrier_concurrency")

    for i in range(number_child_states):
        hierarchy_state = create_hierarchy_state(number_childs_per_child)
        barrier_state.add_state(hierarchy_state)

    barrier_state.add_transition(barrier_state.states[UNIQUE_DECIDER_STATE_ID].state_id, 0, barrier_state.state_id, 0)
    return barrier_state
Esempio n. 2
0
def create_concurrency_barrier_state():
    state1 = ExecutionState("FirstState",
                            "id_of_state_1",
                            path=testing_utils.TEST_SCRIPT_PATH,
                            filename="concurrency_barrier1.py")
    state1.add_outcome("FirstOutcomeState1", 3)
    state1.add_outcome("SecondOutcomeState1", 4)
    input_state1 = state1.add_input_data_port("input_data_port1", "float")
    output_state1 = state1.add_output_data_port("output_data_port1", "float")

    state2 = ExecutionState("SecondState",
                            "id_of_state_2",
                            path=testing_utils.TEST_SCRIPT_PATH,
                            filename="concurrency_barrier2.py")
    state2.add_outcome("FirstOutcomeState2", 3)
    state2.add_outcome("SecondOutcomeState2", 4)
    input_state2 = state2.add_input_data_port("input_data_port1", "float")
    output_state2 = state2.add_output_data_port("output_data_port1", "float")

    barrier_state = BarrierConcurrencyState("FirstConcurrencyState",
                                            "barrier_state_id")
    barrier_state.add_state(state1)
    barrier_state.add_state(state2)
    input1_state3 = barrier_state.add_input_data_port("input_data_port1",
                                                      "float", 0.1)
    input2_state3 = barrier_state.add_input_data_port("input_data_port2",
                                                      "float", 0.1)
    barrier_state.add_data_flow(barrier_state.state_id, input1_state3,
                                state1.state_id, input_state1)
    barrier_state.add_data_flow(barrier_state.state_id, input2_state3,
                                state2.state_id, input_state2)
    barrier_state.add_output_data_port("output_data_port1", "str",
                                       "default_output_value")
    barrier_state.add_outcome("success_outcome", 3)
    barrier_state.add_outcome("error_outcome", 4)

    barrier_state.states[UNIQUE_DECIDER_STATE_ID].name = "decider_state"
    barrier_state.states[UNIQUE_DECIDER_STATE_ID]._script = Script(
        path=testing_utils.TEST_SCRIPT_PATH,
        filename="decider_state.py",
        check_path=True,
        parent=barrier_state.states[UNIQUE_DECIDER_STATE_ID])
    barrier_state.states[UNIQUE_DECIDER_STATE_ID].add_outcome(
        "FirstOutcomeDecider", 3)
    barrier_state.states[UNIQUE_DECIDER_STATE_ID].add_outcome(
        "SecondOutcomeDecider", 4)

    barrier_state.add_transition(
        barrier_state.states[UNIQUE_DECIDER_STATE_ID].state_id, 3,
        barrier_state.state_id, 3)
    barrier_state.add_transition(
        barrier_state.states[UNIQUE_DECIDER_STATE_ID].state_id, 4,
        barrier_state.state_id, 4)

    return barrier_state