Saving parameters after shut down

More
17 May 2013 21:36 - 31 May 2013 22:08 #34239 by ArcEye
Hi

Now completed my full paramsaver component

This component will create up to 32 IN pins and 32 OUT pins of each, of types float, s32 and bit.

The OUT pins can be overwritten by reading from a file, enabling components or widgets attached to those pins
to be initialised to known or saved values.

The IN pins can be connected to any suitable component pin or widget pin
The values received at the IN pins can be saved to file making settings persistent between shutdowns.

This comes into its own if you use my amended pyvcp_widgets
www.linuxcnc.org/index.php/english/forum...nbox-in-hal?start=27

Then you can link say the hal-pin of a spinbox to paramsaver.invalueF.00 and the new param-pin of the spinbox to paramsaver.outvalueF.00
Set paramsaver.writetrigger to true and create a file
Set paramsaver.readtrigger to true and the value will be inserted back into the spinbox.

Commandline switches:-

loadusr -W paramsaver f=NN s=NN b=NN filename=xxxxxxx onstart=0/1 onexit=0/1

f=NN number of float pins to create, one of IN and OUT for each

s=NN number of s32 pins to create, one of IN and OUT for each

b=NN number of bit pins to create, one of IN and OUT for each

filename=xxxxxx filename to save under
If none given will default to param.sav
Only input filename, not extension or path
Will be created as /home/username/linuxcnc/xxxxxxxx.sav

onstart=0/1 If set to 1, will load file at startup to populate the OUT pins (defaults to 0)

onexit=0/1 If set to 1 will write to file at shutdown (defaults to 0)



The zip contains a compiled component for 10.04, the C source code and a man page

Compile the source with comp --install --userspace paramsaver.c

Usual caveats - let me know any bugs - I have tested a fair amount and seems OK.


regards

PS
It could do with making more efficient regards memory allocation, for the reasons Andy was outlining regards not being able easily to have dynamic arrays etc in a file compiled by comp.
Works perfectly well as is, just offends the OCD side of my nature. Next job on the jotter.

See later posts for updated zip
Last edit: 31 May 2013 22:08 by ArcEye.
The following user(s) said Thank You: mariusl

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

More
17 May 2013 22:37 #34248 by mariusl
ArcEye
Thanks a lot for all your input here and into our lives. This is one of the most welcome components for a long time. I am presenting a CNC/MACH course tomorrow but I will try and test it by the evening.

Thanks again man.

Regards
Marius


www.bluearccnc.com

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

More
17 May 2013 23:07 #34252 by mariusl
ArcEye,
I tested it on my simulator and it work great. I will integrate it with the machine as soon as I have my troubles sorted with the plasma THC.

Regards
Marius


www.bluearccnc.com

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

More
17 May 2013 23:14 #34255 by ArcEye

ArcEye,
I tested it on my simulator and it work great. I will integrate it with the machine as soon as I have my troubles sorted with the plasma THC.


Thanks for the feedback

regards

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

More
18 May 2013 20:41 - 31 May 2013 22:12 #34331 by ArcEye

It could do with making more efficient regards memory allocation, for the reasons Andy was outlining regards not being able easily to have dynamic arrays etc in a file compiled by comp.
Works perfectly well as is, just offends the OCD side of my nature. Next job on the jotter.


Found a way to do it, quite similar to your solution Andy.

Made a struct xstruct, which contained one of each type of pin.
Then declared the struct __comp_state with the 2 fixed bit pins and a dynamic array of pointers to xstruct.

Thereafter just had to allocate the right amount of memory for the struct __comp_state and hal_malloc each xstruct as required and populate the array.

I shall definitely do it this way again, gives powerful direct indexing but does not break comp compatibility for compiling

EDIT

Now no reason to have 32 pin limit, limit raised to 1000 (0-999) and a bit of code optimisation and clean up done

