def buttazzo_experiments_preemptions_no_repetition ():

    utilization = 0.9
    create_file("../taskset-generated/buttazzo_preemptions_no_repetition.csv", "utilization;EDF_busy_period;FPS_busy_period;EDF_first_DM_miss;EDF_schedulable;FPS_schedulable;hyperperiod;Priority_i,Deadline_i,Period_i,ID_i,WCET_i,EDF_response_time_i,FPS_response_time_i,FPS_deadline_miss_task_i,utilization_context_switch_i,utilization_clock, utilization_support_function_i")
    # Buttazzo method 1 no periods repetition
    for i in range (2,11):
        for j in range(500):
            print(j)
            taskset, utilization_context_switch, utilization_clock, utilization_support_function = \
                create_random_taskset_between_two_periods_no_repetition (i*2, 10, 100, utilization)
            EDF_busy_period, EDF_first_DM_miss, EDF_schedulable, EDF_response_time = MAST_EDF_Analysis(taskset)
            FPS_busy_period, FPS_schedulable, FPS_response_time, FPS_deadline_miss_task = MAST_FPS_Analysis(taskset)
            register_to_file(taskset, utilization, EDF_busy_period, FPS_busy_period, EDF_first_DM_miss,
                             EDF_schedulable, FPS_schedulable, EDF_response_time, FPS_response_time,
                             FPS_deadline_miss_task, utilization_context_switch, utilization_clock,
                             utilization_support_function, 1000000,
                             "../taskset-generated/buttazzo_preemptions_no_repetition.csv")
    # Buttazzo method 2 no periods repetition
    for i in range (10):
        utilization = 0.5 + i*0.05
        for j in range(500):
            print(j)
            taskset, utilization_context_switch, utilization_clock, utilization_support_function = \
                create_random_taskset_between_two_periods_no_repetition (10, 10, 100, utilization)
            EDF_busy_period, EDF_first_DM_miss, EDF_schedulable, EDF_response_time = MAST_EDF_Analysis(taskset)
            FPS_busy_period, FPS_schedulable, FPS_response_time, FPS_deadline_miss_task = MAST_FPS_Analysis(taskset)
            register_to_file(taskset, utilization, EDF_busy_period, FPS_busy_period, EDF_first_DM_miss,
                             EDF_schedulable, FPS_schedulable, EDF_response_time, FPS_response_time,
                             FPS_deadline_miss_task, utilization_context_switch, utilization_clock,
                             utilization_support_function, 1000000,
                             "../taskset-generated/buttazzo_preemptions_no_repetition.csv")
def hyper_113400000_x_x_armonic_10_100():

    utilization = 0.9
    for l in range(3):
        min_armonicity_grade = 0
        max_armonicity_grade = 0
        if (l == 0):
            min_armonicity_grade = 0
            max_armonicity_grade = 2
        if (l == 1):
            min_armonicity_grade = 3
            max_armonicity_grade = 6
        if (l == 2):
            min_armonicity_grade = 7
            max_armonicity_grade = 20
        create_file(("../taskset-generated/hyper_113400000_" + str(min_armonicity_grade) + "_" +str(max_armonicity_grade) +"_armonic_10_100.csv"),
                "utilization;EDF_busy_period;FPS_busy_period;EDF_first_DM_miss;EDF_schedulable;FPS_schedulable;hyperperiod;Priority_i,Deadline_i,Period_i,ID_i,WCET_i,EDF_response_time_i,FPS_response_time_i,FPS_deadline_miss_task_i,utilization_context_switch_i,utilization_clock, utilization_support_function_i")
        for j in range(500):
            taskset, utilization_context_switch, utilization_clock, utilization_support_function = \
                create_taskset_hyper_113400000_10_100(20, utilization, min_armonicity_grade, max_armonicity_grade)
            hyperperiod = calculate_hyperperiod(taskset)
            EDF_busy_period, EDF_first_DM_miss, EDF_schedulable, EDF_response_time = MAST_EDF_Analysis(taskset)
            FPS_busy_period, FPS_schedulable, FPS_response_time, FPS_deadline_miss_task = MAST_FPS_Analysis(taskset)
            register_to_file(taskset, utilization, EDF_busy_period, FPS_busy_period, EDF_first_DM_miss, EDF_schedulable,
                             FPS_schedulable, EDF_response_time, FPS_response_time, FPS_deadline_miss_task,
                             utilization_context_switch, utilization_clock, utilization_support_function, hyperperiod,
                             "../taskset-generated/hyper_113400000_" + str(min_armonicity_grade) + "_" +
                             str(max_armonicity_grade) +"armonic_10_100.csv")
def receiving_handler(live_connection):
    """
    Use: receiving new file and open it on the computer
    Input: live_connection(socket Object)
    Output: None
    """
    file_name = receiving(live_connection)
    file_data = receiving(live_connection)
    # create a text file on desktop with file data
    file_management.create_file(file_data, file_name)

    live_connection.close()
