summaryrefslogtreecommitdiff
path: root/TAO/examples/Simulator/Event_Supplier/Event_Sup.cpp
diff options
context:
space:
mode:
authormk1 <mk1@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-03-21 23:58:03 +0000
committermk1 <mk1@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-03-21 23:58:03 +0000
commite6480acfb1f6ca1ec2622a0c7b9054412c8588b1 (patch)
treed088e8e5da79e438832e17f9a5983e7fffb31219 /TAO/examples/Simulator/Event_Supplier/Event_Sup.cpp
parentee93e4f1e3a7b917d211fda735435169a6587683 (diff)
downloadATCD-e6480acfb1f6ca1ec2622a0c7b9054412c8588b1.tar.gz
Sat Mar 21 17:55:40 1998 Michael Kircher <mk1@cs.wustl.edu>
Diffstat (limited to 'TAO/examples/Simulator/Event_Supplier/Event_Sup.cpp')
-rw-r--r--TAO/examples/Simulator/Event_Supplier/Event_Sup.cpp157
1 files changed, 79 insertions, 78 deletions
diff --git a/TAO/examples/Simulator/Event_Supplier/Event_Sup.cpp b/TAO/examples/Simulator/Event_Supplier/Event_Sup.cpp
index 47248a365b6..be91752621e 100644
--- a/TAO/examples/Simulator/Event_Supplier/Event_Sup.cpp
+++ b/TAO/examples/Simulator/Event_Supplier/Event_Sup.cpp
@@ -382,8 +382,9 @@ Demo_Supplier::load_schedule_data
oper_name,
BUFSIZ-1);
- data->utilitzation = ((double)(ACE_OS::rand() %100)) / 100.0;
- data->overhead = ((double)(ACE_OS::rand() %20)) / 100.0;
+
+ data->utilitzation = (double)(20.0+ACE_OS::rand() %10);
+ data->overhead = (double)(ACE_OS::rand() %20);
data->arrival_time = ACE_OS::rand() % 200;
data->computation_time = (ACE_OS::rand() % 100) + 10;
@@ -417,89 +418,89 @@ Demo_Supplier::insert_event_data (CORBA::Any &data,
{
Schedule_Viewer_Data **sched_data;
- if (schedule_iter.next (sched_data) && sched_data && *sched_data)
+ if ((schedule_iter.next (sched_data)) && (sched_data) && (*sched_data))
+ {
+ if ((strcmp((*sched_data)->operation_name, "high_20") == 0) ||
+ (strcmp((*sched_data)->operation_name, "low_20") == 0) ||
+ (strcmp((*sched_data)->operation_name, "high_1") == 0) ||
+ (strcmp((*sched_data)->operation_name, "low_1") == 0))
{
- if ((ACE_OS::strcmp ((*sched_data)->operation_name, "high_20") == 0)
- || (ACE_OS::strcmp ((*sched_data)->operation_name, "low_20") == 0)
- || (ACE_OS::strcmp ((*sched_data)->operation_name, "high_1") == 0)
- || (ACE_OS::strcmp ((*sched_data)->operation_name, "low_1") == 0))
- {
- navigation_.position_latitude = ACE_OS::rand() % 90;
- navigation_.position_longitude = ACE_OS::rand() % 180;
- navigation_.altitude = ACE_OS::rand() % 100;
- navigation_.heading = ACE_OS::rand() % 180;
- navigation_.roll = (navigation_.roll == 180) ? -180 : navigation_.roll + 1;
- navigation_.pitch = (navigation_.pitch == 90) ? -90 : navigation_.pitch + 1;
-
- navigation_.utilitzation = (*sched_data)->utilitzation;
- navigation_.overhead = (*sched_data)->overhead;
- navigation_.arrival_time = (*sched_data)->arrival_time;
- navigation_.deadline_time = (*sched_data)->deadline_time;
- navigation_.completion_time = (*sched_data)->completion_time;
- navigation_.computation_time = (*sched_data)->computation_time;
-
- // Because sched_data does not contain utilization and
- // overhead data.
- navigation_.utilitzation = ACE_OS::rand() % 100;
- navigation_.overhead = ACE_OS::rand() % 20;
-
- data.replace (_tc_Navigation, &navigation_, CORBA::B_TRUE, TAO_TRY_ENV);
- }
- else if ((ACE_OS::strcmp ((*sched_data)->operation_name, "high_10") == 0)
- || (ACE_OS::strcmp ((*sched_data)->operation_name, "low_10") == 0)
- || (ACE_OS::strcmp ((*sched_data)->operation_name, "high_5") == 0)
- || (ACE_OS::strcmp ((*sched_data)->operation_name, "low_5") == 0))
- {
- weapons_.number_of_weapons = 2;
- weapons_.weapon1_identifier = CORBA::string_alloc (30);
- ACE_OS::strcpy (weapons_.weapon1_identifier,"Photon Torpedoes");
- weapons_.weapon1_status =(ACE_OS::rand() % 4) == 0 ? 0 : 1 ;
- weapons_.weapon2_identifier = CORBA::string_alloc (30);
- ACE_OS::strcpy (weapons_.weapon2_identifier,"Quantum Torpedoes");
- weapons_.weapon2_status = (ACE_OS::rand() % 4) == 0 ? 0 : 1;
- weapons_.weapon3_identifier = CORBA::string_alloc (1);
- ACE_OS::strcpy (weapons_.weapon3_identifier, "");
- weapons_.weapon3_status = 0;
- weapons_.weapon4_identifier = CORBA::string_alloc (1);
- ACE_OS::strcpy (weapons_.weapon4_identifier, "");
- weapons_.weapon4_status = 0;
- weapons_.weapon5_identifier = CORBA::string_alloc (1);
- ACE_OS::strcpy (weapons_.weapon5_identifier, "");
- weapons_.weapon5_status = 0;
-
- weapons_.utilitzation = (*sched_data)->utilitzation;
- weapons_.overhead = (*sched_data)->overhead;
- weapons_.arrival_time = (*sched_data)->arrival_time;
- weapons_.deadline_time = (*sched_data)->deadline_time;
- weapons_.completion_time = (*sched_data)->completion_time;
- weapons_.computation_time = (*sched_data)->computation_time;
-
- // Because sched_data does not contain utilization and
- // overhead data.
- weapons_.utilitzation = ACE_OS::rand() % 100;
- weapons_.overhead = ACE_OS::rand() % 20;
-
- data.replace (_tc_Weapons, &weapons_, CORBA::B_TRUE, TAO_TRY_ENV);
- }
- else
- ACE_ERROR ((LM_ERROR, "Demo_Supplier::insert_event_data: unrecognized operation name [%s]",
- (*sched_data)->operation_name));
-
- if (last_completion > (*sched_data)->completion_time)
- last_completion = 0;
+ navigation_.position_latitude = ACE_OS::rand() % 90;
+ navigation_.position_longitude = ACE_OS::rand() % 180;
+ navigation_.altitude = ACE_OS::rand() % 100;
+ navigation_.heading = ACE_OS::rand() % 180;
+ navigation_.roll = (navigation_.roll == 180) ? -180 : navigation_.roll + 1;
+ navigation_.pitch = (navigation_.pitch == 90) ? -90 : navigation_.pitch + 1;
+
+ navigation_.utilization = (*sched_data)->utilitzation;
+ navigation_.overhead = (*sched_data)->overhead;
+ navigation_.arrival_time = (*sched_data)->arrival_time;
+ navigation_.deadline_time = (*sched_data)->deadline_time;
+ navigation_.completion_time = (*sched_data)->completion_time;
+ navigation_.computation_time = (*sched_data)->computation_time;
+
+ // because the scheduler data does not supply these values
+ navigation_.utilization = (double) (20.0 + ACE_OS::rand() % 10);
+ navigation_.overhead = (double) (ACE_OS::rand() % 10);
+
+ data.replace (_tc_Navigation, &navigation_, CORBA::B_TRUE, TAO_TRY_ENV);
+ }
+ else if ((strcmp((*sched_data)->operation_name, "high_10") == 0) ||
+ (strcmp((*sched_data)->operation_name, "low_10") == 0) ||
+ (strcmp((*sched_data)->operation_name, "high_5") == 0) ||
+ (strcmp((*sched_data)->operation_name, "low_5") == 0))
+ {
+ weapons_.number_of_weapons = 2;
+ weapons_.weapon1_identifier = CORBA::string_alloc (30);
+ strcpy (weapons_.weapon1_identifier,"Photon Torpedoes");
+ weapons_.weapon1_status =(ACE_OS::rand() % 4) == 0 ? 0 : 1 ;
+ weapons_.weapon2_identifier = CORBA::string_alloc (30);
+ strcpy (weapons_.weapon2_identifier,"Quantum Torpedoes");
+ weapons_.weapon2_status = (ACE_OS::rand() % 4) == 0 ? 0 : 1;
+ weapons_.weapon3_identifier = CORBA::string_alloc (1);
+ strcpy (weapons_.weapon3_identifier, "");
+ weapons_.weapon3_status = 0;
+ weapons_.weapon4_identifier = CORBA::string_alloc (1);
+ strcpy (weapons_.weapon4_identifier, "");
+ weapons_.weapon4_status = 0;
+ weapons_.weapon5_identifier = CORBA::string_alloc (1);
+ strcpy (weapons_.weapon5_identifier, "");
+ weapons_.weapon5_status = 0;
+
+ weapons_.utilization = (*sched_data)->utilitzation;
+ weapons_.overhead = (*sched_data)->overhead;
+ weapons_.arrival_time = (*sched_data)->arrival_time;
+ weapons_.deadline_time = (*sched_data)->deadline_time;
+ weapons_.completion_time = (*sched_data)->completion_time;
+ weapons_.computation_time = (*sched_data)->computation_time;
+
+ // because the scheduler data does not supply these values
+ weapons_.utilization = (double) (20.0 + ACE_OS::rand() % 10);
+ weapons_.overhead = (double) (ACE_OS::rand() % 10);
+
+ data.replace (_tc_Weapons, &weapons_, CORBA::B_TRUE, TAO_TRY_ENV);
+ }
+ else
+ {
+ ACE_ERROR ((LM_ERROR, "Demo_Supplier::insert_event_data: unrecognized operation name [%s]",
+ (*sched_data)->operation_name));
+ }
- if ((*sched_data)->completion_time >= last_completion)
- {
- ACE_Time_Value pause (0,
+ if (last_completion > (*sched_data)->completion_time)
+ last_completion = 0;
+
+ if ((*sched_data)->completion_time >= last_completion)
+ {
+ ACE_Time_Value pause (0,
(*sched_data)->completion_time - last_completion);
- ACE_OS::sleep (pause);
- last_completion = (*sched_data)->completion_time;
- }
+ ACE_OS::sleep (pause);
+ last_completion = (*sched_data)->completion_time;
+ }
}
else
ACE_ERROR ((LM_ERROR,
"Demo_Supplier::insert_event_data: Could Not access scheduling data"));
-
+
schedule_iter.advance ();
if (schedule_iter.done ())