Report Item Query Options Configuration

Preparations

1 To house the objects which we will create for the examples in this JumpStart, create a Folder named "Report Demo" object underneath the Core by right-clicking the Core object and selecting Admin  New  Data Processing  Folder.

2 Then, create a Report Item called Test Report in the newly created Report Demo folder by right-clicking the Folder object and selecting Admin  New  Report  Report Item.

Adding Query Options

The system offers different Query Options which can be added to reports. The configurations for the different are very similar, the following sections address the configuration for each Query Option individually, though.

The following links provide shortcuts to the specific sections of this page:

Adding a Realtime Query Option

1 Select the Test Report item, and, in the Properties Panel, expand the Report property compound, and click the + icon for the RealtimeQueryOptions.

2 Click Apply for the Properties to save the changes made so far and allow dragging and dropping from the I/O Model for the subsequent steps.

3 In the Properties Panel, expand the newly added Query Option and give it an individual Table Name Prefix to make it distinguishable from other Query Options. In this example, we will use RT-EX-DD-PD - RT for realtime, and EX, DD and PD for Examples > Demo Data > Process Data - hinting at where the data for this Query Option is coming from.

4 Select the Item Names Template-Able checkbox. If this option is enabled, report templates can be exported and reused without being tied to certain item names.

5 Click on the Table icon for the Query Objects property to open the Table Property Grid dialog.

6 Drag the data producing items which you want to use in the report from the I/O model into the Query Objects column.
For this example, add the following items from the …​/Examples/Demo Data/Process Data/ branch in the I/O Model:

  • DC4711

  • DC666

  • FC4711

  • FC666

  • PC4711

  • PC666

  • QC4711

  • QC666

7 Click OK to close the Query Objects table property.

8 Open the Properties drop-down menu and scroll down to the object type you selected for the query option. Here, select the checkboxes for the properties of this Query Option which you want to make available in the Report Designer. There, these properties will appear in the Dictionary tab, in the *_items and the *_data/*_items tables, which will be addressed in the Layout Design ).
For this example, expand the Generic Item section and select Object Name, Object Description, Engineering Unit, and Value.

9 Click Apply on the Properties Panel to save the configuration changes.

Adding a History Query Option

Adding a History Query Option is similar to adding a Realtime Query Option.

1 Select the Test Report item, and, in the Properties Panel, expand the Report property compound, and click the + icon for the HistoryQueryOptions.

2 In the Properties Panel, expand the newly added Query Option and give it an individual Table Name Prefix to make it distinguishable from other Query Options.
In this example, we will use Hist-EX-DD-PD - Hist for historical, and EX, DD and PD for Examples > Demo Data > Process Data - hinting at where the data for this Query Option is coming from.

3 Click on the table icon for the Query Objects property to open a Table Property Grid dialog.

4 Drag the data producing items which you want to use in the report from the I/O model into the Query Objects column.
For this example, add the following items from the …​/Examples/Demo Data/Process Data/ branch in the I/O Model:

  • DC4711

  • DC666

  • FC4711

  • FC666

  • PC4711

  • PC666

  • QC4711

  • QC666

5 Click Apply to close the Query Objects table property.

6 Open the Properties drop-down menu and scroll down to the object type you selected for the query option. Here, select the checkboxes for the properties of your Query Object which will be made available to the Report Designer.

7 For the Aggregates property, select a suitable option from the drop-down menu. For this example the aggregate is set to Average.

8 For the Timesettings property, click on the …​ icon to open the DataStudio Time Period Settings dialog. Detailed information on this dialog is provided in this section of the History Grid documentation.
For this example the time period is set to retrieve the last hour of data with an interval count of 6).

The other options are standard OPC History Call options in accordance to the OPC UA standard; we will leave these on default for the moment.

9 Click Apply on the Properties Panel to save the Query Options configurations to the Report Item.

Making the Query Options Available to the Reporting System

To make the configured Query Options available to the Reporting System, the Report Item needs to provide them as a JSON structure. For this, a simple Lua script has to be added to the Report Item.

To do this …​

1 In the Properties Panel for the Report Item object, expand the Common section and cick on the …​ icon for the Lua Script Body property to open a Script Editor display.

2 Enter the following Lua script into the editor:

local report = require ("syslib.report")
return report:getjsondata(syslib.getself():path(), false)

3 Click OK to close the Script Editor.

4 Click Apply to confirm the changes.

Executing the Lua Script

When you click Ok in the Lua Script Editor, the script is executed once and a JSON string is returned containing the query options, objects and properties that were configured. The values that populate the dynamic fields are the ones retrieved at the moment that the script is executed. These are the values that will be visible during Design Time and will remain static unless the script is re-excuted (for instance, if the Core service is stopped then the Report Item script will be re-executed when the Core is re-started.

Once the Query Objects have been configured and the Lua Script has been executed to return a JSON string containing the all the Query Options, we can now use the Report Item to design a report layout in the Report Designer Display.