Tips and Tricks
We’ve all used Source, but we’re all specialists – we probably use about 80% of Source, but a different 80%. There are things in that 20% that can help us. Here's some tips and tricks for writing tools and plugins to work with Source.
What: What you can do
How: Quick instructions on how to do it
Who: Who to see for more information
Where: What parts of Source this touches.
What | How | Who | Where |
---|---|---|---|
Control Model behaviour from another program | Set Reload on Run, then overwrite the file from your program | Parameter Input Sets | |
Get around the need for a UI for a plugin | Extend Input Sets with a plugin, then set value through input sets. | Parameter Input Sets, Plugins | |
Push time series metadata to Source (like units) | Use res.csv as a data source format - supports metadata, identifiers and custom missing format | Data Sources | |
REPL edit plugin code in Visual Studio | Put a reference to the plugin project in Source.sln, then set a breakpoint in the code. You can use the immediate window and live edit code and xaml! Don't commit the solution! | Plugins | |
Free confidential version control | You can set up a file based Hg or SVN repo on a network drive | ||
Set values in a plugin without worrying about Source changing | Use the API, which seldom changes. Better yet, use functions which eWater does backwards compatibility for! | Plugins | |
Run unit tests when Source is built | eWater will often run your unit tests for you (if they're fast enough!) | Plugins | |
Build large complex input sets without code | Create an Excel document with all your variables & what you want to change. Use Functions to assemble each scenario input set line in rows (this means values can reference each other, for example) Make a cell for each row that uses Concatenate functions to turn the row into a string. Then you can copy and paste the cells straight into the scenario input sets editor. | Parameter Input Sets | |
Write a plugin that can handle changes to the active project | ProjectManager.Instance allows subscribing to load, save and close events | Plugins | |