The following VcExecutor generates a signal. It is supposed to be used with ascan-like scans of 50 points.
#!/bin/env python
#
# this Vc counter produces a Gauss peak
# - it is supposed to be used with ascans of 50 points
# - the maximum is in the middle
#
import HasyUtils
import random, math
NP = 50.
class VC:
def __init__(self):
print " VC.init"
self.xMin = 0.
self.xMax = 10.
self.width = 1.
self.height = 800.
self.x = 0.1
self.delta = self.xMax/NP/4.
self.x0 = 5.
self.offset = 0.
self.scanID = -1
self.count = 0
#
# dev_state
#
def dev_state( self):
argout = self.proxies[0].State()
return argout
#
# Counts
#
def read_Counts( self):
self.count += 1
#
# reset things, if the ScanID changes, new scan
#
try:
if int( HasyUtils.getEnv( 'ScanID')) != self.scanID:
self.scanID = int( HasyUtils.getEnv( 'ScanID'))
self.x = 0
except:
pass
temp = (self.x - self.x0)/self.width;
temp = self.height*math.exp( -temp*temp/self.width)
self.x = self.x + self.delta
if self.x > self.xMax:
self.x = 0
return temp
def write_Counts( self, argin):
return 1
#
# Offset
#
def read_Offset( self):
return self.offset
def write_Offset( self, argin):
self.offset = argin
return 1
#
# reset
#
def Reset(self):
return True