Merge pull request #1551 from DOCGroup/plm_jira_333
[ACE_TAO.git] / TAO / examples / Simulator / Event_Supplier / DualEC_Sup.h
blobe9df243f7319139b2ace5bcf3cb0fe4d7cbcdd4a
2 //=============================================================================
3 /**
4 * @file DualEC_Sup.h
6 * Event supplier for visualization of scheduling behavior, using
7 * arrival and dispatch data logged by an EC dispatch command object
9 * @author Chris Gill (cdgill@cs.wustl.edu) Adapted from the orginal DOVE simulation event supplier written by Michael Kircher (mk1@cs.wustl.edu)
11 //=============================================================================
14 #ifndef DUALEC_SUP_H
15 #define DUALEC_SUP_H
17 #include "orbsvcs/RtecEventChannelAdminS.h"
18 #include "orbsvcs/RtecEventCommS.h"
19 #include "orbsvcs/Event_Utilities.h"
20 #include "orbsvcs/Event_Service_Constants.h"
21 #include "orbsvcs/Scheduler_Factory.h"
22 #include "orbsvcs/RtecSchedulerS.h"
24 #include "NavWeapC.h"
25 #include "NavWeapS.h"
26 #include "DOVE_Supplier.h"
28 struct Schedule_Viewer_Data
30 char operation_name [BUFSIZ];
31 double utilitzation;
32 double overhead;
33 u_long arrival_time;
34 u_long deadline_time;
35 u_long completion_time;
36 u_long computation_time;
40 /**
41 * @class DualEC_Supplier
43 * @brief Event Supplier.
45 * Reads information out of a file and
46 * feeds it with additional navigation and
47 * weapon data into the dove_supplier, which
48 * is connected to the event channel
50 class DualEC_Supplier
52 public:
54 DualEC_Supplier (int argc, ACE_TCHAR** argv);
56 ~DualEC_Supplier (void);
58 /// Initialize: set up, resolve ORB services,
59 /// connect the DOVE_Suppliers.
60 int init (void);
62 /// Compute schedule priorities, possibly dump
63 /// data into runtime scheduler header files.
64 void compute_schedules (void);
66 /// here is really something going on,
67 /// here we deliver the messages
68 void start_generating_events (void);
70 /// Load the scheduling information into memory
71 void load_schedule_data ();
74 private:
76 /**
77 * @class Terminator
79 * Private class that implements a termination servant.
81 class Terminator : public POA_NavWeapTerminator
83 void shutdown (void);
86 /// Run the orb event loop.
87 static ACE_THR_FUNC_RETURN run_orb (void *);
89 /// Run navigation event generation thread.
90 static ACE_THR_FUNC_RETURN run_nav_thread (void *arg);
92 /// Run weapons event generation thread.
93 static ACE_THR_FUNC_RETURN run_weap_thread (void *arg);
95 /// Create two scheduling service instances, registers
96 /// them with the Naming Service.
97 int create_schedulers (void);
99 /// Create two event service instances, registers
100 /// them with the Naming Service.
101 int create_event_channels (void);
103 /// Get command line options.
104 unsigned int get_options (int argc, ACE_TCHAR *argv []);
106 // Time values to pause before notifying the supplier each time.
107 ACE_Time_Value nav_pause_;
108 ACE_Time_Value weap_pause_;
110 // POA client references.
111 PortableServer::POA_var root_POA_var_;
112 PortableServer::POAManager_var poa_manager_;
114 // Naming Service client reference and names to use.
115 CosNaming::NamingContext_var naming_context_;
116 CosNaming::Name channel_hi_name_;
117 CosNaming::Name channel_lo_name_;
118 CosNaming::Name sched_hi_name_;
119 CosNaming::Name sched_lo_name_;
121 // Scheduling Service servant implementation pointers.
122 POA_RtecScheduler::Scheduler * sched_hi_impl_;
123 POA_RtecScheduler::Scheduler * sched_lo_impl_;
125 // Scheduling Service client references.
126 RtecScheduler::Scheduler_var sched_hi_;
127 RtecScheduler::Scheduler_var sched_lo_;
129 // Handles for the dummy rt_infos registered with the
130 // schedulers in order to force priority differentiation.
131 RtecScheduler::handle_t sched_hi_rt_info_hi_;
132 RtecScheduler::handle_t sched_hi_rt_info_lo_;
133 RtecScheduler::handle_t sched_lo_rt_info_hi_;
134 RtecScheduler::handle_t sched_lo_rt_info_lo_;
136 // Termination servant implementation and client reference
137 Terminator terminator_impl_;
138 NavWeapTerminator_var terminator_;
140 // Event Service servant implementation pointers.
141 POA_RtecEventChannelAdmin::EventChannel *ec_hi_impl_;
142 POA_RtecEventChannelAdmin::EventChannel *ec_lo_impl_;
144 // Event Service client references.
145 RtecEventChannelAdmin::EventChannel_var ec_hi_;
146 RtecEventChannelAdmin::EventChannel_var ec_lo_;
148 DOVE_Supplier weapons_Supplier_;
149 DOVE_Supplier navigation_Supplier_;
151 // Data for registering RT_Infos
152 ACE_Scheduler_Factory::POD_RT_Info rt_info_nav_hi_;
153 ACE_Scheduler_Factory::POD_RT_Info rt_info_nav_lo_;
154 ACE_Scheduler_Factory::POD_RT_Info rt_info_weap_hi_;
155 ACE_Scheduler_Factory::POD_RT_Info rt_info_weap_lo_;
156 ACE_Scheduler_Factory::POD_RT_Info rt_info_dummy_hi_;
157 ACE_Scheduler_Factory::POD_RT_Info rt_info_dummy_lo_;
159 // References for CORBA RtecScheduler data structures
160 RtecScheduler::RT_Info_Set_var infos_hi_;
161 RtecScheduler::Dependency_Set_var deps_hi_;
162 RtecScheduler::Config_Info_Set_var configs_hi_;
163 RtecScheduler::Scheduling_Anomaly_Set_var anomalies_hi_;
164 RtecScheduler::RT_Info_Set_var infos_lo_;
165 RtecScheduler::Dependency_Set_var deps_lo_;
166 RtecScheduler::Config_Info_Set_var configs_lo_;
167 RtecScheduler::Scheduling_Anomaly_Set_var anomalies_lo_;
169 // Queues to store event carried data structures.
170 ACE_Unbounded_Queue<Navigation *> navigation_data_;
171 ACE_Unbounded_Queue<Weapons *> weapons_data_;
173 int argc_;
174 ACE_TCHAR **argv_;
175 long total_messages_;
176 long break_count_;
177 ACE_TCHAR *input_file_name_;
178 unsigned long update_data_;
179 int dump_schedule_headers_;
180 int use_runtime_schedulers_;
181 int suppress_priority_;
182 const ACE_TCHAR * hi_schedule_file_name_;
183 const ACE_TCHAR * lo_schedule_file_name_;
184 CORBA::Long nav_roll_;
185 CORBA::Long nav_pitch_;
188 #endif /* DUALEC_SUP_H */