Process or store OPC data by an event from the OPC server
I have this item: Kemro.opc.4.IF1.1.92.Mars1.SVs.system.sv_ShotCounter="1" in OPC Data Logger. I want to take data and write it to MySQL only when this value rises to 1. The logger should reset this value to 0 on the OPC server. This action will confirm that the data was received.
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. You've configured a data export to MySQL.
1. Enable highlighted options in the OPC group settings.
Fig.1. OPC group settings
2. Download and install the "Script Execute" plugin.
3. Enable it (fig. 2).
Fig.2. Script Execute plugin
4. Select the plugin in the list and click the "Setup" button below.
5. In the script editor window select "PascalScript" from the "Script type" list
6. Copy and paste the following code. Modify it if necessary. The row sName1:string = 'Kemro.opc.4.IF1.1.92.Mars1.SVs.system.sv_ShotCounter'; contains the name of the controlled OPC tag. The row SendString(sName+'=0'); sends data to the OPC server, where the string '=0' represents the new value. The logger internally will decode this string and send the corresponding value to the OPC server.
7. Click the "Check" button and verify that the script was compiled successfully.
8. Click the "OK" button and save all changes.
The PascalScript code
sName:string = 'Kemro.opc.4.IF1.1.92.Mars1.SVs.system.sv_ShotCounter';
// checks a variable in a data packet
if IsVariableDefined(sName) then
v := GetVariable(sName);
// the script will discard data packets by the following condition
if v <> 1 then
// discard data also when the counter didn't read yet
OPC and DCOM Configuration on Windows 2008 and Windows 7
OPC and DCOM Configuration on Windows Server 2012 and Windows 8