47 char line[1024], *cptr, *cptr2;
48 int maxItemNameLength,numItems,len,i;
49 int value_offset, delta_index;
53 fin = fopen(filename,
"r");
56 printf(
"could not open itemlist %s\n",filename);
59 maxItemNameLength = numItems = 0;
60 while(fgets(line,
sizeof(line)-1,fin) != NULL)
62 if(line[0] >
' ' && line[0] !=
'#')
65 if(len > maxItemNameLength) maxItemNameLength = len;
74 fin = fopen(filename,
"r");
77 printf(
"could not open itemlist %s\n",filename);
84 if(ilong < numItems*delta_index)
86 printf(
"rlDataAcquisitionProvider::shared memmory is too small sharedMemorySize=%ld sizeNeeded=%d\n",
sharedMemorySize, (
int) (numItems*delta_index +
sizeof(
SHM_HEADER)));
90 while(fgets(line,
sizeof(line)-1,fin) != NULL)
92 if(line[0] >
' ' && line[0] !=
'#')
96 cptr2 = strchr(line,
'\n');
97 if(cptr2 != NULL) *cptr2 =
'\0';
98 cptr2 = strchr(line,
' ');
99 if(cptr2 != NULL) *cptr2 =
'\0';
100 cptr2 = strchr(line,
'\t');
101 if(cptr2 != NULL) *cptr2 =
'\0';
102 strcpy(cptr + (i*delta_index), line);
114 int value_offset, delta_index;
131 int value_offset, delta_index;
149 int value_offset, delta_index, nmax, i;
152 if(
shmheader == NULL)
return "DAQ_ERROR";
159 for(i=0; i<nmax; i++)
161 if(strcmp(cptr,variable) == 0)
163 return cptr + value_offset;
180 sscanf(cptr,
"%d",&ret);
192 if(isdigit(*cptr) || *cptr ==
'-')
195 sscanf(cptr,
"%f",&ret);
206 int value_offset, delta_index, nmax, i;
211 int len = strlen(value);
212 char *val =
new char[len+1];
221 for(i=0; i<nmax; i++)
223 if(strcmp(cptr,variable) == 0)
225 strcpy(cptr + value_offset, val);
236 strcpy(cptr, variable);
237 strcpy(cptr + value_offset, val);
244 ::printf(
"rlDataAcquisitionProvider: ERROR shared memory too small to add variable=%s val=%s please increase shared memory size", variable, val);
256 sprintf(cval,
"%d",value);
264 sprintf(cval,
"%f",value);
int intValue(const char *variable)
int setLifeCounter(int count)
int setIntValue(const char *variable, int value)
virtual ~rlDataAcquisitionProvider()
const char * stringValue(const char *variable)
int readItemList(const char *filename)
int setFloatValue(const char *variable, float value)
rlDataAcquisitionProvider(int maxNameLength=31, const char *shared_memory="c:\utomation\hm\ataacquisition.shm", long shared_memory_size=65536)
int setAllowAddValues(int allow, int maxItemNameLength)
int setReadErrorCount(int count)
float floatValue(const char *variable)
int setStringValue(const char *variable, const char *value)
int setWriteErrorCount(int count)