diff options
author | mk1 <mk1@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1998-03-21 23:58:03 +0000 |
---|---|---|
committer | mk1 <mk1@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1998-03-21 23:58:03 +0000 |
commit | e6480acfb1f6ca1ec2622a0c7b9054412c8588b1 (patch) | |
tree | d088e8e5da79e438832e17f9a5983e7fffb31219 /TAO/examples | |
parent | ee93e4f1e3a7b917d211fda735435169a6587683 (diff) | |
download | ATCD-e6480acfb1f6ca1ec2622a0c7b9054412c8588b1.tar.gz |
Sat Mar 21 17:55:40 1998 Michael Kircher <mk1@cs.wustl.edu>
Diffstat (limited to 'TAO/examples')
24 files changed, 2277 insertions, 143 deletions
diff --git a/TAO/examples/Simulator/DOVEBrowser/AnswerEvent.java b/TAO/examples/Simulator/DOVEBrowser/AnswerEvent.java new file mode 100644 index 00000000000..c10ae7d766a --- /dev/null +++ b/TAO/examples/Simulator/DOVEBrowser/AnswerEvent.java @@ -0,0 +1,23 @@ +// $Id$ +// +// = FILENAME +// AnswerEvent.java +// +// = AUTHOR +// Michael Kircher (mk1@cs.wustl.edu) +// +// = DESCRIPTION +// Event definition for the Dialog for selecting Observables. +// +// ============================================================================ + +public class AnswerEvent extends java.util.EventObject { + + protected String selected_; + + public AnswerEvent (Object source, String selected) { + super (source); + this.selected_ = selected; + } +} + diff --git a/TAO/examples/Simulator/DOVEBrowser/AnswerListener.java b/TAO/examples/Simulator/DOVEBrowser/AnswerListener.java new file mode 100644 index 00000000000..77d43646729 --- /dev/null +++ b/TAO/examples/Simulator/DOVEBrowser/AnswerListener.java @@ -0,0 +1,18 @@ +// $Id$ +// +// = FILENAME +// AnswerListener.java +// +// = AUTHOR +// Michael Kircher (mk1@cs.wustl.edu) +// +// = DESCRIPTION +// EventListener definition for the Dialog for selecting Observables. +// +// ============================================================================ + + +public class AnswerListener implements java.util.EventListener { + public void ok (AnswerEvent e) {} + public void cancel (AnswerEvent e) {} +} diff --git a/TAO/examples/Simulator/DOVEBrowser/DOVEBrowser.java b/TAO/examples/Simulator/DOVEBrowser/DOVEBrowser.java new file mode 100644 index 00000000000..a83ad81581d --- /dev/null +++ b/TAO/examples/Simulator/DOVEBrowser/DOVEBrowser.java @@ -0,0 +1,44 @@ +// $Id$ +// +// = FILENAME +// NewDemo.java +// +// = AUTHOR +// Michael Kircher (mk1@cs.wustl.edu) +// +// = DESCRIPTION +// Entry point for the demo. +// +// ============================================================================ + + +import java.awt.*; + +public class DOVEBrowser { //extends java.applet.Applet { + + DemoCore demoCore_; + + public DOVEBrowser () { + super (); + demoCore_ = new DemoCore (); + } + + public void init () { + demoCore_.show (); + demoCore_.run (); + } + + public void paint (Graphics g) { + + g.drawString ("Michael is here",10,10); + } + + + public static void main (String[] args) + { + DOVEBrowser doveBrowser_ = new DOVEBrowser (); + doveBrowser_.init (); + } +} + + diff --git a/TAO/examples/Simulator/DOVEBrowser/DataHandler.java b/TAO/examples/Simulator/DOVEBrowser/DataHandler.java new file mode 100644 index 00000000000..a2a88771b4a --- /dev/null +++ b/TAO/examples/Simulator/DOVEBrowser/DataHandler.java @@ -0,0 +1,34 @@ +// $Id$ +// +// = FILENAME +// DataHandler.java +// +// = AUTHOR +// Michael Kircher (mk1@cs.wustl.edu) +// +// = DESCRIPTION +// This is the interface for data handling in the simulation demo +// using the Event Channel as transport media. +// +// ============================================================================ + +import org.omg.CORBA.*; + +public interface DataHandler { + + // entry point for an consumer to put data into the data handler + public void update (Any any_value); + + // get a list of the Observables names to allow selection + public java.util.Enumeration getObservablesList (); + + // get a specific Observable + public DemoObservable getObservable(String name); + + // get the property of an observable + public int getObservableProperty (String name); +} + + + + diff --git a/TAO/examples/Simulator/DOVEBrowser/DemoCore.java b/TAO/examples/Simulator/DOVEBrowser/DemoCore.java new file mode 100644 index 00000000000..ffdef7c0618 --- /dev/null +++ b/TAO/examples/Simulator/DOVEBrowser/DemoCore.java @@ -0,0 +1,158 @@ +// $Id$ +// +// = FILENAME +// DemoCore.java +// +// = AUTHOR +// Michael Kircher (mk1@cs.wustl.edu) +// +// = DESCRIPTION +// This class servers as the core class of the simulation demo. +// It connects the push consumer of the event service with +// one or several Java Beans. +// +// ============================================================================ + + +import java.awt.*; +import java.awt.event.*; + +public class DemoCore extends Frame { + + private static final int MAX_VIS_COMPS = 10; + + private PushConsumerFactory pushConsumerFactory_; + private DataHandler dataHandler_; + private java.util.Vector vis_comp_list_; + private int countVisComp_ = 0; + private GridBagLayout gridbag_; + private GridBagConstraints constraints_; + + + DemoCore () { + super (); + + setSize (600,400); + setBounds (new Rectangle (50,50,800,500)); + setVisible (true); + + gridbag_ = new GridBagLayout(); + constraints_ = new GridBagConstraints(); + constraints_.fill = GridBagConstraints.BOTH; + constraints_.weightx = 1.0; + constraints_.weighty = 1.0; + this.setLayout (gridbag_); + + // Instantiate the DataHandler and the PushConsumer + dataHandler_ = new NavWeapDataHandler (); + pushConsumerFactory_ = new PushConsumerFactory (dataHandler_); + + // List of Visualization Components + vis_comp_list_ = new java.util.Vector(); + + + MenuBar menubar_ = new MenuBar (); + Menu menu_ = new Menu ("File"); + MenuItem menu_quit_item_ = new MenuItem ("Quit"); + menu_quit_item_.setEnabled (true); + MenuItem menu_add_item_ = new MenuItem ("Add"); + menu_add_item_.setEnabled (true); + menu_.add (menu_add_item_); + menu_.add (menu_quit_item_); + menubar_.add (menu_); + + setMenuBar (menubar_); + + menu_quit_item_.addActionListener (new ActionListener () + { + public void actionPerformed (ActionEvent e) { + System.exit (0); + } + }); + + menu_add_item_.addActionListener (new ActionListener () + { + public void actionPerformed (ActionEvent e) { + ObservablesDialog obsDialog_ = + new ObservablesDialog (DemoCore.this, + dataHandler_.getObservablesList()); + obsDialog_.addAnswerListener (new AnswerListener () + { + public void ok (AnswerEvent e) + { + DemoCore.this.addConnection (e.selected_); + } + }); + obsDialog_.setVisible (true); + } + }); + + addConnection ("Cpu_UsageObservable"); + System.out.println ("Connected Cpu_UsageObservable to Observable!"); + } + + public boolean addConnection (String selected) { + // to not fill too many into it + if (countVisComp_ < MAX_VIS_COMPS) { + + DemoObservable observable = dataHandler_.getObservable (selected); + + if (observable != null) { + + VisComp visComp_ = null; + if (observable.getProperty () == Properties.DOUBLE) { + visComp_ = new DoubleVisComp (selected, 100); + } + else if (observable.getProperty () == Properties.NAVIGATION) { + visComp_ = new NavigationVisComp (selected); + } + else if (observable.getProperty () == Properties.WEAPONS) { + visComp_ = new WeaponsVisComp (selected); + } + if (visComp_ != null) { + vis_comp_list_.addElement (visComp_); + + // connect the Observer with the Observable + observable.addObserver (visComp_); + + countVisComp_++; + + if (countVisComp_ == 3){ + constraints_.gridwidth = GridBagConstraints.REMAINDER; + } + if (countVisComp_ > 3) { + constraints_.gridwidth = 1; + } + + gridbag_.setConstraints ((java.awt.Component) visComp_, constraints_); + + // add the Visualization Component to the Frame + DemoCore.this.add ((java.awt.Component) visComp_); + + System.out.println ("Connected the consumer with the visualization component!"); + DemoCore.this.show (); + + return true; + } + } + } + return false; + } + + public void init () { + + } + + public void paint (Graphics g) + { + } + + public void run () { + + // Wait passive until events come in + pushConsumerFactory_.run (); + + } +} + + diff --git a/TAO/examples/Simulator/DOVEBrowser/DemoObservable.java b/TAO/examples/Simulator/DOVEBrowser/DemoObservable.java new file mode 100644 index 00000000000..81c85b961f8 --- /dev/null +++ b/TAO/examples/Simulator/DOVEBrowser/DemoObservable.java @@ -0,0 +1,19 @@ +// $Id$ +// +// = FILENAME +// DemoObservable.java +// +// = AUTHOR +// Michael Kircher (mk1@cs.wustl.edu) +// +// = DESCRIPTION +// This class servers as the core class of the simulation demo +// +// ============================================================================ + + + +public abstract class DemoObservable extends java.util.Observable { + + public abstract int getProperty (); +} diff --git a/TAO/examples/Simulator/DOVEBrowser/DoubleVisComp.java b/TAO/examples/Simulator/DOVEBrowser/DoubleVisComp.java new file mode 100644 index 00000000000..e30644705a8 --- /dev/null +++ b/TAO/examples/Simulator/DOVEBrowser/DoubleVisComp.java @@ -0,0 +1,204 @@ +// $Id$ +// +// = FILENAME +// DoubleVisComp.java +// +// = AUTHOR +// Seth Widoff (core graph functionality) +// Michael Kircher (mk1@cs.wustl.edu) +// +// = DESCRIPTION +// This is a Visualization Component for displaying doubles. +// +// ============================================================================ + + + + +import java.awt.*; +import java.util.*; + +public class DoubleVisComp extends Canvas implements VisComp +{ + 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 DoubleVisComp(String title, int max_value) + { + super(); + + plot_ = new Queue(); + spacing_ = MIN_SPACING; + title_ = title; + max_value_ = max_value; + old_max_value_ = max_value; + + java.util.Random rand = new java.util.Random (System.currentTimeMillis()); + float hue_ = rand.nextFloat(); + 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); + + this.setBackground(new_color); + this.setForeground(Color.white); + } + + public int getProperty () + { + return Properties.DOUBLE; + } + + public Dimension getMinimumSize () + { + return new Dimension (75, 75); + } + + public Dimension getPreferredSize () + { + return new Dimension (175, 175); + } + + public void update(java.util.Observable observable, java.lang.Object obj) + { + Double double_temp_; + try { + double_temp_ = (Double) obj; + } + catch (Exception excp) { + double_temp_ = new Double (0.0); + System.out.println (excp); + System.out.println ("Visualization Component received wrong data type!"); + } + + float new_point = double_temp_.floatValue(); + 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); + } +} + diff --git a/TAO/examples/Simulator/DOVEBrowser/NS_Resolve.java b/TAO/examples/Simulator/DOVEBrowser/NS_Resolve.java new file mode 100644 index 00000000000..b6a39e63dec --- /dev/null +++ b/TAO/examples/Simulator/DOVEBrowser/NS_Resolve.java @@ -0,0 +1,112 @@ +// $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/DOVEBrowser/NavWeapDataHandler.java b/TAO/examples/Simulator/DOVEBrowser/NavWeapDataHandler.java new file mode 100644 index 00000000000..2eb358a4ef2 --- /dev/null +++ b/TAO/examples/Simulator/DOVEBrowser/NavWeapDataHandler.java @@ -0,0 +1,218 @@ +// $Id$ +// +// = FILENAME +// NavWeapDataHandler.java +// +// = AUTHOR +// Michael Kircher (mk1@cs.wustl.edu) +// +// = DESCRIPTION +// This is an implementation of the interface Data Handler, +// it handles Navigation and Weapons data, where statistic data is +// part of it. Several Observables are declared, they can be accessed by +// any number of Observers, which could reside in a Java Bean for example. +// +// ============================================================================ + +import org.omg.CORBA.*; + +public class NavWeapDataHandler implements DataHandler { + + java.util.Hashtable ObservablesTable; + int received_events_; + + + // Observable for Navigation data + class NavigationObservable extends DemoObservable { + + // to ask which kind of viewer is needed to display data + public int getProperty () { + return Properties.NAVIGATION; + } + + public void updateNavigation (Navigation navigation) { + setChanged (); + notifyObservers (navigation); + } + + } + + class WeaponsObservable extends DemoObservable { + + // to ask which kind of viewer is needed to display data + public int getProperty () { + return Properties.WEAPONS; + } + + public void updateWeapons (Weapons weapons) { + setChanged (); + notifyObservers (weapons); + } + } + + class Cpu_UsageObservable extends DemoObservable { + + public int getProperty () { + return Properties.DOUBLE; + } + + public void updateCpu_Usage (double utilization) { + setChanged (); + Double temp_ = new Double (utilization); + notifyObservers (temp_); + } + } + class OverheadObservable extends DemoObservable { + + public int getProperty () { + return Properties.DOUBLE; + } + + public void updateOverhead (double overhead) { + setChanged (); + Double temp_ = new Double (overhead); + notifyObservers (temp_); + } + } + class JitterObservable extends DemoObservable { + double latency = 0.0; + double last_latency = 0.0; + + public int getProperty () { + return Properties.DOUBLE; + } + + public void updateJitter (int completion_time, + int computation_time, + int arrival_time ) { + last_latency = latency; + latency = (double)(completion_time + - computation_time + - arrival_time); + latency = latency > 0 ? latency : 0; + double jitter_ = (double)Math.abs(latency - last_latency); + + setChanged (); + Double temp_ = new Double (jitter_); + notifyObservers (temp_); + } + } + class DeadlinesObservable extends DemoObservable { + + public int getProperty () { + return Properties.DOUBLE; + } + + public void updateDeadlines (int deadline_time, + int completion_time) { + double missed_ = (double) ((deadline_time + < completion_time) + ? 1.0 : 0.0); + + Double temp_ = new Double (missed_); + setChanged (); + notifyObservers (temp_); + } + } + class LatencyObservable extends DemoObservable { + double latency = 0.0; + double last_latency = 0.0; + + public int getProperty () { + return Properties.DOUBLE; + } + + public void updateLatency (int completion_time, + int computation_time, + int arrival_time ) { + last_latency = latency; + latency = (double)(completion_time + - computation_time + - arrival_time); + latency = latency > 0 ? latency : 0; + + setChanged (); + Double temp_ = new Double(latency); + notifyObservers (temp_); + } + } + + + public void update (Any any_value) { + + if (any_value.type().equal (NavigationHelper.type())) + { + Navigation navigation_ = NavigationHelper.extract (any_value); + NavigationObservable nobs = (NavigationObservable)ObservablesTable.get ("NavigationObservable"); + nobs.updateNavigation (navigation_); + Cpu_UsageObservable cobs = (Cpu_UsageObservable)ObservablesTable.get ("Cpu_UsageObservable"); + cobs.updateCpu_Usage (navigation_.utilization); + OverheadObservable oobs = (OverheadObservable)ObservablesTable.get ("OverheadObservable"); + oobs.updateOverhead (navigation_.overhead); + JitterObservable jobs = (JitterObservable)ObservablesTable.get ("JitterObservable"); + jobs.updateJitter (navigation_.completion_time, + navigation_.computation_time, + navigation_.arrival_time); + DeadlinesObservable dobs = (DeadlinesObservable)ObservablesTable.get ("DeadlinesObservable"); + dobs.updateDeadlines (navigation_.deadline_time, + navigation_.completion_time); + LatencyObservable lobs = (LatencyObservable)ObservablesTable.get ("LatencyObservable"); + lobs.updateLatency (navigation_.completion_time, + navigation_.computation_time, + navigation_.arrival_time); + received_events_++; + } + else if (any_value.type().equal (WeaponsHelper.type())) + { + Weapons weapons_ = WeaponsHelper.extract (any_value); + WeaponsObservable wobs = (WeaponsObservable)ObservablesTable.get ("WeaponsObservable");; + wobs.updateWeapons (weapons_); + Cpu_UsageObservable cobs = (Cpu_UsageObservable)ObservablesTable.get ("Cpu_UsageObservable"); + cobs.updateCpu_Usage (weapons_.utilization); + OverheadObservable oobs = (OverheadObservable)ObservablesTable.get ("OverheadObservable"); + oobs.updateOverhead (weapons_.overhead); + JitterObservable jobs = (JitterObservable)ObservablesTable.get ("JitterObservable"); + jobs.updateJitter (weapons_.completion_time, + weapons_.computation_time, + weapons_.arrival_time); + DeadlinesObservable dobs = (DeadlinesObservable)ObservablesTable.get ("DeadlinesObservable"); + dobs.updateDeadlines (weapons_.deadline_time, + weapons_.completion_time); + LatencyObservable lobs = (LatencyObservable)ObservablesTable.get ("LatencyObservable"); + lobs.updateLatency (weapons_.completion_time, + weapons_.computation_time, + weapons_.arrival_time); + received_events_++; + } + } + + NavWeapDataHandler () { + ObservablesTable = new java.util.Hashtable(); + + ObservablesTable.put ("NavigationObservable", new NavigationObservable()); + ObservablesTable.put ("WeaponsObservable", new WeaponsObservable()); + ObservablesTable.put ("Cpu_UsageObservable", new Cpu_UsageObservable()); + ObservablesTable.put ("OverheadObservable", new OverheadObservable()); + ObservablesTable.put ("JitterObservable", new JitterObservable()); + ObservablesTable.put ("DeadlinesObservable", new DeadlinesObservable()); + ObservablesTable.put ("LatencyObservable", new LatencyObservable()); + } + + public java.util.Enumeration getObservablesList () { + return ObservablesTable.keys (); + } + + public DemoObservable getObservable(String name) { + return (DemoObservable)ObservablesTable.get (name); + } + + public int getObservableProperty (String name) { + DemoObservable obs = (DemoObservable)ObservablesTable.get (name); + return obs.getProperty (); + } + +} + + + + diff --git a/TAO/examples/Simulator/DOVEBrowser/NavigationVisComp.java b/TAO/examples/Simulator/DOVEBrowser/NavigationVisComp.java new file mode 100644 index 00000000000..d34e8d7e1eb --- /dev/null +++ b/TAO/examples/Simulator/DOVEBrowser/NavigationVisComp.java @@ -0,0 +1,332 @@ +// $Id$ +// +// = FILENAME +// NavigationVisComp.java +// +// = AUTHOR +// Seth Widoff (core functionality) +// Michael Kircher (mk1@cs.wustl.edu) +// +// = DESCRIPTION +// This is a Visualization Component for displaying navigation. +// +// ============================================================================ + + + +import java.awt.*; +import java.io.*; + +public class NavigationVisComp extends Panel implements VisComp +{ + private Alt_Horizon alt_hor_ = new Alt_Horizon (); + private Position pos_ = new Position (); + + public NavigationVisComp (String title) + { + setLayout (new BorderLayout (0, 2)); + add ("Center", alt_hor_); + add ("South", pos_); + } + + public int getProperty () + { + return Properties.NAVIGATION; + } + + public void update (java.util.Observable observable, java.lang.Object obj) + { + Navigation navigation_ = null; + try { + navigation_ = (Navigation) obj; + } + catch (Exception excp) { + System.out.println (excp); + System.out.println ("Visualization Component received wrong data type!"); + } + if (navigation_ != null) + { + alt_hor_.update_display (navigation_.roll, navigation_.pitch); + pos_.update_display (navigation_.position_latitude, + navigation_.position_longitude, + navigation_.altitude, + navigation_.heading); + } + } +} + +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 Dimension getMinimumSize () + { + return new Dimension (80, 80); + } + + 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); + + 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; + + + } + + 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; + } + + 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_); + } + + 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/DOVEBrowser/ObservablesDialog.java b/TAO/examples/Simulator/DOVEBrowser/ObservablesDialog.java new file mode 100644 index 00000000000..2ea856c24e2 --- /dev/null +++ b/TAO/examples/Simulator/DOVEBrowser/ObservablesDialog.java @@ -0,0 +1,90 @@ +// $Id$ +// +// = FILENAME +// ObservablesDialog.java +// +// = AUTHOR +// Michael Kircher (mk1@cs.wustl.edu) +// +// = DESCRIPTION +// Dialog for selecting Observables. +// +// ============================================================================ + +import java.awt.*; +import java.awt.event.*; + +public class ObservablesDialog extends Dialog { + + List list_; + DemoCore parent_; + AnswerListener listener_; + + ObservablesDialog (DemoCore parent,java.util.Enumeration enumeration) { + + super ((Frame)parent, "Select Observables", true); + parent_ = parent; + this.setSize(400, 300); + setBounds (new Rectangle (50,50,400,300)); + + list_ = new List (); + list_.setFont ( new Font ("Helvetica", Font.PLAIN, 10)); + list_.setSize (200,200); + + for (; enumeration.hasMoreElements();) { + list_.add ((String)enumeration.nextElement()); + } + + + Button ok_button_ = new Button ("OK"); + ok_button_.setFont ( new Font ("DialogHelvetica", Font.PLAIN, 10)); + Button cancel_button_ = new Button ("Cancel"); + cancel_button_.setFont ( new Font ("DialogHelvetica", Font.PLAIN, 10)); + + GridBagLayout gridbag_ = new GridBagLayout (); + GridBagConstraints constraints_ = new GridBagConstraints (); + + constraints_.fill = GridBagConstraints.BOTH; + this.setLayout (gridbag_); + + constraints_.weightx = 1.0; + constraints_.weighty = 1.0; + constraints_.gridwidth = GridBagConstraints.REMAINDER; + gridbag_.setConstraints (list_, constraints_); + this.add (list_); + + constraints_.weightx = 1.0; + constraints_.weighty = 1.0; + constraints_.gridwidth = GridBagConstraints.RELATIVE; + constraints_.fill = GridBagConstraints.NONE; + gridbag_.setConstraints (ok_button_, constraints_); + gridbag_.setConstraints (cancel_button_, constraints_); + this.add (ok_button_); + this.add (cancel_button_); + + ok_button_.addActionListener (new ActionListener () { + public void actionPerformed (ActionEvent e) { + + String selected_ = ObservablesDialog.this.list_.getSelectedItem (); + if (selected_ != null) { + System.out.println (">>>>> " + selected_); + if (listener_ != null) { + AnswerEvent ev = new AnswerEvent (ObservablesDialog.this, selected_); + listener_.ok (ev); + } + ObservablesDialog.this.setVisible (false); + } + } + }); + + cancel_button_.addActionListener (new ActionListener () { + public void actionPerformed (ActionEvent e) { + ObservablesDialog.this.setVisible (false); + } + }); + } + + public void addAnswerListener (AnswerListener al) { + listener_ = al; + } +} diff --git a/TAO/examples/Simulator/DOVEBrowser/Properties.java b/TAO/examples/Simulator/DOVEBrowser/Properties.java new file mode 100644 index 00000000000..17ff69e5a18 --- /dev/null +++ b/TAO/examples/Simulator/DOVEBrowser/Properties.java @@ -0,0 +1,22 @@ +// $Id$ +// +// = FILENAME +// DataHandler.java +// +// = AUTHOR +// Michael Kircher (mk1@cs.wustl.edu) +// +// = DESCRIPTION +// This is the interface for data handling in the simulation demo +// using the Event Channel as transport media. Several observables +// are created to feed observer Java Beans. +// +// ============================================================================ + + +public class Properties { + public static final int DOUBLE = 0; + public static final int NAVIGATION = 1; + public static final int WEAPONS = 2; +} + diff --git a/TAO/examples/Simulator/DOVEBrowser/PushConsumer.java b/TAO/examples/Simulator/DOVEBrowser/PushConsumer.java new file mode 100644 index 00000000000..26978a52d8a --- /dev/null +++ b/TAO/examples/Simulator/DOVEBrowser/PushConsumer.java @@ -0,0 +1,196 @@ +// $Id $ +// +// ============================================================================ +// +// +// = FILENAME +// PushConsumer.java +// +// = AUTHOR +// Michael Kircher (mk1@cs.wustl.edu) +// +// = DESCRIPTION +// This is a Push Consumer which takes the data field of the +// event and updates with it a Data Handler. +// +// +// ============================================================================ + + + +// The Consumer has to implement the Skeleton Consumer + +public class PushConsumer 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 DataHandler dataHandler_; + private RtecScheduler.handle_tHolder rt_info_; + private RtecEventChannelAdmin.EventChannel channel_admin_; + private RtecEventChannelAdmin.ConsumerAdmin consumer_admin_; + private RtecEventChannelAdmin.ProxyPushSupplier suppliers_; + + public PushConsumer (org.omg.CORBA.ORB orb, DataHandler dataHandler) + { + orb_ = orb; + dataHandler_ = dataHandler; + } + + + 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_++; + + for (int i = 0; i < events.length; ++i) + { + if(events[i].type_ == ACE_ES_EVENT_NOTIFICATION) + { + try + { + dataHandler_.update (events[i].data_.any_value); + } + 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); + } + } +} + + + + + + + + + + diff --git a/TAO/examples/Simulator/DOVEBrowser/PushConsumerFactory.java b/TAO/examples/Simulator/DOVEBrowser/PushConsumerFactory.java new file mode 100644 index 00000000000..37d30057c40 --- /dev/null +++ b/TAO/examples/Simulator/DOVEBrowser/PushConsumerFactory.java @@ -0,0 +1,152 @@ +// $Id$ +// +// ============================================================================ +// +// = FILENAME +// PushConsumerFactory.java +// +// = AUTHOR +// Michael Kircher (mk1@cs.wustl.edu) +// +// = DESCRIPTION +// This is the administor/factory for a PushConsumer. +// +// ============================================================================ + + + + +public class PushConsumerFactory { + + private org.omg.CORBA.ORB orb_; + private org.omg.CORBA.BOA boa_; + private org.omg.CORBA.Object naming_service_object_; + + private DataHandler dataHandler_; + private Navigation navigation_; + private Weapons weapons_; + + + public PushConsumerFactory (DataHandler dataHandler) //, String name_service_ior, java.applet.Applet applet) + { + try { + dataHandler_ = dataHandler; + 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"); + System.exit (1); + } + + // 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 + PushConsumer pushConsumer_ = new PushConsumer (orb_, dataHandler_); + pushConsumer_.open_consumer (event_channel_, scheduler_, "demo_consumer"); + + // Tell the CORBA environment that we are ready + + boa_.obj_is_ready (pushConsumer_); + + 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 PushConsumerFactory + + + + + + + diff --git a/TAO/examples/Simulator/DOVEBrowser/Queue.java b/TAO/examples/Simulator/DOVEBrowser/Queue.java new file mode 100644 index 00000000000..7ffaba15c52 --- /dev/null +++ b/TAO/examples/Simulator/DOVEBrowser/Queue.java @@ -0,0 +1,190 @@ +// $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/DOVEBrowser/Statistics.java b/TAO/examples/Simulator/DOVEBrowser/Statistics.java new file mode 100644 index 00000000000..90ec144a1fb --- /dev/null +++ b/TAO/examples/Simulator/DOVEBrowser/Statistics.java @@ -0,0 +1,52 @@ +/** +<p> +<ul> +<li> <b>Java Class</b> Statistics +<li> <b>Source File</b> Statistics.java +<li> <b>IDL Source File</b> NewNavWeap.idl +<li> <b>IDL Absolute Name</b> ::Statistics +<li> <b>Repository Identifier</b> IDL:Statistics:1.0 +</ul> +<b>IDL definition:</b> +<pre> + struct Statistics { + double utilization; + double overhead; + unsigned long arrival_time; + unsigned long deadline_time; + unsigned long completion_time; + unsigned long computation_time; + }; +</pre> +</p> +*/ +final public class Statistics { + public double utilization; + public double overhead; + public int arrival_time; + public int deadline_time; + public int completion_time; + public int computation_time; + public Statistics() { + } + public Statistics( + double utilization, + double overhead, + int arrival_time, + int deadline_time, + int completion_time, + int computation_time + ) { + this.utilization = utilization; + this.overhead = overhead; + this.arrival_time = arrival_time; + this.deadline_time = deadline_time; + this.completion_time = completion_time; + this.computation_time = computation_time; + } + public java.lang.String toString() { + org.omg.CORBA.Any any = org.omg.CORBA.ORB.init().create_any(); + StatisticsHelper.insert(any, this); + return any.toString(); + } +} diff --git a/TAO/examples/Simulator/DOVEBrowser/StatisticsHelper.java b/TAO/examples/Simulator/DOVEBrowser/StatisticsHelper.java new file mode 100644 index 00000000000..f9bb21dc31e --- /dev/null +++ b/TAO/examples/Simulator/DOVEBrowser/StatisticsHelper.java @@ -0,0 +1,73 @@ +/** +<p> +<ul> +<li> <b>Java Class</b> StatisticsHelper +<li> <b>Source File</b> StatisticsHelper.java +<li> <b>IDL Source File</b> NewNavWeap.idl +<li> <b>IDL Absolute Name</b> ::Statistics +<li> <b>Repository Identifier</b> IDL:Statistics:1.0 +</ul> +<b>IDL definition:</b> +<pre> + struct Statistics { + double utilization; + double overhead; + unsigned long arrival_time; + unsigned long deadline_time; + unsigned long completion_time; + unsigned long computation_time; + }; +</pre> +</p> +*/ +abstract public class StatisticsHelper { + private static org.omg.CORBA.ORB _orb() { + return org.omg.CORBA.ORB.init(); + } + public static Statistics read(org.omg.CORBA.portable.InputStream _input) { + Statistics result = new Statistics(); + result.utilization = _input.read_double(); + result.overhead = _input.read_double(); + result.arrival_time = _input.read_ulong(); + result.deadline_time = _input.read_ulong(); + result.completion_time = _input.read_ulong(); + result.computation_time = _input.read_ulong(); + return result; + } + public static void write(org.omg.CORBA.portable.OutputStream _output, Statistics value) { + _output.write_double(value.utilization); + _output.write_double(value.overhead); + _output.write_ulong(value.arrival_time); + _output.write_ulong(value.deadline_time); + _output.write_ulong(value.completion_time); + _output.write_ulong(value.computation_time); + } + public static void insert(org.omg.CORBA.Any any, Statistics value) { + org.omg.CORBA.portable.OutputStream output = any.create_output_stream(); + write(output, value); + any.read_value(output.create_input_stream(), type()); + } + public static Statistics extract(org.omg.CORBA.Any any) { + if(!any.type().equal(type())) { + throw new org.omg.CORBA.BAD_TYPECODE(); + } + return read(any.create_input_stream()); + } + private static org.omg.CORBA.TypeCode _type; + public static org.omg.CORBA.TypeCode type() { + if(_type == null) { + org.omg.CORBA.StructMember[] members = new org.omg.CORBA.StructMember[6]; + members[0] = new org.omg.CORBA.StructMember("utilization", _orb().get_primitive_tc(org.omg.CORBA.TCKind.tk_double), null); + members[1] = new org.omg.CORBA.StructMember("overhead", _orb().get_primitive_tc(org.omg.CORBA.TCKind.tk_double), null); + members[2] = new org.omg.CORBA.StructMember("arrival_time", _orb().get_primitive_tc(org.omg.CORBA.TCKind.tk_ulong), null); + members[3] = new org.omg.CORBA.StructMember("deadline_time", _orb().get_primitive_tc(org.omg.CORBA.TCKind.tk_ulong), null); + members[4] = new org.omg.CORBA.StructMember("completion_time", _orb().get_primitive_tc(org.omg.CORBA.TCKind.tk_ulong), null); + members[5] = new org.omg.CORBA.StructMember("computation_time", _orb().get_primitive_tc(org.omg.CORBA.TCKind.tk_ulong), null); + _type = _orb().create_struct_tc(id(), "Statistics", members); + } + return _type; + } + public static java.lang.String id() { + return "IDL:Statistics:1.0"; + } +} diff --git a/TAO/examples/Simulator/DOVEBrowser/StatisticsHolder.java b/TAO/examples/Simulator/DOVEBrowser/StatisticsHolder.java new file mode 100644 index 00000000000..a465e839e27 --- /dev/null +++ b/TAO/examples/Simulator/DOVEBrowser/StatisticsHolder.java @@ -0,0 +1,39 @@ +/** +<p> +<ul> +<li> <b>Java Class</b> StatisticsHolder +<li> <b>Source File</b> StatisticsHolder.java +<li> <b>IDL Source File</b> NewNavWeap.idl +<li> <b>IDL Absolute Name</b> ::Statistics +<li> <b>Repository Identifier</b> IDL:Statistics:1.0 +</ul> +<b>IDL definition:</b> +<pre> + struct Statistics { + double utilization; + double overhead; + unsigned long arrival_time; + unsigned long deadline_time; + unsigned long completion_time; + unsigned long computation_time; + }; +</pre> +</p> +*/ +final public class StatisticsHolder implements org.omg.CORBA.portable.Streamable { + public Statistics value; + public StatisticsHolder() { + } + public StatisticsHolder(Statistics value) { + this.value = value; + } + public void _read(org.omg.CORBA.portable.InputStream input) { + value = StatisticsHelper.read(input); + } + public void _write(org.omg.CORBA.portable.OutputStream output) { + StatisticsHelper.write(output, value); + } + public org.omg.CORBA.TypeCode _type() { + return StatisticsHelper.type(); + } +} diff --git a/TAO/examples/Simulator/DOVEBrowser/VisComp.java b/TAO/examples/Simulator/DOVEBrowser/VisComp.java new file mode 100644 index 00000000000..f4815a71588 --- /dev/null +++ b/TAO/examples/Simulator/DOVEBrowser/VisComp.java @@ -0,0 +1,18 @@ +// $Id$ +// +// = FILENAME +// VisComp.java +// +// = AUTHOR +// Michael Kircher (mk1@cs.wustl.edu) +// +// = DESCRIPTION +// This is the interface for Java Beans. +// +// ============================================================================ + + +public interface VisComp extends java.util.Observer { + + public int getProperty (); +} diff --git a/TAO/examples/Simulator/DOVEBrowser/WeaponsVisComp.java b/TAO/examples/Simulator/DOVEBrowser/WeaponsVisComp.java new file mode 100644 index 00000000000..619adbd17e6 --- /dev/null +++ b/TAO/examples/Simulator/DOVEBrowser/WeaponsVisComp.java @@ -0,0 +1,129 @@ +// $Id$ +// +// = FILENAME +// WeaponsVisComp.java +// +// = AUTHOR +// Seth Widoff (core functionality) +// Michael Kircher (mk1@cs.wustl.edu) +// +// = DESCRIPTION +// This is a Visualization Component for displaying weapons. +// +// ============================================================================ + + +import java.io.*; +import java.util.*; +import java.awt.*; + + +public class WeaponsVisComp extends Panel implements VisComp +{ + private final static String ONLINE = "Online"; + private final static String OFFLINE = "Offline"; + private final static Font FONT_BIG = new Font ("Dialog", Font.BOLD, 14); + private final static Font 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_table_ = new Hashtable (); + private GridLayout gl_= new GridLayout (1,1); + Label default_label_ = new Label ("No weapons available", Label.CENTER); + + public WeaponsVisComp (String title) + { + default_label_.setFont (FONT_BIG); + default_label_.setForeground (BLUE); + + setLayout (gl_); + + setBackground (Color.black); + add (default_label_); + } + + public int getProperty () + { + return Properties.WEAPONS; + } + + public Dimension getPreferredSize () + { + return new Dimension (250, 200); + } + + public Dimension getMinimumSize () + { + return new Dimension (80, 80); + } + + public void update (java.util.Observable observable, java.lang.Object obj) + { + Weapons weapons_ = null; + try { + weapons_ = (Weapons) obj; + } + catch (Exception excp) { + System.out.println (excp); + System.out.println ("Visualization Component received wrong data type!"); + } + if (weapons_ != null) + { + 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_table_.get (weapon); + + if (status_label != null) + status_label.setText ((status == 1) ? ONLINE : OFFLINE); + else + { + if (count_ == 0) + this.removeAll (); + count_++; + Label weapon_label = new Label (count_ + ". " + weapon, Label.LEFT); + status_label = new Label ((status == 1) ? ONLINE : OFFLINE, Label.LEFT); + + status_label.setFont (FONT_SMALL); + weapon_label.setFont (FONT_SMALL); + weapon_label.setForeground (BLUE); + + gl_.setRows (count_); + gl_.setColumns (2); + + this.add (weapon_label); + this.add (status_label); + weapons_table_.put (weapon, status_label); + } + + status_label.setForeground ((status == 1) ? + Color.lightGray : + Color.darkGray); + } + + validate (); + } + } +} 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 ()) diff --git a/TAO/examples/Simulator/NavWeap.idl b/TAO/examples/Simulator/NavWeap.idl index f3bc10f9412..de695b14522 100644 --- a/TAO/examples/Simulator/NavWeap.idl +++ b/TAO/examples/Simulator/NavWeap.idl @@ -13,41 +13,42 @@ // // ========================================================================================================= -struct Navigation -{ - long position_latitude; - long position_longitude; - unsigned long altitude; - long heading; - long roll; - long pitch; - // common part - double utilitzation; - double overhead; - unsigned long arrival_time; - unsigned long deadline_time; - unsigned long completion_time; - unsigned long computation_time; + +struct Navigation { + long position_latitude; + long position_longitude; + unsigned long altitude; + long heading; + long roll; + long pitch; + // common part + double utilization; + double overhead; + unsigned long arrival_time; + unsigned long deadline_time; + unsigned long completion_time; + unsigned long computation_time; }; -struct Weapons -{ - unsigned long number_of_weapons; - string weapon1_identifier; - unsigned long weapon1_status; - string weapon2_identifier; - unsigned long weapon2_status; - string weapon3_identifier; - unsigned long weapon3_status; - string weapon4_identifier; - unsigned long weapon4_status; - string weapon5_identifier; - unsigned long weapon5_status; - // common part - double utilitzation; - double overhead; - unsigned long arrival_time; - unsigned long deadline_time; - unsigned long completion_time; - unsigned long computation_time; + + +struct Weapons { + unsigned long number_of_weapons; + string weapon1_identifier; + unsigned long weapon1_status; + string weapon2_identifier; + unsigned long weapon2_status; + string weapon3_identifier; + unsigned long weapon3_status; + string weapon4_identifier; + unsigned long weapon4_status; + string weapon5_identifier; + unsigned long weapon5_status; + // common part + double utilization; + double overhead; + unsigned long arrival_time; + unsigned long deadline_time; + unsigned long completion_time; + unsigned long computation_time; }; diff --git a/TAO/examples/Simulator/README b/TAO/examples/Simulator/README index fe6a805a023..dec55fdede1 100644 --- a/TAO/examples/Simulator/README +++ b/TAO/examples/Simulator/README @@ -1,6 +1,6 @@ $Id$ -Documentation for the Simulator +Documentation for the Simulator/DOVE demo Purpose: To show how the event service can be used to as a media to transport monitoring events including data. @@ -8,7 +8,8 @@ Purpose: To show how the event service can be used to as a media to Application: The events contain C++ structs with avionics information. They are supllied by sensors of an avionic and are consumed by an JAVA applet running on a different machine and/or - location. + location. The collected metrics are displayed in + JAVA Beans. Implementation: A C++ Supplier pushes events containing a navigation or weapons struct to the Event Service. @@ -17,6 +18,11 @@ Implementation: A C++ Supplier pushes events containing a consumer extracts the data of the structs and dispatches it to various display components. + +For more informations refer to: + $TAO_ROOT/docs/releasenotes/index.html + + Requirements: C++ compiler, TAO environment, Visibroker 3.2 for JAVA @@ -33,7 +39,7 @@ Files: NavWeap.idl - IDL definition of the Weapons and Navigation struct README - this readme file - Supplier: + Supplier: (in directory $TAO_ROOT/orbsvcs/tests/Simulator/Event_Supplier/) Event_Sup.cpp - Event Supplier Event_Sup.h - Event Supplier class definition Makefile - Event Supplier Makefile @@ -41,22 +47,24 @@ Files: svc.conf - helper file - Consumer, Simulator: - Display.java - Simulation core class - Display_Client.java - Main Entry point of the Simulation - Display_Consumer.java - Event Consumer Administrator - Display_Push_Consumer.java - Actual Event Consumer - Display_Object.java - Interface for an Display_Object - Display_Weapons.java - Implementation of an Display_Object - Display_Art_Horizon.java - Implementation of an Display_Object - Display_Object_Factory.java - Factory Object for Display_Objects - Graph.java - Simulation - Graph_Panel.java - Simulation - NS_Resolve.java - Resolving the inital reference to the Naming Service - Queue.java - Simulation - Sim_Panel.java - Simulation - Border_Panel.java - Simulation - + Consumer, DOVEBrowswer: (in directory $TAO_ROOT/orbsvcs/tests/Simulator/DOVEBrowser/) + AnswerEvent.java - Having my own Events + AnswerListener.java - Listener for these Events + DataHandler.java - Base class for all Data Handlers + DemoCore.java - Core of the Demo to connect Observables with Observers + DemoObservable.java - Base class for Observables + DoubleVisComp.java - Visualization Component (will be a JavaBean) for Doubles + DOVEBrowser.java - Wrapper around DemoCore + NS_Resolve.java - Resolving the inital reference to the Naming Service + NavWeapDataHandler.java - Specialized Data Handler for Navigation and Weapon data + NavigationVisComp.java - Visualization Component (... JavaBean) for Navigation data + ObservablesDialog.java - Dialog window for connecting Observables with OBservers + Properties.java - constant definitons + PushConsumer.java - Event Service Push Consumer + PushConsumerFactory.java - Factory for the Consumer + Queue.java - Queue for the DoubleVisComp + VisComp.java - Base class for the Visualization Components + WeaponsVisComp.java - Visualization Component for Weapons Compiling: @@ -80,23 +88,24 @@ Compiling: make - DOVE Browser: in directory $TAO/orbsvcs/tests/Simulator/Sim_Display/.) + + + DOVE Browser: in directory $TAO/orbsvcs/tests/Simulator/DOVEBrowser/.) cp ../NavWeap.idl . cp $TAO_ROOT/orbsvcs/orbsvcs/CosNaming.idl . cp $TAO_ROOT/orbsvcs/orbsvcs/CosTimeBase.idl . cp $TAO_ROOT/orbsvcs/orbsvcs/RtecEventChannelAdmin.idl . cp $TAO_ROOT/orbsvcs/orbsvcs/RtecEventComm.idl . cp $TAO_ROOT/orbsvcs/orbsvcs/RtecScheduler.idl . - idl2java NavWeap.idl - idl2java CosNaming.idl - idl2java CosTimeBase.idl - idl2java RtecEventChannelAdmin.idl - idl2java RtecEventComm.idl - idl2java RtecScheduler.idl + idl2java *.idl vbjc *.java Starting: + Start in the following order: + Naming Service + Scheduling Service + Event Service Supplier: Event_Sup -ORBport 10040 -f MLF.dat -m 1000 @@ -104,4 +113,4 @@ Starting: // -f MLF.dat to read scheduling data from this file as input DOVE Browser: - vbj Display_Client + vbj DOVEBrowser diff --git a/TAO/examples/Simulator/Sim_Display/Display_Push_Consumer.java b/TAO/examples/Simulator/Sim_Display/Display_Push_Consumer.java index 30ee8231742..42fca6e7db9 100644 --- a/TAO/examples/Simulator/Sim_Display/Display_Push_Consumer.java +++ b/TAO/examples/Simulator/Sim_Display/Display_Push_Consumer.java @@ -86,7 +86,7 @@ public class Display_Push_Consumer extends RtecEventComm._PushConsumerImplBase if (events[i].data_.any_value.type().equal (NavigationHelper.type())) { navigation_ = NavigationHelper.extract (events[i].data_.any_value); - display_.update_metrics (navigation_.utilitzation, + display_.update_metrics (navigation_.utilization, navigation_.overhead, navigation_.arrival_time, navigation_.deadline_time, @@ -97,7 +97,7 @@ public class Display_Push_Consumer extends RtecEventComm._PushConsumerImplBase else if (events[i].data_.any_value.type().equal (WeaponsHelper.type())) { weapons_ = WeaponsHelper.extract (events[i].data_.any_value); - display_.update_metrics (weapons_.utilitzation, + display_.update_metrics (weapons_.utilization, weapons_.overhead, weapons_.arrival_time, weapons_.deadline_time, @@ -147,7 +147,7 @@ public class Display_Push_Consumer extends RtecEventComm._PushConsumerImplBase new TimeBase.ulonglong (0,0), new TimeBase.ulonglong (0,0), 2500000, // period - RtecScheduler.Importance.VERY_LOW, + RtecScheduler.Importance.VERY_LOW_IMPORTANCE, new TimeBase.ulonglong (0,0), 1); |