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
96f3df31
Commit
96f3df31
authored
Apr 28, 2022
by
Ivan Tyagov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Define once, use multiple times.
parent
06563242
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
12 deletions
+25
-12
coupler/opc-ua-server/common.h
coupler/opc-ua-server/common.h
+18
-0
coupler/opc-ua-server/keep_alive_subscriber.h
coupler/opc-ua-server/keep_alive_subscriber.h
+7
-12
No files found.
coupler/opc-ua-server/common.h
View file @
96f3df31
...
@@ -64,6 +64,24 @@ char *randomString(size_t length)
...
@@ -64,6 +64,24 @@ char *randomString(size_t length)
return
randomString
;
return
randomString
;
}
}
char
*
convertInt2Str
(
int
my_int
){
/* Convert integer to string */
int
length
=
snprintf
(
NULL
,
0
,
"%d"
,
my_int
);
char
*
my_str
=
malloc
(
length
+
1
);
snprintf
(
my_str
,
length
+
1
,
"%d"
,
my_int
);
return
my_str
;
}
char
*
convertLongInt2Str
(
long
int
my_int
){
/* Convert integer to string */
int
length
=
snprintf
(
NULL
,
0
,
"%ld"
,
my_int
);
char
*
my_str
=
malloc
(
length
+
1
);
snprintf
(
my_str
,
length
+
1
,
"%ld"
,
my_int
);
return
my_str
;
}
// XXX: dictionary implementation based on https://gist.github.com/kylef/86784/fe97567ec9baf5c0dce3c7fcbec948e21dfcce09
// XXX: dictionary implementation based on https://gist.github.com/kylef/86784/fe97567ec9baf5c0dce3c7fcbec948e21dfcce09
typedef
struct
dict_t_struct
{
typedef
struct
dict_t_struct
{
...
...
coupler/opc-ua-server/keep_alive_subscriber.h
View file @
96f3df31
...
@@ -19,6 +19,7 @@ UA_DataSetReaderConfig readerConfig;
...
@@ -19,6 +19,7 @@ UA_DataSetReaderConfig readerConfig;
static
void
fillTestDataSetMetaData
(
UA_DataSetMetaDataType
*
pMetaData
);
static
void
fillTestDataSetMetaData
(
UA_DataSetMetaDataType
*
pMetaData
);
/* callback to handle change notifications */
/* callback to handle change notifications */
static
void
dataChangeNotificationCallback
(
UA_Server
*
server
,
UA_UInt32
monitoredItemId
,
static
void
dataChangeNotificationCallback
(
UA_Server
*
server
,
UA_UInt32
monitoredItemId
,
void
*
monitoredItemContext
,
const
UA_NodeId
*
nodeId
,
void
*
monitoredItemContext
,
const
UA_NodeId
*
nodeId
,
...
@@ -34,15 +35,11 @@ static void dataChangeNotificationCallback(UA_Server *server, UA_UInt32 monitore
...
@@ -34,15 +35,11 @@ static void dataChangeNotificationCallback(UA_Server *server, UA_UInt32 monitore
//HEART_BEAT_ID_LIST
//HEART_BEAT_ID_LIST
UA_LOG_INFO
(
UA_Log_Stdout
,
UA_LOGCATEGORY_USERLAND
,
"Got heart beat from ID = %d, timestamp=%ld"
,
coupler_id
,
micro_seconds
);
UA_LOG_INFO
(
UA_Log_Stdout
,
UA_LOGCATEGORY_USERLAND
,
"Got heart beat from ID = %d, timestamp=%ld"
,
coupler_id
,
micro_seconds
);
// convert coupler_id to str (XXX: define as a function)
// convert coupler_id to str
int
length
=
snprintf
(
NULL
,
0
,
"%d"
,
coupler_id
);
char
*
coupler_id_str
=
convertInt2Str
(
coupler_id
);
char
*
coupler_id_str
=
malloc
(
length
+
1
);
snprintf
(
coupler_id_str
,
length
+
1
,
"%d"
,
coupler_id
);
// convert micro seconds to str (XXX: define as afunction)
// convert micro seconds to str
length
=
snprintf
(
NULL
,
0
,
"%ld"
,
micro_seconds
);
char
*
micro_seconds_str
=
convertLongInt2Str
(
micro_seconds
);
char
*
micro_seconds_str
=
malloc
(
length
+
1
);
snprintf
(
micro_seconds_str
,
length
+
1
,
"%ld"
,
micro_seconds
);
// XXX: implement check for dead couplers using asynchronous callbacks from open62541
// XXX: implement check for dead couplers using asynchronous callbacks from open62541
int
i
,
id
;
int
i
,
id
;
...
@@ -50,10 +47,8 @@ static void dataChangeNotificationCallback(UA_Server *server, UA_UInt32 monitore
...
@@ -50,10 +47,8 @@ static void dataChangeNotificationCallback(UA_Server *server, UA_UInt32 monitore
for
(
int
i
=
0
;
i
<
n
;
i
++
)
{
for
(
int
i
=
0
;
i
<
n
;
i
++
)
{
id
=
HEART_BEAT_ID_LIST
[
i
];
id
=
HEART_BEAT_ID_LIST
[
i
];
if
(
id
>
0
)
{
if
(
id
>
0
)
{
// XXX: define as a function
// convert to str as this is the hash key
length
=
snprintf
(
NULL
,
0
,
"%d"
,
id
);
char
*
id_str
=
convertInt2Str
(
id
);
char
*
id_str
=
malloc
(
length
+
1
);
snprintf
(
id_str
,
length
+
1
,
"%d"
,
id
);
char
*
last_seen_timestamp
=
getItem
(
SUBSCRIBER_DICT
,
id_str
);
char
*
last_seen_timestamp
=
getItem
(
SUBSCRIBER_DICT
,
id_str
);
UA_LOG_INFO
(
UA_Log_Stdout
,
UA_LOGCATEGORY_USERLAND
,
"
\t
check ID=%s, last_seen=%s"
,
id_str
,
last_seen_timestamp
);
UA_LOG_INFO
(
UA_Log_Stdout
,
UA_LOGCATEGORY_USERLAND
,
"
\t
check ID=%s, last_seen=%s"
,
id_str
,
last_seen_timestamp
);
if
(
last_seen_timestamp
!=
NULL
){
if
(
last_seen_timestamp
!=
NULL
){
...
...
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