diff options
author | mk1 <mk1@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1998-04-15 00:36:21 +0000 |
---|---|---|
committer | mk1 <mk1@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1998-04-15 00:36:21 +0000 |
commit | 50b2cb259685ef0cd707adaa48ffa6786b68f77c (patch) | |
tree | a9474405d946a7ece70fa5ff3228307e375e017a | |
parent | 082c03a3aeabb96a15facae53ef6821ae1af900c (diff) | |
download | ATCD-50b2cb259685ef0cd707adaa48ffa6786b68f77c.tar.gz |
Removed the Sim_Display directorySim_Display
-rw-r--r-- | TAO/examples/Simulator/Sim_Display/Border_Panel.java | 57 | ||||
-rw-r--r-- | TAO/examples/Simulator/Sim_Display/Display.java | 92 | ||||
-rw-r--r-- | TAO/examples/Simulator/Sim_Display/Display_Art_Horizon.java | 377 | ||||
-rw-r--r-- | TAO/examples/Simulator/Sim_Display/Display_Client.java | 116 | ||||
-rw-r--r-- | TAO/examples/Simulator/Sim_Display/Display_Consumer.java | 172 | ||||
-rw-r--r-- | TAO/examples/Simulator/Sim_Display/Display_Object.java | 8 | ||||
-rw-r--r-- | TAO/examples/Simulator/Sim_Display/Display_Object_Factory.java | 42 | ||||
-rw-r--r-- | TAO/examples/Simulator/Sim_Display/Display_Push_Consumer.java | 248 | ||||
-rw-r--r-- | TAO/examples/Simulator/Sim_Display/Display_Weapons.java | 123 | ||||
-rw-r--r-- | TAO/examples/Simulator/Sim_Display/Graph.java | 163 | ||||
-rw-r--r-- | TAO/examples/Simulator/Sim_Display/Graph_Panel.java | 181 | ||||
-rw-r--r-- | TAO/examples/Simulator/Sim_Display/NS_Resolve.java | 112 | ||||
-rw-r--r-- | TAO/examples/Simulator/Sim_Display/Queue.java | 190 | ||||
-rw-r--r-- | TAO/examples/Simulator/Sim_Display/Sim_Panel.java | 64 |
14 files changed, 0 insertions, 1945 deletions
diff --git a/TAO/examples/Simulator/Sim_Display/Border_Panel.java b/TAO/examples/Simulator/Sim_Display/Border_Panel.java deleted file mode 100644 index 1c9b8099499..00000000000 --- a/TAO/examples/Simulator/Sim_Display/Border_Panel.java +++ /dev/null @@ -1,57 +0,0 @@ -// $Id$ -import java.awt.*; - -public class Border_Panel extends Panel -{ - private String title_; - private final static Insets SPACE = new Insets (16, 16, 16, 16); - - public Border_Panel (Component component, String title) - { - GridBagLayout gb = new GridBagLayout (); - GridBagConstraints gbc = new GridBagConstraints (); - - title_ = title; - setFont (new Font ("Dialog", Font.PLAIN, 12)); - setLayout (new CardLayout (SPACE.left, SPACE.top)); - - add ("Front", component); - } - - public void paint (Graphics g) - { - FontMetrics fm = g.getFontMetrics (); - Dimension d = getSize (); - int font_height = fm.getAscent (), - rect_x = SPACE.left/2, - rect_y = SPACE.top/2, - rect_width = d.width - SPACE.right, - rect_height = d.height - SPACE.top/2 - SPACE.bottom/2, - font_x = SPACE.left/2 + 20, - font_y = (int)Math.round (SPACE.top/2 + font_height/2.0 - 1); - - g.setColor (getBackground ()); - - g.draw3DRect (rect_x - 1, rect_y - 1, - rect_width + 1, rect_height + 1, false); - g.draw3DRect (rect_x, rect_y, - rect_width - 1, rect_height - 1, true); - g.fillRect (font_x - 2, 0, fm.stringWidth (title_) + 4, SPACE.top); - - g.setColor (Color.black); - g.drawString (title_, font_x, font_y); - } - - public static void main (String[] args) - { - Frame yadda = new Frame ("Border Frame Test"); - Panel blank = new Panel (); - Border_Panel bpanel = new Border_Panel (blank, "Border Panel"); - - yadda.setLayout (new BorderLayout ()); - yadda.add ("Center", bpanel); - yadda.setBounds (0, 0, 640, 480); - - yadda.show (); - } -} diff --git a/TAO/examples/Simulator/Sim_Display/Display.java b/TAO/examples/Simulator/Sim_Display/Display.java deleted file mode 100644 index 21def23be1d..00000000000 --- a/TAO/examples/Simulator/Sim_Display/Display.java +++ /dev/null @@ -1,92 +0,0 @@ -// $Id$ - - -import java.io.*; -import java.awt.*; - -public class Display extends Panel -{ - private Graph_Panel metrics_ = new Graph_Panel (); - private Sim_Panel sims_ = new Sim_Panel (); - private double last_latency = 0; - - public Display () - { - setLayout (new GridLayout (2, 1)); - add (new Border_Panel (sims_, "Flight Simulator")); - add (new Border_Panel (metrics_, "Scheduling Performance")); - } - - public void update_metric (String name, float new_value) - { - metrics_.updateGraph (name, new_value); - } - - public void add_metric (String name, int max) - { - metrics_.addGraph (name, max); - } - - public void add_simulator (String name) - { - Display_Object obj = - Display_Object_Factory.create_display_object (name); - - if (obj != null) - sims_.add_simulator (name, obj); - } - - public void update_simulator (String name, Display_Push_Consumer display_push_consumer) - { - sims_.update_simulator (name, display_push_consumer); - } - - - public void update_metrics (double utilization, - double overhead, - int arrival_time, - int deadline_time, - int completion_time, - int computation_time) - { - float latency = (float)(completion_time-computation_time-arrival_time); - latency = latency > 0 ? latency : 0; - float jitter = (float)Math.abs(latency - last_latency); - // float latency = (float)(dispatch_time - arrival_time > 0 ? dispatch_time - arrival_time : 0); - // float jitter = (float)Math.abs(latency - last_latency); - float missed_deadline = - (float)((deadline_time < completion_time) ? 1.0 : 0.0); - - /* - System.out.println ("Metrics: cpu " + header.utilization_ + - " overhead " + header.overhead_ + - " jitter " + jitter + - " deadlines " + missed_deadline + - " latency " + latency); - */ - update_metric (Display_Client.CPU_USAGE, (float)utilization); - update_metric (Display_Client.OVERHEAD, (float)overhead); - update_metric (Display_Client.JITTER, jitter); - update_metric (Display_Client.DEADLINES, missed_deadline); - update_metric (Display_Client.LATENCY, latency); - } - - public void update_simulation (long simulation_id, - Display_Push_Consumer display_push_consumer) - { - String sim_name = - Display_Object_Factory.resolve_name (simulation_id); - - if (sim_name != null) - update_simulator (sim_name, display_push_consumer); - } -} - - - - - - - - - diff --git a/TAO/examples/Simulator/Sim_Display/Display_Art_Horizon.java b/TAO/examples/Simulator/Sim_Display/Display_Art_Horizon.java deleted file mode 100644 index 4b5c9fd4fe9..00000000000 --- a/TAO/examples/Simulator/Sim_Display/Display_Art_Horizon.java +++ /dev/null @@ -1,377 +0,0 @@ -// $Id$ - - -import java.awt.*; -import java.io.*; - -public class Display_Art_Horizon - extends Panel - implements Display_Object -{ - private Alt_Horizon alt_hor_ = new Alt_Horizon (); - private Position pos_ = new Position (); - - public Display_Art_Horizon () - { - setLayout (new BorderLayout (0, 2)); - add ("Center", alt_hor_); - add ("South", pos_); - } - - public int update_display (Display_Push_Consumer display_push_consumer) - { - Navigation navigation = display_push_consumer.get_navigation (); - /* - System.out.println ("Art_Horizon: lat " + latitude + " long " + longitude + " alt " + - altitude + " heading " + heading + " roll " + - roll + " pitch " + pitch); - */ - - alt_hor_.update_display (navigation.roll, navigation.pitch); - pos_.update_display (navigation.position_latitude, navigation.position_longitude, navigation.altitude, navigation.heading); - - return 0; - } -} - -class Alt_Horizon -extends Canvas -{ - private final static Color GREEN = new Color (0, 100, 0), - BLUE = new Color (30, 144, 255); - - private Graphics offgraphics_; - private Image offscreen_; - private Dimension offscreensize_; - - private int roll_ = 0, pitch_ = 0; - - public void update_display (int roll, int pitch) - { - roll_ = roll; - pitch_ = pitch; - - repaint (); - } - - public Dimension getPreferredSize () - { - return new Dimension (180, 180); - } - - public void paint (Graphics g) - { - update (g); - } - - public void update (Graphics g) - { - Dimension d = getSize (); - int rad, angles[] = { 180, 0 }; - Point center; - - if ((offscreen_ == null) || (d.width != offscreensize_.width) || - (d.height != offscreensize_.height)) - { - offscreen_ = createImage (d.width, d.height); - offscreensize_ = new Dimension (d.width, d.height); - offgraphics_ = offscreen_.getGraphics (); - offgraphics_.setFont (getFont()); - - // g.setColor (Color.lightGray); - // g.draw3DRect (0, 0, d.width - 1, d.height - 1, true); - // g.draw3DRect (1, 1, d.width - 3, d.height - 3, true); - // g.draw3DRect (2, 2, d.width - 5, d.height - 5, true); - } - - offgraphics_.setColor (getBackground()); - offgraphics_.fillRect (0, 0, d.width, d.height); - offgraphics_.setColor (BLUE); - - // Calculate from the dimensions, the largest square. - center = new Point (d.width / 2, d.height / 2); - rad = ((center.x < center.y) ? center.x : center.y); - - // Draw a circle of blue - offgraphics_.fillOval (center.x - rad, center.y - rad, - 2*rad, 2*rad); - - // Roll the horizon based on the roll angle - if (roll_ != 0) - roll_horizon (rad, angles); - - // Pitch the horizon based on the pitch angle - if (pitch_ != 0) - pitch_horizon (rad, angles); - - // Draw the resulting terrain - draw_horizon (rad, center, angles); - - // Draw the plotted Image. - g.drawImage (offscreen_, 0, 0, null); - } - - private void draw_horizon (int rad, Point center, int[] angles) - { - // Draw an arc - int arc_angle = - ((angles[0] > angles[1]) ? - (360 - angles[0]) + angles[1] : - (angles[1] - angles[0])); - - Polygon remainder = new Polygon (); - - offgraphics_.setColor (GREEN); - offgraphics_.fillArc (center.x - rad, center.y - rad, - 2*rad, 2*rad, - angles[0], arc_angle); - - /* - System.out.println ("Start Angle " + angles[0] + - " End Angle " + angles[1] + - " Arc Angle " + arc_angle); - */ - if (pitch_ != 0) - { - if ((pitch_ > 0 && Math.abs (roll_) < 90) || - (pitch_ < 0 && Math.abs (roll_) >= 90)) - offgraphics_.setColor (BLUE); - - int cover_angle = (angles[0] + arc_angle/2 + ((arc_angle < 180) ? 180 : 0)) % 360; - - // System.out.println (points[0] + " " + points[1]); - - // System.out.println (accepted_point); - - remainder.addPoint (center.x + polar_to_rect_x (rad, cover_angle), - center.y - polar_to_rect_y (rad, cover_angle)); - remainder.addPoint (center.x + polar_to_rect_x (rad, angles[0]), - center.y - polar_to_rect_y (rad, angles[0])); - remainder.addPoint (center.x + polar_to_rect_x (rad, angles[1]), - center.y - polar_to_rect_y (rad, angles[1])); - offgraphics_.fillPolygon (remainder); - //offgraphics_.setColor (getBackground ()); - //offgraphics_.drawPolygon (remainder); - } - } - - private void pitch_horizon (int rad, int[] angles) - { - boolean upside_down = Math.abs (roll_) >= 90; - int angle_shift = (int) Math.round ((double)(90 - (Math.abs (roll_) % 180)) / 90.0 * pitch_); - - // System.out.println ("angle_shift " + angle_shift); - - angles[0] += angle_shift; - angles[1] -= angle_shift; - - // Shift the terrain line to account for the pitch. - // if (Math.abs (roll_) != 90) - // { - /* - boolean upside_down = Math.abs (roll_) >= 90; - double offset = - (double)rad * (double)pitch_ / 90.0; - double y_intercept = (Math.abs (roll_) <= 90) ? offset : offset; - double slope = caclulate_slope (rad, angles); - Point[] roots = null; - int x_l, x_r, y_l, y_r; - - roots = line_circle_intesect (rad, y_intercept, slope); - - // System.out.println ("Y intercept " + y_intercept + " slope " + slope); - // System.out.println ("Root x1 " + roots[0].x + " x2 " + roots[1].x); - // System.out.println ("Root y1 " + roots[0].y + " y2 " + roots[1].y); - // System.out.println ("Was left_point.x " + left_point.x + " left_point.y " + left_point.y); - // System.out.println ("Was right_point.x " + right_point.x + " right_point.y " + right_point.y); - - x_l = upside_down ? roots[0].x : roots[1].x; - y_l = upside_down ? roots[0].y : roots[1].y; - x_r = upside_down ? roots[1].x : roots[0].x; - y_r = upside_down ? roots[1].y : roots[0].y; - - angles[0] = calculate_angle (rad, x_l, y_l); - angles[1] = calculate_angle (rad, x_r, y_r); - - // System.out.println ("Now left_point.x " + left_point.x + " left_point.y " + left_point.y); - // System.out.println ("Now right_point.x " + right_point.x + " right_point.y " + right_point.y); - */ - // } - } - - private void roll_horizon (int rad, int[] angles) - { - // Roll the left and right points of the terrain. - angles[0] += roll_; - angles[1] += roll_; - - if (angles[0] < 0) - angles[0] += 360; - - if (angles[1] < 0) - angles[1] += 360; - - // boolean rightside_up = Math.abs (roll_) <= 90, - // positive_roll = roll_ >= 0; - // double roll_rad = (double) roll_ * Math.PI / 180.0; - // Point tmp = - // new Point ((int) Math.round ((double) rad * Math.cos (roll_rad)), - // (int) Math.round ((double) rad * Math.sin (roll_rad))); - - // System.out.println ("Was left_point.x " + left_point.x + " left_point.y " + left_point.y); - // System.out.println ("Was right_point.x " + right_point.x + " right_point.y " + right_point.y); - - // right_point.x = tmp.x; - // left_point.x = -tmp.x; - // right_point.y = tmp.y; - // left_point.y = -tmp.y; - - // System.out.println ("Now left_point.x " + left_point.x + " left_point.y " + left_point.y); - // System.out.println ("Now right_point.x " + right_point.x + " right_point.y " + right_point.y); - } - - private int polar_to_rect_x (int rad, int angle) - { - return (int) Math.round (rad * Math.cos ((double)angle * Math.PI/180.0)); - } - - private int polar_to_rect_y (int rad, int angle) - { - return (int) Math.round (rad * Math.sin ((double)angle * Math.PI/180.0)); - } - - private double caclulate_slope (int rad, int[] angles) - { - int x1 = polar_to_rect_x (rad, angles[0]), - x2 = polar_to_rect_x (rad, angles[1]), - y1 = polar_to_rect_y (rad, angles[0]), - y2 = polar_to_rect_y (rad, angles[1]); - - return ((double) (y2 - y1)) / ((double) (x2 - x1)); - } - - private Point[] line_circle_intesect (int rad, double y_intercept, double slope) - { - double r_2 = (double)(rad * rad), - s_2 = slope * slope, - a_x = s_2 + 1, - b_x = 2.0 * slope * y_intercept, - c_x = y_intercept * y_intercept - r_2; - int[] x_roots = quad_eq (a_x, b_x, c_x), - y_roots = { (int) Math.round ((double)((double) x_roots[0])*slope + y_intercept), - (int) Math.round ((double)((double) x_roots[1])*slope + y_intercept) }; - Point[] points = new Point [2]; - - points[0] = new Point (x_roots[0], y_roots[0]); - points[1] = new Point (x_roots[1], y_roots[1]); - - return points; - } - - private int calculate_angle (int rad, int x, int y) - { - /* - double angle = 0, - sin_value = Math.asin ((double)y / (double)rad), - tan_value = Math.atan ((double)y / (double)x); - - if (x >= 0) - angle = (x != 0) ? tan_value : sin_value + - ((y < 0) ? 2*Math.PI : 0); - else - angle = Math.PI + tan_value; - - return (int) Math.round (angle * 180.0 / Math.PI); - */ - - double angle = 0.0, - sin_value = Math.asin ((double)Math.abs (y) / (double)rad); - - if (x >= 0 && y >= 0) - angle = sin_value; - else if (x < 0 && y >= 0) - angle = sin_value + Math.PI/2.0; - else if (x < 0 && y < 0) - angle = sin_value + Math.PI; - else if (x >= 0 && y < 0) - angle = sin_value + 3.0*Math.PI/2.0; - - return (int) Math.round (angle * 180.0 / Math.PI); - } - - private int[] quad_eq (double a, double b, double c) - { - int[] roots = new int [2]; - double body = Math.sqrt (b*b - 4.0*a*c); - - roots[0] = (int) Math.round ((-b + body) / (2.0 * a)); - roots[1] = (int) Math.round ((-b - body) / (2.0 * a)); - - return roots; - } - - private int distance (Point point1, Point point2) - { - double xdiff = point1.x - point2.x, - ydiff = point1.y - point2.y; - - return (int) Math.round (Math.sqrt (xdiff*xdiff + ydiff*ydiff)); - } -} - -class Position -extends Panel -{ - private final static Font FONT = new Font ("Dialog", Font.BOLD, 12); - private final static char DEGREE = '\u00B0'; - - private Label lat_ = new Label ("0" + DEGREE + " N", Label.RIGHT), - long_ = new Label ("0" + DEGREE + " S", Label.RIGHT), - alt_ = new Label ("0 Kft", Label.RIGHT), - heading_ = new Label ("0" + DEGREE + " ", Label.RIGHT); - - public Position () - { - Panel grid_panel = new Panel (); - - lat_.setFont (FONT); - long_.setFont (FONT); - alt_.setFont (FONT); - heading_.setFont (FONT); - - setLayout (new GridLayout (1, 4)); - add (lat_); - add (long_); - add (heading_); - add (alt_); - - // lat_.setBackground (Color.lightGray); - // long_.setBackground (Color.lightGray); - // alt_.setBackground (Color.lightGray); - // heading_.setBackground (Color.lightGray); - - // setBackground (Color.black); - // setLayout (new CardLayout (1, 1)); - - // grid_panel.setBackground (Color.black); - // grid_panel.setLayout (new GridLayout(1, 4, 1, 0)); - // grid_panel.add (lat_); - // grid_panel.add (long_); - // grid_panel.add (alt_); - // grid_panel.add (heading_); - - // add ("Grid Panel", grid_panel); - } - - public void update_display (int lat, int lon, int alt, int heading) - { - String lat_str = - Math.abs (lat) + "" + DEGREE + ((lat > 0) ? " N" : " S"); - String long_str = - Math.abs (lon) + "" + DEGREE + ((lon > 0) ? " E" : " W"); - - lat_.setText (lat_str); - long_.setText (long_str); - alt_.setText (alt + " Kft"); - heading_.setText (heading + "" + DEGREE + " "); - } -} diff --git a/TAO/examples/Simulator/Sim_Display/Display_Client.java b/TAO/examples/Simulator/Sim_Display/Display_Client.java deleted file mode 100644 index d7140d54c3d..00000000000 --- a/TAO/examples/Simulator/Sim_Display/Display_Client.java +++ /dev/null @@ -1,116 +0,0 @@ -// $Id$ - -/** - * This class pulls the structured simulation data from a socket and - * funnels it into the display. - * - * @author Seth Widoff - * @version $Id$ - * modified by Michael Kircher on 1998/02/19 - */ - -import java.util.*; -import java.awt.*; - -class Display_Frame extends Frame -{ - MenuBar menubar_; - Menu menu_quit_; - MenuItem menu_quit_item_; - - public Display_Frame () - { - super (); - menubar_ = new MenuBar (); - menu_quit_ = new Menu ("Quit"); - menu_quit_item_ = new MenuItem ("Quit"); - menu_quit_item_.enable (); - menu_quit_.add (menu_quit_item_); - menubar_.add (menu_quit_); - - setMenuBar (menubar_); - } - - - - public boolean action (Event e, Object arg) - { - System.out.println ("action occured"); - if (e.target == menu_quit_item_) - { - System.exit (0); - return true; - } - return false; - } - -} - - -public class Display_Client // extends java.applet.Applet -{ - public final static int DEFAULT_PORT = 5555; - - public final static String CPU_USAGE = "CPU Usage (%)", - LATENCY = "Latency (ms)", - JITTER = "Jitter (ms)", - OVERHEAD = "Overhead (%)", - DEADLINES = "Missed Deadlines (#)"; - - -public synchronized void paint (Graphics g) {} - - public void init () - { - - String art_hor_name = - Display_Object_Factory.resolve_name - (Display_Object_Factory.ART_HORIZON_ENUM); - String weapons_name = - Display_Object_Factory.resolve_name - (Display_Object_Factory.WEAPONS_ENUM); - - display.add_metric (CPU_USAGE, 1); - display.add_metric (OVERHEAD, 1); - display.add_metric (JITTER, 10); - display.add_metric (LATENCY, 10); - display.add_metric (DEADLINES, 2); - display.add_simulator (weapons_name); - display.add_simulator (art_hor_name); - - display_consumer = new Display_Consumer (display); //, this.getParameter("NS_IOR"), this); - Dimension ss = Toolkit.getDefaultToolkit ().getScreenSize (); - - sim_frame.setResizable (false); - sim_frame.setTitle ("Scheduler Demo"); - sim_frame.setBounds (ss.width/2 - 275, ss.height/2 - 275, 700, 700); - sim_frame.setLayout (new BorderLayout ()); - sim_frame.add ("Center", display); - - sim_frame.show (); - - display_consumer.run (); - } - - - - public Display_Client () - { - sim_frame = new Display_Frame (); - display = new Display (); - - } - - private Frame sim_frame; - private Display display; - private Display_Consumer display_consumer; - - public static void main (String[] args) - { - - Display_Client display_client_ = new Display_Client (); - display_client_.init (); - } -} - - diff --git a/TAO/examples/Simulator/Sim_Display/Display_Consumer.java b/TAO/examples/Simulator/Sim_Display/Display_Consumer.java deleted file mode 100644 index 29b6f4e3535..00000000000 --- a/TAO/examples/Simulator/Sim_Display/Display_Consumer.java +++ /dev/null @@ -1,172 +0,0 @@ -// $Id$ -// -// ============================================================================ -// -// -// = FILENAME -// Display_Consumer.java -// -// = AUTHOR -// Michael Kircher (mk1@cs.wustl.edu) -// -// = DESCRIPTION -// This Consumer connects to the Event Channel (TAO Event Channel). -// It accepts Notification events containing Navigation and -// Weapons data. -// -// -// ============================================================================ - - - - -public class Display_Consumer { - - public static final int ACE_ES_EVENT_ANY = 0; - public static final int ACE_ES_EVENT_SHUTDOWN = 1; - public static final int ACE_ES_EVENT_ACT = 2; - public static final int ACE_ES_EVENT_NOTIFICATION = 3; - public static final int ACE_ES_EVENT_TIMEOUT = 4; - public static final int ACE_ES_EVENT_INTERVAL_TIMEOUT = 5; - public static final int ACE_ES_EVENT_DEADLINE_TIMEOUT = 6; - public static final int ACE_ES_GLOBAL_DESIGNATOR = 7; - public static final int ACE_ES_CONJUNCTION_DESIGNATOR = 8; - public static final int ACE_ES_DISJUNCTION_DESIGNATOR = 9; - public static final int ACE_ES_EVENT_UNDEFINED = 16; - public static final int TOTAL_MESSAGES = 30; - - private org.omg.CORBA.ORB orb_; - private org.omg.CORBA.BOA boa_; - private org.omg.CORBA.Object naming_service_object_; - - private Display display_; - private Navigation navigation_; - private Weapons weapons_; - - public synchronized void init () - { - } - - -public Display_Consumer (Display display) //, String name_service_ior, java.applet.Applet applet) - { - display_ = display; - try { - orb_ = org.omg.CORBA.ORB.init (); // applet, null); - boa_ = orb_.BOA_init (); - - // Get the Naming Service initial reference - - //naming_service_object_ = orb_.string_to_object (name_service_ior); - - NS_Resolve ns_resolve_ = new NS_Resolve (); - - naming_service_object_ = ns_resolve_.resolve_name_service (orb_); - } - catch(org.omg.CORBA.SystemException e) { - System.err.println ("Client constructur: Failure"); - System.err.println(e); - } - - } - - public class Object_is_null_exception extends Exception - { - Object_is_null_exception (String s) - { - super (s); - } - } - - public void run () - { - try - { - - // Get the Naming Context to allow resolving the EventService and - // ScheduleService - CosNaming.NamingContext naming_context_ = - CosNaming.NamingContextHelper.narrow (naming_service_object_); - - if (naming_context_ == null) - { - System.err.println ("The Naming Context is null"); - } - - // Get a reference for the EventService - - CosNaming.NameComponent[] ec_name_components_ = new CosNaming.NameComponent[1]; - ec_name_components_[0] = new CosNaming.NameComponent ("EventService",""); - org.omg.CORBA.Object event_channel_object_ = naming_context_.resolve (ec_name_components_); - - if (event_channel_object_ == null) - { - throw new Object_is_null_exception("EventService Object is null"); - } - - RtecEventChannelAdmin.EventChannel event_channel_ = - RtecEventChannelAdmin.EventChannelHelper.narrow (event_channel_object_); - - // Get a reference for the ScheduleService - - CosNaming.NameComponent[] s_name_components_ = new CosNaming.NameComponent[1]; - s_name_components_[0] = new CosNaming.NameComponent ("ScheduleService",""); - org.omg.CORBA.Object scheduler_object_ = naming_context_.resolve (s_name_components_); - - if (scheduler_object_ == null) - { - throw new Object_is_null_exception("ScheduleService Object is null"); - } - - RtecScheduler.Scheduler scheduler_ = - RtecScheduler.SchedulerHelper.narrow (scheduler_object_); - - - // Start the consumer - Display_Push_Consumer display_push_consumer_ = new Display_Push_Consumer (orb_, display_); - display_push_consumer_.open_consumer (event_channel_, scheduler_, "demo_consumer"); - - // Tell the CORBA environment that we are ready - - boa_.obj_is_ready (display_push_consumer_); - - System.out.println ("boa.obj_is_ready succeeded"); - - boa_.impl_is_ready (); - } - catch (CosNaming.NamingContextPackage.CannotProceed e) - { - System.err.println ("CosNaming.NamingContextPackage.CannotProceed"); - System.err.println (e); - } - catch (CosNaming.NamingContextPackage.InvalidName e) - { - System.err.println ("CosNaming.NamingContextPackage.InvalidName"); - System.err.println (e); - } - catch (CosNaming.NamingContextPackage.NotFound e) - { - System.err.println ("CosNaming.NamingContextPackage.NotFound"); - System.err.println (e); - - } - catch (Object_is_null_exception e) - { - System.err.println (e); - } - catch(org.omg.CORBA.SystemException e) - { - System.err.println ("Client run: Failure"); - System.err.println(e); - } - } - - -} // public class Display_Consumer - - - - - - - diff --git a/TAO/examples/Simulator/Sim_Display/Display_Object.java b/TAO/examples/Simulator/Sim_Display/Display_Object.java deleted file mode 100644 index 9d401f6e723..00000000000 --- a/TAO/examples/Simulator/Sim_Display/Display_Object.java +++ /dev/null @@ -1,8 +0,0 @@ -// $Id$ - -import java.io.*; - -public interface Display_Object -{ - public int update_display (Display_Push_Consumer display_push_consumer); -} diff --git a/TAO/examples/Simulator/Sim_Display/Display_Object_Factory.java b/TAO/examples/Simulator/Sim_Display/Display_Object_Factory.java deleted file mode 100644 index c7a036e1132..00000000000 --- a/TAO/examples/Simulator/Sim_Display/Display_Object_Factory.java +++ /dev/null @@ -1,42 +0,0 @@ -// $Id$ - -import java.io.*; -import java.util.*; - -public class Display_Object_Factory -{ - public final static int LONG_SIZE = 4; - public final static int DOUBLE_SIZE = 8; - - public final static int ART_HORIZON_ENUM = 0, - WEAPONS_ENUM = 1; - - private final static String[] DISPLAY_NAMES = - { - "Artificial Horizon", - "Weapons Display", - }; - - private static Hashtable objs_ = new Hashtable (); - - static - { - objs_.put (DISPLAY_NAMES[ART_HORIZON_ENUM], - new Display_Art_Horizon ()); - objs_.put (DISPLAY_NAMES[WEAPONS_ENUM], - new Display_Weapons ()); - } - - public static String resolve_name (long enum) - { - return (enum < DISPLAY_NAMES.length) ? - DISPLAY_NAMES[(int)enum] : null; - } - - public static Display_Object create_display_object (String name) - { - Object obj = objs_.get (name); - return (obj == null) ? null : (Display_Object) obj; - } -} - diff --git a/TAO/examples/Simulator/Sim_Display/Display_Push_Consumer.java b/TAO/examples/Simulator/Sim_Display/Display_Push_Consumer.java deleted file mode 100644 index 42fca6e7db9..00000000000 --- a/TAO/examples/Simulator/Sim_Display/Display_Push_Consumer.java +++ /dev/null @@ -1,248 +0,0 @@ -// $Id$ -// -// ============================================================================ -// -// -// = FILENAME -// Display_Push_Consumer.java -// -// = AUTHOR -// Michael Kircher (mk1@cs.wustl.edu) -// -// = DESCRIPTION -// Implemenation of a PushConsumer -// -// -// ============================================================================ - - - - - -// The Consumer has to implement the Skeleton Consumer - -public class Display_Push_Consumer extends RtecEventComm._PushConsumerImplBase -{ - - public static final int ACE_ES_EVENT_ANY = 0; - public static final int ACE_ES_EVENT_SHUTDOWN = 1; - public static final int ACE_ES_EVENT_ACT = 2; - public static final int ACE_ES_EVENT_NOTIFICATION = 3; - public static final int ACE_ES_EVENT_TIMEOUT = 4; - public static final int ACE_ES_EVENT_INTERVAL_TIMEOUT = 5; - public static final int ACE_ES_EVENT_DEADLINE_TIMEOUT = 6; - public static final int ACE_ES_GLOBAL_DESIGNATOR = 7; - public static final int ACE_ES_CONJUNCTION_DESIGNATOR = 8; - public static final int ACE_ES_DISJUNCTION_DESIGNATOR = 9; - public static final int ACE_ES_EVENT_UNDEFINED = 16; - public static final int TOTAL_MESSAGES = 30; - - // Store the number of received events - private int total_received_ = 0; - private org.omg.CORBA.ORB orb_; - private Navigation navigation_; - private Weapons weapons_; - private Display display_; - private RtecScheduler.handle_tHolder rt_info_; - private RtecEventChannelAdmin.EventChannel channel_admin_; - private RtecEventChannelAdmin.ConsumerAdmin consumer_admin_; - private RtecEventChannelAdmin.ProxyPushSupplier suppliers_; - - public Display_Push_Consumer (org.omg.CORBA.ORB orb, Display display) - { - orb_ = orb; - display_ = display; - } - - - public void push (RtecEventComm.Event[] events) - { - //if (total_received_ < 5) - // System.out.println ("Demo Consumer: Received an event! ->Number: " + total_received_); - //else if (total_received_ == 5) - // System.out.println ("Demo Consumer: Everything is fine. Going to be mute."); - - - if (events.length == 0) - { - System.err.println ("No events"); - } - else - { - total_received_++; - /* - if (total_received_ >= TOTAL_MESSAGES) - { - orb.disconnect (this); - System.exit (0); - } - */ - for (int i = 0; i < events.length; ++i) - { - if(events[i].type_ == ACE_ES_EVENT_NOTIFICATION) - { - try - { - if (events[i].data_.any_value.type().equal (NavigationHelper.type())) - { - navigation_ = NavigationHelper.extract (events[i].data_.any_value); - display_.update_metrics (navigation_.utilization, - navigation_.overhead, - navigation_.arrival_time, - navigation_.deadline_time, - navigation_.completion_time, - navigation_.computation_time); - display_.update_simulation (Display_Object_Factory.ART_HORIZON_ENUM, this); - } - else if (events[i].data_.any_value.type().equal (WeaponsHelper.type())) - { - weapons_ = WeaponsHelper.extract (events[i].data_.any_value); - display_.update_metrics (weapons_.utilization, - weapons_.overhead, - weapons_.arrival_time, - weapons_.deadline_time, - weapons_.completion_time, - weapons_.computation_time); - display_.update_simulation (Display_Object_Factory.WEAPONS_ENUM, this); - } - else - { - System.out.println ("Demo Consumer: Received an event! ->Number: " + total_received_); - System.out.println (">>TypeCode in the any does not match!"); - System.out.println ("Id: " + events[i].data_.any_value.type().id ()); - System.out.println ("Name: " + events[i].data_.any_value.type().name ()); - System.out.println ("Kind: " + events[i].data_.any_value.type().kind ()); - } - } - catch (org.omg.CORBA.TypeCodePackage.BadKind e) - { - System.err.println (e); - } - catch(org.omg.CORBA.SystemException e) - { - System.err.println(e); - } - } - } - } - } - - public void disconnect_push_consumer() - { - System.out.println ("Demo Consumer: Have to disconnect!"); - } - - public void open_consumer (RtecEventChannelAdmin.EventChannel event_channel_, - RtecScheduler.Scheduler scheduler_, - String name) - { - try { - - // Define Real-time information - - rt_info_ = new RtecScheduler.handle_tHolder (scheduler_.create (name)); - - scheduler_.set (rt_info_.value, - new TimeBase.ulonglong (0,0), - new TimeBase.ulonglong (0,0), - new TimeBase.ulonglong (0,0), - 2500000, // period - RtecScheduler.Importance.VERY_LOW_IMPORTANCE, - new TimeBase.ulonglong (0,0), - 1); - - - // Register for Notification and Shutdown events - - - RtecEventComm.Event disjunction_designator_ = - new RtecEventComm.Event (ACE_ES_DISJUNCTION_DESIGNATOR, 0, - 1, // ttl - new TimeBase.ulonglong (0,0), - new TimeBase.ulonglong (0,0), - new TimeBase.ulonglong (0,0), - new RtecEventComm.EventData (0, 0, orb_.create_any()) - ); - RtecEventComm.Event notification_event_ = - new RtecEventComm.Event (ACE_ES_EVENT_NOTIFICATION, 0, - 1, // ttl - new TimeBase.ulonglong (0,0), - new TimeBase.ulonglong (0,0), - new TimeBase.ulonglong (0,0), - new RtecEventComm.EventData (0, 0, orb_.create_any()) - ); - RtecEventComm.Event shutdown_event_ = - new RtecEventComm.Event (ACE_ES_EVENT_SHUTDOWN, 0, - 1, // ttl - new TimeBase.ulonglong (0,0), - new TimeBase.ulonglong (0,0), - new TimeBase.ulonglong (0,0), - new RtecEventComm.EventData (0, 0, orb_.create_any()) - ); - - - RtecEventChannelAdmin.Dependency dependencies_[] = new RtecEventChannelAdmin.Dependency[3]; - dependencies_[0] = new RtecEventChannelAdmin.Dependency (disjunction_designator_, rt_info_.value); - dependencies_[1] = new RtecEventChannelAdmin.Dependency (notification_event_, rt_info_.value); - dependencies_[2] = new RtecEventChannelAdmin.Dependency (shutdown_event_, rt_info_.value); - - - - RtecEventChannelAdmin.ConsumerQOS qos = new RtecEventChannelAdmin.ConsumerQOS (dependencies_); - - - // The channel administrator is the event channel we got from the invocation - // of this routine - - channel_admin_ = event_channel_; - - // Connect as a consumer - - consumer_admin_ = channel_admin_.for_consumers (); - - // Obtain a reference to the proxy push supplier - - suppliers_ = consumer_admin_.obtain_push_supplier (); - - suppliers_.connect_push_consumer (this, qos); - - System.out.println ("Registered the consumer successfully."); - - - } - catch (RtecScheduler.UNKNOWN_TASK e) - { - System.err.println ("Demo_Consumer.open_consumer: Unknown task"); - System.err.println (e); - } - catch (RtecScheduler.DUPLICATE_NAME e) - { - System.err.println ("Demo_Consumer.open_consumer: Duplicate names"); - System.err.println (e); - } - catch(org.omg.CORBA.SystemException e) - { - System.err.println(e); - } - } - public Navigation get_navigation () - { - return navigation_; - } - - public Weapons get_weapons () - { - return weapons_; - } - -} - - - - - - - - - - diff --git a/TAO/examples/Simulator/Sim_Display/Display_Weapons.java b/TAO/examples/Simulator/Sim_Display/Display_Weapons.java deleted file mode 100644 index c23e68f15be..00000000000 --- a/TAO/examples/Simulator/Sim_Display/Display_Weapons.java +++ /dev/null @@ -1,123 +0,0 @@ -// $Id$ - -import java.io.*; -import java.net.*; -import java.util.*; -import java.awt.*; - -public class Display_Weapons - extends Panel - implements Display_Object -{ - private final static String ONLINE = "Online", - OFFLINE = "Offline"; - private final static Font FONT_BIG = new Font ("Dialog", Font.BOLD, 14), - FONT_SMALL = new Font ("Dialog", Font.BOLD, 10); - private final static Color BLUE = new Color (30, 144, 255); - - private int count_ = 0; - private Hashtable weapons_ = new Hashtable (); - private GridBagLayout gbl_= new GridBagLayout (); - private GridBagConstraints gbc_ = new GridBagConstraints (); - - public Display_Weapons () - { - Label default_label = - new Label ("No weapons available", Label.CENTER); - - default_label.setFont (FONT_BIG); - default_label.setForeground (BLUE); - - setLayout (gbl_); - gbc_.gridx = 0; - gbc_.gridy = 0; - gbc_.gridheight = 1; - gbc_.gridwidth = 1; - gbc_.anchor = GridBagConstraints.NORTH; - gbc_.fill = GridBagConstraints.NONE; - setBackground (Color.black); - - gbl_.setConstraints (default_label, gbc_); - add (default_label); - } - - public Dimension getPreferredSize () - { - return new Dimension (250, 200); - } - - public Dimension getMinimumSize () - { - return new Dimension (250, 100); - } - - public int update_display (Display_Push_Consumer display_push_consumer) - { - Weapons weapons = display_push_consumer.get_weapons (); - - for (int i = 0; i < weapons.number_of_weapons && i < 5; i++) - { - String weapon; - int status; - switch (i) - { - default: - case 0: weapon = weapons.weapon1_identifier; - status = weapons.weapon1_status; - break; - case 1: weapon = weapons.weapon2_identifier; - status = weapons.weapon2_status; - break; - case 2: weapon = weapons.weapon3_identifier; - status = weapons.weapon3_status; - break; - case 3: weapon = weapons.weapon4_identifier; - status = weapons.weapon4_status; - break; - case 4: weapon = weapons.weapon5_identifier; - status = weapons.weapon5_status; - break; - } - - - Label status_label = (Label)weapons_.get (weapon); - - if (status_label != null) - status_label.setText ((status == 1) ? ONLINE : OFFLINE); - else - { - if (count_ == 0) - removeAll (); - - count_++; - Label weapon_label = - new Label (count_ + ". " + weapon, Label.LEFT); - status_label = - new Label ((status == 1) ? ONLINE : OFFLINE, Label.RIGHT); - - status_label.setFont (FONT_SMALL); - weapon_label.setFont (FONT_SMALL); - weapon_label.setForeground (BLUE); - - gbc_.gridx = 0; - gbc_.anchor = GridBagConstraints.WEST; - gbl_.setConstraints (weapon_label, gbc_); - add (weapon_label); - gbc_.gridx = 1; - gbc_.anchor = GridBagConstraints.EAST; - gbl_.setConstraints (status_label, gbc_); - add (status_label); - - gbc_.gridy++; - weapons_.put (weapon, status_label); - } - - status_label.setForeground ((status == 1) ? - Color.lightGray : - Color.darkGray); - } - - validate (); - return 0; - } -} diff --git a/TAO/examples/Simulator/Sim_Display/Graph.java b/TAO/examples/Simulator/Sim_Display/Graph.java deleted file mode 100644 index d8be73b54cb..00000000000 --- a/TAO/examples/Simulator/Sim_Display/Graph.java +++ /dev/null @@ -1,163 +0,0 @@ -// $Id$ - - -import java.awt.*; -import java.util.*; - -public class Graph extends Canvas -{ - private static final int MIN_SPACING = 2; - private static final int POINT_HISTORY = 200; - private static final Font FONT = new Font ("Dialog", Font.PLAIN, 10); - - private Queue plot_; - private String title_; - private Graphics offgraphics_; - private Image offscreen_; - private Dimension offscreensize_; - private int max_value_; - private int old_max_value_; - private int spacing_; - private float local_max_ = 0; - private boolean max_increased_ = false; - - public Graph(String title, int max_value) - { - super(); - - plot_ = new Queue(); - spacing_ = MIN_SPACING; - title_ = title; - max_value_ = max_value; - old_max_value_ = max_value; - } - - public Dimension getMinimumSize () - { - return new Dimension (75, 75); - } - - public Dimension getPreferredSize () - { - return new Dimension (175, 175); - } - - public void addNewData(float new_point) - { - Float temp = (Float)plot_.dequeue_tail(); - plot_.enqueue_head(new Float(new_point)); - - if (new_point > local_max_) - local_max_ = new_point; - - while (local_max_ > max_value_) - max_value_ *= 2; - - while ((local_max_ < max_value_/2) && (max_value_ > old_max_value_)) - max_value_ /= 2; - - repaint(); - } - - public void update(Graphics g) - { - Dimension d = getSize (); - float tmp, value_1, value_2; - FontMetrics fm = g.getFontMetrics (); - Enumeration queue_iter = plot_.forward_iterator(); - int x1 = d.width - 8, y1, x2, y2, fheight = fm.getHeight (), i; - String value = "Value (of " + max_value_ + "): " + String.valueOf(plot_.head()); - - if ((offscreen_ == null) || - (offscreensize_.width != d.width - 8) || - (offscreensize_.height != d.height - 8)) - { - offscreen_ = createImage(d.width - 8, d.height - 8); - offscreensize_ = new Dimension(d.width - 8, d.height - 8); - offgraphics_ = offscreen_.getGraphics(); - offgraphics_.setFont(FONT); - } - - g.setColor (Color.lightGray); - g.draw3DRect (0, 0, d.width - 1, d.height - 1, true); - g.draw3DRect (1, 1, d.width - 3, d.height - 3, true); - g.draw3DRect (2, 2, d.width - 5, d.height - 5, true); - - local_max_ = 0; - offgraphics_.setColor (getBackground()); - offgraphics_.fillRect (0, 0, offscreensize_.width, offscreensize_.height); - offgraphics_.setColor (getForeground()); - offgraphics_.drawString(title_, 5, fheight); - offgraphics_.drawString(value, 5, offscreensize_.height - 5); - - value_1 = ((Float)queue_iter.nextElement()).floatValue(); - while (queue_iter.hasMoreElements()) - { - value_2 = ((Float)queue_iter.nextElement()).floatValue(); - - if (value_1 > local_max_) - local_max_ = value_1; - - y1 = normalize(offscreensize_.height - fheight, value_1); - y2 = normalize(offscreensize_.height - fheight, value_2); - - tmp = value_2; - value_2 = value_1; - value_1 = tmp; - - x2 = x1 - spacing_; - offgraphics_.drawLine(x1, y1, x2, y2); - x1 = x2; - if (x1 <= 5) - break; - } - - g.drawImage(offscreen_, 3, 3, null); - } - - public void paint(Graphics g) - { - Dimension d = getSize (); - int plot_length = plot_.length(); - int num_points = d.width / spacing_; - - if (plot_.length() < num_points) - { - for (int i = 0; i < num_points - plot_length; i++) - plot_.enqueue_tail(new Float(0)); - } - else if (plot_.length() > num_points) - { - for (int i = 0; i < plot_length - num_points; i++) - plot_.dequeue_tail(); - } - - update(g); - } - - public String getKey() - { - return title_; - } - - public int getMax() - { - return old_max_value_; - } - - private int normalize(int height, float coord) - { - float ratio = (float)coord/max_value_; - float pixels = (float)height*ratio; - float location = (float)height - pixels; - - return Math.round(location); - } - - public void updateDisplay(float information) - { - addNewData(information); - repaint(); - } -} - diff --git a/TAO/examples/Simulator/Sim_Display/Graph_Panel.java b/TAO/examples/Simulator/Sim_Display/Graph_Panel.java deleted file mode 100644 index 2eb6519f7c3..00000000000 --- a/TAO/examples/Simulator/Sim_Display/Graph_Panel.java +++ /dev/null @@ -1,181 +0,0 @@ -// $Id$ - -import java.awt.*; -import java.awt.event.*; -import java.util.*; - -class Graph_Panel - extends Panel - implements ComponentListener, - ContainerListener -{ - private final static int VPAD = 4, HPAD = 4, - MIN_WIDTH = 100, - SUG_WIDTH = 175; - private final static Random RAND = new Random (System.currentTimeMillis()); - private static float hue_ = RAND.nextFloat(); - - private Hashtable graphs_ = new Hashtable(); - - public Graph_Panel() - { - addComponentListener (this); - addContainerListener (this); - } - - public void addGraph(String name, int max) - { - int index = name.lastIndexOf('/'); - String short_name; - - if (index != -1) - short_name = name.substring(index+1); - else - short_name = name; - - Graph graph = constructGraph(short_name, max); - graphs_.put(name, graph); - } - - public void updateGraph(String name, float new_value) - { - Graph graph = (Graph)graphs_.get(name); - - if(graph != null) - graph.addNewData(new_value); - } - - public Graph getGraph(String name) - { - return (Graph)((Container)graphs_.get(name)).getComponent(0); - } - - public void removeGraph(String name) - { - graphs_.remove(name); - - if (graphs_.size() > 0) - layoutGraphs(); - else - removeAll(); - } - - public int numGraphs() - { - return graphs_.size(); - } - - public void clear() - { - removeAll(); - } - - public void componentResized(ComponentEvent e) - { - System.out.println ("Component resized."); - removeContainerListener (this); - removeComponentListener (this); - layoutGraphs (); - addComponentListener (this); - addContainerListener (this); - } - - public void componentMoved(ComponentEvent e) {} - public void componentShown(ComponentEvent e) {} - public void componentHidden(ComponentEvent e) {} - - public void componentAdded(ContainerEvent e) - { - System.out.println ("component added."); - removeContainerListener (this); - removeComponentListener (this); - layoutGraphs (); - addComponentListener (this); - addContainerListener (this); - } - - public void componentRemoved(ContainerEvent e) - { - System.out.println ("component removed."); - } - - private void layoutGraphs () - { - Dimension current_size = getSize (); - int total_area = current_size.width * current_size.height; - int num_rows, graphs_per_row, min_width = MIN_WIDTH; - int graph_area = graphs_.size () * - (SUG_WIDTH + HPAD) * - (SUG_WIDTH + VPAD); - Enumeration graph_enum = graphs_.elements (); - - removeAll (); - - System.out.println ("Total area: " + total_area + " Graph area: " + graph_area); - - if ((total_area < graph_area) || - (current_size.width < MIN_WIDTH) || - (current_size.height < MIN_WIDTH)) - { - System.out.println ("adjusting graph size"); - min_width = total_area / graphs_.size (); - min_width = (int) Math.round (Math.sqrt (min_width)); - - if (min_width > current_size.height) - min_width = current_size.height; - if (min_width > current_size.width) - min_width = current_size.width; - - // Ah, hopeless. Too narrow to draw graphs in this panel. - if (min_width < MIN_WIDTH) - { - System.err.println ("Graph_Panel.layoutGraphs: Giving up!"); - return; - } - } - - graphs_per_row = current_size.width / (min_width + HPAD); - num_rows = (graphs_.size () / graphs_per_row) + 1; - - setLayout (new GridLayout (num_rows, 1, 0, VPAD)); - for (int i = 0; i < num_rows; i++) - { - Panel row = new Panel (); - row.setLayout (new GridLayout (1, graphs_per_row, HPAD, 0)); - - for (int j = 0; - j < graphs_per_row && graph_enum.hasMoreElements (); - j++) - { - Component graph = (Component) graph_enum.nextElement (); - row.add (graph); - } - - add (row); - } - - validate (); - } - - private final static Graph constructGraph(String label, int max) - { - Graph graph = new Graph(label, max); - - float brightness = RAND.nextFloat(); - - hue_ += .075; - - if (hue_ > 1.0) - hue_ -= 1.0; - - if (brightness > 0.75) - brightness -= 0.25; - - Color new_color = Color.getHSBColor(hue_, 1, brightness); - - graph.setBackground(new_color); - graph.setForeground(Color.white); - - return graph; - } -} diff --git a/TAO/examples/Simulator/Sim_Display/NS_Resolve.java b/TAO/examples/Simulator/Sim_Display/NS_Resolve.java deleted file mode 100644 index b6a39e63dec..00000000000 --- a/TAO/examples/Simulator/Sim_Display/NS_Resolve.java +++ /dev/null @@ -1,112 +0,0 @@ -// $Id$ -// ============================================================================ -// -// -// = FILENAME -// NS_Resolve.java -// -// = AUTHOR -// Michael Kircher (mk1@cs.wustl.edu) -// -// = DESCRIPTION -// Resolves the initial reference to the Naming service, -// the orb has to be given as a parameter to the -// resolve_name_service call. -// -// -// ============================================================================ - - - - -import org.omg.CORBA.*; -import java.net.*; -import java.io.*; - - - -public class NS_Resolve -{ - - private static final String ACE_DEFAULT_MULTICAST_ADDR = "224.9.9.2"; - private static final int TAO_DEFAULT_NAME_SERVER_REQUEST_PORT = 10013; - private static final int MULTICAST_SEND_PORT = 10060; - private static final int MULTICAST_RECEIVE_PORT = 10061; - private static final int TAO_SERVICEID_NAMESERVICE = 0; - private static final int TAO_SERVICEID_TRADINGSERVICE = 1; - - org.omg.CORBA.Object name_service_; - - - public org.omg.CORBA.Object resolve_name_service (org.omg.CORBA.ORB orb) - { - try - { - // Create a message with the multicast receive port in it - ByteArrayOutputStream byte_stream_ = new ByteArrayOutputStream (); - byte_stream_.write ((int)((MULTICAST_RECEIVE_PORT&0xff00)>>>8)); - byte_stream_.write ((int)(MULTICAST_RECEIVE_PORT&0x00ff)); - byte_stream_.write ((int)((TAO_SERVICEID_NAMESERVICE&0xff00)>>>8)); - byte_stream_.write ((int)(TAO_SERVICEID_NAMESERVICE&0x00ff)); - byte[] msg = byte_stream_.toByteArray(); - - - // Define the group for the multicast - - InetAddress group = InetAddress.getByName(ACE_DEFAULT_MULTICAST_ADDR); - // Create the multicast socket at any port you want - MulticastSocket multicastsocket_ = new MulticastSocket(MULTICAST_SEND_PORT); - // Create a socket for the answer of the Naming Service - DatagramSocket socket_ = new DatagramSocket (MULTICAST_RECEIVE_PORT); - // Give three seconds time for the Naming Service to respond - socket_.setSoTimeout (3000); - // Build a packet with the port number in it - DatagramPacket hello = new DatagramPacket(msg, msg.length, - group, TAO_DEFAULT_NAME_SERVER_REQUEST_PORT); - - // Send the packet - multicastsocket_.send (hello); - - // @@ The restriction right now is that the length of the IOR cannot be longer than 4096 - byte[] buf = new byte[4096]; - // Set up packet which can be received - DatagramPacket recv = new DatagramPacket (buf, buf.length); - // Receive a packet or time out - socket_.receive (recv); - - // Determine the length of the IOR - int length; - for (length = 0; buf[length] != 0; length++); - - // Store the IOR in a String - String name_service_ior_ = new String (recv.getData (),0,length); - - // Convert the String into - return orb.string_to_object (name_service_ior_); - } - catch (SocketException e) - { - System.err.println (e); - } - catch (java.io.InterruptedIOException e) - { - System.err.println ("NS_Resolve: The receive lasted too long"); - } - catch(org.omg.CORBA.SystemException e) - { - System.err.println(e); - } - catch (java.io.IOException e) - { - System.err.println (e); - } - return null; - - } - -}; - - - - - diff --git a/TAO/examples/Simulator/Sim_Display/Queue.java b/TAO/examples/Simulator/Sim_Display/Queue.java deleted file mode 100644 index 7ffaba15c52..00000000000 --- a/TAO/examples/Simulator/Sim_Display/Queue.java +++ /dev/null @@ -1,190 +0,0 @@ -// $Id$ - - -import java.util.Enumeration; - -public class Queue -{ - // Friendly? - Queue_Node head_ = null; - Queue_Node tail_ = null; - - private int length_ = 0; - - public Queue() - { - } - - public Enumeration forward_iterator() - { - return new Queue_Iterator(this, Queue_Iterator.FORWARD); - } - - public Enumeration reverse_iterator() - { - return new Queue_Iterator(this, Queue_Iterator.REVERSE); - } - - public void enqueue_tail(Object new_data) - { - Queue_Node new_node = new Queue_Node(new_data); - - if (tail_ == null) - { - tail_ = new_node; - head_ = new_node; - } - else - { - new_node.prev_ = tail_; - tail_.next_ = new_node; - tail_ = new_node; - } - - length_++; - } - - public void enqueue_head(Object new_data) - { - Queue_Node new_node = new Queue_Node(new_data); - - if (head_ == null) - { - tail_ = new_node; - head_ = new_node; - } - else - { - new_node.next_ = head_; - head_.prev_ = new_node; - head_ = new_node; - } - - length_++; - } - - public Object dequeue_head() - { - Object return_value = null; - - if (head_ == null) - return_value = null; - else if (tail_ == head_) - { - return_value = head_.data_; - tail_ = null; - head_ = null; - } - else - { - return_value = head_.data_; - head_ = head_.next_; - head_.prev_ = null; - } - - length_--; - - return return_value; - } - - public Object dequeue_tail() - { - Object return_value = null; - - if (tail_ == null) - return_value = null; - else if (tail_ == head_) - { - return_value = tail_.data_; - tail_ = null; - head_ = null; - } - else - { - return_value = tail_.data_; - tail_ = tail_.prev_; - tail_.next_ = null; - } - - length_--; - - return return_value; - } - - public int length() - { - return length_; - } - - public Object head() - { - if (head_ != null) - return head_.data_; - else - return null; - } - - public Object tail() - { - if (tail_ != null) - return tail_.data_; - else - return null; - } -} - -class Queue_Node -{ - public Queue_Node prev_ = null; - public Queue_Node next_ = null;; - public Object data_; - - public Queue_Node(Object data) - { - data_ = data; - } -} - -class Queue_Iterator implements Enumeration -{ - public static final boolean FORWARD = true; - public static final boolean REVERSE = false; - - private Queue queue_; - private Queue_Node queue_ptr_; - private boolean direction_ = FORWARD; - - public Queue_Iterator(Queue queue) - { - queue_ = queue; - queue_ptr_ = queue.head_; - } - - public Queue_Iterator(Queue queue, boolean direction) - { - queue_ = queue; - direction_ = direction; - - if (direction_) - queue_ptr_ = queue_.head_; - else - queue_ptr_ = queue_.tail_; - } - - public Object nextElement() - { - Object data = queue_ptr_.data_; - - if (direction_) - queue_ptr_ = queue_ptr_.next_; - else - queue_ptr_ = queue_ptr_.prev_; - - return data; - } - - public boolean hasMoreElements() - { - return queue_ptr_ != null; - } -} diff --git a/TAO/examples/Simulator/Sim_Display/Sim_Panel.java b/TAO/examples/Simulator/Sim_Display/Sim_Panel.java deleted file mode 100644 index 42ed5d7b0f2..00000000000 --- a/TAO/examples/Simulator/Sim_Display/Sim_Panel.java +++ /dev/null @@ -1,64 +0,0 @@ -// $Id$ - -import java.awt.*; -import java.util.*; -import java.io.*; - -class Sim_Panel extends Panel -{ - private GridBagLayout gbl_ = new GridBagLayout (); - private GridBagConstraints gbc_ = new GridBagConstraints (); - - private Hashtable sims_ = new Hashtable(); - - public Sim_Panel() - { - setLayout (gbl_); - gbc_.gridy = 0; - gbc_.weightx= 1; - gbc_.gridwidth = 1; - gbc_.gridheight = 1; - gbc_.gridx = GridBagConstraints.RELATIVE; - gbc_.anchor = GridBagConstraints.CENTER; - } - - public void add_simulator (String name, Display_Object disp_obj) - { - String short_name; - - if (! sims_.contains (name)) - { - Label label = new Label(name, Label.CENTER); - Panel panel = new Panel(); - - label.setFont(new Font("Dialog", Font.BOLD, 12)); - - panel.setLayout(new BorderLayout(0, 2)); - panel.add("Center", (Component)disp_obj); - panel.add("North", label); - sims_.put(name, panel); - - gbl_.setConstraints (panel, gbc_); - add (panel); - } - } - - public void update_simulator (String name, Display_Push_Consumer display_push_consumer) - - { - Container panel = (Container) sims_.get (name); - Display_Object sim = (panel != null) ? (Display_Object) panel.getComponent(0) : null; - - if(sim != null) - sim.update_display (display_push_consumer); - } - - public Display_Object get_simulator(String name) - { - return (Display_Object)((Container) sims_.get (name)).getComponent (0); - } -} - - - - |