use new callback Delay routines

This commit is contained in:
Marty Kraimer
2000-02-02 21:48:06 +00:00
parent 17a7f128fc
commit 80eabf1529
11 changed files with 127 additions and 379 deletions

View File

@@ -44,8 +44,6 @@
#include <string.h>
#include "alarm.h"
#include "osiWatchdog.h"
#include "osiClock.h"
#include "callback.h"
#include "cvtTable.h"
#include "dbDefs.h"
@@ -75,39 +73,16 @@ struct {
NULL,
read_ai,
NULL};
/* control block for callback*/
struct callback {
CALLBACK callback;
struct dbCommon *precord;
watchdogId wd_id;
};
static void myCallback(pcallback)
struct callback *pcallback;
{
struct dbCommon *precord=pcallback->precord;
struct rset *prset=(struct rset *)(precord->rset);
dbScanLock(precord);
(*prset->process)(precord);
dbScanUnlock(precord);
}
static long init_record(pai)
struct aiRecord *pai;
{
struct callback *pcallback;
CALLBACK *pcallback;
/* ai.inp must be a CONSTANT*/
switch (pai->inp.type) {
case (CONSTANT) :
pcallback = (struct callback *)(calloc(1,sizeof(struct callback)));
pcallback = (CALLBACK *)(calloc(1,sizeof(CALLBACK)));
pai->dpvt = (void *)pcallback;
callbackSetCallback(myCallback,&pcallback->callback);
pcallback->precord = (struct dbCommon *)pai;
pcallback->wd_id = watchdogCreate();
if(recGblInitConstantLink(&pai->inp,DBF_DOUBLE,&pai->val))
pai->udf = FALSE;
break;
@@ -118,13 +93,11 @@ static long init_record(pai)
}
return(0);
}
static long read_ai(pai)
struct aiRecord *pai;
{
struct callback *pcallback=(struct callback *)(pai->dpvt);
int wait_time;
CALLBACK *pcallback = (CALLBACK *)pai->dpvt;
/* ai.inp must be a CONSTANT*/
switch (pai->inp.type) {
case (CONSTANT) :
@@ -132,13 +105,11 @@ static long read_ai(pai)
printf("Completed asynchronous processing: %s\n",pai->name);
return(2); /* don`t convert*/
} else {
wait_time = (int)(pai->disv * clockGetRate());
if(wait_time<=0) return(2);
callbackSetPriority(pai->prio,&pcallback->callback);
if(pai->disv<=0) return(2);
printf("Starting asynchronous processing: %s\n",pai->name);
watchdogStart(pcallback->wd_id,wait_time,
(WATCHDOGFUNC)callbackRequest,(void *)pcallback);
pai->pact=TRUE;
callbackRequestProcessCallbackDelayed(
pcallback,pai->prio,pai,(double)pai->disv);
return(0);
}
default :

View File

@@ -46,8 +46,6 @@
#include <stdio.h>
#include "alarm.h"
#include "osiWatchdog.h"
#include "osiClock.h"
#include "callback.h"
#include "cvtTable.h"
#include "dbDefs.h"
@@ -77,40 +75,17 @@ struct {
NULL,
write_ao,
NULL};
/* control block for callback*/
struct callback {
CALLBACK callback;
struct dbCommon *precord;
watchdogId wd_id;
};
static void myCallback(pcallback)
struct callback *pcallback;
{
struct dbCommon *precord=pcallback->precord;
struct rset *prset=(struct rset *)(precord->rset);
dbScanLock(precord);
(*prset->process)(precord);
dbScanUnlock(precord);
}
static long init_record(pao)
struct aoRecord *pao;
{
struct callback *pcallback;
CALLBACK *pcallback;
/* ao.out must be a CONSTANT*/
switch (pao->out.type) {
case (CONSTANT) :
pcallback = (struct callback *)(calloc(1,sizeof(struct callback)));
pcallback = (CALLBACK *)(calloc(1,sizeof(CALLBACK)));
pao->dpvt = (void *)pcallback;
callbackSetCallback(myCallback,&pcallback->callback);
pcallback->precord = (struct dbCommon *)pao;
pcallback->wd_id = watchdogCreate();
break;
default :
recGblRecordError(S_db_badField,(void *)pao,
@@ -119,12 +94,11 @@ static long init_record(pao)
}
return(2);
}
static long write_ao(pao)
struct aoRecord *pao;
{
struct callback *pcallback=(struct callback *)(pao->dpvt);
int wait_time;
CALLBACK *pcallback=(CALLBACK *)(pao->dpvt);
/* ao.out must be a CONSTANT*/
switch (pao->out.type) {
@@ -133,13 +107,11 @@ static long write_ao(pao)
printf("Completed asynchronous processing: %s\n",pao->name);
return(0);
} else {
wait_time = (int)(pao->disv * clockGetRate());
if(wait_time<=0) return(0);
callbackSetPriority(pao->prio,&pcallback->callback);
if(pao->disv<=0) return(0);
printf("Starting asynchronous processing: %s\n",pao->name);
watchdogStart(pcallback->wd_id,wait_time,
(WATCHDOGFUNC)callbackRequest,(void *)pcallback);
pao->pact=TRUE;
callbackRequestProcessCallbackDelayed(
pcallback,pao->prio,pao,(double)pao->disv);
return(0);
}
default :

View File

@@ -46,8 +46,6 @@
#include <string.h>
#include "alarm.h"
#include "osiWatchdog.h"
#include "osiClock.h"
#include "callback.h"
#include "dbDefs.h"
#include "dbAccess.h"
@@ -76,40 +74,17 @@ struct {
NULL,
read_bi,
NULL};
/* control block for callback*/
struct callback {
CALLBACK callback;
struct dbCommon *precord;
watchdogId wd_id;
};
static void myCallback(pcallback)
struct callback *pcallback;
{
struct dbCommon *precord=pcallback->precord;
struct rset *prset=(struct rset *)(precord->rset);
dbScanLock(precord);
(*prset->process)(precord);
dbScanUnlock(precord);
}
static long init_record(pbi)
struct biRecord *pbi;
{
struct callback *pcallback;
CALLBACK *pcallback;
/* bi.inp must be a CONSTANT*/
switch (pbi->inp.type) {
case (CONSTANT) :
pcallback = (struct callback *)(calloc(1,sizeof(struct callback)));
pcallback = (CALLBACK *)(calloc(1,sizeof(CALLBACK)));
pbi->dpvt = (void *)pcallback;
callbackSetCallback(myCallback,&pcallback->callback);
pcallback->precord = (struct dbCommon *)pbi;
pcallback->wd_id = watchdogCreate();
if(recGblInitConstantLink(&pbi->inp,DBF_ENUM,&pbi->val))
pbi->udf = FALSE;
break;
@@ -120,12 +95,11 @@ static long init_record(pbi)
}
return(0);
}
static long read_bi(pbi)
struct biRecord *pbi;
{
struct callback *pcallback=(struct callback *)(pbi->dpvt);
int wait_time;
CALLBACK *pcallback=(CALLBACK *)(pbi->dpvt);
/* bi.inp must be a CONSTANT*/
switch (pbi->inp.type) {
@@ -134,13 +108,11 @@ static long read_bi(pbi)
printf("%s Completed\n",pbi->name);
return(2); /* don't convert */
} else {
wait_time = (int)(pbi->disv * clockGetRate());
if(wait_time<=0) return(0);
callbackSetPriority(pbi->prio,&pcallback->callback);
printf("%s Starting asynchronous processing\n",pbi->name);
watchdogStart(pcallback->wd_id,wait_time,
(WATCHDOGFUNC)callbackRequest,(void *)pcallback);
pbi->pact=TRUE;
if(pbi->disv<=0) return(2);
printf("Starting asynchronous processing: %s\n",pbi->name);
pbi->pact=TRUE;
callbackRequestProcessCallbackDelayed(
pcallback,pbi->prio,pbi,(double)pbi->disv);
return(0);
}
default :

View File

@@ -46,8 +46,6 @@
#include <string.h>
#include "alarm.h"
#include "osiWatchdog.h"
#include "osiClock.h"
#include "callback.h"
#include "cvtTable.h"
#include "dbDefs.h"
@@ -77,39 +75,17 @@ struct {
NULL,
write_bo,
NULL};
/* control block for callback*/
struct callback {
CALLBACK callback;
struct dbCommon *precord;
watchdogId wd_id;
};
static void myCallback(pcallback)
struct callback *pcallback;
{
struct dbCommon *precord=pcallback->precord;
struct rset *prset=(struct rset *)(precord->rset);
dbScanLock(precord);
(*prset->process)(precord);
dbScanUnlock(precord);
}
static long init_record(pbo)
struct boRecord *pbo;
{
struct callback *pcallback;
CALLBACK *pcallback;
/* bo.out must be a CONSTANT*/
switch (pbo->out.type) {
case (CONSTANT) :
pcallback = (struct callback *)(calloc(1,sizeof(struct callback)));
pcallback = (CALLBACK *)(calloc(1,sizeof(CALLBACK)));
pbo->dpvt = (void *)pcallback;
callbackSetCallback(myCallback,&pcallback->callback);
pcallback->precord = (struct dbCommon *)pbo;
pcallback->wd_id = watchdogCreate();
break;
default :
recGblRecordError(S_db_badField,(void *)pbo,
@@ -118,12 +94,11 @@ static long init_record(pbo)
}
return(2);
}
static long write_bo(pbo)
struct boRecord *pbo;
{
struct callback *pcallback=(struct callback *)(pbo->dpvt);
int wait_time;
CALLBACK *pcallback=(CALLBACK *)(pbo->dpvt);
/* bo.out must be a CONSTANT*/
switch (pbo->out.type) {
@@ -132,13 +107,11 @@ static long write_bo(pbo)
printf("%s Completed\n",pbo->name);
return(0);
} else {
wait_time = (int)(pbo->disv * clockGetRate());
if(wait_time<=0) return(0);
callbackSetPriority(pbo->prio,&pcallback->callback);
printf("%s Starting asynchronous processing\n",pbo->name);
watchdogStart(pcallback->wd_id,wait_time,
(WATCHDOGFUNC)callbackRequest,(void *)pcallback);
pbo->pact=TRUE;
if(pbo->disv<=0) return(2);
printf("Starting asynchronous processing: %s\n",pbo->name);
pbo->pact=TRUE;
callbackRequestProcessCallbackDelayed(
pcallback,pbo->prio,pbo,(double)pbo->disv);
return(0);
}
default :

View File

@@ -38,14 +38,14 @@
#include <string.h>
#include "dbDefs.h"
#include "osiWatchdog.h"
#include "dbAccess.h"
#include "callback.h"
#include "dbScan.h"
#include "recSup.h"
#include "devSup.h"
#include "eventRecord.h"
/* Create the dset for devEventTestIoEvent */
static long init();
static long init_record();
static long get_ioint_info();
static long read_event();
struct {
@@ -58,45 +58,59 @@ struct {
}devEventTestIoEvent={
5,
NULL,
init,
NULL,
init_record,
get_ioint_info,
read_event
};
static IOSCANPVT ioscanpvt;
watchdogId wd_id=NULL;
static long init(after)
int after;
typedef struct myCallback {
CALLBACK callback;
IOSCANPVT ioscanpvt;
}myCallback;
static void myCallbackFunc(CALLBACK *arg)
{
if(after) return(0);
scanIoInit(&ioscanpvt);
return(0);
myCallback *pcallback;
callbackGetUser(pcallback,arg);
scanIoRequest(pcallback->ioscanpvt);
}
static long init_record(pevent,pass)
eventRecord *pevent;
int pass;
{
myCallback *pcallback;
pcallback = (myCallback *)(calloc(1,sizeof(myCallback)));
scanIoInit(&pcallback->ioscanpvt);
callbackSetCallback(myCallbackFunc,&pcallback->callback);
callbackSetUser(pcallback,&pcallback->callback);
pevent->dpvt = (void *)pcallback;
return(0);
}
static long get_ioint_info(
int cmd,
struct eventRecord *pr,
struct eventRecord *pevent,
IOSCANPVT *ppvt)
{
myCallback *pcallback = (myCallback *)pevent->dpvt;
*ppvt = ioscanpvt;
*ppvt = pcallback->ioscanpvt;
return(0);
}
static long read_event(pevent)
struct eventRecord *pevent;
{
int wait_time;
myCallback *pcallback= (myCallback *)pevent->dpvt;
wait_time = (int)pevent->proc;
if(wait_time<=0) return(0);
pevent->udf = FALSE;
if(wd_id==NULL) wd_id = watchdogCreate();
printf("%s Requesting Next ioEnevt\n",pevent->name);
watchdogStart(wd_id,wait_time,
(WATCHDOGFUNC)scanIoRequest,(void *)ioscanpvt);
return(0);
if(pevent->proc<=0) return(0);
pevent->udf = FALSE;
printf("%s Requesting Next ioEnevt\n",pevent->name);
callbackRequestDelayed(&pcallback->callback,(double)pevent->proc);
return(0);
}

View File

@@ -41,8 +41,6 @@
#include <string.h>
#include "alarm.h"
#include "osiWatchdog.h"
#include "osiClock.h"
#include "callback.h"
#include "cvtTable.h"
#include "dbDefs.h"
@@ -72,38 +70,17 @@ struct {
NULL,
read_histogram,
NULL};
/* control block for callback*/
struct callback {
CALLBACK callback;
struct dbCommon *precord;
watchdogId wd_id;
};
static void myCallback(pcallback)
struct callback *pcallback;
{
struct dbCommon *precord=pcallback->precord;
struct rset *prset=(struct rset *)(precord->rset);
dbScanLock(precord);
(*prset->process)(precord);
dbScanUnlock(precord);
}
static long init_record(phistogram)
struct histogramRecord *phistogram;
{
struct callback *pcallback;
CALLBACK *pcallback;
/* histogram.svl must be a CONSTANT*/
switch (phistogram->svl.type) {
case (CONSTANT) :
pcallback = (struct callback *)(calloc(1,sizeof(struct callback)));
pcallback = (CALLBACK *)(calloc(1,sizeof(CALLBACK)));
phistogram->dpvt = (void *)pcallback;
callbackSetCallback(myCallback,&pcallback->callback);
pcallback->precord = (struct dbCommon *)phistogram;
pcallback->wd_id = watchdogCreate();
if(recGblInitConstantLink(&phistogram->svl,DBF_DOUBLE,&phistogram->sgnl))
phistogram->udf = FALSE;
break;
@@ -118,8 +95,7 @@ static long init_record(phistogram)
static long read_histogram(phistogram)
struct histogramRecord *phistogram;
{
struct callback *pcallback=(struct callback *)(phistogram->dpvt);
int wait_time;
CALLBACK *pcallback=(CALLBACK *)(phistogram->dpvt);
/* histogram.svl must be a CONSTANT*/
switch (phistogram->svl.type) {
@@ -128,13 +104,13 @@ static long read_histogram(phistogram)
printf("%s Completed\n",phistogram->name);
return(0); /*add count*/
} else {
wait_time = (int)(phistogram->disv * clockGetRate());
if(wait_time<=0) return(0);
callbackSetPriority(phistogram->prio,&pcallback->callback);
printf("%s Starting asynchronous processing\n",phistogram->name);
watchdogStart(pcallback->wd_id,wait_time,
(WATCHDOGFUNC)callbackRequest,(void *)pcallback);
phistogram->pact=TRUE;
if(phistogram->disv<=0) return(2);
printf("Starting asynchronous processing: %s\n",
phistogram->name);
phistogram->pact=TRUE;
callbackRequestProcessCallbackDelayed(
pcallback,phistogram->prio,phistogram,
(double)phistogram->disv);
return(0);
}
default :

View File

@@ -46,8 +46,6 @@
#include <string.h>
#include "alarm.h"
#include "osiWatchdog.h"
#include "osiClock.h"
#include "callback.h"
#include "dbDefs.h"
#include "dbAccess.h"
@@ -76,39 +74,17 @@ struct {
NULL,
read_mbbi,
NULL};
/* control block for callback*/
struct callback {
CALLBACK callback;
struct dbCommon *precord;
watchdogId wd_id;
};
static void myCallback(pcallback)
struct callback *pcallback;
{
struct dbCommon *precord=pcallback->precord;
struct rset *prset=(struct rset *)(precord->rset);
dbScanLock(precord);
(*prset->process)(precord);
dbScanUnlock(precord);
}
static long init_record(pmbbi)
struct mbbiRecord *pmbbi;
{
struct callback *pcallback;
CALLBACK *pcallback;
/* mbbi.inp must be a CONSTANT*/
switch (pmbbi->inp.type) {
case (CONSTANT) :
pcallback = (struct callback *)(calloc(1,sizeof(struct callback)));
pcallback = (CALLBACK *)(calloc(1,sizeof(CALLBACK)));
pmbbi->dpvt = (void *)pcallback;
callbackSetCallback(myCallback,&pcallback->callback);
pcallback->precord = (struct dbCommon *)pmbbi;
pcallback->wd_id = watchdogCreate();
if(recGblInitConstantLink(&pmbbi->inp,DBF_ENUM,&pmbbi->val))
pmbbi->udf = FALSE;
break;
@@ -119,12 +95,11 @@ static long init_record(pmbbi)
}
return(0);
}
static long read_mbbi(pmbbi)
struct mbbiRecord *pmbbi;
{
struct callback *pcallback=(struct callback *)(pmbbi->dpvt);
int wait_time;
CALLBACK *pcallback=(CALLBACK *)(pmbbi->dpvt);
/* mbbi.inp must be a CONSTANT*/
switch (pmbbi->inp.type) {
@@ -133,13 +108,11 @@ static long read_mbbi(pmbbi)
printf("%s Completed\n",pmbbi->name);
return(2); /* don't convert */
} else {
wait_time = (int)(pmbbi->disv * clockGetRate());
if(wait_time<=0) return(0);
callbackSetPriority(pmbbi->prio,&pcallback->callback);
printf("%s Starting asynchronous processing\n",pmbbi->name);
watchdogStart(pcallback->wd_id,wait_time,
(WATCHDOGFUNC)callbackRequest,(void *)pcallback);
pmbbi->pact=TRUE;
if(pmbbi->disv<=0) return(2);
printf("Starting asynchronous processing: %s\n",pmbbi->name);
pmbbi->pact=TRUE;
callbackRequestProcessCallbackDelayed(
pcallback,pmbbi->prio,pmbbi,(double)pmbbi->disv);
return(0);
}
default :

View File

@@ -46,8 +46,6 @@
#include <string.h>
#include "alarm.h"
#include "osiWatchdog.h"
#include "osiClock.h"
#include "callback.h"
#include "cvtTable.h"
#include "dbDefs.h"
@@ -77,40 +75,17 @@ struct {
NULL,
write_mbbo,
NULL};
/* control block for callback*/
struct callback {
CALLBACK callback;
struct dbCommon *precord;
watchdogId wd_id;
};
static void myCallback(pcallback)
struct callback *pcallback;
{
struct dbCommon *precord=pcallback->precord;
struct rset *prset=(struct rset *)(precord->rset);
dbScanLock(precord);
(*prset->process)(precord);
dbScanUnlock(precord);
}
static long init_record(pmbbo)
struct mbboRecord *pmbbo;
{
struct callback *pcallback;
CALLBACK *pcallback;
/* mbbo.out must be a CONSTANT*/
switch (pmbbo->out.type) {
case (CONSTANT) :
pcallback = (struct callback *)(calloc(1,sizeof(struct callback)));
pcallback = (CALLBACK *)(calloc(1,sizeof(CALLBACK)));
pmbbo->dpvt = (void *)pcallback;
callbackSetCallback(myCallback,&pcallback->callback);
pcallback->precord = (struct dbCommon *)pmbbo;
pcallback->wd_id = watchdogCreate();
break;
default :
recGblRecordError(S_db_badField,(void *)pmbbo,
@@ -119,12 +94,11 @@ static long init_record(pmbbo)
}
return(2);
}
static long write_mbbo(pmbbo)
struct mbboRecord *pmbbo;
{
struct callback *pcallback=(struct callback *)(pmbbo->dpvt);
int wait_time;
CALLBACK *pcallback=(CALLBACK *)(pmbbo->dpvt);
/* mbbo.out must be a CONSTANT*/
switch (pmbbo->out.type) {
@@ -133,13 +107,11 @@ static long write_mbbo(pmbbo)
printf("%s Completed\n",pmbbo->name);
return(0);
} else {
wait_time = (int)(pmbbo->disv * clockGetRate());
if(wait_time<=0) return(0);
callbackSetPriority(pmbbo->prio,&pcallback->callback);
printf("%s Starting asynchronous processing\n",pmbbo->name);
watchdogStart(pcallback->wd_id,wait_time,
(WATCHDOGFUNC)callbackRequest,(void *)pcallback);
pmbbo->pact=TRUE;
if(pmbbo->disv<=0) return(2);
printf("Starting asynchronous processing: %s\n",pmbbo->name);
pmbbo->pact=TRUE;
callbackRequestProcessCallbackDelayed(
pcallback,pmbbo->prio,pmbbo,(double)pmbbo->disv);
return(0);
}
default :

View File

@@ -45,8 +45,6 @@
#include <string.h>
#include "alarm.h"
#include "osiWatchdog.h"
#include "osiClock.h"
#include "callback.h"
#include "dbDefs.h"
#include "dbAccess.h"
@@ -75,39 +73,17 @@ struct {
NULL,
read_stringin,
NULL};
/* control block for callback*/
struct callback {
CALLBACK callback;
struct dbCommon *precord;
watchdogId wd_id;
};
static void myCallback(pcallback)
struct callback *pcallback;
{
struct dbCommon *precord=pcallback->precord;
struct rset *prset=(struct rset *)(precord->rset);
dbScanLock(precord);
(*prset->process)(precord);
dbScanUnlock(precord);
}
static long init_record(pstringin)
struct stringinRecord *pstringin;
{
struct callback *pcallback;
CALLBACK *pcallback;
/* stringin.inp must be a CONSTANT*/
switch (pstringin->inp.type) {
case (CONSTANT) :
pcallback = (struct callback *)(calloc(1,sizeof(struct callback)));
pcallback = (CALLBACK *)(calloc(1,sizeof(CALLBACK)));
pstringin->dpvt = (void *)pcallback;
callbackSetCallback(myCallback,&pcallback->callback);
pcallback->precord = (struct dbCommon *)pstringin;
pcallback->wd_id = watchdogCreate();
if(recGblInitConstantLink(&pstringin->inp,DBF_STRING,pstringin->val))
pstringin->udf = FALSE;
break;
@@ -122,8 +98,7 @@ static long init_record(pstringin)
static long read_stringin(pstringin)
struct stringinRecord *pstringin;
{
struct callback *pcallback=(struct callback *)(pstringin->dpvt);
int wait_time;
CALLBACK *pcallback=(CALLBACK *)(pstringin->dpvt);
/* stringin.inp must be a CONSTANT*/
switch (pstringin->inp.type) {
@@ -132,13 +107,13 @@ static long read_stringin(pstringin)
printf("%s Completed\n",pstringin->name);
return(0);
} else {
wait_time = (int)(pstringin->disv * clockGetRate());
if(wait_time<=0) return(0);
callbackSetPriority(pstringin->prio,&pcallback->callback);
printf("%s Starting asynchronous processing\n",pstringin->name);
watchdogStart(pcallback->wd_id,wait_time,
(WATCHDOGFUNC)callbackRequest,(void *)pcallback);
pstringin->pact=TRUE;
if(pstringin->disv<=0) return(2);
printf("Starting asynchronous processing: %s\n",
pstringin->name);
pstringin->pact=TRUE;
callbackRequestProcessCallbackDelayed(
pcallback,pstringin->prio,pstringin,
(double)pstringin->disv);
return(0);
}
default :

View File

@@ -45,8 +45,6 @@
#include <string.h>
#include "alarm.h"
#include "osiWatchdog.h"
#include "osiClock.h"
#include "callback.h"
#include "cvtTable.h"
#include "dbDefs.h"
@@ -76,39 +74,17 @@ struct {
NULL,
write_stringout,
NULL};
/* control block for callback*/
struct callback {
CALLBACK callback;
struct dbCommon *precord;
watchdogId wd_id;
};
static void myCallback(pcallback)
struct callback *pcallback;
{
struct dbCommon *precord=pcallback->precord;
struct rset *prset=(struct rset *)(precord->rset);
dbScanLock(precord);
(*prset->process)(precord);
dbScanUnlock(precord);
}
static long init_record(pstringout)
struct stringoutRecord *pstringout;
{
struct callback *pcallback;
CALLBACK *pcallback;
/* stringout.out must be a CONSTANT*/
switch (pstringout->out.type) {
case (CONSTANT) :
pcallback = (struct callback *)(calloc(1,sizeof(struct callback)));
pcallback = (CALLBACK *)(calloc(1,sizeof(CALLBACK)));
pstringout->dpvt = (void *)pcallback;
callbackSetCallback(myCallback,&pcallback->callback);
pcallback->precord = (struct dbCommon *)pstringout;
pcallback->wd_id = watchdogCreate();
break;
default :
recGblRecordError(S_db_badField,(void *)pstringout,
@@ -117,12 +93,11 @@ static long init_record(pstringout)
}
return(0);
}
static long write_stringout(pstringout)
struct stringoutRecord *pstringout;
{
struct callback *pcallback=(struct callback *)(pstringout->dpvt);
int wait_time;
CALLBACK *pcallback=(CALLBACK *)(pstringout->dpvt);
/* stringout.out must be a CONSTANT*/
switch (pstringout->out.type) {
@@ -131,13 +106,13 @@ static long write_stringout(pstringout)
printf("%s Completed\n",pstringout->name);
return(0); /* don`t convert*/
} else {
wait_time = (int)(pstringout->disv * clockGetRate());
if(wait_time<=0) return(0);
callbackSetPriority(pstringout->prio,&pcallback->callback);
printf("%s Starting asynchronous processing\n",pstringout->name);
watchdogStart(pcallback->wd_id,wait_time,
(WATCHDOGFUNC)callbackRequest,(void *)pcallback);
pstringout->pact=TRUE;
if(pstringout->disv<=0) return(2);
printf("Starting asynchronous processing: %s\n",
pstringout->name);
pstringout->pact=TRUE;
callbackRequestProcessCallbackDelayed(
pcallback,pstringout->prio,pstringout,
(double)pstringout->disv);
return(0);
}
default :

View File

@@ -46,8 +46,6 @@
#include <string.h>
#include "alarm.h"
#include "osiWatchdog.h"
#include "osiClock.h"
#include "callback.h"
#include "dbDefs.h"
#include "dbAccess.h"
@@ -76,38 +74,17 @@ struct {
NULL,
read_wf,
NULL};
/* control block for callback*/
struct callback {
CALLBACK callback;
struct dbCommon *precord;
watchdogId wd_id;
};
static void myCallback(pcallback)
struct callback *pcallback;
{
struct dbCommon *precord=pcallback->precord;
struct rset *prset=(struct rset *)(precord->rset);
dbScanLock(precord);
(*prset->process)(precord);
dbScanUnlock(precord);
}
static long init_record(pwf)
struct waveformRecord *pwf;
{
struct callback *pcallback;
CALLBACK *pcallback;
/* wf.inp must be a CONSTANT*/
switch (pwf->inp.type) {
case (CONSTANT) :
pcallback = (struct callback *)(calloc(1,sizeof(struct callback)));
pcallback = (CALLBACK *)(calloc(1,sizeof(CALLBACK)));
pwf->dpvt = (void *)pcallback;
callbackSetCallback(myCallback,&pcallback->callback);
pcallback->precord = (struct dbCommon *)pwf;
pcallback->wd_id = watchdogCreate();
pwf->nord = 0;
break;
default :
@@ -117,12 +94,11 @@ static long init_record(pwf)
}
return(0);
}
static long read_wf(pwf)
struct waveformRecord *pwf;
{
struct callback *pcallback=(struct callback *)(pwf->dpvt);
int wait_time;
CALLBACK *pcallback=(CALLBACK *)(pwf->dpvt);
/* wf.inp must be a CONSTANT*/
switch (pwf->inp.type) {
@@ -131,12 +107,11 @@ static long read_wf(pwf)
printf("%s Completed\n",pwf->name);
return(0); /* don`t convert*/
} else {
wait_time = (int)(pwf->disv * clockGetRate());
if(wait_time<=0) return(0);
callbackSetPriority(pwf->prio,&pcallback->callback);
printf("%s Starting asynchronous processing\n",pwf->name);
watchdogStart(pcallback->wd_id,wait_time,
(WATCHDOGFUNC)callbackRequest,(void *)pcallback);
if(pwf->disv<=0) return(2);
printf("Starting asynchronous processing: %s\n",pwf->name);
pwf->pact=TRUE;
callbackRequestProcessCallbackDelayed(
pcallback,pwf->prio,pwf,(double)pwf->disv);
pwf->pact=TRUE;
return(0);
}