diff --git a/superxas_bec/devices/test_script_cachannel.py b/superxas_bec/devices/test_script_cachannel.py new file mode 100644 index 0000000..77e000e --- /dev/null +++ b/superxas_bec/devices/test_script_cachannel.py @@ -0,0 +1,61 @@ +#!/usr/bin/python +# python script + +import time + +from CaChannel import CaChannel, ca + +I0 = CaChannel() +I0.searchw("X10DA-ES1-SAI_01:MEAN") + +Trigger = CaChannel() +Trigger.searchw("X10DA-ES1:SMPL") +TriggerDone = CaChannel() +TriggerDone.searchw("X10DA-ES1:SMPL-DONE") + +XMAPStart = CaChannel() +XMAPStart.searchw("X10DA-SITORO:EraseStart") +XMAPStop = CaChannel() +XMAPStop.searchw("X10DA-SITORO:StopAll") +XMAPAcquiring = CaChannel() +XMAPAcquiring.searchw("X10DA-SITORO:Acquiring") +XMAPICR = CaChannel() +XMAPICR.searchw("X10DA-SITORO:dxp1:InputCountRate") +XMAPOCR = CaChannel() +XMAPOCR.searchw("X10DA-SITORO:dxp1:OutputCountRate") +XMAPROI = CaChannel() +XMAPROI.searchw("X10DA-SITORO:mca1.R0") + + +for i in range(25): + start_time = time.time() + XMAPStart.putw(1) + + f = 0 + while f == 0: + time.sleep(0.05) + f = XMAPAcquiring.getw() + + Trigger.putw(1) + time.sleep(0.2) + + t = 0 + while t == 0: + time.sleep(0.05) + t = TriggerDone.getw() + + XMAPStop.putw(1) + + f = 1 + while f == 1: + time.sleep(0.05) + f = XMAPAcquiring.getw() + + time.sleep(0.1) + + i0 = I0.getw() + icr = XMAPICR.getw() + ocr = XMAPOCR.getw() + roi = XMAPROI.getw() + end_time = time.time() + print(f"time={end_time-start_time:.4f}", i0, icr, ocr, roi) diff --git a/superxas_bec/devices/test_script_pyepics.py b/superxas_bec/devices/test_script_pyepics.py new file mode 100644 index 0000000..095038a --- /dev/null +++ b/superxas_bec/devices/test_script_pyepics.py @@ -0,0 +1,51 @@ +#!/usr/bin/python +# PyEpics version of the script + +import time + +import epics + +# Define PVs +I0 = epics.PV("X10DA-ES1-SAI_01:MEAN") +Trigger = epics.PV("X10DA-ES1:SMPL") +TriggerDone = epics.PV("X10DA-ES1:SMPL-DONE") + +XMAPStart = epics.PV("X10DA-SITORO:EraseStart") +XMAPStop = epics.PV("X10DA-SITORO:StopAll") +XMAPAcquiring = epics.PV("X10DA-SITORO:Acquiring") +XMAPICR = epics.PV("X10DA-SITORO:dxp1:InputCountRate") +XMAPOCR = epics.PV("X10DA-SITORO:dxp1:OutputCountRate") +XMAPROI = epics.PV("X10DA-SITORO:mca1.R0") + +# Wait for connections (optional) +for pv in [I0, Trigger, TriggerDone, XMAPStart, XMAPStop, XMAPAcquiring, XMAPICR, XMAPOCR, XMAPROI]: + pv.wait_for_connection(timeout=2) + +# Measurement loop +for i in range(25): + start_time = time.time() + XMAPStart.put(1, wait=True) + + while XMAPAcquiring.get() == 0: + time.sleep(0.05) + + Trigger.put(1, wait=True) + time.sleep(0.2) + + while TriggerDone.get() == 0: + time.sleep(0.05) + + XMAPStop.put(1, wait=True) + + while XMAPAcquiring.get() == 1: + time.sleep(0.05) + + time.sleep(0.1) + + i0 = I0.get() + icr = XMAPICR.get() + ocr = XMAPOCR.get() + roi = XMAPROI.get() + end_time = time.time() + + print(f"time={end_time - start_time:.4f}", i0, icr, ocr, roi)