ESP OpenBCI - An EEG Signal Processing Library for OpenBCI Hardware

com.github.mrstampy.esp.openbci
Class MultiConnectOpenBCISocket

java.lang.Object
  extended by com.github.mrstampy.esp.multiconnectionsocket.AbstractMultiConnectionSocket<byte[]>
      extended by com.github.mrstampy.esp.openbci.MultiConnectOpenBCISocket
All Implemented Interfaces:
MultiConnectionSocket, OpenBCIConstants

public class MultiConnectOpenBCISocket
extends AbstractMultiConnectionSocket<byte[]>
implements OpenBCIConstants

The Class MultiConnectOpenBCISocket.


Field Summary
 
Fields inherited from interface com.github.mrstampy.esp.openbci.OpenBCIConstants
CHANNELS_START_IDX, END_PACKET, NUM_CHANNELS_IDX, START_PACKET
 
Constructor Summary
MultiConnectOpenBCISocket()
          Instantiates a new multi connect open bci socket.
MultiConnectOpenBCISocket(boolean broadcasting)
          Instantiates a new multi connect open bci socket.
 
Method Summary
 void activateChannel(int channelNumber)
          Activate channel.
 void activateLeadoffN(int channelNumber)
          Activate leadoff n.
 void activateLeadoffP(int channelNumber)
          Activate leadoff p.
 void addListener(OpenBCIEventListener l)
          Adds the listener.
 void clearListeners()
          Clear listeners.
 void deactivateChannel(int channelNumber)
          Deactivate channel.
 void deactivateLeadoffN(int channelNumber)
          Deactivate leadoff n.
 void deactivateLeadoffP(int channelNumber)
          Deactivate leadoff p.
 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.
protected  org.apache.mina.core.service.IoHandler getHandlerAdapter()
          Gets the handler adapter.
 OpenBCICommand getStartCommand()
          Gets the start command.
 boolean isConnected()
          Returns true if connected to the AbstractMultiConnectionSocket socket.
protected  void parseMessage(byte[] message)
          Invoked via Disruptor's onEvent processing, implement to notify event listeners and any multi connection subscribers.
 void removeListener(OpenBCIEventListener l)
          Removes the listener.
 void sendCommand(OpenBCICommand command)
          Send command.
 void setStartCommand(OpenBCICommand startCommand)
          Sets the start command.
protected  void startImpl()
          Implement to create a connection to the EEG device.
protected  void stopImpl()
          Implement to close the connection to the EEG device.
 void tune()
          When invoked the tuning functionality of the SampleBuffer will be activated.
 
Methods inherited from class com.github.mrstampy.esp.multiconnectionsocket.AbstractMultiConnectionSocket
addConnectionEventListener, bindBroadcaster, canBroadcast, clearConnectionEventListeners, getNumChannels, initBroadCaster, isBound, notifyConnectionEventListeners, publishMessage, removeConnectionEventListener, setNumChannels, start, stop, unbindBroadcaster
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MultiConnectOpenBCISocket

public MultiConnectOpenBCISocket()
                          throws java.io.IOException
Instantiates a new multi connect open bci socket.

Throws:
java.io.IOException - Signals that an I/O exception has occurred.

MultiConnectOpenBCISocket

public MultiConnectOpenBCISocket(boolean broadcasting)
                          throws java.io.IOException
Instantiates a new multi connect open bci socket.

Parameters:
broadcasting - the broadcasting
Throws:
java.io.IOException - Signals that an I/O exception has occurred.
Method Detail

sendCommand

public void sendCommand(OpenBCICommand command)
Send command.

Parameters:
command - the command

activateChannel

public void activateChannel(int channelNumber)
Activate channel.

Parameters:
channelNumber - the channel number

deactivateChannel

public void deactivateChannel(int channelNumber)
Deactivate channel.

Parameters:
channelNumber - the channel number

activateLeadoffN

public void activateLeadoffN(int channelNumber)
Activate leadoff n.

Parameters:
channelNumber - the channel number

activateLeadoffP

public void activateLeadoffP(int channelNumber)
Activate leadoff p.

Parameters:
channelNumber - the channel number

deactivateLeadoffN

public void deactivateLeadoffN(int channelNumber)
Deactivate leadoff n.

Parameters:
channelNumber - the channel number

deactivateLeadoffP

public void deactivateLeadoffP(int channelNumber)
Deactivate leadoff p.

Parameters:
channelNumber - the channel number

addListener

public void addListener(OpenBCIEventListener l)
Adds the listener.

Parameters:
l - the l

removeListener

public void removeListener(OpenBCIEventListener l)
Removes the listener.

Parameters:
l - the l

clearListeners

public void clearListeners()
Clear listeners.


tune

public void tune()
When invoked the tuning functionality of the SampleBuffer will be activated. The tuning process takes ~ 10 seconds, during which the number of samples will be counted and used to resize the buffer to more closely represent 1 seconds' worth of data.


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

startImpl

protected void startImpl()
                  throws MultiConnectionSocketException
Description copied from class: AbstractMultiConnectionSocket
Implement to create a connection to the EEG device. Messages retrieved from the device should be passed to the AbstractMultiConnectionSocket#publishMessage(String) method.

Specified by:
startImpl in class AbstractMultiConnectionSocket<byte[]>
Throws:
MultiConnectionSocketException - the multi connection socket exception
See Also:
AbstractMultiConnectionSocket#publishMessage(String)

stopImpl

protected void stopImpl()
Description copied from class: AbstractMultiConnectionSocket
Implement to close the connection to the EEG device.

Specified by:
stopImpl in class AbstractMultiConnectionSocket<byte[]>

getHandlerAdapter

protected org.apache.mina.core.service.IoHandler getHandlerAdapter()
Description copied from class: AbstractMultiConnectionSocket
Gets the handler adapter.

Specified by:
getHandlerAdapter in class AbstractMultiConnectionSocket<byte[]>
Returns:
the handler adapter

parseMessage

protected void parseMessage(byte[] message)
Description copied from class: AbstractMultiConnectionSocket
Invoked via Disruptor's onEvent processing, implement to notify event listeners and any multi connection subscribers.

Specified by:
parseMessage in class AbstractMultiConnectionSocket<byte[]>
Parameters:
message - the message

getStartCommand

public OpenBCICommand getStartCommand()
Gets the start command. Defaults to START_BINARY.

Returns:
the start command

setStartCommand

public void setStartCommand(OpenBCICommand startCommand)
Sets the start command.

Parameters:
startCommand - the new start command

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

brought to you by Mr. Stampy