EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  <20152016  2017  2018  2019  2020  2021  2022  2023  2024  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  <20152016  2017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: RE: To write data to VDCT from device support
From: "Mooney, Tim M." <[email protected]>
To: Deepika Thakur <[email protected]>, "[email protected]" <[email protected]>
Date: Fri, 7 Aug 2015 16:10:10 +0000
You need to allocate a dbAddr structure for dbNameToAddr() to fill in.

    struct dbAddr dbaddr;
    struct dbAddr *paddr = &dbaddr;
    ...
    status = dbNameToAddr("optoRead.VAL", paddr);

To get the array data into the waveform record's array, copy it to pwaf->bptr, and set pwaf->nord to the number of values you copied.  See base/src/dev/softDev/devWfSoft.c for an example.

What you're doing is writing data to a waveform record's VAL field.  VDCT doesn't have anything to do with this.


Tim Mooney ([email protected]) (630)252-5417
Software Services Group (www.aps.anl.gov)
Advanced Photon Source, Argonne National Lab


From: [email protected] [[email protected]] on behalf of Deepika Thakur [[email protected]]
Sent: Friday, August 07, 2015 4:44 AM
To: [email protected]
Subject: To write data to VDCT from device support

Hello,
I have created following device support. Now what I want is to write values of a array(as per following code c2 array) to a waveform record(PV name: optoRead) in VDCT

#include <stdio.h>
#include <string.h>
#include <stddef.h>
#include <math.h>
#include <stdlib.h>

#include "alarm.h"
#include "cvtTable.h"
#include "dbDefs.h"
#include "dbAccess.h"
#include "recGbl.h"
#include "recSup.h"
#include "devSup.h"
#include "link.h"
#include "aiRecord.h"
#include "waveformRecord.h"
#include "epicsExport.h"



int i;
unsigned short c1[50],c2[10];
static long read_waveform();
static long read_wafopto();


//------------STRUCTURE FOR WAVEFORM---------
struct
{
long   number;
DEVSUPFUN report;
DEVSUPFUN init;
DEVSUPFUN init_record;
DEVSUPFUN get_ioint_info;
DEVSUPFUN read_waveform;
}
devmywaveform = {
      5,
      NULL,
      NULL,
              NULL,
      NULL,
              read_waveform};
epicsExportAddress(dset,devmywaveform);

//------------STRUCTURE FOR WAVEFORM to get opto-reading---------
struct
{
long   number;
DEVSUPFUN report;
DEVSUPFUN init;
DEVSUPFUN init_record;
DEVSUPFUN get_ioint_info;
DEVSUPFUN read_wafopto;
}
devwafopto = {
      5,
      NULL,
      NULL,
              NULL,
      NULL,
              read_wafopto};
epicsExportAddress(dset,devwafopto);


//-----------------CODE-----------------//

static long read_waveform(pwaf)
struct waveformRecord *pwaf;
{
//int i;
long int n;
unsigned short myptr[100];
struct dbAddr *paddr;
//unsigned short c1[50],c2[10];

n = pwaf->nelm;
paddr = dbGetPdbAddrFromLink(&pwaf->inp);
dbGet(paddr,pwaf->ftvl,(void *)myptr,0,&n,NULL);
for(i=0;i<=71;i++)
{
printf("\ndata=%x\n",myptr[i]);
}

for(i=0;i<36;i++)
{
 if(myptr[i+36]==143)
{
c1[i]=myptr[i]-50;
}
  else
      c1[i]=myptr[i];
}
for(i=0;i<36;i++)
{
printf("\ndata1=%u %x\n",c1[i],c1[i]);
}


for(i=0;i<=4;i++)
{
c2[i]=c1[i+4];
}

for(i=0;i<=4;i++)
{
printf("\ndata2=%u",c2[i]);
}

return(2);
}

          //---DEVICE SUPPORT TO VDCT---
                                                                                                                                                                 
static long read_wafopto(popto)
struct waveformRecord *popto;
{
//char *optoRead[10];
long int n;
struct dbAddr *paddr;

//paddr = dbGetPdbAddrFromLink(&inp->popto);
//dbPut(paddr,popto->ftvl,(void *)c2,&n);
n = popto->nelm;
dbNameToAddr("optoRead.VAL",paddr);
dbPut(paddr,popto->ftvl,(void *)c2,n);

//popto->val=c2;

return(2);
}


DB FILE:

record(waveform, optoRead) {
  field(SCAN, "Passive")
  field(NELM, "4")
  field(FTVL, "USHORT")
  field(DTYP, "wafoptosupport")
}

I want to write value of c2 array in waveform record in VDCT. On doing "caget" I get following output:
 caget optoRead
optoRead 4 3 0 0 0

Output should be:
optoRead 4 127 255 0 0


When I do "make" i do not get any error but on doing "make clean install" I get following warning:

../aiDevsup.c: In function ‘read_wafopto’:
../aiDevsup.c:274:14: warning: ‘paddr’ is used uninitialized in this function [-Wuninitialized]
  dbNameToAddr("optoRead.VAL",paddr);

Please suggest how to resolve this warning .Also suggest is there any other way to write this data in VDCT or is it possible to use any other record other than waveform. My ultimate aim is to get this data in VDCT and  convert it in binary.

References:
To write data to VDCT from device support Deepika Thakur

Navigate by Date:
Prev: Re: Data Archiver Rod Nussbaumer
Next: Re: Data Archiver Jeong Han Lee
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  <20152016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: To write data to VDCT from device support Deepika Thakur
Next: To read single element from waveform record ishita bhatia
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  <20152016  2017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 16 Dec 2015 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·