Open Automation Software
Moving Data From Anywhere to Anywhere

Utility Functions

The following Javascript functions are provided as helper methods for formatting and extracting data from each callback or elsewhere within an application referencing the OAS Web HMI libraries.

Use OPC.init() after making any changes to OPC_config. For example, when altering any trend_binding features, you can then call OPC.init() to force the OPC_config to reload with the new settings.

  • data: object
    This utility converts the data returned in the trend callback into data series objects directly usable by the Flot charting library. This should only be executed within the context of a trend callback and only when using the Flot library.

  • value: string
    The original string to be padded. This can also be anything that can be converted to a string, like a numeric.
  • pad: string
    The padding string, typically a single character (e.g. ‘0’ when padding numbers)
  • len: number
    The desired total length of the output string. For example, if you want to convert the number 9 to ‘009’ you would call OPC.Util.padleft(9,'0',3).

  • dt: date
    The date to be converted.
  • format: string
    A standard date formmating string which replaces specific tokens with parts of the date and time. Valid tokens:

Examples: (January 6, 1970 2:23 pm as date input)

  • data: object
    This utility returns an instance of a Trend Binding object given a set of data returned in the trend callback. This is useful for determining which chart and set of pens the data is for, since the trend binding calls are asynchronous.