C++ API
Loading...
Searching...
No Matches
Plux::BaseDev Class Reference

Base class for all PLUX devices. More...

#include <plux.h>

Inheritance diagram for Plux::BaseDev:
Plux::SignalsDev Plux::StimDev Plux::BITalinoDev Plux::MemoryDev

Public Types

enum  ProductId {
  PID_BioPlux = 0x0101 , PID_BiosignalsPlux = 0x0201 , PID_BiosignalsPluxPRO = 0x0205 , PID_MotionPlux = 0x020A ,
  PID_OpenBan = 0x0214 , PID_OpenBanV2_DDME = 0x0215 , PID_OpenBanV2 = 0x0216 , PID_fNIRS = 0x021E ,
  PID_StimPlux = 0x0301 , PID_MuscleBan = 0x0502 , PID_BITalino = 0x0601 , PID_BITalinoRev = 0x0602 ,
  PID_scoliosis = 0x0701 , PID_MuscleBanWearable = 0x0801 , PID_CardioBanWearable = 0x0802 , PID_RespiBanWearable = 0x0803
}
 Product ID enumeration. More...
 

Public Member Functions

virtual void onFoundDevice (const char *path, const char *description)
 
DevInfos findDevicesWithCallback (void)
 
 BaseDev (const String &path)
 Connects to a PLUX device.
 
virtual ~BaseDev (void)
 Disconnects from the device.
 
Properties getProperties (void)
 Returns the device properties.
 
void setParameter (int port, int index, const void *data, int dataLen)
 Sets a system or sensor parameter value.
 
float getBattery (void)
 Returns the remaining battery charge as a percentage of full capacity.
 
void setTimeout (int timeout=-1)
 Sets the receiving timeout value for loop().
 
void loop (void)
 Runs the device message loop.
 
void interrupt (void *param=NULL)
 Sends an interrupt signal to loop().
 
virtual bool onEvent (const Event &evt)
 Event callback.
 
virtual bool onTimeout (void)
 Timeout callback.
 
virtual bool onInterrupt (void *param)
 Interrupt signal callback.
 

Static Public Member Functions

static DevInfos findDevices (const String &domain="")
 Finds PLUX devices within the given domain.
 

Detailed Description

Base class for all PLUX devices.

This class provides the basic functionality common to all PLUX devices. A BaseDev device can be instantiated if a specific device functionality is not required. A BaseDev instance can be promoted afterwards to a derived class instance, based on device properties. This promotion is done by passing the BaseDev instance to the constructor of the derived class.

Alternatively, a derived class can be directly instantiated from the path string if a specific device functionality is required.

It is not possible to demote a derived class instance to a BaseDev instance.

Member Enumeration Documentation

◆ ProductId

Product ID enumeration.

Enumerator
PID_BioPlux 

BioPlux device (PID: 1.01)

PID_BiosignalsPlux 

biosignalsplux device (PID: 2.01)

PID_BiosignalsPluxPRO 

biosignalsplux PRO+ device (PID: 2.05)

PID_MotionPlux 

Motionplux (PID: 2.10)

PID_OpenBan 

OpenBan device (PID: 2.20)

PID_OpenBanV2_DDME 

OpenBan v2 device - DDME (PID: 2.21)

PID_OpenBanV2 

OpenBan v2 device (PID: 2.22)

PID_fNIRS 

fNIRS device (PID: 2.30)

PID_StimPlux 

StimPlux device (PID: 3.01)

PID_MuscleBan 

MuscleBan device (PID: 5.02)

PID_BITalino 

Original BITalino device (PID: 6.01)

PID_BITalinoRev 

BITalino (r)evolution device (PID: 6.02)

PID_scoliosis 

EastCoast Scoliosis (PID: 7.01)

PID_MuscleBanWearable 

MuscleBan device v2 - Wearable version with SD card (PID: 8.01)

PID_CardioBanWearable 

CardioBan device - Wearable version with SD card (PID: 8.02)

PID_RespiBanWearable 

RespiBan device - Wearable version with SD card (PID: 8.03)

Constructor & Destructor Documentation

◆ BaseDev()

Plux::BaseDev::BaseDev ( const String path)

Connects to a PLUX device.

Parameters
pathPath to the PLUX device. It can have one of the following formats:
Format Meaning Supported platforms
xx:xx:xx:xx:xx:xx Classic Bluetooth MAC address All platforms
BTHxx:xx:xx:xx:xx:xx Classic Bluetooth MAC address All platforms
BLExx:xx:xx:xx:xx:xx Bluetooth Low Energy MAC address Windows
COMn COM serial/virtual port Windows
/dev/... Serial device Mac OS and Linux
USB or USBn USB adapter connection Windows

◆ ~BaseDev()

virtual Plux::BaseDev::~BaseDev ( void  )
virtual

