GitHub - terion-io/BOPTestAPI.jl: Julia functions for calling the BOPTEST REST API. (original) (raw)

BOPTestAPI

Build Status

Some convenience functions for developing building controllers against the BOPTEST framework in Julia.

Info

This package can be used to develop building controllers against the BOPTEST REST API.

BOPTEST itself comes in two flavours, the "single-plant" BOPTEST and the larger scale BOPTEST-Service, which allows running many plants in parallel.

Usage

The general idea is that the BOPTEST services are abstracted away as a BOPTestPlant, which only stores metadata about the plant such as the endpoints to use.

The package then defines common functions to operate on the plant, which are translated to REST API calls and the required data formattings.

Initialization

There are two types of plants:

The types are parametrized, depending on whether they run in BOPTEST or BOPTEST-Service:

Important

BOPTEST from version v0.7.0 uses the BOPTEST-service API even on local deployment. Thus, since BOPTestAPI v0.3, the BOPTestPlant constructor is overloaded and can be used directly.

Tip

For a plant instance, plant.api_endpoint(service) is callable and returns the endpoint of a specific service as String, this can be useful for defining additional functions. E.g. plant.api_endpoint("advance") for a plant on localhost with internal testid "a-b-c-d" returns "http://localhost/advance/a-b-c-d".

testcase = "bestest_hydronic"

NREL hosts the BOPTEST API "http://api.boptest.net"

remote_plant = BOPTestPlant("http://api.boptest.net", testcase)

local_plant = BOPTestPlant("http://localhost", testcase)

!! Note: For BOPTEST < v0.7 use this for local deployed test cases

The test case is then set when starting up BOPTEST

local_plant = initboptest!("http://127.0.0.1:5000")

The initialization functions also query and store the available signals (as DataFrame), since they are constant for a testcase. The signals are available as

Interaction with the plant

The package then defines common functions to operate on the plant, namely

Querying data

The time series functions return a DataFrame with the time series. By default, a conversion to Float64 is attempted (else the datatypes would be Any). You can use the keyword argument convert_f64=false to disable conversion.

Query forecast data for 24 hours, with 1/dt sampling frequency

dt = 900.0 fc = getforecasts(plant, 24*3600, dt)

Advancing

The advance! function requires the control inputs u as a Dict.

This will by default overwrite all baseline values with the lowest allowed value

u = controlinputs(plant)

Simulate 100 steps open-loop

res_ol = [advance!(plant, u) for _ = 1:100] df_ol = DataFrame(res_ol)

KPI

kpi = getkpi(plant)

Stop

Stop a test case when no longer needed: