Exemplo n.º 1
0
 def startstopCountMCA(self):
     if self.countPushButton.text() == 'Count':
         epics.caput(BYTES2STR(self.medm_P + 'mca1EraseStart'), 1)
         self.countPushButton.setText('Stop')
     else:
         epics.caput(BYTES2STR(self.medm_P + 'Stop'), 1)
         self.countPushButton.setText('Count')
Exemplo n.º 2
0
 def get_mca_manual_calib(self):
     """
     Get the manual calibration number from the MCA_Widget
     """
     self.mca_offset = float(self.offsetLineEdit.text())
     self.mca_linear = float(self.linearLineEdit.text())
     self.mca_quadratic = float(self.quadraticLineEdit.text())
     self.mca_realtime = epics.caget(BYTES2STR(self.medm_P + "mca1.ERTM"))
     self.mca_livetime = epics.caget(BYTES2STR(self.medm_P + "mca1.ELTM"))
Exemplo n.º 3
0
 def onReturn(self):
     if (self.type == float or self.type == int):
         if self.validator.validate(self.text(),
                                    0)[0] == self.validator.Acceptable:
             self.pv.put(BYTES2STR(self.text()))
         else:
             QMessageBox.warning(
                 self, 'Value Error',
                 'Please input floating point numbers only', QMessageBox.Ok)
     else:
         self.pv.put(BYTES2STR(self.text()))
 def onStopUpdate(self):
     self.startUpdate = False
     self.arrayDataUpdated.disconnect(self.start_stop_Update)
     self.startUpdatePushButton.setEnabled(True)
     self.stopUpdatePushButton.setEnabled(False)
     self.setOutputOptions(enabled=True)
     self.detPVLineEdit.setEnabled(True)
     epics.caput(BYTES2STR(self.detPV + "cam1:Acquire"), 0)
     epics.caput(BYTES2STR(self.detPV + "cam1:ArrayCounter"), 0)
     if self.widSeriesExists:
         self.widthCutPlot.parent().close()
     if self.cutSeriesExists:
         self.peakCutPlot.parent().close()
Exemplo n.º 5
0
    def get_mca_epics_calib(self):
        """
        Get the epics calibration numbers and reset the manual calibration numbers accordingly
        """
        self.mca_offset = epics.caget(BYTES2STR(self.medm_P + "mca1.CALO"))
        self.mca_linear = epics.caget(BYTES2STR(self.medm_P + "mca1.CALS"))
        self.mca_quadratic = epics.caget(BYTES2STR(self.medm_P + "mca1.CALQ"))
        self.mca_realtime = epics.caget(BYTES2STR(self.medm_P + "mca1.ERTM"))
        self.mca_livetime = epics.caget(BYTES2STR(self.medm_P + "mca1.ELTM"))

        if not self.overrideMCACalibCheckBox.isChecked():
            self.offsetLineEdit.setText('%.5f' % self.mca_offset)
            self.linearLineEdit.setText('%.5f' % self.mca_linear)
            self.quadraticLineEdit.setText('%.5f' % self.mca_quadratic)
 def init_PVs(self):
     """
     Initialize all the PVs
     :return:
     """
     self.minX_PV = epics.PV(BYTES2STR(self.detPV + "cam1:MinX_RBV"),
                             callback=self.onMinXChanged)
     self.minY_PV = epics.PV(BYTES2STR(self.detPV + "cam1:MinY_RBV"),
                             callback=self.onMinYChanged)
     self.sizeX_PV = epics.PV(BYTES2STR(self.detPV + "cam1:SizeX_RBV"),
                              callback=self.onSizeXChanged)
     self.sizeY_PV = epics.PV(BYTES2STR(self.detPV + "cam1:SizeY_RBV"),
                              callback=self.onSizeYChanged)
     self.data_PV = epics.PV(BYTES2STR(self.detPV + "image1:ArrayData"))