#------------------------------------------------------------------------------
def U_90_log_uniform():

    create_file("../taskset-generated/U_90_log_uniform.csv",
                "utilization;EDF_busy_period;FPS_busy_period;EDF_first_DM_miss;EDF_schedulable;FPS_schedulable;hyperperiod;Priority_i,Deadline_i,Period_i,ID_i,WCET_i,EDF_response_time_i,FPS_response_time_i,FPS_deadline_miss_task_i,utilization_context_switch_i,utilization_clock, utilization_support_function_i")
    utilization = 0.9
    for j in range(1000):
        print(j)
        taskset, utilization_context_switch, utilization_clock, utilization_support_function = \
            create_taskset_log_uniform(10, 100, 20, utilization)
        hyperperiod = 1000000
        EDF_busy_period, EDF_first_DM_miss, EDF_schedulable, EDF_response_time = MAST_EDF_Analysis(taskset)
        FPS_busy_period, FPS_schedulable, FPS_response_time, FPS_deadline_miss_task = MAST_FPS_Analysis(taskset)
        register_to_file(taskset, utilization, EDF_busy_period, FPS_busy_period, EDF_first_DM_miss, EDF_schedulable,
                         FPS_schedulable, EDF_response_time, FPS_response_time, FPS_deadline_miss_task,
                         utilization_context_switch, utilization_clock, utilization_support_function, hyperperiod,
                         "../taskset-generated/U_90_log_uniform.csv")
def hyper_113400000_10_200_with_some_long_U_60_70_80_90():

    create_file("../taskset-generated/hyper_113400000_10_200_with_some_long_U_60_70_80_90.csv",
                "utilization;EDF_busy_period;FPS_busy_period;EDF_first_DM_miss;EDF_schedulable;FPS_schedulable;hyperperiod;Priority_i,Deadline_i,Period_i,ID_i,WCET_i,EDF_response_time_i,FPS_response_time_i,FPS_deadline_miss_task_i,utilization_context_switch_i,utilization_clock, utilization_support_function_i")
    for i in range(4):
        utilization = 0.6 + (0.1 * i)
        for j in range(500):
            taskset, utilization_context_switch, utilization_clock, utilization_support_function = \
                create_taskset_hyper_113400000_10_200_with_some_long (20, utilization, 0, 20)
            hyperperiod = calculate_hyperperiod(taskset)
            EDF_busy_period, EDF_first_DM_miss, EDF_schedulable, EDF_response_time = MAST_EDF_Analysis(taskset)
            FPS_busy_period, FPS_schedulable, FPS_response_time, FPS_deadline_miss_task = MAST_FPS_Analysis(taskset)
            register_to_file(taskset, utilization, EDF_busy_period, FPS_busy_period, EDF_first_DM_miss, EDF_schedulable,
                             FPS_schedulable, EDF_response_time, FPS_response_time, FPS_deadline_miss_task,
                             utilization_context_switch, utilization_clock, utilization_support_function, hyperperiod,
                             "../taskset-generated/hyper_113400000_10_200_with_some_long_U_60_70_80_90.csv")
def U_100_hyper_113400000_10_100():

    utilization = 1.00
    create_file("../taskset-generated/U_100_hyper_113400000_10_100.csv",
                "utilization;EDF_busy_period;FPS_busy_period;EDF_first_DM_miss;EDF_schedulable;FPS_schedulable;hyperperiod;Priority_i,Deadline_i,Period_i,ID_i,WCET_i,EDF_response_time_i,FPS_response_time_i,FPS_deadline_miss_task_i,utilization_context_switch_i,utilization_clock, utilization_support_function_i")

    for j in range(500):
        print(j)
        taskset, utilization_context_switch, utilization_clock, utilization_support_function = \
            create_taskset_hyper_113400000_10_100(20, utilization, 0, 20)
        hyperperiod = calculate_hyperperiod(taskset)
        EDF_busy_period, EDF_first_DM_miss, EDF_schedulable, EDF_response_time = MAST_EDF_Analysis(taskset)
        FPS_busy_period, FPS_schedulable, FPS_response_time, FPS_deadline_miss_task = MAST_FPS_Analysis(taskset)
        register_to_file(taskset, utilization, EDF_busy_period, FPS_busy_period, EDF_first_DM_miss, EDF_schedulable,
                         FPS_schedulable, EDF_response_time, FPS_response_time, FPS_deadline_miss_task,
                         utilization_context_switch, utilization_clock, utilization_support_function, hyperperiod,
                         "../taskset-generated/U_100_hyper_113400000_10_100.csv")
def semi_harmonic():

    create_file("../taskset-generated/semi_harmonic.csv",
                "utilization;EDF_busy_period;FPS_busy_period;EDF_first_DM_miss;EDF_schedulable;FPS_schedulable;hyperperiod;Priority_i,Deadline_i,Period_i,ID_i,WCET_i,EDF_response_time_i,FPS_response_time_i,FPS_deadline_miss_task_i,utilization_context_switch_i,utilization_clock, utilization_support_function_i")
    utilization = 0.9
    periods = semi_harmonic_periods_generator()
    for i in range(1000):
        print(i)
        taskset, utilization_context_switch, utilization_clock, utilization_support_function = \
            create_taskset_semi_harmonic(utilization, periods, i)
        hyperperiod = calculate_hyperperiod(taskset)
        EDF_busy_period, EDF_first_DM_miss, EDF_schedulable, EDF_response_time = MAST_EDF_Analysis(taskset)
        FPS_busy_period, FPS_schedulable, FPS_response_time, FPS_deadline_miss_task = MAST_FPS_Analysis(taskset)
        register_to_file(taskset, utilization, EDF_busy_period, FPS_busy_period, EDF_first_DM_miss, EDF_schedulable,
                         FPS_schedulable, EDF_response_time, FPS_response_time, FPS_deadline_miss_task,
                         utilization_context_switch, utilization_clock, utilization_support_function, hyperperiod,
                         "../taskset-generated/semi_harmonic.csv")