Greets - I'm trying to write a machine-specific glade gui and I need to
create a multiple step jog sequence while a button (and/or preferably a
HAL pin) is true.
The jog info and my test jogging to a single target value works fine in
my glade panels, however the "if" tests (trying not to set up "while"
blocking) don't seem to actually get tested while the glade button is
depressed for the multiple target points version.
For example: a glade panel contains 3 spinners (feed, target_a,
target_b) and a button (go), and there is a working basic environment
for axes and feedback. Assuming the current position is 0.00, the
target_a is 1.00 and target_b is 2.00, and feed = 50....if I have a
function and assuming we are in linuxcnc.MODE_MANUAL:
def go_pressed(self, widget, data=None)
feed = self.builder.get_object("feed").get_value() # which
comes from the glade panel as 50.0
target_a = self.builder.get_object("target_a").get_value() #
which comes from the glade panel as 1.00
target_b = self.builder.get_object("target_b").get_value() #
which comes from the glade panel as 2.00
if feed > 0: # test to make sure there is a motion feedrate so
we don't stall forever...
self.s.poll()
position = self.s.actual_position[0] # assuming X axis for
testing
if position < target_a: # tests that position is less than
target_a, where we are going to jog positive to get to target_a
self.c.jog(self.cnc.JOG_CONTINUOUS, 0, feed) # assumes
joint 0 for testing
elif position < target_b: # we should fall through to here
once position = target_a, but we DON'T!
self.c.jog(self.cnc.JOG_CONTINUOUS, 0, feed / 10) # note
the div 10 for "really slow".
else:
print 'All done'
self.c.jog(self.cnc.JOG_STOP, 0) # and stop motion even
if the button is still pressed, yet this also doesn't get tested!
so the above has a companion go_released function for completeness that
I didn't show (the basics of this came from John Thorton's excellent
tutorials - thank you , BTW) -- the function above is the crux to get
right first.
I understand the concept of non-blocking routines from other aspects of
my career, so have been cautious to avoid a test like "where" that could
potentially stall the python script. What I am observing with the above
(and about 5 or 6 variants I tried without success, including external
functions, mdi sequences, wait_for_complete - which does block etc) is
that if I keep the button pressed the routine keeps running, it seems to
get stalled in the first "if" test and never jumps out. If I release the
button, motion stops as expected - and if I'm lucky to do it between
states, the "if" statements get re-evaluated, and the 2nd test will get
tried. For example, if I press button and I release before position gets
to 2.00, the re-press, the feed will be 10% - as required, but it will
never re-test to find position >= target_b. IF I release and re-press
past 2.00, then it does fall through to the final else.
I had originally built this with a very long (and ugly) halcomp. Is
there a clean way to keep this all in python, or does it need a
companion halcomp, and if so, how does one pass data between comps and
python?
Thanks,
Ted.
_______________________________________________
Emc-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/emc-users