2 //=============================================================================
6 * @author Carlos O'Ryan (coryan@cs.wustl.edu)
8 //=============================================================================
16 #if !defined (ACE_LACKS_PRAGMA_ONCE)
18 #endif /* ACE_LACKS_PRAGMA_ONCE */
20 #include "orbsvcs/RtecEventCommS.h"
21 #include "orbsvcs/RtecEventChannelAdminC.h"
23 #include "ace/OS_NS_time.h"
24 #include "ace/High_Res_Timer.h"
29 * @brief Simple supplier object to implement EC tests.
31 * This class is a supplier of events.
32 * The class is just a helper to simplify common tasks in EC
33 * tests, such as subscribing for a range of events, disconnecting
34 * from the EC, informing the driver of shutdown messages, etc.
35 * There are several ways to connect and disconnect this class,
36 * and it is up to the driver program to use the right one.
37 * The driver can request that to this class to send a new event,
38 * a new shutdown event or to become "active" and send a number of
39 * events at a certain rate.
41 class EC_Test_Export EC_Supplier
: public POA_RtecEventComm::PushSupplier
45 * Constructor, specifies the types of events to send.
46 * Notice that the user can connect to the EC using other
47 * publications, this is useful for filtering tests.
49 EC_Supplier (EC_Driver
*driver
,
50 void* supplier_cookie
);
52 /// The types of the event is chosen by the driver, based on the
53 /// cookie and the <event_number>
54 void send_event (int event_number
);
56 /// Send <event> to the EC.
57 void send_event (const RtecEventComm::EventSet
& event
);
59 /// Set the event type and source in <event>
60 void send_event (int event_number
,
61 const RtecEventComm::Event
& event
);
63 /// Send a shutdown event.
64 void send_shutdown ();
66 /// Connect using a <supplier_admin> and publications (<qos>)
67 /// computed by the user
68 virtual void connect (
69 RtecEventChannelAdmin::SupplierAdmin_ptr supplier_admin
,
70 const RtecEventChannelAdmin::SupplierQOS
& qos
,
71 int shutdown_event_type
);
73 /// Connect using the current consumer_proxy (useful for reconnect test)
74 virtual void connect (
75 const RtecEventChannelAdmin::SupplierQOS
& qos
,
76 int shutdown_event_type
);
78 /// Disconnect from the EC, also deactivates the object
81 /// Disconnect from the EC, also deactivates the object
84 /// Dump the results...
85 virtual void dump_results (
86 const ACE_TCHAR
* name
,
87 ACE_High_Res_Timer::global_scale_factor_type global_scale_factor
);
89 /// Add our statistics to <stats>
90 void accumulate (ACE_Throughput_Stats
& stats
) const;
92 /// Return an event type to push....
93 void event_type (int event_number
,
94 RtecEventComm::Event
& event
);
96 // = The PushSupplier methods
97 virtual void disconnect_push_supplier ();
100 /// Class we forward to.
103 /// Magic cookie provided by the supplier to identify ourselves
106 /// Protect the internal state
107 TAO_SYNCH_MUTEX lock_
;
109 /// Count the number of push() calls
112 /// We talk to the EC (as a supplier) using this proxy.
113 RtecEventChannelAdmin::ProxyPushConsumer_var consumer_proxy_
;
115 /// The time for the first event sent
116 ACE_hrtime_t throughput_start_
;
118 /// Measure the elapsed time spent while sending the events.
119 ACE_Throughput_Stats throughput_
;
127 int shutdown_event_type_
;
129 /// The publications, used to select the events.
130 RtecEventChannelAdmin::SupplierQOS qos_
;
132 /// Is the supplier active in the POA?
135 /// Cache the object reference to speed up connect/disconnect calls
136 RtecEventComm::PushSupplier_var myself_
;
139 // ****************************************************************
142 * @class EC_Supplier_Task
144 class EC_Supplier_Task
: public ACE_Task_Base
148 EC_Supplier_Task (EC_Supplier
* supplier
,
155 int shutdown_event_type
,
156 ACE_Thread_Manager
* thr_mgr
= 0);
163 EC_Supplier
* supplier_
;
165 /// The driver program
168 /// The magic cookie assigned to the supplier
171 /// Number of events "bursts"
174 /// The number of events in a "burst", i.e. between two calls to
178 /// The sleep time (in usecs) between each burst
181 /// The size of the payload in each event.
184 /// Define the shutdown event, invoked at the end of the loop.
185 int shutdown_event_type_
;
188 #endif /* EC_SUPPLIER_H */