Hi,
It is possible to to initialize an output/set point record to the current
state of the device
using devGpib device support
Firstly the records PINI field should be set "YES".
The gpibCmd entry is set to GPIBCVTIO, e.g:
static struct gpibCmd gpibCmds[] = {
...
/* 1 - Frequency Set Point */
{&DSET_AO, GPIBCVTIO, IB_Q_LOW, NULL, NULL, 0, 20,
convertSetPoint, 12, 0, Frequency_Cmds, NULL, "\033"},
...
In the convertSetPoint function, test is this is the first time the record
has processed.
If yes, read the current device state othersize update the device state,
e.g:
static int convertSetPoint (struct gpibDpvt *pdpvt, int P1, int P2,
char **P3)
{
struct aoRecord *pao = ((struct aoRecord *) (pdpvt->precord));
asynOctet *pasynOctet = pdpvt->pasynOctet;
void *asynOctetPvt = pdpvt->asynOctetPvt;
char *command;
int size;
asynStatus status;
size_t ntrans;
size_t nrecv;
char cbuf[80];
/* If it's the first time this routine is called, just initialise the
record
to the present set point stored in the device.
NB. This means that the record must have PINI = YES.
*/
if (pao->init == 1) {
command = P3[GET_CMD_INDEX];
size = strlen (command);
strcpy (pdpvt->msg, command);
status = pasynOctet->
write (asynOctetPvt, pdpvt->pasynUser, pdpvt->msg, size,
&ntrans);
if (status != asynSuccess) {
errlogPrintf ("pasynOctet write failed\n");
return NOTOK;
}
/* read the result
*/
status = pasynOctet->
read (asynOctetPvt, pdpvt->pasynUser, cbuf, 80, &nrecv, NULL);
if (status != asynSuccess) {
errlogPrintf ("\n pasynOctet read failed\n");
return NOTOK;
}
/* convert the value to float
*/
pao->val = atof (&(cbuf[P1]));
pao->nsev = NO_ALARM;
pao->nsta = NO_ALARM;
pao->udf = 0;
return OK;
} else {
/* Write the Current Set Point command out to the device.
*/
sprintf (cbuf, P3[SET_CMD_INDEX], pao->val);
size = strlen (cbuf);
status = pasynOctet->
write (asynOctetPvt, pdpvt->pasynUser, cbuf, size, &ntrans);
if (status != asynSuccess) {
errlogPrintf ("pasynOctet write failed\n");
return NOTOK;
}
pao->nsev = NO_ALARM;
pao->nsta = NO_ALARM;
pao->udf = 0;
return OK;
}
} /* convertSetPoint */
Regards
Andrew Starritt
_______________________________________
Senior Systems Engineer - Software Specialist
Australian Synchrotron Project
800 Blackburn Road, Clayton, Victoria 3168
Tel: +61 3 8540 4164
Fax: +61 3 8540 4200
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]] On Behalf Of Szalata, Zenon M.
> Sent: 20 October 2007 11:45 AM
> To: Mark Rivers; EPICS tech-talk
> Subject: RE: Initial Value
>
> Thanks Mark, I will look into it.
> Zen
>
> -----Original Message-----
> From: Mark Rivers [mailto:[email protected]]
> Sent: Friday, October 19, 2007 6:39 PM
> To: Szalata, Zenon M.; EPICS tech-talk
> Subject: RE: Initial Value
>
> Hi Zen,
>
> I just looked at the devGpib documentation, and I don't see a
> way to initialize an output record to the current state of the device.
>
> You might want to look at the Steam Device instead
> (http://epics.web.psi.ch/software/streamdevice/doc/).
>
> It can definitely do what you want, and it may be simpler
> than devGpib.
>
> >From the Stream Device documentation:
> @init
> Not really an exception but formally specified in the same syntax.
> This handler is called from iocInit during record initialization.
> It can be used to initialize an output record with a value
> read from the device.
>
> Mark
>
>
>
>
> ________________________________
>
> From: Mark Rivers
> Sent: Fri 10/19/2007 8:21 PM
> To: Szalata, Zenon M.; EPICS tech-talk
> Subject: RE: Initial Value
>
>
> I am not familiar with the devGpib device support that you
> are using. I was making a general point that EPICS output
> records typically do a read during iocInit to come up with
> the current state of the device. I assume it is possible to
> do this with devGpib but I don't know how. Eric Norum is
> probably the person to ask.
>
> Mark
>
>
> ________________________________
>
> From: Szalata, Zenon M. [mailto:[email protected]]
> Sent: Fri 10/19/2007 6:38 PM
> To: Mark Rivers; EPICS tech-talk
> Subject: RE: Initial Value
>
>
>
> I don't understand. You seem to be implying that the mbbo
> record should come up in a state which corresponds to the
> state of the instrument. That is not what happens in my
> case. This is my record:
>
> record( mbbo,"$(P)$(R)WFunc"){
> field( DESC, "set function")
> field( DTYP, "ag33220")
> field( OUT, "#L$(L) A$(A) @4")
> }
>
> Am I missing some field in this? The gpibCmd is:
>
> {&DSET_MBBO,GPIBEFASTO,IB_Q_HIGH,0,0,0,32,0,0,0,fcmds,&func,0}
>
> Where:
> static char*
> funcList[]={"SIN","SQU","TRI","RAMP","NOISE","DC","USER",0};
> static unsigned long funcVal[]={0,1,2,3,4,5,6,7}; static
> struct devGpibNames func={7,funcList,funcVal,2}; static char
> *(fcmds[])={"APPL:SIN","APPL:SQU","APPL:TRI","APPL:RAMP",
> "APPL:NOISE","APPL:DC","APPL:USER",NULL};
>
> Thanks for helping,
> Zen
>
> -----Original Message-----
> From: Mark Rivers [mailto:[email protected]]
> Sent: Friday, October 19, 2007 3:27 PM
> To: Szalata, Zenon M.; EPICS tech-talk
> Subject: RE: Initial Value
>
> Yes, the device support for the mbbo record should do an
> initial read of the device to get the value when the IOC boots.
>
> You can see an example in the generic asyn device support for
> the mbbo record in asyn/devEpics/devAsynInt32.c
>
> > -----Original Message-----
> > From: [email protected]
> > [mailto:[email protected]] On Behalf Of
> Szalata, Zenon M.
> > Sent: Friday, October 19, 2007 5:24 PM
> > To: EPICS tech-talk
> > Subject: Initial Value
> >
> > An Agilent 33220A Wave Form Generator is attached to ICS8065
> > Ethernet-GPIB controller. I am designing a soft IOC using EPICS
> > 3.14.9 and asyn 4-8. I have setup mbbo type record to control the
> > instrument function, which can have one of 7 values. In
> edm I have a
> > choice button connected to this record. I can chose the
> function by
> > clicking on one of the choices. When the instrument is in
> a function
> > which corresponds to any but the first choice and the IOC is
> > restarted, the record comes up with some initial values consistent
> > with the first choice. Hence, the instrument and the IOC
> disagree on
> > the function.
> > Is there a simple way to initialize the mbbo record when the IOC is
> > starting up so that it reflects the function selected in the
> > instrument? Thanks, Zen
> >
> >
>
>
>
>
- References:
- RE: Initial Value Szalata, Zenon M.
- Navigate by Date:
- Prev:
Calculating status with invalid/non-existant inputs Andrew Starritt
- Next:
Re: Installing EDM on OS X 10.4.10 Bertrand H.J. Biritz
- Index:
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
<2007>
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
- Navigate by Thread:
- Prev:
RE: Initial Value Szalata, Zenon M.
- Next:
Motor record news Denison, PN (Peter)
- Index:
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
<2007>
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
|