esi-examples

A library for setting up various examples to demonstrate various features of the system or for showcasing the capabilites of built-in Lua libraries.

The following esi-examples can be installed using this library:

  • DemoData: Creates example data to demonstrate the use of I/O Model, KPI Model and ISA-95 Equipment Model.

  • RemoteMongoDB: Except for the local Data Store for logfiles, all other Data Stores will be redirected to a remote standalone Mongodb server. Only "simple" standalone connections are currently supported: No security settings, no encryption, no replica sets!

  • SendMail: Sends an HTML-formatted test eMail to a given recipient.

  • WeatherData: Fetches live weather data and weather warnings from the German Weather Service.

  • BatchTracker: Simulates a bread factory to illustrate various uses of the batch tracker feature.

Changes

Version Date Description s:i Release

1.1.0

2022-05-01

General availability

1.84


Dependencies

library version inmation core library

esi-examples-demodata

0.1.1

yes

esi-examples-mongodb

0.1.1

yes

esi-examples-smtp

0.1.1

yes

esi-examples-weatherdata

0.1.1

yes

esi-examples-batch-tracker

0.1.1

yes


Available functions

All functions have to be called according to the ESI standard, using colons, e.g.

lib:FUNCTIONNAME(params)
Function Description

SETUP

Sets up one or more requested examples


SETUP

Function head:

