def plot_intercepting_path_delays(ax, shared=False):
    if shared:
        folder = gl_dump_path + '/shared/'
        sched = Schedule(num_slots=gl_num_active_slots, num_off=gl_num_off_slots,
                         num_serial=gl_num_serial_slots, shared=shared)
    else:
        folder = gl_dump_path + '/tdma/'
        sched = Schedule(num_slots=gl_num_active_slots, num_off=gl_num_off_slots, num_serial=gl_num_serial_slots)

    files = [f for f in os.listdir(folder) if isfile(join(folder, f))]
    files = sorted(files)

    df = pd.DataFrame(columns=['set', 'path', 'real_delay', 'min_delay'])

    for idx, filename in enumerate(files):
        if idx == 1:
            # skip the low interference scenario
            continue

        set_id = idx
        if idx > 0:
            set_id -= 1

        pr = AdvDelayProcessor(filename=folder + filename, schedule=sched)

        r, m = pr.plot_path_delay()

        for i, el in enumerate(r):
            df = df.append({'set': set_id, 'path': el[0], 'real_delay': el[1], 'min_delay': m[i][1]}, ignore_index=True)

    data = df.groupby('path').filter(lambda x: len(x) == 3)

    print(data)

    data['min_path_delay'] = data.path.apply(sched.get_min_path_delay)


    int_delay = [[], [], []]
    buf_delay = [[], [], []]

    for iter in data.iterrows():
        index, d = iter
        int_delay[int(d.set)] += list((np.array(d.min_delay) - d.min_path_delay))#/len(d.path))
        buf_delay[int(d.set)] += list((np.array(d.real_delay) - np.array(d.min_delay)))#/len(d.path))

    bp = ax.boxplot(int_delay + buf_delay, showmeans=True, showfliers=False)
    plt.grid(True)
    set_box_plot(bp)
    # plt.show()
    return
Ejemplo n.º 2
0
def plot_all_path_delays(shared=False):
    """
    Plot for interference / buffering delay for all scenarios
    :return:
    """

    # create a schedule
    if shared:
        folder = gl_dump_path + '/shared/'
        sched = Schedule(num_slots=gl_num_active_slots,
                         num_off=gl_num_off_slots,
                         num_serial=gl_num_serial_slots,
                         shared=shared)
    else:
        folder = gl_dump_path + '/tdma/'
        sched = Schedule(num_slots=gl_num_active_slots,
                         num_off=gl_num_off_slots,
                         num_serial=gl_num_serial_slots)

    files = [f for f in os.listdir(folder) if isfile(join(folder, f))]
    files = sorted(files)

    int_delays = []
    buf_delays = []

    for idx, filename in enumerate(files):
        if idx == 1:
            # ignore medium interference case
            continue

        p = AdvDelayProcessor(filename=folder + filename, schedule=sched)

        r0, m0 = p.plot_path_delay()

        i, b = p.print_delay(r0, m0)
        int_delays.append(i)
        buf_delays.append(b)

    # comparison figure for different delays
    plt.figure()
    plt.boxplot(int_delays + buf_delays, showmeans=True, showfliers=False)

    x = range(1, 7)
    plt.xticks(x, ['I (i)', 'III (i)', 'IV (i)', 'I (b)', 'III (b)', 'IV (b)'])
    locs, labels = plt.xticks()
    plt.setp(labels, rotation=0)

    plt.grid(True)
    plt.show()
Ejemplo n.º 3
0
    def load_schedule(self, file):

        # read and parse config
        config = read_config(file)

        active_slots = config["active_slots"]
        numserialrx = config["numserialrx"]
        numslotoff = config["numslotoff"]

        slotframe_length = len(active_slots) + numserialrx + numslotoff

        hopping_sequence = config["hopping_seq"].split(',')

        mote_slot_map = {}
        parsed_active_slots = []
        for idx, slot in enumerate(active_slots):
            parsed_active_slots.append({
                'slot_offset': slot["slotOffset"],
                'channel_offset': slot["channelOffset"],
                'address': slot["address"]
            })
            mote_id = int(slot['address'].split(":")[-1][-2:], 16)
            mote_slot_map.__setitem__(mote_id, idx)

        return Schedule(len(active_slots), numslotoff, numserialrx,
                        parsed_active_slots, hopping_sequence, mote_slot_map)
Ejemplo n.º 4
0
from dataprocessing.basic_processor import set_box_plot
from dataprocessing.log_processor import LogProcessor
from dataprocessing.toolbox import set_figure_parameters, Schedule

set_figure_parameters()
pd.options.mode.chained_assignment = None
gl_num_active_slots = 13
gl_num_off_slots = 2
gl_num_serial_slots = 2
gl_mote_range = range(1, 14)
gl_dump_path = "../../data/raw"
gl_image_path = '../../SGMeasurements/pics/'
gl_save = False

gl_default_schedule = Schedule(num_slots=gl_num_active_slots,
                               num_off=gl_num_off_slots,
                               num_serial=gl_num_serial_slots)


class AdvDelayProcessor(LogProcessor):
    def __init__(self, **kwargs):
        if 'schedule' in kwargs.keys():
            self.schedule = kwargs.pop('schedule')
        else:
            self.schedule = gl_default_schedule
        super().__init__(**kwargs)

    def get_all_paths_w_delay(self):
        '''
        :return: a list of (path, delay) to delay array values
        '''