EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

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

Subject: Re: stringin/out <-> sub record ?
From: "Martin L. Smith" <[email protected]>
To: "Laznovsky, Michael" <[email protected]>
Cc: [email protected]
Date: Thu, 30 Mar 2006 06:49:16 -0600
Hi Michael,

I have a sub record that does something like this but tha actual string
comes from a file that the IOC reads in during boot.
It is easier to just give an example rather than explaining, here is the
code and databse records. Hope that this helps.

Database Records:
record(mbbi,"ID$(ID):DeviceSelect") {
        field(DESC,"No of the Device ")
        field(PINI,"YES")
        field(INP,"$(DS)")
        field(ZRVL,"0")
        field(ONVL,"1")
        field(ZRST,"First")
        field(ONST,"Second")
}
record(sub,"ID$(ID):DeviceName") {
        field(DESC,"Device Identifier")
        field(PINI,"YES")
        field(INAM,"initSubDevName")
        field(SNAM,"subDeviceName")
        field(INPA,"ID$(ID):DeviceSelect.VAL PP NMS")
        field(INPB,"ID$(ID):Device.PROC PP NMS")
}
record(stringin,"ID$(ID):Device") {
        field(DESC,"Device Identifier String")
}
-------------------------------------------
Subroutine Code:
struct  subDNamePvt {
    struct stringinRecord  *psi;
    char  device[40];
};
-------------------------------------------
#define  DEVICENAME     psub->inpb
long  initSubDevName(psub)
struct subRecord  *psub;
{
    char  *xname="initSubDevName";
    struct subDNamePvt   *p;
    struct  dbAddr  *pdbAddr;
    long  status;

if ((psub->dpvt = malloc( sizeof(struct subDNamePvt))) == NULL) {
errPrintf(S_dev_noMemory, __FILE__, __LINE__,
"%s: couldn't allocate memory for %s\n", xname, psub->name);
return(S_dev_noMemory);
}
p = (struct subDNamePvt *)psub->dpvt;
if(!(pdbAddr = dbGetPdbAddrFromLink(&DEVICENAME))) {
psub->dpvt = NULL;
status = S_dev_NoInit;
recGblRecordError(status, (void *)psub,
"initSubDevName: inpb not a db link\n");
return(status);
}
p->psi = (struct stringinRecord *)pdbAddr->precord;
return(OK);
}
---------------------------------------------------------------
long subDeviceName(psub)
struct subRecord *psub;
{
struct subDNamePvt *p;
int id;
if ((p=(struct subDNamePvt *)psub->dpvt) == NULL )
return(OK);


id = (int) psub->a;

strcpy(p->device,idInfo[id].name);

    psub->c = idInfo[id].periodLength;
    psub->d = idInfo[id].minimumGap;
    psub->e = idInfo[id].hardStops;

    strcpy(p->psi->val, p->device);
    dbPutLink(&DEVICENAME,DBR_SHORT,1,1);
    printf("For Device Number %d\n", id);
    printf("     Data read from file %s\n",idInfo[id].dataFile);
    printf("     Device Name is : %s\n", p->psi->val);
    printf("     Period is %.2f cm\n",  psub->c);
    printf("     Mimimum Gap is %.2f mm\n",psub->d);
    printf("     Hard stops is %.2f mm\n",psub->e);

    return(0);
}

Marty

Laznovsky, Michael wrote:
Hi- how can I get strings in & out of subroutine records?

It appears that the sub record tries to convert all its inputs to "double" before calling the user function, and complains if it fails. All I want is to read/write actual strings from inside the function.

thanks, Mike
SLAC



References:
stringin/out <-> sub record ? Laznovsky, Michael

Navigate by Date:
Prev: Re: stringin/out <-> sub record ? Andy Foster
Next: RE: gateway enum writes Kenneth Evans, Jr.
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  <20062007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: Re: stringin/out <-> sub record ? Andy Foster
Next: Re: stringin/out <-> sub record ? Andrew Johnson
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  <20062007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 02 Sep 2010 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·