Ejemplo n.º 1
0
static long init_record(mbbiRecord *prec, int pass)
{
    struct mbbidset *pdset;
    long status;

    if (pass==0) return(0);

    if (prec->siml.type == CONSTANT) {
	recGblInitConstantLink(&prec->siml,DBF_USHORT,&prec->simm);
    }
    if (prec->siol.type == CONSTANT) {
	recGblInitConstantLink(&prec->siol,DBF_USHORT,&prec->sval);
    }
    if(!(pdset = (struct mbbidset *)(prec->dset))) {
	recGblRecordError(S_dev_noDSET,(void *)prec,"mbbi: init_record");
	return(S_dev_noDSET);
    }
    /* must have read_mbbi function defined */
    if( (pdset->number < 5) || (pdset->read_mbbi == NULL) ) {
	recGblRecordError(S_dev_missingSup,(void *)prec,"mbbi: init_record");
	return(S_dev_missingSup);
    }
    /* initialize mask*/
    prec->mask = (1 << prec->nobt) - 1;

    if( pdset->init_record ) {
	if((status=(*pdset->init_record)(prec))) return(status);
    }
    init_common(prec);
    prec->mlst = prec->val;
    prec->lalm = prec->val;
    prec->oraw = prec->rval;
    return(0);
}
Ejemplo n.º 2
0
static long init_record(longoutRecord *prec, int pass)
{
    struct longoutdset *pdset;
    long status=0;

    if (pass==0) return(0);
    if (prec->siml.type == CONSTANT) {
	recGblInitConstantLink(&prec->siml,DBF_USHORT,&prec->simm);
    }
    if(!(pdset = (struct longoutdset *)(prec->dset))) {
	recGblRecordError(S_dev_noDSET,(void *)prec,"longout: init_record");
	return(S_dev_noDSET);
    }
    /* must have  write_longout functions defined */
    if( (pdset->number < 5) || (pdset->write_longout == NULL) ) {
	recGblRecordError(S_dev_missingSup,(void *)prec,"longout: init_record");
	return(S_dev_missingSup);
    }
    if (prec->dol.type == CONSTANT) {
	if(recGblInitConstantLink(&prec->dol,DBF_LONG,&prec->val))
	    prec->udf=FALSE;
    }
    if( pdset->init_record ) {
	if((status=(*pdset->init_record)(prec))) return(status);
    }
    prec->mlst = prec->val;
    prec->alst = prec->val;
    prec->lalm = prec->val;
    return(0);
}
Ejemplo n.º 3
0
static long init_record(boRecord *prec,int pass)
{
    struct bodset *pdset;
    long status=0;
    myCallback *pcallback;

    if (pass==0) return(0);

    /* bo.siml must be a CONSTANT or a PV_LINK or a DB_LINK */
    if (prec->siml.type == CONSTANT) {
	recGblInitConstantLink(&prec->siml,DBF_USHORT,&prec->simm);
    }

    if(!(pdset = (struct bodset *)(prec->dset))) {
	recGblRecordError(S_dev_noDSET,(void *)prec,"bo: init_record");
	return(S_dev_noDSET);
    }
    /* must have  write_bo functions defined */
    if( (pdset->number < 5) || (pdset->write_bo == NULL) ) {
	recGblRecordError(S_dev_missingSup,(void *)prec,"bo: init_record");
	return(S_dev_missingSup);
    }
    /* get the initial value */
    if (prec->dol.type == CONSTANT) {
	unsigned short ival = 0;

	if(recGblInitConstantLink(&prec->dol,DBF_USHORT,&ival)) {
	    if (ival  == 0)  prec->val = 0;
	    else  prec->val = 1;
	    prec->udf = FALSE;
	}
    }

    pcallback = (myCallback *)(calloc(1,sizeof(myCallback)));
    prec->rpvt = (void *)pcallback;
    callbackSetCallback(myCallbackFunc,&pcallback->callback);
    callbackSetUser(pcallback,&pcallback->callback);
    pcallback->precord = (struct dbCommon *)prec;

    if( pdset->init_record ) {
	status=(*pdset->init_record)(prec);
	if(status==0) {
		if(prec->rval==0) prec->val = 0;
		else prec->val = 1;
		prec->udf = FALSE;
	} else if (status==2) status=0;
    }
    prec->mlst = prec->val;
    /* 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;

    prec->mlst = prec->val;
    prec->lalm = prec->val;
    prec->oraw = prec->rval;
    prec->orbv = prec->rbv;
    return(status);
}
Ejemplo n.º 4
0
static long init_record(stringinRecord *prec, int pass)
{
    STATIC_ASSERT(sizeof(prec->oval)==sizeof(prec->val));
    struct stringindset *pdset;
    long status;

    if (pass==0) return(0);

    if (prec->siml.type == CONSTANT) {
	recGblInitConstantLink(&prec->siml,DBF_USHORT,&prec->simm);
    }

    /* stringin.siol must be a CONSTANT or a PV_LINK or a DB_LINK */
    if (prec->siol.type == CONSTANT) {
        recGblInitConstantLink(&prec->siol,DBF_STRING,prec->sval);
    } 

    if(!(pdset = (struct stringindset *)(prec->dset))) {
	recGblRecordError(S_dev_noDSET,(void *)prec,"stringin: init_record");
	return(S_dev_noDSET);
    }
    /* must have read_stringin function defined */
    if( (pdset->number < 5) || (pdset->read_stringin == NULL) ) {
	recGblRecordError(S_dev_missingSup,(void *)prec,"stringin: init_record");
	return(S_dev_missingSup);
    }
    if( pdset->init_record ) {
	if((status=(*pdset->init_record)(prec))) return(status);
    }
    strcpy(prec->oval,prec->val);
    return(0);
}
Ejemplo n.º 5
0
static long init_record(stringoutRecord *prec, int pass)
{
    STATIC_ASSERT(sizeof(prec->oval)==sizeof(prec->val));
    struct stringoutdset *pdset;
    long status=0;

    if (pass==0) return(0);

    if (prec->siml.type == CONSTANT) {
	recGblInitConstantLink(&prec->siml,DBF_USHORT,&prec->simm);
    }

    if(!(pdset = (struct stringoutdset *)(prec->dset))) {
	recGblRecordError(S_dev_noDSET,(void *)prec,"stringout: init_record");
	return(S_dev_noDSET);
    }
    /* must have  write_stringout functions defined */
    if( (pdset->number < 5) || (pdset->write_stringout == NULL) ) {
	recGblRecordError(S_dev_missingSup,(void *)prec,"stringout: init_record");
	return(S_dev_missingSup);
    }
    /* get the initial value dol is a constant*/
    if (prec->dol.type == CONSTANT){
	if(recGblInitConstantLink(&prec->dol,DBF_STRING,prec->val))
	    prec->udf=FALSE;
    }
    if( pdset->init_record ) {
	if((status=(*pdset->init_record)(prec))) return(status);
    }
    strcpy(prec->oval,prec->val);
    return(0);
}
Ejemplo n.º 6
0
static long init_record(epidRecord *pepid, int pass)
{
    struct epidDSET *pdset;
    int status;

    if (pass==0) return(0);
    /* initialize the setpoint for constant setpoint */
    if (pepid->stpl.type == CONSTANT) {
        if(recGblInitConstantLink(&pepid->stpl,DBF_DOUBLE,&pepid->val))
            pepid->udf = FALSE;
    }

    /* must have dset defined */
    if (!(pdset = (struct epidDSET *)(pepid->dset))) {
        recGblRecordError(S_dev_noDSET,(void *)pepid,"epid: init_record1");
        return(S_dev_noDSET);
    }
    /* must have do_pid function defined */
    if ( (pdset->number < 5) || (pdset->do_pid == NULL) ) {
        recGblRecordError(S_dev_missingSup,(void *)pepid,"epid: init_record2");
        printf("%ld %p\n",pdset->number, pdset->do_pid);
        return(S_dev_missingSup);
    }
    if (pdset->init_record) {
        if ((status=(*pdset->init_record)(pepid))) return(status);
    }
    return(0);
}
Ejemplo n.º 7
0
static long init_record(fanoutRecord *prec, int pass)
{

    if (pass==0) return(0);
    recGblInitConstantLink(&prec->sell,DBF_USHORT,&prec->seln);
    return(0);
}
Ejemplo n.º 8
0
static long init_record(struct ifstatRecord	*pifstat)
{
	char *dopts = NULL;

#if 1
	if (!ifstat_get_driver("proc", &driver)) {
		printf("Get Driver Error!!\n");
		return -1;
	}
#endif

	if (driver.open_driver != NULL && !driver.open_driver(&driver, dopts))
	{
		printf("Open Driver Error!!\n");
		return -1;
	};

	ifs.flags = 0;
	ifs.first = NULL;

	ifstat_add_interface(&ifs, pifstat->nic, 0); 

    if(recGblInitConstantLink(&pifstat->inp,DBF_DOUBLE,&pifstat->val))
         pifstat->udf = FALSE;

	pifstat->dpvt = &driver;
    return(0);
}
Ejemplo n.º 9
0
static long dsetInit_devAiSyncSoft(aiRecord *pai) {

  dsetLog(3, __FILE__ "[%d] -> %s(%s)\n", __LINE__, __func__, pai->name);

  /* ai.inp must be a CONSTANT or a PV_LINK or a DB_LINK or a CA_LINK*/
  switch (pai->inp.type) {
    case (CONSTANT) :
        if(recGblInitConstantLink(&pai->inp,DBF_DOUBLE,&pai->val))
            pai->udf = FALSE;
	break;
    case (PV_LINK) :
    case (DB_LINK) :
    case (CA_LINK) :
	break;
    default :
	recGblRecordError(S_db_badField, (void *)pai,
		"DMC2183_devAiSyncSoft (init_record) Illegal INP field");

	return(S_db_badField);
  }
  /* Make sure record processing routine does not perform any conversion*/
  pai->linr = 0;
  
  dsetLog(3, __FILE__ "[%d] <- %s\n", __LINE__, __func__);
  return(SUCCESS);
}
Ejemplo n.º 10
0
static long init_record(aiRecord *pao)
{
  struct prngState* priv;
  unsigned long start;

  priv=malloc(sizeof(struct prngState));
  if(!priv){
    recGblRecordError(S_db_noMemory, (void*)pao,
      "devAoTimebase failed to allocate private struct");
    return S_db_noMemory;
  }

  /* New */
  callbackSetCallback(prng_cb,&priv->cb);
  callbackSetPriority(priorityLow,&priv->cb);
  callbackSetUser(pao,&priv->cb);
  priv->cb.timer=NULL;

  recGblInitConstantLink(&pao->inp,DBF_ULONG,&start);

  priv->seed=start;
  pao->dpvt=priv;

  return 0;
}
Ejemplo n.º 11
0
static long dsetInit_devSiSyncSoft(stringinRecord *pstringin)
{
  #ifdef DEBUG1
  printf( __FILE__ "[%d] -> %s(%s)\n", __LINE__, __func__, pstringin->name);
  #endif

  /* stringin.inp must be a CONSTANT or a PV_LINK or a DB_LINK or a CA_LINK*/
  switch (pstringin->inp.type) {
  case (CONSTANT) :
       if(recGblInitConstantLink(&pstringin->inp,DBF_STRING,pstringin->val))
           pstringin->udf = FALSE;
       break;
  case (PV_LINK) :
  case (DB_LINK) :
  case (CA_LINK) :
        break;
  default :
	recGblRecordError(S_db_badField,(void *)pstringin,
		"devSiSoft (init_record) Illegal INP field");
	return(S_db_badField);
  }

  #ifdef DEBUG1
  printf( __FILE__ "[%d] <- %s\n", __LINE__, __func__);
  #endif
  return(SUCCESS);
}
Ejemplo n.º 12
0
static long init_record(void *precord,int pass)
{
    aiRecord	*prec = (aiRecord *)precord;
    aidset	*pdset;
    double	eoff = prec->eoff, eslo = prec->eslo;

    if (pass==0) return(0);

    /* ai.siml must be a CONSTANT or a PV_LINK or a DB_LINK */
    if (prec->siml.type == CONSTANT) {
	recGblInitConstantLink(&prec->siml,DBF_USHORT,&prec->simm);
    }

    /* ai.siol must be a CONSTANT or a PV_LINK or a DB_LINK */
    if (prec->siol.type == CONSTANT) {
	recGblInitConstantLink(&prec->siol,DBF_DOUBLE,&prec->sval);
    }

    if(!(pdset = (aidset *)(prec->dset))) {
	recGblRecordError(S_dev_noDSET,(void *)prec,"ai: init_record");
	return(S_dev_noDSET);
    }
    /* must have read_ai function defined */
    if( (pdset->number < 6) || (pdset->read_ai == NULL) ) {
	recGblRecordError(S_dev_missingSup,(void *)prec,"ai: init_record");
	return(S_dev_missingSup);
    }
    prec->init = TRUE;
    /*The following is for old device support that doesnt know about eoff*/
    if ((prec->eslo==1.0) && (prec->eoff==0.0)) {
	prec->eoff = prec->egul;
    }

    if( pdset->init_record ) {
	long status=(*pdset->init_record)(prec);
	if (prec->linr == menuConvertSLOPE) {
	    prec->eoff = eoff;
	    prec->eslo = eslo;
	}
	return (status);
    }
    prec->mlst = prec->val;
    prec->alst = prec->val;
    prec->lalm = prec->val;
    prec->oraw = prec->rval;
    return(0);
}
Ejemplo n.º 13
0
/*****************************************************************************
 *
 * Initialize a sequence record.
 *
 * Allocate the callback request structure (tacked on dpvt.)
 * Initialize watch-dog ID
 * Initialize SELN based on the link-type of SELL
 * If SELL is a CA_LINK, inform CA about it
 * For each constant input link, fill in the DOV field
 *
 ******************************************************************************/
