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

Inserting Tag Items if not using Litmus Edge Integration via JSON

6min

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

Use Cases

Litmus Production Record Database allows for several ways to insert data into its tables.

The recommended way when using Litmus Edge, is to make use of the MSSQL Integrations to insert data directly into the table PROREC_Misc_Transactions. As it allows to make use of the integrated store and forward capability, preventing data loss on a connection interruption.

But for cases, where this is not an option, a stored procedure can be called by a program or code snippet to insert data data. Any application which provided the capability to use an ODBC connection can be used like:

  • Python
  • C#
  • .Net
  • Excel
  • Go
  • Java

Method

Execute Stored Procedure PROREC_Misc_WriteIntoTransactionTables using a JSON object as Input.

Input Variables

Variable name

Datatype

Description

Example

@JSONInput

VARCHAR(8000)

A single JSON object which has to always include the keys:

  • deviceid -> device name associated with the tag
  • registerid -> tag name
  • tagname -> Item name
  • datatype -> timestamp in unix millisecond format enclosed by "##" -> this is also used to distinguish between a Production Record Item and a Tag
  • value -> value for the tag
  • success -> quality of the tag (1 = Good, 0 = Bad)

Or an Array of JSON objects for multiple inserts

[{"deviceid":"P2_Electrical_Panel","registerid":"L3_Machine3_1_S7_Power","tagname":"Value","datatype":"##1694688509846##","value":"43.39283446097687","success":"1"},{"deviceid":"P2_Electrical_Panel","registerid":"L3_Machine3_1_S7_Speed","tagname":"Value","datatype":"##1694688519848##","value":"52.524841352846764","success":"1"}]

How to use

To insert a value(s) for Production Tag Item(s) via JSON, call the stored procedure PROREC_Misc_WriteIntoTransactionTables using the T-SQL EXEC or EXECUTE keyword and provide the Input variable. Below is an example using T-SQL in SQL Server Management Studio:

EXEC [LE_ProductionRecord].[dbo].[PROREC_Misc_WriteIntoTransactionTables] @JSONInput = N'[{"deviceid":"P2_Electrical_Panel","registerid":"L3_Machine3_1_S7_Power","tagname":"Value","datatype":"##1694688509846##","value":"43.39283446097687","success":"1"},{"deviceid":"P2_Electrical_Panel","registerid":"L3_Machine3_1_S7_Speed","tagname":"Value","datatype":"##1694688519848##","value":"52.524841352846764","success":"1"}]';

Result

The stored procedure will verify that the provided values are correctly formatted and then write them into the table PROREC_ProRec_Transactions. This will trigger their immediate processing. The result can be read back from the log table PROREC_Tag_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_Tag_Log] Order by LogID Desc;

With the result returned

Document image


For more detailed logging, enable the "Debug_Log" option for verbose logging as described in Reading out the Application configuration of Litmus Production Record Database and Modify Application Configuration Items