Jump to content

Technical Reference:States of Operation

From BCI2000 Wiki
Revision as of 16:28, 27 February 2007 by Mellinger (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

This page describes the states of operation that apply to a BCI2000 system as a whole. These are different from concept of BCI2000 States which are saved to data files on a per-data block basis.

Driven by user interaction, the system cycles through five phases of operation: Startup, Initialization, Suspended, Running, Termination.

State Diagram

Startup -> Initialization <-> Suspended -> Termination
                                  ^
                                  |
                                  v
                               Running

System Startup

Introduction

This section describes the system startup process. Since the system is a distributed system of encapsulated modules, this procedure ensures a proper and well defined information flow at start-up.

Startup Sequence

The operator module must be started first. Since in most cases the IP address of the operator module can be more easily statically defined, its IP address and port number(s) have to be provided to the core modules. It listens on ports 4000 (for Source), 4001 (for Signal Processing), and 4002 (for Application) and waits for the respective core module to connect. Each can connect to its assigned port on the operator module in any order. Upon start-up, each core module opens a listening socket on an arbitrary port number.

Publishing Phase

Upon connection, each core module publishes its parameters to the operator module as a sequence of parameter messages (parameter messages). After publishing its parameters, each core module publishes the states it requests as a sequence of state messages (state messages). At this time, the operator module ignores every field except Name and Length , which it needs to construct the state vector. For this and all subsequent communication, the modules use the BCI2000 messages protocol. Following the last state, each core module sends a system command containing the string EndOfState. On receiving this command from all core modules, the operator module ends this initial publishing phase.

System Initialization

Information Phase

The operator module processes the received parameters and states. It creates a list of all parameters and all states and creates the state vector (duplicate parameters or states are ignored). At this point, the operator module may modify the value of the parameters and states (depending on the investigator's input or the parameter file). The operator module then uses the same channel on which it received data from the core modules to send back to all core modules a list of all system-wide parameters and system-wide states (in any order). Since the IP address and port number on which the core modules listen for data from other core modules are published in system parameters as described, each module now knows where to send its data. The connections from the core modules to the operator module remain open (all subsequent traffic will go through these connections). As in the publishing phase, the Information Phase ends when a system command EndOfState is sent. In order to maintain integrity throughout operation, no parameters or states should be added to or removed from the system beyond this point.

Preflight Phase

Each core module declares whether it can process data with the received parameters and states, or indicates errors by sending descriptions into an error channel. If any errors are indicated during the preflight phase, the module will not initiate the initialization phase; the operator module will display the errors, prompting the user to fix the problems detected, and not offer the "Start" option.

Initialization Phase

Each core module uses the information in the received parameters to configure and initialize its operation. It also opens an active (i.e., client) connection to the other core module it must connect to, i.e., Source opens a connection to Signal Processing, Signal Processing to Application and Application to Source. Each core module sends a status message (BCI2000 messages) to the operator that indicates either successful or failed initialization. The Initialization Phase ends when all core modules indicate successful configuration.

System is Suspended

At the end of the Initialization Phase, the system is fully configured. All parameters and states (and positions thereof in the state vector) are defined. The system is suspended when Running is 0. Any module shall disregard a change in parameters if the system is not suspended. Data flows through the system and it is up to each module to decide how to process these data. The Application, for example, might give visual feedback that indicates that the system is suspended. As long as operation is suspended (i.e., Running is 0), any module might update system parameters and send them back to the Operator.

System is Running

During system operation, the Operator module must send states only to the Source module and Signal Processing and Application must disregard any state that the Operator does send to them. The system is started when the Operator module sets the state Running to 1 and sends it to the Source module.

System Termination

If any module detects a dropped connection to the Operator, it must shut down all other socket connections and terminate.