diff -cPr --exclude=CVS --exclude=old ../StreamDevice-2-1/doc/aai.html ./doc/aai.html *** ../StreamDevice-2-1/doc/aai.html Thu Jan 1 01:00:00 1970 --- ./doc/aai.html Mon Jun 12 10:53:47 2006 *************** *** 0 **** --- 1,124 ---- + + + + StreamDevice: aai Records + + + + + + +

StreamDevice: aai Records

+ +

Normal Operation

+

+ With aai records, the format converter is applied to + each element. Between the elements, a separator is printed + or expected as specified by the Separator + variable in the protocol. + When parsing input, a space as the first character of the + Separator matches any number of any whitespace + characters. +

+

+ During input, a maximum of NELM elements is + read and NORD is updated accordingly. + Parsing of elements stops when the separator does not match, + conversion fails, or the end of the input is reached. + A minimum of one element must be available. +

+

+ During output, the first NORD elements are + written. +

+

+ The format data type must be convertible to or from the type + specified in the FTVL field. + The variable x[i] stands for one element of + the written or read value. +

+
+
DOUBLE format (e.g. %f):
+
+ Output:x[i]=double(VAL[i])
+ FTVL can be "DOUBLE", "FLOAT", + "LONG", "ULONG", "SHORT", + "USHORT", "CHAR", "UCHAR", + or "ENUM" (which is treated as "USHORT").
+ Input: VAL[i]=FTVL(x[i])
+ FTVL must be "FLOAT" or "DOUBLE" +
+
LONG or ENUM format (e.g. %i or %{):
+
+ Output: x[i]=long(VAL[i])
+ FTVL can be + "LONG", "ULONG", "SHORT", + "USHORT", "CHAR", "UCHAR", + or "ENUM" (which is treated as "USHORT").
+ Signed values are sign-extended to long, unsigned values are + zero-extended to long before converting them.
+ Input: VAL[i]=FTVL(x[i])
+ FTVL can be "DOUBLE", "FLOAT", + "LONG", "ULONG", "SHORT", + "USHORT", "CHAR", "UCHAR", + or "ENUM" (which is treated as "USHORT").
+ The value is truncated to the least significant bytes if + FTVL has a smaller data size than long. +
+
STRING format (e.g. %s):
+
+
+
If FTVL=="STRING":
+
+ Output: x[i]=VAL[i]
+ Input: VAL[i]=x[i]
+ Note that this is an array of strings, not an array of characters. +
+
If FTVL=="CHAR" or FTVL="UCHAR":
+
+ In this case, the complete aai is treated as a large + single string of size NORD. + No separators are printed or expected.
+ Output: x=range(VAL,0,NORD)
+ The first NORD characters are printed, + which might be less than NELM.
+ Input: VAL=x, NORD=length(x)
+ A maximum of NELM-1 characters can be read. + NORD is updated to the index of the first of the + trailing zeros. + Usually, this is the same as the string length. +
+
+ Other values of FTVL are not allowed for this format. +
+
+ +

Initialization

+

+ During initialization, the @init handler is executed, if + present. All format converters work like in normal operation. +

+ +
+

+ aao + ai + ao + bi + bo + mbbi + mbbo + mbbiDirect + mbboDirect + longin + longout + stringin + stringout + calcout + scalcout +

+

Dirk Zimoch, 2006

+ + + diff -cPr --exclude=CVS --exclude=old ../StreamDevice-2-1/doc/aao.html ./doc/aao.html *** ../StreamDevice-2-1/doc/aao.html Thu Jan 1 01:00:00 1970 --- ./doc/aao.html Mon Jun 12 10:53:47 2006 *************** *** 0 **** --- 1,124 ---- + + + + StreamDevice: aao Records + + + + + + +

StreamDevice: aao Records

+ +

Normal Operation

+

+ With aao records, the format converter is applied to + each element. Between the elements, a separator is printed + or expected as specified by the Separator + variable in the protocol. + When parsing input, a space as the first character of the + Separator matches any number of any whitespace + characters. +

+

+ During output, the first NORD elements are + written. +

+

+ During input, a maximum of NELM elements is + read and NORD is updated accordingly. + Parsing of elements stops when the separator does not match, + conversion fails, or the end of the input is reached. + A minimum of one element must be available. +

+

+ The format data type must be convertible to or from the type + specified in the FTVL field. + The variable x[i] stands for one element of + the written or read value. +

+
+
DOUBLE format (e.g. %f):
+
+ Output:x[i]=double(VAL[i])
+ FTVL can be "DOUBLE", "FLOAT", + "LONG", "ULONG", "SHORT", + "USHORT", "CHAR", "UCHAR", + or "ENUM" (which is treated as "USHORT").
+ Input: VAL[i]=FTVL(x[i])
+ FTVL must be "FLOAT" or "DOUBLE" +
+
LONG or ENUM format (e.g. %i or %{):
+
+ Output: x[i]=long(VAL[i])
+ FTVL can be + "LONG", "ULONG", "SHORT", + "USHORT", "CHAR", "UCHAR", + or "ENUM" (which is treated as "USHORT").
+ Signed values are sign-extended to long, unsigned values are + zero-extended to long before converting them.
+ Input: VAL[i]=FTVL(x[i])
+ FTVL can be "DOUBLE", "FLOAT", + "LONG", "ULONG", "SHORT", + "USHORT", "CHAR", "UCHAR", + or "ENUM" (which is treated as "USHORT").
+ The value is truncated to the least significant bytes if + FTVL has a smaller data size than long. +
+
STRING format (e.g. %s):
+
+
+
If FTVL=="STRING":
+
+ Output: x[i]=VAL[i]
+ Input: VAL[i]=x[i]
+ Note that this is an array of strings, not an array of characters. +
+
If FTVL=="CHAR" or FTVL="UCHAR":
+
+ In this case, the complete aao is treated as a large + single string of size NORD. + No separators are printed or expected.
+ Output: x=range(VAL,0,NORD)
+ The first NORD characters are printed, + which might be less than NELM.
+ Input: VAL=x, NORD=length(x)
+ A maximum of NELM-1 characters can be read. + NORD is updated to the index of the first of the + trailing zeros. + Usually, this is the same as the string length. +
+
+ Other values of FTVL are not allowed for this format. +
+
+ +

Initialization

+

+ During initialization, the @init handler is executed, if + present. All format converters work like in normal operation. +

+ +
+

+ aai + ai + ao + bi + bo + mbbi + mbbo + mbbiDirect + mbboDirect + longin + longout + stringin + stringout + calcout + scalcout +

+

Dirk Zimoch, 2006

+ + + diff -cPr --exclude=CVS --exclude=old ../StreamDevice-2-1/doc/ai.html ./doc/ai.html *** ../StreamDevice-2-1/doc/ai.html Wed May 24 14:53:13 2006 --- ./doc/ai.html Mon Jun 12 10:53:47 2006 *************** *** 58,63 **** --- 58,65 ----

+ aai + aao ao bi bo diff -cPr --exclude=CVS --exclude=old ../StreamDevice-2-1/doc/ao.html ./doc/ao.html *** ../StreamDevice-2-1/doc/ao.html Wed May 24 14:53:13 2006 --- ./doc/ao.html Mon Jun 12 10:53:47 2006 *************** *** 59,64 **** --- 59,66 ----


+ aai + aao ai bi bo diff -cPr --exclude=CVS --exclude=old ../StreamDevice-2-1/doc/bi.html ./doc/bi.html *** ../StreamDevice-2-1/doc/bi.html Wed May 24 14:53:13 2006 --- ./doc/bi.html Mon Jun 12 10:53:47 2006 *************** *** 54,59 **** --- 54,61 ----


+ aai + aao ai ao bo diff -cPr --exclude=CVS --exclude=old ../StreamDevice-2-1/doc/bo.html ./doc/bo.html *** ../StreamDevice-2-1/doc/bo.html Wed May 24 14:53:13 2006 --- ./doc/bo.html Mon Jun 12 10:53:47 2006 *************** *** 53,58 **** --- 53,60 ----


+ aai + aao ai ao bi diff -cPr --exclude=CVS --exclude=old ../StreamDevice-2-1/doc/calcout.html ./doc/calcout.html *** ../StreamDevice-2-1/doc/calcout.html Wed May 24 16:15:06 2006 --- ./doc/calcout.html Mon Jun 12 10:53:47 2006 *************** *** 60,65 **** --- 60,67 ----


+ aai + aao ai ao bi diff -cPr --exclude=CVS --exclude=old ../StreamDevice-2-1/doc/formats.html ./doc/formats.html *** ../StreamDevice-2-1/doc/formats.html Mon Jun 12 11:09:02 2006 --- ./doc/formats.html Mon Jun 12 10:53:47 2006 *************** *** 142,148 **** With the # flag, output always contains a period character.

! In input all these formats are equivalent. Leading whitespaces are skipped.

--- 142,148 ---- With the # flag, output always contains a period character.

! In input, all these formats are equivalent. Leading whitespaces are skipped.

diff -cPr --exclude=CVS --exclude=old ../StreamDevice-2-1/doc/longin.html ./doc/longin.html *** ../StreamDevice-2-1/doc/longin.html Wed May 24 14:53:13 2006 --- ./doc/longin.html Mon Jun 12 10:53:47 2006 *************** *** 45,50 **** --- 45,52 ----

+ aai + aao ai ao bi diff -cPr --exclude=CVS --exclude=old ../StreamDevice-2-1/doc/longout.html ./doc/longout.html *** ../StreamDevice-2-1/doc/longout.html Wed May 24 14:53:13 2006 --- ./doc/longout.html Mon Jun 12 10:53:47 2006 *************** *** 45,50 **** --- 45,52 ----


+ aai + aao ai ao bi diff -cPr --exclude=CVS --exclude=old ../StreamDevice-2-1/doc/mbbi.html ./doc/mbbi.html *** ../StreamDevice-2-1/doc/mbbi.html Wed May 24 14:53:13 2006 --- ./doc/mbbi.html Mon Jun 12 10:53:47 2006 *************** *** 71,76 **** --- 71,78 ----


+ aai + aao ai ao bi diff -cPr --exclude=CVS --exclude=old ../StreamDevice-2-1/doc/mbbiDirect.html ./doc/mbbiDirect.html *** ../StreamDevice-2-1/doc/mbbiDirect.html Wed May 24 14:53:13 2006 --- ./doc/mbbiDirect.html Mon Jun 12 10:53:47 2006 *************** *** 57,62 **** --- 57,64 ----


+ aai + aao ai ao bi diff -cPr --exclude=CVS --exclude=old ../StreamDevice-2-1/doc/mbbo.html ./doc/mbbo.html *** ../StreamDevice-2-1/doc/mbbo.html Wed May 24 14:53:13 2006 --- ./doc/mbbo.html Mon Jun 12 10:53:47 2006 *************** *** 72,77 **** --- 72,79 ----


+ aai + aao ai ao bi diff -cPr --exclude=CVS --exclude=old ../StreamDevice-2-1/doc/mbboDirect.html ./doc/mbboDirect.html *** ../StreamDevice-2-1/doc/mbboDirect.html Wed May 24 14:53:13 2006 --- ./doc/mbboDirect.html Mon Jun 12 10:53:47 2006 *************** *** 59,64 **** --- 59,66 ----


+ aai + aao ai ao bi diff -cPr --exclude=CVS --exclude=old ../StreamDevice-2-1/doc/nav.html ./doc/nav.html *** ../StreamDevice-2-1/doc/nav.html Wed May 24 14:53:13 2006 --- ./doc/nav.html Mon Jun 12 10:53:47 2006 *************** *** 125,130 **** --- 125,132 ---- Record Types

+ aai
+ aao
ai
ao
bi
diff -cPr --exclude=CVS --exclude=old ../StreamDevice-2-1/doc/recordtypes.html ./doc/recordtypes.html *** ../StreamDevice-2-1/doc/recordtypes.html Wed Apr 19 09:16:54 2006 --- ./doc/recordtypes.html Mon Jun 12 10:53:47 2006 *************** *** 18,23 **** --- 18,25 ----

There is a separate page for each supported record type:
+ aai + aao ai ao bi *************** *** 30,37 **** longout stringin stringout - calcout waveform

Each page describes which record fields are used in input and output --- 32,40 ---- longout stringin stringout waveform + calcout + scalcout

Each page describes which record fields are used in input and output diff -cPr --exclude=CVS --exclude=old ../StreamDevice-2-1/doc/scalcout.html ./doc/scalcout.html *** ../StreamDevice-2-1/doc/scalcout.html Fri May 26 11:20:37 2006 --- ./doc/scalcout.html Mon Jun 12 10:53:47 2006 *************** *** 78,83 **** --- 78,85 ----


+ aai + aao ai ao bi diff -cPr --exclude=CVS --exclude=old ../StreamDevice-2-1/doc/stringin.html ./doc/stringin.html *** ../StreamDevice-2-1/doc/stringin.html Wed May 24 14:53:13 2006 --- ./doc/stringin.html Mon Jun 12 10:53:47 2006 *************** *** 44,49 **** --- 44,51 ----


+ aai + aao ai ao bi diff -cPr --exclude=CVS --exclude=old ../StreamDevice-2-1/doc/stringout.html ./doc/stringout.html *** ../StreamDevice-2-1/doc/stringout.html Wed May 24 14:53:13 2006 --- ./doc/stringout.html Mon Jun 12 10:53:47 2006 *************** *** 44,49 **** --- 44,51 ----


+ aai + aao ai ao bi diff -cPr --exclude=CVS --exclude=old ../StreamDevice-2-1/doc/waveform.html ./doc/waveform.html *** ../StreamDevice-2-1/doc/waveform.html Wed May 24 14:53:13 2006 --- ./doc/waveform.html Mon Jun 12 10:53:47 2006 *************** *** 102,107 **** --- 102,109 ----


+ aai + aao ai ao bi *************** *** 119,124 ****

Dirk Zimoch, 2005

- --- 121,125 ---- diff -cPr --exclude=CVS --exclude=old ../StreamDevice-2-1/src/CONFIG_STREAM ./src/CONFIG_STREAM *** ../StreamDevice-2-1/src/CONFIG_STREAM Mon May 29 14:22:11 2006 --- ./src/CONFIG_STREAM Mon Jun 12 10:51:31 2006 *************** *** 14,19 **** --- 14,20 ---- # This requires the naming conventions # dev$(RECORD)Stream.c + RECORDS += aai aao RECORDS += ao ai RECORDS += bo bi RECORDS += mbbo mbbi diff -cPr --exclude=CVS --exclude=old ../StreamDevice-2-1/src/Makefile ./src/Makefile *** ../StreamDevice-2-1/src/Makefile Mon May 29 14:21:18 2006 --- ./src/Makefile Mon Jun 12 10:49:03 2006 *************** *** 48,54 **** FORCE: # create stream.dbd from all RECORDS ! $(COMMON_DIR)/$(LIBRARY_DEFAULT).dbd: @for r in $(RECORDS); \ do echo "device($$r,INST_IO,dev$${r}Stream,\"stream\")"; \ done > $@ --- 48,54 ---- FORCE: # create stream.dbd from all RECORDS ! $(COMMON_DIR)/$(LIBRARY_DEFAULT).dbd: ../CONFIG_STREAM @for r in $(RECORDS); \ do echo "device($$r,INST_IO,dev$${r}Stream,\"stream\")"; \ done > $@ diff -cPr --exclude=CVS --exclude=old ../StreamDevice-2-1/src/devaaiStream.c ./src/devaaiStream.c *** ../StreamDevice-2-1/src/devaaiStream.c Thu Jan 1 01:00:00 1970 --- ./src/devaaiStream.c Mon Jun 12 10:54:08 2006 *************** *** 0 **** --- 1,301 ---- + /*************************************************************** + * StreamDevice record interface for aai records * + * * + * (C) 1999 Dirk Zimoch (zimoch@delta.uni-dortmund.de) * + * (C) 2006 Dirk Zimoch (dirk.zimoch@psi.ch) * + * * + * This is an EPICS record Interface for StreamDevice. * + * Please refer to the HTML files in ../doc/ for a detailed * + * documentation. * + * * + * If you do any changes in this file, you are not allowed to * + * redistribute it any more. If there is a bug or a missing * + * feature, send me an email and/or your patch. If I accept * + * your changes, they will go to the next release. * + * * + * DISCLAIMER: If this software breaks something or harms * + * someone, it's your problem. * + * * + ***************************************************************/ + + #include + #include + #include + #include + + static long readData (dbCommon *record, format_t *format) + { + aaiRecord *aai = (aaiRecord *) record; + double dval; + long lval; + + for (aai->nord = 0; aai->nord < aai->nelm; aai->nord++) + { + switch (format->type) + { + case DBF_DOUBLE: + { + if (streamScanf (record, format, &dval) != OK) + { + return aai->nord ? OK : ERROR; + } + switch (aai->ftvl) + { + case DBF_DOUBLE: + ((double *)aai->bptr)[aai->nord] = dval; + break; + case DBF_FLOAT: + ((float *)aai->bptr)[aai->nord] = dval; + break; + default: + errlogSevPrintf (errlogFatal, + "readData %s: can't convert from double to %s\n", + record->name, pamapdbfType[aai->ftvl].strvalue); + return ERROR; + } + break; + } + case DBF_LONG: + case DBF_ENUM: + { + if (streamScanf (record, format, &lval) != OK) + { + return aai->nord ? OK : ERROR; + } + switch (aai->ftvl) + { + case DBF_DOUBLE: + ((double *)aai->bptr)[aai->nord] = lval; + break; + case DBF_FLOAT: + ((float *)aai->bptr)[aai->nord] = lval; + break; + case DBF_LONG: + case DBF_ULONG: + ((long *)aai->bptr)[aai->nord] = lval; + break; + case DBF_SHORT: + case DBF_USHORT: + case DBF_ENUM: + ((short *)aai->bptr)[aai->nord] = lval; + break; + case DBF_CHAR: + case DBF_UCHAR: + ((char *)aai->bptr)[aai->nord] = lval; + break; + default: + errlogSevPrintf (errlogFatal, + "readData %s: can't convert from long to %s\n", + record->name, pamapdbfType[aai->ftvl].strvalue); + return ERROR; + } + break; + } + case DBF_STRING: + { + switch (aai->ftvl) + { + case DBF_STRING: + if (streamScanfN (record, format, + (char *)aai->bptr + aai->nord * MAX_STRING_SIZE, + MAX_STRING_SIZE) != OK) + { + return aai->nord ? OK : ERROR; + } + break; + case DBF_CHAR: + case DBF_UCHAR: + memset (aai->bptr, 0, aai->nelm); + aai->nord = 0; + if (streamScanfN (record, format, + (char *)aai->bptr, aai->nelm) != OK) + { + return ERROR; + } + ((char*)aai->bptr)[aai->nelm] = 0; + for (lval = aai->nelm; + lval >= 0 && ((char*)aai->bptr)[lval] == 0; + lval--); + aai->nord = lval+1; + return OK; + default: + errlogSevPrintf (errlogFatal, + "readData %s: can't convert from string to %s\n", + record->name, pamapdbfType[aai->ftvl].strvalue); + return ERROR; + } + break; + } + default: + { + errlogSevPrintf (errlogMajor, + "readData %s: can't convert from %s to %s\n", + record->name, pamapdbfType[format->type].strvalue, + pamapdbfType[aai->ftvl].strvalue); + return ERROR; + } + } + } + return OK; + } + + static long writeData (dbCommon *record, format_t *format) + { + aaiRecord *aai = (aaiRecord *) record; + double dval; + long lval; + unsigned long nowd; + + for (nowd = 0; nowd < aai->nord; nowd++) + { + switch (format->type) + { + case DBF_DOUBLE: + { + switch (aai->ftvl) + { + case DBF_DOUBLE: + dval = ((double *)aai->bptr)[nowd]; + break; + case DBF_FLOAT: + dval = ((float *)aai->bptr)[nowd]; + break; + case DBF_LONG: + dval = ((long *)aai->bptr)[nowd]; + break; + case DBF_ULONG: + dval = ((unsigned long *)aai->bptr)[nowd]; + break; + case DBF_SHORT: + dval = ((short *)aai->bptr)[nowd]; + break; + case DBF_USHORT: + case DBF_ENUM: + dval = ((unsigned short *)aai->bptr)[nowd]; + break; + case DBF_CHAR: + dval = ((char *)aai->bptr)[nowd]; + break; + case DBF_UCHAR: + dval = ((unsigned char *)aai->bptr)[nowd]; + break; + default: + errlogSevPrintf (errlogFatal, + "writeData %s: can't convert from %s to double\n", + record->name, pamapdbfType[aai->ftvl].strvalue); + return ERROR; + } + if (streamPrintf (record, format, dval)) + return ERROR; + break; + } + case DBF_LONG: + case DBF_ENUM: + { + switch (aai->ftvl) + { + case DBF_LONG: + case DBF_ULONG: + lval = ((long *)aai->bptr)[nowd]; + break; + case DBF_SHORT: + lval = ((short *)aai->bptr)[nowd]; + break; + case DBF_USHORT: + case DBF_ENUM: + lval = ((unsigned short *)aai->bptr)[nowd]; + break; + case DBF_CHAR: + lval = ((char *)aai->bptr)[nowd]; + break; + case DBF_UCHAR: + lval = ((unsigned char *)aai->bptr)[nowd]; + break; + default: + errlogSevPrintf (errlogFatal, + "writeData %s: can't convert from %s to long\n", + record->name, pamapdbfType[aai->ftvl].strvalue); + return ERROR; + } + if (streamPrintf (record, format, lval)) + return ERROR; + break; + } + case DBF_STRING: + { + switch (aai->ftvl) + { + case DBF_STRING: + if (streamPrintf (record, format, + ((char *)aai->bptr) + nowd * MAX_STRING_SIZE)) + return ERROR; + break; + case DBF_CHAR: + case DBF_UCHAR: + /* print aai as a null-terminated string */ + if (aai->nord < aai->nelm) + { + ((char *)aai->bptr)[aai->nord] = 0; + } + else + { + ((char *)aai->bptr)[aai->nelm-1] = 0; + } + if (streamPrintf (record, format, + ((char *)aai->bptr))) + return ERROR; + return OK; + default: + errlogSevPrintf (errlogFatal, + "writeData %s: can't convert from %s to string\n", + record->name, pamapdbfType[aai->ftvl].strvalue); + return ERROR; + } + break; + } + default: + { + errlogSevPrintf (errlogFatal, + "writeData %s: can't convert from %s to %s\n", + record->name, pamapdbfType[aai->ftvl].strvalue, + pamapdbfType[format->type].strvalue); + return ERROR; + } + } + } + return OK; + } + + static long initRecord (dbCommon *record) + { + static const int typesize[] = {MAX_STRING_SIZE,1,1,2,2,4,4,4,8,2}; + aaiRecord *aai = (aaiRecord *) record; + + aai->bptr = calloc(aai->nelm, typesize[aai->ftvl]); + if (aai->bptr == NULL) + { + errlogSevPrintf (errlogFatal, + "initRecord %s: can't allocate memory for data array\n", + record->name); + return ERROR; + } + return streamInitRecord (record, &aai->inp, readData, writeData); + } + + struct { + long number; + DEVSUPFUN report; + DEVSUPFUN init; + DEVSUPFUN init_record; + DEVSUPFUN get_ioint_info; + DEVSUPFUN read; + } devaaiStream = { + 5, + streamReport, + streamInit, + initRecord, + streamGetIointInfo, + streamRead + }; + + epicsExportAddress(dset,devaaiStream); diff -cPr --exclude=CVS --exclude=old ../StreamDevice-2-1/src/devaaoStream.c ./src/devaaoStream.c *** ../StreamDevice-2-1/src/devaaoStream.c Thu Jan 1 01:00:00 1970 --- ./src/devaaoStream.c Mon Jun 12 10:54:12 2006 *************** *** 0 **** --- 1,301 ---- + /*************************************************************** + * StreamDevice record interface for aao records * + * * + * (C) 1999 Dirk Zimoch (zimoch@delta.uni-dortmund.de) * + * (C) 2006 Dirk Zimoch (dirk.zimoch@psi.ch) * + * * + * This is an EPICS record Interface for StreamDevice. * + * Please refer to the HTML files in ../doc/ for a detailed * + * documentation. * + * * + * If you do any changes in this file, you are not allowed to * + * redistribute it any more. If there is a bug or a missing * + * feature, send me an email and/or your patch. If I accept * + * your changes, they will go to the next release. * + * * + * DISCLAIMER: If this software breaks something or harms * + * someone, it's your problem. * + * * + ***************************************************************/ + + #include + #include + #include + #include + + static long readData (dbCommon *record, format_t *format) + { + aaoRecord *aao = (aaoRecord *) record; + double dval; + long lval; + + for (aao->nord = 0; aao->nord < aao->nelm; aao->nord++) + { + switch (format->type) + { + case DBF_DOUBLE: + { + if (streamScanf (record, format, &dval) != OK) + { + return aao->nord ? OK : ERROR; + } + switch (aao->ftvl) + { + case DBF_DOUBLE: + ((double *)aao->bptr)[aao->nord] = dval; + break; + case DBF_FLOAT: + ((float *)aao->bptr)[aao->nord] = dval; + break; + default: + errlogSevPrintf (errlogFatal, + "readData %s: can't convert from double to %s\n", + record->name, pamapdbfType[aao->ftvl].strvalue); + return ERROR; + } + break; + } + case DBF_LONG: + case DBF_ENUM: + { + if (streamScanf (record, format, &lval) != OK) + { + return aao->nord ? OK : ERROR; + } + switch (aao->ftvl) + { + case DBF_DOUBLE: + ((double *)aao->bptr)[aao->nord] = lval; + break; + case DBF_FLOAT: + ((float *)aao->bptr)[aao->nord] = lval; + break; + case DBF_LONG: + case DBF_ULONG: + ((long *)aao->bptr)[aao->nord] = lval; + break; + case DBF_SHORT: + case DBF_USHORT: + case DBF_ENUM: + ((short *)aao->bptr)[aao->nord] = lval; + break; + case DBF_CHAR: + case DBF_UCHAR: + ((char *)aao->bptr)[aao->nord] = lval; + break; + default: + errlogSevPrintf (errlogFatal, + "readData %s: can't convert from long to %s\n", + record->name, pamapdbfType[aao->ftvl].strvalue); + return ERROR; + } + break; + } + case DBF_STRING: + { + switch (aao->ftvl) + { + case DBF_STRING: + if (streamScanfN (record, format, + (char *)aao->bptr + aao->nord * MAX_STRING_SIZE, + MAX_STRING_SIZE) != OK) + { + return aao->nord ? OK : ERROR; + } + break; + case DBF_CHAR: + case DBF_UCHAR: + memset (aao->bptr, 0, aao->nelm); + aao->nord = 0; + if (streamScanfN (record, format, + (char *)aao->bptr, aao->nelm) != OK) + { + return ERROR; + } + ((char*)aao->bptr)[aao->nelm] = 0; + for (lval = aao->nelm; + lval >= 0 && ((char*)aao->bptr)[lval] == 0; + lval--); + aao->nord = lval+1; + return OK; + default: + errlogSevPrintf (errlogFatal, + "readData %s: can't convert from string to %s\n", + record->name, pamapdbfType[aao->ftvl].strvalue); + return ERROR; + } + break; + } + default: + { + errlogSevPrintf (errlogMajor, + "readData %s: can't convert from %s to %s\n", + record->name, pamapdbfType[format->type].strvalue, + pamapdbfType[aao->ftvl].strvalue); + return ERROR; + } + } + } + return OK; + } + + static long writeData (dbCommon *record, format_t *format) + { + aaoRecord *aao = (aaoRecord *) record; + double dval; + long lval; + unsigned long nowd; + + for (nowd = 0; nowd < aao->nord; nowd++) + { + switch (format->type) + { + case DBF_DOUBLE: + { + switch (aao->ftvl) + { + case DBF_DOUBLE: + dval = ((double *)aao->bptr)[nowd]; + break; + case DBF_FLOAT: + dval = ((float *)aao->bptr)[nowd]; + break; + case DBF_LONG: + dval = ((long *)aao->bptr)[nowd]; + break; + case DBF_ULONG: + dval = ((unsigned long *)aao->bptr)[nowd]; + break; + case DBF_SHORT: + dval = ((short *)aao->bptr)[nowd]; + break; + case DBF_USHORT: + case DBF_ENUM: + dval = ((unsigned short *)aao->bptr)[nowd]; + break; + case DBF_CHAR: + dval = ((char *)aao->bptr)[nowd]; + break; + case DBF_UCHAR: + dval = ((unsigned char *)aao->bptr)[nowd]; + break; + default: + errlogSevPrintf (errlogFatal, + "writeData %s: can't convert from %s to double\n", + record->name, pamapdbfType[aao->ftvl].strvalue); + return ERROR; + } + if (streamPrintf (record, format, dval)) + return ERROR; + break; + } + case DBF_LONG: + case DBF_ENUM: + { + switch (aao->ftvl) + { + case DBF_LONG: + case DBF_ULONG: + lval = ((long *)aao->bptr)[nowd]; + break; + case DBF_SHORT: + lval = ((short *)aao->bptr)[nowd]; + break; + case DBF_USHORT: + case DBF_ENUM: + lval = ((unsigned short *)aao->bptr)[nowd]; + break; + case DBF_CHAR: + lval = ((char *)aao->bptr)[nowd]; + break; + case DBF_UCHAR: + lval = ((unsigned char *)aao->bptr)[nowd]; + break; + default: + errlogSevPrintf (errlogFatal, + "writeData %s: can't convert from %s to long\n", + record->name, pamapdbfType[aao->ftvl].strvalue); + return ERROR; + } + if (streamPrintf (record, format, lval)) + return ERROR; + break; + } + case DBF_STRING: + { + switch (aao->ftvl) + { + case DBF_STRING: + if (streamPrintf (record, format, + ((char *)aao->bptr) + nowd * MAX_STRING_SIZE)) + return ERROR; + break; + case DBF_CHAR: + case DBF_UCHAR: + /* print aao as a null-terminated string */ + if (aao->nord < aao->nelm) + { + ((char *)aao->bptr)[aao->nord] = 0; + } + else + { + ((char *)aao->bptr)[aao->nelm-1] = 0; + } + if (streamPrintf (record, format, + ((char *)aao->bptr))) + return ERROR; + return OK; + default: + errlogSevPrintf (errlogFatal, + "writeData %s: can't convert from %s to string\n", + record->name, pamapdbfType[aao->ftvl].strvalue); + return ERROR; + } + break; + } + default: + { + errlogSevPrintf (errlogFatal, + "writeData %s: can't convert from %s to %s\n", + record->name, pamapdbfType[aao->ftvl].strvalue, + pamapdbfType[format->type].strvalue); + return ERROR; + } + } + } + return OK; + } + + static long initRecord (dbCommon *record) + { + static const int typesize[] = {MAX_STRING_SIZE,1,1,2,2,4,4,4,8,2}; + aaoRecord *aao = (aaoRecord *) record; + + aao->bptr = calloc(aao->nelm, typesize[aao->ftvl]); + if (aao->bptr == NULL) + { + errlogSevPrintf (errlogFatal, + "initRecord %s: can't allocate memory for data array\n", + record->name); + return ERROR; + } + return streamInitRecord (record, &aao->out, readData, writeData); + } + + struct { + long number; + DEVSUPFUN report; + DEVSUPFUN init; + DEVSUPFUN init_record; + DEVSUPFUN get_ioint_info; + DEVSUPFUN read; + } devaaoStream = { + 5, + streamReport, + streamInit, + initRecord, + streamGetIointInfo, + streamWrite + }; + + epicsExportAddress(dset,devaaoStream); diff -cPr --exclude=CVS --exclude=old ../StreamDevice-2-1/srcSynApps/Makefile ./srcSynApps/Makefile *** ../StreamDevice-2-1/srcSynApps/Makefile Mon May 29 14:21:02 2006 --- ./srcSynApps/Makefile Mon Jun 12 10:49:27 2006 *************** *** 24,30 **** include $(TOP)/configure/RULES # create streamSynApps.dbd from all SYNAPPS_RECORDS ! $(COMMON_DIR)/$(LIBRARY_DEFAULT).dbd: @for r in $(SYNAPPS_RECORDS); \ do echo "device($$r,INST_IO,dev$${r}Stream,\"stream\")"; \ done > $@ --- 24,30 ---- include $(TOP)/configure/RULES # create streamSynApps.dbd from all SYNAPPS_RECORDS ! $(COMMON_DIR)/$(LIBRARY_DEFAULT).dbd: ../../src/CONFIG_STREAM @for r in $(SYNAPPS_RECORDS); \ do echo "device($$r,INST_IO,dev$${r}Stream,\"stream\")"; \ done > $@ diff -cPr --exclude=CVS --exclude=old ../StreamDevice-2-1/streamApp/Makefile ./streamApp/Makefile *** ../StreamDevice-2-1/streamApp/Makefile Mon May 29 14:21:32 2006 --- ./streamApp/Makefile Mon Jun 12 10:59:58 2006 *************** *** 8,13 **** --- 8,14 ---- DBD = streamApp.dbd streamApp_DBD += base.dbd + streamApp_DBD += aaiRecord.dbd aaoRecord.dbd PROD_SRCS += streamApp_registerRecordDeviceDriver.cpp PROD_SRCS_DEFAULT = streamAppMain.cc