Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Thermostat Schedule Retrieval Code #38

Merged
merged 26 commits into from
Jan 29, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
f097057
added first version of thermostat schedule retrieval code
john-b-yang Jan 10, 2019
8b64617
added working draft of schedule retrieval code. Added rrule conversio…
john-b-yang Jan 11, 2019
e595d59
cleaned up JSON struct field and type naming
john-b-yang Jan 11, 2019
f925fc5
debugging unknown variable issue
john-b-yang Jan 11, 2019
05d009b
created polling parameters, code for retrieving thermostat schedule i…
john-b-yang Jan 11, 2019
bd32c96
cleaned up method, struct, and variable naming. Replace id with noden…
john-b-yang Jan 11, 2019
79e33ee
edited thermostat scheduler code by recommendations
john-b-yang Jan 13, 2019
a46e042
removed unnecessary conditional case
john-b-yang Jan 14, 2019
fa4c6df
replaced structs for retrieving thermostat IDs with free form interfa…
john-b-yang Jan 14, 2019
a7ff14d
removed all decoding structs, reimplemented JSON parsing with free fo…
john-b-yang Jan 14, 2019
1e9aebd
reverted free form interface JSON decoding to struct based approach. …
john-b-yang Jan 15, 2019
92149c3
added small modification to interface name
john-b-yang Jan 16, 2019
420aed1
added msgpack aliases to return JSONs
john-b-yang Jan 16, 2019
ec0a841
added descriptions to the thermostat schedule result structs
john-b-yang Jan 16, 2019
7c6e4cc
some refs failed to push, repushing
john-b-yang Jan 16, 2019
686d8e0
adding markdown description of schedule interface, file is interface.md
john-b-yang Jan 18, 2019
91504f9
added more in depth explanations regarding schedule struct in interfa…
john-b-yang Jan 19, 2019
2ae10cd
corrected struct definition errors, added explanation regarding how R…
john-b-yang Jan 21, 2019
7739169
added examples regarding what time conversion might look like
john-b-yang Jan 22, 2019
a242229
corrected grammatical + syntax errors in interface doc
john-b-yang Jan 23, 2019
3d9501a
small grammatical correction
john-b-yang Jan 23, 2019
e93ed19
cut out intermediate day schedule struct and made time parsing more c…
john-b-yang Jan 24, 2019
1643010
added new schedule go request field to Pelican, corrected occupancy s…
john-b-yang Jan 24, 2019
e20fda0
created 3 new fields for Pelican struct (id, cookie, sitename). Recon…
john-b-yang Jan 26, 2019
266e819
added 2 clarifying comments regarding setCookieAndID method
john-b-yang Jan 26, 2019
aad2654
cleaned up syntax + conditional cases. Added new cookie expiration fi…
john-b-yang Jan 28, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions driver/pelican/interface.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,19 @@ type ThermostatSchedule struct {

// Struct containing a series of blocks that describes a one day schedule
john-b-yang marked this conversation as resolved.
Show resolved Hide resolved
type ThermostatDaySchedule struct {
Blocks []ThermostatBlockSchedule `msgpack:blocks`
Blocks []ThermostatBlockSchedule `msgpack:"blocks"`
}

// Struct containing data defining the settings of each schedule block
type ThermostatBlockSchedule struct {
CoolSetting float64 `msgpack:"cool_setting"` // Cooling turns on when room temperature exceeds cool setting temp.
HeatSetting float64 `msgpack:"heat_setting"` // Heating turns on when room temperature drops below heat setting temp.
System string `msgpack:"system"` // Indicates if system is heating, cooling, off, or set to auto
Time string `msgpack:"time"` // Indicates the time of day which the above settings are enacted.
// Cooling turns on when room temperature exceeds cool setting temp.
CoolSetting float64 `msgpack:"cool_setting"`
// Heating turns on when room temperature drops below heat setting temp.
HeatSetting float64 `msgpack:"heat_setting"`
// Indicates if system is heating, cooling, off, or set to auto
System string `msgpack:"system"`
// Indicates the time of day which the above settings are enacted.
Time string `msgpack:"time"`
}
```

Expand Down Expand Up @@ -61,6 +65,14 @@ Three fields are configured.
- Wkst tells us which day of the week (Sunday - Saturday) this event occurs.
- Dtstart is a required field that indicates the "start date" of the particular event. In Go, the Dtstart field is a time.Date object, which is initialized with the following parameters: year, month, day, hour minute, second, millisecond, timezone. For our purposes, there is no real concept of a "start date", just the time, so the year, month, and day parameters are filled with dummy values of 0. Only hour, minute, and timezone (which can be determined from the Pelican settings + schedule) are filled in. As long as an individual knows the time is in RRule format, he or she will be able to determine each field.

The translation from the above RRule format to a string is performed using the RRule-go module, specifically this function linked here:
https://github.com/teambition/rrule-go/blob/master/str.go#L123

Within the thermSchedule.go code, the last line of the convertTimeToRRule function calls the ".string()" function of the RRule object. The implementation of this function is fairly straightforward. In a nutshell, the conversion function scans through each of the RRule object's fields. The "key-value" pair of each field is appended to a string object, which is ultimately returned. Some helper functions are used primarily for casting a variety of types into a string, such as appendIntsOption, timeToStr (for Dtstart), and append. In a general sense, the conversion function is meant to achieve two things:

1. Be as human readable as possible. If one reads the resulting string output, he or she should easily be able to identify the interval, frequency, count, and start/end dates of the respective event.
2. Can be converted back into RRule format. The RRule-go module has a complementary ".StrToRRule(rfcString string)" function that converts from string back to an RRule object.

gtfierro marked this conversation as resolved.
Show resolved Hide resolved
##### XBOS Interface Configuration

The current version of XBOS uses YAML files to define the expectations for the output of different functionalities of the driver code from the bw2-contrib repository. There are a couple limitations regarding what the YAML files are able to represent. The incumbent version of XBOS features protobuf definitions for messages. When the next release of XBOS comes, both new and existing YAML files will be created and modified to reflect the outputs' types more accurately.
2 changes: 1 addition & 1 deletion driver/pelican/types/thermSchedule.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ type ThermostatSchedule struct {

// Struct containing a series of blocks that describes a one day schedule
type ThermostatDaySchedule struct {
Blocks []ThermostatBlockSchedule `msgpack:blocks`
Blocks []ThermostatBlockSchedule `msgpack:"blocks"`
}

// Struct containing data defining the settings of each schedule block
Expand Down