diff --git a/build/lib/iexcode/instruments/scanRecord.py b/build/lib/iexcode/instruments/scanRecord.py index 07ff5d0c75c9ffab5ea17a14690c43c39511305b..32fc1cdc2c495b4f9872a1dedcdddaf4f0202b4d 100644 --- a/build/lib/iexcode/instruments/scanRecord.py +++ b/build/lib/iexcode/instruments/scanRecord.py @@ -512,21 +512,30 @@ class ScanRecord: def check(self,scan_dim): """ checks pvs connects and that positioners are within limits + + returns scan_ok = True/False """ - self._check_pvs(scan_dim) - if not self._check_limits(scan_dim): - print("check positioner limits") + pv_ok = self._check_pvs(scan_dim) + limits_ok = self._check_limits(scan_dim) + + scan_ok = bool(pv_ok * limits_ok) + return scan_ok - def _check_pvs(self,scan_dim): + def _check_pvs(self,scan_dim,verbose=False): """ Check if any of the detectors or positions pvs are not connected + returns connected = True/False + Previously: Scan_Check """ - print('Checking if all detectors & positioners are connected...') - scan_pv = self.ioc+"scan"+str(scan_dim) + if verbose: + print('Checking if all detectors & positioners are connected...') + scan_pv = self.ioc+"scan"+str(scan_dim) + #Detectors + det_ok = True for i in range(1,71): det_num=(str(i).zfill(2)) det_pv=caget(scan_pv+".D"+det_num+"PV") @@ -534,7 +543,10 @@ class ScanRecord: det=PV(det_pv); time.sleep(0.1)#smallest sleep to allow for PV traffic if not det.connected: print("Detector "+det_num+" has a bad PV: "+det.pvname+" not connected") + det_ok = False + #Positioners + pos_ok = True for i in range(1,5): pos_num=str(i) pos_pv=caget(scan_pv+".P"+pos_num+"PV") @@ -542,8 +554,13 @@ class ScanRecord: pos=PV(pos_pv) if not pos.connected: print("Positioner "+pos_num+" has a BAD PV: "+pos.pvname+" not connected") + pos_ok = False + if verbose: + print('Connected') + + return bool(pos_ok * det_ok) - def _check_limits(self,scan_dim): + def _check_limits(self,scan_dim,verbose=False): """ checks if the scan parameters are within the limits returns limits_ok (True / False) @@ -552,11 +569,16 @@ class ScanRecord: caput(scan_pv+'.CMND',1) time.sleep(.5) SMSG = caget(scan_pv+'.SMSG',as_string=True) - if len(SMSG) > 0: + if verbose: + print(SMSG) + + if SMSG != 'SCAN Values within limits': print_warning_message('Positioner out of limits \n '+SMSG) limits_ok = False else: limits_ok = True + + return limits_ok ############################################################################################################## @@ -658,7 +680,7 @@ class ScanRecord: step = caget(self.ioc+"scan"+str(i)+".P1SI") print('Scan'+str(i)+': '+drive+'= '+str(start)+' / '+str(stop)+' / '+str(step)) - if self._check_limits(scan_dim): + if self.check(scan_dim): filename = self.prefix(self.ioc) fileNum = self.fileNum(self.ioc) print(filename+str(fileNum)+" started at ", dateandtime()) @@ -674,14 +696,20 @@ class ScanRecord: ############################################################################################################## - def empty_scan(self,**kwargs): + def empty_scan(self,npts=1,**kwargs): """ starts a scan with out a drive + npts = number of points + + **kwargs: + execute = True/False (default=True) Previously: Scan_Empty_Go """ kwargs.setdefault('execute',True) - self.fillin("","",0,1,1,**kwargs) + kwargs.setdefault('num_points',True) + self.fillin("","",0,npts,1,**kwargs) + if kwargs['execute']: self.go(**kwargs) diff --git a/iexcode/instruments/scanRecord.py b/iexcode/instruments/scanRecord.py index 30cf6095a9a50842ebe7cf576f68bd546be979c3..ce9ae011609b348d654c4de12597a74f6874806b 100644 --- a/iexcode/instruments/scanRecord.py +++ b/iexcode/instruments/scanRecord.py @@ -512,21 +512,30 @@ class ScanRecord: def check(self,scan_dim): """ checks pvs connects and that positioners are within limits + + returns scan_ok = True/False """ - self._check_pvs(scan_dim) - if not self._check_limits(scan_dim): - print("check positioner limits") + pv_ok = self._check_pvs(scan_dim) + limits_ok = self._check_limits(scan_dim) + + scan_ok = bool(pv_ok * limits_ok) + return scan_ok - def _check_pvs(self,scan_dim): + def _check_pvs(self,scan_dim,verbose=False): """ Check if any of the detectors or positions pvs are not connected + returns connected = True/False + Previously: Scan_Check """ - print('Checking if all detectors & positioners are connected...') - scan_pv = self.ioc+"scan"+str(scan_dim) + if verbose: + print('Checking if all detectors & positioners are connected...') + scan_pv = self.ioc+"scan"+str(scan_dim) + #Detectors + det_ok = True for i in range(1,71): det_num=(str(i).zfill(2)) det_pv=caget(scan_pv+".D"+det_num+"PV") @@ -534,7 +543,10 @@ class ScanRecord: det=PV(det_pv); time.sleep(0.1)#smallest sleep to allow for PV traffic if not det.connected: print("Detector "+det_num+" has a bad PV: "+det.pvname+" not connected") + det_ok = False + #Positioners + pos_ok = True for i in range(1,5): pos_num=str(i) pos_pv=caget(scan_pv+".P"+pos_num+"PV") @@ -542,8 +554,13 @@ class ScanRecord: pos=PV(pos_pv) if not pos.connected: print("Positioner "+pos_num+" has a BAD PV: "+pos.pvname+" not connected") + pos_ok = False + if verbose: + print('Connected') + + return bool(pos_ok * det_ok) - def _check_limits(self,scan_dim): + def _check_limits(self,scan_dim,verbose=False): """ checks if the scan parameters are within the limits returns limits_ok (True / False) @@ -552,11 +569,16 @@ class ScanRecord: caput(scan_pv+'.CMND',1) time.sleep(.5) SMSG = caget(scan_pv+'.SMSG',as_string=True) - if SMSG != 'SCAN Values within limits !!!!!': + if verbose: + print(SMSG) + + if SMSG != 'SCAN Values within limits': print_warning_message('Positioner out of limits \n '+SMSG) limits_ok = False else: limits_ok = True + + return limits_ok ############################################################################################################## @@ -658,7 +680,7 @@ class ScanRecord: step = caget(self.ioc+"scan"+str(i)+".P1SI") print('Scan'+str(i)+': '+drive+'= '+str(start)+' / '+str(stop)+' / '+str(step)) - if self._check_limits(scan_dim): + if self.check(scan_dim): filename = self.prefix(self.ioc) fileNum = self.fileNum(self.ioc) print(filename+str(fileNum)+" started at ", dateandtime()) @@ -682,13 +704,13 @@ class ScanRecord: **kwargs: execute = True/False (default=True) - Previously: Scan_Empty_Go """ kwargs.setdefault('execute',True) kwargs.setdefault('num_points',True) - num_points self.fillin("","",0,npts,1,**kwargs) + sleep(.1) + if kwargs['execute']: self.go(**kwargs)