Eclipse IDE Setup

The only thing that is necessary to create a VOLTTRON agent is a text editor and the shell. However, we have found the Eclipse Development Environment (IDE) to be a valuable tool for helping to develop VOLTTRON agents. You can obtain the latest (MARS as fo 10/7/15) from http://www.eclipse.org/. Once downloaded the PyDev Plugin is a valuable tool for executing the platform as well as debugging agent code.

PyDev Plugin

Installing the PyDev plugin from the Eclipse Market place There is a python plugin for eclipse that makes development much easier. Install it from the eclipse marketplace.

Help -> Eclipse Marketplace...

Click Install

Cloning the Source Code

The VOLTTRON code is stored in a git repository. Eclipse (Luna and Mars) come with a git plugin out of the box. For other versions the plugin is available for Eclipse that makes development more convenient (note: you must have Git already installed on the system and have built VOLTTRON):

If your version of Eclipse does not have the marketplace follow these instructions.

The project can now be checked out from the repository into Eclipse.

  1. Open the Git view

    Select Git view

  2. Clone a Git Repository

    Clone existing repo

  3. Fill out the URI: https://github.com/VOLTTRON/volttron

    Select repo

  4. Select master for latest stable version

    Select branch repo

  5. Import the cloned repository as a general project

    Import project

  6. Pick a project name (default volttron) and hit Finish

    Finish import

  7. Switch to the PyDev perspective

Build VOLTTRON

Continue the setup process by opening a command shell. Make the current directory the root of your cloned VOLTTRON directory. Follow the instructions in our Building VOLTTRON section of the wiki and then continue below.

Linking Eclipse and the VOLTTRON Python Environment

From the Eclipse IDE right click on the project name and select Refresh so eclipse will be aware of the file system changes. The next step will define the python version that PyDev will use for VOLTTRON

  1. Choose Window - > Preferences

  2. Expand the PyDev tree

  3. Select Interpreters - > Python Interpreter

  4. Click New

  5. Click Browse and browse to the pydev-python file located in scripts directory off of the volttron source

  6. Click Ok

    Pick Python

  7. Select All, then uncheck the VOLTTRON root like the picture below

    Select path

  8. Click Ok

Note

You may need redo this stage after platform updates

Make Project a PyDev Project

  1. In the Project/PackageExplorer view on the left, right-click on the project, PyDev-> Set as PyDev Project
  2. Switch to the PyDev perspective (if it has not already switched), Window -> Open Perspective -> PyDev Set as Pydev

Eclipse should now be configured to use the project’s environment.

Testing the Installation

In order to test the installation the VOLTTRON platform must be running. You can do this either through the shell or through Eclipse.

Execute VOLTTRON Through Shell

  1. Open a console and cd into the root of the volttron repository.

  2. Execute source env/bin/activate

  3. Execute volttron -vv

    Execute VOLTTRON in Shell

You now have a running VOLTTRON logging to standard out. The next step to verifying the installation is to start a listeneragent.

Execute VOLTTRON Through Eclipse

  1. Click Run -> Run Configuration from the Eclipse Main Menu

  2. Click the New Launch Configuration button

    New Launch Configuration

  3. Change the name and select the main module volttron/platform/main.py

    Main Module

  4. Click the Arguments Tab add ‘-vv’ to the arguments and change the working directory to default

    Arguments

  5. Click Run. The following image displays the output of a successfully started platform

    Successful Start

ref:_Start-Listener-Eclipse:

Start a ListenerAgent

Warning

Before attempting to run an agent in Eclipse, please see the note in: AgentDevelopment

The listener agent will listen to the message bus for any published messages. It will also publish a heartbeat message ever 10 seconds (by default).

Create a new run configuration entry for the listener agent.

  1. In the Package Explorer view, open examples -> ListenerAgent –> listener

  2. Righ-click on agent.py and select Run As -> Python Run (this will create a run configuration but fail)

  3. On the menu bar, pick Run -> Run Configurations…

  4. Under Python Run pick “volttron agent.py”

  5. Click on the Arguments tab and Change Working Directory to Default

  6. In the Environment tab, click new set the variable to AGENT_CONFIG with the value of /home/git/volttron/examples/ListenerAgent/config

    Listener Vars

  7. Click Run, this launches the agent

You should see the agent start to publish and receive its own heartbeat message in the console.