Morbidissimo -- A very soft IOC.
Consists of two parts:
ModuleManager
A manager/runner of scripts:
- Checks a folder (e.g.,
./scripts/
) for files*.py
. - If file contains a function
run()
, this is imported and executed. - At a fixed interval, the function is run again (if the last call has finished). If it is still running, it will not be started a second time (i.e., continuous scripts also work).
- If a file's mtime changes, its potentially running function will be killed, the script reloaded and executed again.
MorIOC
A trivially easy to use softIOC:
- Uses
pcaspy
(in a slightly unintended way). serve
(output) PVs andhost
(input) PVs:
with MorIOC("mtest") as mor:
while True:
# serve MTEST:RAND1 and MTEST:RAND2
# holding a random float and a random int
mor.serve(
rand1 = random(),
rand2 = randint(10, 100)
)
# host MTEST:BUCKET
# can be filled from external via caput
# get current value
# serve MTEST:DOUBLED holding the doubled value
mor.host(bucket = int)
value = mor.get("bucket")
mor.serve(doubled = value * 2)
sleep(0.5)
-
PV's data type is inferred from the value.
-
Currently supports Python scalars (int, float, str), sequences (lists, tuples, etc.) as well as numpy arrays and scalars.
-
Alternatively, an object-oriented interface exists:
with MorIOC("mtest") as mor:
pvo = mor.PV("chan-PV-out") # creates MTEST:CHAN-PV-OUT
pvi = mor.PV("chan-PV-in") # creates MTEST:CHAN-PV-IN
img = mor.Image("chan-Image")
# creates MTEST:CHAN-IMAGE:FPICTURE, :WIDTH, :HEIGHT
while True:
val = random()
pvo.put(val)
val = pvi.get()
print(val)
val = np.random.random(200).reshape(10, 20)
img.put(val)
Description
Languages
Python
100%