The Timer Node
The Timer node () adds a timer that controls how often a command sequence is triggered. Each time a delay has elapsed, a command sequence that you define is run. You can use a timer that receives input from some external source (for example, a hardware sensor, an external database, or a web service) and then update the application’s user interface based on the received data.
Enter the name of the event object in the Name field.
In the Delay field, enter the delay time (in seconds) for the timer to delay running the command. The default value for the delay is 1 second, and the value controls how often the event is triggered.
By default, the timer is enabled. Clear the Enabled checkbox that to disable triggering of timer events if desired.
The Settings window contains the following section, where you define a command sequence that controls what should happen when the timer event is triggered.
Choose Commands to Run
In this section, you choose the commands to run for the timer. The section contains a tree with a filtered view of the trees in the Application Builder and Model Builder windows. The nodes either support a command or have children that do. When you select a node that supports one or more commands, the corresponding command toolbar buttons become enabled in the toolbar below the tree. You can also right-click a node to get a list of available commands for that particular node. Once you click a command with a node selected (or press Enter to add a command with its default command such as Run, Plot, or Set Value), the command and node appear in the last row of the table below the tree. This table contains all nodes that run, and you can delete and move commands using the toolbar below the table.
In the Model branch, all nodes that represent some sort of data value, such as a parameter under the Parameters node, support the Set Value command. When adding a Set Value command to the table, the third column, Arguments, becomes enabled. In this column, you type the value to set. For data that represents arrays, use braces and commas to enter the array elements. For example, enter {1,2,3} to set a three-element array with the values 1, 2, and 3. See The Array 1D String Node for more details on how to enter arrays and matrices. For nodes that represent a file import, such as a Filename node under an Interpolation function node, an Import File command is available.
The tree includes a number of branches from the application tree in addition to the Model branch:
The Forms branch: Form nodes support the commands Show, which sets the form as the main form of the application (that is, the content of the application window will be this form), and Show as Dialog, which brings up the form as a separate dialog window.
The GUI Commands branch: The commands under this branch are grouped in three subcategories:
-
File Commands: These include Save Application (to save the application under its current name); Save Application As (to open a file browser dialog allowing the user to save the application in a suitable location); Save Application Copy As; Save Application on Server; Save Application on Server As; Open File (to open an application file resource specified using a valid URI path in the Arguments column); Save File As (similarly, to allow the user to save the file under a name specified in the Arguments column); and Exit Application (to close the running application). If the application is run on COMSOL Server, the Save Application on Server and Save Application on Server As commands save the current state as a new application in the COMSOL Server Application Library.
-
Graphics Commands: Here you find the commands Zoom Extents, Zoom to Selection, Reset Current View, Scene Light, Environment Reflections, Skybox, Transparency, Orthographic Projection, Print, Select All, Clear Selection, Show Selection Colors, and Show Material Color and Texture. For all graphics commands, add the name of the Graphics object that you want to apply the command to as an argument.
-
Model Commands: Here you find the commands Clear All Solutions and Clear All Meshes.
Double-click or right-click any of the nodes above to add a Run command.
The Declarations branch: This branch contains any variable declarations you have added under the Application Builder window’s Declarations branch grouped by type. Like parameters, they support the Set Value command.
The Methods branch: Method nodes support the Run command.
The Libraries branch: Under Sounds, you can choose between sound files to play in a command sequence.
When you click one of the commands underneath the tree, the command appears under Command in the list below. There is also a Symbol column and an Arguments column, where you can enter any applicable arguments that the command uses. A tooltip appears, indicating what type of argument the command expects. For example, for the downloadtoclient command, the argument is both a filename and its path, such as embedded:///myfile.txt, and there is a separate dialog that helps you define such an argument. See File Schemes and File Handling for more information.
Click the Convert to Method toolbar button () and choose Convert to Method or Convert to Local Method to convert the entire list of commands in the table to a global or local method that contains the equivalent code. After this operation, the list of commands only contains a single Run operation on the created method. When you select a method under Command, or there is exactly one method in the list, you can go to the editor window for that method by clicking the Go to Method button (). For information about the Edit Argument button (), see Editing Initial Values and Arguments in Declarations and Command Sequences. Use the Move Up (), Move Down (), and Delete () toolbar buttons to organize and remove commands from the list (and also remove the local method, if deleted).
You can extend the list of available nodes by clicking the Switch to Model Builder and Activate Data Access button () in the Choose Commands to Run section header, which takes you automatically to the Model Builder, and then selecting a node in the Model Builder branch that you want to access. With this button active, the Settings window of the selected node displays a Select Data Source checkbox (a green square) next to the settings that you can include. Select the checkbox to include that data as an available source node for timers.