I have a project connected to hardware outputs. If I close TD while the device is active, or, say, I save the project and then TD crashes, then on restart, the values retain what they were. However, I would prefer the device to always be OFF on startup.
This is a specific case of the general question: How should I guarantee that certain parameters have specific values when I open the project? It turns out that even Count CHOPs retain their value on save-and-restart, so that’s not an option.
Here is a quite dated discussion of the topic, and I wonder if the best practise has evolved at all (perhaps even simplified) since then Saving default values
The problem is that the state of the project is part of the toe file. Which means that the moment you reload the project the state of the project will also be reproduced.
I had a lengthly talk about this at the TD Event in Berlin last year.
Several solutions:
- Rebuild the project on startup. This is of course not always possible but I like to setup my projects in a way where it handles everything more like a standalone application and loads a “subproject” on startup. Resetting everything.
- Have everything statebased as external components. This does not always work but saving parts of your network as an external component excludes this components/OPs from the state saved in the .toe file. Your .tox files then still keep it then thoufh.
- Write a script to reset the state on startup to your definition. This can be grnaular like markus example in the linked thread or more generic using something like the following:
def onStart():
for resetOperator in root.findChildren( tags = ["reset_state"] ):
for customParameter in resetOperator.customPars:
customParameter.val = customParameter.default
return
- ff. This will search all operator with the given tag and reset their customParameters to the default value. You can continue here with adding additional custom tags for example for resetPulse triggering, recalling preset etc…
1 Like