Trend Control Description and Options
After defining the Trend Control bindings, or Trend Bindings, the OAS Web HMI library will continually poll the server for realtime data, or Historical Data, depending on the context.
After each polling cycle, a callback function will be executed, allowing you to examine the data, use it in your client side code, or simply apply it to a charting library like Flot. It is your responsibility to implement the callback function and reference it in the Trend Bindings.
The Javascript OAS_config
variable contains several options for determining the behavior of the Script Library. This variable is a standard JSON construct. The full definition with defaults desplayed is:
OAS_config = { debug: false, debug_refresh: false, interval: 1000, auto_start: true, token:'', serverURL:'http://localhost:58725' };
To add Trend Bindings to this configuration, you will add the following node to your OAS_config construct. The trend_bindings node is an array of Trend Binding objects, each representing data to be displayed in a single chart or to be used together.
trend_bindings: [ { chartid: <string>, samplerate: <integer>, timeframe: <integer>, tags:[ <array of Tag Definitions - see below> ], retain: <optional:integer>, callback: <function> } ]
- chartid: string
This string is available within the callback
- samplerate: integer
The server-side sample rate for extracting trend data
- timeframe: int
The server-side timeframe
- tags: array
An array of Tag Definitions. Each tag definition represents a feed of data values corresponding to an OAS Server Tag. You can either provide an array of strings containing Tag names (e.g. ‘Ramp.Value’) or you can provide an array of Tag Definition objects with the tag name and other options.
{ tag: "Tag.Name", label: <string: label that can be used on a chart>, color: <string: html color in hex format e.g. '#FFCC00'>, historystatprocessing: <string: avg|min|max|lastsample> historytag: <string: MyDataLoggingGroup.Field> ... other custom nodes ... }
Historystatprocessing and historytag are optional. Historytag is used to specify the data logging group and field to return history data from. Commonly used when the same tag is defined in multiple logging groups.
- historystatprocessing: string
This allows you to explicitly calculate the value of the historical data point. If omitted, “avg” is assumed which will average the value when it spans two entries in the data log. - historytag: string
The history tag allow you to specify where the historical data for that tag can be found. By default, OAS will choose the data logging group based on the sample rate of the trend control. However, you can point to the specific data logging group to use if there is more than one defined on the server logging the tag values. The formats to follow are:- <data logging group>. <field name>
The field name is the actual database column that stores data for the tag in question. For example if you have a data logging group called “DemoLog” and the db field is “Sine_Value” the historytag should be set to “DemoLog.Sine_Value”. - \\<network node>\<data logging group>.<field name>
Additionally if your data logging is being performed by an other OAS server, you can prepend the historytag with “\\<networknode\”. For example, if the above tag data is being logged by another OAS server called “myServer” on the network, the historytag should be set to “\\myServer\DemoLog.Sine_Value”. You can use an IP address or registered domain name for network node as long as it maps to the OAS server performing the data logging.
- <data logging group>. <field name>
An array of Tag Definitions. Each tag definition represents a feed of data values corresponding to an OAS Server Tag. You can either provide an array of strings containing Tag names (e.g. ‘Ramp.Value’) or you can provide an array of Tag Definition objects with the tag name and other options.
- retain: integer
The number of values to retain between callbacks. For example, if you are displaying real-time data, you will want to set this to the maximum number of points on the x-axis so that any chart using the data will effectively scroll. If you do not set a retain value, all values will be retained, gradually using up more memory over time, and forcing you to manually extract portions for display.
- callback: function
A function pointer with that receives a single argument. This function must be globally accessible and will be called on each server refresh of data. The single argument will represent the raw data from the server with metadata about the data set. More information below.
- returnalldatawithtimes: bool
An optional flag that determines whether the server will return timestamps for each individual data point. If this setting is not included or is set to false, only the start and end timestamps are included in along with the data points as each is assumed to be averaged between the start and end. Setting this to true will inlude an additional array of timestamps on the server response labeled timesforreturnalldata.