Solutions
...
Litmus Production Record Datab...
Interacting with Litmus Produc...

Adding or Modifying a Data Model Item(s) via JSON

7min

Note: This requires Litmus Production Record Database V 1.4.0.0 or higher.

Use Cases

Litmus Production Record Database makes use of Data models based on ISA-88 to store and publish Event data.

To be able to store event data, such a data model has to be configured first.

User can do this either by using applications such as:

  • Microsoft SQL Server Management Studio
  • MSSQL CLI

This can also be used for building custom solutions based on applications which allow for an ODBC connection such as:

  • Excel
  • C#
  • .Net
  • Python

Method

Execute Stored Procedure PROREC_ProRec_ProcessConfiguration using a JSON object as Input.

Note

Do learn more about the data model concept and how to define it, please read the document Core Concept behind recording production record data via data model

Input Variables

Variable name

Datatype

Description

Example

@JSONInput

VARCHAR(8000)

A single JSON object which has include the keys:

Mandatory:

  • Node -> The name of the root Node and the name of the data model.
  • Item -> The name of the Item which represents the value.
  • isTime -> Is the value type of the Item a time stamp?
  • isNumeric -> Is the value type of the Item a numeric value?
  • isString -> Is the value type of the Item a alphanumeric string?
  • isBoolean -> Is the value type of the Item a boolean value?
  • isID -> Is this Item an Identifier?

Optional:

  • Level1 -> The name of the first sub level in the ISA-88 based data model hierarchy
  • Level2 -> The name of the second sub level in the ISA-88 based data model hierarchy
  • Level3 -> The name of the third sub level in the ISA-88 based data model hierarchy
  • Level4 -> The name of the fourth sub level in the ISA-88 based data model hierarchy
  • Level5 -> The name of the fifth sub level in the ISA-88 based data model hierarchy
  • NodeDesc -> An optional short description of the model
  • Level1Desc -> An optional short description of Level1
  • Level2Desc -> An optional short description of Level2
  • Level3Desc -> An optional short description of Level3
  • Level4Desc -> An optional short description of Level4
  • Level5Desc -> An optional short description of Level5
  • ItemDesc -> An optional short description of the Item
  • ItemEng -> An optional engineering unit for items

Users can also provide an Array of JSON objects for multiple inserts.

[{"Node":"EnergyMonitoringDevice_DTDL","Item":"Asset","isTime":false,"isNumeric":false,"isString":true,"isBoolean":false,"isID":true},{"Node":"EnergyMonitoringDevice_DTDL","Item":"DT_Instance","isTime":false,"isNumeric":false,"isString":true,"isBoolean":false,"isID":true},{"Node":"EnergyMonitoringDevice_DTDL","Level1":"MetaData","Level2":"Meta[0]","Item":"Tag","isTime":false,"isNumeric":false,"isString":true,"isBoolean":false,"isID":false},{"Node":"EnergyMonitoringDevice_DTDL","Level1":"MetaData","Level2":"Meta[1]","Item":"Instance","isTime":false,"isNumeric":false,"isString":true,"isBoolean":false,"isID":false},{"Node":"EnergyMonitoringDevice_DTDL","Level1":"MetaData","Level2":"Meta[1]","Item":"Model","isTime":false,"isNumeric":false,"isString":true,"isBoolean":false,"isID":false},{"Node":"EnergyMonitoringDevice_DTDL","Level1":"MetaData","Level2":"rawmetadata","Item":"line_tag","isTime":false,"isNumeric":false,"isString":true,"isBoolean":false,"isID":false},{"Node":"EnergyMonitoringDevice_DTDL","Level1":"MetaData","Level2":"rawmetadata","Item":"name_tag","isTime":false,"isNumeric":false,"isString":true,"isBoolean":false,"isID":false},{"Node":"EnergyMonitoringDevice_DTDL","Level1":"MetaData","Level2":"rawmetadata","Item":"plant","isTime":false,"isNumeric":false,"isString":true,"isBoolean":false,"isID":false}]





For a more detailed explanation of the content to be provided by each key, please read the document Adding or Modifying a Data Model Item.

How to use

To insert a data model item(s), call the stored procedure PROREC_ProRec_ProcessConfiguration using the T-SQL EXEC or EXECUTE keyword and provide the Input variables. Below is an example using T-SQL in SQL Server Management Studio:

EXECUTE [LE_ProductionRecord].[dbo].[PROREC_ProRec_ProcessConfiguration] @JSONInput= N'[{"Node":"EnergyMonitoringDevice_DTDL","Item":"Asset","isTime":false,"isNumeric":false,"isString":true,"isBoolean":false,"isID":true},{"Node":"EnergyMonitoringDevice_DTDL","Item":"DT_Instance","isTime":false,"isNumeric":false,"isString":true,"isBoolean":false,"isID":true},{"Node":"EnergyMonitoringDevice_DTDL","Level1":"MetaData","Level2":"Meta[0]","Item":"Tag","isTime":false,"isNumeric":false,"isString":true,"isBoolean":false,"isID":false},{"Node":"EnergyMonitoringDevice_DTDL","Level1":"MetaData","Level2":"Meta[1]","Item":"Instance","isTime":false,"isNumeric":false,"isString":true,"isBoolean":false,"isID":false},{"Node":"EnergyMonitoringDevice_DTDL","Level1":"MetaData","Level2":"Meta[1]","Item":"Model","isTime":false,"isNumeric":false,"isString":true,"isBoolean":false,"isID":false},{"Node":"EnergyMonitoringDevice_DTDL","Level1":"MetaData","Level2":"rawmetadata","Item":"line_tag","isTime":false,"isNumeric":false,"isString":true,"isBoolean":false,"isID":false},{"Node":"EnergyMonitoringDevice_DTDL","Level1":"MetaData","Level2":"rawmetadata","Item":"name_tag","isTime":false,"isNumeric":false,"isString":true,"isBoolean":false,"isID":false},{"Node":"EnergyMonitoringDevice_DTDL","Level1":"MetaData","Level2":"rawmetadata","Item":"plant","isTime":false,"isNumeric":false,"isString":true,"isBoolean":false,"isID":false}]';

Result

The stored procedure will verify that the provided values are correctly formatted and then create any new node, levels and items or modify existing items.

The result can be read back from the log table PROREC_Misc_Log.

Below is an example using T-SQL in SQL Server Management Studio:

SELECT TOP (100) [LogID] ,[LogType] ,[LogProcedure] ,[LogEntry] ,[LogTime] FROM [LE_ProductionRecord].[dbo].[PROREC_Misc_Log] WHERE [LogProcedure] = 'PROREC_ProRec_ProcessConfiguration' Order by LogID Desc;

With the result returned

Document image