My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
DeveloperGuide  
How to install and build this system.
Featured
Updated Apr 13, 2010 by philipmj...@gmail.com

Table of Contents

Installation

Installation requires Java, Ant, and the WattDepot simulation package itself.

Install Java

To build the WattDepot simulations project, you must first download and install Java, Version 1.5 or above. You should download and install the JDK, not the JRE.

When finished, you should be able to invoke Java from the command line as follows:

C:\wattdepot\wattdepot-simulation>java -version
java version "1.6.0_10"
Java(TM) SE Runtime Environment (build 1.6.0_10-b33)
Java HotSpot(TM) Client VM (build 11.0-b15, mixed mode, sharing)

Install Ant

Next, install Apache Ant, Version 1.7.1 or above.

When finished, you should be able to invoke Ant from the command line as follows:

C:\wattdepot\wattdepot-simulation>ant -version
Apache Ant version 1.7.1 compiled on June 27 2008

Checkout the source code

Finally, checkout the WattDepot Simulation source code from the Google Project Hosting subversion repository. Instructions are available here. Checkout the trunk/ directory to get the latest development version of the system.

When you are finished, assuming you checked out the trunk into a folder called wattdepot-simulation, you should have a directory structure similar to the following:

wattdepot-simulation/
  .classpath
  .project
  build.xml
  (various *.build.xml files)
  src/
      org/wattdepot/simulation/oahugrid/
                                       demandcurve
                                       main
                                       powerplant
                                       strategy
                             /uhcampus/
                                      building
                                      main
                            /util/
  xml/

As you can see, the system consists of a variety of Ant files (*.build.xml) at the top-level, plus an xml/ directory, plus a src/ directory containing the actual Java implementation.

The sources are split into two primary packages, org.wattdepot.simulation.oahugrid and org.wattdepot.simulation.uhcampus, which correspond to the two simulations supported by this package. The org.wattdepot.simulation.util package provides a small class providing code common to both simulations.

Building

To build the system for the first time, bring up a command shell, change directories to the top-level of the system, and type 'ant'. The system will download Apache Ivy if necessary, then utilize Ivy to download additional libraries required by WattDepot Simulation.

A sample invocation of Ant might look like this:

C:\wattdepot\wattdepot-simulation>ant
Buildfile: build.xml
    [mkdir] Created dir: C:\wattdepot\wattdepot-simulation\lib\configfiles

download-ivy-if-necessary:

install-ivy:

install-libraries:
No ivy:settings found for the default reference 'ivy.instance'.  A default instance will be used
[ivy:retrieve] :: Ivy 2.1.0-rc1 - 20090319213629 :: http://ant.apache.org/ivy/ ::
:: loading settings :: file = C:\wattdepot\wattdepot-simulation\ivysettings.xml

compile:
    [mkdir] Created dir: C:\wattdepot\wattdepot-simulation\build\classes
    [javac] Compiling 13 source files to C:\wattdepot\wattdepot-simulation\build\classes

BUILD SUCCESSFUL
Total time: 7 seconds
C:\wattdepot\wattdepot-simulation>

Your output may be considerably longer than this if the build process requires downloading of additional libraries.

As part of the build process, a new directory called lib/ will be created. This directory will have the following initial contents:

lib/
   configfiles/
   cron4j/
   junit/
   wattdepot/

The lib/ directory contains various libraries required by the simulation package. The package requires three additional libraries to compile: cron4j, junit, and wattdepot.

Testing

Once you can build the system successfully, you can test the system using the various quality assurance tools. To download, install, and invoke all of them on the WattDepot simulation system, invoke 'ant -f verify.build.xml':

C:\wattdepot\wattdepot-simulation>ant -f verify.build.xml
Buildfile: verify.build.xml
    [mkdir] Created dir: C:\wattdepot\wattdepot-simulation\lib\configfiles

download-ivy-if-necessary:

install-ivy:

install-libraries:
No ivy:settings found for the default reference 'ivy.instance'.  A default instance will be used
[ivy:retrieve] :: Ivy 2.1.0-rc1 - 20090319213629 :: http://ant.apache.org/ivy/ ::
:: loading settings :: file = C:\wattdepot\wattdepot-simulation\ivysettings.xml

compile:

junit.tool:
    [junit] Running org.wattdepot.simulation.oahugrid.main.batch.TestBatchSimulation
    [junit] Tests run: 2, Failures: 0, Errors: 0, Time elapsed: 3.203 sec

install-checkstyle:

