Jump to content

Technical Reference:SignalSharingClient Library: Difference between revisions

From BCI2000 Wiki
Mellinger (talk | contribs)
Mellinger (talk | contribs)
Line 3: Line 3:
==Functions provided by the Library==
==Functions provided by the Library==


===SSC_RESULT DLLEXPORT STDCALL SSC_CreateConnector(const char* listeningAddress, SSC_HANDLE*)===
===SSC_RESULT SSC_CreateConnector(const char* listeningAddress, SSC_HANDLE*)===
Create a connector object, and obtain a handle to it. A connector object is necessary to handle a connection to BCI2000.
Create a connector object, and obtain a handle to it. A connector object is necessary to handle a connection to BCI2000,
and is specified as the first argument of the remaining ''SignalSharingClient'' library functions.
The listening address is in the format <IP>:<port> with <IP> being a name or numeric address.
The listening address is in the format <IP>:<port> with <IP> being a name or numeric address.


===SSC_RESULT DLLEXPORT STDCALL SSC_DeleteConnector(SSC_HANDLE)===
===SSC_RESULT SSC_DeleteConnector(SSC_HANDLE)===
Delete a connector object. Must be called when connector object is no longer used.
Delete a connector object. Must be called when connector object is no longer used.


===SSC_RESULT DLLEXPORT STDCALL SSC_RegisterSignalCallback(SSC_HANDLE, SSC_CALLBACK, void* refdata)===
===SSC_RESULT SSC_RegisterSignalCallback(SSC_HANDLE, SSC_CALLBACK, void* refdata)===
Register a callback to be called whenever new signal data is available.
Register a callback to be called whenever new signal data is available.
For each connector object, it is only possible to register one signal callback at a time.
For each connector object, it is only possible to register one signal callback at a time.
Line 16: Line 17:
Use the <refdata> argument to specify auxiliary data which will be provided to the callback function when it is called.
Use the <refdata> argument to specify auxiliary data which will be provided to the callback function when it is called.


===SSC_RESULT DLLEXPORT STDCALL SSC_RegisterStatesCallback(SSC_HANDLE, SSC_CALLBACK, void* refdata)===
===SSC_RESULT SSC_RegisterStatesCallback(SSC_HANDLE, SSC_CALLBACK, void* refdata)===
Register a callback to be called whenever new state data is available.
Register a callback to be called whenever new state data is available.
For each connector object, it is only possible to register one states callback at a time.
For each connector object, it is only possible to register one states callback at a time.
Line 22: Line 23:
Use the <refdata> argument to specify auxiliary data which will be provided to the callback function when it is called.
Use the <refdata> argument to specify auxiliary data which will be provided to the callback function when it is called.


===SSC_RESULT DLLEXPORT STDCALL SSC_RegisterParametersCallback(SSC_HANDLE, SSC_CALLBACK, void* refdata)===
===SSC_RESULT SSC_RegisterParametersCallback(SSC_HANDLE, SSC_CALLBACK, void* refdata)===
Register a callback to be called whenever new parameter data is available.
Register a callback to be called whenever new parameter data is available.
For each connector object, it is only possible to register one parameters callback at a time.
For each connector object, it is only possible to register one parameters callback at a time.
Line 28: Line 29:
Use the <refdata> argument to specify auxiliary data which will be provided to the callback function when it is called.
Use the <refdata> argument to specify auxiliary data which will be provided to the callback function when it is called.


===SSC_RESULT DLLEXPORT STDCALL SSC_LockSignal(SSC_HANDLE, const double** pSignal, int* channels, int* samples, const char* const** channelNames)===
===SSC_RESULT SSC_LockSignal(SSC_HANDLE, const double** pSignal, int* channels, int* samples, const char* const** channelNames)===
Lock signal data and obtain signal information. Typically, this function will be called from a signal callback.
Lock signal data and obtain signal information. Typically, this function will be called from a signal callback.
Locking blocks the arrival of new signal data, so call <tt>SCC_ReleaseSignal()</tt> as soon as possible.
Locking blocks the arrival of new signal data, so call <tt>SCC_ReleaseSignal()</tt> as soon as possible.
All pointer arguments are optional, may be <tt>nullptr</tt>.
All pointer arguments are optional, may be <tt>nullptr</tt>.