Exemplo n.º 7
0
    def SetPV(self, pvname):
        if self.pv is not None and self.cb_index is not None:
            self.pv.remove_callback(self.cb_index)

        self.pv = epics.PV(BYTES2STR(pvname))
        self.setText(self.pv.get(as_string=True))
        self.cb_index = self.pv.add_callback(self.onPVChange)
Exemplo n.º 8
0
 def readMCA(self):
     self.mca_y = self.mcaPV.value
     self.mca_yerr = np.sqrt(self.mca_y)
     xmca = np.arange(len(self.mca_y))
     if self.overrideMCACalibCheckBox.isChecked():
         self.get_mca_manual_calib()
     else:
         self.get_mca_epics_calib()
     self.energy = epics.caget(BYTES2STR("15IDA:BraggERdbkAO"))
     self.mca_x = self.mca_offset + self.mca_linear * xmca + self.mca_quadratic * xmca**2
     self.mcaPlotWidget.add_data(self.mca_x,
                                 self.mca_y,
                                 yerr=self.mca_yerr,
                                 name='mca1')
     self.xmin = float(self.xminLineEdit.text())
     self.xmax = float(self.xmaxLineEdit.text())
     self.performStats(fname=None)
     keys = [
         'Energy', 'real_time', 'live_time', 'sum', 'sum_err', 'corr_sum',
         'corr_sum_err'
     ]  # self.dlg_data[fullfnames[0]]['meta'].keys()
     stats_data = [[
         self.energy, self.mca_realtime, self.mca_livetime, self.sum,
         self.sum_err, self.corr_sum, self.corr_sum_err
     ]]
     self.updateStatisticsTable(stats_data, keys)
 def onStartUpdate(self):
     self.cutSeriesExists = False
     self.widSeriesExists = False
     epics.caput(BYTES2STR(self.detPV + "cam1:ArrayCounter"), 0)
     epics.caput(BYTES2STR(self.detPV + "cam1:Acquire"), 1)
     epics.camonitor(BYTES2STR(self.detPV + "image1:ArrayCounter_RBV"),
                     callback=self.onArrayDataUpdate)
     self.arrayDataUpdated.connect(self.start_stop_Update)
     self.startUpdate = True
     self.startTime = time.time()
     self.posTimeData = []
     self.widTimeData = []
     self.startUpdatePushButton.setEnabled(False)
     self.stopUpdatePushButton.setEnabled(True)
     self.setOutputOptions(enabled=False)
     self.detPVLineEdit.setEnabled(False)
Exemplo n.º 10
0
 def setPV(self, pvname):
     if self.pv is not None:
         self.currentIndexChanged.disconnect()
     self.pv = epics.PV(BYTES2STR(pvname))
     self.clear()
     self.addItems(self.pv.enum_strs)
     self.setCurrentIndex(self.pv.value)
     self.currentIndexChanged.connect(self.stateChanged)
Exemplo n.º 11
0
 def change_MCA(self):
     """
     Resets the P, D and M values of MCA
     :return:
     """
     self.medm_P = self.medm_P_LineEdit.text()
     self.medm_D = self.medm_D_LineEdit.text()
     self.medm_M = self.medm_M_LineEdit.text()
     self.mcaPV = epics.PV(BYTES2STR(self.medm_P + self.medm_M))
     try:
         self.mcaStatusPV.clear_callbacks()
     except:
         self.mcaStatusPV = epics.PV(
             BYTES2STR(self.medm_P + self.medm_M + '.ACQG'))
     self.monitorIndex = self.mcaStatusPV.add_callback(self.mcaChanging)
     self.mcaUpdating.connect(self.mcaAutoUpdate)
     self.init_pv()
