Пример #1
0
static long process(stringoutRecord *prec)
{
	struct stringoutdset	*pdset = (struct stringoutdset *)(prec->dset);
	long		 status=0;
	unsigned char    pact=prec->pact;

	if( (pdset==NULL) || (pdset->write_stringout==NULL) ) {
		prec->pact=TRUE;
		recGblRecordError(S_dev_missingSup,(void *)prec,"write_stringout");
		return(S_dev_missingSup);
	}
        if (!prec->pact
        && (prec->dol.type != CONSTANT)
        && (prec->omsl == menuOmslclosed_loop)) {
		status = dbGetLink(&(prec->dol),
			DBR_STRING,prec->val,0,0);
		if(prec->dol.type!=CONSTANT && RTN_SUCCESS(status)) prec->udf=FALSE;
	}

        if(prec->udf == TRUE ){
                recGblSetSevr(prec,UDF_ALARM,INVALID_ALARM);
        }

        if (prec->nsev < INVALID_ALARM )
                status=writeValue(prec); /* write the new value */
        else {
                switch (prec->ivoa) {
                    case (menuIvoaContinue_normally) :
                        status=writeValue(prec); /* write the new value */
                        break;
                    case (menuIvoaDon_t_drive_outputs) :
                        break;
                    case (menuIvoaSet_output_to_IVOV) :
                        if(prec->pact == FALSE){
                                strcpy(prec->val,prec->ivov);
                        }
                        status=writeValue(prec); /* write the new value */
                        break;
                    default :
                        status=-1;
                        recGblRecordError(S_db_badField,(void *)prec,
                                "stringout:process Illegal IVOA field");
                }
        }

	/* check if device support set pact */
	if ( !pact && prec->pact ) return(0);

	prec->pact = TRUE;
	recGblGetTimeStamp(prec);
	monitor(prec);
	recGblFwdLink(prec);
	prec->pact=FALSE;
	return(status);
}
static long process(permissiveRecord *prec)
{

    prec->pact=TRUE;
    prec->udf=FALSE;
    recGblGetTimeStamp(prec);
    monitor(prec);
    recGblFwdLink(prec);
    prec->pact=FALSE;
    return(0);
}
Пример #3
0
static long process(aliveRecord *prec)
{
  prec->pact = TRUE;
  prec->udf = FALSE;

  /* process the forward scan link record */
  recGblFwdLink(prec);

  prec->pact=FALSE;

  return 0;
}
Пример #4
0
static long process(compressRecord *prec)
{
    long	status=0;
    long	nelements = 0;
    int		alg = prec->alg;

    prec->pact = TRUE;
    if(!dbIsLinkConnected(&prec->inp)
    || dbGetNelements(&prec->inp,&nelements)
    || nelements<=0) {
	recGblSetSevr(prec,LINK_ALARM,INVALID_ALARM);
    } else {
	if(!prec->wptr || nelements!=prec->inpn) {
            if(prec->wptr) {
                free(prec->wptr);
                reset(prec);
            }
	    prec->wptr = (double *)dbCalloc(nelements,sizeof(double));
	    prec->inpn = nelements;
	}
	status = dbGetLink(&prec->inp,DBF_DOUBLE,prec->wptr,0,&nelements);
	if(status || nelements<=0) {
            recGblSetSevr(prec,LINK_ALARM,INVALID_ALARM);
	    status = 0;
	} else {
	    if(alg==compressALG_Average) {
		status = array_average(prec,prec->wptr,nelements);
	    } else if(alg==compressALG_Circular_Buffer) {
		(void)put_value(prec,prec->wptr,nelements);
		status = 0;
	    } else if(nelements>1) {
		status = compress_array(prec,prec->wptr,nelements);
	    }else if(nelements==1){
		status = compress_scalar(prec,prec->wptr);
	    }else status=1;
	}
    }
    /* check event list */
    if(status!=1) {
		prec->udf=FALSE;
		recGblGetTimeStamp(prec);
		monitor(prec);
		/* process the forward scan link record */
		recGblFwdLink(prec);
    }
    prec->pact=FALSE;
    return(0);
}
Пример #5
0
static long process(void *precord)
{
	ushortRecord	*pushort = (ushortRecord *)precord;

	pushort->pact = TRUE;

	recGblGetTimeStamp(pushort);
	/* check for alarms */
	checkAlarms(pushort);
	/* check event list */
	monitor(pushort);
	/* process the forward scan link record */
        recGblFwdLink(pushort);

	pushort->pact=FALSE;
	return(0);
}
Пример #6
0
LOCAL long process(ab1771IXRecord *precord)
{
    recordPvt	*precordPvt = (recordPvt *)precord->dpvt;

    if(precordPvt->err == errFatal) {
	precord->pact = TRUE;
	return(0);
    }
    if(!precord->pact) {/* starting new request*/
	if(precord->cmd==ab1771IX_Init) {
	    precordPvt->msgState = msgStateInit;
	    precord->cmd = ab1771IX_CMD_None;
	    db_post_events(precord,&precord->cmd,DBE_VALUE|DBE_LOG);
	}
	precordPvt->err = errOK;
  	/* starting new request*/
	switch(precordPvt->msgState) {
	    case msgStateInit:
	        msgInit(precord);
		break;
	    case msgStateGet:
	    case msgStateDone:
		msgGet(precord);
		break;
	    default: break;
	}/*Note that state may switch because of msgRequest just issued*/
    }
    switch(precordPvt->msgState) {
	case msgStateWaitInit: 
	case msgStateWaitGet: 
	    precord->pact = TRUE;
	    precordPvt->waitAsynComplete = TRUE;
	    return(0);
	default:
	    break;
    }
    precord->pact = TRUE;
    monitor(precord);
    recGblFwdLink(precord);
    precordPvt->waitAsynComplete = FALSE;
    if(precordPvt->err != errFatal) precord->pact = FALSE;
    return(0);
}
Пример #7
0
static long process(selRecord *prec)
{
    prec->pact = TRUE;
    if ( RTN_SUCCESS(fetch_values(prec)) ) {
	do_sel(prec);
    }

    recGblGetTimeStamp(prec);
    /* check for alarms */
    checkAlarms(prec);


    /* check event list */
    monitor(prec);

    /* process the forward scan link record */
    recGblFwdLink(prec);

    prec->pact=FALSE;
    return(0);
}
Пример #8
0
/*****************************************************************************
 *
 * Finish record processing by posting any events and processing forward links.
 *
 * NOTE:
 *   dbScanLock is already held for prec before this function is called.
 *
 ******************************************************************************/