static long init_record(seqRecord *prec, int pass)
{
    int		index;
    linkDesc      *plink;
    callbackSeq *pcallbackSeq;

    if (pass==0) return(0);

    if (seqRecDebug > 5)
      printf("init_record(%s) entered\n", prec->name);

    /* Allocate a callback structure for use in processing */
    pcallbackSeq  = (callbackSeq *)calloc(1,sizeof(callbackSeq));
    pcallbackSeq->pseqRecord = prec;
    callbackSetCallback(processCallback,&pcallbackSeq->callback);
    callbackSetUser(pcallbackSeq,&pcallbackSeq->callback);
    callbackSetPriority(prec->prio,&pcallbackSeq->callback);
    prec->dpvt = (void *)pcallbackSeq;

    /* Get link selection if sell is a constant and nonzero */
    if (prec->sell.type==CONSTANT)
    {
      if (seqRecDebug > 5)
        printf("init_record(%s) SELL is a constant\n", prec->name);
      recGblInitConstantLink(&prec->sell,DBF_USHORT,&prec->seln);
    }

  /* Copy over ALL the input link constants here */
  plink = (linkDesc *)(&(prec->dly1));

  index = 0;
  while (index < NUM_LINKS)
  {

    if (plink->dol.type == CONSTANT)
	recGblInitConstantLink(&plink->dol,DBF_DOUBLE,&plink->dov);

    index++;

    plink++;
  }

  return(0);
}
Ejemplo n.º 14
0
static long init_record(eventRecord *prec, int pass)
{
    struct eventdset *pdset;
    long status=0;

    if (pass==0) return(0);

    if (prec->siml.type == CONSTANT) {
	recGblInitConstantLink(&prec->siml,DBF_USHORT,&prec->simm);
    }

    if (prec->siol.type == CONSTANT) {
	recGblInitConstantLink(&prec->siol,DBF_USHORT,&prec->sval);
    }

    if( (pdset=(struct eventdset *)(prec->dset)) && (pdset->init_record) ) 
		status=(*pdset->init_record)(prec);
    return(status);
}
Ejemplo n.º 15
0
static long dsetInit_devMbbiSyncSoft(mbbiRecord *pmbbi) {

  dsetLog(3, __FILE__ "[%d] -> %s(%s)\n", __LINE__, __func__, pmbbi->name);

  if (pmbbi->inp.type == CONSTANT) {
    if (recGblInitConstantLink(&pmbbi->inp,DBF_ENUM,&pmbbi->val))
      pmbbi->udf = FALSE;
  }
  dsetLog(3, __FILE__ "[%d] <- %s\n", __LINE__, __func__);
  return(SUCCESS);
}
Ejemplo n.º 16
0
static long init_record(selRecord *prec, int pass)
{
    struct link *plink;
    int i;
    double *pvalue;

    if (pass==0) return(0);

    /* get seln initial value if nvl is a constant*/
    if (prec->nvl.type == CONSTANT ) {
	recGblInitConstantLink(&prec->nvl,DBF_USHORT,&prec->seln);
    }

    plink = &prec->inpa;
    pvalue = &prec->a;
    for(i=0; i<SEL_MAX; i++, plink++, pvalue++) {
	*pvalue = epicsNAN;
	if (plink->type==CONSTANT) {
	    recGblInitConstantLink(plink,DBF_DOUBLE,pvalue);
	}
    }
    return(0);
}
Ejemplo n.º 17
0
static long init_record(struct cvtRecord *pcvt, int pass)
{
    void *sub;

    if (pass == 0) {
        /* set new conversion parameters equal to to configured ones */
        pcvt->nmet = pcvt->meth;
        strncpy(pcvt->nbdi, pcvt->bdir, BDIR_SIZE);
        strncpy(pcvt->ntdi, pcvt->tdir, TDIR_SIZE);
        strncpy(pcvt->nspe, pcvt->spec, SPEC_SIZE);
        return 0;
    }

    /* initialize input links */
    if (pcvt->inpx.type == CONSTANT) {
        recGblInitConstantLink(&pcvt->inpx, DBF_DOUBLE, &pcvt->x);
    }
    if (pcvt->inpy.type == CONSTANT) {
        recGblInitConstantLink(&pcvt->inpy, DBF_DOUBLE, &pcvt->y);
    }
    if (pcvt->iaml.type == CONSTANT) {
        recGblInitConstantLink(&pcvt->iaml, DBF_UCHAR, &pcvt->iaom);
    }
    if (pcvt->iavl.type == CONSTANT) {
        recGblInitConstantLink(&pcvt->iavl, DBF_DOUBLE, &pcvt->iaov);
    }

    /* try to initialize conversion as specified */
    if (initConversion(pcvt->name, pcvt->nbdi, pcvt->ntdi, pcvt->nmet, pcvt->nspe, &sub)) {
        pcvt->ista = menuCvtInitStateError;
        pcvt->drty |= DRTY_ISTA;
        return -1;
    }
    pcvt->csub = sub;
    return 0;
}
Ejemplo n.º 18
0
static long init_record(biRecord *prec)
{
    /* INP must be CONSTANT, PV_LINK, DB_LINK or CA_LINK*/
    switch (prec->inp.type) {
    case CONSTANT:
        recGblInitConstantLink(&prec->inp, DBF_ULONG, &prec->rval);
        break;
    case PV_LINK:
    case DB_LINK:
    case CA_LINK:
        break;
    default:
        recGblRecordError(S_db_badField, (void *)prec,
            "devBiSoftRaw (init_record) Illegal INP field");
        return S_db_badField;
    }
    return 0;
}
Ejemplo n.º 19
0
static long init_record(subRecord *prec, int pass)
{
    SUBFUNCPTR psubroutine;
    long status = 0;
    struct link *plink;
    int i;
    double *pvalue;

    if (pass==0) return(0);

    plink = &prec->inpa;
    pvalue = &prec->a;
    for (i = 0; i < INP_ARG_MAX; i++, plink++, pvalue++) {
        if (plink->type == CONSTANT) {
            recGblInitConstantLink(plink, DBF_DOUBLE, pvalue);
        }
    }

    if (prec->inam[0]) {
        /* convert the initialization subroutine name  */
        psubroutine = (SUBFUNCPTR)registryFunctionFind(prec->inam);
        if (psubroutine == 0) {
            recGblRecordError(S_db_BadSub, (void *)prec, "recSub(init_record)");
            return S_db_BadSub;
        }
        /* invoke the initialization subroutine */
        status = (*psubroutine)(prec);
    }

    if (prec->snam[0] == 0) {
        epicsPrintf("%s.SNAM is empty\n", prec->name);
        prec->pact = TRUE;
        return 0;
    }
    prec->sadr = (SUBFUNCPTR)registryFunctionFind(prec->snam);
    if (prec->sadr == NULL) {
        recGblRecordError(S_db_BadSub, (void *)prec, "recSub(init_record)");
        return S_db_BadSub;
    }
    prec->mlst = prec->val;
    prec->alst = prec->val;
    prec->lalm = prec->val;
    return 0;
}
Ejemplo n.º 20
0
static long init_record(stringinRecord *prec)
{
    /* INP must be CONSTANT or PN_LINK */
    switch (prec->inp.type) {
    case CONSTANT:
        if (recGblInitConstantLink(&prec->inp, DBR_STRING, &prec->val))
            prec->udf = FALSE;
        break;
    case PN_LINK:
        /* Handled by add_record */
        break;
    default:
        recGblRecordError(S_db_badField, (void *)prec,
            "devSiSoftCallback (init_record) Illegal INP field");
        prec->pact = TRUE;
        return S_db_badField;
    }
    return 0;
}
Ejemplo n.º 21
0
static long init_record(aiRecord *pao)
{
  struct prngState* priv;
  unsigned long start;

  priv=malloc(sizeof(struct prngState));
  if(!priv){
    recGblRecordError(S_db_noMemory, (void*)pao,
      "devAoTimebase failed to allocate private struct");
    return S_db_noMemory;
  }

  recGblInitConstantLink(&pao->inp,DBF_ULONG,&start);

  priv->seed=start;
  pao->dpvt=priv;

  return 0;
}
Ejemplo n.º 22
0
static long init_record(histogramRecord	*prec)
{
    /* histogram.svl must be a CONSTANT or a PV_LINK or a DB_LINK or a CA_LINK*/
    switch (prec->svl.type) {
    case (CONSTANT) :
        if(recGblInitConstantLink(&prec->svl,DBF_DOUBLE,&prec->sgnl))
            prec->udf = FALSE;
        break;
    case (PV_LINK) :
    case (DB_LINK) :
    case (CA_LINK) :
        break;
    default :
        recGblRecordError(S_db_badField,(void *)prec,
                          "devHistogramSoft (init_record) Illegal SVL field");
        return(S_db_badField);
    }
    return 0;
}
Ejemplo n.º 23
0
static long init_record(eventRecord *prec)
{
    /* INP must be CONSTANT, PV_LINK, DB_LINK or CA_LINK*/
    switch (prec->inp.type) {
    case CONSTANT:
        if (recGblInitConstantLink(&prec->inp, DBF_STRING, &prec->val))
            prec->udf = FALSE;
        break;
    case PV_LINK:
    case DB_LINK:
    case CA_LINK:
        break;
    default:
        recGblRecordError(S_db_badField, (void *)prec,
            "devEventSoft (init_record) Illegal INP field");
        return S_db_badField;
    }
    return 0;
}
Ejemplo n.º 24
0
static long init_record(struct histogramRecord *prec)
{
    CALLBACK *pcallback;

    /* histogram.svl must be a CONSTANT*/
    switch (prec->svl.type) {
    case (CONSTANT) :
	pcallback = (CALLBACK *)(calloc(1,sizeof(CALLBACK)));
	prec->dpvt = (void *)pcallback;
        if(recGblInitConstantLink(&prec->svl,DBF_DOUBLE,&prec->sgnl))
            prec->udf = FALSE;
	break;
    default :
	recGblRecordError(S_db_badField,(void *)prec,
	    "devHistogramTestAsyn (init_record) Illegal SVL field");
        prec->pact=TRUE;
	return(S_db_badField);
    }
    return(0);
}
Ejemplo n.º 25
0
static long init_record(mbbiDirectRecord *prec)
{
    /* INP must be CONSTANT, PV_LINK, DB_LINK or CA_LINK*/
    switch (prec->inp.type) {
    case CONSTANT:
        recGblInitConstantLink(&prec->inp, DBF_ULONG, &prec->rval);
        break;
    case PV_LINK:
    case DB_LINK:
    case CA_LINK:
        break;
    default:
        recGblRecordError(S_db_badField, (void *)prec,
            "devMbbiDirectSoftRaw (init_record) Illegal INP field");
        return S_db_badField;
    }
    /*to preserve old functionality*/
    if (prec->nobt == 0) prec->mask = 0xffffffff;
    prec->mask <<= prec->shft;
    return 0;
}
Ejemplo n.º 26
0
static long init_record(struct RECORDTYPE *precord, int pass)
{
  RECORDTYPE	*self = (RECORDTYPE *)precord;
  long	status;
  DBLINK *plink;

  if (pass == 0){
    if(self->nelm <= 0) self->nelm=1;
    if(self->nelm == 1) {
      self->nord = 1;
    } else {
      self->nord = 0;
    }
    self->bptr = (double *)calloc(self->nelm, sizeof(double));
    if (self->bptr == NULL ){
      self->pact=TRUE;
      /* errlogPrintf("aRaw:(array select) cannot allocate buffer area.");*/
      self->nord = 0;
      if (self->bptr != NULL) free(self->bptr);
      return (-1);
    }
    return(0);
  }

  /* AveDev Record  is a pure soft record */
  plink = &(self->inp);
  if(plink->type == CONSTANT){
    self->bptr = (double *) calloc(1,sizeof(double));
    self->nord = 1;
    recGblInitConstantLink(plink, DBF_DOUBLE, self->bptr);
  }
  else{
    status=dbGetNelements(plink, (signed long *)&self->nord);
    if (self->nord> self->nelm){
      self->nord = self->nelm;
    }
  }
    return(0);
}
Ejemplo n.º 27
0
static long init_record(waveformRecord *prec, int pass)
{
    struct wfdset *pdset;

    if (pass==0) {
        if (prec->nelm <= 0)
            prec->nelm = 1;
        if (prec->ftvl > DBF_ENUM)
            prec->ftvl = DBF_UCHAR;
        prec->bptr = callocMustSucceed(prec->nelm, dbValueSize(prec->ftvl),
                                       "waveform calloc failed");
        if (prec->nelm == 1) {
            prec->nord = 1;
        } else {
            prec->nord = 0;
        }
        return 0;
    }

    /* wf.siml must be a CONSTANT or a PV_LINK or a DB_LINK */
    if (prec->siml.type == CONSTANT) {
        recGblInitConstantLink(&prec->siml,DBF_USHORT,&prec->simm);
    }

    /* must have dset defined */
    if (!(pdset = (struct wfdset *)(prec->dset))) {
        recGblRecordError(S_dev_noDSET,(void *)prec,"wf: init_record");
        return S_dev_noDSET;
    }
    /* must have read_wf function defined */
    if ((pdset->number < 5) || (pdset->read_wf == NULL)) {
        recGblRecordError(S_dev_missingSup,(void *)prec,"wf: init_record");
        return S_dev_missingSup;
    }
    if (! pdset->init_record) return 0;

    return (*pdset->init_record)(prec);
}
Ejemplo n.º 28
0
static long dsetInit_devBiSyncSoft(biRecord *pbi) {

    dsetLog(3, __FILE__ "[%d] -> %s(%s)\n", __LINE__, __func__, pbi->name);

    switch (pbi->inp.type) {
    case (CONSTANT) :
        if(recGblInitConstantLink(&pbi->inp,DBF_ENUM,&pbi->val))
            pbi->udf = FALSE;
        break;
    case (DB_LINK) :
    case (PV_LINK) :
    case (CA_LINK) :
        break;
    default :
        recGblRecordError(S_db_badField,(void *)pbi,
                          "SNOVA_devBiSyncSoft (init_record) Illegal INP field");
        return(S_db_badField);
    }

    dsetLog(3, __FILE__ "[%d] <- %s\n", __LINE__, __func__);

    return(SUCCESS);
}
Ejemplo n.º 29
0
long snmp_Init(void *precord)
{            
  snmpRecord *psnmp = (snmpRecord *)precord;
  /* psnmp->dpvt = (SNMP_INFO*)gsnmpInfo; */

  printf("snmpInit()****** Message: %s, version: %s, ip: %s, name: %s, authpass: %s, privpass: %s\n",snmpinfo->msg, snmpinfo->version, snmpinfo->hostaddr, snmpinfo->username, snmpinfo->authpass, snmpinfo->privpass);

  if(recGblInitConstantLink(&psnmp->inp,DBF_DOUBLE,&psnmp->val))
    psnmp->udf = FALSE;


  devSNMPPvt *pdev = (devSNMPPvt *)malloc(sizeof (devSNMPPvt));
  if(pdev == NULL) return -1;

  pdev->mutexId = epicsMutexCreate();
  scanIoInit(&pdev->ioScanPvt);
  psnmp->dpvt = pdev;
  pdev->prec = (dbCommon*)precord;

  ellAdd(&devSNMPList, &(((devSNMPPvt*)psnmp->dpvt)->devSNMPNode));

  initialize(psnmp);
  return(0);
}
Ejemplo n.º 30
0
static long init_record(aSubRecord *prec, int pass)
{
    GENFUNCPTR     pfunc;
    long           status;
    int            i;

    status = 0;
    if (pass == 0) {
        /* Allocate memory for arrays */
        initFields(&prec->fta,  &prec->noa,  &prec->nea,  Ifldnames,
            &prec->a,    NULL);
        initFields(&prec->ftva, &prec->nova, &prec->neva, Ofldnames,
            &prec->vala, &prec->ovla);
        return 0;
    }

    /* Initialize the Subroutine Name Link */
    switch (prec->subl.type) {
    case CONSTANT:
        recGblInitConstantLink(&prec->subl, DBF_STRING, prec->snam);
        break;

    case PV_LINK:
    case DB_LINK:
    case CA_LINK:
        break;

    default:
        recGblRecordError(S_db_badField, (void *)prec,
            "aSubRecord(init_record) Bad SUBL link type");
        return S_db_badField;
    }

    /* Initialize Input Links */
    for (i = 0; i < NUM_ARGS; i++) {
        struct link *plink = &(&prec->inpa)[i];
        switch (plink->type) {
        case CONSTANT:
            if ((&prec->noa)[i] < 2) {
                if (recGblInitConstantLink(plink, (&prec->fta)[i], (&prec->a)[i])) {
                    prec->udf = FALSE;
                } else
                    prec->udf = TRUE;
            }
            break;

        case PV_LINK:
        case CA_LINK:
        case DB_LINK:
            break;

        default:
            recGblRecordError(S_db_badField, (void *)prec,
                "aSubRecord(init_record) Illegal INPUT LINK");
            status = S_db_badField;
            break;
        }
    }

    if (status)
        return status;

    /* Initialize Output Links */
    for (i = 0; i < NUM_ARGS; i++) {
        switch ((&prec->outa)[i].type) {
        case CONSTANT:
        case PV_LINK:
        case CA_LINK:
        case DB_LINK:
            break;

        default:
            recGblRecordError(S_db_badField, (void *)prec,
                "aSubRecord(init_record) Illegal OUTPUT LINK");
            status = S_db_badField;
        }
    }
    if (status)
        return status;

    /* Call the user initialization routine if there is one */
    if (prec->inam[0] != 0) {
        pfunc = (GENFUNCPTR)registryFunctionFind(prec->inam);
        if (pfunc) {
            pfunc(prec);
        } else {
            recGblRecordError(S_db_BadSub, (void *)prec,
                "aSubRecord::init_record - INAM subr not found");
            return S_db_BadSub;
        }
    }

    if (prec->lflg == aSubLFLG_IGNORE &&
        prec->snam[0] != 0) {
        pfunc = (GENFUNCPTR)registryFunctionFind(prec->snam);
        if (pfunc)
            prec->sadr = pfunc;
        else {
            recGblRecordError(S_db_BadSub, (void *)prec,
                "aSubRecord::init_record - SNAM subr not found");
            return S_db_BadSub;
        }
    }
    strcpy(prec->onam, prec->snam);
    prec->oval = prec->val;
    return 0;
}