Hi Patrick,
To answer your second question first: Are you using asyn for socket
communication? If so all communication should be done either with
pasynOctetSyncIO->writeRead() which is an atomic operation, and/or in
the callback from pasynManager->queueRequest, where you can do
pasynOctet->write() followed by pasynOctet->read() and be guaranteed
that nothing else can talk to the socket at the same time.
For your first question, if you set PACT=1 then another position cannot
make it to your device support until PACT=0 from the original record
processing.
Are you aware of the EPICS "motor" record? It handles all of these
things for you. It does not set PACT=1 when a move it in progress, so
additional positions or stop requests can make it to device support.
The current version of the motor record uses a device-independent asyn
device support layer, a device-independent asyn driver layer, and then a
simple set of about a dozen functions that you must write for a
particular controller. It is really quite easy to write a new driver.
It does exactly what you want: polling updates of position and status,
ability to set a new target position while the motor is moving, etc.
Plus lots of features like hard and soft limits, etc.
http://www.aps.anl.gov/bcda/synApps/motor/
Mark
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Patrick Thomas
Sent: Friday, July 24, 2009 7:22 AM
To: [email protected]
Subject: checking for change in value in device support function
Hi,
I would like to try to implement the following pseudo code as a device
support function for a motor. Basically, when called, it turns the motor
on, checks to see if the motor was on, tells the motor to move to a
position, waits for it to finish or time out, turns the motor off,
checks to see if the motor is off, then checks to see if the current
position is the one that was requested. The functions that it calls will
be provided by driver support. The question I have is that I want it to
immediately start moving to a new position if a new value is entered in
the associated ao record field, even if the motor is already in motion.
Is it possible to check for changes in the value field of the record
from this function? Do I need to start this function as a new thread,
set PACT to true, and then set it to false at the end of the thread? How
would the thread pick up on the fact that the record value field has
changed?
Another question I have is, that in driver support, in the init
function, I will open up a socket connection and spawn a thread which
constantly polls the motor for its status, ie current position,
trajectory mode, motion done, etc. This data will be written to a
structure which is available to the device support. However, when device
support calls other driver support functions which communicate with the
motor over the same socket connection, how do I ensure that these don't
collide with the functions that are constantly polling?
Thank you,
Patrick
request_move_to_absolute_position( record val field )
{
motor_on();
if (read_motor_on != true)
{
print error;
return;
}
move_to_absolute_position( record val field );
while ( (motion_done_status != true) and (timeout != true) ) {
if ( record val field changes ) {
move_to_absolute_position( record val field );
reset timeout;
}
}
motor_off();
if (read_motor_off != true)
{
print error;
}
if (read_actual_position() != record val field) {
print error;
}
return;
}
- References:
- checking for change in value in device support function Patrick Thomas
- Navigate by Date:
- Prev:
checking for change in value in device support function Patrick Thomas
- Next:
Re: labview w/ CA Jiro Fujita
- 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:
checking for change in value in device support function Patrick Thomas
- Next:
DG645 driver - anyone have one? Dalesio, Leo
- 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
|