Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
osie
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nikola Balog
osie
Commits
abad3a39
Commit
abad3a39
authored
Apr 13, 2022
by
Ivan Tyagov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP: Add 3 Pub/Sub variables.
parent
69b7b0e5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
69 additions
and
1 deletion
+69
-1
coupler/opc-ua-server/keep_alive.h
coupler/opc-ua-server/keep_alive.h
+39
-0
coupler/opc-ua-server/server.c
coupler/opc-ua-server/server.c
+30
-1
No files found.
coupler/opc-ua-server/keep_alive.h
View file @
abad3a39
...
...
@@ -112,3 +112,42 @@ static void addDataSetWriter(UA_Server *server) {
UA_Server_addDataSetWriter
(
server
,
writerGroupIdent
,
publishedDataSetIdent
,
&
dataSetWriterConfig
,
&
dataSetWriterIdent
);
}
// XXX: work of LEO which to integrate above
typedef
struct
PublishedVariable
{
char
*
name
;
char
*
description
;
void
*
UA_RESTRICT
pdefaultValue
;
UA_DataType
type
;
}
PublishedVariable
;
static
void
addPubSubVariable
(
UA_Server
*
server
,
PublishedVariable
varDetails
)
{
UA_VariableAttributes
attr
=
UA_VariableAttributes_default
;
UA_Variant_setScalar
(
&
attr
.
value
,
varDetails
.
pdefaultValue
,
&
varDetails
.
type
);
attr
.
description
=
UA_LOCALIZEDTEXT
(
"en-US"
,
varDetails
.
description
);
attr
.
displayName
=
UA_LOCALIZEDTEXT
(
"en-US"
,
varDetails
.
description
);
attr
.
dataType
=
varDetails
.
type
.
typeId
;
attr
.
accessLevel
=
UA_ACCESSLEVELMASK_READ
|
UA_ACCESSLEVELMASK_WRITE
;
UA_Server_addVariableNode
(
server
,
UA_NODEID_STRING
(
1
,
varDetails
.
name
),
UA_NODEID_NUMERIC
(
0
,
UA_NS0ID_OBJECTSFOLDER
),
UA_NODEID_NUMERIC
(
0
,
UA_NS0ID_ORGANIZES
),
UA_QUALIFIEDNAME
(
1
,
varDetails
.
description
),
UA_NODEID_NUMERIC
(
0
,
UA_NS0ID_BASEDATAVARIABLETYPE
),
attr
,
NULL
,
NULL
);
}
static
void
addPubSubDataSetField
(
UA_Server
*
server
,
PublishedVariable
varDetails
)
{
UA_NodeId
dataSetFieldIdent
;
UA_DataSetFieldConfig
dataSetFieldConfig
;
memset
(
&
dataSetFieldConfig
,
0
,
sizeof
(
UA_DataSetFieldConfig
));
dataSetFieldConfig
.
dataSetFieldType
=
UA_PUBSUB_DATASETFIELD_VARIABLE
;
dataSetFieldConfig
.
field
.
variable
.
fieldNameAlias
=
UA_STRING
(
varDetails
.
description
);
dataSetFieldConfig
.
field
.
variable
.
promotedField
=
UA_FALSE
;
dataSetFieldConfig
.
field
.
variable
.
publishParameters
.
publishedVariable
=
UA_NODEID_STRING
(
1
,
varDetails
.
name
);
dataSetFieldConfig
.
field
.
variable
.
publishParameters
.
attributeId
=
UA_ATTRIBUTEID_VALUE
;
UA_Server_addDataSetField
(
server
,
publishedDataSetIdent
,
&
dataSetFieldConfig
,
&
dataSetFieldIdent
);
}
coupler/opc-ua-server/server.c
View file @
abad3a39
...
...
@@ -34,6 +34,8 @@
#include <open62541/plugin/pubsub_ethernet.h>
#include <open62541/plugin/pubsub_udp.h>
#define countof(a) (sizeof(a)/sizeof(*(a)))
// The default port of OPC-UA server
const
int
DEFAULT_OPC_UA_PORT
=
4840
;
const
int
DEFAULT_MODE
=
0
;
...
...
@@ -226,6 +228,29 @@ int main(int argc, char **argv)
#endif
// enable keep-alive
UA_Float
defaultFloat
=
0
;
UA_Double
defaultDouble
=
0
;
const
PublishedVariable
publishedVariableArray
[]
=
{
{
.
name
=
"lattitude"
,
.
description
=
"Lattitude"
,
.
pdefaultValue
=
&
defaultDouble
,
.
type
=
UA_TYPES
[
UA_TYPES_DOUBLE
],
},
{
.
name
=
"longitude"
,
.
description
=
"Longitude"
,
.
pdefaultValue
=
&
defaultDouble
,
.
type
=
UA_TYPES
[
UA_TYPES_DOUBLE
],
},
{
.
name
=
"altitude"
,
.
description
=
"Altitude"
,
.
pdefaultValue
=
&
defaultFloat
,
.
type
=
UA_TYPES
[
UA_TYPES_FLOAT
],
},
};
UA_String
transportProfile
=
UA_STRING
(
"http://opcfoundation.org/UA-Profile/Transport/pubsub-udp-uadp"
);
UA_NetworkAddressUrlDataType
networkAddressUrl
=
...
...
@@ -238,7 +263,11 @@ int main(int argc, char **argv)
addPubSubConnection
(
server
,
&
transportProfile
,
&
networkAddressUrl
);
addPublishedDataSet
(
server
);
addDataSetField
(
server
);
//addDataSetField(server);
for
(
i
=
0
;
i
<
countof
(
publishedVariableArray
);
i
++
)
{
addPubSubVariable
(
server
,
publishedVariableArray
[
i
]);
addPubSubDataSetField
(
server
,
publishedVariableArray
[
i
]);
}
addWriterGroup
(
server
);
addDataSetWriter
(
server
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment