Note: This is documentation for version 5.4 of Source. For a different version of Source, select the relevant space by using the Spaces menu in the toolbar above

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.


WhatHowWhoWhere
Control Model behaviour from another programSet Reload on Run, then overwrite the file from your programParameter Input Sets
Get around the need for a UI for a pluginExtend 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 formatData Sources
REPL edit plugin code in Visual StudioPut 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 controlYou 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 builteWater 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 projectProjectManager.Instance allows subscribing to load, save and close eventsPlugins