make compatible to 3.14.8- and remove duplicate code

This commit is contained in:
2017-01-25 15:28:46 +01:00
parent 31189ebecf
commit d22e1a5f4a
2 changed files with 30 additions and 33 deletions

View File

@ -18,7 +18,6 @@
* *
***************************************************************/
#include <menuConvert.h>
#include <aiRecord.h>
#include "devStream.h"
#ifdef EPICS_3_13
@ -33,19 +32,14 @@
static long readData (dbCommon *record, format_t *format)
{
aiRecord *ai = (aiRecord *) record;
double val;
switch (format->type)
{
case DBF_DOUBLE:
{
double val;
if (streamScanf (record, format, &val)) return ERROR;
if (ai->aslo != 0.0 && ai->aslo != 1.0) val *= ai->aslo;
val += ai->aoff;
if (!(ai->smoo == 0.0 || ai->init || ai->udf || isinf(ai->val) || isnan(ai->val)))
val = ai->val * ai->smoo + val * (1.0 - ai->smoo);
ai->val = val;
return DO_NOT_CONVERT;
break;
}
case DBF_ULONG:
case DBF_LONG:
@ -53,51 +47,56 @@ static long readData (dbCommon *record, format_t *format)
long rval;
if (streamScanf (record, format, &rval)) return ERROR;
ai->rval = rval;
if (ai->linr == menuConvertNO_CONVERSION)
if (ai->linr == 0)
{
/* allow integers with more than 32 bits */
double val;
if (format->type == DBF_ULONG)
val = (unsigned long)rval;
else
val = rval;
if (ai->aslo != 0.0 && ai->aslo != 1.0) val *= ai->aslo;
ai->val = val + ai->aoff;
return DO_NOT_CONVERT;
break;
}
return OK;
}
default:
return ERROR;
}
return ERROR;
if (ai->aslo != 0.0 && ai->aslo != 1.0) val *= ai->aslo;
val += ai->aoff;
if (!(ai->smoo == 0.0 || ai->init || ai->udf || isinf(ai->val) || isnan(ai->val)))
val = ai->val * ai->smoo + val * (1.0 - ai->smoo);
ai->val = val;
return DO_NOT_CONVERT;
}
static long writeData (dbCommon *record, format_t *format)
{
aiRecord *ai = (aiRecord *) record;
double val = ai->val - ai->aoff;
if (ai->aslo != 0.0 && ai->aslo != 1.0) val /= ai->aslo;
switch (format->type)
{
case DBF_DOUBLE:
{
double val = ai->val - ai->aoff;
if (ai->aslo != 0.0 && ai->aslo != 1.0) val /= ai->aslo;
return streamPrintf (record, format, val);
}
case DBF_ULONG:
{
if (ai->linr == menuConvertNO_CONVERSION)
if (ai->linr == 0)
{
/* allow more bits than 32 */
return streamPrintf (record, format, (unsigned long)ai->val);
return streamPrintf (record, format, (unsigned long)val);
}
return streamPrintf (record, format, (unsigned long)ai->rval);
}
case DBF_LONG:
{
if (ai->linr == menuConvertNO_CONVERSION)
if (ai->linr == 0)
{
/* allow more bits than 32 */
return streamPrintf (record, format, (long)ai->val);
return streamPrintf (record, format, (long)val);
}
return streamPrintf (record, format, (long)ai->rval);
}

View File

@ -18,7 +18,6 @@
* *
***************************************************************/
#include <menuConvert.h>
#include <aoRecord.h>
#include "devStream.h"
#include <epicsExport.h>
@ -26,16 +25,14 @@
static long readData (dbCommon *record, format_t *format)
{
aoRecord *ao = (aoRecord *) record;
double val;
switch (format->type)
{
case DBF_DOUBLE:
{
double val;
if (streamScanf (record, format, &val)) return ERROR;
if (ao->aslo != 0.0 && ao->aslo != 1.0) val *= ao->aslo;
ao->val = val + ao->aoff;
return DO_NOT_CONVERT;
break;
}
case DBF_ULONG:
case DBF_LONG:
@ -44,22 +41,23 @@ static long readData (dbCommon *record, format_t *format)
if (streamScanf (record, format, &rval)) return ERROR;
ao->rbv = rval;
ao->rval = rval;
if (ao->linr == menuConvertNO_CONVERSION)
if (ao->linr == 0)
{
/* allow integers with more than 32 bits */
double val;
if (format->type == DBF_ULONG)
val = (unsigned long)rval;
else
val = rval;
if (ao->aslo != 0.0 && ao->aslo != 1.0) val *= ao->aslo;
ao->val = val + ao->aoff;
return DO_NOT_CONVERT;
break;
}
return OK;
}
default:
return ERROR;
}
return ERROR;
if (ao->aslo != 0.0 && ao->aslo != 1.0) val *= ao->aslo;
ao->val = val + ao->aoff;
return DO_NOT_CONVERT;
}
static long writeData (dbCommon *record, format_t *format)
@ -77,7 +75,7 @@ static long writeData (dbCommon *record, format_t *format)
}
case DBF_ULONG:
{
if (ao->linr == menuConvertNO_CONVERSION)
if (ao->linr == 0)
{
/* allow integers with more than 32 bits */
return streamPrintf (record, format, (unsigned long)val);
@ -86,7 +84,7 @@ static long writeData (dbCommon *record, format_t *format)
}
case DBF_LONG:
{
if (ao->linr == menuConvertNO_CONVERSION)
if (ao->linr == 0)
{
/* allow integers with more than 32 bits */
return streamPrintf (record, format, (long)val);