Jump to content

Technical Reference:States of Operation: Difference between revisions

From BCI2000 Wiki
Mellinger (talk | contribs)
No edit summary
 
Mellinger (talk | contribs)
No edit summary
Line 1: Line 1:
This page describes the states of operation that apply to a BCI2000 system as a whole.
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.
These are different from concept of [[State definition|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:
Driven by user interaction from the operator module, the system cycles through five phases of operation:
Startup, Initialization, Suspended, Running, Termination.
Startup, Initialization, Suspended, Running, Termination.


Line 20: Line 20:
proper and
proper and
well defined information flow at start-up.
well defined information flow at start-up.
===Startup Sequence===
===Startup Sequence===
The operator module must be started first. Since in most cases the IP
The operator module must be started first. Since in most cases the IP
Line 25: Line 26:
the operator module can be more easily statically defined, its IP
the operator module can be more easily statically defined, its IP
address and
address and
port number(s) have to be provided to the core modules. It listens on
port number(s) have to be provided to the core modules.
ports 4000
It listens on ports 4000
(for Source), 4001 (for Signal Processing), and 4002 (for Application)
(for Source), 4001 (for Signal Processing), and 4002 (for Application)
and
and
Line 34: Line 35:
each core
each core
module opens a listening socket on an arbitrary port number.
module opens a listening socket on an arbitrary port number.
===Publishing Phase===
===Publishing Phase===
Upon connection, each core module publishes its parameters to the
Upon connection, each core module publishes its parameters to the
operator module as a sequence of parameter messages ([[parameter messages]]).
operator module as a sequence of [[BCI2000 messages|parameter messages]].
After
After
publishing its
publishing its
parameters, each core module publishes the states it requests as
parameters, each core module publishes the states it requests as
a sequence of state messages ([[state messages]]).
a sequence of [[BCI2000 messages|state messages]].
At this time, the operator module ignores
At this time, the operator module ignores
every
every
Line 51: Line 53:
<tt>EndOfState</tt>.
<tt>EndOfState</tt>.
On receiving this command from all core modules, the operator module
On receiving this command from all core modules, the operator module
ends
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), and ends
this initial publishing phase.
this initial publishing phase.
In order to maintain integrity throughout operation, no parameters or
states
should be added to or removed from the system beyond this point.


==System Initialization==
==System Initialization==
===Information Phase===
===Information Phase===
The operator module processes the received parameters and states. It
At this point, the operator module
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
may modify
the value of the parameters and states (depending on the
the value of the parameters and states (depending on the
Line 82: Line 87:
command
command
<tt>EndOfState</tt> is sent.
<tt>EndOfState</tt> 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===
===Preflight Phase===
Line 107: Line 109:
connection to Signal Processing, Signal Processing to Application and
connection to Signal Processing, Signal Processing to Application and
Application to Source.
Application to Source.
Each core module sends a status message ([[BCI2000 messages]])
Each core module sends a [[BCI2000 messages|status message]]
to the
to the
operator that indicates either successful or failed initialization.
operator that indicates either successful or failed initialization.
Line 147: Line 149:
shut down
shut down
all other socket connections and terminate.
all other socket connections and terminate.
Thus, the operator module can initiate system termination by closing its connections to the individual modules.
----
See also:

Revision as of 16:40, 27 February 2007

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 from the operator module, 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. After publishing its parameters, each core module publishes the states it requests as a sequence of 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 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), and ends this initial publishing phase. In order to maintain integrity throughout operation, no parameters or states should be added to or removed from the system beyond this point.

System Initialization

Information Phase

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.

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 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. Thus, the operator module can initiate system termination by closing its connections to the individual modules.


See also: