Files
x03da/script/local.py
2015-07-15 17:59:09 +02:00

58 lines
1.2 KiB
Python

import random
import ch.psi.pshell.dev.Readable.ReadableArray as ReadableArray
class SimulatedOutput(Writable):
def getName(self):
return "SimulatedOutput"
def write(self, value):
pass
class SimulatedInput(Readable):
def __init__(self):
self.x = 0.0
def getName(self):
return "SimulatedInput"
def read(self):
self.x = self.x + 0.2
noise = (random.random() - 0.5) / 20.0
return math.sin(self.x) + noise
sout = SimulatedOutput()
sinp = SimulatedInput()
def integrate_image():
data = scienta.data.read()
#Integrate and plot
(width,height) = scienta.getImageSize().tolist()
integration = []
for i in range(width):
p=0.0
for j in range(height):
p=p+data[j*width+i]
integration.append(p)
return integration
class ImageIntegrator(ReadableArray):
def getName(self):
return "integration"
def getSize(self):
(width,height) = scienta.getImageSize().tolist()
return width
def read(self):
return to_array(integrate_image(),'d')
integration = ImageIntegrator()
def trig_scienta():
scienta.start()
scienta.waitReady(-1)