Loading...
Searching...
No Matches
linkedChannels.py

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.

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.
1"""! @example linkedChannels.py
2 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.
3 AisInstrumentHandler::setLinkedChannels MUST be called before each experiment that uses paralleled channels.
4 Once linked, these channels must be controlled by ONLY the master channel, which is returned by the AIsInstrumentHandler::setLinkedChannels function.
5
6 @note This feature is only available on Cycler models.
7"""
8import sys
9from PySide6.QtWidgets import QApplication
10from SquidstatPyLibrary import AisDeviceTracker, AisInstrumentHandler, AisErrorCode, AisConstantCurrentElement, AisExperiment
11
12# Define relavant device information, for easy access
13COMPORT = "COM1"
14
15app = QApplication()
16
18
19# Build an experiment
20ccElement = AisConstantCurrentElement(10, 1, 30)
21experiment = AisExperiment()
22success = experiment.appendElement(ccElement)
23
24if not success:
25 print("Error adding element to experiment")
26 app.quit()
27
28def connectSignals(handler):
29 handler.activeDCDataReady.connect(lambda channel, data: print(f"Timestamp: {data.timestamp} Current: {data.current} Voltage: {data.workingElectrodeVoltage} CE Voltage : {data.counterElectrodeVoltage}"))
30 handler.deviceError.connect(lambda channel, error: print(f"Device Error: {error}"))
31 handler.experimentStopped.connect(lambda channel, reason: (print(f"Experiment Stopped Signal {channel}, {reason}"), app.quit()))
32
33def startExperiment(deviceName):
34 handler = tracker.getInstrumentHandler(deviceName)
35
36 # Here we want to link channels 0 and 1 together, so we pass in a vector of the channels to link
37 # It will return which of the channels is the master channel, this should be used to control the experiment
38 masterChannel = handler.setLinkedChannels([ 0, 1 ])
39
40 connectSignals(handler)
41
42 error = handler.uploadExperimentToChannel(masterChannel, experiment)
43 if error.value() != AisErrorCode.Success:
44 print(error.message())
45 app.quit()
46
47 # Start the previously uploaded experiment on the master channel
48 error = handler.startUploadedExperiment(masterChannel)
49 if error.value() != AisErrorCode.Success:
50 print(error.message())
51 app.quit()
52
53
54tracker.newDeviceConnected.connect(startExperiment)
55tracker.deviceDisconnected.connect(lambda deviceName: print(f"Device Disconnected: {deviceName}"))
56
57error = tracker.connectToDeviceOnComPort(COMPORT)
58if error.value() != AisErrorCode.Success:
59 print(error.message())
60 sys.exit()
61# Calling sys.exit(app.exec()) will keep the program running until the application is exited
62sys.exit(app.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.
this class is used to create custom experiments. A custom experiment contains one or more elements....
Definition AisExperiment.h:22