1 #include "Counting_Consumer.h"
4 EC_Counting_Consumer::EC_Counting_Consumer (const char* name
)
12 EC_Counting_Consumer::connect (RtecEventChannelAdmin::ConsumerAdmin_ptr consumer_admin
,
13 const RtecEventChannelAdmin::ConsumerQOS
&qos
)
15 // The canonical protocol to connect to the EC
17 RtecEventComm::PushConsumer_var consumer
=
20 if (CORBA::is_nil (this->supplier_proxy_
.in ()))
22 this->supplier_proxy_
=
23 consumer_admin
->obtain_push_supplier ();
26 this->supplier_proxy_
->connect_push_consumer (consumer
.in (),
31 EC_Counting_Consumer::disconnect ()
33 if (!CORBA::is_nil (this->supplier_proxy_
.in ()))
35 this->supplier_proxy_
->disconnect_push_supplier ();
36 this->supplier_proxy_
=
37 RtecEventChannelAdmin::ProxyPushSupplier::_nil ();
43 EC_Counting_Consumer::deactivate ()
45 PortableServer::POA_var consumer_poa
=
46 this->_default_POA ();
47 PortableServer::ObjectId_var consumer_id
=
48 consumer_poa
->servant_to_id (this);
49 consumer_poa
->deactivate_object (consumer_id
.in ());
53 EC_Counting_Consumer::dump_results (int expected_count
, int tolerance
)
55 int diff
= this->event_count
- expected_count
;
56 if (diff
> tolerance
|| diff
< -tolerance
)
59 "ERROR - %s unexpected number of events <%d> instead of <%d>\n",
67 "%s - number of events <%d> within margins expected <%d>\n",
75 EC_Counting_Consumer::push (const RtecEventComm::EventSet
& events
)
77 if (events
.length () == 0)
80 "%s (%P|%t) no events\n", this->name_
));
86 if (this->event_count
% 10 == 0)
89 "%s (%P|%t): %d events received\n",
97 EC_Counting_Consumer::disconnect_push_consumer ()
99 this->disconnect_count
++;
100 this->supplier_proxy_
=
101 RtecEventChannelAdmin::ProxyPushSupplier::_nil ();