Introduction Reference Server Registration Creating and Releasing Methods
| Introduction
R2DToo version 1.7 introduces a new feature, automation, which allows the end user to control R2DToo via another program or script. This functionality replaces the Experiment form while offering a much richer interface.
Automation is intended to allow the researcher to run R2DToo over long periods with no user intervention. A possible application would be spanning the model's parameter space via repeated runs with incremented parameters between each run.
R2DToo provides automation through MS-Windows' OLE/COM functionality. This exposes certain methods (or functions) to client applications, to automate steps like pressing the Run Simulation button. Using OLE/COM allows the user to automate R2DToo with any language they prefer. In particular, if the Windows Scripting Host is installed, then simple VBScripts or JScripts can drive R2DToo (or PerlScripts, Python, etc.). The following pages will demonstrate driving R2DToo using VBScript (a scripting language based on Visual Basic).

Reference
In the following sections the terms server and client may be bandied about. For your information server refers to R2DToo, the program itself and the client is the application or script that is interfacing with R2DToo to control it. Remember it this way: the client asks the server to do stuff.
Server Registration
To use the automation features you must first register R2DToo as an automation server. This was done automatically if you checked the "Register as automation server (for scripting)" option when R2DToo was installed. Otherwise, you need to run R2DToo with the command-line option /regserver.
To unregister the server (to uninstall for example) run it with the option /unregserver.

Creating and Releasing
Once R2DToo has been registered as an automation server, it can be started by creating a new automation object of type R2DToo.FrontEnd.
VBScript Example
' load
Dim R2DToo
Set R2DToo = Wscript.CreateObject("R2DToo.FrontEnd")
...
|
The automation object will fail to be created if it cannot locate a valid model.dll file. To run R2DToo with a particular model that model.dll must be in the current working directory when R2DToo is loaded. With Windows Scripting Host version 5.6 or higher this is achieved with the CurrentDirectory method as demonstrated in the following example.
VBScript Example
Dim R2DToo
Dim WshShell
Set WshShell = WScript.CreateObject("WScript.Shell")
' Set WshShell.CurrentDirectory to folder containing model.dll to load that model into R2DToo.
' Requires Windows Scripting Host 5.6 or newer (http://msdn.microsoft.com/scripting/).
WshShell.CurrentDirectory = "C:\Program Files\R2DToo\Models\ConwaysLife"
' load
CreateObject("R2DToo.FrontEnd")
...
|
Releasing the R2DToo.FrontEnd object automatically closes R2DToo.
VBScript Example
...
' unload
Set R2DToo = nothing
|

Methods
The following methods (functions) are available to the automation client. Currently the list consists only of methods necessary for running experiments and recording data. Few methods to manipulate the user interface are currently available. This is because the end user can still interact with R2DToo while it is automated, adjusting the interface to their preference.
|