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
Martin Manchev
osie
Commits
181b82ce
Commit
181b82ce
authored
May 03, 2022
by
Ivan Tyagov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use proper variables.
parent
bb8124a7
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
7 deletions
+10
-7
coupler/opc-ua-server/common.h
coupler/opc-ua-server/common.h
+4
-1
coupler/opc-ua-server/keep_alive_subscriber.h
coupler/opc-ua-server/keep_alive_subscriber.h
+6
-6
No files found.
coupler/opc-ua-server/common.h
View file @
181b82ce
...
@@ -7,7 +7,10 @@
...
@@ -7,7 +7,10 @@
#include <open62541/server.h>
#include <open62541/server.h>
int
getMicroSeconds
()
{
int
getMilliSecondsSinceEpoch
()
{
/*
* Return milli seconds since epoch
*/
struct
timeval
current_time
;
struct
timeval
current_time
;
gettimeofday
(
&
current_time
,
NULL
);
gettimeofday
(
&
current_time
,
NULL
);
long
int
ms
=
current_time
.
tv_sec
*
1000
+
current_time
.
tv_usec
/
1000
;
long
int
ms
=
current_time
.
tv_sec
*
1000
+
current_time
.
tv_usec
/
1000
;
...
...
coupler/opc-ua-server/keep_alive_subscriber.h
View file @
181b82ce
...
@@ -25,7 +25,7 @@ static void dataChangeNotificationCallback(UA_Server *server, UA_UInt32 monitore
...
@@ -25,7 +25,7 @@ static void dataChangeNotificationCallback(UA_Server *server, UA_UInt32 monitore
void
*
monitoredItemContext
,
const
UA_NodeId
*
nodeId
,
void
*
monitoredItemContext
,
const
UA_NodeId
*
nodeId
,
void
*
nodeContext
,
UA_UInt32
attributeId
,
void
*
nodeContext
,
UA_UInt32
attributeId
,
const
UA_DataValue
*
var
)
{
const
UA_DataValue
*
var
)
{
long
int
mi
cro_seconds
=
getMicroSeconds
();
long
int
mi
lli_seconds_now
=
getMilliSecondsSinceEpoch
();
// filter out ID from Data Set
// filter out ID from Data Set
if
(
UA_Variant_hasScalarType
(
&
var
->
value
,
&
UA_TYPES
[
UA_TYPES_UINT32
]))
{
if
(
UA_Variant_hasScalarType
(
&
var
->
value
,
&
UA_TYPES
[
UA_TYPES_UINT32
]))
{
...
@@ -33,16 +33,16 @@ static void dataChangeNotificationCallback(UA_Server *server, UA_UInt32 monitore
...
@@ -33,16 +33,16 @@ static void dataChangeNotificationCallback(UA_Server *server, UA_UInt32 monitore
// care for other coupler_id NOT ourselves
// care for other coupler_id NOT ourselves
if
(
coupler_id
!=
COUPLER_ID
)
{
if
(
coupler_id
!=
COUPLER_ID
)
{
//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
,
mi
cro_seconds
);
UA_LOG_INFO
(
UA_Log_Stdout
,
UA_LOGCATEGORY_USERLAND
,
"Got heart beat from ID = %d, timestamp=%ld"
,
coupler_id
,
mi
lli_seconds_now
);
// convert coupler_id to str
// convert coupler_id to str
char
*
coupler_id_str
=
convertInt2Str
(
coupler_id
);
char
*
coupler_id_str
=
convertInt2Str
(
coupler_id
);
// convert micro seconds to str
// convert micro seconds to str
char
*
mi
cro_seconds_str
=
convertLongInt2Str
(
micro_seconds
);
char
*
mi
lli_seconds_now_str
=
convertLongInt2Str
(
milli_seconds_now
);
// Add to our local linked list
// Add to our local linked list
addItem
(
&
SUBSCRIBER_DICT
,
coupler_id_str
,
mi
cro_seconds
_str
);
addItem
(
&
SUBSCRIBER_DICT
,
coupler_id_str
,
mi
lli_seconds_now
_str
);
}
}
}
}
...
@@ -258,7 +258,7 @@ static void fillTestDataSetMetaData(UA_DataSetMetaDataType *pMetaData) {
...
@@ -258,7 +258,7 @@ static void fillTestDataSetMetaData(UA_DataSetMetaDataType *pMetaData) {
void
callbackCheckHeartBeat
()
{
void
callbackCheckHeartBeat
()
{
int
i
,
coupler_id
;
int
i
,
coupler_id
;
long
int
mi
cro_seconds
=
getMicroSeconds
();
long
int
mi
lli_seconds
=
getMilliSecondsSinceEpoch
();
size_t
n
=
sizeof
(
HEART_BEAT_ID_LIST
)
/
sizeof
(
HEART_BEAT_ID_LIST
[
0
]);
size_t
n
=
sizeof
(
HEART_BEAT_ID_LIST
)
/
sizeof
(
HEART_BEAT_ID_LIST
[
0
]);
for
(
int
i
=
0
;
i
<
n
;
i
++
)
{
for
(
int
i
=
0
;
i
<
n
;
i
++
)
{
coupler_id
=
HEART_BEAT_ID_LIST
[
i
];
coupler_id
=
HEART_BEAT_ID_LIST
[
i
];
...
@@ -270,7 +270,7 @@ void callbackCheckHeartBeat() {
...
@@ -270,7 +270,7 @@ void callbackCheckHeartBeat() {
if
(
last_seen_timestamp
!=
NULL
){
if
(
last_seen_timestamp
!=
NULL
){
// we do have timestamp for this coupler ID
// we do have timestamp for this coupler ID
int
last_seen_timestamp_int
=
atoi
(
last_seen_timestamp
);
int
last_seen_timestamp_int
=
atoi
(
last_seen_timestamp
);
int
timestamp_delta
=
mi
cro
_seconds
-
last_seen_timestamp_int
;
int
timestamp_delta
=
mi
lli
_seconds
-
last_seen_timestamp_int
;
bool
is_down
=
(
timestamp_delta
>
1000
);
bool
is_down
=
(
timestamp_delta
>
1000
);
UA_LOG_INFO
(
UA_Log_Stdout
,
UA_LOGCATEGORY_USERLAND
,
"
\t
delta=%d, is_down=%d"
,
timestamp_delta
,
is_down
);
UA_LOG_INFO
(
UA_Log_Stdout
,
UA_LOGCATEGORY_USERLAND
,
"
\t
delta=%d, is_down=%d"
,
timestamp_delta
,
is_down
);
}
}
...
...
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