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

Commit cea2196

Browse files
committed
Extract interface change event from attribute events
1 parent 6b51943 commit cea2196

File tree

5 files changed

+22
-39
lines changed

5 files changed

+22
-39
lines changed

cppapi/server/device.cpp

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6121,23 +6121,14 @@ void DeviceImpl::remove_local_command(const string &cmd_name)
61216121
//
61226122
//------------------------------------------------------------------------------------------------------------------
61236123

6124-
void DeviceImpl::get_event_param(DeviceEventSubscriptionState& eve)
6124+
void DeviceImpl::get_event_param(DeviceEventSubscriptionState& device_events_state)
61256125
{
61266126
ZmqEventSupplier *event_supplier_zmq = Util::instance()->get_zmq_event_supplier();
61276127

6128-
if (event_supplier_zmq->any_dev_intr_client(this) == true)
6129-
{
6130-
AttributeEventSubscriptionState ep;
6131-
6132-
ep.notifd = false;
6133-
ep.zmq = true;
6134-
ep.attr_id = -1;
6135-
ep.quality = false;
6136-
ep.data_ready = false;
6137-
ep.dev_intr_change = true;
6128+
device_events_state.has_interface_change_event_clients
6129+
= event_supplier_zmq->any_dev_intr_client(this);
61386130

6139-
eve.push_back(ep);
6140-
}
6131+
dev_attr->get_event_param(device_events_state.attribute_events);
61416132
}
61426133

61436134
//+-----------------------------------------------------------------------------------------------------------------
@@ -6154,19 +6145,14 @@ void DeviceImpl::get_event_param(DeviceEventSubscriptionState& eve)
61546145
//
61556146
//------------------------------------------------------------------------------------------------------------------
61566147

6157-
void DeviceImpl::set_event_param(const DeviceEventSubscriptionState& eve)
6148+
void DeviceImpl::set_event_param(const DeviceEventSubscriptionState& device_events_state)
61586149
{
6159-
for (size_t loop = 0; loop < eve.size(); loop++)
6150+
if (device_events_state.has_interface_change_event_clients)
61606151
{
6161-
if (eve[loop].attr_id == -1)
6162-
{
6163-
if (eve[loop].dev_intr_change == true)
6164-
{
6165-
set_event_intr_change_subscription(time(NULL));
6166-
}
6167-
break;
6168-
}
6152+
set_event_intr_change_subscription(time(NULL));
61696153
}
6154+
6155+
dev_attr->set_event_param(device_events_state.attribute_events);
61706156
}
61716157

61726158
//+-----------------------------------------------------------------------------------------------------------------

cppapi/server/dserver.cpp

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -872,7 +872,6 @@ void DServer::restart(string &d_name)
872872
dev_pol.push_back(tmp);
873873
}
874874

875-
dev_to_del->get_device_attr()->get_event_param(eve);
876875
dev_to_del->get_event_param(eve);
877876

878877
//
@@ -1044,8 +1043,6 @@ void DServer::restart(string &d_name)
10441043
// Re-set classical event parameters (if needed)
10451044
//
10461045

1047-
Tango::MultiAttribute *m_attr = new_dev->get_device_attr();
1048-
m_attr->set_event_param(eve);
10491046
new_dev->set_event_param(eve);
10501047

10511048
//
@@ -1964,13 +1961,9 @@ void DServer::mem_event_par(EventSubscriptionState& _map)
19641961
for (size_t j = 0;j < dev_list.size();j++)
19651962
{
19661963
DeviceEventSubscriptionState eve;
1967-
dev_list[j]->get_device_attr()->get_event_param(eve);
19681964
dev_list[j]->get_event_param(eve);
19691965

1970-
if (eve.size() != 0)
1971-
{
1972-
_map.insert(make_pair(dev_list[j]->get_name(),eve));
1973-
}
1966+
_map.insert(make_pair(dev_list[j]->get_name(),eve));
19741967
}
19751968
}
19761969
}
@@ -1997,12 +1990,11 @@ void DServer::apply_event_par(EventSubscriptionState& _map)
19971990
for (size_t j = 0;j < dev_list.size();j++)
19981991
{
19991992
string &dev_name = dev_list[j]->get_name();
2000-
EventSubscriptionState::iterator ite;
1993+
EventSubscriptionState::iterator ite;
20011994
ite = _map.find(dev_name);
20021995

20031996
if (ite != _map.end())
20041997
{
2005-
dev_list[j]->get_device_attr()->set_event_param(ite->second);
20061998
dev_list[j]->set_event_param(ite->second);
20071999
}
20082000
}

cppapi/server/event_subscription_state.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,17 @@ struct AttributeEventSubscriptionState
2222
EventClientLibVersions user;
2323
EventClientLibVersions att_conf;
2424
bool data_ready;
25-
bool dev_intr_change;
2625
bool notifd;
2726
bool zmq;
2827
};
2928

30-
typedef std::vector<AttributeEventSubscriptionState> DeviceEventSubscriptionState;
29+
typedef std::vector<AttributeEventSubscriptionState> AttributeEventSubscriptionStates;
30+
31+
struct DeviceEventSubscriptionState
32+
{
33+
bool has_interface_change_event_clients;
34+
AttributeEventSubscriptionStates attribute_events;
35+
};
3136

3237
typedef std::map<std::string, DeviceEventSubscriptionState> EventSubscriptionState;
3338

cppapi/server/multiattribute.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1501,7 +1501,7 @@ void MultiAttribute::read_alarm(string &status)
15011501
//
15021502
//------------------------------------------------------------------------------------------------------------------
15031503

1504-
void MultiAttribute::get_event_param(DeviceEventSubscriptionState& eve)
1504+
void MultiAttribute::get_event_param(AttributeEventSubscriptionStates& eve)
15051505
{
15061506
unsigned int i;
15071507

@@ -1600,7 +1600,7 @@ void MultiAttribute::get_event_param(DeviceEventSubscriptionState& eve)
16001600
//
16011601
//------------------------------------------------------------------------------------------------------------------
16021602

1603-
void MultiAttribute::set_event_param(const DeviceEventSubscriptionState& eve)
1603+
void MultiAttribute::set_event_param(const AttributeEventSubscriptionStates& eve)
16041604
{
16051605
for (size_t i = 0;i < eve.size();i++)
16061606
{

cppapi/server/multiattribute.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,8 @@ class MultiAttribute
269269
void remove_attribute(string &,bool);
270270
vector<long> &get_w_attr_list() {return writable_attr_list;}
271271
bool is_att_quality_alarmed();
272-
void get_event_param(DeviceEventSubscriptionState&);
273-
void set_event_param(const DeviceEventSubscriptionState&);
272+
void get_event_param(AttributeEventSubscriptionStates&);
273+
void set_event_param(const AttributeEventSubscriptionStates&);
274274
void add_alarmed_quality_factor(string &);
275275
void add_default(vector<AttrProperty> &,string &,string &,long);
276276
void add_attr(Attribute *att);

0 commit comments

Comments
 (0)