Files
x07ma/script/local.py
2015-08-24 18:14:34 +02:00

52 lines
1.6 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")
#This procedude is used to emulate file names generated by FDA
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())
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()