Simple Function Example
TimeInterval | BrowsePath | ValueSource | DataType |
---|
0 | TagA | sine(0,100,10,true) | Double |
The table above shows us function usage with parameters. Because the example is using default values, it is functionally equivalent to the following:
TimeInteval | BrowsePath | ValueSource | DataType |
---|
0 | TagA | sine() | Double |
Running this program should yield the following results (assuming repeat is enabled):
- A tag at root named “TagA” will be created.
- Since only a single Time Interval was defined, the program ends quickly. The delta time between the start of the program and the end should be around one Base Rate interval.
- The simulator will use a internal clock to ensure that the value reported is representative of the actual period for the function requested and if history is enabled, a full wave would be graphed.
Advanced Program Example
TimeInterval | BrowsePath | ValueSource | DataType |
---|
0 | TagA | sine() | Double |
0 | myFolder/TagB | 0 | Int32 |
3 | myFolder/TagB | 4 | Int32 |
4 | another_folder/TagC | 100 | Int32 |
20 | TagA | ramp() | Double |
30 | myFolder/TagB | 55 | Int32 |
The program above should yield the following results:
- TagA is initialized with the Sine function.
- TagB (which is located under myFolder in the simulator’s structure) is initialized with a value of 0.
- TagC isn’t defined at the start, but that doesn’t matter; the program creates a TagC initially because it will exist in the device. If this is the first time the program ran, then TagC started with a value of 0. If it is the second time through, it maintains the value at the end of the program until it reaches an interval where something changes.
- Time Interval 1. The program doesn’t state that any changes should be made, so we’re done evaluating this Time Interval.
- Time Interval 2. Again, nothing to do here, so we wait another Base Rate duration.
- Time Interval 3, the value on TagB to 4.
- Time Interval 4. The value of TagC changes to 100. If this program has executed at least once before, then TagC could already have a value of 100, since this is the only entry in the program that changes the value on Tag C. However, it is possible that the user (or something else, such as a binding or script) wrote another value to this tag. At this point, our program is setting the value back to 100
- Time Interval 20, TagA switches to the Ramp function. This whole time it has been using the Sine function to generate some moving numbers, but now we’re telling it to use the Ramp function, which change the value (starting with the minimum value for the function) and uses a different method to determine its value.
- Time Interval 30. The value of TagB changes to 55.
- We’re now at the end of the program. If Repeat was enabled, we’ll move back to Time Interval 0 and start the whole process over again. If not, then the program ends for all tags.