From c8fcfbea9f40941111d4fea298101aa0c8079863 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Sat, 27 May 2017 20:35:53 -0500 Subject: [PATCH] Convert all Async Soft Channel input devices to use link support --- src/std/dev/devAiSoftCallback.c | 35 ++++++++++------------- src/std/dev/devBiSoftCallback.c | 34 +++++++++-------------- src/std/dev/devI64inSoftCallback.c | 32 ++++++++------------- src/std/dev/devLiSoftCallback.c | 34 +++++++++-------------- src/std/dev/devMbbiDirectSoftCallback.c | 34 +++++++++-------------- src/std/dev/devMbbiSoftCallback.c | 34 +++++++++-------------- src/std/dev/devSiSoftCallback.c | 37 ++++++++++--------------- 7 files changed, 93 insertions(+), 147 deletions(-) diff --git a/src/std/dev/devAiSoftCallback.c b/src/std/dev/devAiSoftCallback.c index cd3b7fc41..cf38c8713 100644 --- a/src/std/dev/devAiSoftCallback.c +++ b/src/std/dev/devAiSoftCallback.c @@ -4,7 +4,7 @@ * Copyright (c) 2002 The Regents of the University of California, as * Operator of Los Alamos National Laboratory. * EPICS BASE is distributed subject to a Software License Agreement found -* in file LICENSE that is included with this distribution. +* in file LICENSE that is included with this distribution. \*************************************************************************/ /* devAiSoftCallback.c */ /* @@ -80,10 +80,11 @@ static long add_record(dbCommon *pcommon) devPvt *pdevPvt; processNotify *ppn; - if (plink->type == CONSTANT) return 0; + if (dbLinkIsDefined(plink) && dbLinkIsConstant(plink)) + return 0; if (plink->type != PV_LINK) { - long status = S_db_badField; + long status = S_db_badField; recGblRecordError(status, (void *)prec, "devAiSoftCallback (add_record) Illegal INP field"); @@ -92,7 +93,7 @@ static long add_record(dbCommon *pcommon) chan = dbChannelCreate(plink->value.pv_link.pvname); if (!chan) { - long status = S_db_notFound; + long status = S_db_notFound; recGblRecordError(status, (void *)prec, "devAiSoftCallback (add_record) link target not found"); @@ -129,7 +130,9 @@ static long del_record(dbCommon *pcommon) { DBLINK *plink = &prec->inp; devPvt *pdevPvt = (devPvt *)prec->dpvt; - if (plink->type == CONSTANT) return 0; + if (dbLinkIsDefined(plink) && dbLinkIsConstant(plink)) + return 0; + assert(plink->type == PN_LINK); dbNotifyCancel(&pdevPvt->pn); @@ -152,21 +155,9 @@ static long init(int pass) static long init_record(aiRecord *prec) { - /* INP must be CONSTANT or PN_LINK */ - switch (prec->inp.type) { - case CONSTANT: - if (recGblInitConstantLink(&prec->inp, DBF_DOUBLE, &prec->val)) - prec->udf = FALSE; - break; - case PN_LINK: - /* Handled by add_record */ - break; - default: - recGblRecordError(S_db_badField, (void *)prec, - "devAiSoftCallback (init_record) Illegal INP field"); - prec->pact = TRUE; - return S_db_badField; - } + if (recGblInitConstantLink(&prec->inp, DBF_DOUBLE, &prec->val)) + prec->udf = FALSE; + return 0; } @@ -195,6 +186,7 @@ static long read_ai(aiRecord *prec) pdevPvt->buffer.value * (1.0 - prec->smoo); else prec->val = pdevPvt->buffer.value; + prec->udf = FALSE; pdevPvt->smooth = TRUE; @@ -214,9 +206,10 @@ static long read_ai(aiRecord *prec) break; } - if (prec->tsel.type == CONSTANT && + if (dbLinkIsConstant(&prec->tsel) && prec->tse == epicsTimeEventDeviceTime) prec->time = pdevPvt->buffer.time; + return 2; } diff --git a/src/std/dev/devBiSoftCallback.c b/src/std/dev/devBiSoftCallback.c index 67c15260c..314460049 100644 --- a/src/std/dev/devBiSoftCallback.c +++ b/src/std/dev/devBiSoftCallback.c @@ -4,7 +4,7 @@ * Copyright (c) 2002 The Regents of the University of California, as * Operator of Los Alamos National Laboratory. * EPICS BASE is distributed subject to a Software License Agreement found -* in file LICENSE that is included with this distribution. +* in file LICENSE that is included with this distribution. \*************************************************************************/ /* devBiSoftCallback.c */ /* @@ -78,10 +78,11 @@ static long add_record(dbCommon *pcommon) devPvt *pdevPvt; processNotify *ppn; - if (plink->type == CONSTANT) return 0; + if (dbLinkIsDefined(plink) && dbLinkIsConstant(plink)) + return 0; if (plink->type != PV_LINK) { - long status = S_db_badField; + long status = S_db_badField; recGblRecordError(status, (void *)prec, "devBiSoftCallback (add_record) Illegal INP field"); @@ -90,7 +91,7 @@ static long add_record(dbCommon *pcommon) chan = dbChannelCreate(plink->value.pv_link.pvname); if (!chan) { - long status = S_db_notFound; + long status = S_db_notFound; recGblRecordError(status, (void *)prec, "devBiSoftCallback (add_record) link target not found"); @@ -127,7 +128,9 @@ static long del_record(dbCommon *pcommon) { DBLINK *plink = &prec->inp; devPvt *pdevPvt = (devPvt *)prec->dpvt; - if (plink->type == CONSTANT) return 0; + if (dbLinkIsDefined(plink) && dbLinkIsConstant(plink)) + return 0; + assert(plink->type == PN_LINK); dbNotifyCancel(&pdevPvt->pn); @@ -150,21 +153,9 @@ static long init(int pass) static long init_record(biRecord *prec) { - /* INP must be CONSTANT or PN_LINK */ - switch (prec->inp.type) { - case CONSTANT: - if (recGblInitConstantLink(&prec->inp, DBR_ENUM, &prec->val)) - prec->udf = FALSE; - break; - case PN_LINK: - /* Handled by add_record */ - break; - default: - recGblRecordError(S_db_badField, (void *)prec, - "devBiSoftCallback (init_record) Illegal INP field"); - prec->pact = TRUE; - return S_db_badField; - } + if (recGblInitConstantLink(&prec->inp, DBR_ENUM, &prec->val)) + prec->udf = FALSE; + return 0; } @@ -205,9 +196,10 @@ static long read_bi(biRecord *prec) break; } - if (prec->tsel.type == CONSTANT && + if (dbLinkIsConstant(&prec->tsel) && prec->tse == epicsTimeEventDeviceTime) prec->time = pdevPvt->buffer.time; + return 2; } diff --git a/src/std/dev/devI64inSoftCallback.c b/src/std/dev/devI64inSoftCallback.c index 8c9e77896..baa05fdcc 100644 --- a/src/std/dev/devI64inSoftCallback.c +++ b/src/std/dev/devI64inSoftCallback.c @@ -78,10 +78,11 @@ static long add_record(dbCommon *pcommon) devPvt *pdevPvt; processNotify *ppn; - if (plink->type == CONSTANT) return 0; + if (dbLinkIsDefined(plink) && dbLinkIsConstant(plink)) + return 0; if (plink->type != PV_LINK) { - long status = S_db_badField; + long status = S_db_badField; recGblRecordError(status, (void *)prec, "devI64inSoftCallback (add_record) Illegal INP field"); @@ -90,7 +91,7 @@ static long add_record(dbCommon *pcommon) chan = dbChannelCreate(plink->value.pv_link.pvname); if (!chan) { - long status = S_db_notFound; + long status = S_db_notFound; recGblRecordError(status, (void *)prec, "devI64inSoftCallback (init_record) linked record not found"); @@ -127,7 +128,9 @@ static long del_record(dbCommon *pcommon) { DBLINK *plink = &prec->inp; devPvt *pdevPvt = (devPvt *)prec->dpvt; - if (plink->type == CONSTANT) return 0; + if (dbLinkIsDefined(plink) && dbLinkIsConstant(plink)) + return 0; + assert(plink->type == PN_LINK); dbNotifyCancel(&pdevPvt->pn); @@ -150,21 +153,9 @@ static long init(int pass) static long init_record(int64inRecord *prec) { - /* INP must be CONSTANT or PN_LINK */ - switch (prec->inp.type) { - case CONSTANT: - if (recGblInitConstantLink(&prec->inp, DBR_INT64, &prec->val)) - prec->udf = FALSE; - break; - case PN_LINK: - /* Handled by add_record */ - break; - default: - recGblRecordError(S_db_badField, (void *)prec, - "devI64inSoftCallback (init_record) Illegal INP field"); - prec->pact = TRUE; - return S_db_badField; - } + if (recGblInitConstantLink(&prec->inp, DBR_INT64, &prec->val)) + prec->udf = FALSE; + return 0; } @@ -205,9 +196,10 @@ static long read_int64in(int64inRecord *prec) break; } - if (prec->tsel.type == CONSTANT && + if (dbLinkIsConstant(&prec->tsel) && prec->tse == epicsTimeEventDeviceTime) prec->time = pdevPvt->buffer.time; + return 0; } diff --git a/src/std/dev/devLiSoftCallback.c b/src/std/dev/devLiSoftCallback.c index 5530e7089..caab523e5 100644 --- a/src/std/dev/devLiSoftCallback.c +++ b/src/std/dev/devLiSoftCallback.c @@ -4,7 +4,7 @@ * Copyright (c) 2002 The Regents of the University of California, as * Operator of Los Alamos National Laboratory. * EPICS BASE is distributed subject to a Software License Agreement found -* in file LICENSE that is included with this distribution. +* in file LICENSE that is included with this distribution. \*************************************************************************/ /* devLiSoftCallback.c */ /* @@ -78,10 +78,11 @@ static long add_record(dbCommon *pcommon) devPvt *pdevPvt; processNotify *ppn; - if (plink->type == CONSTANT) return 0; + if (dbLinkIsDefined(plink) && dbLinkIsConstant(plink)) + return 0; if (plink->type != PV_LINK) { - long status = S_db_badField; + long status = S_db_badField; recGblRecordError(status, (void *)prec, "devLiSoftCallback (add_record) Illegal INP field"); @@ -90,7 +91,7 @@ static long add_record(dbCommon *pcommon) chan = dbChannelCreate(plink->value.pv_link.pvname); if (!chan) { - long status = S_db_notFound; + long status = S_db_notFound; recGblRecordError(status, (void *)prec, "devLiSoftCallback (init_record) linked record not found"); @@ -127,7 +128,9 @@ static long del_record(dbCommon *pcommon) { DBLINK *plink = &prec->inp; devPvt *pdevPvt = (devPvt *)prec->dpvt; - if (plink->type == CONSTANT) return 0; + if (dbLinkIsDefined(plink) && dbLinkIsConstant(plink)) + return 0; + assert(plink->type == PN_LINK); dbNotifyCancel(&pdevPvt->pn); @@ -150,21 +153,9 @@ static long init(int pass) static long init_record(longinRecord *prec) { - /* INP must be CONSTANT or PN_LINK */ - switch (prec->inp.type) { - case CONSTANT: - if (recGblInitConstantLink(&prec->inp, DBR_LONG, &prec->val)) - prec->udf = FALSE; - break; - case PN_LINK: - /* Handled by add_record */ - break; - default: - recGblRecordError(S_db_badField, (void *)prec, - "devLiSoftCallback (init_record) Illegal INP field"); - prec->pact = TRUE; - return S_db_badField; - } + if (recGblInitConstantLink(&prec->inp, DBR_LONG, &prec->val)) + prec->udf = FALSE; + return 0; } @@ -205,9 +196,10 @@ static long read_li(longinRecord *prec) break; } - if (prec->tsel.type == CONSTANT && + if (dbLinkIsConstant(&prec->tsel) && prec->tse == epicsTimeEventDeviceTime) prec->time = pdevPvt->buffer.time; + return 0; } diff --git a/src/std/dev/devMbbiDirectSoftCallback.c b/src/std/dev/devMbbiDirectSoftCallback.c index cfcce0ffe..93016329f 100644 --- a/src/std/dev/devMbbiDirectSoftCallback.c +++ b/src/std/dev/devMbbiDirectSoftCallback.c @@ -4,7 +4,7 @@ * Copyright (c) 2002 The Regents of the University of California, as * Operator of Los Alamos National Laboratory. * EPICS BASE is distributed subject to a Software License Agreement found -* in file LICENSE that is included with this distribution. +* in file LICENSE that is included with this distribution. \*************************************************************************/ /* devMbbiDirectSoftCallback.c */ /* @@ -78,10 +78,11 @@ static long add_record(dbCommon *pcommon) devPvt *pdevPvt; processNotify *ppn; - if (plink->type == CONSTANT) return 0; + if (dbLinkIsDefined(plink) && dbLinkIsConstant(plink)) + return 0; if (plink->type != PV_LINK) { - long status = S_db_badField; + long status = S_db_badField; recGblRecordError(status, (void *)prec, "devMbbiDirectSoftCallback (add_record) Illegal INP field"); @@ -90,7 +91,7 @@ static long add_record(dbCommon *pcommon) chan = dbChannelCreate(plink->value.pv_link.pvname); if (!chan) { - long status = S_db_notFound; + long status = S_db_notFound; recGblRecordError(status,(void *)prec, "devMbbiDirectSoftCallback (add_record) linked record not found"); @@ -127,7 +128,9 @@ static long del_record(dbCommon *pcommon) { DBLINK *plink = &prec->inp; devPvt *pdevPvt = (devPvt *)prec->dpvt; - if (plink->type == CONSTANT) return 0; + if (dbLinkIsDefined(plink) && dbLinkIsConstant(plink)) + return 0; + assert(plink->type == PN_LINK); dbNotifyCancel(&pdevPvt->pn); @@ -150,21 +153,9 @@ static long init(int pass) static long init_record(mbbiDirectRecord *prec) { - /* INP must be CONSTANT or PN_LINK */ - switch (prec->inp.type) { - case CONSTANT: - if (recGblInitConstantLink(&prec->inp, DBR_ENUM, &prec->val)) - prec->udf = FALSE; - break; - case PN_LINK: - /* Handled by add_record */ - break; - default: - recGblRecordError(S_db_badField, (void *)prec, - "devMbbiSoftCallback (init_record) Illegal INP field"); - prec->pact = TRUE; - return S_db_badField; - } + if (recGblInitConstantLink(&prec->inp, DBR_ENUM, &prec->val)) + prec->udf = FALSE; + return 0; } @@ -205,9 +196,10 @@ static long read_mbbiDirect(mbbiDirectRecord *prec) break; } - if (prec->tsel.type == CONSTANT && + if (dbLinkIsConstant(&prec->tsel) && prec->tse == epicsTimeEventDeviceTime) prec->time = pdevPvt->buffer.time; + return 2; } diff --git a/src/std/dev/devMbbiSoftCallback.c b/src/std/dev/devMbbiSoftCallback.c index fee8d30f0..3796bcee6 100644 --- a/src/std/dev/devMbbiSoftCallback.c +++ b/src/std/dev/devMbbiSoftCallback.c @@ -4,7 +4,7 @@ * Copyright (c) 2002 The Regents of the University of California, as * Operator of Los Alamos National Laboratory. * EPICS BASE is distributed subject to a Software License Agreement found -* in file LICENSE that is included with this distribution. +* in file LICENSE that is included with this distribution. \*************************************************************************/ /* devMbbiSoftCallback.c */ /* @@ -78,10 +78,11 @@ static long add_record(dbCommon *pcommon) devPvt *pdevPvt; processNotify *ppn; - if (plink->type == CONSTANT) return 0; + if (dbLinkIsDefined(plink) && dbLinkIsConstant(plink)) + return 0; if (plink->type != PV_LINK) { - long status = S_db_badField; + long status = S_db_badField; recGblRecordError(status, (void *)prec, "devMbbiSoftCallback (add_record) Illegal INP field"); @@ -90,7 +91,7 @@ static long add_record(dbCommon *pcommon) chan = dbChannelCreate(plink->value.pv_link.pvname); if (!chan) { - long status = S_db_notFound; + long status = S_db_notFound; recGblRecordError(status, (void *)prec, "devMbbiSoftCallback (add_record) linked record not found"); @@ -127,7 +128,9 @@ static long del_record(dbCommon *pcommon) { DBLINK *plink = &prec->inp; devPvt *pdevPvt = (devPvt *)prec->dpvt; - if (plink->type == CONSTANT) return 0; + if (dbLinkIsDefined(plink) && dbLinkIsConstant(plink)) + return 0; + assert(plink->type == PN_LINK); dbNotifyCancel(&pdevPvt->pn); @@ -150,21 +153,9 @@ static long init(int pass) static long init_record(mbbiRecord *prec) { - /* INP must be CONSTANT or PN_LINK */ - switch (prec->inp.type) { - case CONSTANT: - if (recGblInitConstantLink(&prec->inp, DBR_ENUM, &prec->val)) - prec->udf = FALSE; - break; - case PN_LINK: - /* Handled by add_record */ - break; - default: - recGblRecordError(S_db_badField, (void *)prec, - "devMbbiSoftCallback (init_record) Illegal INP field"); - prec->pact = TRUE; - return S_db_badField; - } + if (recGblInitConstantLink(&prec->inp, DBR_ENUM, &prec->val)) + prec->udf = FALSE; + return 0; } @@ -205,9 +196,10 @@ static long read_mbbi(mbbiRecord *prec) break; } - if (prec->tsel.type == CONSTANT && + if (dbLinkIsConstant(&prec->tsel) && prec->tse == epicsTimeEventDeviceTime) prec->time = pdevPvt->buffer.time; + return 2; } diff --git a/src/std/dev/devSiSoftCallback.c b/src/std/dev/devSiSoftCallback.c index 715754218..8f679889e 100644 --- a/src/std/dev/devSiSoftCallback.c +++ b/src/std/dev/devSiSoftCallback.c @@ -4,7 +4,7 @@ * Copyright (c) 2002 The Regents of the University of California, as * Operator of Los Alamos National Laboratory. * EPICS BASE is distributed subject to a Software License Agreement found -* in file LICENSE that is included with this distribution. +* in file LICENSE that is included with this distribution. \*************************************************************************/ /* devSiSoftCallback.c */ /* @@ -80,10 +80,11 @@ static long add_record(dbCommon *pcommon) devPvt *pdevPvt; processNotify *ppn; - if (plink->type == CONSTANT) return 0; + if (dbLinkIsDefined(plink) && dbLinkIsConstant(plink)) + return 0; if (plink->type != PV_LINK) { - long status = S_db_badField; + long status = S_db_badField; recGblRecordError(status, (void *)prec, "devSiSoftCallback (add_record) Illegal INP field"); @@ -92,7 +93,7 @@ static long add_record(dbCommon *pcommon) pdevPvt = calloc(1, sizeof(*pdevPvt)); if (!pdevPvt) { - long status = S_db_noMemory; + long status = S_db_noMemory; recGblRecordError(status, (void *)prec, "devSiSoftCallback (add_record) out of memory, calloc() failed"); @@ -102,7 +103,7 @@ static long add_record(dbCommon *pcommon) chan = dbChannelCreate(plink->value.pv_link.pvname); if (!chan) { - long status = S_db_notFound; + long status = S_db_notFound; recGblRecordError(status, (void *)prec, "devSiSoftCallback (add_record) linked record not found"); @@ -129,7 +130,9 @@ static long del_record(dbCommon *pcommon) { DBLINK *plink = &prec->inp; devPvt *pdevPvt = (devPvt *)prec->dpvt; - if (plink->type == CONSTANT) return 0; + if (dbLinkIsDefined(plink) && dbLinkIsConstant(plink)) + return 0; + assert(plink->type == PN_LINK); dbNotifyCancel(&pdevPvt->pn); @@ -152,21 +155,9 @@ static long init(int pass) static long init_record(stringinRecord *prec) { - /* INP must be CONSTANT or PN_LINK */ - switch (prec->inp.type) { - case CONSTANT: - if (recGblInitConstantLink(&prec->inp, DBR_STRING, &prec->val)) - prec->udf = FALSE; - break; - case PN_LINK: - /* Handled by add_record */ - break; - default: - recGblRecordError(S_db_badField, (void *)prec, - "devSiSoftCallback (init_record) Illegal INP field"); - prec->pact = TRUE; - return S_db_badField; - } + if (recGblInitConstantLink(&prec->inp, DBR_STRING, &prec->val)) + prec->udf = FALSE; + return 0; } @@ -187,6 +178,7 @@ static long read_si(stringinRecord *prec) recGblSetSevr(prec, READ_ALARM, INVALID_ALARM); return pdevPvt->status; } + strncpy(prec->val, pdevPvt->buffer.value, MAX_STRING_SIZE); prec->val[MAX_STRING_SIZE-1] = 0; prec->udf = FALSE; @@ -207,9 +199,10 @@ static long read_si(stringinRecord *prec) break; } - if (prec->tsel.type == CONSTANT && + if (dbLinkIsConstant(&prec->tsel) && prec->tse == epicsTimeEventDeviceTime) prec->time = pdevPvt->buffer.time; + return 0; }