Difference between revisions of "Agilla Tutorial Lesson 2: Injecting an Agent"

From Cyber-Physical Systems Laboratory
Jump to navigationJump to search
 
(7 intermediate revisions by the same user not shown)
Line 1: Line 1:
Example Agilla agents can be found in $TOSROOT/contrib/wustl/apps/AgillaAgents. Read the README file within this directory for a description of each agent.
+
Example agents are in $TOSROOT/contrib/wustl/apps/AgillaAgents. Read the README file within this directory for a description of each agent.
  
 
== Configuring the AgentInjector ==
 
== Configuring the AgentInjector ==
Line 17: Line 17:
 
== Injecting an Agent ==
 
== Injecting an Agent ==
  
To inject an agent into the network, you have open them using the AgentInjector, and select the destination location.
+
Agents are injected into the WSN using the Agent Injector.  The following instructions describe how this is done using agent 3Blink.ma as an example.
  
 
=== Step 1: Run the Agent Injector ===
 
=== Step 1: Run the Agent Injector ===
 +
 +
Attach a mote to the PC and launch the Agent Injector using the appropriate COM port.  The following example assumes the mote is attached to COM1.
  
 
<pre>
 
<pre>
$ java edu.wustl.mobilab.agilla.AgentInjector -comm COM1:115200 -d
+
cd $TOSROOT/contrib/wustl/tools/java
 +
java -Djava.security.policy=java.policy edu.wustl.mobilab.agilla.AgentInjector \
 +
  -comm COM1:57600 -d &
 
</pre>
 
</pre>
 +
 +
The following GUI should appear:
 +
 +
[[image:agent-injector-init.jpg|center|thumb|702px|The Agilla Agent Injector GUI.]]
 +
 +
The main area of the GUI is a text area that contains the code of the agent that is being injected into the WSN.  Above this text area is a status bar that displays whether RMI is enabled and which port the Agent Injector is connected to.  In this case, RMI is disabled meaning agents cannot be remotely injected, and the WSN is attached to COM1. 
 +
 +
Below the text area are text boxes that allow you to specify where the agent should be injected, and displays the number of columns in the network's [[Agilla's Network Topology|grid topology]]. The inject button is located at the bottom of the GUI.  When this button is pressed, the Agent Injector will compile the agent and inject it into the WSN.
 +
 +
=== Step 2: Open an Agent ===
 +
 +
Once the Agent Injector is running, go to File, Open and choose 3Blink.ma.  You should see the following:
 +
 +
[[image:agent-injector.jpg|center|thumb|702px|The Agilla AgentInjector with agent 3Blink.ma opened.]]
 +
 +
 +
 +
 +
 +
 +
Type the address of the mote attached to the PC in the TOS Address box, and then click on the Inject Agent!! button. The 3Blink agent will then be compiled and injected into the network. Watch the mote attached to the PC. It should blink its LEDs 3 times each time you inject this agent.

Latest revision as of 20:01, 10 December 2007

Example agents are in $TOSROOT/contrib/wustl/apps/AgillaAgents. Read the README file within this directory for a description of each agent.

Configuring the AgentInjector

The AgentInjector searches for an agilla.properties file in the directory from which you launched it. This file may contain the following properties:

initDir=../../apps/AgillaAgents
defaultAgent=3Blink.ma
runTest=false
  • initDir specifies the directory that the open dialog should be at when it is opened for the first time.
  • defaultAgent specifies the agent that should be opened when the AgentInjector starts. This agent must be located in the initDir.
  • runTest specifies whether an experiment should be run. This is only used for debugging and evaluation purposes and should remain off in normal use.

Injecting an Agent

Agents are injected into the WSN using the Agent Injector. The following instructions describe how this is done using agent 3Blink.ma as an example.

Step 1: Run the Agent Injector

Attach a mote to the PC and launch the Agent Injector using the appropriate COM port. The following example assumes the mote is attached to COM1.

cd $TOSROOT/contrib/wustl/tools/java
java -Djava.security.policy=java.policy edu.wustl.mobilab.agilla.AgentInjector \
  -comm COM1:57600 -d &

The following GUI should appear:

File:Agent-injector-init.jpg
The Agilla Agent Injector GUI.

The main area of the GUI is a text area that contains the code of the agent that is being injected into the WSN. Above this text area is a status bar that displays whether RMI is enabled and which port the Agent Injector is connected to. In this case, RMI is disabled meaning agents cannot be remotely injected, and the WSN is attached to COM1.

Below the text area are text boxes that allow you to specify where the agent should be injected, and displays the number of columns in the network's grid topology. The inject button is located at the bottom of the GUI. When this button is pressed, the Agent Injector will compile the agent and inject it into the WSN.

Step 2: Open an Agent

Once the Agent Injector is running, go to File, Open and choose 3Blink.ma. You should see the following:

The Agilla AgentInjector with agent 3Blink.ma opened.




Type the address of the mote attached to the PC in the TOS Address box, and then click on the Inject Agent!! button. The 3Blink agent will then be compiled and injected into the network. Watch the mote attached to the PC. It should blink its LEDs 3 times each time you inject this agent.