how to create a link Button help me please !!

More
07 Jan 2011 15:00 #6514 by Raen
i already made buttons with configuration and saved program.xml :

<pyvcp>
<button>
<text>"program"</text>
</button>
</pyvcp>

program.xml --> placed in the same place as axis_mm.ini and on [display] have been add pyvcp = program.xml

this made button appear on software Emc2-Axis

1. how can i create link to call "holeicecircle.py" when i click the "program" button?

2. where should i put the "holeicecircle.py"?

3. please guide me step by step.......

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

More
07 Jan 2011 17:27 - 07 Jan 2011 17:35 #6517 by andypugh
There may be neater ways with ngcgui or gladevcp, but I think this will work.

You can make EMC2 run a G-Code command using the MDI_COMMAND option in the INI file.

You can create a "Custom M-code" from M101 to M199 that can be any executable file.
Firstly, as written the button does nothing at all, you probably need:
<pyvcp>
<button>
<text>"program"</text>
<halpin>"program"</halpin>
</button>
</pyvcp>

In the INI file you need

1) In the [HAL] Section
HALUI = halui

2) Add a section [HALUI]
[HALUI]
MDI_COMMAND = M101

3) Create an M101 executable file and put it in your PROGRAM_PREFIX directory. Right-click it to make it executable. it should start with
#!bin/sh
And then the commands you would use to start the python script from the command line.

Alternatively you can probably start the M101 file with "#!/usr/bin/env python" and then paste in all the python from your existing file.

You then need to link the button you created to the MDI_COMMAND pin, so, in the postgui HAL file add this line:
net btn1 halui.mdi-command-00 <= pyvcp.program
Last edit: 07 Jan 2011 17:35 by andypugh.

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

More
07 Jan 2011 17:45 #6519 by Raen
3) Create an M101 executable file and put it in your PROGRAM_PREFIX directory. Right-click it to make it executable. it should start with

Code:

#!bin/sh


And then the commands you would use to start the python script from the command line.

Alternatively you can probably start the M101 file with "#!/usr/bin/env python" and then paste in all the python from your existing file.

You then need to link the button you created to the MDI_COMMAND pin, so, in the postgui HAL file add this line:

Code:

net btn1 halui.mdi-command-00 <= pyvcp.program

^
^

i dont understand this step....anyway thx for helping me ^^

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

More
07 Jan 2011 18:49 #6521 by andypugh
Raen wrote:

net btn1 halui.mdi-command-00 <= pyvcp.program

i dont understand this step.


You need to create a link between the button and EMC2. At the moment it is just a button, it doesn't do anything. This line makes a link between the button (pyvcp.program) and the MDI_COMMAND. It then calls that "signal" btn1, but you could call it anything you like.

It has to go in the postgui.hal file as until the GUI has loaded and created the pyvcp panel, there is no pyvcp.program pin to link. (You can change the name of the pin to anything you want as long as it matches the <halpin> tag in the pyvcp xml file.)

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

More
08 Jan 2011 09:09 #6525 by Raen
Umm, i mean, i dont understand from step 3....

3) Create an M101 executable file and put it in your PROGRAM_PREFIX directory. Right-click it to make it executable. it should start with
(how to create an M101 executeable file? .exe / .py / .xml ??)
(what is the PROGRAM_PREFIX directory?)

Code:

#!bin/sh
(where should i put this command?)

And then the commands you would use to start the python script from the command line. (python script? "my program.py" ?)

Alternatively you can probably start the M101 file with "#!/usr/bin/env python" and then paste in all the python from your existing file. (how to configure this step? >.<)

You then need to link the button you created to the MDI_COMMAND pin, so, in the postgui HAL file add this line: (where's the postgui HAl file ?)

Code:

net btn1 halui.mdi-command-00 <= pyvcp.program

sorry for many question....but i hope that you want to help me....>.<

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

More
08 Jan 2011 12:06 #6526 by andypugh
Raen wrote:

3) Create an M101 executable file and put it in your PROGRAM_PREFIX directory. Right-click it to make it executable. it should start with
(how to create an M101 executeable file? .exe / .py / .xml ??)

I would probably use Gedit (the text editor). Just create a new file, and call it M101, and save it.

(what is the PROGRAM_PREFIX directory?)

It is the directory where EMC2 looks for files. PROGRAM_PREFIX is a setting in the INI file which defines where it is.

#! bin/sh

(where should i put this command?)

In the text file you created above. Setting the file to be executable (right-click or use chmod) tells Linux that the file is a program. the <hash><exclamation><space> sequence tells Linux that the rest of the first line is the path to the interpreter that will execute the file, in this case the command shell.

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

More
08 Jan 2011 12:35 #6527 by Raen
i already finished all step but the button still cant execute my program.....

1. my xml file is int.xml --> i put this file in same place with axis_mm.ini file
<pyvcp>
<button>
<text>"program"</text>
<halpin>"program"</halpin>
</button>
</pyvcp>

2.axis_mm.ini [DISPLAY] section
pyvcp = int.xml

[HAL] section
HALUI = halui

then i add
[HALUI]
MDI_COMMAND = M101

3. i put a M101 file into NC_files
right click / properties / permissions tab / check a allow executing file as program
#!bin/sh already added at M101 file

4.i have create a intpostgui.hal and i put that file with the same place with my int.xml
intpostgui.hal file :
net btn1 halui.mdi-command-00 <= pyvcp.program

5. i confuse to place my "program.py" file....where should i put that file ?

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

More
08 Jan 2011 12:46 - 08 Jan 2011 12:47 #6528 by BigJohnT
I assume up to step 3 all works. Can you issue a M101 in a program and does it work?

Step 4 looks fine, not sure what your asking on step 5.

John
Last edit: 08 Jan 2011 12:47 by BigJohnT.

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

More
08 Jan 2011 13:25 #6529 by Raen
@John

i already done till step 3 but i still cant execute my "program.py" file from clicking my button named "program"

step 5 mean, is there any specific place for my "program.py" file to be placed?

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

More
08 Jan 2011 13:48 #6531 by BigJohnT
The program button will run the MDI command 00 which is M101. Is program.py part of M101?

John

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

Time to create page: 0.140 seconds
Powered by Kunena Forum