22 lines
563 B
Python
22 lines
563 B
Python
import random
|
|
|
|
####################################################################################################
|
|
# Simulated Devices
|
|
####################################################################################################
|
|
|
|
class AnalogInput(ReadonlyRegisterBase):
|
|
def doRead(self):
|
|
time.sleep(0.001)
|
|
self.val = to_array(self.calc(), 'd')
|
|
return self.val
|
|
|
|
class Random(AnalogInput):
|
|
def calc(self):
|
|
return random.random()
|
|
|
|
|
|
for i in range(20):
|
|
r=Random("r"+str(i))
|
|
add_device(r, True)
|
|
r.polling=5
|