On Monday 17 April 2017 16:16:45 Kurt Jacobson wrote:
> #!/usr/bin/env python
> import hal, time
> import linuxcnc
>
> stat = linuxcnc.stat()
>
> h = hal.component("units")
> h.newpin("prog_in", hal.HAL_BIT, hal.HAL_OUT)
> h.newpin("prog_mm", hal.HAL_BIT, hal.HAL_OUT)
> h.newpin("update_rate", hal.HAL_FLOAT, hal.HAL_IN)
>
I did a loadusr units, and if I look at a halmeter I can see the above
pins, with
prog_in=true
prog_mm=false
update_rate=.1
but I now assume it needs addf'd to a thread before it works as it is not
responding to a g20-g21 issued thru the MDI cmd line.
The jog-thread is 10x too fast. I already have a jog-thread created, and
man 9 threads says it can do 3 per call, so am I to have it create a
mode-thread at 10x the period of the jog-thread? And addf it to that
thread? But that won't run. The light at the end of the tunnel? It's
not moving. :(
So I got rid of the addf, but left the mode-thread, and now its working!
Call me confused. The docs do not cover this.
Now I need it to report the viewport dro mode too, and find out if I can
use it to switch the background colors of a label box, and a number box,
neither of which are noted to actually have that ability. A pyvcp LED
can, but it can't show text.
Is getting the DRO mode as simple as adding:
h.newpin("dro_in", hal.HAL_BIT, hal.HAL_OUT)
h.newpin("dro_mm", hal.HAL_BIT, hal.HAL_OUT)
To the above code? It can't do worse than fail. And of course it did.
Failed safe, and the only thing that is updated in the linuxcnc-status
display is the number of the command when the ! key is repeatedly
pressed. So it is not available in the status array. Grrrr.
That means all I can do is leave the displayed jog size alone, but make
the jog size displayed be inches or mm's as applied to the machines
motion. EG if G20 it true the displayed value in inches, but if G21 is
true, the displayed jog size, which doesn't change in the gui, but the
jog is then done in mm's.
That is not what I had in mind, but it can be lived with IF I can change
the background color of the num-box to track the g20-g21 status.
Can I???
Thanks pyvcp experts. And how many on this list are color-blind, making
a poor choice of colors unusable for your use?
> h.ready()
>
> # Set default update rate to 50ms
> h.update_rate = .05
>
> try:
> while 1:
> time.sleep(h.update_rate)
> stat.poll()
> prog_units = stat.program_units
> if prog_units == 1: # Inch
> h.prog_in = 1
> h.prog_mm = 0
> elif prog_units == 2: # Metric
> h.prog_in = 0
> h.prog_mm = 1
> except KeyboardInterrupt:
> raise SystemExit
Cheers, Gene Heskett
--
"There are four boxes to be used in defense of liberty:
soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
Genes Web page <http://geneslinuxbox.net:6309/gene>
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Emc-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/emc-developers