diff --git a/src/dev/devBiTestAsyn.c b/src/dev/devBiTestAsyn.c new file mode 100644 index 000000000..08e2293c7 --- /dev/null +++ b/src/dev/devBiTestAsyn.c @@ -0,0 +1,127 @@ +/* devBiTestAsyn.c */ +/* share/src/dev $Id$ */ + +/* devBiTestAsyn.c - Device Support Routines for testing asynchronous processing*/ + + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +/* Create the dset for devBiTestAsyn */ +long init_record(); +long read_bi(); +struct { + long number; + DEVSUPFUN report; + DEVSUPFUN init; + DEVSUPFUN init_record; + DEVSUPFUN get_ioint_info; + DEVSUPFUN read_bi; + DEVSUPFUN special_linconv; +}devBiTestAsyn={ + 6, + NULL, + NULL, + init_record, + NULL, + read_bi, + NULL}; + +/* control block for callback*/ +struct callback { + void (*callback)(); + int priority; + struct dbAddr dbAddr; + WDOG_ID wd_id; + void (*process)(); +}; + +void callbackRequest(); + +static void myCallback(pcallback) + struct callback *pcallback; +{ + struct biRecord *pbi=(struct biRecord *)(pcallback->dbAddr.precord); + + dbScanLock(pbi); + (pcallback->process)(&pcallback->dbAddr); + dbScanUnlock(pbi); +} + + + +static long init_record(pbi,process) + struct biRecord *pbi; + void (*process)(); +{ + char message[100]; + struct callback *pcallback; + + /* bi.inp must be a CONSTANT*/ + switch (pbi->inp.type) { + case (CONSTANT) : + pcallback = (struct callback *)(calloc(1,sizeof(struct callback))); + pbi->dpvt = (caddr_t)pcallback; + pcallback->callback = myCallback; + pcallback->priority = priorityLow; + if(dbNameToAddr(pbi->name,&(pcallback->dbAddr))) { + logMsg("dbNameToAddr failed in init_record for devBiTestAsyn\n"); + exit(1); + } + pcallback->wd_id = wdCreate(); + pcallback->process = process; + pbi->val = pbi->inp.value.value; + break; + default : + strcpy(message,pbi->name); + strcat(message,": devBiTestAsyn (init_record) Illegal INP field"); + errMessage(S_db_badField,message); + return(S_db_badField); + } + return(0); +} + +static long read_bi(pbi) + struct biRecord *pbi; +{ + char message[100]; + long status,options,nRequest; + struct callback *pcallback=(struct callback *)(pbi->dpvt); + int wait_time; + + /* bi.inp must be a CONSTANT*/ + switch (pbi->inp.type) { + case (CONSTANT) : + if(pbi->pact) { + printf("%s Completed\n",pbi->name); + return(0); + } else { + wait_time = (int)(pbi->val * vxTicksPerSecond); + if(wait_time<=0) return(0); + printf("%s Starting asynchronous processing\n",pbi->name); + wdStart(pcallback->wd_id,wait_time,callbackRequest,pcallback); + return(1); + } + default : + if(pbi->nsevnsev = MAJOR_ALARM; + pbi->nsta = SOFT_ALARM; + if(pbi->stat!=SOFT_ALARM) { + strcpy(message,pbi->name); + strcat(message,": devBiTestAsyn (read_bi) Illegal INP field"); + errMessage(S_db_badField,message); + } + } + } + return(0); +} diff --git a/src/dev/devBoTestAsyn.c b/src/dev/devBoTestAsyn.c new file mode 100644 index 000000000..530be8f15 --- /dev/null +++ b/src/dev/devBoTestAsyn.c @@ -0,0 +1,127 @@ +/* devBoTestAsyn.c */ +/* share/src/dev $Id$ */ + +/* devBoTestAsyn.c - Device Support Routines for testing asynchronous processing*/ + + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +/* Create the dset for devBoTestAsyn */ +long init_record(); +long write_bo(); +struct { + long number; + DEVSUPFUN report; + DEVSUPFUN init; + DEVSUPFUN init_record; + DEVSUPFUN get_ioint_info; + DEVSUPFUN write_bo; + DEVSUPFUN special_linconv; +}devBoTestAsyn={ + 6, + NULL, + NULL, + init_record, + NULL, + write_bo, + NULL}; + +/* control block for callback*/ +struct callback { + void (*callback)(); + int priority; + struct dbAddr dbAddr; + WDOG_ID wd_id; + void (*process)(); +}; +void callbackRequest(); + +static void myCallback(pcallback) + struct callback *pcallback; +{ + struct boRecord *pbo=(struct boRecord *)(pcallback->dbAddr.precord); + + dbScanLock(pbo); + (pcallback->process)(&pcallback->dbAddr); + dbScanUnlock(pbo); +} + + + +static long init_record(pbo,process) + struct boRecord *pbo; + void (*process)(); +{ + char message[100]; + struct callback *pcallback; + + /* bo.out must be a CONSTANT*/ + switch (pbo->out.type) { + case (CONSTANT) : + pcallback = (struct callback *)(calloc(1,sizeof(struct callback))); + pbo->dpvt = (caddr_t)pcallback; + pcallback->callback = myCallback; + pcallback->priority = priorityLow; + if(dbNameToAddr(pbo->name,&(pcallback->dbAddr))) { + logMsg("dbNameToAddr failed in init_record for devBoTestAsyn\n"); + exit(1); + } + pcallback->wd_id = wdCreate(); + pcallback->process = process; + pbo->val = pbo->inp.value.value; + break; + default : + strcpy(message,pbo->name); + strcat(message,": devBoTestAsyn (init_record) Illegal OUT field"); + errMessage(S_db_badField,message); + return(S_db_badField); + } + return(0); +} + +static long write_bo(pbo) + struct boRecord *pbo; +{ + char message[100]; + long status,options,nRequest; + struct callback *pcallback=(struct callback *)(pbo->dpvt); + int wait_time; + + /* bo.out must be a CONSTANT*/ + switch (pbo->out.type) { + case (CONSTANT) : + if(pbo->pact) { + printf("%s Completed\n",pbo->name); + return(0); /* don`t convert*/ + } else { + wait_time = (int)(pbo->val * vxTicksPerSecond); + if(wait_time<=0) return(0); + printf("%s Starting asynchronous processing\n",pbo->name); + wdStart(pcallback->wd_id,wait_time,callbackRequest,pcallback); + return(1); + } + default : + if(pbo->nsevnsev = MAJOR_ALARM; + pbo->nsta = SOFT_ALARM; + if(pbo->stat!=SOFT_ALARM) { + strcpy(message,pbo->name); + strcat(message,": devBoTestAsyn (read_bo) Illegal OUT field"); + errMessage(S_db_badField,message); + } + } + } + return(0); +} diff --git a/src/dev/devMbbiTestAsyn.c b/src/dev/devMbbiTestAsyn.c new file mode 100644 index 000000000..60f1f3747 --- /dev/null +++ b/src/dev/devMbbiTestAsyn.c @@ -0,0 +1,127 @@ +/* devMbbiTestAsyn.c */ +/* share/src/dev $Id$ */ + +/* devMbbiTestAsyn.c - Device Support Routines for testing asynchronous processing*/ + + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +/* Create the dset for devMbbiTestAsyn */ +long init_record(); +long read_mbbi(); +struct { + long number; + DEVSUPFUN report; + DEVSUPFUN init; + DEVSUPFUN init_record; + DEVSUPFUN get_ioint_info; + DEVSUPFUN read_mbbi; + DEVSUPFUN special_linconv; +}devMbbiTestAsyn={ + 6, + NULL, + NULL, + init_record, + NULL, + read_mbbi, + NULL}; + +/* control block for callback*/ +struct callback { + void (*callback)(); + int priority; + struct dbAddr dbAddr; + WDOG_ID wd_id; + void (*process)(); +}; + +void callbackRequest(); + +static void myCallback(pcallback) + struct callback *pcallback; +{ + struct mbbiRecord *pmbbi=(struct mbbiRecord *)(pcallback->dbAddr.precord); + + dbScanLock(pmbbi); + (pcallback->process)(&pcallback->dbAddr); + dbScanUnlock(pmbbi); +} + + + +static long init_record(pmbbi,process) + struct mbbiRecord *pmbbi; + void (*process)(); +{ + char message[100]; + struct callback *pcallback; + + /* mbbi.inp must be a CONSTANT*/ + switch (pmbbi->inp.type) { + case (CONSTANT) : + pcallback = (struct callback *)(calloc(1,sizeof(struct callback))); + pmbbi->dpvt = (caddr_t)pcallback; + pcallback->callback = myCallback; + pcallback->priority = priorityLow; + if(dbNameToAddr(pmbbi->name,&(pcallback->dbAddr))) { + logMsg("dbNameToAddr failed in init_record for devMbbiTestAsyn\n"); + exit(1); + } + pcallback->wd_id = wdCreate(); + pcallback->process = process; + pmbbi->val = pmbbi->inp.value.value; + break; + default : + strcpy(message,pmbbi->name); + strcat(message,": devMbbiTestAsyn (init_record) Illegal INP field"); + errMessage(S_db_badField,message); + return(S_db_badField); + } + return(0); +} + +static long read_mbbi(pmbbi) + struct mbbiRecord *pmbbi; +{ + char message[100]; + long status,options,nRequest; + struct callback *pcallback=(struct callback *)(pmbbi->dpvt); + int wait_time; + + /* mbbi.inp must be a CONSTANT*/ + switch (pmbbi->inp.type) { + case (CONSTANT) : + if(pmbbi->pact) { + printf("%s Completed\n",pmbbi->name); + return(0); + } else { + wait_time = (int)(pmbbi->val * vxTicksPerSecond); + if(wait_time<=0) return(0); + printf("%s Starting asynchronous processing\n",pmbbi->name); + wdStart(pcallback->wd_id,wait_time,callbackRequest,pcallback); + return(1); + } + default : + if(pmbbi->nsevnsev = MAJOR_ALARM; + pmbbi->nsta = SOFT_ALARM; + if(pmbbi->stat!=SOFT_ALARM) { + strcpy(message,pmbbi->name); + strcat(message,": devMbbiTestAsyn (read_mbbi) Illegal INP field"); + errMessage(S_db_badField,message); + } + } + } + return(0); +} diff --git a/src/dev/devMbboTestAsyn.c b/src/dev/devMbboTestAsyn.c new file mode 100644 index 000000000..6eef37c73 --- /dev/null +++ b/src/dev/devMbboTestAsyn.c @@ -0,0 +1,127 @@ +/* devMbboTestAsyn.c */ +/* share/src/dev $Id$ */ + +/* devMbboTestAsyn.c - Device Support Routines for testing asynchronous processing*/ + + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +/* Create the dset for devMbboTestAsyn */ +long init_record(); +long write_mbbo(); +struct { + long number; + DEVSUPFUN report; + DEVSUPFUN init; + DEVSUPFUN init_record; + DEVSUPFUN get_ioint_info; + DEVSUPFUN write_mbbo; + DEVSUPFUN special_linconv; +}devMbboTestAsyn={ + 6, + NULL, + NULL, + init_record, + NULL, + write_mbbo, + NULL}; + +/* control block for callback*/ +struct callback { + void (*callback)(); + int priority; + struct dbAddr dbAddr; + WDOG_ID wd_id; + void (*process)(); +}; +void callbackRequest(); + +static void myCallback(pcallback) + struct callback *pcallback; +{ + struct mbboRecord *pmbbo=(struct mbboRecord *)(pcallback->dbAddr.precord); + + dbScanLock(pmbbo); + (pcallback->process)(&pcallback->dbAddr); + dbScanUnlock(pmbbo); +} + + + +static long init_record(pmbbo,process) + struct mbboRecord *pmbbo; + void (*process)(); +{ + char message[100]; + struct callback *pcallback; + + /* mbbo.out must be a CONSTANT*/ + switch (pmbbo->out.type) { + case (CONSTANT) : + pcallback = (struct callback *)(calloc(1,sizeof(struct callback))); + pmbbo->dpvt = (caddr_t)pcallback; + pcallback->callback = myCallback; + pcallback->priority = priorityLow; + if(dbNameToAddr(pmbbo->name,&(pcallback->dbAddr))) { + logMsg("dbNameToAddr failed in init_record for devMbboTestAsyn\n"); + exit(1); + } + pcallback->wd_id = wdCreate(); + pcallback->process = process; + pmbbo->val = pmbbo->inp.value.value; + break; + default : + strcpy(message,pmbbo->name); + strcat(message,": devMbboTestAsyn (init_record) Illegal OUT field"); + errMessage(S_db_badField,message); + return(S_db_badField); + } + return(0); +} + +static long write_mbbo(pmbbo) + struct mbboRecord *pmbbo; +{ + char message[100]; + long status,options,nRequest; + struct callback *pcallback=(struct callback *)(pmbbo->dpvt); + int wait_time; + + /* mbbo.out must be a CONSTANT*/ + switch (pmbbo->out.type) { + case (CONSTANT) : + if(pmbbo->pact) { + printf("%s Completed\n",pmbbo->name); + return(0); /* don`t convert*/ + } else { + wait_time = (int)(pmbbo->val * vxTicksPerSecond); + if(wait_time<=0) return(0); + printf("%s Starting asynchronous processing\n",pmbbo->name); + wdStart(pcallback->wd_id,wait_time,callbackRequest,pcallback); + return(1); + } + default : + if(pmbbo->nsevnsev = MAJOR_ALARM; + pmbbo->nsta = SOFT_ALARM; + if(pmbbo->stat!=SOFT_ALARM) { + strcpy(message,pmbbo->name); + strcat(message,": devMbboTestAsyn (read_mbbo) Illegal OUT field"); + errMessage(S_db_badField,message); + } + } + } + return(0); +}