===SSC_RESULT DLLEXPORT STDCALL SSC_ReleaseSignal(SSC_HANDLE)===
===SSC_RESULT SSC_ReleaseSignal(SSC_HANDLE)===
Releases a signal when it is locked. Call this function as soon as you are done with forwarding or processing signal data.
Releases a locked signal. Call this function as soon as you are done with forwarding or processing signal data.


===SSC_RESULT DLLEXPORT STDCALL SSC_LockStates(SSC_HANDLE, const double**, int* count, int* samples, const char* const** pStateNames)===
===SSC_RESULT SSC_LockStates(SSC_HANDLE, const double**, int* count, int* samples, const char* const** pStateNames)===
Lock state data and obtain state information.
Lock state data and obtain state information. Typically, this function will be called from a state callback.
  Locking blocks the arrival of new state data, so call SCC_ReleaseStates() as soon as possible.
Locking blocks the arrival of new state data, so call <tt>SCC_ReleaseStates)</tt> as soon as possible.
All pointer arguments are optional, may be nullptr
All pointer arguments are optional, may be <tt>nullptr</tt>.


===SSC_RESULT DLLEXPORT STDCALL SSC_ReleaseStates(SSC_HANDLE)===
===SSC_RESULT SSC_ReleaseStates(SSC_HANDLE)===
Releases locked state information. Call this function as soon as you are done with forwarding or processing state data.


===SSC_RESULT SSC_LockParameters(SSC_HANDLE, const char* const** parameterLines, int* count)===
Lock parameter data and obtain parameter information. Typically, this function will be called from a parameter callback.
Locking blocks the arrival of new parameter data, so call <tt>SCC_ReleaseParameters)</tt> as soon as possible.
All pointer arguments are optional, may be <tt>nullptr</tt>.


===SSC_RESULT DLLEXPORT STDCALL SSC_LockParameters(SSC_HANDLE, const char* const** parameterLines, int* count)===
===SSC_RESULT SSC_ReleaseParameters(SSC_HANDLE)===
Lock signal data and obtain signal information.
Releases locked parameter information. Call this function as soon as you are done with forwarding or processing parameter data.
  Locking blocks the arrival of new parameter data, so call SCC_ReleaseParameters() as soon as possible.
All pointer arguments are optional, may be nullptr
 
===SSC_RESULT DLLEXPORT STDCALL SSC_ReleaseParameters(SSC_HANDLE)===
 


===SSC_RESULT DLLEXPORT STDCALL SSC_GetSignalDimensions(SSC_HANDLE, int*, int*)===
===SSC_RESULT SSC_GetSignalDimensions(SSC_HANDLE, int* channels, int* samples)===
Get signal dimensions for use with PushSignal()
Obtain signal dimensions for use with <tt>SSC_PushSignal()</tt>.


===SSC_RESULT DLLEXPORT STDCALL SSC_PushSignal(SSC_HANDLE, const double*)===
===SSC_RESULT SSC_PushSignal(SSC_HANDLE, const double* pSignal)===
Push signal data
Push signal data. The ''pSignal'' pointer must point to a valid memory area that is at least as large as determined by a previous call to <tt>SSC_GetSignalDimensions</tt>. Pushing signal data will have no effect unless <tt>SSC_Commit()</tt> is called.


===SSC_RESULT DLLEXPORT STDCALL SSC_PushState(SSC_HANDLE, const char*, unsigned int)===
===SSC_RESULT SSC_PushState(SSC_HANDLE, const char* name, unsigned int value)===
Push a state value
Push a state value. Pushing a state value will have no effect unless <tt>SSC_Commit()</tt> is called.


===SSC_RESULT DLLEXPORT STDCALL SSC_Commit(SSC_HANDLE)===
===SSC_RESULT SSC_Commit(SSC_HANDLE)===
Commit pushed signal and state data to BCI2000
Commit pushed signal and state data to BCI2000. Any previously pushed signal or state data will be transmitted to BCI2000 when this function is called.


==See also==
==See also==

Revision as of 14:27, 11 March 2026

The SignalSharingClient library provides a SignalSharing client, wrapped into a C interface. It may be used to tap into signal and state data at any point of processing from external applications. The SignalSharingClient library can be used from any programming language that allows using a shared library (DLL). Although the SignalSharingClient library is written in C++, its DLL interface is plain C, and can be used with compiled languages such as C, C++, C#, Pascal, but also with interpreted languages that can call functions in a DLL, such as Python, Matlab, VisualBasic, etc. Interfacing with Java requires a JNI (Java Native Interface) wrapper, which is currently not provided by BCI2000.

