Difference between revisions of "NeuroMD SDK Manual"

From Neurotech Software Development Kit
Jump to: navigation, search
(Device abstraction)
(Device abstraction)
Line 114: Line 114:
 
<syntaxhighlight lang='java' line='line' class="mw-collapsible">
 
<syntaxhighlight lang='java' line='line' class="mw-collapsible">
 
public class Device {
 
public class Device {
    /**
 
    * Subscribe this event to receive notifications about changes of device parameters
 
    */
 
 
     public final SubscribersNotifier<ParameterName> parameterChanged;
 
     public final SubscribersNotifier<ParameterName> parameterChanged;
  
    /**
 
    * Tries to establish connection with device
 
    * Check DeviceState parameter or subscribe parameterChanged event for operation result
 
    */
 
 
     public native void connect();
 
     public native void connect();
 
    /**
 
    * Disconnects from device
 
    * Check DeviceState parameter or subscribe parameterChanged event for operation result
 
    */
 
 
     public native void disconnect();
 
     public native void disconnect();
 
    /**
 
    * 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
 
    * @return Array of channel info objects
 
    */
 
 
     public native ChannelInfo[] channels();
 
     public native ChannelInfo[] channels();
 
    /**
 
    * Returns supported commands of device
 
    * @return Array of supported commands
 
    */
 
 
     public native Command[] commands();
 
     public native Command[] commands();
 
    /**
 
    * Returns all available parameters of device, their types and access rights
 
    * @return Array of available parameters
 
    */
 
 
     public native Parameter[] parameters();
 
     public native Parameter[] parameters();
 
    /**
 
    * 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
 
    * @param cmd Command to execute
 
    * @return Operation success indicator
 
    * @throws UnsupportedOperationException
 
    */
 
 
     public native boolean execute(Command cmd);
 
     public native boolean execute(Command cmd);
 
    /**
 
    * 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
 
    * @param param ParameterName to read
 
    * @return Parameter value
 
    * @throws UnsupportedOperationException
 
    */
 
 
     public native <ParamType> ParamType readParam(ParameterName param);
 
     public native <ParamType> ParamType readParam(ParameterName param);
 
    /**
 
    * 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
 
    * @param param Name of parameter to set
 
    * @param value Parameter value
 
    * @return Operation success
 
    * @throws UnsupportedOperationException
 
    */
 
 
     public native boolean setParam(ParameterName param, Object value);
 
     public native boolean setParam(ParameterName param, Object value);
 
}
 
}
 
</syntaxhighlight>
 
</syntaxhighlight>

Revision as of 06:09, 25 April 2018

This section contains information about software development kit required for using Callibri and Brainbit devices in user applications.

Introduction

NeuroSDK as a part of Callibri and Brainbit products is a set of libraries for different operating systems and platforms providing full set of tools needed for configuring and receiving data from Callibri and Brainbit devices. This software development kit consists of portable core written on C++11/14 and a set of wrappers for different languages and platforms: Java for Android operating system, Objective-C++ for iOS/MacOS, C# for Windows, Python for different OS'es. Also core could be used for making cross-platform applications in C++ using different compilers and IDEs.

NeuroSDK is intended to be used by developers of different systems which requires biopotential data in conjunction with information about movements and respiratory activity. NeuroSDK is also provides tools for making electrostimulation using Callibri MotionAssistant device.

Devices versions, commands and parameters

Callibri and Brainbit devices could have different sets of modules and functions depend on purpose of specific device. In this section all possible compositions of modules or functions are listed

Callibri

Since Callibri device is positioned as universal biopotential measuring device it has modules to provide as much information as possible.

All posible modules of Callibri device are:

Base Callibri module

Base module is responsible for common Callibri device configuration and BLE configuration.

Signal module

This module controls wide range of bio signals acquisition and its parameters such as sampling frequency, gain etc.

Respiration module

Respiration module controls special signal acquisition - respiration characteristic.

Micro electro-mechanical system module

This module is responsible for orientation and acceleration tracking of device.

Stimulation module

Special module for Callibri MotionAssistant which provides output with stimulation current pulses for miostimulation.

Most commonly Callibri device are supplied with all of these modules except stimulation module. Stimulation module is included in Callibri MotionAssistant modification. Modules could be configured through device parameters. Its is also possible to execute set of module-specific commands. List of supported commands and parameters could be acquired from device by appropriate calls to device library. All possible commands and parameters are listed in separate section below.

Brainbit

Brainbit is more simplier than Callibri device and has only two modules

Base Brainbit module

Base module is responsible for connection establishing through BLE and for device state and mode control.

Signal module

Signal module is responsible for acquisition of EEG signal from 4 device electrodes and for measuring electrodes resistance.

There is no modifications for Brainbit device yet, so it has fixed set of commands and parameters.

Device commands and parameters

Whole list of device commands consists of:

1. StartSignal command
2. StopSignal command
3. StartResist command
4. StopResist command
5. StartMEMS command
6. StopMEMS command
7. StartRespiration command
8. StopRespiration command
9. StartStimulation command
10. EnableMotionAssistant command
11. FindMe command

Set of command for specific device depends on which modules does device have. This is also true for parameters set. All possible parameters are listed below:

1. Name,
2. State,
3. Address,
4. SerialNumber,
5. HardwareFilterState,
6. FirmwareMode,
7. SamplingFrequency,
8. Gain,
9. Offset,
10. ExternalSwitchState,
11. ADCInputState,
12. AccelerometerSens,
13. GyroscopeSens,
14. StimulatorState,
15. MotionAssistantState,
16. StimulatorParamPack,
17. MotionAssistantParamPack

Device could be configured by setting these parameters, but whether each parameter could be set or not is represented by parameter access modifier:

1. Read,
2. ReadWrite,
3. ReadNotify

Parameters could be readonly, for some of them device provides notification mechanism. Parameters with ReadWrite notifier could be set from user code.

Device abstraction

Every physical device, Callibri or Brainbit, is represented in NeuroSDK as Device abstraction which has state and set of possible control actions. Device state (should not be confused with connection state - one of device parameters) is characterized by parameters of device , which could be read with special function call readParam. Control actions are presented as set of possible commands and set of writable parameters. Commands could be executed by execute function, parameters could be set with setParam function.

C++

namespace Neuro {

class Device final {
private:
    std::unique_ptr<DeviceImpl> mImpl;

public:
    ~Device();

    void connect();
    void disconnect();
    std::vector<ChannelInfo> channels() const;
    std::vector<Command> commands() const;
    std::vector<ParamPair> parameters() const;
    bool execute(Command);
    void setParamChangedCallback(std::function<void(Parameter)>);

    template <Parameter P>
    typename ParamValue<P>::Type readParam() const;

    template <Parameter P>
    bool setParam(typename ParamValue<P>::Type value);

private:
    Device(std::unique_ptr<DeviceImpl>);
};

}


Java

public class Device {
    public final SubscribersNotifier<ParameterName> parameterChanged;

    public native void connect();
    public native void disconnect();
    public native ChannelInfo[] channels();
    public native Command[] commands();
    public native Parameter[] parameters();
    public native boolean execute(Command cmd);
    public native <ParamType> ParamType readParam(ParameterName param);
    public native boolean setParam(ParameterName param, Object value);
}