Ejemplo n.º 1
0
controller_obj = ramp_controller_object(controllerDict)

time_granted = 0  # time variable for checking the retuned time from FNCS
timeSim = 0

# Start simulation for each time step:
while (time_granted < tf * 3600):
    # =================Simulation for each time step ============================================
    # Initialization when time = 0
    if time_granted == 0:
        controller_obj.initController()

    # Subscrib values from FNCS broker (or csv file here)
    if time_granted != 0:
        fncs_sub_value_String = ''
        fncs_sub_value_unicode = (fncs.agentGetEvents()).decode()
        if fncs_sub_value_unicode != '':
            fncs_sub_value_String = json.loads(fncs_sub_value_unicode)
            controller_obj.subscribeVal(fncs_sub_value_String, time_granted)

    # Process presync, sync and postsync part for each time step:

    # Presync process
    presyncReturn = controller_obj.presync()

    # Sync process
    syncReturn = controller_obj.sync(time_granted)

    # Postsync process
    postsyncReturn = controller_obj.postsync()
Ejemplo n.º 2
0
time_granted = 0  # time variable for checking the retuned time from FNCS
timeSim = 0

# Start simulation for each time step:
# for timeSim in np.arange(0, tf*3600, deltaT):
while (time_granted < tf * 3600):
    # =================Simulation for each time step ============================================
    # Initialization when time = 0
    if time_granted == 0:
        controller_obj.initController()
    print("Initialization", flush=True)
    # Subscrib values from FNCS broker (or csv file here)
    if time_granted != 0:
        fncs_sub_value_String = ''
        fncs_sub_value_unicode = (fncs.agentGetEvents()).decode()
        print('printing all agent events', fncs.agentGetEvents())
        if fncs_sub_value_unicode != '':
            fncs_sub_value_String = json.loads(fncs_sub_value_unicode)
            controller_obj.subscribeVal(fncs_sub_value_String)
    if time_granted != 0:
        events = fncs.get_events()
        print('printing all events', events, flush=True)
        for key in events:
            title = key.decode()
            value = fncs.get_value(key).decode()
            controller_obj.subscribeGLD(title, value)

    # Process presync, sync and postsync part for each time step:

    # Presync process