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
nexedi
osie
Commits
c71159c3
Commit
c71159c3
authored
Oct 13, 2022
by
Ivan Tyagov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Coupler should know its state thus keep it accordingly.
parent
4678ad35
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
5 deletions
+29
-5
coupler/opc-ua-server/keep_alive.h
coupler/opc-ua-server/keep_alive.h
+9
-0
coupler/opc-ua-server/keep_alive_subscriber.h
coupler/opc-ua-server/keep_alive_subscriber.h
+15
-5
coupler/opc-ua-server/server.c
coupler/opc-ua-server/server.c
+5
-0
No files found.
coupler/opc-ua-server/keep_alive.h
View file @
c71159c3
...
@@ -5,6 +5,15 @@ char *NETWORK_ADDRESS_URL_DATA_TYPE = "opc.udp://224.0.0.22:4840/";
...
@@ -5,6 +5,15 @@ char *NETWORK_ADDRESS_URL_DATA_TYPE = "opc.udp://224.0.0.22:4840/";
// global HEART BEATs of coupler
// global HEART BEATs of coupler
static
unsigned
int
HEART_BEATS
=
0
;
static
unsigned
int
HEART_BEATS
=
0
;
// handling coupler's state
static
unsigned
int
CURRENT_STATE
;
const
int
STATE_UP
=
1
;
const
int
STATE_DOWN
=
0
;
const
int
STATE_NO_INITIAL_HEART_BEAT
=
2
;
// number of times the coupler was in SAFE mode
static
unsigned
int
SAFE_MODE_STATE_COUNTER
=
0
;
// the heart beat interval (in ms)
// the heart beat interval (in ms)
const
int
DEFAULT_HEART_BEAT_INTERVAL
=
250
;
const
int
DEFAULT_HEART_BEAT_INTERVAL
=
250
;
static
int
HEART_BEAT_INTERVAL
=
DEFAULT_HEART_BEAT_INTERVAL
;
static
int
HEART_BEAT_INTERVAL
=
DEFAULT_HEART_BEAT_INTERVAL
;
...
...
coupler/opc-ua-server/keep_alive_subscriber.h
View file @
c71159c3
...
@@ -300,15 +300,25 @@ void callbackCheckHeartBeat() {
...
@@ -300,15 +300,25 @@ void callbackCheckHeartBeat() {
timestamp_delta
=
milli_seconds
-
last_seen_timestamp_int
;
timestamp_delta
=
milli_seconds
-
last_seen_timestamp_int
;
is_down
=
(
timestamp_delta
>
HEART_BEAT_TIMEOUT_INTERVAL
);
is_down
=
(
timestamp_delta
>
HEART_BEAT_TIMEOUT_INTERVAL
);
if
(
is_down
)
{
if
(
is_down
)
{
UA_LOG_INFO
(
UA_Log_Stdout
,
\
// count for stats the switch to SAFE mode
UA_LOGCATEGORY_USERLAND
,
\
if
(
CURRENT_STATE
!=
STATE_DOWN
)
{
"DOWN: %s (delta=%d)"
,
coupler_id_str
,
timestamp_delta
);
CURRENT_STATE
=
STATE_DOWN
;
// go to safe mode as a dependant coupler is DOWN.
SAFE_MODE_STATE_COUNTER
+=
1
;
gotoSafeMode
();
UA_LOG_INFO
(
UA_Log_Stdout
,
\
UA_LOGCATEGORY_USERLAND
,
\
"DOWN: %s (delta=%d)"
,
coupler_id_str
,
timestamp_delta
);
// go to safe mode as a dependant coupler is DOWN.
gotoSafeMode
();
}
}
else
{
// all good, we received a keep alive in time
CURRENT_STATE
=
STATE_UP
;
}
}
}
}
else
{
else
{
// still no hear beat from this coupler ...
// still no hear beat from this coupler ...
CURRENT_STATE
=
STATE_NO_INITIAL_HEART_BEAT
;
UA_LOG_INFO
(
UA_Log_Stdout
,
UA_LOGCATEGORY_USERLAND
,
"NO INITIAL HEART BEAT: %s"
,
coupler_id_str
);
UA_LOG_INFO
(
UA_Log_Stdout
,
UA_LOGCATEGORY_USERLAND
,
"NO INITIAL HEART BEAT: %s"
,
coupler_id_str
);
}
}
}
}
...
...
coupler/opc-ua-server/server.c
View file @
c71159c3
...
@@ -185,5 +185,10 @@ int main(int argc, char **argv)
...
@@ -185,5 +185,10 @@ int main(int argc, char **argv)
// always leave attached slaves to a known safe shutdown state
// always leave attached slaves to a known safe shutdown state
safeShutdownI2CSlaveList
();
safeShutdownI2CSlaveList
();
// print statistics
UA_LOG_INFO
(
UA_Log_Stdout
,
\
UA_LOGCATEGORY_USERLAND
,
\
"SAFE mode counter=%d"
,
SAFE_MODE_STATE_COUNTER
);
return
retval
==
UA_STATUSCODE_GOOD
?
EXIT_SUCCESS
:
EXIT_FAILURE
;
return
retval
==
UA_STATUSCODE_GOOD
?
EXIT_SUCCESS
:
EXIT_FAILURE
;
}
}
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