]> jspc29.x-matter.uni-frankfurt.de Git - daqdata.git/commitdiff
*** empty log message ***
authorhades <hades>
Tue, 3 Apr 2001 11:01:14 +0000 (11:01 +0000)
committerhades <hades>
Tue, 3 Apr 2001 11:01:14 +0000 (11:01 +0000)
allParam/ca/client/caParam.c
allParam/ca/server/paramBlobRecord.cc
allParam/ca/server/paramIntRecord.cc

index c7b163c5adf8aeef2dd047cc7c254f33638e5593..0e59eb072b9fdb9a8da1a0b17f46c42d517240e7 100644 (file)
@@ -462,28 +462,29 @@ static void Param_copyStringsToAllocMem(struct event_handler_args args)
 
 static void Param_copyIntsToAllocMem(struct event_handler_args args)
 {
-#if 1
-       int i;
-#endif
        ParamIntResult *result = args.usr;
-#if 0
        dbr_long_t *buffer = (dbr_long_t *) args.dbr;
-#endif
 
-       *(result->rows) = (args.count > result->maxrows) ?
-               result->maxrows :
-               args.count;
-       if(args.type == DBR_LONG && args.status == ECA_NORMAL) {
-               memcpy(result->val, (dbr_long_t *) args.dbr, (sizeof(dbr_long_t) * *(result->rows)));
-               for(i = 0 ; i < *(result->rows) ; i++) {
-#if 0
-                       (result->val)[i] = buffer[i];
-#endif
-                       fprintf(stderr, "val[%d] received: %ld\n", i, (result->val)[i]);
+       if (args.count == 1) {
+               *(result->rows) = 1;
+               if(args.type == DBR_LONG && args.status == ECA_NORMAL) {
+                       memcpy(result->val, buffer, sizeof(dbr_long_t));
+               } else {
+                       Param_strerror((Param *) result->my, ca_message(args.status));
+                       *(result->rows) = 0;
                }
        } else {
-               Param_strerror((Param *) result->my, ca_message(args.status));
-               *(result->rows) = 0;
+               if (args.count - 2 <= result->maxrows) {
+                       *(result->rows) = args.count - 2;
+               } else {
+                       *(result->rows) = result->maxrows;
+               }
+               if(args.type == DBR_LONG && args.status == ECA_NORMAL) {
+                       memcpy(result->val, buffer + 2, (sizeof(dbr_long_t) * *(result->rows)));
+               } else {
+                       Param_strerror((Param *) result->my, ca_message(args.status));
+                       *(result->rows) = 0;
+               }
        }
 }
 
index ed556e08cd84ba9f803af9d05a71b5aed1b15dc8..f663c662a0740f75d5abc1982203901da045c345 100644 (file)
@@ -73,12 +73,12 @@ gddAppFuncTableStatus ParamBlobRecord::readValue(gdd &value)
        if((retVal != 0) || (index == 0) || (index > EPICS_MAX_INDEX)) {
                return S_cas_noRead;
        } else {
-               aitUint32 *ourValue = new aitUint32[index];
-               *ourValue = size;
-               fread(ourValue + 1, sizeof(aitUint32), index - 1, blob);
+               aitUint32 *intValue = new aitUint32[index];
+               *intValue = size;
+               fread(intValue + 1, sizeof(aitUint32), index - 1, blob);
                fclose(blob);
 
-               value.putRef(ourValue);
+               value.putRef(intValue);
        }
 
        return S_casApp_success;
@@ -98,14 +98,14 @@ caStatus ParamBlobRecord::scan()
        if((retVal != 0) || (index == 0) || (index > EPICS_MAX_INDEX)) {
                return S_cas_noRead;
        } else {
-               aitUint32 *ourValue = new aitUint32[index];
-               *ourValue = size;
-               fread(ourValue + 1, sizeof(aitUint32), index - 1, blob);
+               aitUint32 *intValue = new aitUint32[index];
+               *intValue = size;
+               fread(intValue + 1, sizeof(aitUint32), index - 1, blob);
                fclose(blob);
 
-               val = new gddAtomic(gddAppType_value, aitEnumString, 1, index);
+               val = new gddAtomic(gddAppType_value, aitEnumUint32, 1, index);
 
-               val->putRef(ourValue, pDest);
+               val->putRef(intValue, pDest);
        }
 
        val->setStat(epicsAlarmNone);
index af1ce82f4e3a95b9ee6a7fd6560379d508050ae7..fb8bb8851a90c76520be810affa1f6a34b43fa6a 100644 (file)
@@ -13,7 +13,11 @@ ParamIntRecord::ParamIntRecord(caServer& cas, const Param *p, const char *rn, co
        unsigned long int tmp[PARAM_MAX_ARRAY_LEN];
 
        if(Param_getIntArray(param, name, idx, PARAM_MAX_ARRAY_LEN, &rows, tmp) == 0) {
-               index = rows == 0 ? 1 : (unsigned int) rows;
+               if ((rows == 0) || (rows == 1)) {
+                       index = 1;
+               } else {
+                       index = (unsigned int) rows + 2;
+               }
        } else {
                index = 1;
        }
@@ -61,24 +65,20 @@ gddAppFuncTableStatus ParamIntRecord::readValue(gdd &value)
        int retVal;
 
        retVal = Param_getIntArray(param, name, idx, PARAM_MAX_ARRAY_LEN, &rows, ourValue);
-       index = (unsigned int) rows;
-       if((retVal != 0) || (index == 0)) {
+       if((retVal != 0) || (rows == 0)) {
                index = 1;
                return S_cas_noRead;
-       } else if(index == 1) {
+       } else if(rows == 1) {
+               index = 1;
                aitUint32 intValue;
 
                intValue = ourValue[0];
 
                value.putConvert(intValue);
        } else {
+               index = (unsigned int) rows + 2;
                aitUint32 *intValue = new aitUint32[index];
-               for (unsigned int k = 0 ; k < index ; k++) {
-                       intValue[k] = ourValue[k];
-#if 0
-                       fprintf(stderr, "intValue[%d] put: %d\n", k, intValue[k]);
-#endif
-               }
+               memcpy(intValue + 2, ourValue, sizeof(aitUint32) * (index - 2));
 
                value.putRef(intValue);
                delete [] intValue;
@@ -95,25 +95,22 @@ caStatus ParamIntRecord::scan()
        ArrayDestructor *pDest = new ArrayDestructor;
 
        retVal = Param_getIntArray(param, name, idx, PARAM_MAX_ARRAY_LEN, &rows, ourValue);
-       index = (unsigned int) rows;
-       if((retVal != 0) || (index == 0)) {
+       if((retVal != 0) || (rows == 0)) {
                index = 1;
                return S_cas_noRead;
-       } else if(index == 1) {
+       } else if(rows == 1) {
+               index = 1;
                aitUint32 intValue;
+
                val = new gddScalar(gddAppType_value, aitEnumUint32);
 
                intValue = ourValue[0];
 
                val->putConvert(intValue);
        } else {
+               index = (unsigned int) rows + 2;
                aitUint32 *intValue = new aitUint32[index];
-               for (unsigned int k = 0 ; k < index  ; k++) {
-                       intValue[k] = ourValue[k];
-#if 1
-                       fprintf(stderr, "intValue[%d] put: %d\n", k, intValue[k]);
-#endif
-               }
+               memcpy(intValue + 2, ourValue, sizeof(aitUint32) * (index - 2));
 
                val = new gddAtomic(gddAppType_value, aitEnumUint32, 1, index);