ChimeraTK-ControlSystemAdapter-OPCUAAdapter
04.00.01
ua_typeconversion.h
Go to the documentation of this file.
1
/*
2
* This file is part of ChimeraTKs ControlSystem-OPC-UA-Adapter.
3
*
4
* ChimeraTKs ControlSystem-OPC-UA-Adapter is free software: you can
5
* redistribute it and/or modify it under the terms of the Lesser GNU
6
* General Public License as published by the Free Software Foundation,
7
* either version 3 of the License, or (at your option) any later version.
8
*
9
* ChimeraTKs ControlSystem-OPC-UA-Adapter is distributed in the hope
10
* that it will be useful, but WITHOUT ANY WARRANTY; without even the
11
* implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
* See the Lesser GNU General Public License for more details.
13
*
14
* You should have received a copy of the GNU General Public License
15
* along with Foobar. If not, see https://www.gnu.org/licenses/lgpl.html
16
*
17
* Copyright (c) 2016 Chris Iatrou <Chris_Paul.Iatrou@tu-dresden.de>
18
* Copyright (c) 2016 Julian Rahm <Julian.Rahm@tu-dresden.de>
19
*/
20
21
#pragma once
22
23
#include <open62541/server.h>
24
25
#include <string>
26
27
/* Helpers for type converstion and such */
28
#define UA_STRING_TO_CPPSTRING_COPY(_p_uastring, _p_cppstring) \
29
do { \
30
UA_String* ua_url = (UA_String*)_p_uastring; \
31
char* ua_str_tmp = (char*)malloc(ua_url->length + 1); \
32
memset(ua_str_tmp, 0, ua_url->length + 1); \
33
strncpy(ua_str_tmp, (char*)ua_url->data, ua_url->length); \
34
*(_p_cppstring) = ua_str_tmp; \
35
free(ua_str_tmp); \
36
} while(0);
37
38
/* UASTRING_TO_CPPSTRING(UA_String s_ua, char *s_c)
39
*
40
* Create a new buffer s_c that will contain s_ua
41
*/
42
#define UASTRING_AS_CSTRING(_p_uastring, _p_strbuffer) \
43
{ \
44
_p_strbuffer = (char*)malloc(_p_uastring.length + 1); \
45
memset(_p_strbuffer, 0, _p_uastring.length + 1); \
46
memcpy(_p_strbuffer, _p_uastring.data, _p_uastring.length); \
47
}
48
49
/* UASTRING_TO_CPPSTRING(UA_String s_ua, std::string s_cpp)
50
*
51
* Copy contents of s_ua into s_cpp
52
*/
53
#define UASTRING_TO_CPPSTRING(_p_uastring, _p_cppstring) \
54
do { \
55
char* s; \
56
UASTRING_AS_CSTRING(_p_uastring, s) \
57
_p_cppstring.assign(s, _p_uastring.length); \
58
free(s); \
59
} while(0);
60
61
#define NODE_BROWSENAME_AS_STRING(_p_server, _p_nodeid, _p_strbuffer) \
62
{ \
63
UA_QualifiedName _p_tmpName; \
64
UA_Server_readBrowseName(_p_server, _p_nodeid, &_p_tmpName); \
65
UASTRING_AS_STRING(_p_tmpName.name, _p_strbuffer); \
66
}
67
68
#define NODE_DISPLAYNAME_AS_STRING(_p_server, _p_nodeid, _p_strbuffer) \
69
{ \
70
UA_LocalizedText _p_tmpName; \
71
UA_Server_readDisplayName(_p_server, _p_nodeid, &_p_tmpName); \
72
UASTRING_AS_STRING(_p_tmpName.text, _p_strbuffer); \
73
}
74
75
#define NODE_DESCRIPTION_AS_STRING(_p_server, _p_nodeid, _p_strbuffer) \
76
{ \
77
UA_LocalizedText _p_tmpName; \
78
UA_Server_readDisplayName(_p_server, _p_nodeid, &_p_tmpName); \
79
UASTRING_AS_STRING(_p_tmpName.text, _p_strbuffer); \
80
}
sources
ChimeraTK-ControlSystemAdapter-OPCUAAdapter
include
ua_typeconversion.h
Generated by
1.8.17