Python API
Loading...
Searching...
No Matches
plux.MemoryDev Class Reference

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

Inheritance diagram for plux.MemoryDev:
plux.SignalsDev plux.BaseDev

Public Member Functions

 __init__ (self, path)
 Connects to a PLUX device.
 
 __init__ (self, baseDev)
 Promotes a BaseDev instance to MemoryDev.
 
 setTime (self, time=None)
 Sets the device real-time clock.
 
 getTime (self)
 Returns the device current real-time clock as a datetime.datetime object.
 
 getSchedules (self)
 Returns all session schedules stored on the device.
 
 addSchedule (self, sch)
 Adds a session schedule to the device.
 
 deleteSchedule (self, startTime)
 Deletes a session schedule from the device.
 
 deleteAllSchedules (self)
 Deletes all session schedules from the device.
 
 stopSessionAcq (self)
 Stops an internal acquisition session.
 
 getSessions (self)
 Returns the headers of all sessions stored on the device.
 
 replaySession (self, startTime, iniFrame=0)
 Replays a session stored on the device.
 
 deleteAllSessions (self)
 Deletes all sessions stored on the device.
 
 getMemoryUsed (self)
 Returns the amount of memory used by all sessions stored on the device in kBytes.
 
 onSessionRawFrame (self, nSeq, data)
 Raw frames callback for stored sessions replay.
 
 onSessionEvent (self, event)
 Event callback for stored sessions replay.
 
- Public Member Functions inherited from plux.SignalsDev
 getSensors (self)
 Returns information about attached sensors and internal sensors.
 
 start (self, baseFreq, sources)
 Starts a real-time acquisition session.
 
 start (self, freq, portMask, nBits)
 Starts a real-time acquisition session.
 
 start (self, freq, ports, nBits)
 Starts a real-time acquisition session.
 
 stop (self)
 Stops a real-time acquisition session.
 
 getNumChannels (self)
 Returns the total number of acquisition channels.
 
 setDOut (self, state)
 Sets the digital output state.
 
 onRawFrame (self, nSeq, data)
 Raw frames callback.
 
- Public Member Functions inherited from plux.BaseDev
 getProperties (self)
 Returns the device properties.
 
 setParameter (self, port, index, data)
 Sets a system or sensor parameter value.
 
 getBattery (self)
 Returns a float number with the remaining battery charge as a percentage of full capacity.
 
 setTimeout (self, timeout=-1)
 Sets the receiving timeout value for loop().
 
 loop (self)
 Runs the device message loop.
 
 interrupt (self, param=None)
 Sends an interrupt signal to loop().
 
 onEvent (self, event)
 Event callback.
 
 onTimeout (self)
 Timeout callback.
 
 onInterrupt (self, param)
 Interrupt signal callback.
 
 close ()
 Disconnects from the device.
 

Additional Inherited Members

- Static Public Member Functions inherited from plux.BaseDev
 findDevices (domain='')
 Finds PLUX devices within the given domain.
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __init__() [1/2]

plux.MemoryDev.__init__ (   self,
  path 
)

Connects to a PLUX device.

Parameters
pathA string with the path to the PLUX device. It has the same meaning as in BaseDev.__init__().

Reimplemented from plux.SignalsDev.

◆ __init__() [2/2]

plux.MemoryDev.__init__ (   self,
  baseDev 
)

Promotes a BaseDev instance to MemoryDev.

Parameters
baseDevThe BaseDev instance to be promoted. If promotion is successful, baseDev is no longer valid.

Reimplemented from plux.SignalsDev.

Member Function Documentation

◆ setTime()

plux.MemoryDev.setTime (   self,
  time = None 
)

Sets the device real-time clock.

Parameters
timeAn optional datetime.datetime object with the time to set on device. If this parameter is not given, current host time is used.

◆ getTime()

plux.MemoryDev.getTime (   self)

Returns the device current real-time clock as a datetime.datetime object.

◆ getSchedules()

plux.MemoryDev.getSchedules (   self)

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().

Returns
A tuple of ScheduleEx objects.
Remarks
On current devices firmware, the device cannot store more than one schedule.

◆ addSchedule()

plux.MemoryDev.addSchedule (   self,
  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
schThe schedule do add as a Schedule object.
Remarks
On current devices firmware, the device cannot store more than one schedule.

◆ deleteSchedule()

plux.MemoryDev.deleteSchedule (   self,
  startTime 
)

Deletes a session schedule from the device.

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

◆ deleteAllSchedules()

plux.MemoryDev.deleteAllSchedules (   self)

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()

plux.MemoryDev.stopSessionAcq (   self)

Stops an internal acquisition session.

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

◆ getSessions()

plux.MemoryDev.getSessions (   self)

Returns the headers of all sessions stored on the device.

Returns
A tuple of Session objects.
Remarks
This method cannot be called while the device is acquiring.

◆ replaySession()

plux.MemoryDev.replaySession (   self,
  startTime,
  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
startTimeThe Session.startTime attribute value (as returned by getSessions()) of the session to replay.
iniFrameAn optional integer with the frame sequence number from which the session starts to be replayed.
Remarks
This method cannot be called from a callback. This method cannot be called while the device is acquiring.

◆ deleteAllSessions()

plux.MemoryDev.deleteAllSessions (   self)

Deletes all sessions stored on the device.

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

◆ getMemoryUsed()

plux.MemoryDev.getMemoryUsed (   self)

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()

plux.MemoryDev.onSessionRawFrame (   self,
  nSeq,
  data 
)

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()

plux.MemoryDev.onSessionEvent (   self,
  event 
)

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
eventThe replayed event. It can be a Event.DigInUpdate or Event.Sync object.
Returns
Return True to exit replaySession() or False otherwise. Default callback returns False.