Exemplo n.º 12
0
 def __init__(self, parent=None):
     """
     """
     QWidget.__init__(self, parent)
     loadUi('UI_Forms/Energy_Widget.ui', self)
     self.tabWidget.setTabText(0, 'Xtal Plot')
     self.tabWidget.setTabText(1, 'Mirror Plot')
     self.loadPVs()
     self.init_validation()
     self.xtalMinChanged()
     self.xtalMaxChanged()
     self.mirrorMinChanged()
     self.mirrorMaxChanged()
     self.xtalStepsChanged()
     self.mirrorStepsChanged()
     self.stoppedTracking = False
     self.init_signals()
     self.undulatorStartPV = epics.PV(BYTES2STR("ID15:Start.VAL"))
     self.undulatorStopPV = epics.PV(BYTES2STR("ID15:Start.VAL"))
     self.scaler_15IDC_PV = epics.PV(BYTES2STR("15IDC:scaler1.CNT"))
     self.scaler_15IDD_PV = epics.PV(BYTES2STR("15IDD:vsc:c0.CNT"))
     self.countTime_15IDC_PV = epics.PV(BYTES2STR("15IDC:scaler1.TP"))
     self.countTime_15IDD_PV = epics.PV(BYTES2STR("15IDD:vsc:c0.TP"))
     self.xiaShutter_PV = epics.PV(BYTES2STR("15IDD:2openXIAShutter"))
     self.countTime_15IDC_PV.put(1)
     self.countTime_15IDD_PV.put(1)
     self.getUndulatorOffset()
     self.undulatorChanging = False
     if self.feedbackComboBox.pv.value == 1:
         # self.feedback_enabled=True
         # self.feedback_disable=False
         QMessageBox.warning(
             self, 'Feedback Warning',
             'Please switch off the feedback before start energy tracking',
             QMessageBox.Ok)
Exemplo n.º 13
0
 def getMonoValues(self):
     self.m1 = epics.caget(BYTES2STR("15IDA:m1.REP"))
     self.m2 = epics.caget(BYTES2STR("15IDA:m2.REP"))
     self.m3 = epics.caget(BYTES2STR("15IDA:m3.REP"))
     self.m4 = epics.caget(BYTES2STR("15IDA:m4.REP"))
     self.m5 = epics.caget(BYTES2STR("15IDA:m5.REP"))
     self.m6 = epics.caget(BYTES2STR("15IDA:m6.REP"))
     self.monB = epics.caget(BYTES2STR("15IDB:scaler1.S2"))
Exemplo n.º 14
0
 def colorModeChanged(self):
     if self.startUpdate:
         QtGui.QMessageBox.warning(
             self, "Warning", "Please Stop the updating of the image first",
             QtGui.QMessageBox.Ok)
         self.colorModeComboBox.setCurrentText(self.colorMode)
         return
     else:
         self.colorMode = self.colorModeComboBox.currentText()
         if self.colorMode == 'Greyscale':
             epics.caput(self.detPV + 'cam1:ColorMode', 0)
             epics.caput(self.detPV + 'cam1:BayerConvert', 0)
         else:
             epics.caput(self.detPV + 'cam1:ColorMode', 2)
             epics.caput(self.detPV + 'cam1:BayerConvert', 1)
         epics.caput(BYTES2STR(self.detPV + "cam1:ArrayCounter"), 0)
         epics.caput(BYTES2STR(self.detPV + "cam1:Acquire"), 1)
         time.sleep(0.2)
         epics.caput(BYTES2STR(self.detPV + "cam1:Acquire"), 0)
         epics.caput(BYTES2STR(self.detPV + "cam1:ArrayCounter"), 0)
Exemplo n.º 15
0
    def setPV(self, pvname, prec=5, type=float):
        self.prec = prec
        self.type = type
        if self.pv is not None and self.cb_index is not None:
            self.pvChanging.disconnect()
            self.pv.remove_callback(self.cb_index)

        self.pv = epics.PV(BYTES2STR(pvname))
        self.setText(self.pv.get(as_string=True))
        self.cb_index = self.pv.add_callback(self.onPVChange)
        self.pvChanging.connect(self.updatePV)