Disconnects from the device.

If the device is in real-time acquisition (through SignalsDev.start()), it is automatically stopped.

Member Function Documentation

◆ findDevices()

static DevInfos Plux::BaseDev::findDevices ( const String domain = "")
static

Finds PLUX devices within the given domain.

Parameters
domainDomain of search (optional). It can be "BTH" for a Classic Bluetooth search, "BLE" for a Bluetooth Low Energy search, or "USB" for an USB search. If it is not given (or if it is an empty string), a search is attempted in all domains.

◆ getProperties()

Properties Plux::BaseDev::getProperties ( void  )

Returns the device properties.

The device properties map String keywords to Variant values. The currently defined keywords are:

Keyword Meaning
description Device description string
fwVersion Device firmware version
hwVersion Device hardware version (not present in old devices)
memorySize Device internal memory size in kBytes (only on MemoryDev instances)
(zero if internal memory is not available)
path Device path string as passed to constructor
productID Device product identifier (see BaseDev::ProductId)
uid Device unique identifier string

The fwVersion, hwVersion and productID properties are composed of two numbers (the major and minor numbers). These properties and are encoded as 2-byte integers where the higher byte is the major number and the lower byte is the minor number.

◆ setParameter()

void Plux::BaseDev::setParameter ( int  port,
int  index,
const void *  data,
int  dataLen 
)

Sets a system or sensor parameter value.

Parameters
portSensor port number for a sensor parameter, or zero for a system parameter.
indexIndex of the parameter to set within the sensor or system.
dataAddress of the data block to assign to the parameter
dataLenSize of the data block in bytes.
Remarks
The following parameters are currently supported on biosignalplux devices with firmware v3.7:
Port Index System / Sensor # of bytes Description Default value
0 0 System 1 Idle connection timeout in 32-second units 28 (~15 minutes)
9 3 SpO2/fNIRS sensor on ground port 2 LED current setting for red (1st byte) and IR (2nd byte) Read from redDefCurrent and irDefCurrent sensor characteristics
10 2 Digital output on digital port 1 Byte value 0: output low; value 1: output high; another value: ignored 0 (output low)

◆ getBattery()

float Plux::BaseDev::getBattery ( void  )

Returns the remaining battery charge as a percentage of full capacity.

The returned value is -1 if the device is charging.

◆ setTimeout()

void Plux::BaseDev::setTimeout ( int  timeout = -1)

Sets the receiving timeout value for loop().

Parameters
timeoutTimeout value in milliseconds (optional). If timeout is 0, an immediate timeout condition occurs in loop() if there are no pending messages from device to dispatch. If timeout is not given or if it is -1, a timeout condition never occurs.
See also
onTimeout()

◆ loop()

void Plux::BaseDev::loop ( void  )

Runs the device message loop.

The message loop receives and dispatches the messages from the device to the callbacks. This method returns when a callback returns true.

Remarks
This method cannot be called from a callback.

◆ interrupt()

void Plux::BaseDev::interrupt ( void *  param = NULL)

Sends an interrupt signal to loop().

This method can be called from a thread while loop() is running on another thread. The onInterrupt() callback will be called from loop() (in the context of its thread).

Parameters
paramAn optional parameter to be passed to onInterrupt() callback.
Remarks
This method cannot be called from a callback, and it cannot be called if loop() is not running in another thread.

◆ onEvent()

virtual bool Plux::BaseDev::onEvent ( const Event evt)
inlinevirtual

Event callback.

This callback is called by message loop when an event is received from the device. In order to receive device events, an application must derive BaseDev class (or any of its derived classes) to a new class and override this method in the new class.

Parameters
evtReceived event, which can be a EvtDigInUpdate, EvtDisconnect, EvtSchedChange or EvtSync object.
Returns
Return true to exit message loop or false otherwise. Default callback returns false.

◆ onTimeout()

virtual bool Plux::BaseDev::onTimeout ( void  )
inlinevirtual

Timeout callback.

This callback is called by message loop when a timeout condition occurred. In order to receive timeout conditions, an application must derive BaseDev class (or any of its derived classes) to a new class and override this method in the new class.

Returns
Return true to exit message loop or false otherwise. Default callback returns false.
See also
setTimeout()

◆ onInterrupt()

virtual bool Plux::BaseDev::onInterrupt ( void *  param)
inlinevirtual

Interrupt signal callback.

This callback is called by message loop after interrupt() is called from another thread. In order to receive interrupt signals, an application must derive BaseDev class (or any of its derived classes) to a new class and override this method in the new class.

Parameters
paramOptional parameter passed to interrupt() (or NULL if no parameter was given).
Returns
Return true to exit message loop or false otherwise. Default callback returns false.

The documentation for this class was generated from the following file: