summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/orbsvcs/Event/EC_Kokyu_Filter.cpp
blob: 12157e7b50b80ad593377151a874cd7e3248c8ab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
// $Id$

#include "EC_Kokyu_Filter.h"
#include "EC_QOS_Info.h"

#if ! defined (__ACE_INLINE__)
#include "EC_Kokyu_Filter.i"
#endif /* __ACE_INLINE__ */

ACE_RCSID(Event, EC_Kokyu_Filter, "$Id$")

TAO_EC_Kokyu_Filter::
    TAO_EC_Kokyu_Filter (const char* name,
                         RtecScheduler::handle_t rt_info,
                         RtecScheduler::Scheduler_ptr scheduler,
                         TAO_EC_Filter* body,
                         RtecScheduler::handle_t body_info,
                         RtecScheduler::handle_t parent_info,
                         RtecScheduler::Info_Type_t info_type)

  :  rt_info_ (rt_info),
     rt_info_computed_ (0),
     name_ (name),
     scheduler_ (RtecScheduler::Scheduler::_duplicate (scheduler)),
     body_ (body),
     body_info_ (body_info),
     parent_info_ (parent_info),
     info_type_ (info_type)
{
  this->adopt_child (this->body_);

#if 1 //by VS
this->rt_info_computed_ = 1;
#endif
}

TAO_EC_Kokyu_Filter::~TAO_EC_Kokyu_Filter (void)
{
  delete this->body_;
}

TAO_EC_Filter::ChildrenIterator
TAO_EC_Kokyu_Filter::begin (void) const
{
  return this->body_->begin ();
}

TAO_EC_Filter::ChildrenIterator
TAO_EC_Kokyu_Filter::end (void) const
{
  return this->body_->end ();
}

int
TAO_EC_Kokyu_Filter::size (void) const
{
  return this->body_->size ();
}

int
TAO_EC_Kokyu_Filter::filter (const RtecEventComm::EventSet &event,
                             TAO_EC_QOS_Info& qos_info
                             ACE_ENV_ARG_DECL)
{
  return this->body_->filter (event, qos_info ACE_ENV_ARG_PARAMETER);
}

int
TAO_EC_Kokyu_Filter::filter_nocopy (RtecEventComm::EventSet &event,
                                    TAO_EC_QOS_Info& qos_info
                                    ACE_ENV_ARG_DECL)
{
  return this->body_->filter_nocopy (event, qos_info ACE_ENV_ARG_PARAMETER);
}

// This is private, so we can make it inline in the .cpp file...
void
TAO_EC_Kokyu_Filter::compute_qos_info (TAO_EC_QOS_Info& qos_info
                                       ACE_ENV_ARG_DECL)
{
  this->init_rt_info (ACE_ENV_SINGLE_ARG_PARAMETER);
  ACE_CHECK;

  //qos_info.rt_info = this->rt_info_;
  switch (this->info_type_)
    {
    default:
    case RtecScheduler::DISJUNCTION:
      break;

    case RtecScheduler::CONJUNCTION:
    case RtecScheduler::OPERATION:
      {
        RtecScheduler::OS_Priority os_priority;
        RtecScheduler::Preemption_Subpriority_t p_subpriority;
        RtecScheduler::Preemption_Priority_t p_priority;
        this->scheduler_->priority (this->rt_info_,
                                    os_priority,
                                    p_subpriority,
                                    p_priority
                                     ACE_ENV_ARG_PARAMETER);
        ACE_CHECK;
        qos_info.preemption_priority = p_priority;
      }
    }
}

void
TAO_EC_Kokyu_Filter::push (const RtecEventComm::EventSet &event,
                           TAO_EC_QOS_Info& qos_info
                           ACE_ENV_ARG_DECL)
{
  if (this->parent () != 0)
    {
      this->compute_qos_info (qos_info ACE_ENV_ARG_PARAMETER);
      ACE_CHECK;

      this->parent ()->push (event, qos_info ACE_ENV_ARG_PARAMETER);
      ACE_CHECK;
    }
}

void
TAO_EC_Kokyu_Filter::push_nocopy (RtecEventComm::EventSet &event,
                                  TAO_EC_QOS_Info& qos_info
                                  ACE_ENV_ARG_DECL)
{
  if (this->parent () != 0)
    {
      this->compute_qos_info (qos_info ACE_ENV_ARG_PARAMETER);
      ACE_CHECK;

      this->parent ()->push_nocopy (event, qos_info ACE_ENV_ARG_PARAMETER);
      ACE_CHECK;
    }
}

void
TAO_EC_Kokyu_Filter::clear (void)
{
  this->body_->clear ();
}

CORBA::ULong
TAO_EC_Kokyu_Filter::max_event_size (void) const
{
  return this->body_->max_event_size ();
}

int
TAO_EC_Kokyu_Filter::can_match (const RtecEventComm::EventHeader& header) const
{
  return this->body_->can_match (header);
}

/* 
    Kokyu_Filter
        |
        |body
        |
    Con/DisjunctionFilter
        |
        |children
        |*
    Kokyu_Filter
        |
        |body
        |
    Type_Filter

The entire hierarchy will have the same rt_info as the root. Only the root
rt_info will be part of the dependency graph in the scheduler. The root
rt_info will have a dependency on the consumer rt_info. 

<--- shows dependency (oneway)

supplier1<-----|
          con/disj_rt_info<-------consumer_rt_info
supplier2<-----|
*/

