Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Zepeng Liu
OPC UA PubSub
Commits
633bce5a
Commit
633bce5a
authored
Jun 11, 2018
by
Patrick Bellot
Browse files
Merge remote-tracking branch 'origin/linux64_ingopcs2' into linux32_ingopcs2
parents
d62d4939
12803b71
Changes
45
Expand all
Hide whitespace changes
Inline
Side-by-side
opcua-client/.cproject
View file @
633bce5a
...
...
@@ -49,13 +49,14 @@
<tool
id=
"cdt.managedbuild.tool.gnu.cpp.linker.exe.debug.264726240"
name=
"GCC C++ Linker"
superClass=
"cdt.managedbuild.tool.gnu.cpp.linker.exe.debug"
>
<option
id=
"gnu.cpp.link.option.libs.1117397115"
name=
"Libraries (-l)"
superClass=
"gnu.cpp.link.option.libs"
useByScannerDiscovery=
"false"
valueType=
"libs"
>
<listOptionValue
builtIn=
"false"
value=
"opcua"
/>
<listOptionValue
builtIn=
"false"
value=
"
ingopcs
"
/>
<listOptionValue
builtIn=
"false"
value=
"
s2opc_stack
"
/>
<listOptionValue
builtIn=
"false"
value=
"mbedtls"
/>
<listOptionValue
builtIn=
"false"
value=
"mbedcrypto"
/>
<listOptionValue
builtIn=
"false"
value=
"mbedx509"
/>
</option>
<option
id=
"gnu.cpp.link.option.paths.306338987"
name=
"Library search path (-L)"
superClass=
"gnu.cpp.link.option.paths"
useByScannerDiscovery=
"false"
valueType=
"libPaths"
>
<listOptionValue
builtIn=
"false"
value=
""${workspace_loc:/opcua}/Debug""
/>
<listOptionValue
builtIn=
"false"
value=
""${workspace_loc:/mbedtls}/Debug""
/>
<listOptionValue
builtIn=
"false"
value=
""${workspace_loc:/ingopcs}/Debug""
/>
<listOptionValue
builtIn=
"false"
value=
""${workspace_loc:/s2opc_stack}/Debug""
/>
</option>
<option
id=
"gnu.cpp.link.option.flags.1880234795"
name=
"Linker flags"
superClass=
"gnu.cpp.link.option.flags"
useByScannerDiscovery=
"false"
value=
"-pthread"
valueType=
"string"
/>
<inputType
id=
"cdt.managedbuild.tool.gnu.cpp.linker.input.1745689070"
superClass=
"cdt.managedbuild.tool.gnu.cpp.linker.input"
>
...
...
@@ -77,9 +78,10 @@
</folderInfo>
<folderInfo
id=
"cdt.managedbuild.config.gnu.exe.debug.416750145.665078728"
name=
"/"
resourcePath=
"client"
>
<toolChain
id=
"cdt.managedbuild.toolchain.gnu.exe.debug.1935986400"
name=
"Linux GCC"
superClass=
"cdt.managedbuild.toolchain.gnu.exe.debug"
unusedChildren=
""
>
<targetPlatform
id=
"cdt.managedbuild.target.gnu.platform.exe.debug"
name=
"Debug Platform"
superClass=
"cdt.managedbuild.target.gnu.platform.exe.debug"
/>
<tool
id=
"cdt.managedbuild.tool.gnu.archiver.base.281808316"
name=
"GCC Archiver"
superClass=
"cdt.managedbuild.tool.gnu.archiver.base.180226217"
/>
<tool
id=
"cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug.98487614"
name=
"GCC C++ Compiler"
superClass=
"cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug.443247346"
>
<option
id=
"gnu.cpp.compiler.option.include.paths.1291081052"
superClass=
"gnu.cpp.compiler.option.include.paths"
useByScannerDiscovery=
"false"
valueType=
"includePath"
>
<option
id=
"gnu.cpp.compiler.option.include.paths.1291081052"
name=
"Include paths (-I)"
superClass=
"gnu.cpp.compiler.option.include.paths"
useByScannerDiscovery=
"false"
valueType=
"includePath"
>
<listOptionValue
builtIn=
"false"
value=
""${workspace_loc:/opcua}""
/>
<listOptionValue
builtIn=
"false"
value=
"../../../S2OPC/install_linux/include"
/>
<listOptionValue
builtIn=
"false"
value=
"../../../S2OPC/csrc/secure_channels"
/>
...
...
opcua-client/.project
View file @
633bce5a
...
...
@@ -4,6 +4,7 @@
<comment></comment>
<projects>
<project>
opcua
</project>
<project>
s2opc_stack
</project>
</projects>
<buildSpec>
<buildCommand>
...
...
opcua-client/client/Client_01_Subscription/Client_01.h
View file @
633bce5a
...
...
@@ -43,9 +43,9 @@ public:
void
run
()
{
int
nbExt
=
3
;
// Number of total loops from CreateSession to CloseSession
int
nbInt
=
5
;
// Number of internal loops
int
nbPub
=
20
;
// Number of publish inside internal loops
int
nbExt
=
10
;
// Number of total loops from CreateSession to CloseSession
int
nbInt
=
5
0
;
// Number of internal loops
int
nbPub
=
20
00
;
// Number of publish inside internal loops
SOPC_StatusCode
status
=
STATUS_OK
;
...
...
@@ -82,10 +82,12 @@ public:
&
revisedPublishingInterval
,
&
revisedLifetimeCount
,
&
revisedMaxKeepAliveCount
)
;
if
(
status
!=
STATUS_OK
)
{
debug_i
(
COM_ERR
,
"Client_01"
,
"Cannot CreateSubscription: status=0x%08x"
,
status
)
;
break
;
}
debug
(
MAIN_LIFE_DBG
,
"Client_01"
,
"CreateSubscription succeeds"
)
;
// INTERNAL LOOP
...
...
@@ -108,10 +110,12 @@ public:
&
monitoredItemId0
,
&
revisedSamplingInterval0
,
&
revisedQueueSize0
)
;
if
(
status
!=
STATUS_OK
)
{
debug_i
(
COM_ERR
,
"Client_01"
,
"Cannot CreateMonitoredItems(0): status=0x%08x"
,
status
)
;
break
;
}
debug
(
MAIN_LIFE_DBG
,
"Client_01"
,
"CreateMonitoredItems (0) succeeds"
)
;
// CREATE MONITORED ITEMS (1)
...
...
@@ -122,10 +126,12 @@ public:
&
monitoredItemId1
,
&
revisedSamplingInterval1
,
&
revisedQueueSize1
)
;
if
(
status
!=
STATUS_OK
)
{
debug_i
(
COM_ERR
,
"Client_01"
,
"Cannot CreateMonitoredItems (1): status=0x%08x"
,
status
)
;
break
;
}
debug
(
MAIN_LIFE_DBG
,
"Client_01"
,
"CreateMonitoredItems (1) succeeds"
)
;
// BEGINNING PUBLISH SEQUENCE
...
...
@@ -149,7 +155,7 @@ public:
}
// END PUBLISH SEQUENCE
if
(
(
sequenceNumber
)
)
if
(
sequenceNumber
!=
NULL
)
sequenceNumber
->
release
()
;
// DELETE MONITORED ITEMS
...
...
@@ -162,6 +168,7 @@ public:
debug_i
(
COM_ERR
,
"Client_01"
,
"Cannot DeleteMonitoredItems: status=0x%08x"
,
status
)
;
break
;
}
debug
(
MAIN_LIFE_DBG
,
"Client_01"
,
"DeleteMonitoredItems succeeds"
)
;
// DELETE CREATE MONITORED ITEMS (0) DATA
...
...
@@ -196,30 +203,8 @@ public:
public:
Client_01
(
SOPC_Channel
_hChannel
,
const
char
*
_sEndpointUrl
,
SOPC_String
*
_stEndpointUrl
,
String
*
_endPointUrl
,
Certificate
*
_crt_cli
,
AsymmetricKey
*
_priv_cli
,
Certificate
*
_crt_srv
,
PKIProvider
*
_pki
,
char
*
_pRequestedSecurityPolicyUri
,
OpcUa_MessageSecurityMode
_messageSecurityMode
)
:
BaseClient
(
_hChannel
,
_sEndpointUrl
,
_stEndpointUrl
,
_endPointUrl
,
_crt_cli
,
_priv_cli
,
_crt_srv
,
_pki
,
_pRequestedSecurityPolicyUri
,
_messageSecurityMode
)
Client_01
(
int
num
,
SOPC_SecureChannel_Config
*
pScConfig
,
uint32_t
channel_config_idx
,
String
*
endpointUrl
)
:
BaseClient
(
num
,
pScConfig
,
channel_config_idx
,
endpointUrl
)
{}
virtual
~
Client_01
()
...
...
@@ -251,7 +236,7 @@ private:
new
RequestHeader
(
SessionAuthenticationToken
::
nullNodeId
,
UtcTime
::
now
(),
new
IntegerId
(
sequence
),
new
IntegerId
(
sequence
<<
8
|
num
),
UInt32
::
zero
,
// ReturnDiagnostics
String
::
empty
,
// auditEntryId
UInt32
::
zero
// TimeoutHint
...
...
@@ -368,7 +353,7 @@ private:
new
RequestHeader
(
new
SessionAuthenticationToken
(
authenticationTokenNum
),
UtcTime
::
now
(),
new
IntegerId
(
sequence
),
new
IntegerId
(
sequence
<<
8
|
num
),
UInt32
::
zero
,
// ReturnDiagnostics
String
::
empty
,
// auditEntryId
new
UInt32
(
5000
)
// TimeoutHint
...
...
@@ -411,7 +396,7 @@ private:
new
RequestHeader
(
new
SessionAuthenticationToken
(
authenticationTokenNum
),
UtcTime
::
now
(),
new
IntegerId
(
sequence
),
new
IntegerId
(
sequence
<<
8
|
num
),
UInt32
::
zero
,
// ReturnDiagnostics
String
::
empty
,
// auditEntryId
new
UInt32
(
5000
)
// TimeoutHint
...
...
@@ -480,7 +465,7 @@ private:
new
RequestHeader
(
new
SessionAuthenticationToken
(
authenticationTokenNum
),
UtcTime
::
now
(),
new
IntegerId
(
sequence
),
new
IntegerId
(
sequence
<<
8
|
num
),
UInt32
::
zero
,
// ReturnDiagnostics
String
::
empty
,
// auditEntryId
UInt32
::
zero
// TimeoutHint
...
...
@@ -533,7 +518,7 @@ private:
new
RequestHeader
(
new
SessionAuthenticationToken
(
authenticationTokenNum
),
UtcTime
::
now
(),
new
IntegerId
(
sequence
),
new
IntegerId
(
sequence
<<
8
|
num
),
UInt32
::
zero
,
// ReturnDiagnostics
String
::
empty
,
// auditEntryId
UInt32
::
zero
// TimeoutHint
...
...
@@ -601,7 +586,7 @@ private:
QualifiedName
::
defaultBinary
)
;
MonitoringParameters
*
requestedParameters
=
new
MonitoringParameters
(
new
IntegerId
(
sequence
),
new
IntegerId
(
sequence
<<
8
|
num
),
new
Duration
(
200.0
),
DataChangeFilter
::
nullFilter
,
new
Counter
(
64
),
...
...
@@ -622,7 +607,7 @@ private:
new
RequestHeader
(
new
SessionAuthenticationToken
(
authenticationTokenNum
),
UtcTime
::
now
(),
new
IntegerId
(
sequence
),
new
IntegerId
(
sequence
<<
8
|
num
),
UInt32
::
zero
,
// ReturnDiagnostics
String
::
empty
,
// auditEntryId
UInt32
::
zero
// TimeoutHint
...
...
@@ -695,7 +680,7 @@ private:
new
RequestHeader
(
new
SessionAuthenticationToken
(
authenticationTokenNum
),
UtcTime
::
now
(),
new
IntegerId
(
sequence
),
new
IntegerId
(
sequence
<<
8
|
num
),
UInt32
::
zero
,
// ReturnDiagnostics
String
::
empty
,
// auditEntryId
UInt32
::
zero
// TimeoutHint
...
...
@@ -766,7 +751,7 @@ private:
new
RequestHeader
(
new
SessionAuthenticationToken
(
authenticationTokenNum
),
UtcTime
::
now
(),
new
IntegerId
(
sequence
),
new
IntegerId
(
sequence
<<
8
|
num
),
UInt32
::
zero
,
// ReturnDiagnostics
String
::
empty
,
// auditEntryId
UInt32
::
zero
// TimeoutHint
...
...
opcua-client/client/Client_01_Subscription/StartClients_01.h
View file @
633bce5a
...
...
@@ -21,8 +21,17 @@
#define STARTCLIENTS_01_H_
#include "lib/Stacks/All.h"
#include "Client_01.h"
#include "../OpcUa_BaseClient.h"
#include "../Client_01_Subscription/Client_01.h"
#include <sopc_toolkit_config.h>
extern
"C"
{
extern
opcua
::
BaseClient
**
the_clients
;
extern
int
the_nbClients
;
}
#if (WITH_SUBSCRIPTION == 1)
...
...
@@ -33,54 +42,42 @@ class StartClients_01
public:
static
SOPC_StatusCode
startClients
(
const
char
*
sEndpointUrl
,
SOPC_String
*
stEndpointUrl
,
String
*
endpointUrl
,
Certificate
*
crt_cli
,
AsymmetricKey
*
priv_cli
,
Certificate
*
crt_srv
,
PKIProvider
*
pki
,
const
char
*
pRequestedSecurityPolicyUri
,
OpcUa_MessageSecurityMode
messageSecurityMode
SOPC_SecureChannel_Config
*
pScConfig
)
{
int
nbClient
=
5
;
// Number of client threads
int
nbTry
=
2
;
// Number of total loops from OpenSecureChannel to CloseSecureChannel
int
nbClient
s
=
3
;
// Number of client threads
int
nbTry
=
10
;
// Number of total loops from OpenSecureChannel to CloseSecureChannel
SOPC_Channel
hC
hannel
=
NULL
;
uint32_t
c
hannel
_config_idx
=
0
;
Client_01
**
clients
=
NULL
;
SOPC_StatusCode
status
=
STATUS_OK
;
// CREATING CHANNEL CONFIGURATION
channel_config_idx
=
SOPC_ToolkitClient_AddSecureChannelConfig
(
pScConfig
);
if
(
channel_config_idx
==
0
)
{
debug
(
COM_ERR
,
"StartClientss_02"
,
"Cannot add secure channel config"
)
;
goto
error
;
}
else
{
debug_i
(
IPCS_DBG
,
"StartClients_02"
,
"channel_config_idx=%d"
,
channel_config_idx
)
;
}
SOPC_Toolkit_Configured
()
;
debug
(
MAIN_LIFE_DBG
,
"StartClients_02"
,
"Open Secure Channels config succeeds"
)
;
// EXTERNAL LOOP
while
(
--
nbTry
>=
0
)
{
// CREATING CHANNEL
debug
(
MAIN_LIFE_DBG
,
"StartClients_01"
,
"Create channel"
)
;
status
=
SOPC_Channel_Create
(
&
hChannel
,
SOPC_ChannelSerializer_Binary
);
if
(
STATUS_OK
!=
status
)
{
debug_i
(
COM_ERR
,
"StartClients_01"
,
"Create channel failed: status=0x%08x"
,
status
)
;
goto
error
;
}
// CREATING CLIENTS
debug
(
MAIN_LIFE_DBG
,
"StartClients_02"
,
"Building clients"
)
;
clients
=
new
Client_01
*
[
nbClients
]
;
for
(
int
i
=
0
;
i
<
nbClients
;
i
++
)
clients
[
i
]
=
new
Client_01
(
i
,
pScConfig
,
channel_config_idx
,
endpointUrl
)
;
// CREATING CLIENT
debug
(
MAIN_LIFE_DBG
,
"StartClients_01"
,
"Building clients"
)
;
clients
=
new
Client_01
*
[
nbClient
]
;
for
(
int
i
=
0
;
i
<
nbClient
;
i
++
)
clients
[
i
]
=
new
Client_01
(
hChannel
,
sEndpointUrl
,
stEndpointUrl
,
endpointUrl
,
crt_cli
,
priv_cli
,
crt_srv
,
pki
,
(
char
*
)
pRequestedSecurityPolicyUri
,
messageSecurityMode
)
;
the_clients
=
(
BaseClient
**
)
clients
;
the_nbClients
=
nbClients
;
// OPEN SECURE CHANNEL
...
...
@@ -95,14 +92,14 @@ public:
// STARTING CLIENTS
debug
(
MAIN_LIFE_DBG
,
"StartClients_01"
,
"Starting clients"
)
;
for
(
int
i
=
0
;
i
<
nbClient
;
i
++
)
for
(
int
i
=
0
;
i
<
nbClient
s
;
i
++
)
clients
[
i
]
->
start
()
;
debug
(
MAIN_LIFE_DBG
,
"StartClients_01"
,
"Starting clients succeeds"
)
;
// WAITING FOR CLIENTS
debug
(
MAIN_LIFE_DBG
,
"StartClients_01"
,
"Waiting for clients"
)
;
for
(
int
i
=
0
;
i
<
nbClient
;
i
++
)
for
(
int
i
=
0
;
i
<
nbClient
s
;
i
++
)
clients
[
i
]
->
join
()
;
debug
(
MAIN_LIFE_DBG
,
"StartClients_01"
,
"Waiting for clients succeeds"
)
;
...
...
@@ -117,20 +114,9 @@ public:
debug
(
MAIN_LIFE_DBG
,
"StartClients_01"
,
"Close Secure Channel succeeds"
)
;
// DELETING CHANNEL
debug
(
MAIN_LIFE_DBG
,
"StartClients_01"
,
"Delete channel"
)
;
status
=
SOPC_Channel_Delete
(
&
hChannel
);
hChannel
=
NULL
;
if
(
STATUS_OK
!=
status
)
{
debug_i
(
COM_ERR
,
"StartClients_01"
,
"Delete channel failed: status=0x%08x"
,
status
)
;
goto
error
;
}
debug
(
MAIN_LIFE_DBG
,
"StartClients_01"
,
"Delete channel succeeds"
)
;
// DELETING CLIENTS
debug
(
MAIN_LIFE_DBG
,
"StartClients_01"
,
"Deleting clients"
)
;
for
(
int
i
=
0
;
i
<
nbClient
;
i
++
)
for
(
int
i
=
0
;
i
<
nbClient
s
;
i
++
)
delete
clients
[
i
]
;
delete
[]
clients
;
clients
=
NULL
;
...
...
@@ -139,6 +125,8 @@ public:
}
// while (--nbTry >= 0)
SOPC_Toolkit_Clear
();
debug_i
(
MAIN_LIFE_DBG
,
"StartClients_01"
,
"Stopping with status=0x%08x"
,
STATUS_OK
)
;
return
STATUS_OK
;
...
...
@@ -146,15 +134,14 @@ public:
error:
debug
(
MAIN_LIFE_DBG
,
"StartClients_01"
,
"Releasing memory with error"
)
;
if
(
hChannel
!=
NULL
)
SOPC_Channel_Delete
(
&
hChannel
);
if
(
clients
!=
NULL
)
{
for
(
int
i
=
0
;
i
<
nbClient
;
i
++
)
for
(
int
i
=
0
;
i
<
nbClient
s
;
i
++
)
delete
clients
[
i
]
;
delete
[]
clients
;
}
SOPC_Toolkit_Clear
();
debug_i
(
MAIN_LIFE_DBG
,
"StartClients_01"
,
"Stopping with error, status=0x%08x"
,
status
)
;
return
status
;
}
...
...
opcua-client/client/Client_02_Call/Client_02.h
View file @
633bce5a
...
...
@@ -94,35 +94,14 @@ public:
public:
Client_02
(
SOPC_Channel
_hChannel
,
const
char
*
_sEndpointUrl
,
SOPC_String
*
_stEndpointUrl
,
String
*
_endPointUrl
,
Certificate
*
_crt_cli
,
AsymmetricKey
*
_priv_cli
,
Certificate
*
_crt_srv
,
PKIProvider
*
_pki
,
char
*
_pRequestedSecurityPolicyUri
,
OpcUa_MessageSecurityMode
_messageSecurityMode
)
:
BaseClient
(
_hChannel
,
_sEndpointUrl
,
_stEndpointUrl
,
_endPointUrl
,
_crt_cli
,
_priv_cli
,
_crt_srv
,
_pki
,
_pRequestedSecurityPolicyUri
,
_messageSecurityMode
)
Client_02
(
int
num
,
SOPC_SecureChannel_Config
*
pScConfig
,
uint32_t
channel_config_idx
,
String
*
endpointUrl
)
:
BaseClient
(
num
,
pScConfig
,
channel_config_idx
,
endpointUrl
)
{}
virtual
~
Client_02
()
{}
public:
SOPC_StatusCode
createSession
()
...
...
@@ -149,7 +128,7 @@ public:
new
RequestHeader
(
SessionAuthenticationToken
::
nullNodeId
,
UtcTime
::
now
(),
new
IntegerId
(
sequence
),
new
IntegerId
(
sequence
<<
8
|
num
),
UInt32
::
zero
,
// ReturnDiagnostics
String
::
empty
,
// auditEntryId
UInt32
::
zero
// TimeoutHint
...
...
@@ -266,7 +245,7 @@ public:
new
RequestHeader
(
new
SessionAuthenticationToken
(
authenticationTokenNum
),
UtcTime
::
now
(),
new
IntegerId
(
sequence
),
new
IntegerId
(
sequence
<<
8
|
num
),
UInt32
::
zero
,
// ReturnDiagnostics
String
::
empty
,
// auditEntryId
new
UInt32
(
5000
)
// TimeoutHint
...
...
@@ -309,7 +288,7 @@ public:
new
RequestHeader
(
new
SessionAuthenticationToken
(
authenticationTokenNum
),
UtcTime
::
now
(),
new
IntegerId
(
sequence
),
new
IntegerId
(
sequence
<<
8
|
num
),
UInt32
::
zero
,
// ReturnDiagnostics
String
::
empty
,
// auditEntryId
new
UInt32
(
5000
)
// TimeoutHint
...
...
@@ -378,7 +357,7 @@ public:
new
RequestHeader
(
new
SessionAuthenticationToken
(
authenticationTokenNum
),
UtcTime
::
now
(),
new
IntegerId
(
sequence
),
new
IntegerId
(
sequence
<<
8
|
num
),
UInt32
::
zero
,
// ReturnDiagnostics
String
::
empty
,
// auditEntryId
UInt32
::
zero
// TimeoutHint
...
...
@@ -446,7 +425,7 @@ public:
new
RequestHeader
(
new
SessionAuthenticationToken
(
authenticationTokenNum
),
UtcTime
::
now
(),
new
IntegerId
(
sequence
),
new
IntegerId
(
sequence
<<
8
|
num
),
UInt32
::
zero
,
// ReturnDiagnostics
String
::
empty
,
// auditEntryId
UInt32
::
zero
),
// TimeoutHint
...
...
@@ -471,7 +450,7 @@ public:
CallMethodResult
*
result
=
results
->
get
(
i
);
StatusCode
*
statusCode
=
result
->
getStatusCode
();
debug_ii
(
MAIN_LIFE_DBG
,
"Client_02"
,
" Results number %d, status=0x08x"
,
i
,
statusCode
->
get
())
;
debug_ii
(
MAIN_LIFE_DBG
,
"Client_02"
,
" Results number %d, status=0x
%
08x"
,
i
,
statusCode
->
get
())
;
TableVariant
*
outputArguments
=
result
->
getOutputArguments
();
int32_t
len
=
outputArguments
->
getLength
();
...
...
opcua-client/client/Client_02_Call/StartClients_02.h
View file @
633bce5a
...
...
@@ -21,8 +21,17 @@
#define STARTCLIENTS_02_H_
#include "lib/Stacks/All.h"
#include "Client_02.h"
#include "../OpcUa_BaseClient.h"
#include <sopc_toolkit_config.h>
extern
"C"
{
extern
opcua
::
BaseClient
**
the_clients
;
extern
int
the_nbClients
;
}
#if (WITH_CALL == 1)
...
...
@@ -33,54 +42,43 @@ class StartClients_02
public:
static
SOPC_StatusCode
startClients
(
const
char
*
sEndpointUrl
,
SOPC_String
*
stEndpointUrl
,
String
*
endpointUrl
,
Certificate
*
crt_cli
,
AsymmetricKey
*
priv_cli
,
Certificate
*
crt_srv
,
PKIProvider
*
pki
,
const
char
*
pRequestedSecurityPolicyUri
,
OpcUa_MessageSecurityMode
messageSecurityMode
SOPC_SecureChannel_Config
*
pScConfig
)
{
int
nbClient
=
5
;
// Number of client threads
int
nbClient
s
=
5
;
// Number of client threads
int
nbTry
=
5
;
// Number of total loops from OpenSecureChannel to CloseSecureChannel
SOPC_Channel
hChannel
=
NULL
;
Client_02
**
clients
=
NULL
;
SOPC_StatusCode
status
=
STATUS_OK
;
uint32_t
channel_config_idx
=
0
;
Client_02
**
clients
=
NULL
;
SOPC_StatusCode
status
=
STATUS_OK
;
// CREATING CHANNEL CONFIGURATION
channel_config_idx
=
SOPC_ToolkitClient_AddSecureChannelConfig
(
pScConfig
);
if
(
channel_config_idx
==
0
)
{
debug
(
COM_ERR
,
"StartClientss_02"
,
"Cannot add secure channel config"
)
;
goto
error
;
}
else
{
debug_i
(
IPCS_DBG
,
"StartClients_02"
,
"channel_config_idx=%d"
,
channel_config_idx
)
;
}
SOPC_Toolkit_Configured
()
;
debug
(
MAIN_LIFE_DBG
,
"StartClients_02"
,
"Open Secure Channels config succeeds"
)
;
// EXTERNAL LOOP
while
(
--
nbTry
>=
0
)
{
// CREATING CHANNEL
debug
(
MAIN_LIFE_DBG
,
"StartClients_02"
,
"Create channel"
)
;
status
=
SOPC_Channel_Create
(
&
hChannel
,
SOPC_ChannelSerializer_Binary
);
if
(
STATUS_OK
!=
status
)
{
debug_i
(
COM_ERR
,
"StartClients_02"
,
"Create channel failed: status=0x%08x"
,
status
)
;
goto
error
;
}
// CREATING CLIENT
// CREATING CLIENT
S
debug
(
MAIN_LIFE_DBG
,
"StartClients_02"
,
"Building clients"
)
;
clients
=
new
Client_02
*
[
nbClient
]
;
for
(
int
i
=
0
;
i
<
nbClient
;
i
++
)
clients
[
i
]
=
new
Client_02
(
hChannel
,
sEndpointUrl
,
stEndpointUrl
,
endpointUrl
,
crt_cli
,
priv_cli
,
crt_srv
,
pki
,
(
char
*
)
pRequestedSecurityPolicyUri
,
messageSecurityMode
)
;
clients
=
new
Client_02
*
[
nbClients
]
;
for
(
int
i
=
0
;
i
<
nbClients
;
i
++
)
clients
[
i
]
=
new
Client_02
(
i
,
pScConfig
,
channel_config_idx
,
endpointUrl
)
;
the_clients
=
(
BaseClient
**
)
clients
;
the_nbClients
=
nbClients
;
// OPEN SECURE CHANNEL
...
...
@@ -95,14 +93,14 @@ public:
// STARTING CLIENTS
debug
(
MAIN_LIFE_DBG
,
"StartClients_02"
,
"Starting clients"
)
;
for
(
int
i
=
0
;
i
<
nbClient
;
i
++
)
for
(
int
i
=
0
;
i
<
nbClient
s
;
i
++
)
clients
[
i
]
->
start
()
;
debug
(
MAIN_LIFE_DBG
,
"StartClients_02"
,
"Starting clients succeeds"
)
;
// WAITING FOR CLIENTS
debug
(
MAIN_LIFE_DBG
,
"StartClients_02"
,
"Waiting for clients"
)
;
for
(
int
i
=
0
;
i
<
nbClient
;
i
++
)
for
(
int
i
=
0
;
i
<
nbClient
s
;
i
++
)
clients
[
i
]
->
join
()
;
debug
(
MAIN_LIFE_DBG
,
"StartClients_02"
,
"Waiting for clients succeeds"
)
;
...
...
@@ -116,21 +114,9 @@ public:
}
debug
(
MAIN_LIFE_DBG
,
"StartClients_02"
,
"Close Secure Channel succeeds"
)
;
// DELETING CHANNEL
debug
(
MAIN_LIFE_DBG
,
"StartClients_02"
,
"Delete channel"
)
;
status
=
SOPC_Channel_Delete
(
&
hChannel
);
hChannel
=
NULL
;
if
(
STATUS_OK
!=
status
)
{
debug_i
(
COM_ERR
,
"StartClients_02"
,
"Delete channel failed: status=0x%08x"
,
status
)
;
goto
error
;
}
debug
(
MAIN_LIFE_DBG
,
"StartClients_02"
,
"Delete channel succeeds"
)
;
// DELETING CLIENTS