Update value spinbox

More
14 Mar 2020 16:42 - 14 Mar 2020 16:44 #160196 by jurod
Update value spinbox was created by jurod
Hi, I need to update the spinbox value with some gcode. I have an automatic pallet line and after each shot (nail) i need subtract from spinbox nails. From 500 to 0. At value 0 must be a pause. Please help.

From hal:
loadusr -W paramsaver f=3 s=0 b=0 filename=memory_pins onstart=1 onexit=1

net rameno_r1_a-out pyvcp.r1_a => paramsaver.invalueF-000
net rameno_r1_a-in pyvcp.spinbox.0.param_pin <= paramsaver.outvalueF-000
net r1-a-dobit halui.mdi-command-00 pyvcp.r1_a_dobit

net rameno_r1_b-out pyvcp.r1_b => paramsaver.invalueF-001
net rameno_r1_b-in pyvcp.spinbox.1.param_pin <= paramsaver.outvalueF-001
net r1-b-dobit halui.mdi-command-01 pyvcp.r1_b_dobit

net writetrigger motion.digital-out-17 paramsaver.writetrigger
net readtrigger motion.digital-out-18 paramsaver.readtrigger


From ini:
[HALUI]
MDI_COMMAND = o<r1a_dobit> call
...
...

The ngc:
O<r1a_dobit> sub
#<TEMP> = [#<_hal[rameno_r1_a-out]>] ;no works
#<TEMP> = [#<TEMP> -1] ;no works
O<r1a_dobit> endsub
M2


Or i need a python program?
Last edit: 14 Mar 2020 16:44 by jurod.

Please Log in or Create an account to join the conversation.

More
14 Mar 2020 19:12 #160204 by cmorley
Replied by cmorley on topic Update value spinbox
Pyvcp has no way to update spinbox widgets in the way you are hoping to.
Pyvcp has no user exposed way to add python code.
Pyvcp is a simple program to display simple things.

Gladevcp can have have python code added at run time and I'm sure this is the route you will need to go.

Chris

Please Log in or Create an account to join the conversation.

More
16 Mar 2020 11:39 - 20 Mar 2020 05:52 #160413 by jurod
Replied by jurod on topic Update value spinbox
OK
So, i have gladevcp panel
From .ini:
[DISPLAY]
GLADEVCP = -u savestate_gladevcp.py -u dob_button.py  GLADEVCP.ui

[HAL]
HALUI = halui
HALFILE = LINKA.hal
POSTGUI_HALFILE= Gladevcp.hal


From GLADEVCP.ui
<object class="HAL_SpinButton" id="r1a">
                <property name="width_request">100</property>
                <property name="height_request">50</property>
                <property name="visible">TRUE</property>
                <property name="can_focus">TRUE</property>
                <property name="digits">0</property>
                <property name="tooltip_text" translatable="yes">" "</property>
                <property name="invisible_char">&#x25CF;</property>
                <property name="adjustment">r1aadj</property>
                <signal name="changed" handler="spin_handler" swapped="no"/>
              </object>
              <packing>
                <property name="x">150</property>
                <property name="y">25</property>
              </packing>
             <object class="GtkAdjustment" id="r1aadj">
             <property name="lower">0</property>
             <property name="upper">499</property>
             <property name="value">499</property>
             <property name="step_increment">1</property>
             <property name="page_increment">1</property>
             <property name="page_size">50</property>
             </object>
            </child>
...
...
...
             <child>
              <object class="HAL_Button" id="bt_r1a">
                <property name="label" translatable="yes">Dobit</property>
                <property name="width_request">60</property>
                <property name="height_request">25</property>
                <property name="visible">True</property>
                <property name="can_focus">True</property>
                <property name="receives_default">True</property>
                <property name="use_action_appearance">true</property>
                <signal name="pressed" handler="on_bt_r1a_pressed" swapped="no"/>
              </object>
              <packing>
                <property name="x">280</property>
                <property name="y">40</property>
              </packing>         
            </child>
