Modules‎ > ‎

Introduction to WattDepot

Learning objectives

  • To become familiar with a few simple ways to manipulate energy data.
  • To become familiar with the WattDepot API as a prelude to more complex energy data manipulation.
  • To further improve your skill with Eclipse, Ant, and Java-based development.

Resources

Readings

Screencasts


Slides

Note that these slides do not cover all the material presented in the screencast.

Experiential learning

Assignment A22: WattDepot katas

Task

To help you become proficient with the use of the WattDepot API, please implement the following katas.   Although we encourage you to work with others to improve the efficiency of the learning process, you should type in every character of the solutions yourself.

Implement each of these katas in its own Java class in a package called edu.hawaii.<username>.wattdepot.katas, where <username> is replaced by your UH user name. 

If you find it useful to create a utility class that contains code useful to several of these katas, please feel free to create it.  

These katas must be developed using Eclipse and our class build system.  The most simple way to do this is by the following:
  1. Download the wattdepot-simpleapp distribution, unzip it and invoke ant -f verify.build.xml to ensure that the system runs correctly on your local environment. Keep this around in case you run into problems later.
  2. Unzip the wattdepot-simpleapp distribution into a new directory, and rename this directory wattdepot-katas-<username>, where <username> is your UH account.   This is the directory where you will actually develop your Ant katas.
  3. Edit the .project file in your new directory and replace wattdepot-simpleapp by wattdepot-katas-<username>.
  4. Edit the build.xml file and rename the system name to wattdepot-katas-<username>.
  5. Run ant -f verify.build.xml inside your wattdepot-katas-<username> directory.  Everything should still be fine. 
  6. Import your newly named wattdepot-katas-<username> project into Eclipse.  It should import without problems. 
  7. Write the source code to implement the katas. 
When you are done, you can run ant -f dist.build.xml to create a distribution of your system.  

Note that there are no JUnit tests required for these katas. This is because creating reasonable tests for these katas would require you to set up a test WattDepot server with a known data set.  This creates too much complexity for this assignment.  Instead, you should perform walkthroughs or technical reviews to check the quality of your solutions. 

Record the amount of time required to implement each kata for reference in your blog entry summarizing this experience. 

Test your katas using the WattDepot server running at: http://server.wattdepot.org:8190/wattdepot/.  Note that retrieving this URL in a browser will not succeed as it does not provide an HTTP response to this URL.  This server provides data on energy consumption in the Hale Aloha residence halls at the University of Hawaii.

Your katas must all pass Checkstyle, PMD, and FindBugs. 

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 

Submission instructions

By 8am on the date indicated on the calendar, please use "ant -f dist.build.xml" to produce a distribution of your system and email it to philipmjohnson@gmail.com and to kendyll.doi@gmail.com.   Your system will be graded based upon the degree to which you can follow the instructions, including project and directory naming, automated quality assurance, adherence to coding standards, and completion of the katas. 

Also by 8am on the data indicated on the calendar, create a technical report on your blog recounting your experience writing these katas. What did you learn about WattDepot?  What did you learn about energy data manipulation?  Which of the katas did you complete, which did you not complete, and why?  How much time did each kata take to complete?  Remember, write for the world!

Comments