Tuesday, November 29, 2011

Watt Depot Group Project

For the past couple of weeks I've been working on a group project expanding on the WattDepot service that, if you recall from my previous blog posts, collects electricity data from meters and stores it in a database. This allows other tools to retrieve the data for visualization and analysis.

Our group created a command line interface program to help understand various aspects of energy use in the Hale Aloha residence halls at the University of Hawaii at Manoa. The user can call different commands and retrieve energy data with output that is easy to read and nicely formatted.


Furthermore, our program is modular and uses a reflection-based command manager that allows for new commands to be added easily to the system. Because the command manager scans for commands upon execution and does not hold a static list of the commands, no further changes to the code need to be done for new commands other than the command implementation itself.

This was my first experience with issue-based project management and working with a group using tools like subversion and google project hosting. Overall it was a really positive experience, and I know I will use the skills I learned in the future when building software in a group environment. My group members communicated effectively and I believe the quality of our software is pretty good. We implemented all of the required functionality as well as the reflection-based command manager which was not required, but offered for extra credit (Thanks Toy!).

Overall this project was a positive experience and one of the better group projects I've been a part of, simply for the fact that communication was not a problem. I've had my fair share of bad group projects where communication is a problem, and they can be pretty painful experiences. Thankfully were we able to work together effectively and communicated to each other at each step of the way.

Project site: hale-aloha-cli-tnt

You can download a release of the program from our hosting site here.

Tuesday, November 8, 2011

Hawaii's Energy Future

Hawaii is a unique place unlike anywhere else in the world. But the challenges it faces and will continue to face in the near future regarding energy needs are just as unique, and that can be viewed as a blessing as well as a curse. On one hand, there are so many opportunities for people from a wide range of professions to become involved in improving and innovating Hawaii's energy future. Yet, on the other hand, there is a sense of urgency regarding energy in Hawaii because of our dependence on imported oil for our energy needs.

This means that if we fail to develop sustainable energy in a meaningful way, and before it's too late, the consequences for Hawaii will be far more severe than it would be in other places, like the mainland U.S., for example. Hawaii already has some of the highest gas prices in the nation, and we see those costs not only at the pump, but at the grocery store and just about everywhere else as well.

One thing I've been exposed to regarding Hawaii's energy future, and that I think is really exciting, is the fact that Hawaii can potentially develop just about every renewable energy source there is, from solar and wind, to geothermal and more. This means that we can become experts on all of these if we devote the necessary resources and effort they require. Furthermore, we will be able to export that expertise abroad as the need for renewable energy continues to grow elsewhere.

What are some of the problems facing renewable energy in Hawaii? So far it seems there are definitely some environmental and cultural issues surrounding the topic. Some are strongly against building wind turbines on certain islands or in culturally significant locations. Some don't think it's fair for one island to have wind turbines in order to power other islands. I think these sort of issues will begin to take a back seat once that "sense of urgency" thing I previously mentioned begins sinking in (when gas prices hit $10 a gallon, etc.). When that happens, people will check their priorities and begin to see that renewable energy is of paramount importance.

I think it will take a lot of cooperation from everyone if we are to solve the energy problem in Hawaii. Furthermore, I think that educating people about energy, and whether or not we will be able to do that effectively, will prove to be one of most important factors in whether or not we improve Hawaii's energy future. We can all make a difference just by conserving energy ourselves and being more aware.

WattDepot Katas

To begin our exploration of energy-related programming, my fellow ICS classmates and I have been tasked with hacking out 6 programming exercises, or katas, that deal with WattDepot.

What is WattDepot you ask? Well, here is part of the description from the host site:

"WattDepot is an open source, RESTful web service that collects electricity data (such as current power utilization or cumulative power utilization) from meters and stores it in a database. The data can then be retrieved by other tools for visualization and analysis. It is designed to provide infrastructure for experimentation and development of "Smart Grid" applications."

So as you can see, WattDepot is a useful tool for viewing energy consumption data. Here are the 6 katas we were required to do in order to become more familiar with the WattDepot library:

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.

I finished this kata during class. It took me about twenty minutes and was pretty straightforward.

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.

This kata was also straightforward. It took me a half an hour or so.

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.

This was the only kata I didn't complete. I couldn't figure out how to get the subsource data that I needed in order to print the hierarchy the way I wanted.

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.

Katas 4, 5 and 6 together took me about three hours altogether. They were pretty challenging because this was the first time I dealt with timestamps or dates in Java, and I found them to be very non-trivial.

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.

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.

This kata was hard because you had to figure out how to determine the day of the week in order to find the average energy for a Monday--another non-trivial task. This kata took me about an hour.

From these katas I learned that energy data manipulation can be really useful. I think its important that the software analyze the data and create output that is easy to read and understand. That way it can be utilized fully by other professionals and not just other programmers.