Exemple #1
0
static long add_record_waveform(dbCommon *praw)
{
  waveformRecord *prec=(waveformRecord*)praw;
  long ret=0;
try {
  assert(prec->inp.type==INST_IO);

  std::auto_ptr<priv> paddr(new priv);

  if (linkOptionsStore(eventdef, paddr.get(), prec->inp.value.instio.string, 0))
    throw std::runtime_error("Couldn't parse link string");

  mrf::Object *O=mrf::Object::getObject(paddr->obj);
  if(!O) {
      errlogPrintf("%s: failed to find object '%s'\n", prec->name, paddr->obj);
      return S_db_errArg;
  }
  paddr->priv=dynamic_cast<dataBufTx*>(O);
  if(!paddr->priv)
    throw std::runtime_error("Failed to lookup device");

  // scratch space for endian swap if needed
  if(dbValueSize(prec->ftvl)>1 && dbValueSize(prec->ftvl)<=8)
      paddr->scratch = new epicsUInt8[prec->nelm*dbValueSize(prec->ftvl)];
  else
      paddr->scratch = 0;

  // prec->dpvt is set again to indicate
  // This also serves to indicate successful
  // initialization to other dset functions
  prec->dpvt = paddr.release();

  return 0;

} catch(std::runtime_error& e) {
  recGblRecordError(S_dev_noDevice, (void*)prec, e.what());
  ret=S_dev_noDevice;
} catch(std::exception& e) {
  recGblRecordError(S_db_noMemory, (void*)prec, e.what());
  ret=S_db_noMemory;
}
  return ret;
}
Exemple #2
0
static long add_lo(dbCommon* praw)
{
    longoutRecord *prec=(longoutRecord*)praw;
    try {
        assert(prec->out.type==INST_IO);

        mrf::auto_ptr<map_priv> priv(new map_priv);

        if (linkOptionsStore(eventdef, priv.get(), prec->out.value.instio.string, 0))
            throw std::runtime_error("Couldn't parse link string");

        priv->last_code=prec->val;

        mrf::Object *O=mrf::Object::getObject(priv->obj);
        if(!O) {
            errlogPrintf("%s: failed to find object '%s'\n", praw->name, priv->obj);
            return S_db_errArg;
        }
        priv->card=dynamic_cast<EVR*>(O);
        if(!priv->card) {
            errlogPrintf("%s: object '%s' is not an EVR\n", praw->name, priv->obj);
            return S_db_errArg;
        }

        if(priv->last_code>0 && priv->last_code<=255)
            priv->card->specialSetMap(priv->last_code,priv->func,true);

        praw->dpvt = (void*)priv.release();

        return 0;

    } catch(std::exception& e) {
        recGblRecordError(S_db_noMemory, (void*)prec, e.what());
        (void)recGblSetSevr(praw, WRITE_ALARM, INVALID_ALARM);
        return S_db_noMemory;
    }
}