def dhv(val = None): if not val is None: if val.upper() == 'UP': dhv1_up = sics.get_raw_value('dhv1 upper') dhv2_up = sics.get_raw_value('dhv2 upper') res = sics.run_command('drive dhv1 ' + str(dhv1_up) + ' dhv2 ' + str(dhv2_up)) if res.find('Full Stop') >= 0: raise Exception, res elif val.upper() == 'DOWN': dhv1_down = sics.get_raw_value('dhv1 lower') dhv2_down = sics.get_raw_value('dhv2 lower') res = sics.run_command('drive dhv1 ' + str(dhv1_down) + ' dhv2 ' + str(dhv2_down)) if res.find('Full Stop') >= 0: raise Exception, res else: dhv1_up = sics.get_raw_value('dhv1 upper') dhv1_down = sics.get_raw_value('dhv1 lower') dhv1 = sics.get_raw_value('dhv1') dhv2_up = sics.get_raw_value('dhv2 upper') dhv2_down = sics.get_raw_value('dhv2 lower') dhv2 = sics.get_raw_value('dhv2') if abs(dhv1_up - dhv1) <= 5 and (dhv2_up - dhv2) <= 5: return 'UP' elif abs(dhv1 - dhv1_down) <= 5 and (dhv2 - dhv2_down) <= 5: return 'DOWN' else: return 'ERROR'
def dhv(val=None): if not val is None: if val.upper() == 'UP': dhv1_up = sics.get_raw_value('dhv1 upper') dhv2_up = sics.get_raw_value('dhv2 upper') res = sics.run_command('drive dhv1 ' + str(dhv1_up) + ' dhv2 ' + str(dhv2_up)) if res.find('Full Stop') >= 0: raise Exception, res elif val.upper() == 'DOWN': dhv1_down = sics.get_raw_value('dhv1 lower') dhv2_down = sics.get_raw_value('dhv2 lower') res = sics.run_command('drive dhv1 ' + str(dhv1_down) + ' dhv2 ' + str(dhv2_down)) if res.find('Full Stop') >= 0: raise Exception, res else: dhv1_up = sics.get_raw_value('dhv1 upper') dhv1_down = sics.get_raw_value('dhv1 lower') dhv1 = sics.get_raw_value('dhv1') dhv2_up = sics.get_raw_value('dhv2 upper') dhv2_down = sics.get_raw_value('dhv2 lower') dhv2 = sics.get_raw_value('dhv2') if abs(dhv1_up - dhv1) <= 5 and (dhv2_up - dhv2) <= 5: return 'UP' elif abs(dhv1 - dhv1_down) <= 5 and (dhv2 - dhv2_down) <= 5: return 'DOWN' else: return 'ERROR'
def getHistmemTextstatus(name): i = 0 while True: try: return str(sics.run_command('histmem textstatus ' + name)) except: i += 1 if i < 3: time.sleep(1) else: raise
def getHistmemTextstatus(name): counter = 0 while True: try: counter += 1 return str(sics.run_command('histmem textstatus ' + name)) except (Exception, SicsExecutionException) as e: if isInterruptException(e) or (counter >= 3): raise time.sleep(1)
def getHistmemTextstatus(name): counter = 0 while True: try: counter += 1 return str(sics.run_command('histmem textstatus ' + name)) except (Exception, SicsExecutionException) as e: if isInterruptException(e): raise if counter >= 5: return None # break loop time.sleep(1)
def multiDrive(self, det, curtaindet, curtainl, curtainr, curtainu, curtaind): if det is None and curtaindet is None and curtainl is None and curtainr is None \ and curtainu is None and curtaind is None: return cmd = 'drive' if not det is None: cmd += ' det ' + str(det) if not curtaindet is None: cmd += ' curtaindet ' + str(curtaindet) if not curtainl is None: cmd += ' curtainl ' + str(curtainl) if not curtainr is None: cmd += ' curtainr ' + str(curtainr) if not curtainu is None: cmd += ' curtainu ' + str(curtainu) if not curtaind is None: cmd += ' curtaind ' + str(curtaind) res = sics.run_command(cmd) if not res is None and res.find('Full Stop') >= 0: raise Exception, res
def multi_drive(self): cmd = 'drive' if self.need_drive_det(): cmd += ' det ' + str(self.det) if not self.det_offset is None: cmd += ' detoff ' + str(self.det_offset) else: cmd += ' detoff 0' if not self.wavelength is None: cmd += ' nvs_lambda ' + str(self.wavelength) if not self.srce is None: cmd += ' srce ' + str(self.srce) if not self.apx is None: cmd += ' apx ' + str(self.apx) if not cmd == 'drive': log(cmd) res = sics.run_command(cmd) if not res is None and res.find('Full Stop') >= 0: raise Exception, res log('finished multi-drive')
def multi_drive(self): cmd = "drive" if self.need_drive_det(): cmd += " det " + str(self.det) if not self.det_offset is None: cmd += " detoff " + str(self.det_offset) else: cmd += " detoff 0" if not self.wavelength is None: cmd += " nvs_lambda " + str(self.wavelength) if not self.srce is None: cmd += " srce " + str(self.srce) if not self.apx is None: cmd += " apx " + str(self.apx) if not cmd == "drive": log(cmd) res = sics.run_command(cmd) if not res is None and res.find("Full Stop") >= 0: raise Exception, res log("finished multi-drive")
def sapmot(val = None): if not val is None: if type(val) is float or type(val) is int : val = 'D' + str(val) sics.run_command('pdrive sapmot ' + str(val)) return sics.get_raw_value('posname sapmot', str)
def setSafeAttenuation(startingAttenuation=330): local_rate = 0 global_rate = 0 previousLocalRate = 0 previousGlobalRate = 0 startLevel = attenuationLevels.index(startingAttenuation) # Hack: need to reset and run histmem log('set safe attenuation...') # loop from the safe range of attenuation for level in xrange(startLevel, len(attenuationLevels)): # drive the attenuator driveAtt(attenuationLevels[level]) # count bin rate local_rate, global_rate = determineAveragedRates(max_samples=5, log_success=False) log('local rate = ' + str(local_rate)) log('global rate = ' + str(global_rate)) if (local_rate == 0.0) and (global_rate == 0): log('hasTripped: ' + str(hasTripped())) log('detector_protect_num_trip: ' + str(sics.run_command('histmem textstatus detector_protect_num_trip'))) log('detector_protect_num_trip_ack: ' + str(sics.run_command('histmem textstatus detector_protect_num_trip_ack'))) # check if detector has tripped if hasTripped(): log('increasing attenuation...') while hasTripped(): resetTrip() local_rate, global_rate = determineAveragedRates(max_samples=3, log_success=False) log('local rate = ' + str(local_rate)) log('global rate = ' + str(global_rate)) break # exit loop # Too much (check both local and global rate) if ((local_rate > local_rateSafe) or (global_rate > global_rateSafe)): if (level > 0): # [GUMTREE-378] Ensure SICS is ready after count while not sics.getSicsController().getServerStatus().equals(ServerStatus.EAGER_TO_EXECUTE): time.sleep(0.1) # Brings it back to one step driveAtt(attenuationLevels[level - 1]) local_rate = previousLocalRate global_rate = previousGlobalRate break # Within tolerance ([11/06/2015:davidm] 2.8 is a better approximation) if (local_rate >= local_rateSafe / 2) or (global_rate >= global_rateSafe / 2.8): log('exit loop') break previousLocalRate = local_rate previousGlobalRate = global_rate # Ensure SICS is ready after count while not sics.getSicsController().getServerStatus().equals(ServerStatus.EAGER_TO_EXECUTE): time.sleep(0.1) # Print info at the end log('Attenuation is set to ' + str(getAttValue()) + ' degree with bin rate ' + str(local_rate))
def sapmot(val=None): if not val is None: if type(val) is float or type(val) is int: val = 'D' + str(val) sics.run_command('pdrive sapmot ' + str(val)) return sics.get_raw_value('posname sapmot', str)