Experimental Physics and
| |||||||||||||||||
|
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?
| ||||||||||||||||
ANJ, 02 Sep 2010 |
·
Home
·
News
·
About
·
Base
·
Modules
·
Extensions
·
Distributions
·
Download
·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing · |