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

Base class for PLUX signal-acquiring devices with internal memory. More...

#include <plux.h>

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

Public Member Functions

 MemoryDev (const String &path)
 Connects to a PLUX device.
 
 MemoryDev (BaseDev &baseDev)
 Promotes a BaseDev instance to MemoryDev.
 
void setTime (time_t t=0)
 Sets the device real-time clock.
 
time_t getTime (void)
 Returns the device current real-time clock.
 
int getSchedules (Schedules &schs)
 Returns all session schedules stored on the device.
 
void addSchedule (const Schedule &sch)
 Adds a session schedule to the device.
 
void deleteSchedule (time_t startTime)
 Deletes a session schedule from the device.
 
void deleteAllSchedules (void)
 Deletes all session schedules from the device.
 
void stopSessionAcq (void)
 Stops an internal acquisition session.
 
void getSessions (Sessions &sessions)
 Returns the headers of all sessions stored on the device.
 
void replaySession (time_t startTime, int iniFrame=0)
 Replays a session stored on the device.
 
void deleteAllSessions (void)
 Deletes all sessions stored on the device.
 
int getMemoryUsed (void)
 Returns the amount of memory used by all sessions stored on the device in kBytes.
 
virtual bool onSessionRawFrame (int nSeq, const int data[])
 Raw frames callback for stored sessions replay.
 
virtual bool onSessionEvent (const Event &evt)
 Event callback for stored sessions replay.
 
- Public Member Functions inherited from Plux::SignalsDev
 SignalsDev (const String &path)
 Connects to a PLUX device.
 
 SignalsDev (BaseDev &baseDev)
 Promotes a BaseDev instance to SignalsDev.
 
void getSensors (Sensors &sensors)
 Returns information about attached sensors and internal sensors.
 
void start (float freq, int portMask, int nBits)
 Starts a real-time acquisition session.
 
void start (float freq, const Ints &ports, int nBits)
 Starts a real-time acquisition session.
 
void start (float baseFreq, const Sources &sources)
 Starts a real-time acquisition session.
 
void stop (void)
 Stops a real-time acquisition session.
 
int getNumChannels (void)
 Returns the total number of acquisition channels.
 
void setDOut (bool state)
 Sets the digital output state.
 
virtual bool onRawFrame (int nSeq, const int data[])
 Raw frames callback.
 
- Public Member Functions inherited from Plux::BaseDev
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.
 

Additional Inherited Members

- Public Types inherited from Plux::BaseDev
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...
 
- Static Public Member Functions inherited from Plux::BaseDev
static DevInfos findDevices (const String &domain="")
 Finds PLUX devices within the given domain.
 

Detailed Description

Base class for PLUX signal-acquiring devices with internal memory.

Constructor & Destructor Documentation

◆ MemoryDev() [1/2]

Plux::MemoryDev::MemoryDev ( const String path)

Connects to a PLUX device.

Parameters
pathPath to the PLUX device. It has the same meaning as in BaseDev::BaseDev().

◆ MemoryDev() [2/2]

Plux::MemoryDev::MemoryDev ( BaseDev baseDev)

Promotes a BaseDev instance to MemoryDev.

Parameters
baseDevInstance to be promoted. If promotion is successful, baseDev is no longer valid.

Member Function Documentation

◆ setTime()

void Plux::MemoryDev::setTime ( time_t  t = 0)

Sets the device real-time clock.

Parameters
tTime to set on the device (optional). If this parameter is not given, current host time is used.

◆ getSchedules()

int Plux::MemoryDev::getSchedules ( Schedules schs)

Returns all session schedules stored on the device.

The returned schedules can refer to a running session (a running schedule, at most one such schedule) or to a session to run in the future. The schedules were previously added by calling addSchedule() or start().

Parameters
schsReference to a Schedules object to be filled by this method.
Returns
Index to the running schedule in the returned vector, starting at 1; if zero, no schedule is running.
Remarks
On current devices firmware, only one schedule can be stored.

◆ addSchedule()

void Plux::MemoryDev::addSchedule ( const Schedule sch)

Adds a session schedule to the device.

An internal acquisition session (i.e., an acquisition to internal memory) will start when the schedule start time or condition is met.

Parameters
schSchedule to add.
Remarks
On current devices firmware, only one schedule can be stored.

◆ deleteSchedule()

void Plux::MemoryDev::deleteSchedule ( time_t  startTime)

Deletes a session schedule from the device.

Parameters
startTimeSchedule::startTime attribute value of the schedule to delete.
Remarks
A running schedule cannot be deleted.

◆ deleteAllSchedules()

void Plux::MemoryDev::deleteAllSchedules ( void  )

Deletes all session schedules from the device.

Remarks
A running schedule cannot be deleted, so this method cannot be called while the device is acquiring.

◆ stopSessionAcq()

void Plux::MemoryDev::stopSessionAcq ( void  )

Stops an internal acquisition session.

Remarks
Call stop() to stop a real-time acquisition.

◆ getSessions()

void Plux::MemoryDev::getSessions ( Sessions sessions)

Returns the headers of all sessions stored on the device.

Parameters
sessionsReference to a Sessions object to be filled by this method.
Remarks
This method cannot be called while the device is acquiring.

◆ replaySession()

void Plux::MemoryDev::replaySession ( time_t  startTime,
int  iniFrame = 0 
)

Replays a session stored on the device.

While a session is being replayed, this method runs a message loop which replaces loop(). The message loop receives and dispatches real-time messages and stored session data to the callbacks. When a callback returns true, the session replay ends and this method returns. The method returns if the end of stored session was reached.

Parameters
startTimeSession::startTime attribute value (as returned by getSessions()) of the session to replay.
iniFrameFrame sequence number from which the session starts to be replayed (if ommited, start from frame 0).
Remarks
This method cannot be called from a callback. This method cannot be called while the device is acquiring.

◆ deleteAllSessions()

void Plux::MemoryDev::deleteAllSessions ( void  )

Deletes all sessions stored on the device.

Remarks
This method cannot be called while the device is acquiring.

◆ getMemoryUsed()

int Plux::MemoryDev::getMemoryUsed ( void  )

Returns the amount of memory used by all sessions stored on the device in kBytes.

Remarks
This method cannot be called while the device is acquiring.
See also
memorySize property in getProperties().

◆ onSessionRawFrame()

virtual bool Plux::MemoryDev::onSessionRawFrame ( int  nSeq,
const int  data[] 
)
inlinevirtual

Raw frames callback for stored sessions replay.

This callback is called by replaySession() for every frame to be replayed from the stored session. In order to receive data frames, an application must derive MemoryDev class (or any of its derived classes) to a new class and override this method in the new class.

This callback parameters are equivalent to onRawFrame() callback parameters.

Returns
Return true to exit replaySession() or false otherwise. Default callback returns false.

◆ onSessionEvent()

virtual bool Plux::MemoryDev::onSessionEvent ( const Event evt)
inlinevirtual

Event callback for stored sessions replay.

This callback is called by replaySession() for every event to be replayed from the stored session. In order to receive device events, an application must derive MemoryDev class (or any of its derived classes) to a new class and override this method in the new class.

Parameters
evtReplayed event, which can be a EvtDigInUpdate or EvtSync object.
Returns
Return true to exit replaySession() or false otherwise. Default callback returns false.

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