IF YOU HAVE EXISTING CODE USING THIS COMPONENT YOU WILL NEED TO CHANGE PIN NUMBERS TO 3 DIGIT FORMAT
eg paramsaver.outvalueF-00 becomes paramsaver.outvalueF-000

New .zip attached

regards



File Attachment:

File Name: paramsaver6.zip
File Size:11 KB
Attachments:
Last edit: 31 May 2013 22:12 by ArcEye.

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

More
22 May 2013 21:36 #34538 by ArcEye
Now posted on Contributed Components on the Wiki

wiki.linuxcnc.org/cgi-bin/wiki.pl?Contri...ents#Parameter_Saver

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

More
30 May 2013 20:58 #34971 by tld70
Hello ArcEye

I try to use your paramsaver.
How can I write my Spindle tool to this file?

net Spindelwerkzeug => paramsaver.outvalueF.01
this tells the pin does not exists

net wsw_testen paramsaver.writetrigger <= pyvcp.Spindelwerkzeug_setzen
this will work and write the fils ( with 0 bytes )

Do you have a exemple?

Regards
Thomas

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

More
30 May 2013 21:27 #34974 by ArcEye
Hi again Thomas

net Spindelwerkzeug => paramsaver.outvalueF.01
this tells the pin does not exists


The pin, if created, is called paramsaver.outvalueF-01 (dash not dot)

Also you are connecting to a signal only, which is OK as long as something else is connected to it to supply data.

In the zip is paramsaver.9 which is a compressed man file
copy to /usr/share/man/man9
and you will be able to get up the man page just using man paramsaver

If in doubt, you can always run the component through halcmd, to see what is created and what the syntax is
eg
root@INTEL-QUAD:/prog/EMC/Userspace_modules/paramsaver# halrun
halcmd: loadusr paramsaver f=2 s=2 b=2
halcmd: show pin
Component Pins:
Owner   Type  Dir         Value  Name
5  bit   IN          FALSE  paramsaver.invalueB-00
5  bit   IN          FALSE  paramsaver.invalueB-01
5  float IN              0  paramsaver.invalueF-00
5  float IN              0  paramsaver.invalueF-01
5  s32   IN              0  paramsaver.invalueS-00
5  s32   IN              0  paramsaver.invalueS-01
5  bit   OUT         FALSE  paramsaver.outvalueB-00
5  bit   OUT         FALSE  paramsaver.outvalueB-01
5  float OUT             0  paramsaver.outvalueF-00
5 float OUT             0  paramsaver.outvalueF-01
5  s32   OUT             0  paramsaver.outvalueS-00
5  s32   OUT             0  paramsaver.outvalueS-01
5  bit   IN          FALSE  paramsaver.readtrigger
5  bit   IN          FALSE  paramsaver.writetrigger
halcmd:  exit

regards
The following user(s) said Thank You: tld70

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

More
30 May 2013 21:52 #34976 by tld70
Now I got you,

It works perfect

Thank you


Thomas

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

More
31 May 2013 03:50 #34995 by mariusl
Hi ArcEye
Two things. The wiki contains incorrect descriptions of the pins - like this F.00 instead of F-00
Then you can link say the hal-pin of a spinbox to paramsaver.invalueF.00 and the new param-pin of the spinbox to paramsaver.outvalueF.00 Set paramsaver.writetrigger to true and create a file Set paramsaver.readtrigger to true and the value will be inserted back into the spinbox.

Secondly, I have a problem getting a spinbox to value to the file value. These are the two lines that I use to connect the lot.
#setp pyvcp.spinbox.1.param_pin [THC]VOLT_SETTING ---------------- this one works

net init_volts  	pyvcp.spinbox.1.param_pin paramsaver.outvalueF-01 ------------- this remains 0
net involt		pyvcp.set-volts => paramsaver.invalueF-01 -------------- this is spinbox 1

Regards
Marius


www.bluearccnc.com

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

Time to create page: 0.272 seconds
Powered by Kunena Forum