OK, I was not aware that doing a pvGet on a PV that you have set a monitor and event flag on would set the event flag. But you normally would never do this: if you set a monitor on a PV then you don't ever need to do a pvGet on it; the variable is guaranteed to always contain the most recent value of that PV without ever calling pvGet.
Mark
________________________________
From: Patrick Thomas [mailto:[email protected]]
Sent: Fri 10/2/2009 7:29 PM
To: Mark Rivers
Cc: [email protected]
Subject: Re: state notation code flags
This also prints out the flag:
program sncTest
float test_put;
assign test_put to "H3:TEST_PUT";
monitor test_put;
evflag test_putEvent;
sync test_put test_putEvent;
float test_get;
assign test_get to "H3:TEST_GET";
monitor test_get;
evflag test_getEvent;
sync test_get test_getEvent;
ss ss1 {
state init {
when () {
efClear(test_getEvent);
pvGet(test_get);
if (efTest(test_getEvent)) {
printf("flag set\n");
}
} state wait
/*
when () {
efClear(test_putEvent);
test_put = 40;
pvPut(test_put, SYNC);
efClear(test_putEvent);
} state wait
*/
}
state wait {
/*
when () {
if (efTest(test_putEvent)) {
printf("flag set\n");
}
} state wait
*/
when () {
} state wait
}
}
Mark Rivers wrote:
> Patrick,
>
> pvGet will not set the event flag. Event flags are only set on monitor
> callbacks, i.e. when the value changes in the IOC and it does callbacks
> to channel access clients that have subscribed to that channel.
>
> pvGet(pv) normally blocks for the operation to complete, so it gives the
> same behavior as pvGet(pv, SYNC) (unless you compiled with the +a
> option, which I would not recommend).
>
> pvPut(pv) and pvPut(pv, SYNC) do behave differently, because the default
> behavior is not to wait for the pvPut to complete, adding the SYNC
> option forces it to wait for the put to complete.
>
> Mark
>
>
> -----Original Message-----
> From: Patrick Thomas [mailto:[email protected]]
> Sent: Friday, October 02, 2009 1:25 PM
> To: Mark Rivers
> Cc: [email protected]
> Subject: Re: state notation code flags
>
> Hi Mark,
>
> If I have the following:
>
> float request_move_to_absolute_position;
> assign request_move_to_absolute_position to
> "{IFO}:{DRIVER}_REQUEST_MOVE_TO_ABS_POS_{AXIS}";
> monitor request_move_to_absolute_position;
> evflag request_move_to_absolute_positionEvent;
> sync request_move_to_absolute_position
> request_move_to_absolute_positionEvent;
>
> ...
>
> pvGet(request_move_to_absolute_position);
> efClear(request_move_to_absolute_positionEvent);
>
> Will the pvGet set the request_move_to_absolute_positionEvent flag? If
> so, is it possible that even with the efClear, the flag will remain set
> at the end of the code, because the pvGet will not have completed before
>
> the efClear is encountered? But if
> pvGet(request_move_to_absolute_position, SYNC) is used, will this
> guarantee that the efClear will clear the flag?
>
> Thank you,
> Patrick
>
>
> Mark Rivers wrote:
>
>> Patrick,
>>
>> Event flags can be explicitly set, which is typically used to allow
>> communication between state sets. Or event flags can be synced to a
>>
> PV,
>
>> and will be set whenever a monitor is received for that PV, as in the
>> example I sent you.
>>
>> You can use the efTest() function outside of a when statement, just
>>
> like
>
>> any other function.
>>
>> Mark
>>
>>
>> -----Original Message-----
>> From: Patrick Thomas [mailto:[email protected]]
>> Sent: Thursday, October 01, 2009 5:20 PM
>> To: Mark Rivers
>> Cc: [email protected]
>> Subject: Re: state notation code flags
>>
>> Hi Mark,
>>
>> Are the flags on a monitored variable set whenever the monitored
>> variable is used in the code, including a pvPut, pvGet, assignment,
>> calculation, or print statement? Is there a way to test if the flag is
>>
>
>
>> set besides an efTest in a when statement?
>>
>> Thank you,
>> Patrick
>>
>> Mark Rivers wrote:
>>
>>
>>> Hio Patrick,
>>>
>>> Here are some code snippets from one of my SNL programs. It has a
>>>
>>>
>> variable nelements assigned to a PV, and a monitor on that PV. It has
>> an event flag, nelementsMon that is synced to nelements. Whenever
>> nelements changes the event flag will be set. In the init state I
>>
> clear
>
>> the event flag, just to be sure it is clear when the SNL code starts
>> running (after all PVs connect). I then use efTestAndClear in a when
>> statement to take actions when that event flag is set, and to clear
>>
> it.
>
>> This works fine for me.
>>
>>
>>> int nelements; assign nelements to "{P}{R}Nelements.VAL";
>>> monitor nelements;
>>> evflag nelementsMon; sync nelements nelementsMon;
>>>
>>>
>>> /* Initialize things when first starting */
>>> state init {
>>> when() {
>>> /* Clear all event flags */
>>> ...
>>>
>>> efClear(nelementsMon);
>>> } state monitor_inputs
>>> }
>>>
>>>
>>> ...
>>>
>>> state monitor_inputs {
>>>
>>> ...
>>>
>>> when(efTestAndClear(nelementsMon) && (nelements>=1)) {
>>> /* If nelements changes, then change endPulses to this
>>>
>>>
>> value,
>>
>>
>>> * since this is what the user normally wants. endPulses
>>>
>>>
>> can be
>>
>>
>>> * changed again after changing nelements if this is
>>>
>>>
>> desired. */
>>
>>
>>> if (moveMode == MOVE_MODE_RELATIVE)
>>> endPulses = nelements;
>>> else
>>> endPulses = nelements-1;
>>> pvPut(endPulses);
>>> } state monitor_inputs
>>> }
>>>
>>> Mark
>>>
>>> ________________________________
>>>
>>> From: [email protected] on behalf of Patrick Thomas
>>> Sent: Wed 9/30/2009 10:35 PM
>>> To: [email protected]
>>> Subject: state notation code flags
>>>
>>>
>>>
>>> Hi,
>>>
>>> I was wondering if there is a way to track at what point in the state
>>> notation code evflags are getting set and cleared, or if someone
>>>
> could
>
>>> clarify under what conditions they get set. I'm having trouble with
>>>
>>>
>> them
>>
>>
>>> getting set somewhere and not being cleared, but I'm not sure where.
>>>
>>> Thank you,
>>> Patrick
>>>
>>>
>>>
>>>
>>>
>>
>>
>
>
- References:
- state notation code flags Patrick Thomas
- RE: state notation code flags Mark Rivers
- Re: state notation code flags Patrick Thomas
- RE: state notation code flags Mark Rivers
- Re: state notation code flags Patrick Thomas
- RE: state notation code flags Mark Rivers
- Re: state notation code flags Patrick Thomas
- Navigate by Date:
- Prev:
RE: state notation code flags Mark Rivers
- Next:
Re: state notation code flags Patrick Thomas
- 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: state notation code flags Patrick Thomas
- Next:
Re: state notation code flags Patrick Thomas
- 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
|