× Forum Header

Stepconf destroy postgui_custom.hal

More
29 Feb 2016 00:55 #70788 by nicokid
Hi,
Why stepconf overwrites the postgui_custom.hal file while it leaves untouched custom.hal?
I believe that the problem is here:
custom = os.path.join(base, "custom_postgui.hal")
if os.path.exists(custom):
	shutil.copy( custom,os.path.join(base,"postgui_backup.hal") )
f1 = open(custom, "w")
First it is overwritten by the backup file and after is still destroyed by open(custom, "w") :angry:
Did I do something wrong?

Nicola.

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

More
29 Feb 2016 06:01 #70796 by cmorley
it overwrite the custom post gui file because it allows the users to select options that require changes in the file.
The custom file is not overwritten so custom code will not be destroyed, but unfortunately most code requires to be added after the GUI loads - so most code needs to be in the postgui file.

probably a better way (one that pncconf uses) is have the postgui code call a user hal file after all the machine written code.
This user file would not be overwritten.
Put another way have the postgui file call the custom hal file.

Even better would be to have stepconf smart enough to work around custom code but I think that is just do difficult to do well.

Chris M

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

More
29 Feb 2016 12:03 - 29 Feb 2016 17:48 #70804 by nicokid
Hi Chris,

it overwrite the custom post gui file because it allows the users to select options that require changes in the file.


Ok, you're right. So I think this row is useless:
shutil.copy( custom,os.path.join(base,"postgui_backup.hal") )
Originally maybe someone wanted to save the file and then he left there these lines.

probably a better way (one that pncconf uses) is have the postgui code call a user hal file after all the machine written code.
This user file would not be overwritten.
Put another way have the postgui file call the custom hal file.


The easiest way I think is tell of stepconf just append a second file at the end of custom_postgui.hal. Like:
cat user_custom_postgui.hal >> custom_postgui.hal.

Or I can update the ini file to include user_custom_postgui.hal.
1) Do you think I can add additional POSTGUI_HALFILE lines?:
POSTGUI_HALFILE = custom_postgui.hal
POSTGUI_HALFILE = user_custom_postgui.hal

Or can I put other files in same row?:
POSTGUI_HALFILE = custom_postgui.hal; user_custom_postgui.hal

2) Is there a way to call a hal file within another?:
load user_custom_postgui.hal

Even better would be to have stepconf smart enough to work around custom code but I think that is just do difficult to do well.


To differentiate the stepconf lines those custom lines, I might add comment lines like many programs, such as:
#### do not remove this line ####

What I do not know is whether there are precedence in command of hal files. In this case I would not know how to handle the lines.

Thanks, Nicola.
Last edit: 29 Feb 2016 17:48 by nicokid.

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

More
29 Feb 2016 19:43 #70830 by cmorley

Ok, you're right. So I think this row is useless:

shutil.copy( custom,os.path.join(base,"postgui_backup.hal") )
Originally maybe someone wanted to save the file and then he left there these lines.


This was me :) it is done so if the user modified the postgui file (like most will) then uses stepconf again
they have a chance to not lose their hard work.

The easiest way I think is tell of stepconf just append a second file at the end of custom_postgui.hal. Like:
cat user_custom_postgui.hal >> custom_postgui.hal.

I think this is risky order of stuff is important.
and if the user continues to edit and re use stepconf you will add it twice or need to add code to check for it...

Or I can update the ini file to include user_custom_postgui.hal.
1) Do you think I can add additional POSTGUI_HALFILE lines?:
POSTGUI_HALFILE = custom_postgui.hal
POSTGUI_HALFILE = user_custom_postgui.hal

Or can I put other files in same row?:
POSTGUI_HALFILE = custom_postgui.hal; user_custom_postgui.hal

Nope.

2) Is there a way to call a hal file within another?:
load user_custom_postgui.hal

Yes this is what i was referring to:
source [some_filename]

Even better would be to have stepconf smart enough to work around custom code but I think that is just do difficult to do well.


To differentiate the stepconf lines those custom lines, I might add comment lines like many programs, such as:
#### do not remove this line ####

What I do not know is whether there are precedence in command of hal files. In this case I would not know how to handle the lines.

Thanks, Nicola.


The problem with mixing user code and configuration made code in the same file is the complication that the user is
unpredictably dangerous :)
I'm sure it can be done.
then one needs to also look at how we offer custom snipits of code as examples.
They always mention the postgui file. better to leave this file for the user to play with alone.
In pncconf the INI calls a postgui 'jumpfile' that jump file has source commands in it.
One source command isused to call postgui.hal.

While slighly more complicated and unusual it separates config made code from user made code pretty well.

Chris M
The following user(s) said Thank You: nicokid

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

More
02 Mar 2016 00:09 #70878 by nicokid
Hi Chris,

thanks for your answer. :)
I looked in the documentation but could not find anything about "source" command :blink: But it seems to work. :)

About pncconf seems to have a much more complex management for hal files. I think I will copy and paste the pncconf code inside stepconf. :P

Pncconf 1.1 revamped by Chris Morley 2014
Why do not you treated in the same way the stepconf code? Do you hate stepconf? :lol:

Nicola.

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

More
02 Mar 2016 02:19 #70883 by cmorley
man halcmd does show the source command... it's a little used gem.

Stepconf was originally built and maintained by some one else.
His objectives were different then mine - I tried to honour the differences when I updated to newer glade files.

Pncconf was my baby so I was free to do as I pleased - right or wrong :)

I'm a little tired of both so am glad you are interested !
It's a very import part of linuxcnc.

Chris M

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

More
02 Mar 2016 11:25 #70897 by nicokid

man halcmd does show the source command... it's a little used gem.

I have not thought about using man pages, I usually find everything on the web. :)

Pncconf was my baby so I was free to do as I pleased - right or wrong :)

Well done!
Have you a Mesa card for your cnc machine?

I'm a little tired of both so am glad you are interested !

Uh? Please stay here!
I came here for two months and I have not done anything with my milling machine :S, I'm not good enough to do what you did.

Nicola.

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

More
03 Mar 2016 04:25 #70945 by cmorley
Yes I tend to use HTML docs but the man pages are usually are different so always good to look.

I have a large okuma lathe that uses mesa (never quite finished but works)
I have a sherline mill that uses mesa.

I am not a very good programmed but I am tenacious. I hack till it works. after so many years it just looks like I might know something :)
I enjoy the mental challenge.

Welcome to linuxcnc !
Chris M

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

More
03 Mar 2016 13:58 #70969 by nicokid
Ok, I copied your code inside stepconf with minor editing to simplify.
Now stepconf writes 3 files:
postgui_call_list.hal
pyvcp_options.hal
custom_postgui.hal
The last file is never overwritten. I hope I have not done too much confusion. :laugh:

I have a large okuma lathe that uses mesa (never quite finished but works)
I have a sherline mill that uses mesa.

I did not understand if the Mesa cards can directly control motors or if you need to buy another "power card".

Welcome to linuxcnc !

Thanks.
Nicola.

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

More
04 Mar 2016 02:44 #71007 by cmorley
mesa:
Typically people are talking about Mesa interface cards then control other servo/stepper amplifiers
But you can do either - Mesa sells amplifier cards too.

Chris M
The following user(s) said Thank You: nicokid

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

Time to create page: 0.374 seconds
Powered by Kunena Forum