You will need to add the following code snippet into you Constructor Macro M99998.txt for your profile.
- Code: Select all
// LOADS #vars (PARAMETERS) #500 to #999 from profile at machine startup.
// save code snippet to Constructor Macro M99998.txt
for (var x = 500; x < 1000; x++)
{
exec.Setvar(Convert.ToDouble(exec.Readkey("PARAMETERS", "#" + x + "", "0")), x );
}
You will need to add the following code snippet into you Destructor (Deconstructor???) Macro M99999.txt for your profile.
- Code: Select all
// SAVES #vars (PARAMETERS) #500 to #999 to profile at machine shutdown.
// save code snippet to Destructor (Deconstructor??) Macro M99999.txt
for (var x = 500; x < 1000; x++)
{
exec.Writekey("PARAMETERS", "#" + x + "", "" + exec.Getvar(x) + "");
}
Note..... If you have a power loss or your force a shutdown of UCCNC then the destructor macro M99999.txt will not run so the values for vars #500 to #900 will not be saved.
If you want more persistent saving you could run a macroloop at say a 1 minute interval to save these values to the profile or you could run a longer time period between saves as this saving of ~500 vars will add some overhead ..... so you probably don't want to do it too often..... {20Hz is probably a bit pointless given how much you may use / change these #vars......
Option A) use the Destructor Macro M99999.txt
Option B) if you want the saving to be more frequent.... use a macroloop
Macroloop code as follows:
- Code: Select all
// MACROLOOP to periodically save VARIABLES (PARAMETERS) #500 to #900 for UCCNC to Profile for restore at restart (M99998.txt)
// 14/01/2019
//Robertspark
while(loop)
{
// SAVES #vars (PARAMETERS) #500 to #999 to profile at machine shutdown.
// save code snippet to Destructor (Deconstructor??) Macro M99999.txt
for (var x = 500; x < 1000; x++)
{
exec.Writekey("PARAMETERS", "#" + x + "", "" + exec.Getvar(x) + "");
}
Thread.Sleep(60000); // 1 minute save loop cycle {could increase to 5 mins (300000) or 10 mins (600000)}
}
happy coding ....