Loading...
Searching...
No Matches
linkedChannels.cpp

This example will show you how linked channels can be used to combine the multiple channels on a device, in order to amplify the output for a single experiment. AisInstrumentHandler::setLinkedChannels MUST be called before each experiment that uses paralleled channels. Once linked, these channels must be controlled by ONLY the master channel, which is returned by the AIsInstrumentHandler::setLinkedChannels function.

Note
This feature is only available on Cycler models.
#include "AisDeviceTracker.h"
#include "AisExperiment.h"
#include "AisInstrumentHandler.h"
#include "experiments/builder_elements/AisConstantCurrentElement.h"
#include <QCoreApplication>
#include <QDebug>
// Define relevant device information, for easy access
#define COMPORT "COM1"
int main()
{
char** test = nullptr;
int args;
QCoreApplication a(args, test);
auto tracker = AisDeviceTracker::Instance();
// Create an experiment
AisConstantCurrentElement ccElement(10, 1, 30);
auto customExperiment = std::make_shared<AisExperiment>();
customExperiment->appendElement(ccElement, 1);
auto connectSignals = [=](const AisInstrumentHandler& handler) {
QObject::connect(&handler, &AisInstrumentHandler::activeDCDataReady, [=](uint8_t channel, const AisDCData& data) {
qDebug() << "Timestamp: " << data.timestamp << " Current: " << data.current << " Voltage: " << data.workingElectrodeVoltage << " CE Voltage : " << data.counterElectrodeVoltage;
});
QObject::connect(&handler, &AisInstrumentHandler::deviceError, [=](uint8_t channel, const QString& error) {
qDebug() << "Device Error: " << error;
});
};
QObject::connect(tracker, &AisDeviceTracker::newDeviceConnected, [=](const QString& deviceName) {
qDebug() << "New Device Connected: " << deviceName;
auto& handler = tracker->getInstrumentHandler(deviceName);
// Here we want to link channels 0 and 1 together, so we pass in a vector of the channels to link
// It will return which of the channels is the master channel, this should be used to control the experiment
int8_t masterChannel = handler.setLinkedChannels({ 0, 1 });
connectSignals(handler);
AisErrorCode error = handler.uploadExperimentToChannel(masterChannel, customExperiment);
if (error) {
qDebug() << error.message();
}
// Start the previously uploaded experiment on the master channel
error = handler.startUploadedExperiment(masterChannel);
if (error) {
qDebug() << error.message();
return 0;
}
});
AisErrorCode error = tracker->connectToDeviceOnComPort(COMPORT);
if (error != error.Success) {
qDebug() << error.message();
return 0;
}
return a.exec();
}
an experiment that simulates a constant current flow with more advance options for stopping the exper...
Definition AisConstantCurrentElement.h:18
static AisDeviceTracker * Instance()
get the instance of the device tracker.
void newDeviceConnected(const QString &deviceName)
a signal to be emitted whenever a new connection has been successfully established with a device.
This class contains the possible error codes returned to the user when working with the API....
Definition AisErrorCode.h:18
this class provides control of the device including starting, pausing, resuming and stopping an exper...
Definition AisInstrumentHandler.h:27
void deviceError(uint8_t channel, const QString &error)
a signal that is emitted whenever device send any critical error.
void activeDCDataReady(uint8_t channel, const AisDCData &DCData)
a signal that is emitted whenever new DC data for an active experiment are ready.
A structure containing DC data collected from the instrument.
Definition AisDataPoints.h:11