From 128fcb9d1a95522f4911bf603acac1294ea29aa8 Mon Sep 17 00:00:00 2001 From: vnadot Date: Wed, 24 Mar 2021 13:05:56 +0100 Subject: [PATCH] fix the forgetten "}" --- snippets/c.json | 1 + test/test.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/snippets/c.json b/snippets/c.json index ce40f51..602e97c 100644 --- a/snippets/c.json +++ b/snippets/c.json @@ -31,6 +31,7 @@ " float val;", " for (int i=0; i val = ((epicsFloat32 *)precord->b)[2];", " ", diff --git a/test/test.c b/test/test.c index 962d50e..0487915 100644 --- a/test/test.c +++ b/test/test.c @@ -11,6 +11,53 @@ epicsFloat32 epicsFloat64 epicsString +#include +#include +#include + +// most of these examples are coming from Yves Lussignol (https://drf-gitlab.cea.fr/, signalProcessingApp module) +// the goal is to provide examples of reading and writing in different variable types +static long my_asub_routine(aSubRecord *precord){ + // inputs: + // - a: short + // - b: float[] + // - c: int + // outputs: + // - vala: float + // - valb: float[] + + // inputs + short inputA = *(short *)precord->a; // input scalar + epicsFloat32 *inputB_array = (epicsFloat32 *)precord->b; // input array + int nob = precord->nob; // nb of element in array (input b) + int inputC = *(epicsUInt32 *)precord->c; + + // read the whole input array (input b) + float val; + for (int i=0; i val = ((epicsFloat32 *)precord->b)[2]; + + // write the whole output array (output b) + epicsFloat32 *outputB_array = (epicsFloat32 *)precord->valb; + for(int i=0; i < nbOfElement; i++){ + *outputB_array++ = i; + } + // write cell 3 of output array (ouput b) + outputB_array[2] = 3.14; // <=> ((epicsFloat32 *)precord->valb)[2] = 3.10; + + // insert your code here + + // outputs + *(float *)precord->vala = 94.77; + precord->nevb = outsize; // number of output array elements + + return 0; +} +epicsRegisterFunction(my_asub_routine); + // C.E.A. IRFU/SIS/LDISC // // signalProcessingLib.c