The "Set Context" option allows you to define parameters and values that can be used in your Xcos blocks.
For example instead of entering actual P,I & D values for a PID block you could enter variable names like this...
And then in the set context configuration you can specify their values.
Why use the Set Context approach?
There are several benefits;
- You can see all your settings in one place
- You can have sets of cases that you have saved and you just need to paste them into the context dialog and run
- You can use a parameter name more than once so it helps maintain consistency when you make a change
- Parameter values can be based on previous parameter values like this simplifying changes
How to use
Annoyingly you have to have the parameter name specified first in the context configuration before you can use it in an Xcos block so firstly call up the "Set Context" option via the menu bar like this...
Or you can right-click anywhere on the Xcos diagram background and select the "Set Context" option.
Then enter your parameters and values as shown previously.
You can now use these parameter names in your Xcos blocks.
You can add comments too to improve understanding. Just prefix each line with "//" which is the SciCos programming comment mark-up
Be careful because the following is accepted (i.e. without the comment mark-up) but it does not work. I suspect that it generates an error which is automatically handled by an error trap but which results in the values not being set correctly.