-
Notifications
You must be signed in to change notification settings - Fork 154
Running OPC Examples
OPC client and server samples are included in macchina.io.
To quickly see them in action, first build OPC and the accompanying samples:
$ cd macchina.io/
~/macchina.io$ cd platform/
~/macchina.io/platform$ export POCO_BASE=`pwd`
~/macchina.io/platform$ cd ..
~/macchina.io$ export PROJECT_BASE=`pwd`
~/macchina.io$ make -s
~/macchina.io$ cd protocols/OPC/samples
~/macchina.io/protocols/OPC/samples$ make -s
Once samples are built, execute them:
~/macchina.io/protocols/OPC/samples/OPCServer$ ./bin/Linux/x86_64/OPCServer
Connection 404405168 | SecureChannel 1 | Session 7c3d5a00-0018-181abc90-181abbd039d99600-181abc40002e6e6f6904017c3d5a00 | ActivateSession: Session activated
Server listens on the default OPC port (4840).
~/macchina.io/protocols/OPC/samples/OPCClient$ ./bin/Linux/x86_64/OPCClient 4840
OPC Client: connected.
Caching Node: (0, 2255), TYPE: [11]
Caching Node: (0, 2254), TYPE: [11]
Caching Node: (0, 2271), TYPE: [11]
Caching Node: (0, 2735), TYPE: 4
Caching Node: (0, 2269), TYPE: [11]
Type not found for node: (0, 3704), will not be cached.
Caching Node: (0, 2736), TYPE: 4
Caching Node: (0, 2737), TYPE: 4
Caching Node: (0, 2272), TYPE: 10
Caching Node: (0, 2294), TYPE: 0
Caching Node: (0, 2256), TYPE: 137
Caching Node: (0, 2267), TYPE: 2
Caching Node: (0, 2994), TYPE: 0
Caching Node: (0, 3709), TYPE: 5
Caching Node: (1, the.int.answer), TYPE: 5
Caching Node: (2, the.double.answer), TYPE: 10
Caching Node: (2, 3), TYPE: 10
Caching Node: (2, 4), TYPE: 11
Caching Node: (2, 5), TYPE: 12
1 endpoint found.
Endpoint [0]: opc.tcp://localhost:4840
OPC Client: connected.
Server DateTime is: [07/11/2017 08:39:56.061.516.000]
Server objects:
Found 1 results.
[NAMESPACE] [NODEID] [BROWSE NAME] [DISPLAY NAME] [VALUE]
-------------------------------------------------------------------------------------------------------------------------------------------
0 2253 Server Server N/A
0 2255 NamespaceArray NamespaceArray[ "http://opcfoundation.org/UA/", "urn:unconfigured:application", "ns2" ]
0 2254 ServerArray ServerArray [ "urn:unconfigured:application" ]
0 2268 ServerCapabilities ServerCapabilities N/A
0 2271 LocaleIdArray LocaleIdArray [ "en" ]
0 2735 MaxBrowseContinuationPoints MaxBrowseContinuationPoints 0
0 2269 ServerProfileArray ServerProfileArray ["http://opcfoundation.org/UA-Profile/Server/NanoEmbeddedDevice", "http://opcfoundation.org/UA-Profile/Server/EmbeddedDataChangeSubscription" ]
0 3704 SoftwareCertificates SoftwareCertificates null
0 2736 MaxQueryContinuationPoints MaxQueryContinuationPoints 0
0 2737 MaxHistoryContinuationPoints MaxHistoryContinuationPoints 0
0 2272 MinSupportedSampleRate MinSupportedSampleRate 0
0 2996 ModellingRules ModellingRules N/A
0 2997 AggregateFunctions AggregateFunctions N/A
0 2274 ServerDiagnostics ServerDiagnostics N/A
0 2294 EnabledFlag EnabledFlag false
Type not supported:137
0 2256 ServerStatus ServerStatus 0
0 2267 ServiceLevel ServiceLevel 255
0 2994 Auditing Auditing false
0 2295 VendorServerInfo VendorServerInfo N/A
0 2296 ServerRedundancy ServerRedundancy N/A
0 3709 RedundancySupport RedundancySupport 0
1 the.int.answer the int answer the int answer 42
2 the.double.answer the double answer the double answer 4.2
2 3 the double answer by ID in ns2 the double answer by ID in ns2 2.4
2 4 the string answer by ID in ns2 the string answer by ID in ns2 abc123
2 5 the DateTime answer by ID in ns2 the DateTime answer by ID in ns2 07/11/2017 08:37:41.407.223.000
OPC Client: disconnected.
Client will cache data types by default (caching can be disabled via API), when a node contains typed data. Null value nodes are not cached, since they have no type. Only numeric types, character strings and date/time types are currently supported.
For the purpose of this example, we'll use:
Both products are freely available for download after (free) registration.
Let us first run UaExpert and explore the macchina.io example OPC server.
To create an UA Expert connection, it is sufficient to specify the OPC server endpoint:
Once server is configured, right click on the entry, connect and browse it:
As we can see on the above image, the entries from our example server are showing in the server browse display.
Next, let's try to connect the macchina.io client to the Matrikon example OPC server. After downloading the demo server, unzip it:
~/Downloads$ unzip Matrikon-FLEX_DemoServer_Linux.zip
~/Downloads$ cd DemoServer_Linux/Executable/
~/Downloads/DemoServer_Linux/Executable$ ./DemoServer_DA_Linux64
****************************************************************************
Server is running in Demo mode
Discovery and Server Endpoints are at: 'opc.tcp://localhost:55000'
****************************************************************************
Once we have the server running, we can connect our example client to it:
~/macchina.io/protocols/OPC/samples/OPCClient$ ./bin/Linux/x86_64/OPCClient 55000
OPC Client: connected.
Caching Node: (0, 2254), TYPE: [11]
Caching Node: (0, 2255), TYPE: [11]
Caching Node: (0, 2256), TYPE: 137
Caching Node: (0, 2267), TYPE: 2
Caching Node: (0, 2269), TYPE: 11
Caching Node: (0, 2272), TYPE: 10
Caching Node: (0, 2735), TYPE: 6
Caching Node: (0, 2736), TYPE: 6
Caching Node: (0, 2737), TYPE: 6
Caching Node: (0, 3704), TYPE: 14
Caching Node: (0, 11702), TYPE: 6
Caching Node: (0, 11703), TYPE: 6
Caching Node: (0, 11705), TYPE: 6
Caching Node: (0, 12165), TYPE: 6
Caching Node: (0, 12166), TYPE: 6
Caching Node: (0, 11707), TYPE: 6
Caching Node: (0, 12167), TYPE: 6
Caching Node: (0, 12168), TYPE: 6
Caching Node: (0, 11709), TYPE: 6
Caching Node: (0, 11710), TYPE: 6
Caching Node: (0, 11711), TYPE: 6
Caching Node: (0, 11712), TYPE: 6
Caching Node: (0, 11713), TYPE: 6
Caching Node: (0, 11714), TYPE: 6
Caching Node: (0, 2294), TYPE: 0
Caching Node: (0, 2994), TYPE: 0
Caching Node: (0, 3709), TYPE: 5
Caching Node: (1, Objects/MyFolder/MyStoredVariable), TYPE: 6
Caching Node: (1, Objects/MyFolder/MySynchronousVariable), TYPE: 6
Caching Node: (1, Objects/MyFolder/MyAsynchronousVariable), TYPE: 5
1 endpoint found.
Endpoint [0]: opc.tcp://localhost:55000
OPC Client: connected.
Server DateTime is: [07/11/2017 09:20:53.518.739.000]
Server objects:
Found 1 results.
[NAMESPACE] [NODEID] [BROWSE NAME] [DISPLAY NAME] [VALUE]
-------------------------------------------------------------------------------------------------------------------------------------------
0 2253 Server Server N/A
0 2254 ServerArray ServerArray [ "uri://DummyUri" ]
0 2255 NamespaceArray NamespaceArray[ "http://opcfoundation.org/UA/", "uri://DummyUri" ]
Type not supported:137
0 2256 ServerStatus ServerStatus 0
0 2267 ServiceLevel ServiceLevel 255
0 2268 ServerCapabilities ServerCapabilities N/A
0 2269 ServerProfileArray ServerProfileArray [ ]
0 2272 MinSupportedSampleRate MinSupportedSampleRate 50
0 2735 MaxBrowseContinuationPoints MaxBrowseContinuationPoints 10
0 2736 MaxQueryContinuationPoints MaxQueryContinuationPoints 0
0 2737 MaxHistoryContinuationPoints MaxHistoryContinuationPoints 0
Type not supported:14
0 3704 SoftwareCertificates SoftwareCertificates 0
0 11702 MaxArrayLength MaxArrayLength 256
0 11703 MaxStringLength MaxStringLength 4096
0 11704 OperationLimits OperationLimits N/A
0 11705 MaxNodesPerRead MaxNodesPerRead 100
0 12165 MaxNodesPerHistoryReadData MaxNodesPerHistoryReadData 100
0 12166 MaxNodesPerHistoryReadEvents MaxNodesPerHistoryReadEvents 100
0 11707 MaxNodesPerWrite MaxNodesPerWrite 100
0 12167 MaxNodesPerHistoryUpdateData MaxNodesPerHistoryUpdateData 100
0 12168 MaxNodesPerHistoryUpdateEvents MaxNodesPerHistoryUpdateEvents 100
0 11709 MaxNodesPerMethodCall MaxNodesPerMethodCall 100
0 11710 MaxNodesPerBrowse MaxNodesPerBrowse 100
0 11711 MaxNodesPerRegisterNodes MaxNodesPerRegisterNodes 100
0 11712MaxNodesPerTranslateBrowsePathsToNodeIdsMaxNodesPerTranslateBrowsePathsToNodeIds 100
0 11713 MaxNodesPerNodeManagement MaxNodesPerNodeManagement 100
0 11714 MaxMonitoredItemsPerCall MaxMonitoredItemsPerCall 100
0 2996 ModellingRules ModellingRules N/A
0 2997 AggregateFunctions AggregateFunctions N/A
0 2274 ServerDiagnostics ServerDiagnostics N/A
0 3706 SessionsDiagnosticsSummary SessionsDiagnosticsSummary N/A
0 2294 EnabledFlag EnabledFlag false
0 2994 Auditing Auditing false
0 2295 VendorServerInfo VendorServerInfo N/A
0 2296 ServerRedundancy ServerRedundancy N/A
0 3709 RedundancySupport RedundancySupport 0
1/ObjectsFolder/MyFolder MyFolder MyFolder N/A
1Objects/MyFolder/MyStoredVariable MyStoredVariable MyStoredVariable 0
1Objects/MyFolder/MySynchronousVariable MySynchronousVariable MySynchronousVariable 0
1Objects/MyFolder/MyAsynchronousVariable MyAsynchronousVariable MyAsynchronousVariable 2
OPC Client: disconnected.
That concludes our exploration of the macchina.io OPC examples.