lib:SETUP( { {"example", "parameter} [, {"example2", "parameter2"}, {...} ] } )

Installs the chosen example in a folder named Examples underneath the system core object.

The function expects a multi-dimensional Lua table containing the name of the example(s) to be installed and possible additional parameters.

Available examples:

Example Paramaters

DemoData

iomodel, kpimodel, isamodel or data for all models

RemoteMongoDB

 — 

SendMail

 — 

WeatherData

 — 

BatchTracker

 — 

ODBC

 — 

USAIRPORTDATA

 — 

JSON

 — 


Valid Lua usages:

local exm = require('esi-examples')
--
-- Populate I/0 Model:
exm:SETUP({{"demodata", "iomodel"}})
--
-- Note that the following options all implicitly create I/O model data if it not already exists!
--
-- Create random historical data for objects in I/O model:
exm:SETUP({{"demodata", "history"}})
--
-- Populate I/O Model and create random historical data in one step:
exm:SETUP({{"demodata", "iomodel", "history"}})
--
-- Populate KPI Model:
exm:SETUP({{"demodata", "kpimodel"}})
--
-- Populate ISA-95 Equipment Model:
exm:SETUP({{"demodata", "isamodel"}})
--
-- Do all of the above in one simple step:
exm:SETUP({{"demodata", "all"}})
--
-- Creates an action itm that reconfigures the local data stores to use a different MongoDB server:
exm:SETUP({{"RemoteMongodb"}})
--
-- Creates an action item that can send HTML formatted eMails:
exm:SETUP({{"SendMail"}})
--
-- Creates a sample folder for live DWD weather data:
exm:SETUP({{"WeatherData"}})
--
-- Creates a sample folder for demonstrating the batch tracker feature.
exm:SETUP({{"BatchTracker"}})
--
-- Creates a sample folder for live US airport data.
exm:SETUP({{"usairportdata"}})
--
-- Creates a sample folder for demonstrating the useage of ODBC.
exm:SETUP({{"odbc"}})
--
-- Creates a sample folder for demonstrating JSON processing.
exm:SETUP({{"json"}})
--
-- Creates all demo data and the sendmail example in one call:
exm:SETUP({{"demodata","all"},{"sendmail"}})

DemoData

Description

This creates various sets of Demo Data for training and testing purposes. Demo data and objects for I/O Model, KPI Model and ISA-95 model, including historical data, can be created.

Installation

local exm = require('esi-examples')
--
-- Populate I/0 Model:
exm:SETUP({{"demodata", "iomodel"}})
--
-- Note that the following options all implicitly create I/O model data if it not already exists!
--
-- Create random historical data for objects in I/O model:
exm:SETUP({{"demodata", "history"}})
--
-- Populate I/O Model and create random historical data in one step:
exm:SETUP({{"demodata", "iomodel", "history"}})
--
-- Populate KPI Model:
exm:SETUP({{"demodata", "kpimodel"}})
--
-- Populate ISA-95 Equipment Model:
exm:SETUP({{"demodata", "isamodel"}})
--
-- Do all of the above in one simple step:
exm:SETUP({{"demodata", "all"}})

RemoteMongoDB

Description

This example provides an Action Item with a Lua script to point local data stores to a different Mongodb instance.

Installation

The example can be loaded from a Console Display in DataStudio with the following simple Lua code:

local exm = require('esi-examples')
exm:SETUP({{"RemoteMongoDB"}})

The code above will create a folder structruce "Examples/Remote Mongodb" underneath the Core object in I/O Model. In this folder will be a single, disabled Action Item named "Repoint Data Stores". This Action Item contains a Lua script body that illustrates how to repoint the several of the standard data stores to a different standalone Mongodb server.

  • Note: Only "simple" standalone connections are supported - no security settings, no encryption, no replica sets!

SendMail

Description

This example connects to an SMTP server to send emails using the esi-SMTP library

Installation

The example can be loaded from a Console Display in DataStudio with the following simple Lua code:

local exm = require('esi-examples')
exm:SETUP({{"SendMail"}})

The code above will create a folder structure "Examples/Sendmail" underneath the Core object in I/O Model.

WeatherData

Description

The Weather Data example uses the esi-lcurl-http-client library to fetch weather data from the German Weather Service ("DWD - Deutscher Wetterdienst") servers.

This is an official public server and the data is made available in an HTML file that can be downloaded from this URL: https://www.dwd.de/DWD/wetter/aktuell/deutschland/tabelle/wx_brd_akt.html

A Lua script parses this HTML file and then creates objects in I/O model that contain this data.

Installation

The example can be loaded from a Console Display in DataStudio with the following simple Lua code:

exm=require("esi-examples")
exm:SETUP({{"WeatherData"}})

The code above will create a folder structure "Examples/Weather Data" underneath the Core object in I/O Model.

BatchTracker

Description

In order to illustrate the use of the batch tracker feature, an example use case was chosen to is relatively easy to comprehend for everyone. A bread factory represents a scenario everybody can relate to, and baking simple wheat bread, for example, is something everybody can do in their kitchen at home.

Installation

The example can be loaded from a Console Display in DataStudio with the following simple Lua code:

exm=require("esi-examples")
exm:SETUP({{"batchtracker"}})

The code above will create a folder structruce "Examples/Bread Factory" underneath the Core object in I/O Model, and it will also create an enterprise structure in the ISA95 Equipment Model.

After the initial setup, the simulated bread factory will not be active and its objects in I/O model will appear disabled. To activate the simulation, enable the "00 MES" object:

USAirportData

Description

This example uses the esi-lcurl-http-client library to fetch data in XML format from an official US government server: https://soa.smext.faa.gov/asws/api/airport/status/

A Lua script parses the XML file and then creates an object representing the data in I/O model.

Installation

The example can be loaded from a Console Display in Data Studio with the following simple Lua code:

exm=require("esi-examples")
exm:SETUP({{"usairportdata"}})

The code above will create a folder structruce "Examples/US Airport Data" underneath the Core object in I/O Model.

Using the US airport data example

The sample automatically initializes itself and directly begins downloading the data and creating the I/O model objects for each US airport.

ODBC

Description

This example demonstrates ODBC access using Lua scripts.

Installation

he example can be loaded from a Console Display in Data Studio with the following simple Lua code:

exm=require("esi-examples")
exm:SETUP({{"odbc"}})

The code above will create a folder structruce "Examples/ODBC" underneath the Core object in I/O Model.

Using the ODBC example

The created objects contain Lua script bodies to showcase the use of ODBC.

JSON

Description

This example demonstrates JSON processing using Lua scripts.

Installation

The example can be loaded from a Console Display in Data Studio with the following simple Lua code:

exm=require("esi-examples")
exm:SETUP({{"json"}})

The code above will create a folder structruce "Examples/JSON" underneath the Core object in I/O Model.

Using the JSON example

The created objects contain Lua script bodies to showcase JSON processing.