Filter data out if an OPC tag value is not equal to a specified value
Problem scenario.
I have this item: Kemro.opc.4.IF1.1.92.Mars1.SVs.system.sv_ShotCounter[14]="1" in OPC Data Logger. I want to take data and write it to MySQL, only when the value will be equal "1".
Requirements:
It is assumed that:
1. You've created a configuration (using the "Green Plus" button in the main window and added an OPC group in the OPC logger and can receive any data from a selected OPC server.
2. The OPC tag has a numerical data type.
3. You've configured a data export to MySQL.
Solution:
1. Enable highlighted options in the OPC group settings.
Fig.1. OPC group settings
2. The tag name must contain alphanumeric or "_" characters only. If the tag name contains other characters (as in the problem scenario), you must assign a new shorten valid name (fig. 2). In this tutorial, the new name will sv_ShotCounter.
Fig.2. Assigning new name
3. Download and install the "Expressions" plugin.
4. Enable it (fig. 3).
Fig.3. Expressions plugin
5. Select the plugin in the list and click the "Setup" button below.
6. In the editor window (fig. 4), specify the following expression. Please, note that the new tag name is used in this expression.
DISCARD_DATA_PACKET_IF(sv_ShotCounter<>1)
Fig.4. Expression
7. Click the "OK" button and save all changes.
Related articles: Filter data out if an OPC tag value is not equal to a specified value
OPC and DCOM Configuration on Windows 2008 and Windows 7
OPC and DCOM Configuration on Windows 10, 11, Windows Server 2019, 2022