4 * @author Carlos O'Ryan <coryan@uci.edu>
8 #include "Implicit_Deactivator.h"
10 Supplier::Supplier (CORBA::Long experiment_id
,
11 CORBA::Long event_type
,
12 CORBA::Long event_range
,
13 PortableServer::POA_ptr poa
)
14 : experiment_id_ (experiment_id
)
15 , event_type_ (event_type
)
16 , event_range_ (event_range
)
17 , default_POA_ (PortableServer::POA::_duplicate (poa
))
22 Supplier::connect (RtecEventChannelAdmin::EventChannel_ptr ec
)
24 RtecEventChannelAdmin::SupplierAdmin_var supplier_admin
=
28 ACE_GUARD (TAO_SYNCH_MUTEX
, ace_mon
, this->mutex_
);
29 if (!CORBA::is_nil (this->proxy_consumer_
.in ()))
32 this->proxy_consumer_
=
33 supplier_admin
->obtain_push_consumer ();
36 RtecEventComm::PushSupplier_var supplier
=
39 RtecEventChannelAdmin::SupplierQOS supplier_qos
;
40 supplier_qos
.is_gateway
= 0;
41 supplier_qos
.publications
.length (this->event_range_
);
42 for (CORBA::Long i
= 0; i
!= this->event_range_
; ++i
)
44 RtecEventComm::EventHeader
& sh
=
45 supplier_qos
.publications
[i
].event
.header
;
46 sh
.type
= this->event_type_
+ 2 * i
;
47 sh
.source
= this->experiment_id_
;
50 this->proxy_consumer_
->connect_push_supplier (supplier
.in (),
55 Supplier::disconnect ()
57 RtecEventChannelAdmin::ProxyPushConsumer_var proxy
;
59 ACE_GUARD (TAO_SYNCH_MUTEX
, ace_mon
, this->mutex_
);
60 if (CORBA::is_nil (this->proxy_consumer_
.in ()))
62 proxy
= this->proxy_consumer_
._retn ();
65 Implicit_Deactivator
deactivator (this);
69 proxy
->disconnect_push_consumer ();
71 catch (const CORBA::Exception
&){}
75 Supplier::push (const RtecEventComm::EventSet
&events
)
77 // ACE_DEBUG ((LM_DEBUG, "Supplier pushing (%d,%d)\n",
78 // events[0].header.type, events[0].header.source));
79 RtecEventChannelAdmin::ProxyPushConsumer_var proxy
;
81 ACE_GUARD (TAO_SYNCH_MUTEX
, ace_mon
, this->mutex_
);
82 if (CORBA::is_nil (this->proxy_consumer_
.in ()))
84 proxy
= this->proxy_consumer_
;
91 Supplier::disconnect_push_supplier ()
93 ACE_GUARD (TAO_SYNCH_MUTEX
, ace_mon
, this->mutex_
);
94 this->proxy_consumer_
=
95 RtecEventChannelAdmin::ProxyPushConsumer::_nil ();
98 PortableServer::POA_ptr
99 Supplier::_default_POA ()
101 return PortableServer::POA::_duplicate (this->default_POA_
.in ());