NEMO Scripting
The NEMO framework executes every experiment according to the script that defines it. Scripts handle every detail, from creating devices to logging data. Scripts are written in a language called Jython.



The Task Object
When writing a NEMO script, one variable, called task, will be predefined by the framework. task is a Java object that is created when an experiment is created (that is, when a user decides to run the experiment). task serves as an intermediary between the script and the NEMO framework. It provides functions for setting up the environment for an experiment and communicating with clients during an experiment.

The following functions are made available to script writers through task:



The Pre-Start Phase
After a user chooses to run an experiment, NEMO pulls the script from the database and processes it. It is the responsibility of the script (and the script writer) to ensure that certain actions are taken to properly set up the experiment. Before the experiment starts, NEMO requires that a script specify the number of clients to expect, the name of the experiment, the start function, and the devices to be used.

The Pre-Start Phase is also a good time to set up any variables that may need to be used later in the script. This will cut down on time once the experiment starts. For example, this phase is a good time to get the necessary DataTypes from task.

Any part of the script that is not inside a class or function will be run in the Pre-Start Phase. Calls can be made to functions and classes, but only those that are explicitly called will be executed. As shown in the sample code on lines 481-514, calls are made to task.setExptSize, task.setExperimentName, task.setStartFunction, and others in the Pre-Start Phase. Note that a call is made on line 514 to construct an instance of a custom class (called ExampleClass).



Coordinating Clients
NEMO assigns a unique ID to each client that connects to the experiment. The IDs fall in the range 0 to numClients - 1. Client IDs are used when sending commands to clients, receiving communication from a particular client, and creating DataSets for logging data. When writing a script for a single-client experiment, client coordination is very straightforward (it will always be 0!); however, writing an experiment for 12 subjects can be cumbersome. It will be very important to ensure that commands go to the correct client and that events are attributed to the correct client.