Monday, November 7, 2011

Watt Monitor


            I have been at University of Hawaii at Manoa for five years and I have seen many signs encouraging people to recycle or save gas by riding bikes or TheBus. Due to this project call WattDepot, I get to know that the school is doing much more than just posting signs. WattDepot is an open source web service that will collect energy usage from the places where the meters are installed.

            For this past week I had work on the following six katas:

·         1. List sources and the description
·         2. Latency of the sources
·         3. List sources and subsources in a hierarchy format
·         4. Get energy from the previous day
·         5. Get the highest power of each source
·         6. Get average energy used in the previous two Mondays

The first three katas was pretty straight forward of retrieving the latest data and displaying in nice aligned format. Once I got past the third kata problems started because of having to utilize the methods of WattDepot to get the information specified for the particular kata.

            In kata 3 the requirement was to retrieve energy data from “yesterday”, the initial problem was my understanding of the range of data to retrieve. I misunderstood “yesterday” as retrieving data from one point at the current day to the same point of yesterday. For example, if I were to access data from 11:00 p.m. today then the end point would be 11:00 p.m.  Of course I was incorrect because “yesterday” actually means to retrieve data from the yesterday’s 12 a.m. to 11:59 p.m. To accomplish this I learned how to use Calendar class in Java to set the range of time and perform calculation to get yesterday’s date. This kata allowed me to see how much energy are used in one day at the dorms where the sensors are placed.

            The other kata that I had problem is kata 6. Initially I had the problem of figuring how can I calculate or set the day to the previous two Mondays from the current day. To solve this problem I wrote a separate code to test how Calendar works. Turns out that Calendar.DAY_OF_WEEK will return an integer value indicating the day (e.g. 1 for Sunday, 2 for Monday and so forth). I check the day of the week and return value of how many days to subtract to get the first Monday. Then I double the value to get the second Monday.

            This project gave me an experience that none other projects ever gave me. It allowed me  to have a feeling of how it is to pick up a project and implement code with only some description on the site (WattDepot) of how to write certain code. The rest relies on my Java skills and research of how to use certain built in classes that I sometimes don’t get a chance to use. It also allowed me to see what the school is doing to help people understand the importance of moving away from our reliance on oil to produce electricity.

           

No comments:

Post a Comment