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

Adding or Modifying a Tag Item(s) via JSON

7min

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

Use Cases

To store Tag data inside Litmus Production Record Database, Tags and their Device association together with the Item's to be stored have to be setup.

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_Tag_ProcessTagConfiguration using a JSON object as Input.

Note

Litmus Production Record Database can act similar to an Historian and allows to store data for individual defined tags and their meta data.

Input Variables

Variable name

Datatype

Description

Example

@JSONInput

VARCHAR(8000)

A single JSON object which has include the keys:

Mandatory:

  • TagName -> The name of a tag
  • DeviceName -> The name of a specific device
  • Item -> The name of the Item of a tag
  • isDecimal -> Is the value type of the Item a decimal/float/real value?
  • isInteger -> Is the value type of the Item an integer value?
  • isString -> Is the value type of the Item a alphanumeric string?
  • isBoolean -> Is the value type of the Item a boolean value?
  • isMeta -> Is the Item a meta data value or a live data value?

Optional:

  • ItemDesc -> An optional short description of the Item.
  • initValue -> An optional initial value for the item

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

[{"TagName":"L3_Machine3_1_S7_Power","DeviceName":"P2_Electrical_Panel","Item":"Value","isDecimal":true,"isInteger":false,"isString":false,"isBoolean":false,"isMeta":false,"initValue":"43.39283446097687","initTime":1694688509846,"initSuccess":true},{"TagName":"L3_Machine3_1_S7_Power","DeviceName":"P2_Electrical_Panel","Item":"Value","isDecimal":true,"isInteger":false,"isString":false,"isBoolean":false,"isMeta":false,"initValue":"52.524841352846764","initTime":1694688519848,"initSuccess":true}]















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

How to use

To insert a tag item(s) using JSON, call the stored procedure PROREC_Tag_ProcessTagConfiguration 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_Tag_ProcessTagConfiguration] @JSONInput = N'[{"TagName":"L3_Machine3_1_S7_Power","DeviceName":"P2_Electrical_Panel","Item":"Value","isDecimal":true,"isInteger":false,"isString":false,"isBoolean":false,"isMeta":false,"initValue":"43.39283446097687","initTime":1694688509846,"initSuccess":true},{"TagName":"L3_Machine3_1_S7_Power","DeviceName":"P2_Electrical_Panel","Item":"Value","isDecimal":true,"isInteger":false,"isString":false,"isBoolean":false,"isMeta":false,"initValue":"52.524841352846764","initTime":1694688519848,"initSuccess":true}]';

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_Tag_ProcessTagConfiguration' Order by LogID Desc;

With the result returned

Document image