added classes for PV/Image

This commit is contained in:
2021-04-06 14:36:55 +02:00
parent 0c436e4ed6
commit 230f442ce8

51
morioc/channels.py Normal file
View File

@ -0,0 +1,51 @@
from types import SimpleNamespace
class PV:
def __init__(self, ioc, name):
self.ioc = ioc
self.name = name
def get(self):
name = self.name
return self.ioc.get(name)
def put(self, value):
name = self.name
data = {name: value}
self.ioc.serve(**data)
class Image:
def __init__(self, ioc, name):
self.ioc = ioc
self.name = name
self.pvs = SimpleNamespace(
fpicture = PV(ioc, name + ":FPICTURE"),
width = PV(ioc, name + ":WIDTH"),
height = PV(ioc, name + ":HEIGHT")
)
def get(self):
fpicture = self.pvs.fpicture.get()
width = self.pvs.width.get()
height = self.pvs.height.get()
fpicture.shape = (width, height)
return fpicture
def put(self, img):
width, height = img.shape
fpicture = img.ravel()
self.pvs.fpicture.put(fpicture)
self.pvs.width.put(width)
self.pvs.height.put(height)