XBOS Docs
Search…
Demand Response Event
Interface: i.xbos.demand_response
Description: Standard XBOS demand response event interface
PONUM: 2.1.1.9

Properties

Name
Type
Description
Units
Required
dr_status
integer
The local site's status regarding the DR event
dr_status
true
event_end
integer
DR event end time, expressed as nanoseconds since the Unix epoch
ns
true
event_start
integer
DR event start time, expressed as nanoseconds since the Unix epoch
ns
true
event_type
integer
The type (severity) of the DR event
event_type
true
time
integer
nanoseconds since the Unix epoch
ns
false

Signals

    info:
      event_start
      event_end
      event_type
      dr_status
      time

Slots

Interfacing in Go

1
package main
2
3
import (
4
"fmt"
5
bw2 "gopkg.in/immesys/bw2bind.v5"
6
)
7
8
func main() {
9
client := bw2.ConnectOrExit("")
10
client.OverrideAutoChainTo(true)
11
client.SetEntityFromEnvironOrExit()
12
13
base_uri := "Demand Response uri goes here ending in i.xbos.demand_response"
14
15
// subscribe
16
type signal struct {
17
Event_start int64 `msgpack:"event_start"`
18
Event_end int64 `msgpack:"event_end"`
19
Event_type int64 `msgpack:"event_type"`
20
Dr_status int64 `msgpack:"dr_status"`
21
Time int64 `msgpack:"time"`
22
}
23
c, err := client.Subscribe(&bw2.SubscribeParams{
24
URI: base_uri + "/signal/info",
25
})
26
if err != nil {
27
panic(err)
28
}
29
30
for msg := range c {
31
var current_state signal
32
po := msg.GetOnePODF("2.1.1.9/32")
33
err := po.(bw2.MsgPackPayloadObject).ValueInto(&current_state)
34
if err != nil {
35
fmt.Println(err)
36
} else {
37
fmt.Println(current_state)
38
}
39
}
40
}
Copied!

Interfacing in Python

1
import time
2
import msgpack
3
4
from bw2python.bwtypes import PayloadObject
5
from bw2python.client import Client
6
7
bw_client = Client()
8
bw_client.setEntityFromEnviron()
9
bw_client.overrideAutoChainTo(True)
10
11
def onMessage(bw_message):
12
for po in bw_message.payload_objects:
13
if po.type_dotted == (2,1,1,9):
14
print msgpack.unpackb(po.content)
15
16
bw_client.subscribe("Demand Response uri ending in i.xbos.demand_response/signal/info", onMessage)
17
18
print "Subscribing. Ctrl-C to quit."
19
while True:
20
time.sleep(10000)
Copied!
Last modified 1yr ago