Difference between revisions of "Device (Java)"

From Neurotech Software Development Kit
Jump to: navigation, search
(Method Detail)
(Method Detail)
Line 139: Line 139:
  
 
<h3>readParam</h3>
 
<h3>readParam</h3>
<code><span style="color:#0066FF;">'''public int'''</span><ParamType> ParamType readParam([[ParameterName (Java)|ParameterName]] param)</code>
+
<code><span style="color:#0066FF;">'''public'''</span><ParamType> ParamType readParam([[ParameterName (Java)|ParameterName]] param)</code>
  
 
Return value of specified parameter of device.  
 
Return value of specified parameter of device.  

Revision as of 11:08, 28 April 2018

ru.neuromd.neurosdk

Class Device

Related Classes

ru.neuromd.neurosdk.DeviceScanner

Classes hierarchy

  • java.lang.Object
    • ru.neuromd.neurosdk.Device

Class definition

public class Device

The Device class is an abstraction for NeuroMD BLE devices. This abstraction provides functions for changing of device state by executing commands and setting parameters. Each device have different sets of supported commands and parameters, Device class has functions designed to get information about these sets. Callibri and Braibit devices has different parameters sets and provides different ways to access them. Device class hides all differences behind its interface and provides universal way to read and write parameters, execute commands and receive biopotential signals.

Fields Summary

Modifier and Type Field and Description
SubscribersNotifier<ParameterName> parameterChanged

Subscribe this event to receive notifications about changes of device parameters

Constructor Summary

You are not able to create Device directly. Use DeviceScanner to find and create devices

Methods Summary

Modifier and Type Method and Description
void connect()

Establishes connection with device services

void disconnect()

Disconnects from device

ChannelInfo[] channels()

Returns information about supported channels. Check this information before creation of channel. If device does not support channel, channel object won't be initialized.

Command[] commands()

Returns supported commands of a device

Parameter[] parameters()

Returns all available parameters of device, their types and access rights

boolean execute()

Tries to execute command and returns value indicating operation success.

boolean setParam()

Sets value for specified parameter and returns value indicating success of operation.

<ParamType>

ParamType

readParam()

Return value of specified parameter of device.

Field Detail

parameterChanged

public final SubscribersNotifier<ParameterName> parameterChanged

Subscribe this event to receive notifications about changes of device parameters

Method Detail

connect

public void connect()

Tries to establish connection with device. Check DeviceState parameter or subscribe parameterChanged event for operation result.

disconnect

public void disconnect()

Disconnects from device. Check DeviceState parameter or subscribe parameterChanged event for operation result

channels

public ChannelInfo[] channels()

Returns information about supported channels.

Check this information before creation of channel. If device does not support channel, channel object won't be initialized with it.

Returns:
Array of channel info objects

commands

public Command[] commands()

Returns supported commands of device

Returns:
Array of supported commands

parameters

public Parameter[] parameters()

Returns all available parameters of device, their types and access rights

Returns:
Array of available parameters

execute

public boolean execute(Command cmd)

Tries to execute command and returns value indicating operations success.

Will throw if device does not support specified command. To get supported commands call commands() method.

Parameters:
cmd - Command to execute
Returns:
Operation success indicator
Throws:
java.lang.UnsupportedOperationException

readParam

public<ParamType> ParamType readParam(ParameterName param)

Return value of specified parameter of device.

Will throw if parameter does not present in device. To get supported parameters and type information for parameter call parameters() method. It returns Parameter object which consists of parameter name, type and access mode.

Parameters:
param - ParameterName to read
Returns:
Parameter value
Throws:
java.lang.UnsupportedOperationException

setParam

public boolean setParam(ParameterName param, Object value)

Sets value for specified parameter and returns value indicating success of operation.

Will throw if parameter does not present in device or has only Read access mode. To get supported parameters and type information for parameter call parameters() method. It returns Parameter object which consists of parameter name, type and access mode

Parameters:
param - Name of parameter to set
value - Parameter value
Returns:
Operation success indicator
Throws:
java.lang.UnsupportedOperationException