Marty Kraimer's changes to support process-get operations.
This commit is contained in:
@@ -42,6 +42,12 @@ dbRecStd_SRCS += devSoSoft.c
|
||||
dbRecStd_SRCS += devWfSoft.c
|
||||
dbRecStd_SRCS += devGeneralTime.c
|
||||
|
||||
dbRecStd_SRCS += devAiSoftCallback.c
|
||||
dbRecStd_SRCS += devBiSoftCallback.c
|
||||
dbRecStd_SRCS += devLiSoftCallback.c
|
||||
dbRecStd_SRCS += devMbbiSoftCallback.c
|
||||
dbRecStd_SRCS += devSiSoftCallback.c
|
||||
|
||||
dbRecStd_SRCS += devAoSoftCallback.c
|
||||
dbRecStd_SRCS += devBoSoftCallback.c
|
||||
dbRecStd_SRCS += devCalcoutSoftCallback.c
|
||||
|
||||
@@ -0,0 +1,155 @@
|
||||
/*************************************************************************\
|
||||
* Copyright (c) 2002 The University of Chicago, as Operator of Argonne
|
||||
* National Laboratory.
|
||||
* 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.
|
||||
\*************************************************************************/
|
||||
/* devAiSoftCallback.c */
|
||||
/*
|
||||
* Author: Marty Kraimer
|
||||
* Date: 23APR2008
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "alarm.h"
|
||||
#include "callback.h"
|
||||
#include "cantProceed.h"
|
||||
#include "dbDefs.h"
|
||||
#include "dbAccess.h"
|
||||
#include "dbNotify.h"
|
||||
#include "recGbl.h"
|
||||
#include "recSup.h"
|
||||
#include "devSup.h"
|
||||
#include "link.h"
|
||||
#include "aiRecord.h"
|
||||
#include "epicsExport.h"
|
||||
|
||||
/* Create the dset for devAiSoftCallback */
|
||||
static long init_record();
|
||||
static long read_ai();
|
||||
struct {
|
||||
long number;
|
||||
DEVSUPFUN report;
|
||||
DEVSUPFUN init;
|
||||
DEVSUPFUN init_record;
|
||||
DEVSUPFUN get_ioint_info;
|
||||
DEVSUPFUN read_ai;
|
||||
DEVSUPFUN special_linconv;
|
||||
}devAiSoftCallback={
|
||||
6,
|
||||
NULL,
|
||||
NULL,
|
||||
init_record,
|
||||
NULL,
|
||||
read_ai,
|
||||
NULL};
|
||||
epicsExportAddress(dset,devAiSoftCallback);
|
||||
|
||||
typedef struct notifyInfo {
|
||||
processNotify *ppn;
|
||||
CALLBACK *pcallback;
|
||||
double value;
|
||||
int status;
|
||||
}notifyInfo;
|
||||
|
||||
static void getCallback(processNotify *ppn,notifyGetType type)
|
||||
{
|
||||
struct aiRecord *pai = (struct aiRecord *)ppn->usrPvt;
|
||||
notifyInfo *pnotifyInfo = (notifyInfo *)pai->dpvt;
|
||||
int status = 0;
|
||||
long no_elements = 1;
|
||||
long options = 0;
|
||||
|
||||
if(ppn->status==notifyCanceled) {
|
||||
printf("dbtpn:getCallback notifyCanceled\n");
|
||||
return;
|
||||
}
|
||||
switch(type) {
|
||||
case getFieldType:
|
||||
status = dbGetField(ppn->paddr,DBR_DOUBLE,&pnotifyInfo->value,
|
||||
&options,&no_elements,0);
|
||||
break;
|
||||
case getType:
|
||||
status = dbGet(ppn->paddr,DBR_DOUBLE,&pnotifyInfo->value,
|
||||
&options,&no_elements,0);
|
||||
break;
|
||||
}
|
||||
pnotifyInfo->status = status;
|
||||
}
|
||||
|
||||
static void doneCallback(processNotify *ppn)
|
||||
{
|
||||
struct aiRecord *pai = (struct aiRecord *)ppn->usrPvt;
|
||||
notifyInfo *pnotifyInfo = (notifyInfo *)pai->dpvt;
|
||||
|
||||
callbackRequestProcessCallback(pnotifyInfo->pcallback,pai->prio,pai);
|
||||
}
|
||||
|
||||
|
||||
static long init_record(struct aiRecord *pai)
|
||||
{
|
||||
DBLINK *plink = &pai->inp;
|
||||
struct instio *pinstio;
|
||||
char *pvname;
|
||||
DBADDR *pdbaddr=NULL;
|
||||
long status;
|
||||
notifyInfo *pnotifyInfo;
|
||||
CALLBACK *pcallback;
|
||||
processNotify *ppn=NULL;
|
||||
|
||||
if(plink->type!=INST_IO) {
|
||||
recGblRecordError(S_db_badField,(void *)pai,
|
||||
"devAiSoftCallback (init_record) Illegal INP field");
|
||||
pai->pact=TRUE;
|
||||
return(S_db_badField);
|
||||
}
|
||||
pinstio=(struct instio*)&(plink->value);
|
||||
pvname = pinstio->string;
|
||||
pdbaddr = callocMustSucceed(1, sizeof(*pdbaddr),
|
||||
"devAiSoftCallback::init_record");
|
||||
status = dbNameToAddr(pvname,pdbaddr);
|
||||
if(status) {
|
||||
recGblRecordError(status,(void *)pai,
|
||||
"devAiSoftCallback (init_record) linked record not found");
|
||||
pai->pact=TRUE;
|
||||
return(status);
|
||||
}
|
||||
pnotifyInfo = callocMustSucceed(1, sizeof(*pnotifyInfo),
|
||||
"devAiSoftCallback::init_record");
|
||||
pcallback = callocMustSucceed(1, sizeof(*pcallback),
|
||||
"devAiSoftCallback::init_record");
|
||||
ppn = callocMustSucceed(1, sizeof(*ppn),
|
||||
"devAiSoftCallback::init_record");
|
||||
pnotifyInfo->ppn = ppn;
|
||||
pnotifyInfo->pcallback = pcallback;
|
||||
ppn->usrPvt = pai;
|
||||
ppn->paddr = pdbaddr;
|
||||
ppn->getCallback = getCallback;
|
||||
ppn->doneCallback = doneCallback;
|
||||
ppn->requestType = processGetRequest;
|
||||
pai->dpvt = pnotifyInfo;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static long read_ai(aiRecord *pai)
|
||||
{
|
||||
notifyInfo *pnotifyInfo = (notifyInfo *)pai->dpvt;
|
||||
|
||||
if(pai->pact) {
|
||||
if(pnotifyInfo->status) {
|
||||
recGblSetSevr(pai,READ_ALARM,INVALID_ALARM);
|
||||
return(2);
|
||||
}
|
||||
pai->val = pnotifyInfo->value;
|
||||
pai->udf = FALSE;
|
||||
return(2);
|
||||
}
|
||||
dbProcessNotify(pnotifyInfo->ppn);
|
||||
pai->pact = TRUE;
|
||||
return(0);
|
||||
}
|
||||
@@ -0,0 +1,155 @@
|
||||
/*************************************************************************\
|
||||
* Copyright (c) 2002 The University of Chicago, as Operator of Argonne
|
||||
* National Laboratory.
|
||||
* 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.
|
||||
\*************************************************************************/
|
||||
/* devBiSoftCallback.c */
|
||||
/*
|
||||
* Author: Marty Kraimer
|
||||
* Date: 23APR2008
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "alarm.h"
|
||||
#include "callback.h"
|
||||
#include "cantProceed.h"
|
||||
#include "dbDefs.h"
|
||||
#include "dbAccess.h"
|
||||
#include "dbNotify.h"
|
||||
#include "recGbl.h"
|
||||
#include "recSup.h"
|
||||
#include "devSup.h"
|
||||
#include "link.h"
|
||||
#include "biRecord.h"
|
||||
#include "epicsExport.h"
|
||||
|
||||
/* Create the dset for devBiSoftCallback */
|
||||
static long init_record();
|
||||
static long read_bi();
|
||||
struct {
|
||||
long number;
|
||||
DEVSUPFUN report;
|
||||
DEVSUPFUN init;
|
||||
DEVSUPFUN init_record;
|
||||
DEVSUPFUN get_ioint_info;
|
||||
DEVSUPFUN read_bi;
|
||||
DEVSUPFUN special_linconv;
|
||||
}devBiSoftCallback={
|
||||
6,
|
||||
NULL,
|
||||
NULL,
|
||||
init_record,
|
||||
NULL,
|
||||
read_bi,
|
||||
NULL};
|
||||
epicsExportAddress(dset,devBiSoftCallback);
|
||||
|
||||
typedef struct notifyInfo {
|
||||
processNotify *ppn;
|
||||
CALLBACK *pcallback;
|
||||
unsigned short value;
|
||||
int status;
|
||||
}notifyInfo;
|
||||
|
||||
static void getCallback(processNotify *ppn,notifyGetType type)
|
||||
{
|
||||
struct biRecord *pbi = (struct biRecord *)ppn->usrPvt;
|
||||
notifyInfo *pnotifyInfo = (notifyInfo *)pbi->dpvt;
|
||||
int status = 0;
|
||||
long no_elements = 1;
|
||||
long options = 0;
|
||||
|
||||
if(ppn->status==notifyCanceled) {
|
||||
printf("dbtpn:getCallback notifyCanceled\n");
|
||||
return;
|
||||
}
|
||||
switch(type) {
|
||||
case getFieldType:
|
||||
status = dbGetField(ppn->paddr,DBR_USHORT,&pnotifyInfo->value,
|
||||
&options,&no_elements,0);
|
||||
break;
|
||||
case getType:
|
||||
status = dbGet(ppn->paddr,DBR_USHORT,&pnotifyInfo->value,
|
||||
&options,&no_elements,0);
|
||||
break;
|
||||
}
|
||||
pnotifyInfo->status = status;
|
||||
}
|
||||
|
||||
static void doneCallback(processNotify *ppn)
|
||||
{
|
||||
struct biRecord *pbi = (struct biRecord *)ppn->usrPvt;
|
||||
notifyInfo *pnotifyInfo = (notifyInfo *)pbi->dpvt;
|
||||
|
||||
callbackRequestProcessCallback(pnotifyInfo->pcallback,pbi->prio,pbi);
|
||||
}
|
||||
|
||||
|
||||
static long init_record(struct biRecord *pbi)
|
||||
{
|
||||
DBLINK *plink = &pbi->inp;
|
||||
struct instio *pinstio;
|
||||
char *pvname;
|
||||
DBADDR *pdbaddr=NULL;
|
||||
long status;
|
||||
notifyInfo *pnotifyInfo;
|
||||
CALLBACK *pcallback;
|
||||
processNotify *ppn=NULL;
|
||||
|
||||
if(plink->type!=INST_IO) {
|
||||
recGblRecordError(S_db_badField,(void *)pbi,
|
||||
"devBiSoftCallback (init_record) linked record not found");
|
||||
pbi->pact=TRUE;
|
||||
return(S_db_badField);
|
||||
}
|
||||
pinstio=(struct instio*)&(plink->value);
|
||||
pvname = pinstio->string;
|
||||
pdbaddr = callocMustSucceed(1, sizeof(*pdbaddr),
|
||||
"devBiSoftCallback::init_record");
|
||||
status = dbNameToAddr(pvname,pdbaddr);
|
||||
if(status) {
|
||||
recGblRecordError(status,(void *)pbi,
|
||||
"devBiSoftCallback (init_record) Illegal INP field");
|
||||
pbi->pact=TRUE;
|
||||
return(status);
|
||||
}
|
||||
pnotifyInfo = callocMustSucceed(1, sizeof(*pnotifyInfo),
|
||||
"devBiSoftCallback::init_record");
|
||||
pcallback = callocMustSucceed(1, sizeof(*pcallback),
|
||||
"devBiSoftCallback::init_record");
|
||||
ppn = callocMustSucceed(1, sizeof(*ppn),
|
||||
"devBiSoftCallback::init_record");
|
||||
pnotifyInfo->ppn = ppn;
|
||||
pnotifyInfo->pcallback = pcallback;
|
||||
ppn->usrPvt = pbi;
|
||||
ppn->paddr = pdbaddr;
|
||||
ppn->getCallback = getCallback;
|
||||
ppn->doneCallback = doneCallback;
|
||||
ppn->requestType = processGetRequest;
|
||||
pbi->dpvt = pnotifyInfo;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static long read_bi(biRecord *pbi)
|
||||
{
|
||||
notifyInfo *pnotifyInfo = (notifyInfo *)pbi->dpvt;
|
||||
|
||||
if(pbi->pact) {
|
||||
if(pnotifyInfo->status) {
|
||||
recGblSetSevr(pbi,READ_ALARM,INVALID_ALARM);
|
||||
return(2);
|
||||
}
|
||||
pbi->val = pnotifyInfo->value;
|
||||
pbi->udf = FALSE;
|
||||
return(2);
|
||||
}
|
||||
dbProcessNotify(pnotifyInfo->ppn);
|
||||
pbi->pact = TRUE;
|
||||
return(0);
|
||||
}
|
||||
@@ -0,0 +1,155 @@
|
||||
/*************************************************************************\
|
||||
* Copyright (c) 2002 The University of Chicago, as Operator of Argonne
|
||||
* National Laboratory.
|
||||
* 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.
|
||||
\*************************************************************************/
|
||||
/* devLiSoftCallback.c */
|
||||
/*
|
||||
* Author: Marty Kraimer
|
||||
* Date: 23APR2008
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "alarm.h"
|
||||
#include "callback.h"
|
||||
#include "cantProceed.h"
|
||||
#include "dbDefs.h"
|
||||
#include "dbAccess.h"
|
||||
#include "dbNotify.h"
|
||||
#include "recGbl.h"
|
||||
#include "recSup.h"
|
||||
#include "devSup.h"
|
||||
#include "link.h"
|
||||
#include "longinRecord.h"
|
||||
#include "epicsExport.h"
|
||||
|
||||
/* Create the dset for devLiSoftCallback */
|
||||
static long init_record();
|
||||
static long read_li();
|
||||
struct {
|
||||
long number;
|
||||
DEVSUPFUN report;
|
||||
DEVSUPFUN init;
|
||||
DEVSUPFUN init_record;
|
||||
DEVSUPFUN get_ioint_info;
|
||||
DEVSUPFUN read_li;
|
||||
DEVSUPFUN special_linconv;
|
||||
}devLiSoftCallback={
|
||||
6,
|
||||
NULL,
|
||||
NULL,
|
||||
init_record,
|
||||
NULL,
|
||||
read_li,
|
||||
NULL};
|
||||
epicsExportAddress(dset,devLiSoftCallback);
|
||||
|
||||
typedef struct notifyInfo {
|
||||
processNotify *ppn;
|
||||
CALLBACK *pcallback;
|
||||
long value;
|
||||
int status;
|
||||
}notifyInfo;
|
||||
|
||||
static void getCallback(processNotify *ppn,notifyGetType type)
|
||||
{
|
||||
struct longinRecord *pli = (struct longinRecord *)ppn->usrPvt;
|
||||
notifyInfo *pnotifyInfo = (notifyInfo *)pli->dpvt;
|
||||
int status = 0;
|
||||
long no_elements = 1;
|
||||
long options = 0;
|
||||
|
||||
if(ppn->status==notifyCanceled) {
|
||||
printf("dbtpn:getCallback notifyCanceled\n");
|
||||
return;
|
||||
}
|
||||
switch(type) {
|
||||
case getFieldType:
|
||||
status = dbGetField(ppn->paddr,DBR_LONG,&pnotifyInfo->value,
|
||||
&options,&no_elements,0);
|
||||
break;
|
||||
case getType:
|
||||
status = dbGet(ppn->paddr,DBR_LONG,&pnotifyInfo->value,
|
||||
&options,&no_elements,0);
|
||||
break;
|
||||
}
|
||||
pnotifyInfo->status = status;
|
||||
}
|
||||
|
||||
static void doneCallback(processNotify *ppn)
|
||||
{
|
||||
struct longinRecord *pli = (struct longinRecord *)ppn->usrPvt;
|
||||
notifyInfo *pnotifyInfo = (notifyInfo *)pli->dpvt;
|
||||
|
||||
callbackRequestProcessCallback(pnotifyInfo->pcallback,pli->prio,pli);
|
||||
}
|
||||
|
||||
|
||||
static long init_record(struct longinRecord *pli)
|
||||
{
|
||||
DBLINK *plink = &pli->inp;
|
||||
struct instio *pinstio;
|
||||
char *pvname;
|
||||
DBADDR *pdbaddr=NULL;
|
||||
long status;
|
||||
notifyInfo *pnotifyInfo;
|
||||
CALLBACK *pcallback;
|
||||
processNotify *ppn=NULL;
|
||||
|
||||
if(plink->type!=INST_IO) {
|
||||
recGblRecordError(S_db_badField,(void *)pli,
|
||||
"devLiSoftCallback (init_record) linked record not found");
|
||||
pli->pact=TRUE;
|
||||
return(S_db_badField);
|
||||
}
|
||||
pinstio=(struct instio*)&(plink->value);
|
||||
pvname = pinstio->string;
|
||||
pdbaddr = callocMustSucceed(1, sizeof(*pdbaddr),
|
||||
"devLiSoftCallback::init_record");
|
||||
status = dbNameToAddr(pvname,pdbaddr);
|
||||
if(status) {
|
||||
recGblRecordError(status,(void *)pli,
|
||||
"devLiSoftCallback (init_record) Illegal INP field");
|
||||
pli->pact=TRUE;
|
||||
return(status);
|
||||
}
|
||||
pnotifyInfo = callocMustSucceed(1, sizeof(*pnotifyInfo),
|
||||
"devLiSoftCallback::init_record");
|
||||
pcallback = callocMustSucceed(1, sizeof(*pcallback),
|
||||
"devLiSoftCallback::init_record");
|
||||
ppn = callocMustSucceed(1, sizeof(*ppn),
|
||||
"devLiSoftCallback::init_record");
|
||||
pnotifyInfo->ppn = ppn;
|
||||
pnotifyInfo->pcallback = pcallback;
|
||||
ppn->usrPvt = pli;
|
||||
ppn->paddr = pdbaddr;
|
||||
ppn->getCallback = getCallback;
|
||||
ppn->doneCallback = doneCallback;
|
||||
ppn->requestType = processGetRequest;
|
||||
pli->dpvt = pnotifyInfo;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static long read_li(longinRecord *pli)
|
||||
{
|
||||
notifyInfo *pnotifyInfo = (notifyInfo *)pli->dpvt;
|
||||
|
||||
if(pli->pact) {
|
||||
if(pnotifyInfo->status) {
|
||||
recGblSetSevr(pli,READ_ALARM,INVALID_ALARM);
|
||||
return(pnotifyInfo->status);
|
||||
}
|
||||
pli->val = pnotifyInfo->value;
|
||||
pli->udf = FALSE;
|
||||
return(0);
|
||||
}
|
||||
dbProcessNotify(pnotifyInfo->ppn);
|
||||
pli->pact = TRUE;
|
||||
return(0);
|
||||
}
|
||||
@@ -0,0 +1,155 @@
|
||||
/*************************************************************************\
|
||||
* Copyright (c) 2002 The University of Chicago, as Operator of Argonne
|
||||
* National Laboratory.
|
||||
* 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.
|
||||
\*************************************************************************/
|
||||
/* devMbbiSoftCallback.c */
|
||||
/*
|
||||
* Author: Marty Kraimer
|
||||
* Date: 23APR2008
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "alarm.h"
|
||||
#include "callback.h"
|
||||
#include "cantProceed.h"
|
||||
#include "dbDefs.h"
|
||||
#include "dbAccess.h"
|
||||
#include "dbNotify.h"
|
||||
#include "recGbl.h"
|
||||
#include "recSup.h"
|
||||
#include "devSup.h"
|
||||
#include "link.h"
|
||||
#include "mbbiRecord.h"
|
||||
#include "epicsExport.h"
|
||||
|
||||
/* Create the dset for devMbbiSoftCallback */
|
||||
static long init_record();
|
||||
static long read_mbbi();
|
||||
struct {
|
||||
long number;
|
||||
DEVSUPFUN report;
|
||||
DEVSUPFUN init;
|
||||
DEVSUPFUN init_record;
|
||||
DEVSUPFUN get_ioint_info;
|
||||
DEVSUPFUN read_mbbi;
|
||||
DEVSUPFUN special_linconv;
|
||||
}devMbbiSoftCallback={
|
||||
6,
|
||||
NULL,
|
||||
NULL,
|
||||
init_record,
|
||||
NULL,
|
||||
read_mbbi,
|
||||
NULL};
|
||||
epicsExportAddress(dset,devMbbiSoftCallback);
|
||||
|
||||
typedef struct notifyInfo {
|
||||
processNotify *ppn;
|
||||
CALLBACK *pcallback;
|
||||
unsigned short value;
|
||||
int status;
|
||||
}notifyInfo;
|
||||
|
||||
static void getCallback(processNotify *ppn,notifyGetType type)
|
||||
{
|
||||
struct mbbiRecord *pmbbi = (struct mbbiRecord *)ppn->usrPvt;
|
||||
notifyInfo *pnotifyInfo = (notifyInfo *)pmbbi->dpvt;
|
||||
int status = 0;
|
||||
long no_elements = 1;
|
||||
long options = 0;
|
||||
|
||||
if(ppn->status==notifyCanceled) {
|
||||
printf("dbtpn:getCallback notifyCanceled\n");
|
||||
return;
|
||||
}
|
||||
switch(type) {
|
||||
case getFieldType:
|
||||
status = dbGetField(ppn->paddr,DBR_USHORT,&pnotifyInfo->value,
|
||||
&options,&no_elements,0);
|
||||
break;
|
||||
case getType:
|
||||
status = dbGet(ppn->paddr,DBR_USHORT,&pnotifyInfo->value,
|
||||
&options,&no_elements,0);
|
||||
break;
|
||||
}
|
||||
pnotifyInfo->status = status;
|
||||
}
|
||||
|
||||
static void doneCallback(processNotify *ppn)
|
||||
{
|
||||
struct mbbiRecord *pmbbi = (struct mbbiRecord *)ppn->usrPvt;
|
||||
notifyInfo *pnotifyInfo = (notifyInfo *)pmbbi->dpvt;
|
||||
|
||||
callbackRequestProcessCallback(pnotifyInfo->pcallback,pmbbi->prio,pmbbi);
|
||||
}
|
||||
|
||||
|
||||
static long init_record(struct mbbiRecord *pmbbi)
|
||||
{
|
||||
DBLINK *plink = &pmbbi->inp;
|
||||
struct instio *pinstio;
|
||||
char *pvname;
|
||||
DBADDR *pdbaddr=NULL;
|
||||
long status;
|
||||
notifyInfo *pnotifyInfo;
|
||||
CALLBACK *pcallback;
|
||||
processNotify *ppn=NULL;
|
||||
|
||||
if(plink->type!=INST_IO) {
|
||||
recGblRecordError(S_db_badField,(void *)pmbbi,
|
||||
"devMbbiSoftCallback (init_record) linked record not found");
|
||||
pmbbi->pact=TRUE;
|
||||
return(S_db_badField);
|
||||
}
|
||||
pinstio=(struct instio*)&(plink->value);
|
||||
pvname = pinstio->string;
|
||||
pdbaddr = callocMustSucceed(1, sizeof(*pdbaddr),
|
||||
"devMbbiSoftCallback::init_record");
|
||||
status = dbNameToAddr(pvname,pdbaddr);
|
||||
if(status) {
|
||||
recGblRecordError(status,(void *)pmbbi,
|
||||
"devMbbiSoftCallback (init_record) Illegal INP field");
|
||||
pmbbi->pact=TRUE;
|
||||
return(status);
|
||||
}
|
||||
pnotifyInfo = callocMustSucceed(1, sizeof(*pnotifyInfo),
|
||||
"devMbbiSoftCallback::init_record");
|
||||
pcallback = callocMustSucceed(1, sizeof(*pcallback),
|
||||
"devMbbiSoftCallback::init_record");
|
||||
ppn = callocMustSucceed(1, sizeof(*ppn),
|
||||
"devMbbiSoftCallback::init_record");
|
||||
pnotifyInfo->ppn = ppn;
|
||||
pnotifyInfo->pcallback = pcallback;
|
||||
ppn->usrPvt = pmbbi;
|
||||
ppn->paddr = pdbaddr;
|
||||
ppn->getCallback = getCallback;
|
||||
ppn->doneCallback = doneCallback;
|
||||
ppn->requestType = processGetRequest;
|
||||
pmbbi->dpvt = pnotifyInfo;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static long read_mbbi(mbbiRecord *pmbbi)
|
||||
{
|
||||
notifyInfo *pnotifyInfo = (notifyInfo *)pmbbi->dpvt;
|
||||
|
||||
if(pmbbi->pact) {
|
||||
if(pnotifyInfo->status) {
|
||||
recGblSetSevr(pmbbi,READ_ALARM,INVALID_ALARM);
|
||||
return(2);
|
||||
}
|
||||
pmbbi->val = pnotifyInfo->value;
|
||||
pmbbi->udf = FALSE;
|
||||
return(2);
|
||||
}
|
||||
dbProcessNotify(pnotifyInfo->ppn);
|
||||
pmbbi->pact = TRUE;
|
||||
return(0);
|
||||
}
|
||||
@@ -0,0 +1,155 @@
|
||||
/*************************************************************************\
|
||||
* Copyright (c) 2002 The University of Chicago, as Operator of Argonne
|
||||
* National Laboratory.
|
||||
* 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.
|
||||
\*************************************************************************/
|
||||
/* devSiSoftCallback.c */
|
||||
/*
|
||||
* Author: Marty Kraimer
|
||||
* Date: 23APR2008
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "alarm.h"
|
||||
#include "callback.h"
|
||||
#include "cantProceed.h"
|
||||
#include "dbDefs.h"
|
||||
#include "dbAccess.h"
|
||||
#include "dbNotify.h"
|
||||
#include "recGbl.h"
|
||||
#include "recSup.h"
|
||||
#include "devSup.h"
|
||||
#include "link.h"
|
||||
#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;
|
||||
|
||||
static void getCallback(processNotify *ppn,notifyGetType type)
|
||||
{
|
||||
struct stringinRecord *pstringin = (struct stringinRecord *)ppn->usrPvt;
|
||||
notifyInfo *pnotifyInfo = (notifyInfo *)pstringin->dpvt;
|
||||
int status = 0;
|
||||
long no_elements = 1;
|
||||
long options = 0;
|
||||
|
||||
if(ppn->status==notifyCanceled) {
|
||||
printf("dbtpn:getCallback notifyCanceled\n");
|
||||
return;
|
||||
}
|
||||
switch(type) {
|
||||
case getFieldType:
|
||||
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);
|
||||
break;
|
||||
}
|
||||
pnotifyInfo->status = status;
|
||||
}
|
||||
|
||||
static void doneCallback(processNotify *ppn)
|
||||
{
|
||||
struct stringinRecord *pstringin = (struct stringinRecord *)ppn->usrPvt;
|
||||
notifyInfo *pnotifyInfo = (notifyInfo *)pstringin->dpvt;
|
||||
|
||||
callbackRequestProcessCallback(pnotifyInfo->pcallback,pstringin->prio,pstringin);
|
||||
}
|
||||
|
||||
|
||||
static long init_record(struct stringinRecord *pstringin)
|
||||
{
|
||||
DBLINK *plink = &pstringin->inp;
|
||||
struct instio *pinstio;
|
||||
char *pvname;
|
||||
DBADDR *pdbaddr=NULL;
|
||||
long status;
|
||||
notifyInfo *pnotifyInfo;
|
||||
CALLBACK *pcallback;
|
||||
processNotify *ppn=NULL;
|
||||
|
||||
if(plink->type!=INST_IO) {
|
||||
recGblRecordError(S_db_badField,(void *)pstringin,
|
||||
"devSiSoftCallback (init_record) linked record not found");
|
||||
pstringin->pact=TRUE;
|
||||
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 *)pstringin,
|
||||
"devSiSoftCallback (init_record) Illegal INP field");
|
||||
pstringin->pact=TRUE;
|
||||
return(status);
|
||||
}
|
||||
pnotifyInfo = callocMustSucceed(1, sizeof(*pnotifyInfo),
|
||||
"devSiSoftCallback::init_record");
|
||||
pcallback = callocMustSucceed(1, sizeof(*pcallback),
|
||||
"devSiSoftCallback::init_record");
|
||||
ppn = callocMustSucceed(1, sizeof(*ppn),
|
||||
"devSiSoftCallback::init_record");
|
||||
pnotifyInfo->ppn = ppn;
|
||||
pnotifyInfo->pcallback = pcallback;
|
||||
ppn->usrPvt = pstringin;
|
||||
ppn->paddr = pdbaddr;
|
||||
ppn->getCallback = getCallback;
|
||||
ppn->doneCallback = doneCallback;
|
||||
ppn->requestType = processGetRequest;
|
||||
pstringin->dpvt = pnotifyInfo;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static long read_stringin(stringinRecord *pstringin)
|
||||
{
|
||||
notifyInfo *pnotifyInfo = (notifyInfo *)pstringin->dpvt;
|
||||
|
||||
if(pstringin->pact) {
|
||||
if(pnotifyInfo->status) {
|
||||
recGblSetSevr(pstringin,READ_ALARM,INVALID_ALARM);
|
||||
return(pnotifyInfo->status);
|
||||
}
|
||||
strcpy(pstringin->val,pnotifyInfo->value);
|
||||
pstringin->udf = FALSE;
|
||||
return(0);
|
||||
}
|
||||
dbProcessNotify(pnotifyInfo->ppn);
|
||||
pstringin->pact = TRUE;
|
||||
return(0);
|
||||
}
|
||||
@@ -27,6 +27,12 @@ device(mbbiDirect,CONSTANT,devMbbiDirectSoftRaw,"Raw Soft Channel")
|
||||
device(mbbo,CONSTANT,devMbboSoftRaw,"Raw Soft Channel")
|
||||
device(mbboDirect,CONSTANT,devMbboDirectSoftRaw,"Raw Soft Channel")
|
||||
|
||||
device(ai,INST_IO,devAiSoftCallback,"Async Soft Channel")
|
||||
device(bi,INST_IO,devBiSoftCallback,"Async Soft Channel")
|
||||
device(mbbi,INST_IO,devMbbiSoftCallback,"Async Soft Channel")
|
||||
device(longin,INST_IO,devLiSoftCallback,"Async Soft Channel")
|
||||
device(stringin,INST_IO,devSiSoftCallback,"Async Soft Channel")
|
||||
|
||||
device(ao,CONSTANT,devAoSoftCallback,"Async Soft Channel")
|
||||
device(bo,CONSTANT,devBoSoftCallback,"Async Soft Channel")
|
||||
device(calcout,CONSTANT,devCalcoutSoftCallback,"Async Soft Channel")
|
||||
|
||||
Reference in New Issue
Block a user