Other Configuration Options
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 displayed is:
OAS_config = { debug: false, debug_refresh: false, interval: 1000, auto_start: true, token:'', serverURL:'http://localhost:58725' };
debug: bool
Display debug logging messages within a browser debug console. You can hook into this logging mechanism as well, by calling OAS.log(obj)
.
debug_refresh: bool
Display verbose log messages on each ajax callback to the Open Automation Software Server. This can be useful during development when you want to see the raw data being returned by the server.
interval: int
The number of milliseconds between each refresh callback to the server to get new data.
auto_start: bool
When set to true
refresh callbacks will begin immediately after authentication with the token or when OAS.authenticate()
is called successfully. If you would like to defer refreshes, set this to false
and call OAS.toggle_refresh(true)
to begin receiving new data.
token: string
The authentication token sent to the server on each refresh callback
serverURL: string
The location of the Open Automation Software Server
locale: string
An optional string indicating the default locale to use when formatting numeric values. The default is ‘us’ for United States. Other options are:
- Arab Emirates: “ae”
- Australia: “au”
- Austria: “at”
- Brazil: “br”
- Canada: “ca”
- China: “cn”
- Czech: “cz”
- Denmark: “dk”
- Egypt: “eg”
- France: “fr”
- Finland: “fi”
- Germany: “de”
- Greece: “gr”
- Great Britain: “gb”
- Hong Kong: “hk”
- India: “in”
- Israel: “il”
- Japan: “jp”
- Russia: “ru”
- South Korea: “kr”
- Spain: “es”
- Sweden: “se”
- Switzerland: “ch”
- Taiwan: “tw”
- Thailand: “th”
- Vietnam: “vn”
trend_bindings: object
See Web HMI Trend documentation for more details
alarm_bindings: object
See Web HMI Alarm documentation for more details
tag_prefix: string
An optional prefix for all server tags. This allows you to use a truncated tag name with inline configurations if the tags all share the same prefix. For example, if your tags are similar to:
MyCompany.Server3.DataValues.Tag1.Value MyCompany.Server3.DataValues.Tag2.Value MyCompany.Server3.DataValues.Tag3.Value
You can set the tag_prefix to “MyCompany.Server3.DataValues.” and simply use “Tag1.Value”, “Tag2.Value”, and “Tag3.Value” in the inline configurations.
If you want to include one or more tags that do not follow the same pattern or do not have the same prefix, you must add the ignore_prefix:true setting on that attribute’s config.
max_tags_per_msg: number
An optional value to be used in cases where a firewall or network configuration may limit HTTP request sizes. By default, each call to the server includes a request for data on every monitored server tag.
If the page has a large number of tags, this could result in a rejection by a firewall. Setting the max_tags_per_msg value will split calls to the server, resulting in multiple calls. This will reduce application performance since it will effectively multiply the number of executions by the number of calls needed to cover all server tags.
For example, if your page is monitoring 20 tags, and your max_tags_per_msg is set to 4, your page will be executing 5 calls to the server on each interval.
refresh_callback: function(data)
An optional callback that will be fired on every successful refresh call to the server for data. The data passed into the callback will represent all monitored server tags for the current configuration. Note: If the OAS server cannot be reached, the refresh_callback function will not be triggered.
In some cases, you may prefer to read and write tag values programmatically and do not want or need to add oas-tag-xxx attributes to elements inline. This is particularly useful if you need to perform some additional logic or formatting of data within your custom scripts.
If this is the case, then you will need to enumerate the tags to “watch” in a string array. This informs the Web HMI library that it should poll the server for these tag values, making them available to use in custom scripts. This is especially useful when used in conjunction with the refresh_callback, as you’ll be able to programmatically update elements as soon as data is refreshed from the server.
OAS_config = { token:'', serverURL:'http://localhost:58725', watch_tags: ["Pump.Value", "Random.Value"], refresh_callback: update_screen }; // called on every refresh of data function update_screen(data) { var pump = OAS.get_value("Pump.Value"); var random = OAS.get_value("Random.Value"); // your code here }