Closedown
This commit is contained in:
@@ -27,6 +27,27 @@ else:
|
||||
lat = args[4]
|
||||
|
||||
|
||||
class AnalogOutput(RegisterBase):
|
||||
def doRead(self):
|
||||
return self.val if hasattr(self, 'val') else 0.0
|
||||
|
||||
def doWrite(self, val):
|
||||
self.val = val
|
||||
|
||||
class AnalogInput(ReadonlyRegisterBase):
|
||||
def doRead(self):
|
||||
time.sleep(0.001)
|
||||
self.val = to_array(self.calc(), 'd')
|
||||
return self.val
|
||||
class SinusoidSample(AnalogInput):
|
||||
def calc(self):
|
||||
self.x = self.x + 0.1 if hasattr(self, 'x') else 0.0
|
||||
noise = (random.random() - 0.5) / 10.0
|
||||
return math.sin(self.x) + noise
|
||||
|
||||
add_device(AnalogOutput("ao1"), True)
|
||||
add_device(SinusoidSample("ai1"), True)
|
||||
|
||||
r = lscan(ao1, ai1, start, stop, step, latency=lat)
|
||||
|
||||
#Setting the return value
|
||||
|
||||
Reference in New Issue
Block a user