Files
morbidissimo/morioc/channels.py
T

54 lines
1.1 KiB
Python

from types import SimpleNamespace
import numpy as np
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 = np.asarray(fpicture)
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)