summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/examples/RtEC/Federated_Kokyu/dynamic_topology_test/Kokyu_EC.h
blob: c106eab7c5ea33ffbc7ad73f3c646fb0a26ba50c (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
// $Id$

#ifndef KOKYU_EC_H
#define KOKYU_EC_H

#include "Supplier.h"
#include "Consumer.h"
#include "ace/Vector_T.h"
#include "ace/Task_T.h"
#include "ace/Reactor.h"
#include "ace/Select_Reactor_Base.h" //for ACE_Select_Reactor_Impl::DEFAULT_SIZE

#include "RtSchedEventChannelS.h"
#include "tao/Utils/Servant_Var.h"
#include "orbsvcs/Event/EC_Event_Channel.h"

class Kokyu_EC : public POA_RtEventChannelAdmin::RtSchedEventChannel
{
public:
    typedef ACE_Vector<RtecEventComm::EventType> EventType_Vector;

    Kokyu_EC(void);

    virtual ~Kokyu_EC(void);

    ACE_INLINE static RtecScheduler::Period_t time_val_to_period (const ACE_Time_Value &tv)
    {
      //100s of nanoseconds
      return (tv.sec () * 1000000 + tv.usec ())*10;
    }

    int init(const char* schedule_discipline, PortableServer::POA_ptr poa);

    virtual RtEventChannelAdmin::handle_t register_consumer (
        const char * entry_point,
        const RtEventChannelAdmin::SchedInfo & info,
        EventType_Vector& cons_types, //RtecEventComm::EventType type,
        RtecEventComm::PushConsumer_ptr consumer,
        RtecEventChannelAdmin::ProxyPushSupplier_out proxy_supplier
        ACE_ENV_ARG_DECL
      )
      ACE_THROW_SPEC ((
        CORBA::SystemException
        , RtecScheduler::UNKNOWN_TASK
        , RtecScheduler::INTERNAL
        , RtecScheduler::SYNCHRONIZATION_FAILURE
      ));

    virtual RtEventChannelAdmin::handle_t register_supplier (
        const char * entry_point,
        RtecEventComm::EventSourceID source,
        EventType_Vector& supp_types, //RtecEventComm::EventType type,
        RtecEventComm::PushSupplier_ptr supplier,
        RtecEventChannelAdmin::ProxyPushConsumer_out proxy_consumer
        ACE_ENV_ARG_DECL
      )
      ACE_THROW_SPEC ((
        CORBA::SystemException
        , RtecScheduler::UNKNOWN_TASK
        , RtecScheduler::INTERNAL
        , RtecScheduler::SYNCHRONIZATION_FAILURE
      ));


    virtual void add_dependency (
        RtEventChannelAdmin::handle_t handle,
        RtEventChannelAdmin::handle_t dependency,
        CORBA::Long number_of_calls,
        RtecScheduler::Dependency_Type_t dependency_type
        ACE_ENV_ARG_DECL
      )
      ACE_THROW_SPEC ((
        CORBA::SystemException
        , RtecScheduler::SYNCHRONIZATION_FAILURE
        , RtecScheduler::UNKNOWN_TASK
      ));

    virtual void start (ACE_ENV_SINGLE_ARG_DECL)
      ACE_THROW_SPEC ((
        CORBA::SystemException
        , RtecScheduler::UNKNOWN_TASK
        , RtecScheduler::INTERNAL
        , RtecScheduler::SYNCHRONIZATION_FAILURE
      ));

    virtual RtecEventChannelAdmin::EventChannel_ptr event_channel (ACE_ENV_SINGLE_ARG_DECL)
      ACE_THROW_SPEC ((CORBA::SystemException));

    virtual RtecScheduler::Scheduler_ptr scheduler (ACE_ENV_SINGLE_ARG_DECL)
      ACE_THROW_SPEC ((CORBA::SystemException));

    ///Takes ownership of Supplier and Timeout_Consumer
    void add_supplier_with_timeout(
                                   Supplier * supplier_impl,
                                   const char * supp_entry_point,
                                   EventType_Vector& supp_types, //RtecEventComm::EventType supp_type,
                                   Timeout_Consumer * timeout_consumer_impl,
                                   const char * timeout_entry_point,
                                   ACE_Time_Value period,
                                   RtecScheduler::Criticality_t crit,
                                   RtecScheduler::Importance_t imp
                                   ACE_ENV_ARG_DECL
                                   )
      ACE_THROW_SPEC ((
                       CORBA::SystemException
                       , RtecScheduler::UNKNOWN_TASK
                       , RtecScheduler::INTERNAL
                       , RtecScheduler::SYNCHRONIZATION_FAILURE
                       ));

  ///Takes ownership of Timeout_Consumer
  void add_timeout_consumer(
                            Supplier * supplier_impl,
                            Timeout_Consumer * timeout_consumer_impl,
                            const char * timeout_entry_point,
                            ACE_Time_Value period,
                            RtecScheduler::Criticality_t crit,
                            RtecScheduler::Importance_t imp
                            ACE_ENV_ARG_DECL
                            )
    ACE_THROW_SPEC ((
                     CORBA::SystemException
                     , RtecScheduler::UNKNOWN_TASK
                     , RtecScheduler::INTERNAL
                     , RtecScheduler::SYNCHRONIZATION_FAILURE
                     ));

    ///Takes ownership of Supplier
    void add_supplier(
                      Supplier * supplier_impl,
                      const char * entry_point,
                      EventType_Vector& supp_types //RtecEventComm::EventType type
                      ACE_ENV_ARG_DECL
                      )
      ACE_THROW_SPEC ((
                       CORBA::SystemException
                       , RtecScheduler::UNKNOWN_TASK
                       , RtecScheduler::INTERNAL
                       , RtecScheduler::SYNCHRONIZATION_FAILURE
                       ));

    ///Takes ownership of Consumer and Supplier
    void add_consumer_with_supplier(
                                    Consumer * consumer_impl,
                                    const char * cons_entry_point,
                                    ACE_Time_Value cons_period,
                                    EventType_Vector& cons_types, //RtecEventComm::EventType cons_type,
                                    RtecScheduler::Criticality_t cons_crit,
                                    RtecScheduler::Importance_t cons_imp,
                                    Supplier * supplier_impl,
                                    const char * supp_entry_point,
                                    EventType_Vector& supp_types //RtecEventComm::EventType supp_type
                                    ACE_ENV_ARG_DECL
                                    )
      ACE_THROW_SPEC ((
                       CORBA::SystemException
                       , RtecScheduler::UNKNOWN_TASK
                       , RtecScheduler::INTERNAL
                       , RtecScheduler::SYNCHRONIZATION_FAILURE
                       ));

    ///Takes ownership of Consumer
    void add_consumer(
                      Consumer * consumer_impl,
                      const char * entry_point,
                      ACE_Time_Value period,
                      EventType_Vector& cons_types, //RtecEventComm::EventType cons_type,
                      RtecScheduler::Criticality_t crit,
                      RtecScheduler::Importance_t imp
                      ACE_ENV_ARG_DECL
                      )
      ACE_THROW_SPEC ((
                       CORBA::SystemException
                       , RtecScheduler::UNKNOWN_TASK
                       , RtecScheduler::INTERNAL
                       , RtecScheduler::SYNCHRONIZATION_FAILURE
                       ));

    void add_dummy_supplier(EventType_Vector& supp_types
                            ACE_ENV_ARG_DECL
                            )
      ACE_THROW_SPEC ((
                       CORBA::SystemException
                       , RtecScheduler::UNKNOWN_TASK
                       , RtecScheduler::INTERNAL
                       , RtecScheduler::SYNCHRONIZATION_FAILURE
                       ));

private:
  TAO::Utils::Servant_Var<POA_RtecScheduler::Scheduler> scheduler_impl_;
  TAO::Utils::Servant_Var<TAO_EC_Event_Channel> ec_impl_;
  RtecEventChannelAdmin::ConsumerAdmin_var consumer_admin_;
  RtecEventChannelAdmin::SupplierAdmin_var supplier_admin_;
  RtecScheduler::Scheduler_var scheduler_;

  ACE_Vector<Supplier*> suppliers_;
  ACE_Vector<Timeout_Consumer*> timeout_consumers_;
  ACE_Vector<Consumer*> consumers_;
}; //class Kokyu_EC

class Reactor_Task : public ACE_Task<ACE_SYNCH>
{
public:
  /// Constructor
  Reactor_Task (void);

  ~Reactor_Task (void);

  int initialize(void);

  ACE_Reactor *reactor(void);

  /// Process the events in the queue.
  int svc (void);

private:
  int initialized_;

  ACE_Reactor *react_;
}; //class Reactor_Task

#endif