Exemplo n.º 16
0
 def setPV(self, pvname, type=float, prec=5):
     if self.pv is not None and self.cb_index is not None:
         self.pv.remove_callback(self.cb_index)
         self.pvChanged.disconnect(self.updatePV)
     self.prec = prec
     self.type = type
     self.pv = epics.PV(BYTES2STR(pvname))
     self.cb_index = self.pv.add_callback(self.onPVChange)
     self.pvChanged.connect(self.updatePV)
     if self.type == float:
         self.validator = QDoubleValidator()
         self.setValidator(self.validator)
     elif self.type == int:
         self.validator = QIntValidator()
         self.setValidator(self.validator)
Exemplo n.º 17
0
 def changeUndulatorEnergy(self):
     print('Changing Undulator')
     self.undulatorChanging=True
     self.undulatorEnergyLineEdit.pv.put(self.energyLineEdit.pv.value+self.undulatorOffset)
     self.startUndulator()
     while epics.caget(BYTES2STR("15IDA:KohzuMoving"))==1:
         QTest.qWait(10)
     print('Undulator Changed')
     self.wait_for_stablization(detector='MonB')
     #print("Undulator change stablized")
     if self.trackXtalCheckBox.isChecked():
         print("Scanning 2nd Xtal...")
         self.scan_xtal()
     if self.trackMirrorCheckBox.isChecked():
         print("Scanning 2nd Mirror...")
         self.scan_mirror()
     self.undulatorChanging=False
Exemplo n.º 18
0
 def closeEvent(self, evt):
     if self.adReader.connected:
         epics.caput(BYTES2STR(self.detPV + "cam1:Acquire"), 0)
         epics.caput(BYTES2STR(self.detPV + "cam1:ArrayCounter"), 0)
     sys.exit()
Exemplo n.º 19
0
 def stateChanged(self, index):
     text = self.itemText(index)
     self.pv.put(BYTES2STR(text))
     self.setCurrentIndex(index)
Exemplo n.º 20
0
 def horizontal_feedback_OFF(self):
     epics.caput(BYTES2STR("15IDA:pid_mono_2.FBON"), 0, wait=True)
Exemplo n.º 21
0
 def onReturn(self):
     self.pv.put(BYTES2STR(self.text()))
Exemplo n.º 22
0
 def vertical_feedback_OFF(self):
     epics.caput(BYTES2STR("15IDA:pid_mirror.FBON"), 0, wait=True)
Exemplo n.º 23
0
 def auto_count_off(self):
     epics.caput(BYTES2STR("15IDC:scaler1.CONT"),
                 0)  # setting autocount off for 15IDC scaler
     epics.caput(BYTES2STR("15IDD:vsc:c0.CONT"),
                 0)  # setting autocount off for 15IDD scaler
Exemplo n.º 24
0
import epics
from epics.utils import BYTES2STR
import sys
import pylab as pl

win = float(sys.argv[1])
start = float(sys.argv[2])
stop = float(sys.argv[3])
count_time = float(sys.argv[4])
steps = float(sys.argv[5])

llpv = epics.PV(BYTES2STR('15IDC:cyberAmp2k0ScaLL.VAL'))
llvpRBK = epics.PV(BYTES2STR('15IDC:cyberAmp2k0ScaLLRbv.VAL'))
ulpv = epics.PV(BYTES2STR('15IDC:cyberAmp2k0ScaUL.VAL'))
IDC15_scaler_start = epics.PV(BYTES2STR('15IDC:scaler1.CNT'))
IDC15_scaler_mode = epics.PV(BYTES2STR('15IDC:scaler1.CONT'))
IDC15_scaler_count_time = epics.PV(BYTES2STR('15IDC:scaler1.TP'))
IDC15_scaler_mode.put(0)  # for one shot
yap_pv = epics.PV(BYTES2STR('15IDC:scaler1.S8'))

llpv_ip = llpv.value
ulpv_ip = ulpv.value
data = []
positions = pl.linspace(start, stop, steps)
i = 0
for pos in positions:
    llpv.put(str(pos), wait=True)
    llpv.put(str(pos) + win, wait=True)
    IDC15_scaler_start.put(1, wait=True)
    yap_counts = yap_pv.value
    data.append([i, float(llRBK.value), yap_counts])