Splitting RTDB EcOpcClient to multiple instances

This example uses two instances of the RTDB-EcOpcClient service so that they both connect to the same OPC server.
The possible reason for this is that the OPC server is a 32-bit in-process server, and there are too many OPC items to be handled in one instance (because of the 2 GB virtual memory limit of 32-bit processes).
The example assumes that Tags are used in the configuration and that you have a usual RTDB application project installation (the example uses APP_* environment variables)
First, you need to decide on the second instance's name. It is recommended that the name start with “RTDB-EcOpc” so that it can be associated with the application.
This example uses the name RTDB-EcOpcInst2. You must first insert the basic SimpleConfig settings for it with the following SQL script: (save the script to a text file a.sql, and load it to the database with the command praox %app_core_dsn% -ss a.sql -summary )


INSERT INTO SimpleConfig(SectionName, KeyName, StrValue) VALUES('RTDB-EcOpcInst2', 'AutoGetConf', '255');  
INSERT INTO SimpleConfig(SectionName, KeyName, StrValue) VALUES('RTDB-EcOpcInst2', 'DefaultBehaviorMask', '7');  
INSERT INTO SimpleConfig(SectionName, KeyName, StrValue) VALUES('RTDB-EcOpcInst2', 'AppTrace', '96');

Then you need to decide also the “process number” for the second instance. The process numbers 101..199 are reserved for application specific instances, so let’s choose 142 (because “4” is the process number of the standard instance, and “2” reminds us that this is the second instance).
To install the another instance of the RTDB-EcOpcClient service (as a 32-bit version), run the following kind of command line command with Admin privileges:

C:\> call "%APP_ROOT%\Config\FeatureInstall\APP_RtdbServiceInstaller.bat" /32bit RTDB_EcOpcClient -proc 142 -app RTDB-EcOpcInst2

Output Result:

2020-07-30 17:24:18.064 Installing "RTDB-EcOpcInst2 D:\RTDBData" ...
2020-07-30 17:24:21.049 OK: APP_RtdbServiceInstaller: "RTDB-EcOpcInst2 D:\RTDBData" successfully installed

(the above command also automatically created some diagnostic tools to the RTDB Control Panel for the instance)
When using the Tags configuration, the SimpleConfig "DataSources" (see OPC Client#DataSources10 ) defines which tags belong to the OPC client instance.
By default, the DataSources setting of the default OPC client instance (RTDB-EcOpcClient) is “*”, which means that it handles all Tags.
The original intention for using separate OPC client instances was to create a separate instance for each different OPC server connection. But now we need to create another instance that connects to the same OPC server, which makes the situation a little more complicated because the DaPath setting of each tag must be modified.
Let’s assume that currently the DaPaths are something like these:
opcda:///ABB.InProcServer//MyItem1
opcda:///ABB.InProcServer//MyItem2
In order to be able to split these as two instances, we need to use the Class Id of the server instead of the prog id (ABB.InProcServer) as was used before and use a fake progid instead. For example, assume that the class id is "5a17f391-b7bf-46da-b2fb-a10f6f218227". You can choose any names that you like.

This example uses the names OpcServer1 and OpcServer2.

opcda:///OpcServer1/{5a17f391-b7bf-46da-b2fb-a10f6f218227}/MyItem1
opcda:///OpcServer2/{5a17f391-b7bf-46da-b2fb-a10f6f218227}/MyItem2
After this, you can modify the SimpleConfig settings by changing that the default OPC client instance uses only OpcServer1 and the new instance uses only OpcServer2.
You can maintain SimpleConfig with your favorite tool, but this example uses RTDB_Cmd.exe.
NOTE: If the default OPC client instance is wanted to handle also other OPC server connections, you need to add them all to the DataSources setting separated with semicolon. (Unfortunately it is not possible to define a “default” setting that would include all other OPC server connections that those that are explicitly defined). Assume that the default instance needs to handle also the OPC server connection opcda:///ABB.RtdbOpcDaServer.1/ in which case the setting is:

C:\> RTDB_Cmd dbc -datapath %app_datapath% -section RTDB-EcOpcClient -key DataSources -strvalue "opcda:///ABB.RtdbOpcDaServer.1/;opcda:///OpcServer1/{5a17f391-b7bf-46da-b2fb-a10f6f218227}/" SetSimpleConfig

Output Result:

SimpleConfig entry ('RTDB-EcOpcClient', 'DataSources', 'opcda:///ABB.RtdbOpcDaServer.1/;opcda:///OpcServer1/{5a17f391-b7bf-46da-b2fb-a10f6f218227}/') updated, old value '*'

After this, you should wait that the RTDB-EcOpcClient detects the change and takes the new configuration into use (so that you do not accidentally transport the same items from two OPC client instances at the same time. After that, define the SimpleConfig setting for the other OPC client instance:

C:\> RTDB_Cmd dbc -datapath %app_datapath% -section RTDB-EcOpcInst2 -key DataSources -strvalue opcda:///OpcServer2/{5a17f391-b7bf-46da-b2fb-a10f6f218227}/ SetSimpleConfig

Output Result:

SimpleConfig entry ('RTDB-EcOpcInst2', 'DataSources', 'opcda:///OpcServer2/{5a17f391-b7bf-46da-b2fb-a10f6f218227}/') inserted