From d7775324f5c47a8d02d10a94582a6bf483cddc25 Mon Sep 17 00:00:00 2001 From: Sven Augustin Date: Tue, 6 Apr 2021 18:08:40 +0200 Subject: [PATCH] added note on OO interface --- README.md | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1622bf3..9dc06d8 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ A manager/runner of scripts: A trivially easy to use softIOC: -- Uses `pcaspy` (in a slightly unintended way). +- Uses [`pcaspy`](https://github.com/paulscherrerinstitute/pcaspy/) (in a slightly unintended way). - `serve` (output) PVs and `host` (input) PVs: ```python @@ -40,4 +40,24 @@ with MorIOC("mtest") as mor: ``` - 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. \ No newline at end of file +- Currently supports Python scalars (int, float, str), sequences (lists, tuples, etc.) as well as numpy arrays and scalars. + +- Alternatively, an object-oriented interface exists: + +```python +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) +``` \ No newline at end of file