Ejemplo n.º 1
0
        cpuSequence = [0.8, 0.1, 0.30, 0.70, 0.40, 0.10, 0.20, 0.60, 0.20, 0.70]
        #cpuSequence = [0.8, 0.1]
        stepPeriod = 4

        control = ControllerThread(0.1)
        monitor = MonitorThread(0, 0.1)
        actuator = closedLoopActuator(control, monitor, len(cpuSequence) * stepPeriod, 0, 1, dynamics_plot_online)

        monitor.start()
        control.start()
        actuator.run_sequence(cpuSequence)
        
        actuator.close()
        monitor.running = 0
        control.running = 0
        dynamics =  monitor.getDynamics()
       
        monitor.join()
        control.join()
        
        stepPeriod = 4
                
        with open('pid_data', 'w') as outfile:
            json.dump(dynamics, outfile)
    else:
        with open('pid_data', 'r') as outfile:
            dynamics = json.load(outfile)

    plt.figure()
    fig, ax1 = plt.subplots()
    ax1.set_ylabel('CPU Load (%)', color='b')
Ejemplo n.º 2
0
        cpuSequence = [
            0.1, 0.8, 0.30, 0.70, 0.40, 0.10, 0.20, 0.60, 0.20, 0.70
        ]
        #cpuSequence = [ 0.80]
        #sleepTimeSequence = [0.001,  0.02]
        sleepTimeSequence = [cpu_model(x) for x in cpuSequence]
        stepPeriod = 4
        monitor = MonitorThread(0, 0.1)
        actuator = openLoopActuator(monitor,
                                    len(sleepTimeSequence) * stepPeriod, 0,
                                    dynamics_plot_online)
        monitor.start()
        actuator.run_sequence(sleepTimeSequence)

        monitor.running = 0
        dynamics = monitor.getDynamics()
        actuator.close()
        monitor.join()

        with open('feed_forward_data', 'w') as outfile:
            json.dump(dynamics, outfile)
    else:
        with open('feed_forward_data', 'r') as outfile:
            dynamics = json.load(outfile)

    plt.figure()
    fig, ax1 = plt.subplots()
    ax1.set_ylabel('CPU Load (%)', color='b')
    ax1.plot(dynamics['time'], dynamics['cpu'], 'b-')
    ax1.set_xlabel('Time [ms]')
    ax1.grid(True)