diff options
Diffstat (limited to 'TAO/examples/Simulator/Event_Supplier/Event_Sup.cpp')
-rw-r--r-- | TAO/examples/Simulator/Event_Supplier/Event_Sup.cpp | 220 |
1 files changed, 110 insertions, 110 deletions
diff --git a/TAO/examples/Simulator/Event_Supplier/Event_Sup.cpp b/TAO/examples/Simulator/Event_Supplier/Event_Sup.cpp index a928c6dcd83..2b99cbe0b25 100644 --- a/TAO/examples/Simulator/Event_Supplier/Event_Sup.cpp +++ b/TAO/examples/Simulator/Event_Supplier/Event_Sup.cpp @@ -2,7 +2,7 @@ // // ============================================================================ // -// +// // = FILENAME // Event_Sup.cpp // @@ -57,15 +57,15 @@ Demo_Supplier::Internal_Demo_Consumer::Internal_Demo_Consumer (Demo_Supplier *im } -void +void Demo_Supplier::Internal_Demo_Consumer::push (const RtecEventComm::EventSet &events, - CORBA::Environment &env) -{ - this->impl_->push (events, env); + CORBA::Environment &env) +{ + this->impl_->push (events, env); ACE_DEBUG ((LM_DEBUG, "Internal Demo Consumer received push.\n")); } -void +void Demo_Supplier::Internal_Demo_Consumer::disconnect_push_consumer (CORBA::Environment &) { } @@ -76,7 +76,7 @@ Demo_Supplier::Internal_Demo_Supplier::Internal_Demo_Supplier (Demo_Supplier *im { } -void +void Demo_Supplier::Internal_Demo_Supplier::disconnect_push_supplier (CORBA::Environment &) { } @@ -99,7 +99,7 @@ Demo_Supplier::~Demo_Supplier (void) int Demo_Supplier::open_supplier (RtecEventChannelAdmin::EventChannel_ptr ec, - const char *name) + const char *name) { TAO_TRY @@ -114,18 +114,18 @@ Demo_Supplier::open_supplier (RtecEventChannelAdmin::EventChannel_ptr ec, // Generate the Real-time information this->rt_info_ = scheduler_->create (name, TAO_TRY_ENV); - - scheduler_->set (rt_info_, - ORBSVCS_Time::zero, - ORBSVCS_Time::zero, - ORBSVCS_Time::zero, - 2500000, - RtecScheduler::VERY_LOW, - ORBSVCS_Time::zero, - 1, - TAO_TRY_ENV); + + scheduler_->set (rt_info_, + ORBSVCS_Time::zero, + ORBSVCS_Time::zero, + ORBSVCS_Time::zero, + 2500000, + RtecScheduler::VERY_LOW_IMPORTANCE, + ORBSVCS_Time::zero, + 1, + TAO_TRY_ENV); TAO_CHECK_ENV; - + // Set the publications to report them to the event channel CORBA::Short x = 0; @@ -139,7 +139,7 @@ Demo_Supplier::open_supplier (RtecEventChannelAdmin::EventChannel_ptr ec, qos_.publications_[0].event_.ec_send_time_ = ORBSVCS_Time::zero; qos_.publications_[0].event_.data_.x = 0; qos_.publications_[0].event_.data_.y = 0; - qos_.publications_[0].event_.data_.any_value.replace (CORBA::_tc_short, &x, 0, TAO_TRY_ENV); + qos_.publications_[0].event_.data_.any_value.replace (CORBA::_tc_short, &x, 0, TAO_TRY_ENV); qos_.publications_[0].dependency_info_.number_of_calls = 1; qos_.publications_[0].dependency_info_.rt_info = rt_info_; qos_.publications_[1].event_.source_ = SOURCE_ID; @@ -157,21 +157,21 @@ Demo_Supplier::open_supplier (RtecEventChannelAdmin::EventChannel_ptr ec, // = Connect as a supplier. this->supplier_admin_ = - channel_admin_->for_suppliers (TAO_TRY_ENV); + channel_admin_->for_suppliers (TAO_TRY_ENV); TAO_CHECK_ENV; this->proxy_consumer_ = supplier_admin_->obtain_push_consumer (TAO_TRY_ENV); TAO_CHECK_ENV; - // In calling _this we get back an object reference and register the servant with + // In calling _this we get back an object reference and register the servant with // the POA RtecEventComm::PushSupplier_var objref = this->internal_demo_supplier_->_this (TAO_TRY_ENV); TAO_CHECK_ENV; // Connect the supplier to the proxy consumer this->proxy_consumer_->connect_push_supplier (objref.in (), - qos_, - TAO_TRY_ENV); + qos_, + TAO_TRY_ENV); TAO_CHECK_ENV; } @@ -204,7 +204,7 @@ Demo_Supplier::start_generating_events (void) // load the scheduling data for the simulation ACE_Unbounded_Queue<Schedule_Viewer_Data *> schedule_data; this->load_schedule_data (schedule_data); - ACE_Unbounded_Queue_Iterator<Schedule_Viewer_Data *> + ACE_Unbounded_Queue_Iterator<Schedule_Viewer_Data *> schedule_iter (schedule_data); if (schedule_iter.done ()) @@ -218,33 +218,33 @@ Demo_Supplier::start_generating_events (void) TAO_TRY { do { - RtecEventComm::Event event; - event.source_ = SOURCE_ID; - event.type_ = ACE_ES_EVENT_NOTIFICATION; - event.ttl_ = 1; - event.creation_time_ = ORBSVCS_Time::zero; - event.ec_recv_time_ = ORBSVCS_Time::zero; - event.ec_send_time_ = ORBSVCS_Time::zero; - event.data_.x = 0; - event.data_.y = 0; - - this->insert_event_data (event.data_.any_value, schedule_iter); - - RtecEventComm::EventSet events; - events.length (1); - events[0] = event; - - proxy_consumer_->push (events, TAO_TRY_ENV); - TAO_CHECK_ENV; - - if (total_sent_ < 5) - ACE_DEBUG ((LM_DEBUG, "Pushing event data.\n")); - else if (total_sent_ == 5) - ACE_DEBUG ((LM_DEBUG, "Everything is running. Going to be mute.\n")); + RtecEventComm::Event event; + event.source_ = SOURCE_ID; + event.type_ = ACE_ES_EVENT_NOTIFICATION; + event.ttl_ = 1; + event.creation_time_ = ORBSVCS_Time::zero; + event.ec_recv_time_ = ORBSVCS_Time::zero; + event.ec_send_time_ = ORBSVCS_Time::zero; + event.data_.x = 0; + event.data_.y = 0; + + this->insert_event_data (event.data_.any_value, schedule_iter); + + RtecEventComm::EventSet events; + events.length (1); + events[0] = event; + + proxy_consumer_->push (events, TAO_TRY_ENV); + TAO_CHECK_ENV; + + if (total_sent_ < 5) + ACE_DEBUG ((LM_DEBUG, "Pushing event data.\n")); + else if (total_sent_ == 5) + ACE_DEBUG ((LM_DEBUG, "Everything is running. Going to be mute.\n")); } while (++total_sent_ < total_messages); - + // Sending a shutdown event -- not wanted right now /* RtecEventComm::Event event; event.source_ = SOURCE_ID; @@ -282,7 +282,7 @@ Demo_Supplier::start_generating_events (void) } } - this->shutdown (); + this->shutdown (); } @@ -308,7 +308,7 @@ Demo_Supplier::load_schedule_data ( char *temp = input_buf; while ((*temp) && (isspace (*temp))) { - ++temp; + ++temp; } // if there is anything besides whitespace in the line read, @@ -322,12 +322,12 @@ Demo_Supplier::load_schedule_data ( "Demo_Supplier::start_generating_events: " "memory allocation for scheduling data failed\n")); return; - } - + } + scan_count = sscanf (temp, "%s %lf %lf %lu %lu %lu %lu", - &(data->operation_name), &(data->utilitzation), + &(data->operation_name), &(data->utilitzation), &(data->overhead), &(data->arrival_time), - &(data->deadline_time), &(data->completion_time), + &(data->deadline_time), &(data->completion_time), &(data->computation_time)); if (scan_count != 7) { @@ -338,7 +338,7 @@ Demo_Supplier::load_schedule_data ( delete data; return; } - + // insert the data into the queue schedule_data.enqueue_tail (data); } @@ -348,7 +348,7 @@ Demo_Supplier::load_schedule_data ( { ACE_ERROR ((LM_ERROR, "Demo_Supplier::start_generating_events: " - "could not open input file [%s].\n", + "could not open input file [%s].\n", input_file_name)); return; } @@ -367,7 +367,7 @@ Demo_Supplier::load_schedule_data ( "Demo_Supplier::start_generating_events: " "memory allocation for scheduling data failed\n")); return; - } + } char *oper_name = 0; @@ -400,9 +400,9 @@ Demo_Supplier::load_schedule_data ( data->computation_time = (ACE_OS::rand() % 100)+10; data->completion_time = last_completion + (ACE_OS::rand() % 100) + 100; - data->completion_time = + data->completion_time = data->completion_time < data->arrival_time + data->computation_time - ? data->arrival_time + data->computation_time + ? data->arrival_time + data->computation_time : data->completion_time; last_completion = data->completion_time; @@ -411,11 +411,11 @@ Demo_Supplier::load_schedule_data ( // insert the data into the queue schedule_data.enqueue_tail (data); - } + } } } -// This function fills in the random data into the anys transported by +// This function fills in the random data into the anys transported by // the event channel void Demo_Supplier::insert_event_data ( @@ -468,9 +468,9 @@ Demo_Supplier::insert_event_data ( weapons_.weapon3.status = 0; weapons_.weapon4.identifier = CORBA::string_alloc (1); weapons_.weapon4.identifier[0] = 0; - weapons_.weapon4.status = 0; + weapons_.weapon4.status = 0; weapons_.weapon5.identifier = CORBA::string_alloc (1); - weapons_.weapon5.identifier[0] = 0; + weapons_.weapon5.identifier[0] = 0; weapons_.weapon5.status = 0; weapons_.utilitzation = (*sched_data)->utilitzation; @@ -495,23 +495,23 @@ Demo_Supplier::insert_event_data ( if ((*sched_data)->completion_time >= last_completion) { - ACE_Time_Value pause (0, (*sched_data)->completion_time - + ACE_Time_Value pause (0, (*sched_data)->completion_time - last_completion); ACE_OS::sleep (pause); last_completion = (*sched_data)->completion_time; } } - else + else { ACE_ERROR ((LM_ERROR, "Demo_Supplier::insert_event_data: Could Not access scheduling data")); } - + schedule_iter.advance (); if (schedule_iter.done ()) { schedule_iter.first (); } - } + } TAO_CATCHANY { ACE_ERROR ((LM_ERROR, "(%t)Error in Demo_Supplier::insert_event_data.\n")); @@ -519,10 +519,10 @@ Demo_Supplier::insert_event_data ( TAO_ENDTRY; } -void +void Demo_Supplier::push (const RtecEventComm::EventSet &events, - CORBA::Environment &env) -{ + CORBA::Environment &env) +{ } @@ -535,10 +535,10 @@ Demo_Supplier::shutdown (void) // @@ Had problems with the next command, the application got stuck in it // channel_admin_->destroy (TAO_TRY_ENV); // TAO_CHECK_ENV; - + TAO_ORB_Core_instance ()->orb ()->shutdown (); TAO_CHECK_ENV; - + } TAO_CATCHANY { @@ -568,8 +568,8 @@ get_options (int argc, char *argv []) switch (opt) { case '?': ACE_DEBUG ((LM_DEBUG, - "Usage: %s %s\n", - argv[0], usage)); + "Usage: %s %s\n", + argv[0], usage)); ACE_OS::exit (0); break; case 'm': @@ -581,8 +581,8 @@ get_options (int argc, char *argv []) else { ACE_ERROR_RETURN ((LM_ERROR, - "%s: count must be > 0", - argv[0]), 1); + "%s: count must be > 0", + argv[0]), 1); } break; case 'f': @@ -595,25 +595,25 @@ get_options (int argc, char *argv []) { input_file_name = 0; ACE_ERROR_RETURN ((LM_ERROR, - "%s: file name must be specified with -f option", - argv[0]), 1); + "%s: file name must be specified with -f option", + argv[0]), 1); } break; default: ACE_ERROR_RETURN ((LM_ERROR, - "%s: unknown arg, -%c\n" - "Usage: %s %s\n", - argv[0], char(opt), - argv[0], usage), 1); + "%s: unknown arg, -%c\n" + "Usage: %s %s\n", + argv[0], char(opt), + argv[0], usage), 1); } } if (argc != get_opt.optind) { ACE_ERROR_RETURN ((LM_ERROR, - "%s: too many arguments\n" - "Usage: %s %s\n", - argv[0], argv[0], usage), 1); + "%s: too many arguments\n" + "Usage: %s %s\n", + argv[0], argv[0], usage), 1); } return 0; @@ -637,37 +637,37 @@ main (int argc, char *argv []) // Connect to the RootPOA CORBA::Object_var poa_object = orb->resolve_initial_references("RootPOA"); if (CORBA::is_nil (poa_object.in ())) - { - ACE_ERROR_RETURN ((LM_ERROR, - " (%P|%t) Unable to initialize the POA.\n"), - 1); - } - + { + ACE_ERROR_RETURN ((LM_ERROR, + " (%P|%t) Unable to initialize the POA.\n"), + 1); + } + PortableServer::POA_var root_poa = PortableServer::POA::_narrow (poa_object.in (), TAO_TRY_ENV); TAO_CHECK_ENV; - + PortableServer::POAManager_var poa_manager = root_poa->the_POAManager (TAO_TRY_ENV); TAO_CHECK_ENV; // Get the Naming Service object reference CORBA::Object_var naming_obj = orb->resolve_initial_references ("NameService"); if (CORBA::is_nil (naming_obj.in ())) - { - ACE_ERROR_RETURN ((LM_ERROR, - " (%P|%t) Unable get the Naming Service.\n"), - 1); - } - - CosNaming::NamingContext_var naming_context = - CosNaming::NamingContext::_narrow (naming_obj.in (), TAO_TRY_ENV); + { + ACE_ERROR_RETURN ((LM_ERROR, + " (%P|%t) Unable get the Naming Service.\n"), + 1); + } + + CosNaming::NamingContext_var naming_context = + CosNaming::NamingContext::_narrow (naming_obj.in (), TAO_TRY_ENV); TAO_CHECK_ENV; // Tell the ScheduleService to use the same naming service ACE_Scheduler_Factory::use_config (naming_context.in ()); - + if (get_options (argc, argv)) - ACE_OS::exit (-1); + ACE_OS::exit (-1); // Get the Event Channel // @@ If you specify an invalid name, the Name Service crashes @@ -675,12 +675,12 @@ main (int argc, char *argv []) CosNaming::Name channel_name (1); channel_name.length (1); channel_name[0].id = CORBA::string_dup ("EventService"); - + CORBA::Object_var ec_obj = naming_context->resolve (channel_name, TAO_TRY_ENV); TAO_CHECK_ENV; RtecEventChannelAdmin::EventChannel_var ec = - RtecEventChannelAdmin::EventChannel::_narrow (ec_obj.in(), TAO_TRY_ENV); + RtecEventChannelAdmin::EventChannel::_narrow (ec_obj.in(), TAO_TRY_ENV); TAO_CHECK_ENV; // Create the demo supplier @@ -688,22 +688,22 @@ main (int argc, char *argv []) ACE_NEW_RETURN (demo_supplier, Demo_Supplier (SOURCE_ID), -1); if (demo_supplier->open_supplier (ec.ptr (), "demo_supplier") == -1) - ACE_ERROR_RETURN ((LM_ERROR, "Supplier open failed.\n"), -1); - + ACE_ERROR_RETURN ((LM_ERROR, "Supplier open failed.\n"), -1); + // Register the internal demo consumer for timeout events demo_supplier->start_generating_events (); - + ACE_DEBUG ((LM_DEBUG, "Supplier is registered for timeout events.\n")); // The POA Manager has to be activated before starting the ORB event loop poa_manager->activate (TAO_TRY_ENV); TAO_CHECK_ENV; - + // Run the ORB if (orb->run () == -1) - ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "CORBA::ORB::run"), -1); + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "CORBA::ORB::run"), -1); TAO_CHECK_ENV; |