Functions provided by the Library

SSC_RESULT SSC_CreateConnector(const char* listeningAddress, SSC_HANDLE*)

Create a connector object, and obtain a handle to it. A connector object is necessary to handle a connection to BCI2000, and is specified as the first argument of the remaining SignalSharingClient library functions. The listening address is in the format <IP>:<port> with <IP> being a name or numeric address.

SSC_RESULT SSC_DeleteConnector(SSC_HANDLE)

Delete a connector object. Must be called when connector object is no longer used.

SSC_RESULT SSC_RegisterSignalCallback(SSC_HANDLE, SSC_CALLBACK, void* refdata)

Register a callback to be called whenever new signal data is available. For each connector object, it is only possible to register one signal callback at a time. To unregister a signal callback, call SSC_RegisterSignalCallback() with a nullptr argument. Use the <refdata> argument to specify auxiliary data which will be provided to the callback function when it is called.

SSC_RESULT SSC_RegisterStatesCallback(SSC_HANDLE, SSC_CALLBACK, void* refdata)

Register a callback to be called whenever new state data is available. For each connector object, it is only possible to register one states callback at a time. To unregister a signal callback, call SSC_RegisterStatesCallback() with a nullptr argument. Use the <refdata> argument to specify auxiliary data which will be provided to the callback function when it is called.

SSC_RESULT SSC_RegisterParametersCallback(SSC_HANDLE, SSC_CALLBACK, void* refdata)

Register a callback to be called whenever new parameter data is available. For each connector object, it is only possible to register one parameters callback at a time. To unregister a signal callback, call SSC_RegisterParametersCallback() with a nullptr argument. Use the <refdata> argument to specify auxiliary data which will be provided to the callback function when it is called.

SSC_RESULT SSC_LockSignal(SSC_HANDLE, const double** pSignal, int* channels, int* samples, const char* const** channelNames)

Lock signal data and obtain signal information. Typically, this function will be called from a signal callback. Locking blocks the arrival of new signal data, so call SCC_ReleaseSignal() as soon as possible. All pointer arguments are optional, may be nullptr.

SSC_RESULT SSC_ReleaseSignal(SSC_HANDLE)

Releases a locked signal. Call this function as soon as you are done with forwarding or processing signal data.

SSC_RESULT SSC_LockStates(SSC_HANDLE, const double**, int* count, int* samples, const char* const** pStateNames)

Lock state data and obtain state information. Typically, this function will be called from a state callback. Locking blocks the arrival of new state data, so call SCC_ReleaseStates) as soon as possible. All pointer arguments are optional, may be nullptr.

SSC_RESULT SSC_ReleaseStates(SSC_HANDLE)

Releases locked state information. Call this function as soon as you are done with forwarding or processing state data.

SSC_RESULT SSC_LockParameters(SSC_HANDLE, const char* const** parameterLines, int* count)

Lock parameter data and obtain parameter information. Typically, this function will be called from a parameter callback. Locking blocks the arrival of new parameter data, so call SCC_ReleaseParameters) as soon as possible. All pointer arguments are optional, may be nullptr.

SSC_RESULT SSC_ReleaseParameters(SSC_HANDLE)

Releases locked parameter information. Call this function as soon as you are done with forwarding or processing parameter data.

SSC_RESULT SSC_GetSignalDimensions(SSC_HANDLE, int* channels, int* samples)

Obtain signal dimensions for use with SSC_PushSignal().

SSC_RESULT SSC_PushSignal(SSC_HANDLE, const double* pSignal)

Push signal data. The pSignal pointer must point to a valid memory area that is at least as large as determined by a previous call to SSC_GetSignalDimensions. Pushing signal data will have no effect unless SSC_Commit() is called.

SSC_RESULT SSC_PushState(SSC_HANDLE, const char* name, unsigned int value)

Push a state value. Pushing a state value will have no effect unless SSC_Commit() is called.

SSC_RESULT SSC_Commit(SSC_HANDLE)

Commit pushed signal and state data to BCI2000. Any previously pushed signal or state data will be transmitted to BCI2000 when this function is called.

See also

Technical Reference:BCI2000Remote Library, Programming Reference:BCI2000Remote Class, Contributions:BCI2000Command, Contributions:BCI2000PresentationLink, Contributions:Applications