Convert INST_IO links to regular PV_LINK types, for VDCT support.

Added new PN_LINK type in link.h, make dbStaticLib display it.
Made all device support extended so links can be changed at runtime.
Modified startup so add_record() always called before regular link processing.
Incomplete, stilll need to add MS/MSS/MSI support, currently disabled.
This commit is contained in:
Andrew Johnson
2010-01-07 23:48:49 -06:00
parent c6da34286e
commit f7d02cc2a8
12 changed files with 812 additions and 477 deletions

View File

@@ -1,5 +1,5 @@
/*************************************************************************\
* Copyright (c) 2002 The University of Chicago, as Operator of Argonne
* Copyright (c) 2010 UChicago Argonne LLC, as Operator of Argonne
* National Laboratory.
* Copyright (c) 2002 The Regents of the University of California, as
* Operator of Los Alamos National Laboratory.
@@ -8,8 +8,7 @@
\*************************************************************************/
/* devSiSoftCallback.c */
/*
* Author: Marty Kraimer
* Date: 23APR2008
* Authors: Marty Kraimer & Andrew Johnson
*/
#include <stdlib.h>
@@ -19,6 +18,7 @@
#include "alarm.h"
#include "callback.h"
#include "cantProceed.h"
#include "dbCommon.h"
#include "dbDefs.h"
#include "dbAccess.h"
#include "dbNotify.h"
@@ -29,54 +29,34 @@
#include "stringinRecord.h"
#include "epicsExport.h"
/* Create the dset for devSiSoftCallback */
static long init_record();
static long read_stringin();
struct {
long number;
DEVSUPFUN report;
DEVSUPFUN init;
DEVSUPFUN init_record;
DEVSUPFUN get_ioint_info;
DEVSUPFUN read_stringin;
DEVSUPFUN special_linconv;
}devSiSoftCallback={
6,
NULL,
NULL,
init_record,
NULL,
read_stringin,
NULL};
epicsExportAddress(dset,devSiSoftCallback);
typedef struct notifyInfo {
processNotify *ppn;
CALLBACK *pcallback;
char value[40];
int status;
}notifyInfo;
char value[MAX_STRING_SIZE];
int status;
} notifyInfo;
static void getCallback(processNotify *ppn,notifyGetType type)
static void getCallback(processNotify *ppn, notifyGetType type)
{
struct stringinRecord *prec = (struct stringinRecord *)ppn->usrPvt;
stringinRecord *prec = (stringinRecord *)ppn->usrPvt;
notifyInfo *pnotifyInfo = (notifyInfo *)prec->dpvt;
int status = 0;
long no_elements = 1;
long options = 0;
if(ppn->status==notifyCanceled) {
printf("dbtpn:getCallback notifyCanceled\n");
if (ppn->status==notifyCanceled) {
printf("devSiSoftCallback::getCallback notifyCanceled\n");
return;
}
switch(type) {
case getFieldType:
status = dbGetField(ppn->paddr,DBR_STRING,&pnotifyInfo->value,
&options,&no_elements,0);
status = dbGetField(ppn->paddr, DBR_STRING, &pnotifyInfo->value,
&options, &no_elements, 0);
break;
case getType:
status = dbGet(ppn->paddr,DBR_STRING,&pnotifyInfo->value,
&options,&no_elements,0);
status = dbGet(ppn->paddr, DBR_STRING, &pnotifyInfo->value,
&options, &no_elements, 0);
break;
}
pnotifyInfo->status = status;
@@ -84,72 +64,144 @@ static void getCallback(processNotify *ppn,notifyGetType type)
static void doneCallback(processNotify *ppn)
{
struct stringinRecord *prec = (struct stringinRecord *)ppn->usrPvt;
stringinRecord *prec = (stringinRecord *)ppn->usrPvt;
notifyInfo *pnotifyInfo = (notifyInfo *)prec->dpvt;
callbackRequestProcessCallback(pnotifyInfo->pcallback,prec->prio,prec);
callbackRequestProcessCallback(pnotifyInfo->pcallback, prec->prio, prec);
}
static long init_record(struct stringinRecord *prec)
static long add_record(dbCommon *pcommon)
{
stringinRecord *prec = (stringinRecord *)pcommon;
DBLINK *plink = &prec->inp;
struct instio *pinstio;
char *pvname;
DBADDR *pdbaddr=NULL;
DBADDR *pdbaddr;
long status;
notifyInfo *pnotifyInfo;
CALLBACK *pcallback;
processNotify *ppn=NULL;
processNotify *ppn;
if(plink->type!=INST_IO) {
recGblRecordError(S_db_badField,(void *)prec,
"devSiSoftCallback (init_record) Illegal INP field");
prec->pact=TRUE;
return(S_db_badField);
if (plink->type == CONSTANT) return 0;
if (plink->type != PV_LINK) {
recGblRecordError(S_db_badField, (void *)prec,
"devSiSoftCallback (add_record) Illegal INP field");
return S_db_badField;
}
pinstio=(struct instio*)&(plink->value);
pvname = pinstio->string;
pdbaddr = callocMustSucceed(1, sizeof(*pdbaddr),
"devSiSoftCallback::init_record");
status = dbNameToAddr(pvname,pdbaddr);
if(status) {
recGblRecordError(status,(void *)prec,
"devSiSoftCallback (init_record) linked record not found");
prec->pact=TRUE;
return(status);
"devSiSoftCallback::add_record");
status = dbNameToAddr(plink->value.pv_link.pvname, pdbaddr);
if (status) {
free(pdbaddr);
recGblRecordError(status, (void *)prec,
"devSiSoftCallback (add_record) linked record not found");
return status;
}
pnotifyInfo = callocMustSucceed(1, sizeof(*pnotifyInfo),
"devSiSoftCallback::init_record");
pcallback = callocMustSucceed(1, sizeof(*pcallback),
"devSiSoftCallback::init_record");
plink->type = PN_LINK;
plink->value.pv_link.precord = pcommon;
plink->value.pv_link.pvt = pdbaddr;
plink->value.pv_link.pvlMask = 0;
ppn = callocMustSucceed(1, sizeof(*ppn),
"devSiSoftCallback::init_record");
pnotifyInfo->ppn = ppn;
pnotifyInfo->pcallback = pcallback;
"devSiSoftCallback::add_record");
ppn->usrPvt = prec;
ppn->paddr = pdbaddr;
ppn->getCallback = getCallback;
ppn->doneCallback = doneCallback;
ppn->requestType = processGetRequest;
pnotifyInfo = callocMustSucceed(1, sizeof(*pnotifyInfo),
"devSiSoftCallback::add_record");
pnotifyInfo->pcallback = callocMustSucceed(1, sizeof(CALLBACK),
"devSiSoftCallback::add_record");
pnotifyInfo->ppn = ppn;
prec->dpvt = pnotifyInfo;
return 0;
}
static long read_stringin(stringinRecord *prec)
static long del_record(dbCommon *pcommon) {
stringinRecord *prec = (stringinRecord *)pcommon;
DBLINK *plink = &prec->inp;
notifyInfo *pnotifyInfo = (notifyInfo *)prec->dpvt;
if (plink->type == CONSTANT) return 0;
assert (plink->type == PN_LINK);
dbNotifyCancel(pnotifyInfo->ppn);
free(pnotifyInfo->ppn);
free(pnotifyInfo->pcallback);
free(pnotifyInfo);
free(plink->value.pv_link.pvt);
plink->type = PV_LINK;
plink->value.pv_link.pvt = NULL;
return 0;
}
static struct dsxt dsxtSoftCallback = {
add_record, del_record
};
static long init(int pass)
{
if (pass == 0) devExtend(&dsxtSoftCallback);
return 0;
}
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;
}
return 0;
}
static long read_si(stringinRecord *prec)
{
notifyInfo *pnotifyInfo = (notifyInfo *)prec->dpvt;
if(prec->pact) {
if(pnotifyInfo->status) {
recGblSetSevr(prec,READ_ALARM,INVALID_ALARM);
return(pnotifyInfo->status);
}
strcpy(prec->val,pnotifyInfo->value);
prec->udf = FALSE;
return(0);
if (!prec->dpvt)
return 0;
if (!prec->pact) {
dbProcessNotify(pnotifyInfo->ppn);
prec->pact = TRUE;
return 0;
}
dbProcessNotify(pnotifyInfo->ppn);
prec->pact = TRUE;
return(0);
if (pnotifyInfo->status) {
recGblSetSevr(prec, READ_ALARM, INVALID_ALARM);
return pnotifyInfo->status;
}
strncpy(prec->val, pnotifyInfo->value, MAX_STRING_SIZE);
prec->udf = FALSE;
if (prec->tsel.type == CONSTANT &&
prec->tse == epicsTimeEventDeviceTime)
prec->time = prec->inp.value.pv_link.precord->time;
return 0;
}
/* Create the dset for devSiSoftCallback */
struct {
dset common;
DEVSUPFUN read_li;
} devSiSoftCallback = {
{5, NULL, init, init_record, NULL},
read_si
};
epicsExportAddress(dset,devSiSoftCallback);