mbbo changes: use SHFT and MASK even with VAL (if no xxVL defined or ENUM format)
This commit is contained in:
@ -23,7 +23,7 @@ written or read value.
|
||||
<dd>
|
||||
Not allowed.
|
||||
</dd>
|
||||
<dt>LONG format (e.g. <code>%i</code>):</dt>
|
||||
<dt>LONG <span class=new>or ENUM</span> format (e.g. <code>%i</code>):</dt>
|
||||
<dd>
|
||||
<dl>
|
||||
<dt>If any of <code>ZRVL</code> ... <code>FFVL</code> is set
|
||||
@ -41,17 +41,12 @@ written or read value.
|
||||
</dd>
|
||||
<dt>If none of <code>ZRVL</code> ... <code>FFVL</code> is set
|
||||
(all are <code>0</code>):</dt>
|
||||
<dd>
|
||||
<u>Output:</u> <code><i>x</i>=VAL</code><br>
|
||||
<u>Input:</u> <code>VAL=<i>x</i></code><br>
|
||||
<dd class=new>
|
||||
<u>Output:</u> <code><i>x</i>=(VAL<<SHFT)&MASK</code><br>
|
||||
<u>Input:</u> <code>VAL=(RBV=(<i>x</i>&MASK))>>SHFT</code><br>
|
||||
</dd>
|
||||
</dl>
|
||||
</dd>
|
||||
<dt>ENUM format (e.g. <code>%{</code>):</dt>
|
||||
<dd>
|
||||
<u>Output:</u> <code><i>x</i>=VAL</code><br>
|
||||
<u>Input:</u> <code>VAL=<i>x</i></code><br>
|
||||
</dd>
|
||||
<dt>STRING format (e.g. <code>%s</code>):</dt>
|
||||
<dd>
|
||||
<u>Output:</u> Depending on <code>VAL</code>, one of <code>ZRST</code>
|
||||
|
@ -33,11 +33,12 @@ static long readData(dbCommon *record, format_t *format)
|
||||
{
|
||||
case DBF_ULONG:
|
||||
case DBF_LONG:
|
||||
case DBF_ENUM:
|
||||
{
|
||||
if (streamScanf(record, format, &val) == ERROR) return ERROR;
|
||||
if (mbbo->mask) val &= mbbo->mask;
|
||||
mbbo->rbv = val;
|
||||
mbbo->rval = val;
|
||||
if (mbbo->mask) val &= mbbo->mask;
|
||||
if (mbbo->shft > 0) val >>= mbbo->shft;
|
||||
/* read VAL or RBV? Look if any value is defined */
|
||||
if (mbbo->sdef)
|
||||
@ -56,12 +57,6 @@ static long readData(dbCommon *record, format_t *format)
|
||||
mbbo->val = (epicsEnum16)val;
|
||||
break;
|
||||
}
|
||||
case DBF_ENUM:
|
||||
{
|
||||
if (streamScanf(record, format, &val) == ERROR) return ERROR;
|
||||
mbbo->val = (epicsEnum16)val;
|
||||
break;
|
||||
}
|
||||
case DBF_STRING:
|
||||
{
|
||||
char buffer[sizeof(mbbo->zrst)];
|
||||
@ -110,39 +105,38 @@ static long writeData(dbCommon *record, format_t *format)
|
||||
switch (format->type)
|
||||
{
|
||||
case DBF_ULONG:
|
||||
case DBF_ENUM:
|
||||
/* print VAL or RVAL ? */
|
||||
val = mbbo->val;
|
||||
if (mbbo->shft > 0) val <<= mbbo->shft;
|
||||
if (mbbo->sdef) for (i=0; i<16; i++)
|
||||
{
|
||||
if ((&mbbo->zrvl)[i])
|
||||
{
|
||||
/* any values defined ? */
|
||||
val = mbbo->rval;
|
||||
if (mbbo->mask) val &= mbbo->mask;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (mbbo->mask) val &= mbbo->mask;
|
||||
return streamPrintf(record, format, val);
|
||||
case DBF_LONG:
|
||||
{
|
||||
/* print VAL or RVAL ? */
|
||||
val = (epicsInt16)mbbo->val;
|
||||
if (mbbo->shft > 0) val <<= mbbo->shft;
|
||||
if (mbbo->sdef) for (i=0; i<16; i++)
|
||||
{
|
||||
if ((&mbbo->zrvl)[i])
|
||||
{
|
||||
/* any values defined ? */
|
||||
val = (epicsInt32)mbbo->rval;
|
||||
if (mbbo->mask) val &= mbbo->mask;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (mbbo->mask) val &= mbbo->mask;
|
||||
return streamPrintf(record, format, val);
|
||||
}
|
||||
case DBF_ENUM:
|
||||
{
|
||||
return streamPrintf(record, format, mbbo->val);
|
||||
}
|
||||
case DBF_STRING:
|
||||
{
|
||||
if (mbbo->val >= 16) return ERROR;
|
||||
|
Reference in New Issue
Block a user