1"""! @example advancedExperiment.py """
2
3import sys
4from PySide6.QtWidgets import QApplication
5from SquidstatPyLibrary import AisDeviceTracker, AisExperiment, AisInstrumentHandler, AisErrorCode, AisOpenCircuitElement, AisConstantPotElement, AisConstantCurrentElement, AisEISGalvanostaticElement
6
7
8COMPORT = "COM1"
9CHANNEL = 0
10INSTRUMENT_NAME = "Plus2000"
11
12app = QApplication()
13
15
16success = True
17
19
20
22success &= customExperiment.appendElement(ocpElement)
23
26voltage = 0
27for i in range(0, 4):
29 success &= customExperiment.appendElement(cvElement, 1)
30 voltage = voltage + 0.1
31
35
38
39success &= eisSubExperiment.appendElement(galvEISElement, 1)
40success &= eisSubExperiment.appendElement(ocpElement2, 1)
41
42success &= customExperiment.appendSubExperiment(eisSubExperiment, 3)
43
47success &= customExperiment.appendElement(ccElement, 2)
48
49if not success:
50 print("Error building experiment")
51 sys.exit()
52
53
54
55def connectSignals(handler):
56 handler.activeDCDataReady.connect(lambda channel, data: print(f"Timestamp: {data.timestamp} Current: {data.current} Voltage: {data.workingElectrodeVoltage} CE Voltage : {data.counterElectrodeVoltage}"))
57 handler.activeACDataReady.connect(lambda channel, data: print(f"Timestamp: {data.timestamp} Frequency: {data.frequency} Absolute Impedance: {data.absoluteImpedance}"))
58 handler.experimentNewElementStarting.connect(lambda channel, info: print(f"New element starting: {info.stepName}"))
59 handler.experimentStopped.connect(lambda channel, reason: (print(f"Experiment Stopped Signal {channel}, {reason}"), app.quit()))
60 handler.deviceError.connect(lambda channel, error: print(f"Device Error: {error}"))
61
62
63def startExperiment():
64 handler = tracker.getInstrumentHandler(INSTRUMENT_NAME)
65
66 connectSignals(handler)
67
68 error = handler.uploadExperimentToChannel(CHANNEL, customExperiment)
69 if error.value() != AisErrorCode.Success:
70 print(error.message())
71 app.quit()
72
73 error = handler.startUploadedExperiment(CHANNEL)
74 if error.value() != AisErrorCode.Success:
75 print(error.message())
76 app.quit()
77
78tracker.newDeviceConnected.connect(startExperiment)
79
80error = tracker.connectToDeviceOnComPort(COMPORT)
81if error.value() != AisErrorCode.Success:
82 print(error.message())
83 sys.exit()
84
85
86sys.exit(app.exec())
an experiment that simulates a constant current flow with more advance options for stopping the exper...
Definition AisConstantCurrentElement.h:18
an experiment that simulates a constant applied voltage.
Definition AisConstantPotElement.h:18
static AisDeviceTracker * Instance()
get the instance of the device tracker.
This experiment records the complex impedance of the experimental cell in galvanostatic mode,...
Definition AisEISGalvanostaticElement.h:23
this class is used to create custom experiments. A custom experiment contains one or more elements....
Definition AisExperiment.h:22
This experiment observes the open circuit potential of the working electrode for a specific period of...
Definition AisOpenCircuitElement.h:18