checkstyle.install.config.file:
      [get] Getting: http://hackystat.googlecode.com/svn/trunk/configfiles//hackystat.checkstyle.xml
      [get] To: C:\wattdepot\wattdepot-simulation\lib\configfiles\hackystat.checkstyle.xml

checkstyle.tool:
[checkstyle] Running Checkstyle 5.0 on 13 files

install-pmd:

pmd.install.rulesets.file:
      [get] Getting: http://hackystat.googlecode.com/svn/trunk/configfiles//hackystat.pmd.xml
      [get] To: C:\wattdepot\wattdepot-simulation\lib\configfiles\hackystat.pmd.xml

pmd.tool:
     [echo] PMD found 0 problem(s).

install-findbugs:

findbugs.install.filter.file:
      [get] Getting: http://hackystat.googlecode.com/svn/trunk/configfiles//hackystat.findbugs.exclude.xml
      [get] To: C:\wattdepot\wattdepot-simulation\lib\configfiles\hackystat.findbugs.exclude.xml

findbugs.tool:
 [findbugs] Executing findbugs from ant task
 [findbugs] Running FindBugs...
 [findbugs] Calculating exit code...
 [findbugs] Exit code set to: 0
 [findbugs] Output saved to C:\wattdepot\wattdepot-simulation\build\findbugs/findbugs.xml

verify:

BUILD SUCCESSFUL
Total time: 28 seconds
C:\wattdepot\wattdepot-simulation>

As you can see, the verify.build.xml Ant file invokes JUnit, Checkstyle, PMD, and FindBugs on the source code. The system will use Ivy to automatically download these systems into the lib/ directory before running them.

You can invoke them individually using:

  • ant -f junit.build.xml
  • ant -f checkstyle.build.xml
  • ant -f pmd.build.xml
  • ant -f findbugs.build.xml

Running

The build.xml file contains targets to compile and run the various simulations. For example:

C:\wattdepot\wattdepot-simulation>ant run
Buildfile: build.xml

download-ivy-if-necessary:

install-ivy:

install-libraries:
No ivy:settings found for the default reference 'ivy.instance'.  A default instance will be used
[ivy:retrieve] :: Ivy 2.1.0-rc1 - 20090319213629 :: http://ant.apache.org/ivy/ ::
:: loading settings :: file = C:\wattdepot\wattdepot-simulation\ivysettings.xml

compile:

run:
     [java] Authenticating WattDepot server... done.
     [java] Validating PowerPlant sources and getting EnergyGeneratedToDate (MWH).
     [java]      SIM_KAHE_1 energy generated to date:  124 MWH
     [java]      SIM_KAHE_2 energy generated to date:  434 MWH
     [java]      SIM_KAHE_3 energy generated to date:  550 MWH
     [java]      SIM_KAHE_4 energy generated to date:  550 MWH
     [java]      SIM_KAHE_5 energy generated to date:  550 MWH
     [java]      SIM_KAHE_6 energy generated to date:  844 MWH
     [java]      SIM_KAHE_7 energy generated to date:    0 MWH
     [java]     SIM_WAIAU_7 energy generated to date: 1276 MWH
     [java]     SIM_WAIAU_8 energy generated to date:  548 MWH
     [java]      SIM_HPOWER energy generated to date:  288 MWH
     [java]         SIM_AES energy generated to date: 2610 MWH
     [java]    SIM_KALAELOA energy generated to date: 2973 MWH
     [java]     SIM_WAIAU_5 energy generated to date:  338 MWH
     [java]     SIM_WAIAU_6 energy generated to date:  206 MWH
     [java]  SIM_HONOLULU_8 energy generated to date:  609 MWH
     [java]  SIM_HONOLULU_9 energy generated to date:  398 MWH
     [java]     SIM_WAIAU_9 energy generated to date:  160 MWH
     [java]    SIM_WAIAU_10 energy generated to date:  136 MWH
     [java] Oahu grid simulation is now running. Press return to stop server.

     [java] Stopping simulation.

BUILD SUCCESSFUL
Total time: 7 seconds
C:\wattdepot\wattdepot-simulation>

This is easier than building the jar file and invoking it from the command line.

Note that the simulation invoked by 'ant run' may change over time. Consult the build.xml file to determine the target name for the simulation of interest.

Packaging

Creating the jar files

To create jar files for the various simulations, invoke 'ant -f jar.build.xml':

C:\wattdepot\wattdepot-simulation>ant -f jar.build.xml
Buildfile: jar.build.xml

download-ivy-if-necessary:

install-ivy:

install-libraries:
No ivy:settings found for the default reference 'ivy.instance'.  A default instance will be used
[ivy:retrieve] :: Ivy 2.1.0-rc1 - 20090319213629 :: http://ant.apache.org/ivy/ ::
:: loading settings :: file = C:\wattdepot\wattdepot-simulation\ivysettings.xml

