00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef _stub_real_time_task_hh
00019 #define _stub_real_time_task_hh
00020
00021 #include <time_util.h>
00022
00023 #include "BrokerS.h"
00024
00025
00026
00027
00028 class StubRealTimeTask : public POA_Broker::RealTimeTask
00029 {
00030
00031 public:
00032
00033
00034
00035
00036 StubRealTimeTask(const char *name)
00037 {
00038 this->srtt_Name = name;
00039 };
00040
00041
00042
00043
00044 virtual ~StubRealTimeTask()
00045 {
00046 };
00047
00048
00049
00050
00051 virtual char *Name()
00052 throw (CORBA::SystemException)
00053 {
00054 return( this->srtt_Name._retn() );
00055 };
00056
00057
00058
00059
00060
00061
00062
00063 virtual void BeginCPUScheduling(Broker::Manager_ptr manager,
00064 const Broker::ScheduleParameters &sp)
00065 throw (CORBA::SystemException,
00066 Broker::DuplicateScheduleParameter,
00067 Broker::InvalidScheduleParameter,
00068 Broker::MissingScheduleParameter)
00069 {
00070 CORBA::ULongLong period = ~0, deadline = ~0;
00071 unsigned int lpc;
00072 const char *str;
00073
00074 this->srtt_Manager = Broker::Manager::_duplicate(manager);
00075 for( lpc = 0; lpc < sp.length(); lpc++ )
00076 {
00077 if( strcasecmp(sp[lpc].name.in(), "period") == 0 )
00078 {
00079 CORBA::ULong period_ul;
00080
00081 if( period != ~0ULL )
00082 {
00083 throw Broker::DuplicateScheduleParameter("period");
00084 }
00085 else if( sp[lpc].value >>= period_ul )
00086 {
00087 period = period_ul;
00088 }
00089 else if( (sp[lpc].value >>= str) &&
00090 string_to_microsec(&period, str) )
00091 {
00092 }
00093 else
00094 {
00095 throw Broker::InvalidScheduleParameter(
00096 "'period' is not a time",
00097 sp[lpc]);
00098 }
00099 }
00100 else if( strcasecmp(sp[lpc].name.in(), "deadline") == 0 )
00101 {
00102 CORBA::ULong deadline_ul;
00103
00104 if( deadline != ~0ULL )
00105 {
00106 throw Broker::DuplicateScheduleParameter("deadline");
00107 }
00108 else if( sp[lpc].value >>= deadline_ul )
00109 {
00110 deadline = deadline_ul;
00111 }
00112 else if( (sp[lpc].value >>= str) &&
00113 string_to_microsec(&deadline, str) )
00114 {
00115 }
00116 else
00117 {
00118 throw Broker::InvalidScheduleParameter(
00119 "'deadline' is not a time",
00120 sp[lpc]);
00121 }
00122 }
00123 }
00124
00125
00126 if( period == ~0ULL )
00127 {
00128 throw Broker::MissingScheduleParameter("period");
00129 }
00130
00131 if( deadline == ~0ULL )
00132 {
00133 deadline = period;
00134 }
00135
00136 this->srtt_Period = period;
00137 this->srtt_Deadline = deadline;
00138 };
00139
00140
00141
00142
00143 virtual void EndCPUScheduling(void)
00144 throw (CORBA::SystemException)
00145 {
00146 this->srtt_Manager = Broker::Manager::_nil();
00147 };
00148
00149
00150 virtual CORBA::ULong Period(void)
00151 throw (CORBA::SystemException)
00152 {
00153 return( this->srtt_Period );
00154 };
00155
00156
00157 virtual CORBA::ULong Deadline(void)
00158 throw (CORBA::SystemException)
00159 {
00160 return( this->srtt_Deadline );
00161 };
00162
00163
00164 virtual CORBA::ULong GetComputeTime(void)
00165 throw (CORBA::SystemException)
00166 {
00167 return( this->srtt_ComputeTime );
00168 };
00169
00170
00171 virtual void SetComputeTime(CORBA::ULong usecs)
00172 throw (CORBA::SystemException)
00173 {
00174 this->srtt_ComputeTime = usecs;
00175 };
00176
00177
00178 virtual void ReportCPU(Broker::RealTimeTask_ptr rtt,
00179 CORBA::ULong status,
00180 CORBA::ULong advice)
00181 throw (CORBA::SystemException)
00182 {
00183 this->srtt_Manager->ChangeTaskCPU(rtt,
00184 this->srtt_ComputeTime,
00185 status,
00186 advice);
00187 };
00188
00189 private:
00190
00191
00192
00193
00194
00195 Broker::Manager_var srtt_Manager;
00196
00197
00198
00199
00200 CORBA::String_var srtt_Name;
00201
00202
00203
00204
00205 CORBA::ULong srtt_Period;
00206
00207
00208
00209
00210 CORBA::ULong srtt_Deadline;
00211
00212
00213
00214
00215 CORBA::ULong srtt_ComputeTime;
00216
00217 };
00218
00219 #endif