1"""! @example pulseData.py """
2
3import sys
4from PySide6.QtWidgets import QApplication
5from SquidstatPyLibrary import AisDeviceTracker
6from SquidstatPyLibrary import AisCompRange
7from SquidstatPyLibrary import AisDCData
8from SquidstatPyLibrary import AisACData
9from SquidstatPyLibrary import AisExperimentNode
10from SquidstatPyLibrary import AisErrorCode
11from SquidstatPyLibrary import AisExperiment
12from SquidstatPyLibrary import AisInstrumentHandler
13from SquidstatPyLibrary import AisCyclicVoltammetryElement
14from SquidstatPyLibrary import AisDiffPulseVoltammetryElement
15from SquidstatPyLibrary import AisDataManipulator
16from SquidstatPyLibrary import AisPulseType
17
18
19write_header = True
20
22
23COMPORT = "COM5"
24CHANNEL = 0
25
26def create_logic(handler):
27 def on_active_dc_data_ready(channel, data):
28
29 global write_header, data_manipulator
30
31
32
33
34 data_manipulator.loadPrimaryData(data)
35
36
37 if data_manipulator.isPulseCompleted():
38
39
40
41 if write_header:
42 print("time, Pulse_current, base_current, diff_current, base_voltage, pulse_voltage")
43 write_header = False
44
45
46 print(f"{data.timestamp}, {data_manipulator.getPulseCurrent()}, {data_manipulator.getBaseCurrent()}, "
47 f"{data_manipulator.getPulseCurrent() - data_manipulator.getBaseCurrent()}, "
48 f"{data_manipulator.getBaseVoltage()}, {data_manipulator.getPulseVoltage()}")
49
50
51 def on_active_ac_data_ready(channel, data):
52 print(f"channel: {channel}, frequency: {data.frequency}, absoluteImpedance: {data.absoluteImpedance}, "
53 f"phaseAngle: {data.phaseAngle}, timestamp: {data.timestamp}")
54
55
56 def on_experiment_new_element_starting(channel, data):
57 print(f"New Node beginning {data.stepName}, step number {data.stepNumber}, step sub: {data.substepNumber}")
58
59
60 def on_experiment_stopped(channel, reason):
61 print(f"Experiment has completed on channel {channel}, {reason}")
62 QApplication.quit()
63
64
65 def on_experiment_paused(channel):
66 print(f"Experiment on channel {channel} has been paused")
67
68
69 def on_experiment_resumed(channel):
70 print(f"Experiment resumed on channel {channel}")
71
72
73 handler.activeDCDataReady.connect(on_active_dc_data_ready)
74
75
76 handler.activeACDataReady.connect(on_active_ac_data_ready)
77
78
79 handler.experimentNewElementStarting.connect(on_experiment_new_element_starting)
80
81
82 handler.experimentStopped.connect(on_experiment_stopped)
83
84
85 handler.experimentPaused.connect(on_experiment_paused)
86 handler.experimentResumed.connect(on_experiment_resumed)
87
88
89def main():
90
91 app = QApplication()
92
93
95
96
97
99
100
101 dpv_element.setStartVoltageVsOCP(False)
102
103
104 dpv_element.setEndVoltageVsOCP(False)
105
106
107
108 dpv_element.setApproxMaxCurrent(0.2)
109
110
112
113
114
115 success = experiment.appendElement(dpv_element, 1)
116 if not success:
117 print("Error building experiment")
118 sys.exit()
119
120
121 data_manipulator.setPulseType(AisPulseType.DifferentialPulse, dpv_element.getPulseWidth(), dpv_element.getPulsePeriod())
122
123
124 def on_new_device_connected(device_name):
125
126
127 handler = tracker.getInstrumentHandler(device_name)
128
129
130 create_logic(handler)
131
132
133 error = handler.uploadExperimentToChannel(CHANNEL, experiment)
134 if error.value() != AisErrorCode.ErrorCode.Success:
135 print(f"Error: {error.message()}")
136 app.quit()
137
138
139 error = handler.startUploadedExperiment(CHANNEL)
140 if error.value() != AisErrorCode.ErrorCode.Success:
141 print(f"Error: {error.message()}")
142 app.quit()
143
144
145 tracker.newDeviceConnected.connect(on_new_device_connected)
146
147
148 tracker.deviceDisconnected.connect(lambda device_name: print(f"{device_name} has been disconnected"))
149
150
151 error = tracker.connectToDeviceOnComPort(COMPORT)
152 if error.value() != AisErrorCode.ErrorCode.Success:
153 print(f"Error: {error.message()}")
154 sys.exit()
155
156
157 sys.exit(app.exec())
158
159
160if __name__ == "__main__":
161 main()
This class offers advanced control over pulse data collection and manipulation. It provides methods t...
Definition AisDataManipulator.h:21
static AisDeviceTracker * Instance()
get the instance of the device tracker.
In this experiment, the working electrode holds at a starting potential during the quiet time....
Definition AisDiffPulseVoltammetryElement.h:26
this class is used to create custom experiments. A custom experiment contains one or more elements....
Definition AisExperiment.h:22