Loading...
Searching...
No Matches
AisDeviceTracker Class Referencefinal

This class is used track device connections to the computer. It also provides instrument handlers specific to each connected device which provide control of the relevant device.

#include <AisDeviceTracker.h>

#include <AisDeviceTracker.h>

Inheritance diagram for AisDeviceTracker:

Signals

void newDeviceConnected (const QString &deviceName)
 a signal to be emitted whenever a new connection has been successfully established with a device.
 
void deviceDisconnected (const QString &deviceName)
 a signal to be emitted whenever a device has been disconnected.
 
void firmwareUpdateNotification (const QString &message)
 a signal which is emitted regularaly during a firmware update, providing information about the progress of the update.
 
void firmwareUpdateFinished (const QString &deviceName, bool success)
 Emitted when a device finishes the firmware update process.
 

Public Member Functions

AisErrorCode connectToDevice (const QString &deviceName)
 Establish a connection with a device connected on a USB port via its name.
 
AisErrorCode connectToDeviceOnComPort (const QString &comPort)
 establish a connection with a device connected on a USB port.
 
const AisInstrumentHandlergetInstrumentHandler (const QString &deviceName) const
 get an instrument handler to control a specific device.
 
const std::list< QString > getConnectedDevices () const
 get a list of all the connected devices.
 
int connectAllPluggedInDevices ()
 connect all devices physically plugged to the computer.
 
AisErrorCode updateFirmwareOnComPort (const QString &comport) const
 update firmware on connected device at USB port.
 
int updateFirmwareOnAllAvailableDevices ()
 request firmware update for all available devices.
 
void saveLogToFile (bool save)
 Allow to collect device error message in file for debugging purpose.
 
void setLogFilePath (const QString &path)
 This will help to change the log file directory.
 
void purgeStaleDevices ()
 Calling this function will remove all disconnected devices from memory. Any pointers and references to these devices will be invalidated.
 

Static Public Member Functions

static AisDeviceTrackerInstance ()
 get the instance of the device tracker.
 

Member Function Documentation

◆ connectAllPluggedInDevices()

int AisDeviceTracker::connectAllPluggedInDevices ( )

This will automatically detect all the communication ports that have devices plugged in and establish a connection with each.

Returns
the number of new devices that have successfully established a connection with the computer. If a device has already been connected before calling this function, it will not be counted in the return value.
Note
emits newDeviceConnected() signal with the device name for each successful connection.

◆ connectToDevice()

AisErrorCode AisDeviceTracker::connectToDevice ( const QString & deviceName)

Move a device handler to the specified thread. All signals from that handler will then be emitted from that thread.

Parameters
deviceNameThe name of the device to connect. (case sensitive)
Return values
AisErrorCode::Successif the device was connected, or is currently active. No AisDeviceTracker::newDeviceConnected signal will be emitted if the device is already connected.
AisErrorCode::DeviceNotFoundif the device was not found on any comport or it is open in another application
Note
This function will briefly open all available Squidstat serial connections and then close them. It may conflict with other applications attempting to initialize Squidstats.
emits newDeviceConnected() signal with the device name if establishing the connection was successful.

◆ connectToDeviceOnComPort()

AisErrorCode AisDeviceTracker::connectToDeviceOnComPort ( const QString & comPort)
Parameters
comPortthe communication port to connect through.
Returns
AisErrorCode::Success if a connection was established with the device through the given communication port. If not successful, possible returned errors are:
Note
emits newDeviceConnected() signal with the device name if establishing the connection was successful.
You need to specify the communication port specific to your computer. For example, on PC, you may find your port number through the 'device manager'. An example would be "COM15".

◆ deviceDisconnected

void AisDeviceTracker::deviceDisconnected ( const QString & deviceName)
signal
Parameters
deviceNamethe name of the newly disconnected device.
Examples
advancedControlFlow.cpp, basicExperiment.cpp, and pulseData.cpp.

◆ firmwareUpdateFinished

