Skip to content
This repository was archived by the owner on Jul 8, 2022. It is now read-only.

Commit 401ab50

Browse files
Ingvordbourtemb
authored andcommitted
Improve event subscription (#423)
This should improve events reliability when subscribing to events with FQDN containing localhost or network aliases or when there are multiple network interfaces (#315). The situation is especially improved when using an AttributeProxy for the event subscription. Limitation: in case DeviceProxy is used for event subscription, client might get an incorrect event name value in the event data (containing a TANGO_HOST hostname slightly different than the one used during the FQDN subscription or in the env. variable) in the event callback if short domain name is used in TANGO_HOST environment variable e.g. hzgc103k -> hzgc103.desy.de
1 parent 9c91432 commit 401ab50

20 files changed

+486
-330
lines changed

CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ include(CTest)
44
enable_testing()
55
#need to define the version of the library
66
set(MAJOR_VERSION "9")
7-
set(MINOR_VERSION "2")
8-
set(PATCH_VERSION "8")
7+
set(MINOR_VERSION "3")
8+
set(PATCH_VERSION "0")
99

1010
if(WIN32)
1111
include(configure/cmake_win_defs.cmake)
@@ -25,6 +25,7 @@ include_directories(cppapi/server)
2525
include_directories(cppapi/server/idl)
2626
include_directories(log4tango/include)
2727
#required for generated config.h
28+
include_directories(${CMAKE_CURRENT_BINARY_DIR}/cppapi/server)
2829
include_directories(${CMAKE_CURRENT_BINARY_DIR}/log4tango/include)
2930

3031

RELEASE_NOTES

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
1+
9.3.0
2+
=====
3+
4+
1. Fix FQDN events.
5+
Limitations:
6+
- in case DeviceProxy is used for event subscription client will get incorrect value in the event callback if short domain name is used in env.TANGO_HOST e.g. hzgc103k -> hzgc103.desy.de
7+
18
9.2.8
29
=====
10+
311
1. Cmake release targets #438 - Fix appveyor build.
412
Install include files in <install_prefix>/include/tango directory instead of
513
<install_prefix>/include.

cpp_test_suite/environment/setup.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ docker run --name mysql_db \
99

1010
#run tango-cs docker
1111
CONTAINER=$(docker run --name tango_cs \
12+
-p 10000:10000 \
1213
-e TANGO_HOST=127.0.0.1:10000 \
1314
-e MYSQL_HOST=mysql_db:3306 \
1415
-e MYSQL_USER=tango \

cpp_test_suite/new_tests/cxx_cmd_query.cpp

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -520,29 +520,31 @@ class CmdQueryTestSuite: public CxxTest::TestSuite
520520
void test_command_list_query_ZMQEventSubscriptionChange(void)
521521
{
522522
// CommandInfo cmd_inf = dserver->command_query("ZmqEventSubscriptionChange");
523-
CommandInfo cmd_inf = cmd_inf_list[31];
524-
TS_ASSERT_EQUALS(cmd_inf.cmd_name,"ZmqEventSubscriptionChange");
525-
TS_ASSERT_EQUALS(cmd_inf.in_type,Tango::DEVVAR_STRINGARRAY);
526-
TS_ASSERT_EQUALS(cmd_inf.out_type,Tango::DEVVAR_LONGSTRINGARRAY);
527-
TS_ASSERT_EQUALS(cmd_inf.in_type_desc,"Event consumer wants to subscribe to.\n"
528-
"device name, attribute/pipe name, action (\"subscribe\"), event name, <Tango client IDL version>\"\n"
529-
"event name can take the following values:\n"
530-
" \"change\",\n"
531-
" \"quality\",\n"
532-
" \"periodic\",\n"
533-
" \"archive\",\n"
534-
" \"user_event\",\n"
535-
" \"attr_conf\",\n"
536-
" \"data_ready\",\n"
537-
" \"intr_change\",\n"
538-
" \"pipe\"\n"
539-
"\"info\" can also be used as single parameter to retrieve information about the heartbeat and event pub endpoints.");
540-
TS_ASSERT_EQUALS(cmd_inf.out_type_desc,"Str[0] = Heartbeat pub endpoint - Str[1] = Event pub endpoint\n"
541-
"...\n"
542-
"Str[n] = Alternate Heartbeat pub endpoint - Str[n+1] = Alternate Event pub endpoint\n"
543-
"Lg[0] = Tango lib release - Lg[1] = Device IDL release\n"
544-
"Lg[2] = Subscriber HWM - Lg[3] = Multicast rate\n"
545-
"Lg[4] = Multicast IVL - Lg[5] = ZMQ release");
523+
CommandInfo cmd_inf = cmd_inf_list[31];
524+
TS_ASSERT_EQUALS(cmd_inf.cmd_name, "ZmqEventSubscriptionChange");
525+
TS_ASSERT_EQUALS(cmd_inf.in_type, Tango::DEVVAR_STRINGARRAY);
526+
TS_ASSERT_EQUALS(cmd_inf.out_type, Tango::DEVVAR_LONGSTRINGARRAY);
527+
TS_ASSERT_EQUALS(cmd_inf.in_type_desc, "Event consumer wants to subscribe to.\n"
528+
"device name, attribute/pipe name, action (\"subscribe\"), event name, <Tango client IDL version>\"\n"
529+
"event name can take the following values:\n"
530+
" \"change\",\n"
531+
" \"quality\",\n"
532+
" \"periodic\",\n"
533+
" \"archive\",\n"
534+
" \"user_event\",\n"
535+
" \"attr_conf\",\n"
536+
" \"data_ready\",\n"
537+
" \"intr_change\",\n"
538+
" \"pipe\"\n"
539+
"\"info\" can also be used as single parameter to retrieve information about the heartbeat and event pub endpoints.");
540+
TS_ASSERT_EQUALS(cmd_inf.out_type_desc, "Str[0] = Heartbeat pub endpoint - Str[1] = Event pub endpoint\n"
541+
"...\n"
542+
"Str[n] = Alternate Heartbeat pub endpoint - Str[n+1] = Alternate Event pub endpoint\n"
543+
"Str[n+1] = event name used by this server as zmq topic to send events\n"
544+
"Str[n+2] = channel name used by this server to send heartbeat events\n"
545+
"Lg[0] = Tango lib release - Lg[1] = Device IDL release\n"
546+
"Lg[2] = Subscriber HWM - Lg[3] = Multicast rate\n"
547+
"Lg[4] = Multicast IVL - Lg[5] = ZMQ release");
546548
}
547549

548550
};

cppapi/client/AttributeProxy.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ private :
7979
class AttributeProxyExt
8080
{
8181
public:
82-
AttributeProxyExt() {};
82+
string user_defined_name;
83+
AttributeProxyExt(const string& name):user_defined_name(name) {};
8384
};
8485

8586
#ifdef HAS_UNIQUE_PTR
@@ -89,6 +90,7 @@ private :
8990
#endif
9091

9192
public :
93+
string get_user_defined_name() const { return ext->user_defined_name; }
9294
///@name Constructors
9395
//@{
9496
/**

cppapi/client/attr_proxy.cpp

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,12 @@ namespace Tango
5757
//
5858
//-----------------------------------------------------------------------------
5959

60-
AttributeProxy::AttributeProxy (string &name):dev_proxy(NULL),ext(Tango_nullptr)
60+
AttributeProxy::AttributeProxy (string &name):dev_proxy(NULL),ext(new AttributeProxyExt(name))
6161
{
6262
real_constructor(name);
6363
}
6464

65-
AttributeProxy::AttributeProxy (const char *na):dev_proxy(NULL),ext(Tango_nullptr)
65+
AttributeProxy::AttributeProxy (const char *na):dev_proxy(NULL),ext(new AttributeProxyExt(na))
6666
{
6767
string name(na);
6868
real_constructor(name);
@@ -294,12 +294,12 @@ AttributeProxy::AttributeProxy(const AttributeProxy &prev):ext(Tango_nullptr)
294294
#ifdef HAS_UNIQUE_PTR
295295
if (prev.ext.get() != NULL)
296296
{
297-
ext.reset(new AttributeProxyExt);
297+
ext.reset(new AttributeProxyExt(prev.get_user_defined_name()));
298298
}
299299
#else
300300
if (prev.ext != NULL)
301301
{
302-
ext = new AttributeProxyExt();
302+
ext = new AttributeProxyExt(prev.get_user_defined_name());
303303
*ext = *(prev.ext);
304304
}
305305
else
@@ -370,13 +370,13 @@ AttributeProxy &AttributeProxy::operator=(const AttributeProxy &rval)
370370

371371
#ifdef HAS_UNIQUE_PTR
372372
if (rval.ext.get() != NULL)
373-
ext.reset(new AttributeProxyExt);
373+
ext.reset(new AttributeProxyExt(rval.get_user_defined_name()));
374374
else
375375
ext.reset();
376376
#else
377377
if (rval.ext != NULL)
378378
{
379-
ext = new AttributeProxyExt();
379+
ext = new AttributeProxyExt(rval.get_user_defined_name());
380380
*ext = *(rval.ext);
381381
}
382382
else
@@ -1358,7 +1358,11 @@ int AttributeProxy::subscribe_event (EventType event, CallBack *callback,
13581358
int ret;
13591359
try
13601360
{
1361-
ret = api_ptr->get_zmq_event_consumer()->subscribe_event(dev_proxy,attr_name, event, callback, filters, stateless);
1361+
//we use filters here to pass user defined attribute name to later use it in event callback
1362+
// see https://github.com/tango-controls/cppTango/pull/423
1363+
vector<string> non_const_filters;
1364+
non_const_filters.push_back(get_user_defined_name());
1365+
ret = api_ptr->get_zmq_event_consumer()->subscribe_event(dev_proxy,attr_name, event, callback, non_const_filters, stateless);
13621366
}
13631367
catch (DevFailed &e)
13641368
{

0 commit comments

Comments
 (0)