The Scripted Rule editor ("Figure: Scripted Rule Editor - "Default" Template") has the same scripting interface as the State Variable Editor including the API tree and the Text Editor:

Figure: Scripted Rule Editor - "Default" Template


  • Name & Description—Like any other rule, you can enter a Description for the rule in the Name & Description section.
  • API Tree—A tree widget is used to provide access to the ResSim Application Programming Interface (API) available to the script. The tree is divided into two major branches:
    The TimeSeries Branch—Each node in this branch gives you access to the TimeSeries objects for the various elements in your model.
    The APIs Branch—Each node in this branch provides you with easy access to the method calls for accessing and manipulating the java objects in your model that you are most likely to need in your scripts.
    By double-clicking on a node in the tree, the code needed to retrieve an element's time series or to access a method for manipulating a particular object type can be placed in your script at the current location of your cursor in the editor. This action can also be performed by selecting a node in the API tree and clicking the Insert in Script button.
    By hovering your cursor over a node in the tree, a tooltip will appear with the Javadoc entry for the method call that is represented by that node. The Javadocs are class-level documentation of the public classes and their methods that you can use in your scripts.
    Most method calls (or functions) that you may need require arguments (or parameters) as input. If the method you select requires arguments, the text of that method call that is added to your script will include the arguments between the parentheses ().
    Method arguments given as literals (i.e., actual numbers, or strings enclosed by " ") are already complete and require no additional input. The text inserted from items under the Time Series branch of the API tree typically fall into this category; for these calls, you do not need to modify the argument list.
    Method arguments given as java classes are placeholders for variables that you must supply in the script ("Figure: Scripted Rule Editor - API Tree - Java Object Classes and Methods"). The method call text inserted from nodes in the APIs branch usually requires that you replace the placeholders in the argument list with appropriate variables/objects that you created within your script.

    Figure: Scripted Rule Editor - API Tree - Java Object Classes and Methods


    If a method call has: RunTimeStep rts as an argument, you should almost always use the variable: currentRuntimestep for that argument. You will learn more about currentRuntimestep in the next section.

    The list of The ResSim classes and their methods that are included in the APIs branch of the API Tree is not complete nor all-inclusive. If you are looking for a class or method you think you need from ResSim and it isn't in the list, click on a branch or node in the APIs section and press F1. The Javadoc Viewer ("Figure: The Javadoc Viewer") will open showing the Javadoc pertinent to the node or branch you selected. From there, you can search through the Javadocs to find the method you need.

    Figure: The Javadoc Viewer


  • API Preview Bar: When you select a node in the API tree, the text that would be generated by that node will appear in the Preview Bar.

    • Text Editor—This pane of the State variable Editor uses a text editor that interprets the text of your script as Jython source code and colorizes it according to the type of statement or key word it recognizes. This editor supports the standard Windows® shortcut-keys for select all (Ctrl+A), cut (Ctrl+X), copy (Ctrl+C), and paste (Ctrl+V), and undo (Ctrl+Z) functions. These functions can also be accessed from the Edit menu or by right-clicking in the Text Editor to open a context menu. The find (Ctrl+F) function is also supported but can only be access from the shortcut keys.