static long asyncFinish(seqRecord *prec)
{
  unsigned short MonitorMask;

  if (seqRecDebug > 5)
    printf("asyncFinish(%s) completing processing\n", prec->name);
  prec->udf = FALSE;

  recGblGetTimeStamp(prec);

  MonitorMask = recGblResetAlarms(prec);

  if (MonitorMask)
    db_post_events(prec, &prec->val, MonitorMask);

  /* process the forward scan link record */
  recGblFwdLink(prec);

  prec->pact = FALSE;

  return(0);
}
Пример #9
0
static long process(aSubRecord *prec)
{
    int pact = prec->pact;
    long status = 0;

    if (!pact) {
        prec->pact = TRUE;
        status = fetch_values(prec);
        prec->pact = FALSE;
    }

    if (!status) {
        status = do_sub(prec);
        prec->val = status;
    }

    if (!pact && prec->pact)
        return 0;

    prec->pact = TRUE;

    /* Push the output link values */
    if (!status) {
        int i;

        for (i = 0; i < NUM_ARGS; i++)
            dbPutLink(&(&prec->outa)[i], (&prec->ftva)[i], (&prec->vala)[i],
                (&prec->neva)[i]);
    }

    recGblGetTimeStamp(prec);
    monitor(prec);
    recGblFwdLink(prec);
    prec->pact = FALSE;

    return 0;
}
Пример #10
0
static long process(boRecord *prec)
{
	struct bodset	*pdset = (struct bodset *)(prec->dset);
	long		 status=0;
	unsigned char    pact=prec->pact;

	if( (pdset==NULL) || (pdset->write_bo==NULL) ) {
		prec->pact=TRUE;
		recGblRecordError(S_dev_missingSup,(void *)prec,"write_bo");
		return(S_dev_missingSup);
	}
        if (!prec->pact) {
		if ((prec->dol.type != CONSTANT) && (prec->omsl == menuOmslclosed_loop)){
			unsigned short val;

			prec->pact = TRUE;
			status=dbGetLink(&prec->dol,DBR_USHORT, &val,0,0);
			prec->pact = FALSE;
			if(status==0){
				prec->val = val;
				prec->udf = FALSE;
			}else {
       				recGblSetSevr(prec,LINK_ALARM,INVALID_ALARM);
			}
		}

		/* convert val to rval */
		if ( prec->mask != 0 ) {
			if(prec->val==0) prec->rval = 0;
			else prec->rval = prec->mask;
		} else prec->rval = (epicsUInt32)prec->val;
	}

	/* check for alarms */
	checkAlarms(prec);

        if (prec->nsev < INVALID_ALARM )
                status=writeValue(prec); /* write the new value */
        else {
                switch (prec->ivoa) {
                    case (menuIvoaContinue_normally) :
                        status=writeValue(prec); /* write the new value */
                        break;
                    case (menuIvoaDon_t_drive_outputs) :
                        break;
                    case (menuIvoaSet_output_to_IVOV) :
                        if(prec->pact == FALSE){
				/* convert val to rval */
                                prec->val=prec->ivov;
				if ( prec->mask != 0 ) {
					if(prec->val==0) prec->rval = 0;
					else prec->rval = prec->mask;
				} else prec->rval = (epicsUInt32)prec->val;
			}
                        status=writeValue(prec); /* write the new value */
                        break;
                    default :
                        status=-1;
                        recGblRecordError(S_db_badField,(void *)prec,
                                "bo:process Illegal IVOA field");
                }
        }

	/* check if device support set pact */
	if ( !pact && prec->pact ) return(0);
	prec->pact = TRUE;

	recGblGetTimeStamp(prec);
	if((prec->val==1) && (prec->high>0)){
	    myCallback *pcallback;
	    pcallback = (myCallback *)(prec->rpvt);
            callbackSetPriority(prec->prio, &pcallback->callback);
            callbackRequestDelayed(&pcallback->callback,(double)prec->high);
	}
	/* check event list */
	monitor(prec);
	/* process the forward scan link record */
	recGblFwdLink(prec);

	prec->pact=FALSE;
	return(status);
}
Пример #11
0
static long process(struct cvtRecord *pcvt)
{
    long status = 0;

    pcvt->pact = TRUE;
    status = dbGetLink(&pcvt->inil, DBR_UCHAR, &pcvt->init, 0, 0);
    pcvt->pact = FALSE;

    if (status) {
        recGblSetSevr(pcvt, LINK_ALARM, INVALID_ALARM);
        goto error;
    }
    if (checkInit(pcvt)) {
        recGblSetSevr(pcvt, SOFT_ALARM, INVALID_ALARM);
        recGblResetAlarms(pcvt);
        pcvt->pact = TRUE;
        return -1;
    }

    pcvt->pact = TRUE;
    status = readInputs(pcvt);
    pcvt->pact = FALSE;

    if (status) {
        goto error;
    }

    status = convert(pcvt);

error:
    checkAlarms(pcvt);

    pcvt->pact = TRUE;
    if (pcvt->nsev < INVALID_ALARM) {
        status = dbPutLink(&pcvt->out, DBR_DOUBLE, &pcvt->val, 1);
    }
    else {
        switch (pcvt->ivoa) {
        case (menuIvoaSet_output_to_IVOV):
            pcvt->val = pcvt->ivov;
            /* note: this falls through to the case below */
        case (menuIvoaContinue_normally):
            status = dbPutLink(&pcvt->out, DBR_DOUBLE, &pcvt->val, 1);
        case (menuIvoaDon_t_drive_outputs):
            break;
        default:
            status = S_db_badField;
            errmsg("internal error: Illegal value in IVOA field");
            recGblSetSevr(pcvt, SOFT_ALARM, INVALID_ALARM);
            recGblResetAlarms(pcvt);
            return status;
        }
    }

    recGblGetTimeStamp(pcvt);
    monitor(pcvt);
    recGblFwdLink(pcvt);

    pcvt->pact = FALSE;

    return status;
}
Пример #12
0
static long process(acalcoutRecord *pcalc)
{
	rpvtStruct   *prpvt = (rpvtStruct *)pcalc->rpvt;
	long		i;
	double		*pnew, *pprev;

	if (aCalcoutRecordDebug) printf("acalcoutRecord(%s):process: pact=%d, cact=%d, dlya=%d\n",
		pcalc->name, pcalc->pact, pcalc->cact, pcalc->dlya);

	/* Make sure.  Autosave is capable of setting NUSE to an illegal value. */
	if ((pcalc->nuse < 0) || (pcalc->nuse > pcalc->nelm)) {
		pcalc->nuse = pcalc->nelm;
		db_post_events(pcalc,&pcalc->nuse, DBE_VALUE|DBE_LOG);
	}

	/* If we're getting processed, we can no longer put off allocating memory */
	if (pcalc->aval == NULL) pcalc->aval = (double *)calloc(pcalc->nelm, sizeof(double));
	if (pcalc->oav == NULL) pcalc->oav = (double *)calloc(pcalc->nelm, sizeof(double));

	if (!pcalc->pact) {
		pcalc->pact = TRUE;

		/* record scalar-field values so we can tell which ones aCalcPerform wrote to. */
		for (i=0, pnew=&pcalc->a, pprev=&pcalc->pa; i<MAX_FIELDS;  i++, pnew++, pprev++) {
			*pprev = *pnew;
		}

		/* if some links are CA, check connections */
		if (prpvt->caLinkStat != NO_CA_LINKS) checkLinks(pcalc);
		if (fetch_values(pcalc)==0) {
			long stat;

			if (aCalcoutRecordDebug >= 5) printf("acalcoutRecord(%s):process: queueing aCalcPerform\n", pcalc->name);

			pcalc->cact = 0;
			stat = doCalc(pcalc);
			if (stat) printf("%s:process: doCalc failed.\n", pcalc->name);
			if (stat == 0 && pcalc->cact == 1) {
				pcalc->pact = 1;
				/* we'll get processed again when the calculation is done */
				return(0);
			} else {
				if (afterCalc(pcalc) == ASYNC) return(0);
			}
		}
	} else { /* pact == TRUE */

		/* Who invoked us ? */
		if (pcalc->cact) {
			pcalc->cact = 0;
			if (afterCalc(pcalc) == ASYNC) return(0);
		} else if (pcalc->dlya) {
			/* callbackRequestProcessCallbackDelayed() called us */
			pcalc->dlya = 0;
			db_post_events(pcalc,&pcalc->dlya,DBE_VALUE);

			/* Must set pact 0 so that asynchronous device support works */
			pcalc->pact = 0;
			execOutput(pcalc);
			if (pcalc->pact) return(0);
			pcalc->pact = TRUE;
		} else {
			/* We must have been called by asynchronous device support */
			writeValue(pcalc);
		}
	}
	/*checkAlarms(pcalc); This is too late; IVOA might have vetoed output */
	recGblGetTimeStamp(pcalc);

	if (aCalcoutRecordDebug >= 5) {
		printf("acalcoutRecord(%s):process:calling monitor \n", pcalc->name);
	}

    monitor(pcalc);
    recGblFwdLink(pcalc);
    pcalc->pact = FALSE;

	if (aCalcoutRecordDebug >= 5) {
		printf("acalcoutRecord(%s):process-done\n", pcalc->name);
	}
	if (aCalcoutRecordDebug) printf("acalcoutRecord(%s):process: exit, pact==0\n",
		pcalc->name);
	return(0);
}
Пример #13
0
static long process(lsoRecord *prec)
{
    int pact = prec->pact;
    lsodset *pdset = (lsodset *) prec->dset;
    long status = 0;

    if (!pdset || !pdset->write_string) {
        prec->pact = TRUE;
        recGblRecordError(S_dev_missingSup, prec, "lso: write_string");
        return S_dev_missingSup;
    }

    if (!pact && prec->omsl == menuOmslclosed_loop)
        if (!dbGetLinkLS(&prec->dol, prec->val, prec->sizv, &prec->len))
            prec->udf = FALSE;

    if (prec->udf)
        recGblSetSevr(prec, UDF_ALARM, INVALID_ALARM);

    if (prec->nsev < INVALID_ALARM )
        status = writeValue(prec);      /* write the new value */
    else {
        switch (prec->ivoa) {
        case menuIvoaContinue_normally:
            status = writeValue(prec);  /* write the new value */
            break;

        case menuIvoaDon_t_drive_outputs:
            break;

        case menuIvoaSet_output_to_IVOV:
            if (!prec->pact) {
                size_t size = prec->sizv - 1;

                strncpy(prec->val, prec->ivov, size);
                prec->val[size] = 0;
                prec->len = strlen(prec->val) + 1;
            }
            status = writeValue(prec);  /* write the new value */
            break;

        default:
            status = -1;
            recGblRecordError(S_db_badField, prec,
                "lso:process Bad IVOA choice");
        }
    }

    /* Asynchronous if device support set pact */
    if (!pact && prec->pact)
        return status;

    prec->pact = TRUE;
    recGblGetTimeStamp(prec);

    monitor(prec);

    /* Wrap up */
    recGblFwdLink(prec);
    prec->pact = FALSE;
    return status;
}
static long process(struct timestampRecord *ptimestamp){

#if EPICS_VERSION >= 3 && EPICS_REVISION >= 14
#else
  struct tsDetail time_s;
#endif
  
  ptimestamp->udf  = FALSE;
  ptimestamp->pact = TRUE;

  recGblGetTimeStamp(ptimestamp);
  ptimestamp->sec  = ptimestamp->time.secPastEpoch;
  ptimestamp->nsec = ptimestamp->time.nsec;
  
#if EPICS_VERSION >= 3 && EPICS_REVISION >= 14  
  switch(ptimestamp->tst) {
  case timestampTST_YY_MM_DD_HH_MM_SS:
    epicsTimeToStrftime(ptimestamp->val,sizeof(ptimestamp->val),
                        "%y/%m/%d %H:%M:%S",&ptimestamp->time);
    break;
  case timestampTST_MM_DD_YY_HH_MM_SS:
    epicsTimeToStrftime(ptimestamp->val,sizeof(ptimestamp->val),
                        "%m/%d/%y %H:%M:%S",&ptimestamp->time);
    break;
  case timestampTST_MM_DD_HH_MM_SS_YY:
    epicsTimeToStrftime(ptimestamp->val,sizeof(ptimestamp->val),
                        "%b %d %H:%M:%S %y",&ptimestamp->time);
    break;
  case timestampTST_MM_DD_HH_MM_SS:
    epicsTimeToStrftime(ptimestamp->val,sizeof(ptimestamp->val),
                        "%b %d %H:%M:%S",&ptimestamp->time);
    break;
  case timestampTST_HH_MM_SS:
    epicsTimeToStrftime(ptimestamp->val,sizeof(ptimestamp->val),
                        "%H:%M:%S",&ptimestamp->time);
    break;
  case timestampTST_HH_MM:
    epicsTimeToStrftime(ptimestamp->val,sizeof(ptimestamp->val),
                        "%H:%M",&ptimestamp->time);
    break;
  case timestampTST_DD_MM_YY_HH_MM_SS:
    epicsTimeToStrftime(ptimestamp->val,sizeof(ptimestamp->val),
                        "%d/%m/%y %H:%M:%S",&ptimestamp->time);
    break;
  case timestampTST_DD_MM_HH_MM_SS_YY:
    epicsTimeToStrftime(ptimestamp->val,sizeof(ptimestamp->val),
                        "%d %b %H:%M:%S %y",&ptimestamp->time);
    break;
  case timestampTST_VMS:
    epicsTimeToStrftime(ptimestamp->val,sizeof(ptimestamp->val),
                        "%e-%b-%Y %H:%M:%S",&ptimestamp->time);
    break;
  case timestampTST_MM_DD_YYYY:
    epicsTimeToStrftime(ptimestamp->val,sizeof(ptimestamp->val),
                        "%b %d, %Y %H:%M:%S.%04f",&ptimestamp->time);
    break;
  case timestampTST_MM_DD_YY:
    epicsTimeToStrftime(ptimestamp->val,sizeof(ptimestamp->val),
                        "%m/%d/%y %H:%M:%S.%04f",&ptimestamp->time);
    break;
  default :  /* YY/MM/DD HH:MM:SS */
    epicsTimeToStrftime(ptimestamp->val,sizeof(ptimestamp->val),
                        "%y/%m/%D %H:%M:%S",&ptimestamp->time);
    break;
  }
#else
  tsStampToLocal(ptimestamp->time, &time_s);
  
  switch(ptimestamp->tst) {
  case timestampTST_YY_MM_DD_HH_MM_SS:
    sprintf(ptimestamp->val,"%.2d/%.2d/%.2d %.2d:%.2d:%.2d"
	    ,time_s.year,time_s.monthNum+1,time_s.dayMonth+1
	    ,time_s.hours,time_s.minutes,time_s.seconds);
    break;
  case timestampTST_MM_DD_YY_HH_MM_SS:
    sprintf(ptimestamp->val,"%.2d/%.2d/%.2d %.2d:%.2d:%.2d"
	    ,time_s.monthNum+1,time_s.dayMonth+1,time_s.year
	    ,time_s.hours,time_s.minutes,time_s.seconds);
    break;
  case timestampTST_MM_DD_HH_MM_SS_YY:
    sprintf(ptimestamp->val,"%s %.2d %.2d:%.2d:%.2d %.2d"
	    ,MONTH[time_s.monthNum],time_s.dayMonth+1
	    ,time_s.hours,time_s.minutes,time_s.seconds,time_s.year);
    break;
  case timestampTST_MM_DD_HH_MM_SS:
    sprintf(ptimestamp->val,"%s %.2d %.2d:%.2d:%.2d"
	    ,MONTH[time_s.monthNum],time_s.dayMonth+1
	    ,time_s.hours,time_s.minutes,time_s.seconds);
    break;
  case timestampTST_HH_MM_SS:
    sprintf(ptimestamp->val,"%.2d:%.2d:%.2d"
	    ,time_s.hours,time_s.minutes,time_s.seconds);
    break;
  case timestampTST_HH_MM:
    sprintf(ptimestamp->val,"%.2d:%.2d"
	    ,time_s.hours,time_s.minutes);
    break;
  case timestampTST_DD_MM_YY_HH_MM_SS:
    sprintf(ptimestamp->val,"%.2d/%.2d/%.2d %.2d:%.2d:%.2d"
	    ,time_s.dayMonth+1,time_s.monthNum+1,time_s.year
	    ,time_s.hours,time_s.minutes,time_s.seconds);
    break;
  case timestampTST_DD_MM_HH_MM_SS_YY:
    sprintf(ptimestamp->val,"%.2d %s %.2d:%.2d:%.2d %.2d"
	    ,time_s.dayMonth+1,MONTH[time_s.monthNum]
	    ,time_s.hours,time_s.minutes,time_s.seconds,time_s.year);
    break;
  case timestampTST_VMS:
    sprintf(ptimestamp->val,"%.2d-%s-%.4d %.2d:%.2d:%.2d"
	    ,time_s.dayMonth+1,MONTH[time_s.monthNum],time_s.year
	    ,time_s.hours,time_s.minutes,time_s.seconds);
    break;
  case timestampTST_MM_DD_YYYY:
    sprintf(ptimestamp->val,"%s %.2d, %.4d %.2d:%.2d:%.2d"
	    ,MONTH[time_s.monthNum],time_s.dayMonth+1
	    ,time_s.year,time_s.hours,time_s.minutes,time_s.seconds);
    break;
  case timestampTST_MM_DD_YY:
    sprintf(ptimestamp->val,"%.2d/%.2d/%.2d %.2d:%.2d:%.2d"
	    ,time_s.monthNum+1,time_s.dayMonth+1,time_s.year
	    ,time_s.hours,time_s.minutes,time_s.seconds);
    break;
  default :  /* YY/MM/DD HH:MM:SS */
    sprintf(ptimestamp->val,"%.2d/%.2d/%.2d %.2d:%.2d:%.2d"
            ,time_s.year,time_s.monthNum+1,time_s.dayMonth+1
            ,time_s.hours,time_s.minutes,time_s.seconds);
    break;
  }
#endif
  /* check event list */
  monitor(ptimestamp);

  /* process the forward scan link record */
  recGblFwdLink(ptimestamp);
  ptimestamp->pact=FALSE;
  return(0);
}
Пример #15
0
static long process(struct timestampRecord *ptimestamp){

 const char * format=NULL; 
  ptimestamp->udf  = FALSE;
  ptimestamp->pact = TRUE;

  /* Device time here is the OS time appart from any epics
   * time stamp system */

  if (ptimestamp->tse==epicsTimeEventDeviceTime)
      epicsTimeFromTime_t(&ptimestamp->time,time(0));
  else
      recGblGetTimeStamp(ptimestamp);
  ptimestamp->rval=ptimestamp->time.secPastEpoch;

  if (ptimestamp->time.secPastEpoch==0)
  {
    sprintf(ptimestamp->val,"-NULL-");
  }
  else switch(ptimestamp->tst)
  {
  case timestampTST_YY_MM_DD_HH_MM_SS:
      format="%y/%m/%d %H:%M:%S";
    break;
  case timestampTST_MM_DD_YY_HH_MM_SS:
      format="%m/%d/%y %H:%M:%S";
    break;
  case timestampTST_MM_DD_HH_MM_SS_YY:
      format="%b %d %H:%M:%S %y" ;
    break;
  case timestampTST_MM_DD_HH_MM_SS:
      format="%b %d %H:%M:%S";
    break;
  case timestampTST_HH_MM_SS:
      format="%H:%M:%S";
    break;
  case timestampTST_HH_MM:
      format="%H:%M";
    break;
  case timestampTST_DD_MM_YY_HH_MM_SS:
      format="%d/%m/%y %H:%M:%S";
    break;
  case timestampTST_DD_MM_HH_MM_SS_YY:
      format="%d %b %H:%M:%S %y";
    break;
  case timestampTST_VMS:
      format="%d-%b-%Y %H:%M:%S";
    break;
  case timestampTST_MM_DD_YYYY:
      format="%b %d %Y %H:%M:%S.%03f";
    break;
  case timestampTST_MM_DD_YY:
      format="%m/%d/%y %H:%M:%S.%03f";
    break;
  default :  /* YY/MM/DD HH:MM:SS */
      format="%y/%m/%d %H:%M:%S";
    break;
  }
  if (format)
      epicsTimeToStrftime(ptimestamp->val,sizeof(ptimestamp->val),format,
	      &ptimestamp->time);
  /* check event list */
  monitor(ptimestamp);

  /* process the forward scan link record */
  recGblFwdLink(ptimestamp);
  ptimestamp->pact=FALSE;
  return(0);
}
Пример #16
0
/*****************************************************************************
 *
 * This is called to "Process" the record.
 *
 * When we process a record for the digitel, we write out the new values for any
 * field whos'e value(s) might have changed, then read back the operating status
 * from the machine.
 *
 ******************************************************************************/
