00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "config.h"
00019
00020
00021 #if !defined(DEBUG)
00022 #define DEBUG 1
00023 #endif
00024
00025 #include <assert.h>
00026 #include <assert_pp.h>
00027
00028 #include <rk_stub.h>
00029
00030 #include <iostream>
00031
00032 #include <ManagerImpl.hh>
00033
00034 #include <ExactTaskFactory.hh>
00035 #include <ExactTaskAdvocate.hh>
00036
00037 #include "StubPolicy.hh"
00038
00039 #if defined(HAVE_QUO)
00040 #include <quo/QuoKernel.h>
00041 #endif
00042
00043 int main(int argc, char *argv[])
00044 {
00045 int retval = 0;
00046
00047 rk_stub_set_mode(RK_STUB_LOG);
00048
00049
00050 CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
00051 CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
00052
00053 PortableServer::POA_var root_poa = PortableServer::POA::_narrow(obj.in());
00054 PortableServer::POAManager_var mgr = root_poa->the_POAManager();
00055 mgr->activate();
00056
00057 Broker::RealTimeAdvocate_var rta;
00058 Broker::ScheduleParameters sp;
00059 Broker::Manager_var manager;
00060 Broker::TaskFactory_var tf;
00061 Broker::TaskParameters tp;
00062 Broker::Policy_var policy;
00063 Broker::Task_ptr task;
00064
00065 ManagerImpl mi("dummy");
00066 StubPolicy spi("dummy");
00067
00068 manager = mi._this();
00069 policy = spi._this();
00070
00071 manager->CurrentPolicy(policy.in());
00072
00073 pid_t c1;
00074
00075 c1 = rk_stub_mk_pid("test", NULL, NULL, NULL);
00076
00077 ExactTaskFactory etf("ExactTaskAdvocate");
00078
00079 tf = etf._this();
00080
00081 tp.length(2);
00082 tp[0].name = "name";
00083 tp[0].value <<= "test";
00084 tp[1].name = "pid";
00085 tp[1].value <<= (CORBA::Long)c1;
00086
00087 task = tf->CreateTask(tp);
00088
00089 assert(strcmp(task->Name(), "test") == 0);
00090
00091 rta = Broker::RealTimeAdvocate::_narrow(task);
00092
00093 sp.length(1);
00094 sp[0].name = "period";
00095 sp[0].value <<= (CORBA::ULong)10000;
00096
00097 rta->BeginCPUScheduling(manager.in(), sp);
00098
00099 cout << "old ct = " << rta->GetComputeTime() << endl;
00100 try
00101 {
00102 rta->ReportCPU(10);
00103 }
00104 catch(const CORBA::SystemException &e)
00105 {
00106 cerr << "se = " << e << endl;
00107 }
00108 cout << "new ct = " << rta->GetComputeTime() << endl;
00109
00110 #if defined(HAVE_QUO)
00111 {
00112 QUO_ValueSCImpl missed_sci;
00113 quo::ValueSC_var missed_sc;
00114
00115 missed_sc = missed_sci._this();
00116
00117 cout << "sc = " << missed_sc->longValue() << endl;
00118
00119 missed_sc->longValue(5);
00120 }
00121 #endif
00122
00123 rta->EndCPUScheduling();
00124
00125 return( retval );
00126 }