Configuring the Examples

This section of the document describes the Lua scripting capabilities using some simple examples. Each example has a different focus and can be configured independently from the others unless indicated. In this chapter we firstly configure the three examples (DemoData, Lua HTTP Access and Lua ODBC Access) from a variety of data sources. By using the Mass Config display in DataStudio we can configure multiple items simultaneously, including the embedding of Lua scripts and libraries. In the next chapter we will work with these examples and highlight the role of the Lua scripting.

Before the example configuration is started, make sure the Mass Config Reference delimiter is set to pipe '|'. This is done by opening the General Settings dialogue (Menu Options  General Settings or F10), selecting the MassConfig page and changing the default configuration, reference delimiter to '|'.

DemoData Example

This example configures a set of demo objects that generate simulated process data and (by default) a year of history. The demo is mainly intended to enable you to start working with DataStudio’s display types, but it also contains some basic calculations that are explained in the next chapter.

To configure the demo data, first download the Examples_DemoData.xlsx Mass Config file that matches your system:inmation version from the resources page and then follow these steps:

  1. Start DataStudio and login with administrative rights

  2. Open a new Mass Config display (MenuOpen  Mass Config Sheet, or use the Ctrl+M shortcut). Click the Import Display Content icon in the menu bar.

    Icon Menu Import
    Figure 1. Icon Menu Import
  3. Select the downloaded Examples_DemoData.xlsx file from the Open File dialog and click Ok to load it into the display.

    Mass Config of DemoData
    Figure 2. Mass Config of DemoData
  4. The provided configuration uses Core as name of the Core. This may be different in your environment (default object name of the Core is the name of the machine hosting it), and should be changed to match your system.

    To do this , use the shortcut Ctrl+H to open the Replace dialogue, and replace MasterCore with the object name of your Core.

    Replace Dialogue
    Figure 3. Replace Dialogue
  5. Click Replace All; you should see 27 replacements.

    Replacement Message
    Figure 4. Replacement Message
  6. In the Mass Config display click ''Simulate'' to test if the content can be applied to your system now.

    Simulate Changes
    Figure 5. Simulate Changes
  7. You should see 24 successes (this could be less if you already created some of the folders in a previous example).

    Simulate Result
    Figure 6. Simulate Result
  8. Click ''Apply'' to accept the changes. The demo data objects should exist now in the I/O model tree.

    DemoData Objects
    Figure 7. DemoData Objects

Lua HTTP Access Example

This example configures a set of demo objects that will illustrate how to access a http server outside of system inmation to retrieve data (here freely available information about US airports). This example also shows how Lua scripts can dynamically create objects in the tree hierarchy in addition to dealing with their values.

In order to be able to retrieve the http server data, the machine hosting the Core needs to have access to the internet!

To configure this example, download the Examples_LUA.xlsx file from the resources page and open it in the Mass Config display. After the import and the first run of the DataProcessing scripts included in the import, the I/O model tree should look like this:

Lua HTTP Access Objects
Figure 8. Lua HTTP Access Objects

Lua ODBC Access Example

This example configures a set of demo objects that illustrate how to access an ODBC data source.

The provided sample scripts work with a very simplistic SQL demo database, and requires a System DSN configured to access this database on the Core host. Also it requires the DemoData Example to be already configured!

To configure this example first create the SQL environment following these steps:

  1. Make sure you have first configured the DemoData example shown above.

  2. Create the sample sql database by either restoring the InmationDataDemo.bak or running the InmationDataDemo.sql provided with this document at a SQL Server instance of your choice (see note below for details of setting up an example SQL server).

  3. Create a System DSN called 'InmationDataDemo' pointing to the InmationDemoData SQL database (can be found in Administrative tools in the control panel). Double click on ODBC Data Source Administrator (32/64bit, depending on your environment), select the System DSN tab and click Add. Choose an appropriate driver (depending on the SQL Server you are using - ODBC Driver 11 for SQL Server works for MS SQL Express)

  4. Give the System DSN a name in the dialog and connect it to the SQL Server you are using (it may not appear automatically in the drop-down menu). If using MS SQL Express this will be <hostname>\SQLEXPRESS.

  5. Set up the SQL server authentication using same authentication details as during the SQL server set up (see note below for details of setting up an example SQL server) and click Next.

  6. Change the default database to InmationDataDemo, click Next and then Finish. Test Data source and then click OK until all dialog windows are closed.

If you do not have a SQL server available, you can download the 2014 Express version here. Be sure to download the Express with Tools download package as this contains the SQL Server Management Studio. During setup, enable the mixed mode authentication and enter “Inmation!1” as the password for the system administrator (sa) account. This is important for this example as the embedded Lua script uses this authentication to access the ODBC database. To restore the InmationDataDemo.bak database, open the management studio and right-click on Databases in the left hand panel and select Restore Database. Select Source → Device → "…" and click Add to browse to the .bak file.

After you have set up the database, the environment should be similar to this:

Sample SQL Database
Figure 9. Sample SQL Database

The objects needed for the Lua ODBC example are included as part of the Examples_LUA.xlsx Mass Config file used to configure the Lua HTTP Access example. Download the Examples_LuaHttp.xlsx file from the resources page if you haven’t already, and open it in the Mass Config display. After the import and the first run of the DataProcessing scripts included in the import, the I/O model tree should look like this:

Lua ODBC Access Objects
Figure 10. Lua ODBC Access Objects