The Gladevcp.hal:
#empty

The dob_button.py ;no vorks
#!/usr/bin/env python

import os,sys
import hal
import gtk
import linuxcnc
         
class HandlerClass:
    def on_bt_r1a_pressed(self,widget,data=None):
        widget.set_value(499)

def get_handlers(halcomp,builder,useropts):
    return [HandlerClass()]

Now i need by button (bt_r1a) to change the value in spinbutton (r1a) to 499. I also need by a "G" , "M" or "Python" code (after each activation) reduce the value in the spinbox to 0. At value 0 will pause. How to do it?
Attachments:
Last edit: 20 Mar 2020 05:52 by jurod.

Please Log in or Create an account to join the conversation.

More
16 Mar 2020 12:59 - 16 Mar 2020 13:00 #160423 by BigJohnT
Replied by BigJohnT on topic Update value spinbox
This would be pretty simple using QtPyVCP, you can add all the Python you want and have a custom interface with only what you need.

www.qtpyvcp.com/

My BP mill GUI

github.com/jethornton/mill_touch_v6

Are you using several large magazine coil nailers and just move the gantry over the boards to nail?

JT
Last edit: 16 Mar 2020 13:00 by BigJohnT.

Please Log in or Create an account to join the conversation.

More
16 Mar 2020 13:24 #160425 by jurod
Replied by jurod on topic Update value spinbox
For imagination
Attachments:

Please Log in or Create an account to join the conversation.

More
16 Mar 2020 17:09 #160449 by cmorley
Replied by cmorley on topic Update value spinbox
What version of linuxcnc are you using?

Chris

Please Log in or Create an account to join the conversation.

More
16 Mar 2020 17:12 - 16 Mar 2020 17:25 #160450 by jurod
Replied by jurod on topic Update value spinbox
Version from AXIS 2.7.14. and linux:

Distributor ID: Debian
Description: Debian GNU/Linux 9.5 (stretch)
Release: 9.5
Codename: stretch

Linux 2ua3490l 4.9.0-8-rt-amd64 #1 SMP PREEMPT RT Debian 4.9.110-3+deb9u6 (2018-10-08) x86_64 GNU/Linux
Last edit: 16 Mar 2020 17:25 by jurod.

Please Log in or Create an account to join the conversation.

More
16 Mar 2020 17:26 #160452 by cmorley
Replied by cmorley on topic Update value spinbox
Your handler file is coded to catch the button press but the says to set_value on the button.
You want it to set the value of the spinbutton.
You need to define a reference to the spinbutton first...

If you could post the GLADE file I'll see if I have time later to mock something up for you.

Chris

Please Log in or Create an account to join the conversation.

More
16 Mar 2020 18:00 - 16 Mar 2020 18:02 #160457 by jurod
Replied by jurod on topic Update value spinbox
Thanks, but the button function is not essential. It's secondary. For me, the code that counts the nails is necessary. I have four rows of nails. Each works separately.
Attachments:
Last edit: 16 Mar 2020 18:02 by jurod.

Please Log in or Create an account to join the conversation.

More
16 Mar 2020 23:29 #160483 by cmorley
Replied by cmorley on topic Update value spinbox
python handler file that initializes one of the spin buttons, and a HAL pin to control it.
The button will update the spin button to 499
The spin button counts down till 0 then prints 'pause' to the terminal



M105 file to toggle the HAL pin
you must add the Mcode path to INI- something like this:
[RS274NGC]
USER_M_PATH = ~/linuxcnc/nc_files
the file must be executable

File Attachment:

File Name: M105.zip
File Size:0 KB


The every time you add m105 to gcode it counts the spinbox down 1
That should be a good start to what you want.

Chris
Attachments:

Please Log in or Create an account to join the conversation.

Time to create page: 0.219 seconds
Powered by Kunena Forum