Programming Reference:States

From BCI2000 Wiki
Revision as of 15:34, 28 April 2011 by Mellinger (talk | contribs) (→‎See also)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

In BCI2000, states have the function of event markers. State objects are grouped into StateLists, and their values are transported in a global StateVector object. This page lists the methods and properties of State, StateList, and StateVector classes; for a general discussion of the state concept in BCI2000, see the State Definition page.

State Class

Methods

bool operator==( State ), bool operator!=( State )

Tests two State objects for equality.

State AssignValue( State )

Assigns the value of the specified State object.

ostream WriteToStream( ostream ), istream ReadFromStream( istream )

Writes/reads the Param object to/from a stream in human readable format.

ostream WriteBinary( ostream ), istream ReadBinary( istream )

Writes/reads the Param object to/from a BCI2000 binary stream (such as the streams connecting BCI2000 modules).

Properties

string Name (r)

The state's name.

int Location (r)

The state's location in the state vector.

int Length (r)

The state's length in bits.

int Value (w)

The state's value. Write-only to avoid confusion with the state's value in the associated StateVector object.

StateList Class

Methods

bool operator==( StateList ), bool operator!=( StateList )

Tests for equality against the specified StateList object.

State operator[]( string name )

Access to an individual State object by its name.

State operator[]( int index )

Access to an individual State object by its index.

Clear()

Removes all State objects from the list.

bool Exists( string name )

Returns true if a State object with the given name exists in the list.

int Index( string name )

Returns the index of the State object with the given name, or the list's size if there is no such State object.

Add( State )

Adds the given State object to the list.

Add( string stateDefinition )

Creates a State object from the specified State Definition, and adds it to the list.

Delete( string name )

Deletes the State object with the specified name from the list.

AssignPositions

Assigns, for each State object in the list, a position in the state vector, and writes it into the State object's Location property.

ostream WriteToStream( ostream ), istream ReadFromStream( istream )

Writes/reads the entire state list to/from a stream in human readable format.

ostream WriteBinary( ostream ), istream ReadBinary( istream )

Writes/reads the entire state list to/from a BCI2000 binary stream (such as used for communication between modules).

Properties

int Size (r)

The number of State objects in the list.

bool Empty (r)

True if the list is empty, false otherwise.

StateVector Class

Methods

StateVector( StateList, int numSamples = 1 )

Creates a StateVector object from the given StateList, with the specified number of samples. Typically, the number of samples in a StateVector matches the system's sample block size in the online system, and is 1 when accessing data files via the BCI2000FileReader Class.

PostStateChange( string name, int value )

Post a state change by buffering the new value in the associated State object's Value property.

CommitStateChanges()

Commits all buffered state changes to the state vector.

ostream WriteToStream( ostream ), istream ReadFromStream( istream )

Writes/reads the entire parameter list to/from a stream in human readable format.

ostream WriteBinary( ostream ), istream ReadBinary( istream )

Writes/reads the entire parameter list to/from a BCI2000 binary stream (such as used for communication between modules).

Properties

int Samples (r)

The number of samples contained in the state vector.

int Length (r)

The state vector's length, in bytes.

StateList (r)

The StateList object specified when creating the StateVector object.

int StateValue( string name, int sample = 0 )

The value of the specified state inside the state vector, at the specified sample position. In the online system, sample position may refer to [0..sample block size]; when using the BCI2000FileReader Class to access data from a file, sample position must always be 0.

See also

Technical Reference:State Definition, Programming Reference:Accessing Parameters and States