void AisDeviceTracker::firmwareUpdateFinished ( const QString & deviceName,
bool success )
signal
Parameters
deviceNameThe name of the device which is finished updating.
successIndicates whether the firmware updated successfully.
Note
If the device is in reset mode when the firmware is updated, the device name will be "Not Available" for all firmware update messaging.

◆ firmwareUpdateNotification

void AisDeviceTracker::firmwareUpdateNotification ( const QString & message)
signal
Parameters
messagea string containing the progress percentage message.
Note
If the device is in reset mode when the firmware is updated, the device name will be "Not Available" for all firmware update messaging.
Examples
firmwareUpdate.cpp.

◆ getConnectedDevices()

const std::list< QString > AisDeviceTracker::getConnectedDevices ( ) const
Returns
a list of all the connected devices.

◆ getInstrumentHandler()

const AisInstrumentHandler & AisDeviceTracker::getInstrumentHandler ( const QString & deviceName) const
Parameters
deviceNamethe name of the connected device to get the instrument handler for (case sensitive).
Returns
The instrument handler that controls the specified device. If the device has not been connected, it will return a stale device.
Note
You may get a list of the connected devices using getConnectedDevices(). Also, whenever a device has been connected by calling connectToDeviceOnComPort(), a signal is emitted with the device name.
Device handlers will become stale if a device disconnects, and you will need to aquire new instances on reconnection.
See also
AisInstrumentHandler
AisdeviceTracker::connectToDeviceOnComPort()
AisdeviceTracker::getConnectedDevices()

◆ Instance()

◆ newDeviceConnected

void AisDeviceTracker::newDeviceConnected ( const QString & deviceName)
signal
Parameters
deviceNamethe name of the newly connected device.
Note
this signal will be emitted for each newly connected device whenever either connectToDeviceOnComPort() or connectAllPluggedInDevices() successfully established connections.
Examples
advancedControlFlow.cpp, advancedExperiment.cpp, basicExperiment.cpp, dataOutput.cpp, linkedChannels.cpp, manualExperiment.cpp, nonblockingExperiment.cpp, and pulseData.cpp.

◆ purgeStaleDevices()

void AisDeviceTracker::purgeStaleDevices ( )
Note
This function should only be called after handling a disconnection event and removing all references to the disconnected device.
This is a temporary patch function to fix memory leaks over long periods of time with many disconnection events. In a future implementation this function will no longer be needed.

◆ saveLogToFile()

void AisDeviceTracker::saveLogToFile ( bool save)
Note
by default it will be true.
Parameters
saveWhen set to 'false,' it will not write logs to the file. When set to 'true,' it will begin writing device error logs to the file.
See also
setLogFilePath

◆ setLogFilePath()

void AisDeviceTracker::setLogFilePath ( const QString & path)
Note
by default it will be Document/Admiral Instrument/API
Parameters
pathSet the path value at which you want to save the log file.
Note
If you set 'false' for 'saveLogToFile,' it will not generate the log file. It is recommended to set it to 'true' or leave the permission as the default setting.
See also
saveLogToFile

◆ updateFirmwareOnAllAvailableDevices()

int AisDeviceTracker::updateFirmwareOnAllAvailableDevices ( )

This will automatically detect devices not currently in use and update firmware if necessary.

Returns
the number of devices that have successfully requested for firmware update. If a device has already been updated firmware before calling this function, it will not be counted in the return value. If any error is generated while requesting firmware update, it will not be counted in the return value.
Note
emits firmwareUpdateNotification() signal will provide notification regarding firmware update of all devices.
You can update firmware when you reset the device physically through reset button.
See also
updateFirmwareOnComPort

◆ updateFirmwareOnComPort()

AisErrorCode AisDeviceTracker::updateFirmwareOnComPort ( const QString & comport) const
Parameters
comportthe communication port to connect through.
Returns
AisErrorCode::Success if firmware update successfully initiated through the given communication port. If not successful, possible returned errors are:
Note
emits firmwareUpdateNotification() signal to provide firmware update progress.
You need to specify the communication port specific to your computer. For example, on PC, you may find your port number through the 'device manager'. An example would be "COM15".

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