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
1
Merge Requests
1
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
4e786e68
Commit
4e786e68
authored
Oct 05, 2022
by
Ivan Tyagov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP:Implement heart_beats in this format <coupler_id>.heart_beats
parent
72a1342f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
4 deletions
+35
-4
coupler/opc-ua-server/keep_alive_publisher.h
coupler/opc-ua-server/keep_alive_publisher.h
+19
-1
coupler/opc-ua-server/keep_alive_subscriber.h
coupler/opc-ua-server/keep_alive_subscriber.h
+16
-3
No files found.
coupler/opc-ua-server/keep_alive_publisher.h
View file @
4e786e68
...
@@ -141,7 +141,25 @@ void callbackTicHeartBeat()
...
@@ -141,7 +141,25 @@ void callbackTicHeartBeat()
// set OPC UA's heat_beat node value
// set OPC UA's heat_beat node value
UA_NodeId
myFloatNodeId
=
UA_NODEID_STRING
(
1
,
"heart_beat"
);
UA_NodeId
myFloatNodeId
=
UA_NODEID_STRING
(
1
,
"heart_beat"
);
UA_Float
myFloat
=
HEART_BEATS
;
// XXX: implement heart_beat like <ID>.<heart_beats>
int
len
=
snprintf
(
NULL
,
0
,
"%f"
,
HEART_BEATS
);
char
*
result1
=
malloc
(
len
+
1
);
snprintf
(
result1
,
len
+
1
,
"%d"
,
HEART_BEATS
);
int
len1
=
snprintf
(
NULL
,
0
,
"%d"
,
COUPLER_ID
);
char
*
result2
=
malloc
(
len1
+
1
);
snprintf
(
result2
,
len1
+
1
,
"%d"
,
COUPLER_ID
);
// concat
strcat
(
result2
,
"."
);
strcat
(
result2
,
result1
);
char
*
end_ptr
;
float
final_result
=
strtof
(
result2
,
&
end_ptr
);
printf
(
"final_result: %f
\n
"
,
final_result
);
UA_Float
myFloat
=
final_result
;
UA_Variant
myVar
;
UA_Variant
myVar
;
UA_Variant_init
(
&
myVar
);
UA_Variant_init
(
&
myVar
);
UA_Variant_setScalar
(
&
myVar
,
&
myFloat
,
&
UA_TYPES
[
UA_TYPES_FLOAT
]);
UA_Variant_setScalar
(
&
myVar
,
&
myFloat
,
&
UA_TYPES
[
UA_TYPES_FLOAT
]);
...
...
coupler/opc-ua-server/keep_alive_subscriber.h
View file @
4e786e68
...
@@ -26,10 +26,12 @@ static void dataChangeNotificationCallback(UA_Server *server, UA_UInt32 monitore
...
@@ -26,10 +26,12 @@ static void dataChangeNotificationCallback(UA_Server *server, UA_UInt32 monitore
void
*
nodeContext
,
UA_UInt32
attributeId
,
void
*
nodeContext
,
UA_UInt32
attributeId
,
const
UA_DataValue
*
var
)
{
const
UA_DataValue
*
var
)
{
unsigned
long
int
milli_seconds_now
=
getMilliSecondsSinceEpoch
();
unsigned
long
int
milli_seconds_now
=
getMilliSecondsSinceEpoch
();
unsigned
int
coupler_id
;
// 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])) {
unsigned
int
coupler_id
=
*
(
UA_UInt32
*
)
var
->
value
.
data
;
coupler_id = *(UA_UInt32*) var->value.data;
// care for other coupler_id NOT ourselves
// care for other coupler_id NOT ourselves
if (coupler_id!=COUPLER_ID) {
if (coupler_id!=COUPLER_ID) {
UA_LOG_INFO(UA_Log_Stdout, \
UA_LOG_INFO(UA_Log_Stdout, \
...
@@ -47,11 +49,22 @@ static void dataChangeNotificationCallback(UA_Server *server, UA_UInt32 monitore
...
@@ -47,11 +49,22 @@ static void dataChangeNotificationCallback(UA_Server *server, UA_UInt32 monitore
}
}
}
}
*/
// filter out heart_beat from Data Set
// filter out heart_beat from Data Set
if
(
UA_Variant_hasScalarType
(
&
var
->
value
,
&
UA_TYPES
[
UA_TYPES_FLOAT
]))
{
if
(
UA_Variant_hasScalarType
(
&
var
->
value
,
&
UA_TYPES
[
UA_TYPES_FLOAT
]))
{
float
heart_beat
=
*
(
UA_Float
*
)
var
->
value
.
data
;
float
heart_beat
=
*
(
UA_Float
*
)
var
->
value
.
data
;
UA_LOG_INFO
(
UA_Log_Stdout
,
UA_LOGCATEGORY_USERLAND
,
"heart_beat = %f"
,
heart_beat
);
// split <ID>.<heart_beats>, just converting to int is enough
coupler_id
=
(
int
)
heart_beat
;
UA_LOG_INFO
(
UA_Log_Stdout
,
UA_LOGCATEGORY_USERLAND
,
"heart_beat = %f, id=%d"
,
heart_beat
,
coupler_id
);
// convert coupler_id to str
char
*
coupler_id_str
=
convertInt2Str
(
coupler_id
);
// convert micro seconds to str
char
*
milli_seconds_now_str
=
convertLongInt2Str
(
milli_seconds_now
);
// Add to our local linked list
addItem
(
&
SUBSCRIBER_DICT
,
coupler_id_str
,
milli_seconds_now_str
);
}
}
}
}
...
...
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