compile:

jar:
    [mkdir] Created dir: C:\wattdepot\wattdepot-simulation\tmp
    [mkdir] Created dir: C:\wattdepot\wattdepot-simulation\build\jar
     [copy] Copying 15 files to C:\wattdepot\wattdepot-simulation\tmp
    [unjar] Expanding: C:\wattdepot\wattdepot-simulation\lib\cron4j\cron4j.jar into C:\wattdepot\wattdepot-simulation\tmp
    [unjar] Expanding: C:\wattdepot\wattdepot-simulation\lib\wattdepot\wattdepot-lib-client.jar into C:\wattdepot\wattdepot-simulation\tmp
      [jar] Building jar: C:\wattdepot\wattdepot-simulation\build\jar\simulation-oahugrid.jar
   [delete] Deleting directory C:\wattdepot\wattdepot-simulation\tmp

BUILD SUCCESSFUL
Total time: 9 seconds
C:\wattdepot\wattdepot-simulation>

The jar files are created in the build/jar directory.

Creating a distribution

To create a zip file distribution of the system, including jar files and sources, invoke 'ant -f dist.build.xml':

C:\wattdepot\wattdepot-simulation>ant -f dist.build.xml
Buildfile: dist.build.xml
   [delete] Deleting directory C:\wattdepot\wattdepot-simulation\build\jar

clean:
   [delete] Deleting directory C:\wattdepot\wattdepot-simulation\build

download-ivy-if-necessary:

install-ivy:

install-libraries:
No ivy:settings found for the default reference 'ivy.instance'.  A default instance will be used
[ivy:retrieve] :: Ivy 2.1.0-rc1 - 20090319213629 :: http://ant.apache.org/ivy/ ::
:: loading settings :: file = C:\wattdepot\wattdepot-simulation\ivysettings.xml

compile:
    [mkdir] Created dir: C:\wattdepot\wattdepot-simulation\build\classes
    [javac] Compiling 13 source files to C:\wattdepot\wattdepot-simulation\build\classes

jar:
    [mkdir] Created dir: C:\wattdepot\wattdepot-simulation\tmp
    [mkdir] Created dir: C:\wattdepot\wattdepot-simulation\build\jar
     [copy] Copying 15 files to C:\wattdepot\wattdepot-simulation\tmp
    [unjar] Expanding: C:\wattdepot\wattdepot-simulation\lib\cron4j\cron4j.jar into C:\wattdepot\wattdepot-simulation\tmp
    [unjar] Expanding: C:\wattdepot\wattdepot-simulation\lib\wattdepot\wattdepot-lib-client.jar into C:\wattdepot\wattdepot-simulation\tmp
      [jar] Building jar: C:\wattdepot\wattdepot-simulation\build\jar\simulation-oahugrid.jar
   [delete] Deleting directory C:\wattdepot\wattdepot-simulation\tmp

dist:
    [mkdir] Created dir: C:\wattdepot\wattdepot-simulation\dist-tmp\wattdepot-simulation-1.0.408
     [copy] Copying 63 files to C:\wattdepot\wattdepot-simulation\dist-tmp\wattdepot-simulation-1.0.408
     [copy] Copying 1 file to C:\wattdepot\wattdepot-simulation\dist-tmp\wattdepot-simulation-1.0.408
    [mkdir] Created dir: C:\wattdepot\wattdepot-simulation\build\dist
      [zip] Building zip: C:\wattdepot\wattdepot-simulation\build\dist\wattdepot-simulation-1.0.408.zip
   [delete] Deleting directory C:\wattdepot\wattdepot-simulation\dist-tmp

BUILD SUCCESSFUL
Total time: 11 seconds
C:\wattdepot\wattdepot-simulation>

The distribution zip file will be in the build/dist directory.

Design documentation

Design documentation for this system is maintained as JavaDoc. To see a recent snapshot of the JavaDoc for this system, go http://wattdepot-simulation.googlecode.com/svn/javadoc/index.html.

IDE Support

The package contains .classpath and .project files the define this project for use with the Eclipse IDE. Note that the Eclipse project definition refers to the project's lib directory for associated libraries. This lib/ directory is not included in the Subversion sources, but is instead created and populated automatically the first time you invoke Ant. Therefore, you must invoke 'ant' once before importing this project into Eclipse so that the required libraries are available.

Questions and technical support

Join the watt-depot users group to ask questions and receive technical support for this system.


Sign in to add a comment
Powered by Google Project Hosting