Skip to content

Commit

Permalink
fix the forgetten "}"
Browse files Browse the repository at this point in the history
  • Loading branch information
vnadot committed Mar 24, 2021
1 parent 70f19e9 commit 128fcb9
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
1 change: 1 addition & 0 deletions snippets/c.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
" float val;",
" for (int i=0; i<nbOfElement; i++) {",
" val = *inputB_array++;",
" }",
" // read cell 3 of input array (input b)",
" val = inputB_array[2]; // <=> val = ((epicsFloat32 *)precord->b)[2];",
" ",
Expand Down
47 changes: 47 additions & 0 deletions test/test.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,53 @@ epicsFloat32
epicsFloat64
epicsString

#include <aSubRecord.h>
#include <registryFunction.h>
#include <epicsExport.h>

// 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<nbOfElement; i++) {
val = *inputB_array++;
}
// read cell 3 of input array (input b)
val = inputB_array[2]; // <=> 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
Expand Down

0 comments on commit 128fcb9

Please sign in to comment.