We are excited to announce a change to Ignition’s built-in simulator devices. In the latest nightly build a new device is available named Programmable Device Simulator that provides the ability to create your own simulator program with outputs you define.
Our thought when designing the new simulator functionality was users should be able to create tags that can be used in their own development process. Users need the flexibility to simulate devices with a tag structure they are building a project for.
We have included a number of built in functions that will result in tag outputs that hopefully meet your development needs. We have also provided the ability to set specific values at different points of the program should the functions not provide exactly what you need.
This functionality does replace the existing simulators that were included with Ignition. We have added the ability to quickly create the same simulators with this new functionality. If you happen to delete your existing simulator, adding a new Programmable Device Simulator and loading the same program will allow addresses within the device to map existing addresses.
The following instructions will setup the Dairy Simulator within the new Programmable Device Simulator:
- In your Gateway, navigate to Config > Device Connections
- Click Create new Device…
- Select Programmable Device Simulator
- Give the device a name of your choosing, note the properties that are available to modify
- Click button to save the device
- Open the More > edit device screen
- From the Load Program dropdown, select Dairy Simulator
- Click Load Simulator Program button
- Click Save Program button
Feel free to adjust the program before (or after) saving if you want to change some of the functionality.
Instruction File: A CSV with four columns:
- Time Interval: Represents a “step” or point in time for the program. A program will start at interval 0, and set the Value Source on the tag. The program will wait for a number of milliseconds (determined by the Base Rate, defined below) before moving to the new Time Interval.
- Browse Path: The full path to the tag you want to create in the simulator. Forward slashes are used to specify folders, as well as act as a delimiter for additional folders in the path.
- Value Source: Determines how the value for the node at the Browse Path is generated. Either a static value or a function will be used to generate the value.
Data Type: The Data Type for this node. Valid types are:
- uint64 (Not all values fully supported by Ignition at this time)
Program: A runnable series of path configurations. The program can be imported via an Instruction File or manually entered/edited via the GUI. The program “runs” through the rows in the Instruction File. Each Program Device Simulator contains only 1 program.
Meta Tags: Each Programmable Device Simulator will have Meta Tags that allow users to interact with the program from the Designer/Session/Client. All tags will be listed under the parent folder [Controls] within the device. Altered Meta Tag values do not persist after restart. Meta tags provided:
- Base Rate: The number of milliseconds determining how quickly the program should move between each Time Interval. The initial duration of the Base Rate is defined in the Program Device Simulator settings should you need this value to persist after restarts.
- Pause: Setting this tag to True will stop the program at its current Time Interval. Setting it back to False will cause the program to resume from that point.
- Program Counter: A count that tracks the Time Interval of the currently running program. This counter continues to increment for the duration of the program and resets when a program repeats.
- Repeat: If True, the program will repeat indefinitely, meaning that once the last defined Time Interval has been reached, the program will start over again at Time Interval 0.
- Reset: If True, the program is immediately reset to Time Interval 0 and the value will immediately change back to False.
Function: Users are allowed to define a “function” for the value source. This is not a Python or Expression function. Rather, the value in the cell is a string that looks like a function definition; eg., foo(x,x,x). The driver will attempt to parse the string, and then derive a value based on the function. Valid functions are:
Function Parameters: Values that are passed into a function. The following parameters may be available in functions:
Parameter Definition Default Value min Minimum value for the function 0 max Maximum value for the function 100 period Represents a period of time as a number of Time Intervals. The default value of 10 represents “10 Time Intervals”. 10 delta Allows users to determine the range of the number being added to a tag. A delta of 10 means “I’ll randomly pick a number between -10 and 10”. 10 qualityCode Allows users to set the quality on a tag (assuming the function used contains a quality code parameter). Valid values are: Good, Bad, Uncertain Good repeat Does the function repeat for each time slice of the program, or does it report a single value when the instruction is run.The default value of true will ensure that a function will continue to run as long as the program itself is running. A value of false will only update a value when it reaches the specified Time Interval in the program true
|sine(min, max, period, repeat)||Sine wave|
|cosine(min, max, period, repeat)||Cosine wave|
|square(min, max, period, repeat)||Square wave|
|triangle(min, max, period, repeat)||Triangle wave|
|ramp(min, max, period, repeat)||Ramping value. Similar to the ramp values in the Generic Simulator|
|realistic(setPoint, proportion, integral, derivative, repeat)||PID-driven realistic number generator|
|random(min, max, repeat)||Random number, falling between the min and max values|
|list(val1, val2, etc…, repeat)||Accepts any number of parameters. While the program is running and on a step with this function, the function will walk through each value in this list. If list is boolean, the repeat value is a required parameter|
|qv(value, statusCode)||Sets a value and quality code. Allows users to simulate a value with bad quality. Valid values for statusCode are “good”, “bad”, and “uncertain”.|
|readonly(value)||Sets a static value that is read only.|
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” should 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.
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.
Note: The above is how the simulator should behave. We have a couple open issues where the simulator isn’t behaving correctly during a repeating program.