Saturday, November 12, 2011

Watts Up? : Working with WattDepot!

In an earlier post, I noted that in order to become an avid programmer practice would surely make perfect. Continuing on with that valuable, but often overlooked piece of information, I have had another chance to practice my skills on a more challenging systems, WattDepot.
For those unfamiliar to WattDepot, simply put, it is a system for acquiring and storing data from electricity meters for smart grid research and experimentation. For the past few days, I have been working with the system by learning the basics. And, I must say working with the system was a unique challenge. Never have I ever spent such a large amount of time coding and testing, coding and testing, and, did I forget to say,testing!? There were so many new things about Java that I had to learn on the fly such as working with XML timestamps and Calendar events(specifically, conversion) that I often ended up confused, but I pushed my way through to a successful completion of all my katas.
By the end of programming my katas (which took hours,as I stated earlier!), I, in addition to feeling stressed out, felt that WattDepot offered a great service especially for Hawai'i. Since Hawai'i has some of the most expensive costs of energy in the nation, the WattDepot can serve as a library of information that can be used to understand what changes need to be made to our current energy habits and how those changes may affect the costs if energy in the years to come. In fact, I was often surprised at about how much energy is consumed at the University (since the data WattDepot collects and maintains is only from the freshman towers at UHM).
For those interested in getting some practice with WattDepot, it is available to download at: http://code.google.com/p/wattdepot/downloads/list and you can take on the same challenge that I had!:
Kata 1: SourceListing

Implement a class called SourceListing, whose main() method accepts one argument (the URL of the WattDepot server) and which writes out the URL argument and a list of all sources defined on that server and their descriptions, sorted in alphabetical order by source name. Use the System.out.format method to provide a nicely formatted list. For example:

Server: http://server.wattdepot.org:8190/wattdepot/

Source Description
Bar Represents the energy consumed by the Bar building.
Baz Represents the energy consumed by the Baz floor of the Bar building.
Foo Energy generated by the Foo power plant.
Qux The energy meter associated with the Qux household.


Kata 2: SourceLatency

Implement a class called SourceLatency, whose main() method accepts one argument (the URL of the WattDepot server) and which writes out the URL argument and a list of all sources defined on that server and the number of seconds since data was received for that source, sorted in ascending order by this latency value. If no data has every been received for that source, indicate that. Use the System.out.format method to provide a nicely formatted list. For example:

Server: http://server.wattdepot.org:8190/wattdepot/

Source Latency (in seconds, as of 12-Oct-2011 14:32:12)
Baz 9
Bar 10
Foo 14
Qux No data received.

Kata 3: SourceHierarchy

Implement a class called SourceHierarchy, whose main() method accepts one argument (the URL of the WattDepot server) and which writes out the URL argument and a hierarchical list of all sources defined on that server. The hierarchy represents the source and subsource relationship between sources. For example:

Server: http://server.wattdepot.org:8190/wattdepot/

Source Hierarchy
Baz
Bar
Zob
Zob-A
Zob-B
Foo
Qux

Thus, the source Baz has two subsources, Bar and Zob. The source Zob has two subsources, Zob-A and Zob-B. Foo and Qux have no subsources. The hierarchy is represented by two space indentation.

Kata 4: EnergyYesterday

Implement a class called EnergyYesterday, whose main() method accepts one argument (the URL of the WattDepot server) and which writes out the URL argument and a list of all sources defined on that server and the amount of energy in watt-hours consumed by that source during the previous day, sorted in ascending order by watt-hours of consumption. If no energy has every been consumed by that source, indicate zero. Use the System.out.format method to provide a nicely formatted list. For example:

Server: http://server.wattdepot.org:8190/wattdepot/

Source Energy consumed in watt-hours (19-Oct-2011)
Baz 932
Bar 1025
Foo 1436
Qux 2357

Kata 5: HighestRecordedPowerYesterday

Implement a class called HighestRecordedPowerYesterday, whose main() method accepts one argument (the URL of the WattDepot server) and which writes out the URL argument and a list of all sources defined on that server and the highest recorded power associated with that source during the previous day, sorted in ascending order by watts. Also indicate the time when that power value was observed. If no power data is associated with that source, indicate that. Use the System.out.format method to provide a nicely formatted list. For example:

Server: http://server.wattdepot.org:8190/wattdepot/

Source Highest recorded power in watts (12-Oct-2011)
Baz 10,034 10:30am
Bar 10,456 2:45pm
Foo 14,876 12:30pm
Qux 23,578 4:15pm

This is a little tricky due to the presence of both virtual and non-virtual sources. For non-virtual sources, you could retrieve all of the sensor data and just iterate through to find the maximum power value. However, virtual sources represent an aggregate of non-virtual sources, so there is no sensor data associated with them directly, and it is unlikely that the sensor data timestamps for its constituent sources will be synchronized exactly.

One reasonable way to deal with this is to request the computed power at (say) 15 minute intervals for the entire day, which provides 96 data points per source whether it is virtual or non-virtual.

Kata 6: MondayAverageEnergy

Implement a class called MondayAverageEnergy, whose main() method accepts one argument (the URL of the WattDepot server) and which writes out the URL argument and a list of all sources defined on that server and the average energy consumed by that source during the previous two Mondays, sorted in ascending order by watt-hours. Use the System.out.format method to provide a nicely formatted list. For example:

Server: http://server.wattdepot.org:8190/wattdepot/

Source Average energy for last two Mondays in watt-hours (24-Oct-2011, 17-Oct-2011)
Baz 10,034
Bar 10,456
Foo 14,876
Qux 23,578

No comments:

Post a Comment