trigger and counter pvs added

This commit is contained in:
2024-09-25 10:54:27 +02:00
parent 297b62311a
commit 9dd9f096ec
3 changed files with 58 additions and 33 deletions

View File

@@ -51,6 +51,7 @@ class AnalysisProcedure(QObject):
self.check_status_list = self.parent.check_status_list
self.trigger_progressbar = self.parent.trigger_progressbar
self.daq_timeout = 10
self.daq_counter = 0
self.logging = self.parent.logging
self.logger = self.logging.getLogger(__name__)
self.logger.debug("Logging activated in analysis procedure")
@@ -99,8 +100,7 @@ class AnalysisProcedure(QObject):
mat_logger = logging.getLogger('matplotlib')
mat_logger.setLevel(logging.ERROR)
#self.trigger_progressbar.emit(70)
@Slot()
def receive_abort(self):
@@ -325,7 +325,13 @@ class AnalysisProcedure(QObject):
self.check_status_list(_pymodule, "getScalarList",
pv_list, status_list, utils.line_no())
pv_daq_counter = self.pv_dict['daqCounter']
#self.cafe.monitor(pv_daq_counter)
self.daq_counter = self.cafe.getCache(pv_daq_counter)
if self.daq_counter is None:
stat = self.cafe.getStatus(pv_daq_counter)
self.check_status(_pymodule, "getCache", pv_daq_counter, stat,
utils.line_no())
#Put values in dictionary for inspection
for i, (dict_key) in enumerate(self.pv_value_dict.keys()):
self.pv_value_dict[dict_key] = value_list[i]
@@ -335,6 +341,8 @@ class AnalysisProcedure(QObject):
print ("No of turns", self.pv_value_dict['nturns'])
return ambient_data
@@ -342,10 +350,10 @@ class AnalysisProcedure(QObject):
def extract_peak_data(self):
y1_peaks_pre = signal.find_peaks(self.y1_sample, height=0.005)
y1_peaks_avg = np.average(y1_peaks_pre[1]['peak_heights'])
y1_height = y1_peaks_avg * 0.666667
y1_height = y1_peaks_avg * 0.726667
y2_peaks_pre = signal.find_peaks(self.y2_sample, height=0.005)
y2_peaks_avg = np.average(y2_peaks_pre[1]['peak_heights'])
y2_height = y2_peaks_avg * 0.666667
y2_height = y2_peaks_avg * 0.566667
print("AVG = ", y1_height, y2_height, flush=True)
y1_peaks = signal.find_peaks(self.y1_sample, height=y1_height)
@@ -393,32 +401,41 @@ class AnalysisProcedure(QObject):
if not self.simulation:
#start DAQ
#Set
pv_daq_start = self.pv_dict['daqStart']
pv_daq_state = self.pv_dict['daqState']
pv_daq_trigger = self.pv_dict['daqTrigger']
pv_daq_counter = self.pv_dict['daqCounter']
pv_wf_entry = self.pv_dict['wfEntry']
pv_wf_exit = self.pv_dict['wfExit']
pv_wf = [pv_wf_entry, pv_wf_exit]
self.daq_counter = self.cafe.getCache(pv_daq_counter)
print("original cnt", self.daq_counter, flush=True)
stat = self.cafe.set(pv_daq_start, 1)
self.check_status(_pymodule, "set", pv_daq_start, stat,
stat = self.cafe.set(pv_daq_trigger, 24)
self.check_status(_pymodule, "set", pv_daq_trigger, stat,
utils.line_no())
time.sleep(0.2)
stat = self.cafe.set(pv_daq_trigger, 0)
self.check_status(_pymodule, "set", pv_daq_trigger, stat,
utils.line_no())
#Monitor DAQ State
start = time.time()
finished = False
icount = 0
value = 0
while (time.time() - start) < self.daq_timeout:
if self.abort:
self.aborting(utils.line_no())
return None
value = self.cafe.getCache(pv_daq_state)
value = self.cafe.getCache(pv_daq_counter)
print("present cnt", value, flush=True)
if value is None:
stat = self.cafe.getStatus(pv_daq_state)
self.check_status(_pymodule, "getCache", pv_daq_state, stat,
stat = self.cafe.getStatus(pv_daq_counter)
self.check_status(_pymodule, "getCache", pv_daq_counter, stat,
utils.line_no())
elif value == "DONE":
elif value == (self.daq_counter+1):
finished = True
break
time.sleep(1.0)
@@ -434,22 +451,28 @@ class AnalysisProcedure(QObject):
MsgSeverity.ERROR.name, _pymodule, utils.line_no(),
mess, {})
return None
#Read WF from EPICS and fill sample y1_sample, y2_sample
(self.y1_sample, self.y2_sample), status, status_list = self.cafe.getCompoundList(
pv_wf, cacheFlag=True)
(self.y1_sample, self.y2_sample), status, status_list = \
self.cafe.getCompoundList(pv_wf, cacheFlag=False)
if status != self.cyca.ICAFE_NORMAL:
self.check_status_list(_pymodule, "getCompoundListCache",
pv_wf, status_list, utils.line_no())
self.check_status_list(_pymodule, "getCompoundList",
pv_wf, status_list, utils.line_no())
return None
series = pd.Series(self.y1_sample)
self.y1_sample = (series * (-1)).tolist()
print("y1 sample length ", len(self.y1_sample))
print("y2 sample length ", len(self.y2_sample), flush=True)
#series = pd.Series(self.y1_sample)
#self.y1_sample = (series * (-1)).tolist()
self.t_sample = [None] * len(self.y1_sample)
self.t_sample[0] = 0
t_inc = 0
for i in range(1, len(self.y1_sample)):
self.t_sample[i] += self.t_stepsize
t_inc += self.t_stepsize
self.t_sample[i] = t_inc
else:
self.trigger_progressbar.emit(20)

View File

@@ -106,8 +106,8 @@ class AppGui(QWidget):
group_box.setObjectName(obj_name)
vbox = QGridLayout()
pv_daq = []
pv_daq.append(self.settings.data['PV'][accel]['daqStart'])
pv_daq.append(self.settings.data['PV'][accel]['daqState'])
pv_daq.append(self.settings.data['PV'][accel]['daqTrigger'])
pv_daq.append(self.settings.data['PV'][accel]['daqCounter'])
self.cafe.openPrepare()
self.cafe.open(pv_daq)
@@ -115,8 +115,10 @@ class AppGui(QWidget):
pv1 = CAQLabel(self, pv_name=pv_daq[0])
pv2 = CAQLabel(self, pv_name=pv_daq[1])
vbox.addWidget(QLabel('Start/Stop Status:'), 0, 0)
vbox.addWidget(QLabel('Acquisition State:'), 1, 0)
pv1.setFixedWidth(40)
pv2.setFixedWidth(40)
vbox.addWidget(QLabel('DAQ Trigger:'), 0, 0)
vbox.addWidget(QLabel('Event Counter:'), 1, 0)
vbox.addWidget(pv1, 0, 1)
vbox.addWidget(pv2, 1, 1)
vbox.setContentsMargins(9, 19, 9, 9)

View File

@@ -15,16 +15,16 @@
},
"header" : ["SHIFT", "INJ2", "IP2", "IW2", "PK1", "PK2", "SINQ", "UCN"],
"PV" : {"Injector": {"nturns": "PV-INJ:NTURNS",
"daqStart": "PV-INJ:DAQ-START",
"daqState": "PV-INJ:DAQ-STATE",
"daqTrigger": "PV-INJ:TRG",
"daqCounter": "PV-INJ:CNT",
"wfEntry": "PV-INJ:WF-ENTRY",
"wfExit": "PV-INJ:WF-EXIT"
},
"Cyclotron": {"nturns": "PV-CYC:NTURNS",
"daqStart": "PV-CYC:DAQ-START",
"daqState": "PV-CYC:DAQ-STATE",
"wfEntry": "PV-CYC:WF-ENTRY",
"wfExit": "PV-CYC:WF-EXIT"
"daqTrigger": "ZTEST-CPSI-TCRING:FW-SIS0DAQ-TRG",
"daqCounter": "ZTEST-CPSI-TCRING:FW-SIS0DAQ-EVENT-CNT",
"wfEntry": "ZTEST-CPSI-TCRING:FW-SIS0DAQ-CH0-AMPLT-WF",
"wfExit": "ZTEST-CPSI-TCRING:FW-SIS1DAQ-CH0-AMPLT-WF"
}
},
"HIPA": ["Injector", "Ring"],
@@ -58,7 +58,7 @@
},
"Expert":{
"debug": {"flag" : 1, "data":{ "widget": "None", "text" : "Debug", "value" : 0}},
"simulation": {"flag" : 1, "data":{ "widget": "None", "text" : "Oscilloscope", "value" : 1}}
"simulation": {"flag" : 1, "data":{ "widget": "None", "text" : "Oscilloscope", "value" : 0}}
},
"GUI": {
"resultsTabTitle" : "Plots",