21 #include <registryFunction.h> 23 #include <menuFtype.h> 24 #include <aSubRecord.h> 25 #include <epicsExport.h> 27 #define NINPUTS (aSubRecordU - aSubRecordA) 30 long select_string(aSubRecord *prec)
33 char *out = prec->vala;
34 DBLINK *L = &prec->inpa;
35 const char **I = (
const char**)&prec->a;
39 epicsEnum16 sevr, stat;
40 if(L[i].type==CONSTANT)
42 if(dbGetAlarm(&L[i], &stat, &sevr))
46 memcpy(out, I[i], MAX_STRING_SIZE);
51 (void)recGblSetSevr(prec, READ_ALARM, INVALID_ALARM);
68 long gen_timeline(aSubRecord *prec)
74 if (prec->fta != menuFtypeDOUBLE
75 || prec->ftb != menuFtypeDOUBLE
76 || prec->ftc != menuFtypeLONG
78 errlogPrintf(
"%s incorrect input type. A,B (DOUBLE), C (LONG)",
83 if (prec->ftva != menuFtypeDOUBLE
85 errlogPrintf(
"%s incorrect output type. OUTA (DOUBLE)",
92 errlogPrintf(
"%s output size too small. OUTA (>=1)",
99 count=*(epicsUInt32*)prec->c;
102 if (count>prec->nova)
106 for (i=1; i<count; i++) {
107 result[i]=result[i-1]+dx;
131 long gen_delaygen(aSubRecord *prec)
133 double delay, width, egupertick;
134 epicsUInt32 count, i, mult;
135 unsigned char *result;
136 epicsUInt32 idelay, iwidth;
138 if (prec->fta != menuFtypeDOUBLE
139 || prec->ftb != menuFtypeDOUBLE
140 || prec->ftc != menuFtypeDOUBLE
141 || prec->ftd != menuFtypeLONG
143 errlogPrintf(
"%s incorrect input type. A,B,C (DOUBLE) D (LONG)",
148 if (prec->ftva != menuFtypeUCHAR
150 errlogPrintf(
"%s incorrect output type. OUTA (DOUBLE)",
155 delay=*(
double*)prec->a;
156 width=*(
double*)prec->b;
157 egupertick=*(
double*)prec->c;
158 mult=*(epicsUInt32*)prec->d;
165 idelay=(epicsInt32)(0.5 + delay/egupertick);
166 iwidth=(epicsInt32)(0.5 + width/egupertick);
169 errlogPrintf(
"%s : invalid delay %d check units\n",prec->name,idelay);
171 }
else if(iwidth>=count) {
172 errlogPrintf(
"%s : invalid delay %d check units\n",prec->name,iwidth);
174 }
else if(idelay+iwidth>=count) {
175 errlogPrintf(
"%s : delay+width is too long\n",prec->name);
179 for (i=0; i<count; i++) {
182 }
else if(i<idelay+iwidth) {
187 if (i%mult==mult-1) {
216 long gen_bitarraygen(aSubRecord *prec)
218 epicsEnum16 *intype=&prec->fta;
219 epicsUInt16 **indata=(epicsUInt16 **)&prec->a;
220 epicsUInt32 *inlen=&prec->noa;
222 epicsUInt32 outlen=prec->nova, curlen;
224 epicsUInt8 *result=prec->vala;
225 epicsUInt32 numinputs = outlen/16;
227 if(prec->ftva!=menuFtypeUCHAR) {
228 errlogPrintf(
"%s incorrect output type. A (UCHAR))\n",
237 for(curlen=0; curlen<numinputs; curlen++) {
238 if(intype[curlen]!=menuFtypeUSHORT) {
239 errlogPrintf(
"%s incorrect input type. %c (UCHAR))\n",
240 prec->name,
'A'+curlen);
242 }
else if(inlen[curlen]!=1){
243 errlogPrintf(
"%s incorrect input length. %c (1))\n",
244 prec->name,
'A'+curlen);
249 for(curlen=0; curlen<outlen; curlen++) {
250 epicsUInt32 I=curlen/16;
251 epicsUInt32 B=15-(curlen%16);
255 result[curlen]=!!(*indata[I]&(1<<B));
262 long gun_bunchTrain(aSubRecord *prec)
265 unsigned char *result;
270 if (prec->fta != menuFtypeULONG) {
271 errlogPrintf(
"%s incorrect input type. A(ULONG)",
276 if (prec->ftva != menuFtypeUCHAR) {
277 errlogPrintf(
"%s incorrect output type. OUTA (DOUBLE)",
282 bunchPerTrain = *(
int*)prec->a;
285 if(bunchPerTrain<1 || bunchPerTrain>150) {
286 errlogPrintf(
"%s : invalid number of bunches per train %d.\n",prec->name,bunchPerTrain);
292 for(i = 0; i < bunchPerTrain; i++) {
293 for(j = 0; j < 10; j++) {
296 result[i*10 + j] = 1;
298 result[i*10 + j] = 0;
301 for(i = 0; i <10; i++, count++) {
309 static registryFunctionRef asub_seq[] = {
310 {
"Select String", (REGISTRYFUNCTION) select_string},
311 {
"Timeline", (REGISTRYFUNCTION) gen_timeline},
312 {
"Bit Array Gen", (REGISTRYFUNCTION) gen_bitarraygen},
313 {
"Delay Gen", (REGISTRYFUNCTION) gen_delaygen},
314 {
"Bunch Train", (REGISTRYFUNCTION) gun_bunchTrain}
318 void asub_evr(
void) {
319 registryFunctionRefAdd(asub_seq, NELEMENTS(asub_seq));
322 #include <epicsExport.h>
epicsExportRegistrar(asub_evr)