int
TAO_EC_Kokyu_Filter::add_dependencies (const RtecEventComm::EventHeader& header,
                                       const TAO_EC_QOS_Info &qos_info
                                       ACE_ENV_ARG_DECL)
{
#ifdef EC_KOKYU_LOGGING
  ACE_DEBUG ((LM_DEBUG, "Entering EC_Kokyu_Filter::add_dependencies\n"));
#endif
  this->init_rt_info (ACE_ENV_SINGLE_ARG_PARAMETER);
  ACE_CHECK_RETURN (0);

#ifdef EC_KOKYU_LOGGING
  ACE_DEBUG ((LM_DEBUG, 
              "this->rt_info_ = %d, header.type = %d, qos_info.rt_info = %d\n",
              this->rt_info_, header.type, qos_info.rt_info));
#endif

  //this call the add_dependencies() on con/disjunction filter
  int matches = this->body_->add_dependencies (header,
                                               qos_info
                                               ACE_ENV_ARG_PARAMETER);
  ACE_CHECK_RETURN (0);

  if (matches != 0)
    {
#ifdef EC_KOKYU_LOGGING
      ACE_DEBUG ((LM_DEBUG, "Kokyu_Filter::matches != 0\n"));
#endif 
      this->scheduler_->add_dependency (this->rt_info_, qos_info.rt_info, 1,
                                        RtecBase::ONE_WAY_CALL
                                         ACE_ENV_ARG_PARAMETER);
      ACE_CHECK_RETURN (0);

      RtecScheduler::RT_Info_var info =
        this->scheduler_->get (qos_info.rt_info ACE_ENV_ARG_PARAMETER);
      ACE_CHECK_RETURN (0);
      ACE_DEBUG ((LM_DEBUG, "[%s][%d] ----> [%s][%d]\n",
                  this->name_.c_str (),
                  this->rt_info_,
                  info->entry_point.in (),
                  qos_info.rt_info));
    }
  else
    {
#ifdef EC_KOKYU_LOGGING
      ACE_DEBUG ((LM_DEBUG, "Kokyu_Filter::matches == 0\n"));
#endif 
    }

#ifdef EC_KOKYU_LOGGING
  ACE_DEBUG ((LM_DEBUG, "about to iterate thru children\n"));
#endif  
  ChildrenIterator end = this->end ();
  for (ChildrenIterator i = this->begin (); i != end; ++i)
    {
      (*i)->add_dependencies (header, qos_info ACE_ENV_ARG_PARAMETER);
      ACE_CHECK_RETURN (0);
    }
#ifdef EC_KOKYU_LOGGING
  ACE_DEBUG ((LM_DEBUG, "Exiting EC_Kokyu_Filter: add_dependencies\n"));
#endif
  return 0;
}

void
TAO_EC_Kokyu_Filter::get_qos_info (TAO_EC_QOS_Info& qos_info
                                   ACE_ENV_ARG_DECL)
{
  this->init_rt_info (ACE_ENV_SINGLE_ARG_PARAMETER);
  ACE_CHECK;

  qos_info.rt_info = this->rt_info_;
}

void
TAO_EC_Kokyu_Filter::init_rt_info (ACE_ENV_SINGLE_ARG_DECL)
{
  if (this->rt_info_computed_)
    return;

#if 1 //ifdef'ed from 1 to 0 by VS

  // Provide dummy values the scheduler will compute them based on the
  // dependencies and the fact that this is a DISJUNCTION.
  this->scheduler_->set (this->rt_info_,
                         RtecScheduler::VERY_LOW_CRITICALITY,
                         0, // worst_cast_execution_time
                         0, // typical_cast_execution_time
                         0, // cached_cast_execution_time
                         0, // period
                         RtecScheduler::VERY_LOW_IMPORTANCE,
                         0, // quantum
                         0, // threads
                         this->info_type_
                         ACE_ENV_ARG_PARAMETER);
  ACE_CHECK;
#endif  //ifdef'ed by VS

#if 0 //ifdef changed from 1 to 0 by VS
  if (this->body_info_ != this->rt_info_)
    {
      this->scheduler_->add_dependency (this->rt_info_,
                                        this->body_info_,
                                        1,
                                        RtecBase::TWO_WAY_CALL
                                         ACE_ENV_ARG_PARAMETER);
      ACE_CHECK;

      RtecScheduler::RT_Info_var info =
        this->scheduler_->get (this->body_info_ ACE_ENV_ARG_PARAMETER);
      ACE_CHECK;
      ACE_DEBUG ((LM_DEBUG, "[%s] ----> [%s]\n",
                  info->entry_point.in (),
                  this->name_.c_str ()));
    }
#endif /* 0 */

#if 0 //ifdef changed from 1 to 0 by VS
  this->scheduler_->add_dependency (this->parent_info_,
                                    this->rt_info_,
                                    1,
                                    RtecBase::TWO_WAY_CALL
                                     ACE_ENV_ARG_PARAMETER);
  ACE_CHECK;

  RtecScheduler::RT_Info_var info =
    this->scheduler_->get (this->parent_info_ ACE_ENV_ARG_PARAMETER);
  ACE_CHECK;
  ACE_DEBUG ((LM_DEBUG, "[%s] ----> [%s]\n",
              this->name_.c_str (),
              info->entry_point.in ()));
#endif /* 0 */

  this->rt_info_computed_ = 1;
}