################################################################################################### # Deployment specific global definitions - executed after startup.py ################################################################################################### FILENAME = None #Uncomment this line to create the simulated devices needed to the tutorial scripts. #run("tutorial/devices") #The persistence strategy is overriden to adjust file names import ch.psi.pshell.data.ScanPersistenceStrategyTable class Strategy(ch.psi.pshell.data.ScanPersistenceStrategyTable): def getLogFileName(self): return time.strftime('%Y%m%d%H%M%S') + '_' + controller.getExecutingContext() + '_logs' def getDatasetName(self, scan): global FILENAME name = controller.getExecutingContext() if FILENAME is None else FILENAME return time.strftime('%Y%m%d_%H%M') + '_' + FILENAME + '_' + str(controller.dataManager.getScanIndex()).zfill(4) controller.dataManager.setScanStrategy(Strategy()) #Reading Energy Scan configuration file def getPars(element): f = open(controller.setup.getConfigPath() + '/energy_scan.properties') try: for line in f: tokens = line.split("=") if tokens[0] == str(element): tokens = tokens[1].split(";") for i in range(len(tokens)): tokens[i] = float(tokens[i].strip()) return tokens finally: f.close() raise Exception ("Invalid element: " + str(element)) #Pseudo-devices energy = None class SimulatedEnergy(Writable): def write(self, value): self.put(value) def put(self, value, timeout = None): global energy energy = value def close(self): pass class SimulatedEnergyReadback(Readable): def read(self): global energy return energy; def get(self): return self.read() def close(self): pass sim_energy = SimulatedEnergy() sim_energy_readback = SimulatedEnergyReadback()