def run_command(cmd, use_full_feedback=False): call_back = __SICS_Callback__(use_full_feedback) SicsCore.getDefaultProxy().send(cmd, call_back) acc_time = 0 # while call_back.__status__ is None and acc_time < 20: while call_back.__status__ is None: time.sleep(0.2) acc_time += 0.2 if call_back.__status__ is None: raise Exception, 'time out in running the command' return call_back.__status__
def run_command(cmd, use_full_feedback = False): call_back = __SICS_Callback__(use_full_feedback) SicsCore.getDefaultProxy().send(cmd, call_back) acc_time = 0 # while call_back.__status__ is None and acc_time < 2: while call_back.__status__ is None: time.sleep(0.2) acc_time += 0.2 if call_back.__status__ is None: raise Exception, 'time out in running the command' return call_back.__status__
def run_command(cmd): global __status__ __status__ = None call_back = __SICS_Callback__() SicsCore.getDefaultProxy().send(cmd, call_back) acc_time = 0 while __status__ is None and acc_time < 2: time.sleep(0.2) acc_time += 0.2 if __status__ is None: raise Exception, 'time out in running the command' return __status__
def run_command_timeout(cmd, use_full_feedback=False, timeout=None): logger.log('using timeout command') call_back = __SICS_Callback__(use_full_feedback) SicsCore.getDefaultProxy().send(cmd, call_back) acc_time = 0 while call_back.__status__ is None and (timeout is None or acc_time < timeout): # while call_back.__status__ is None: time.sleep(0.2) acc_time += 0.2 if call_back.__status__ is None: raise Exception, 'time out in running the command' return call_back.__status__
def driveGuide(guideConfig): # Set configuration if hasattr(guideConfig, 'key'): guideConfig = guideConfig.key sics.set('/commands/optics/guide/configuration', guideConfig) log('Moving guide to ' + guideConfig) sicsController = SicsCore.getSicsController() commandController = sicsController.findComponentController('/commands/optics/guide') # Setting of configuration and starting a command are committed to SICS via different communication channels # In order to make those in sync, we need to wait for the configuration to be settled. time.sleep(0.1) # Start command now cnt = 0 while cnt < 20: try: commandController.syncExecute(); break except SicsExecutionException, e: em = str(e.getMessage()) if em.__contains__('Interrupted'): raise e log('retry moving guide to ' + str(guideConfig)) time.sleep(1) while not sicsController.getServerStatus().equals(ServerStatus.EAGER_TO_EXECUTE): time.sleep(0.3) cnt += 1
def count(mode, preset): # Initialisation sicsController = SicsCore.getSicsController() countController = sicsController.findComponentController( '/commands/monitor/count') hset(countController, '/mode', mode) hset(countController, '/preset', preset) # Monitor status while (countController.getCommandStatus().equals(CommandStatus.BUSY)): # Don't do anything before counter is ready time.sleep(0.1) # Run scan logger.log('Count started') countController.asyncExecute() # Monitor initial status change timeOut = False counter = 0 while (countController.getStatusDirtyFlag() == False): time.sleep(0.1) counter += 0.1 if (counter >= 1): timeOut = True logger.log('Time out on running count') break # Enter into normal sequence if (timeOut == False): while (countController.getCommandStatus().equals(CommandStatus.BUSY)): time.sleep(0.1) handleInterrupt() logger.log('Count completed')
def count(mode, preset): # Initialisation sicsController = SicsCore.getSicsController() countController = sicsController.findComponentController('/commands/monitor/count') hset(countController, '/mode', mode) hset(countController, '/preset', preset) # Monitor status while(countController.getCommandStatus().equals(CommandStatus.BUSY)): # Don't do anything before counter is ready time.sleep(0.1) # Run scan logger.log('Count started') countController.asyncExecute() # Monitor initial status change timeOut = False counter = 0 while(countController.getStatusDirtyFlag() == False): time.sleep(0.1) counter += 0.1 if (counter >= 1): timeOut = True logger.log('Time out on running count') break # Enter into normal sequence if (timeOut == False): while (countController.getCommandStatus().equals(CommandStatus.BUSY)): time.sleep(0.1) handleInterrupt() logger.log('Count completed')
def driveGuide(guideConfig): # Set configuration sics.set('/commands/optics/guide/configuration', guideConfig.key) log('Moving guide to ' + guideConfig.key) sicsController = SicsCore.getSicsController() commandController = sicsController.findComponentController('/commands/optics/guide') # Setting of configuration and starting a command are committed to SICS via different communication channels # In order to make those in sync, we need to wait for the configuration to be settled. time.sleep(0.1) # Start command now cnt = 0 while cnt < 20: try: commandController.syncExecute(); break except SicsExecutionException, e: em = str(e.getMessage()) if em.__contains__('Interrupted'): raise e log('retry moving guide to ' + str(guideConfig.key)) time.sleep(1) while not sicsController.getServerStatus().equals(ServerStatus.EAGER_TO_EXECUTE): time.sleep(0.3) cnt += 1
def histmem(cmd, mode, preset): sicsController = SicsCore.getSicsController() histmemController = sicsController.findComponentController('/commands/histogram/histmem') hset(histmemController, '/cmd', cmd) hset(histmemController, '/mode', mode) hset(histmemController, '/preset', preset) # give time for hset to finish time.sleep(0.2) # start histmem command logger.log(cmd + ' histogram acquisition') histmemController.asyncExecute() # Monitor initial status change timeOut = False counter = 0; while(histmemController.getStatusDirtyFlag() == False): time.sleep(0.1) counter += 0.1 if (counter >= 1): timeOut = True logger.log('Time out on running count') break # Enter into normal sequence if (timeOut == False): while (histmemController.getCommandStatus().equals(CommandStatus.BUSY) or histmemController.getCommandStatus().equals(CommandStatus.STARTING)): time.sleep(0.1) handleInterrupt() logger.log('Count completed')
def histmem(cmd, mode, preset): sicsController = SicsCore.getSicsController() histmemController = sicsController.findComponentController( '/commands/histogram/histmem') hset(histmemController, '/cmd', cmd) hset(histmemController, '/mode', mode) hset(histmemController, '/preset', preset) # give time for hset to finish time.sleep(0.2) # start histmem command logger.log(cmd + ' histogram acquisition') histmemController.asyncExecute() # Monitor initial status change timeOut = False counter = 0 while (histmemController.getStatusDirtyFlag() == False): time.sleep(0.1) counter += 0.1 if (counter >= 1): timeOut = True logger.log('Time out on running count') break # Enter into normal sequence if (timeOut == False): while (histmemController.getCommandStatus().equals(CommandStatus.BUSY) or histmemController.getCommandStatus().equals( CommandStatus.STARTING)): time.sleep(0.1) handleInterrupt() logger.log('Count completed')
def driveGuide(guideConfig): # Set configuration sics.set('/commands/optics/guide/configuration', guideConfig.key) log('Moving guide to ' + guideConfig.key) sicsController = SicsCore.getSicsController() commandController = sicsController.findComponentController('/commands/optics/guide') # Setting of configuration and starting a command are committed to SICS via different communication channels # In order to make those in sync, we need to wait for the configuration to be settled. time.sleep(0.1) # Start command now commandController.syncExecute(); log('Guide is moved to ' + getGuideConfig())
def driveGuide(guideConfig): # Set configuration sics.set('/commands/optics/guide/configuration', guideConfig.key) log('Moving guide to ' + guideConfig.key) sicsController = SicsCore.getSicsController() commandController = sicsController.findComponentController( '/commands/optics/guide') # Setting of configuration and starting a command are committed to SICS via different communication channels # In order to make those in sync, we need to wait for the configuration to be settled. time.sleep(0.1) # Start command now commandController.syncExecute() log('Guide is moved to ' + getGuideConfig())
def clearInterrupt(): SicsCore.getSicsController().clearInterrupt()
def isInterrupt(): return SicsCore.getSicsController().isInterrupted()
def interrupt(channel=None): if channel == None: SicsCore.getSicsController().interrupt() else: SicsCore.getDefaultProxy().send('INT1712 3', None, channel) logger.log("Sent SICS interrupt")
def getSicsController(): return SicsCore.getSicsController()
def execute(command, channel_id = 'general'): SicsCore.getDefaultProxy().send(command, None, channel_id) handleInterrupt()
def execute(command, channel_id='general'): SicsCore.getDefaultProxy().send(command, None, channel_id) handleInterrupt()
def getSampleHolderPosition(): sicsController = SicsCore.getSicsController() samx = sicsController.findDeviceController(DEVICE_SAMX) return samx.getValue().getFloatData()
def interrupt(): SicsCore.getSicsController().interrupt() logger.log("Sent SICS interrupt")