Initial revision
This commit is contained in:
161
src/dev/devSiTestAsyn.c
Normal file
161
src/dev/devSiTestAsyn.c
Normal file
@@ -0,0 +1,161 @@
|
||||
/* devStringinTestAsyn.c */
|
||||
/* share/src/dev $Id$ */
|
||||
|
||||
/* devStringinTestAsyn.c - Device Support Routines for testing asynchronous processing*/
|
||||
/*
|
||||
* Author: Janet Anderson
|
||||
* Date: 5-1-91
|
||||
*
|
||||
* Experimental Physics and Industrial Control System (EPICS)
|
||||
*
|
||||
* Copyright 1991, the Regents of the University of California,
|
||||
* and the University of Chicago Board of Governors.
|
||||
*
|
||||
* This software was produced under U.S. Government contracts:
|
||||
* (W-7405-ENG-36) at the Los Alamos National Laboratory,
|
||||
* and (W-31-109-ENG-38) at Argonne National Laboratory.
|
||||
*
|
||||
* Initial development by:
|
||||
* The Controls and Automation Group (AT-8)
|
||||
* Ground Test Accelerator
|
||||
* Accelerator Technology Division
|
||||
* Los Alamos National Laboratory
|
||||
*
|
||||
* Co-developed with
|
||||
* The Controls and Computing Group
|
||||
* Accelerator Systems Division
|
||||
* Advanced Photon Source
|
||||
* Argonne National Laboratory
|
||||
*
|
||||
* Modification Log:
|
||||
* -----------------
|
||||
* .01 mm-dd-yy iii Comment
|
||||
* .02 mm-dd-yy iii Comment
|
||||
* ...
|
||||
*/
|
||||
|
||||
|
||||
#include <vxWorks.h>
|
||||
#include <types.h>
|
||||
#include <stdioLib.h>
|
||||
#include <wdLib.h>
|
||||
|
||||
#include <alarm.h>
|
||||
#include <dbDefs.h>
|
||||
#include <dbAccess.h>
|
||||
#include <recSup.h>
|
||||
#include <devSup.h>
|
||||
#include <link.h>
|
||||
#include <stringinRecord.h>
|
||||
|
||||
/* Create the dset for devStringinTestAsyn */
|
||||
long init_record();
|
||||
long read_stringin();
|
||||
struct {
|
||||
long number;
|
||||
DEVSUPFUN report;
|
||||
DEVSUPFUN init;
|
||||
DEVSUPFUN init_record;
|
||||
DEVSUPFUN get_ioint_info;
|
||||
DEVSUPFUN read_stringin;
|
||||
DEVSUPFUN special_linconv;
|
||||
}devStringinTestAsyn={
|
||||
6,
|
||||
NULL,
|
||||
NULL,
|
||||
init_record,
|
||||
NULL,
|
||||
read_stringin,
|
||||
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 stringinRecord *pstringin=(struct stringinRecord *)(pcallback->dbAddr.precord);
|
||||
|
||||
dbScanLock(pstringin);
|
||||
(pcallback->process)(&pcallback->dbAddr);
|
||||
dbScanUnlock(pstringin);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static long init_record(pstringin,process)
|
||||
struct stringinRecord *pstringin;
|
||||
void (*process)();
|
||||
{
|
||||
char message[100];
|
||||
struct callback *pcallback;
|
||||
|
||||
/* stringin.inp must be a CONSTANT*/
|
||||
switch (pstringin->inp.type) {
|
||||
case (CONSTANT) :
|
||||
pcallback = (struct callback *)(calloc(1,sizeof(struct callback)));
|
||||
pstringin->dpvt = (caddr_t)pcallback;
|
||||
pcallback->callback = myCallback;
|
||||
pcallback->priority = priorityLow;
|
||||
if(dbNameToAddr(pstringin->name,&(pcallback->dbAddr))) {
|
||||
logMsg("dbNameToAddr failed in init_record for devStringinTestAsyn\n");
|
||||
exit(1);
|
||||
}
|
||||
pcallback->wd_id = wdCreate();
|
||||
pcallback->process = process;
|
||||
if (pstringin->inp.value.value!=0.0) {
|
||||
sprintf(pstringin->val,"%-14.7g",pstringin->inp.value.value);
|
||||
pstringin->udf = FALSE;
|
||||
}
|
||||
break;
|
||||
default :
|
||||
strcpy(message,pstringin->name);
|
||||
strcat(message,": devStringinTestAsyn (init_record) Illegal INP field");
|
||||
errMessage(S_db_badField,message);
|
||||
return(S_db_badField);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
static long read_stringin(pstringin)
|
||||
struct stringinRecord *pstringin;
|
||||
{
|
||||
char message[100];
|
||||
long status,options,nRequest;
|
||||
struct callback *pcallback=(struct callback *)(pstringin->dpvt);
|
||||
int wait_time;
|
||||
|
||||
/* stringin.inp must be a CONSTANT*/
|
||||
switch (pstringin->inp.type) {
|
||||
case (CONSTANT) :
|
||||
if(pstringin->pact) {
|
||||
printf("%s Completed\n",pstringin->name);
|
||||
return(0);
|
||||
} else {
|
||||
wait_time = (int)(pstringin->disv * vxTicksPerSecond);
|
||||
if(wait_time<=0) return(0);
|
||||
printf("%s Starting asynchronous processing\n",pstringin->name);
|
||||
wdStart(pcallback->wd_id,wait_time,callbackRequest,pcallback);
|
||||
return(1);
|
||||
}
|
||||
default :
|
||||
if(pstringin->nsev<VALID_ALARM) {
|
||||
pstringin->nsev = VALID_ALARM;
|
||||
pstringin->nsta = SOFT_ALARM;
|
||||
if(pstringin->stat!=SOFT_ALARM) {
|
||||
strcpy(message,pstringin->name);
|
||||
strcat(message,": devStringinTestAsyn (read_stringin) Illegal INP field");
|
||||
errMessage(S_db_badField,message);
|
||||
}
|
||||
}
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
100
src/dev/devSoSoft.c
Normal file
100
src/dev/devSoSoft.c
Normal file
@@ -0,0 +1,100 @@
|
||||
/* devStringoutSoft.c */
|
||||
/* share/src/dev $Id$ */
|
||||
|
||||
/* devStringoutSoft.c - Device Support Routines for Soft String Output */
|
||||
/*
|
||||
* Author: Janet Anderson
|
||||
* Date: 04-21-91
|
||||
*
|
||||
* Experimental Physics and Industrial Control System (EPICS)
|
||||
*
|
||||
* Copyright 1991, the Regents of the University of California,
|
||||
* and the University of Chicago Board of Governors.
|
||||
*
|
||||
* This software was produced under U.S. Government contracts:
|
||||
* (W-7405-ENG-36) at the Los Alamos National Laboratory,
|
||||
* and (W-31-109-ENG-38) at Argonne National Laboratory.
|
||||
*
|
||||
* Initial development by:
|
||||
* The Controls and Automation Group (AT-8)
|
||||
* Ground Test Accelerator
|
||||
* Accelerator Technology Division
|
||||
* Los Alamos National Laboratory
|
||||
*
|
||||
* Co-developed with
|
||||
* The Controls and Computing Group
|
||||
* Accelerator Systems Division
|
||||
* Advanced Photon Source
|
||||
* Argonne National Laboratory
|
||||
*
|
||||
* Modification Log:
|
||||
* -----------------
|
||||
* .01 mm-dd-yy iii Comment
|
||||
*/
|
||||
|
||||
#include <vxWorks.h>
|
||||
#include <types.h>
|
||||
#include <stdioLib.h>
|
||||
|
||||
#include <alarm.h>
|
||||
#include <dbAccess.h>
|
||||
#include <dbDefs.h>
|
||||
#include <devSup.h>
|
||||
#include <link.h>
|
||||
#include <module_types.h>
|
||||
#include <stringoutRecord.h>
|
||||
|
||||
/* Create the dset for devStringoutSoft */
|
||||
long write_stringout();
|
||||
|
||||
struct {
|
||||
long number;
|
||||
DEVSUPFUN report;
|
||||
DEVSUPFUN init;
|
||||
DEVSUPFUN init_record;
|
||||
DEVSUPFUN get_ioint_info;
|
||||
DEVSUPFUN write_stringout;
|
||||
}devStringoutSoft={
|
||||
5,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
write_stringout};
|
||||
|
||||
|
||||
static long write_stringout(pstringout)
|
||||
struct stringoutRecord *pstringout;
|
||||
{
|
||||
char message[100];
|
||||
long status;
|
||||
|
||||
/* stringout.out must be a CONSTANT or a DB_LINK or a CA_LINK*/
|
||||
switch (pstringout->out.type) {
|
||||
case (CONSTANT) :
|
||||
break;
|
||||
case (DB_LINK) :
|
||||
status = dbPutLink(&pstringout->out.value.db_link,pstringout,DBR_STRING,
|
||||
pstringout->val,1L);
|
||||
if(status!=0) {
|
||||
if(pstringout->nsev<VALID_ALARM) {
|
||||
pstringout->nsev = VALID_ALARM;
|
||||
pstringout->nsta = LINK_ALARM;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case (CA_LINK) :
|
||||
break;
|
||||
default :
|
||||
if(pstringout->nsev<VALID_ALARM) {
|
||||
pstringout->nsev = VALID_ALARM;
|
||||
pstringout->nsta = SOFT_ALARM;
|
||||
if(pstringout->stat!=SOFT_ALARM) {
|
||||
strcpy(message,pstringout->name);
|
||||
strcat(message,": devStringoutSoft (write_stringout) Illegal OUT field");
|
||||
errMessage(S_db_badField,message);
|
||||
}
|
||||
}
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
157
src/dev/devSoTestAsyn.c
Normal file
157
src/dev/devSoTestAsyn.c
Normal file
@@ -0,0 +1,157 @@
|
||||
/* devStringoutTestAsyn.c */
|
||||
/* share/src/dev $Id$ */
|
||||
|
||||
/* devStringoutTestAsyn.c - Device Support Routines for testing asynchronous processing*/
|
||||
/*
|
||||
* Author: Janet Anderson
|
||||
* Date: 5-1-91
|
||||
*
|
||||
* Experimental Physics and Industrial Control System (EPICS)
|
||||
*
|
||||
* Copyright 1991, the Regents of the University of California,
|
||||
* and the University of Chicago Board of Governors.
|
||||
*
|
||||
* This software was produced under U.S. Government contracts:
|
||||
* (W-7405-ENG-36) at the Los Alamos National Laboratory,
|
||||
* and (W-31-109-ENG-38) at Argonne National Laboratory.
|
||||
*
|
||||
* Initial development by:
|
||||
* The Controls and Automation Group (AT-8)
|
||||
* Ground Test Accelerator
|
||||
* Accelerator Technology Division
|
||||
* Los Alamos National Laboratory
|
||||
*
|
||||
* Co-developed with
|
||||
* The Controls and Computing Group
|
||||
* Accelerator Systems Division
|
||||
* Advanced Photon Source
|
||||
* Argonne National Laboratory
|
||||
*
|
||||
* Modification Log:
|
||||
* -----------------
|
||||
* .01 mm-dd-yy iii Comment
|
||||
* .02 mm-dd-yy iii Comment
|
||||
* ...
|
||||
*/
|
||||
|
||||
|
||||
#include <vxWorks.h>
|
||||
#include <types.h>
|
||||
#include <stdioLib.h>
|
||||
#include <wdLib.h>
|
||||
|
||||
#include <alarm.h>
|
||||
#include <cvtTable.h>
|
||||
#include <dbDefs.h>
|
||||
#include <dbAccess.h>
|
||||
#include <recSup.h>
|
||||
#include <devSup.h>
|
||||
#include <link.h>
|
||||
#include <stringoutRecord.h>
|
||||
|
||||
/* Create the dset for devStringoutTestAsyn */
|
||||
long init_record();
|
||||
long write_stringout();
|
||||
struct {
|
||||
long number;
|
||||
DEVSUPFUN report;
|
||||
DEVSUPFUN init;
|
||||
DEVSUPFUN init_record;
|
||||
DEVSUPFUN get_ioint_info;
|
||||
DEVSUPFUN write_stringout;
|
||||
DEVSUPFUN special_linconv;
|
||||
}devStringoutTestAsyn={
|
||||
6,
|
||||
NULL,
|
||||
NULL,
|
||||
init_record,
|
||||
NULL,
|
||||
write_stringout,
|
||||
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 stringoutRecord *pstringout=(struct stringoutRecord *)(pcallback->dbAddr.precord);
|
||||
|
||||
dbScanLock(pstringout);
|
||||
(pcallback->process)(&pcallback->dbAddr);
|
||||
dbScanUnlock(pstringout);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static long init_record(pstringout,process)
|
||||
struct stringoutRecord *pstringout;
|
||||
void (*process)();
|
||||
{
|
||||
char message[100];
|
||||
struct callback *pcallback;
|
||||
|
||||
/* stringout.out must be a CONSTANT*/
|
||||
switch (pstringout->out.type) {
|
||||
case (CONSTANT) :
|
||||
pcallback = (struct callback *)(calloc(1,sizeof(struct callback)));
|
||||
pstringout->dpvt = (caddr_t)pcallback;
|
||||
pcallback->callback = myCallback;
|
||||
pcallback->priority = priorityLow;
|
||||
if(dbNameToAddr(pstringout->name,&(pcallback->dbAddr))) {
|
||||
logMsg("dbNameToAddr failed in init_record for devStringoutTestAsyn\n");
|
||||
exit(1);
|
||||
}
|
||||
pcallback->wd_id = wdCreate();
|
||||
pcallback->process = process;
|
||||
break;
|
||||
default :
|
||||
strcpy(message,pstringout->name);
|
||||
strcat(message,": devStringoutTestAsyn (init_record) Illegal OUT field");
|
||||
errMessage(S_db_badField,message);
|
||||
return(S_db_badField);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
static long write_stringout(pstringout)
|
||||
struct stringoutRecord *pstringout;
|
||||
{
|
||||
char message[100];
|
||||
long status,options,nRequest;
|
||||
struct callback *pcallback=(struct callback *)(pstringout->dpvt);
|
||||
int wait_time;
|
||||
|
||||
/* stringout.out must be a CONSTANT*/
|
||||
switch (pstringout->out.type) {
|
||||
case (CONSTANT) :
|
||||
if(pstringout->pact) {
|
||||
printf("%s Completed\n",pstringout->name);
|
||||
return(0); /* don`t convert*/
|
||||
} else {
|
||||
wait_time = (int)(pstringout->disv * vxTicksPerSecond);
|
||||
if(wait_time<=0) return(0);
|
||||
printf("%s Starting asynchronous processing\n",pstringout->name);
|
||||
wdStart(pcallback->wd_id,wait_time,callbackRequest,pcallback);
|
||||
return(1);
|
||||
}
|
||||
default :
|
||||
if(pstringout->nsev<VALID_ALARM) {
|
||||
pstringout->nsev = VALID_ALARM;
|
||||
pstringout->nsta = SOFT_ALARM;
|
||||
if(pstringout->stat!=SOFT_ALARM) {
|
||||
strcpy(message,pstringout->name);
|
||||
strcat(message,": devStringoutTestAsyn (read_stringout) Illegal OUT field");
|
||||
errMessage(S_db_badField,message);
|
||||
}
|
||||
}
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
Reference in New Issue
Block a user