ESP OpenBCI - An EEG Signal Processing Library for OpenBCI Hardware

com.github.mrstampy.esp.dsp.lab
Class AbstractRawEspConnection<SOCKET extends MultiConnectionSocket>

java.lang.Object
  extended by com.github.mrstampy.esp.dsp.lab.AbstractRawEspConnection<SOCKET>
Type Parameters:
SOCKET - the generic type
All Implemented Interfaces:
RawEspConnection, MultiConnectionSocket
Direct Known Subclasses:
OpenBCIConnection

public abstract class AbstractRawEspConnection<SOCKET extends MultiConnectionSocket>
extends java.lang.Object
implements RawEspConnection

Abstract implementation.

Author:
burton

Constructor Summary
AbstractRawEspConnection()
           
 
Method Summary
 void addConnectionEventListener(ConnectionEventListener listener)
          Adds the connection event listener.
 void bindBroadcaster()
          Binds the broadcaster to the local host and the broadcaster port in AbstractSocketConnector.
 boolean canBroadcast()
          Returns true if this instance has been configured for broadcasting.
 void clearConnectionEventListeners()
          Clear connection event listeners.
 EspChannel getChannel(int channelNumber)
          Returns the EspChannel representation specified by the channel number.
 java.util.List<EspChannel> getChannels()
          Returns the EspChannel representations processed by the implementation.
 Lab getDefaultLab()
          Returns a DefaultLab instance set to use this connection.
 int getNumChannels()
          Returns the number of channels.
abstract  SOCKET getSocket()
          Gets the socket.
 EspWindowFunction getWindowFunction()
          Return the window function.
 boolean isBound()
          Returns true if the broadcaster is bound.
 boolean isConnected()
          Returns true if connected to the AbstractMultiConnectionSocket socket.
 void removeConnectionEventListener(ConnectionEventListener listener)
          Removes the connection event listener.
 void setWindowFunction(EspWindowFunction function)
          Set the window function.
 void start()
          Connects to the socket.
 void stop()
          Closes the connection to the AbstractMultiConnectionSocket socket.
 void unbindBroadcaster()
          Unbinds the broadcaster.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.github.mrstampy.esp.dsp.lab.RawEspConnection
getCurrent, getCurrent, getCurrentFor, getCurrentFor, getDSPValues, getName, getUtilities
 

Constructor Detail

AbstractRawEspConnection

public AbstractRawEspConnection()
Method Detail

addConnectionEventListener

public void addConnectionEventListener(ConnectionEventListener listener)
Description copied from interface: MultiConnectionSocket
Adds the connection event listener.

Specified by:
addConnectionEventListener in interface MultiConnectionSocket
Parameters:
listener - the listener

removeConnectionEventListener

public void removeConnectionEventListener(ConnectionEventListener listener)
Description copied from interface: MultiConnectionSocket
Removes the connection event listener.

Specified by:
removeConnectionEventListener in interface MultiConnectionSocket
Parameters:
listener - the listener

clearConnectionEventListeners

public void clearConnectionEventListeners()
Description copied from interface: MultiConnectionSocket
Clear connection event listeners.

Specified by:
clearConnectionEventListeners in interface MultiConnectionSocket

start

public void start()
           throws MultiConnectionSocketException
Description copied from interface: MultiConnectionSocket
Connects to the socket.

Specified by:
start in interface MultiConnectionSocket
Throws:
MultiConnectionSocketException - if already connected or an unexpected error occurs

stop

public void stop()
Description copied from interface: MultiConnectionSocket
Closes the connection to the AbstractMultiConnectionSocket socket.

Specified by:
stop in interface MultiConnectionSocket

isConnected

public boolean isConnected()
Description copied from interface: MultiConnectionSocket
Returns true if connected to the AbstractMultiConnectionSocket socket.

Specified by:
isConnected in interface MultiConnectionSocket
Returns:
true if connected

bindBroadcaster

public void bindBroadcaster()
                     throws java.io.IOException
Description copied from interface: MultiConnectionSocket
Binds the broadcaster to the local host and the broadcaster port in AbstractSocketConnector.

Specified by:
bindBroadcaster in interface MultiConnectionSocket
Throws:
java.io.IOException - Signals that an I/O exception has occurred.
See Also:
AbstractSocketConnector

unbindBroadcaster

public void unbindBroadcaster()
Description copied from interface: MultiConnectionSocket
Unbinds the broadcaster.

Specified by:
unbindBroadcaster in interface MultiConnectionSocket
See Also:
AbstractSocketConnector

isBound

public boolean isBound()
Description copied from interface: MultiConnectionSocket
Returns true if the broadcaster is bound.

Specified by:
isBound in interface MultiConnectionSocket
Returns:
true, if is bound
See Also:
AbstractSocketConnector

canBroadcast

public boolean canBroadcast()
Description copied from interface: MultiConnectionSocket
Returns true if this instance has been configured for broadcasting.

Specified by:
canBroadcast in interface MultiConnectionSocket
Returns:
true, if successful

getWindowFunction

public EspWindowFunction getWindowFunction()
Description copied from interface: RawEspConnection
Return the window function.

Specified by:
getWindowFunction in interface RawEspConnection
Returns:
the window function
See Also:
EspSignalUtilities.setWindow(ddf.minim.analysis.WindowFunction)

setWindowFunction

public void setWindowFunction(EspWindowFunction function)
Description copied from interface: RawEspConnection
Set the window function.

Specified by:
setWindowFunction in interface RawEspConnection
Parameters:
function - the new window function
See Also:
EspSignalUtilities.setWindow(ddf.minim.analysis.WindowFunction)

getNumChannels

public int getNumChannels()
Description copied from interface: MultiConnectionSocket
Returns the number of channels.

Specified by:
getNumChannels in interface MultiConnectionSocket
Returns:
the num channels

getChannels

public java.util.List<EspChannel> getChannels()
Description copied from interface: MultiConnectionSocket
Returns the EspChannel representations processed by the implementation.

Specified by:
getChannels in interface MultiConnectionSocket
Returns:
the channels

getChannel

public EspChannel getChannel(int channelNumber)
Description copied from interface: MultiConnectionSocket
Returns the EspChannel representation specified by the channel number.

Specified by:
getChannel in interface MultiConnectionSocket
Parameters:
channelNumber - the channel number
Returns:
the channel

getDefaultLab

public Lab getDefaultLab()
Returns a DefaultLab instance set to use this connection. Can be overridden in subclasses for custom Lab implementations.

Specified by:
getDefaultLab in interface RawEspConnection
Returns:

getSocket

public abstract SOCKET getSocket()
Gets the socket.

Returns:
the socket

brought to you by Mr. Stampy