68 lines
2.1 KiB
Python
68 lines
2.1 KiB
Python
###################################################################################################
|
|
# 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%S') + '_' + 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(";")
|
|
print len(tokens)]
|
|
for i in range[len(tokens)]:
|
|
tokens[i] = float(tokens[i].trim())
|
|
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()
|
|
|
|
|
|
print getPars("Fe") |