static long process(void *precord)
{
    digitelRecord *pdg = (digitelRecord *)precord;
    digiteldset *pdset = (digiteldset *) (pdg->dset);
    long status;
    unsigned char pact = pdg->pact;

    long nRequest = 1;
    long options = 0;

    if (recDigitelDebug >= 25)
	printf("recDigitel.c: Process(%s)\n", pdg->name);

    if ((pdset == NULL) || (pdset->proc_xact == NULL)) {
	pdg->pact = TRUE;
	recGblRecordError(S_dev_missingSup, (void *)pdg, "read_digitel");
	return (S_dev_missingSup);
    }

    /*** if not currently active... save initial values for pressure, voltage... ***/
    if (!pact) {
	pdg->ival = pdg->val;
	pdg->ilva = pdg->lval;
	pdg->imod = pdg->modr;
	pdg->ibak = pdg->bakr;
	pdg->icol = pdg->cool;
	pdg->isp1 = pdg->set1;
	pdg->isp2 = pdg->set2;
	pdg->isp3 = pdg->set3;
	pdg->iacw = pdg->accw;
	pdg->iaci = pdg->acci;
	pdg->ipty = pdg->ptyp;
	pdg->ibkn = pdg->bkin;
	pdg->is1 = pdg->sp1r;
	pdg->ih1 = pdg->s1hr;
	pdg->im1 = pdg->s1mr;
	pdg->ii1 = pdg->s1vr;
	pdg->is2 = pdg->sp2r;
	pdg->ih2 = pdg->s2hr;
	pdg->im2 = pdg->s2mr;
	pdg->ii2 = pdg->s2vr;
	pdg->is3 = pdg->sp3r;
	pdg->ih3 = pdg->s3hr;
	pdg->im3 = pdg->s3mr;
	pdg->ii3 = pdg->s3vr;
	pdg->ib3 = pdg->s3br;
	pdg->it3 = pdg->s3tr;
	pdg->iton = pdg->tonl;
	pdg->icrn = pdg->crnt;
	pdg->ivol = pdg->volt;
	pdg->ierr = pdg->err;
    }
    /*** check to see if simulation mode is being called for from the link ***/
    status = dbGetLink(&(pdg->siml),
		       DBR_USHORT, &(pdg->simm), &options, &nRequest);
    if (status == 0) {
	if (pdg->simm == menuYesNoYES) {
	    recDigitelsimFlag = 1;
	    if (recDigitelDebug >= 5)
		printf("recDigitel.c: Record being processed in simulation mode\n");
	} else
	    recDigitelsimFlag = 0;
    }

    /*** if not in simulation mode allow device support to be called ***/
    if (!(recDigitelsimFlag)) {
	/*** call device support for processing ***/
	status = (*pdset->proc_xact) (pdg);
	/*** Device support is in asynchronous mode, let it finish ***/
	if (!pact && pdg->pact)
	    return (0);
	pdg->pact = TRUE;
	recGblGetTimeStamp(pdg);
    }
    /*** if in simulation mode assign simulated values to fields ***/
    else {
	/*** simulation *** mode set  ***/
	/*** provides ability to simulate mode (OPERATE/ STANDBY) status of ***/
	/*** pump, if set to 1 (OPERATE) make pump voltage appear to be at  ***/
	/*** an "on" (6000V) level ***/
	status = dbGetLink(&(pdg->slmo),
			   DBR_USHORT, &(pdg->svmo), &options, &nRequest);
	if (status == 0)
	    pdg->modr = pdg->svmo;
	if (pdg->modr == 1)
	    pdg->volt = 6000;
	else
	    pdg->volt = 0;
	/*** simulation *** setpoint 1 set ***/
	status = dbGetLink(&(pdg->sls1),
			   DBR_USHORT, &(pdg->svs1), &options, &nRequest);
	if (status == 0)
	    pdg->set1 = pdg->svs1;
	/*** simulation *** setpoint 2 set ***/
	status = dbGetLink(&(pdg->sls2),
			   DBR_USHORT, &(pdg->svs2), &options, &nRequest);
	if (status == 0)
	    pdg->set2 = pdg->svs2;
	/*** simulation *** current level ***/
	/*** adjust current, and make pressure look like there is a 220 l/s ***/
	/*** pump being controlled ***/
	status = dbGetLink(&(pdg->slcr),
			   DBR_DOUBLE, &(pdg->svcr), &options, &nRequest);
	if (status == 0)
	    pdg->crnt = pdg->svcr;
	if (pdg->modr == 0)
	    pdg->crnt = 0;
	pdg->val = .005 * (pdg->crnt / 8.0);
	if (pdg->val <= 0)
	    pdg->lval = -10;
	else
	    pdg->lval = log10(pdg->val);
	pdg->udf = 0;	/* reset udf */
    }

    /*** check for alarms ***/
    checkAlarms(pdg);
    /*** check event list ***/
    monitor(pdg);
    /*** process the forward scan link record ***/
    recGblFwdLink(pdg);
    pdg->pact = FALSE;
    return (status);
}
Пример #17
0
static long process(longoutRecord *prec)
{
	struct longoutdset	*pdset = (struct longoutdset *)(prec->dset);
	long		 status=0;
	epicsInt32	 value;
	unsigned char    pact=prec->pact;

	if( (pdset==NULL) || (pdset->write_longout==NULL) ) {
		prec->pact=TRUE;
		recGblRecordError(S_dev_missingSup,(void *)prec,"write_longout");
		return(S_dev_missingSup);
	}
	if (!prec->pact) {
		if((prec->dol.type != CONSTANT)
                && (prec->omsl == menuOmslclosed_loop)) {
			status = dbGetLink(&(prec->dol),DBR_LONG,
				&value,0,0);
			if (prec->dol.type!=CONSTANT && RTN_SUCCESS(status))
				prec->udf=FALSE;
		}
		else {
			value = prec->val;
		}
		if (!status) convert(prec,value);
	}

	/* check for alarms */
	checkAlarms(prec);

        if (prec->nsev < INVALID_ALARM )
                status=writeValue(prec); /* write the new value */
        else {
                switch (prec->ivoa) {
                    case (menuIvoaContinue_normally) :
                        status=writeValue(prec); /* write the new value */
                        break;
                    case (menuIvoaDon_t_drive_outputs) :
                        break;
                    case (menuIvoaSet_output_to_IVOV) :
                        if(prec->pact == FALSE){
                                prec->val=prec->ivov;
                        }
                        status=writeValue(prec); /* write the new value */
                        break;
                    default :
                        status=-1;
                        recGblRecordError(S_db_badField,(void *)prec,
                                "longout:process Illegal IVOA field");
                }
        }

	/* check if device support set pact */
	if ( !pact && prec->pact ) return(0);
	prec->pact = TRUE;

	recGblGetTimeStamp(prec);

	/* check event list */
	monitor(prec);

	/* process the forward scan link record */
	recGblFwdLink(prec);

	prec->pact=FALSE;
	return(status);
}
Пример #18
0
static long process(calcoutRecord *prec)
{
    rpvtStruct *prpvt = prec->rpvt;
    int doOutput;

    if (!prec->pact) {
        prec->pact = TRUE;
        /* if some links are CA, check connections */
        if (prpvt->caLinkStat != NO_CA_LINKS) {
            checkLinks(prec);
        }
        if (fetch_values(prec) == 0) {
            if (calcPerform(&prec->a, &prec->val, prec->rpcl)) {
                recGblSetSevr(prec, CALC_ALARM, INVALID_ALARM);
            } else {
                prec->udf = isnan(prec->val);
            }
        }
        checkAlarms(prec);
        /* check for output link execution */
        switch (prec->oopt) {
        case calcoutOOPT_Every_Time:
            doOutput = 1;
            break;
        case calcoutOOPT_On_Change:
            doOutput = ! (fabs(prec->pval - prec->val) <= prec->mdel);
            break;
        case calcoutOOPT_Transition_To_Zero:
            doOutput = ((prec->pval != 0.0) && (prec->val == 0.0));
            break;
        case calcoutOOPT_Transition_To_Non_zero:
            doOutput = ((prec->pval == 0.0) && (prec->val != 0.0));
            break;
        case calcoutOOPT_When_Zero:
            doOutput = (prec->val == 0.0);
            break;
        case calcoutOOPT_When_Non_zero:
            doOutput = (prec->val != 0.0);
            break;
        default:
	    doOutput = 0;
            break;
        }
        prec->pval = prec->val;
        if (doOutput) {
            if (prec->odly > 0.0) {
                prec->dlya = 1;
                recGblGetTimeStamp(prec);
                db_post_events(prec, &prec->dlya, DBE_VALUE);
                callbackRequestProcessCallbackDelayed(&prpvt->doOutCb,
                        prec->prio, prec, (double)prec->odly);
                return 0;
            } else {
                prec->pact = FALSE;
                execOutput(prec);
                if (prec->pact) return 0;
                prec->pact = TRUE;
            }
        }
        recGblGetTimeStamp(prec);
    } else { /* pact == TRUE */
        if (prec->dlya) {
            prec->dlya = 0;
            recGblGetTimeStamp(prec);
            db_post_events(prec, &prec->dlya, DBE_VALUE);
            /* Make pact FALSE for asynchronous device support*/
            prec->pact = FALSE;
            execOutput(prec);
            if (prec->pact) return 0;
            prec->pact = TRUE;
        } else {/*Device Support is asynchronous*/
            writeValue(prec);
            recGblGetTimeStamp(prec);
        }
    }
    monitor(prec);
    recGblFwdLink(prec);
    prec->pact = FALSE;
    return 0;
}