|
From: <jac...@us...> - 2010-06-07 17:30:54
|
Revision: 303
http://openlcb.svn.sourceforge.net/openlcb/?rev=303&view=rev
Author: jacobsen
Date: 2010-06-07 17:30:47 +0000 (Mon, 07 Jun 2010)
Log Message:
-----------
first demo applet
Modified Paths:
--------------
trunk/prototypes/java/src/org/openlcb/swing/ConsumerPane.java
trunk/prototypes/java/src/org/openlcb/swing/MonPane.java
trunk/prototypes/java/src/org/openlcb/swing/ProducerPane.java
Added Paths:
-----------
trunk/prototypes/java/BlueGoldApplet.html
trunk/prototypes/java/openlcb.jar
trunk/prototypes/java/test/scenarios/BlueGoldApplet.java
Added: trunk/prototypes/java/BlueGoldApplet.html
===================================================================
--- trunk/prototypes/java/BlueGoldApplet.html (rev 0)
+++ trunk/prototypes/java/BlueGoldApplet.html 2010-06-07 17:30:47 UTC (rev 303)
@@ -0,0 +1,71 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+ <title>Blue-Gold Demo</title>
+</head>
+<body>
+This page demonstrates the OpenLCB Blue/Gold algorithm for easily programming
+producers and consumers.
+<p>
+Press the button at the bottom to start the demonstration.
+
+<h2>An Example</h2>
+
+First, let's set the 1st producer in the 1st node to be programmed:
+<ul>
+<li>Press Blue on the 1st node once. The blue light comes on.
+<li>Next, click Gold on the 1st node once to select the 1st producer.
+The blue light goes off.
+</ul>
+Next, select the 1st consumer on the 2nd board, and tell all selected
+producers and consumers to use its event:
+<ul>
+<li>Press Gold to indicate you want to select an event to be learned.
+The gold light comes on to indicate this.
+<li>Press Blue on the 2nd node 4 times (three for the producers, then
+one more to get to the 1st consumer).
+<li>Press Gold again. The gold and blue lights go off.
+</ul>
+Note that the 1st producer on the 1st node is now showing the event number
+from the selected consumer. If you press that producer, it sends its event,
+and the consumer responds.
+
+<h2>How it works</h2>
+
+Basically, the blue button selects a producer or consumer, and the
+gold button specifies what to do with it.
+
+<p>
+To select a producer or consumer, just click the blue button the
+necessary number of times. Clicks cycle through the producers, then
+through the consumers, then back to no selection.
+If you lose track, just push the blue button until the light goes
+out, then start counting again.
+
+<p>
+The gold button does commands and modes.
+<ul>
+<li>Push and hold it for 3 seconds, then release, to reset the node
+to factory defaults.
+<li>Push it after you pick a producer or consumer with blue to
+select that producer or consumer for programming. You can
+select as many producers and consumers in a node as you'd like.
+<li>Push it before picking with the blue button to select "programming mode".
+The gold LED lights. After you select a producer or consumer (blue LED lit),
+clicking gold again will send the corresponding event to be programmed
+into all the other selected producers and consumers, and then exit this mode
+by turning off the gold LED.
+</ul>
+
+If you've selected producers and/or consumers and want to deselect them,
+press and hold the blue button for at least three seconds. All selected
+producers and consumers on that node will be unselected.
+
+<p>
+<applet code = "scenarios.BlueGoldApplet" archive = "openlcb.jar"
+ height="60"
+ width="300"
+/>
+</body>
+</html>
Property changes on: trunk/prototypes/java/BlueGoldApplet.html
___________________________________________________________________
Added: svn:mime-type
+ text/html
Added: svn:keywords
+ Id Revision
Added: svn:eol-style
+ native
Added: trunk/prototypes/java/openlcb.jar
===================================================================
(Binary files differ)
Property changes on: trunk/prototypes/java/openlcb.jar
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Modified: trunk/prototypes/java/src/org/openlcb/swing/ConsumerPane.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/swing/ConsumerPane.java 2010-06-07 15:49:24 UTC (rev 302)
+++ trunk/prototypes/java/src/org/openlcb/swing/ConsumerPane.java 2010-06-07 17:30:47 UTC (rev 303)
@@ -20,7 +20,7 @@
final static int DELAY = 2000;
- public ConsumerPane(String name, SingleConsumerNode node) throws Exception {
+ public ConsumerPane(String name, SingleConsumerNode node) {
this.name = name;
if (name != null) sendLabel.setText(name);
else sendLabel.setText(node.getEventID().toString());
Modified: trunk/prototypes/java/src/org/openlcb/swing/MonPane.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/swing/MonPane.java 2010-06-07 15:49:24 UTC (rev 302)
+++ trunk/prototypes/java/src/org/openlcb/swing/MonPane.java 2010-06-07 17:30:47 UTC (rev 303)
@@ -46,7 +46,7 @@
protected JTextField entryField = new JTextField();
protected JButton enterButton = new JButton();
- final javax.swing.JFileChooser logFileChooser = new JFileChooser();
+ javax.swing.JFileChooser logFileChooser;
// for locking
MonPane self;
@@ -56,7 +56,7 @@
self = this;
}
- public void initComponents() throws Exception {
+ public void initComponents() {
// the following code sets the frame's initial state
clearButton.setText("Clear screen");
@@ -158,9 +158,24 @@
});
// set file chooser to a default
- logFileChooser.setSelectedFile(new File("monitorLog.txt"));
+ setFileChooser();
+ if (logFileChooser == null) {
+ openFileChooserButton.setEnabled(false);
+ openFileChooserButton.setVisible(false);
+ }
}
+ void setFileChooser() {
+ try {
+ if (logFileChooser == null) {
+ logFileChooser = new JFileChooser();
+ // set file chooser to a default
+ logFileChooser.setSelectedFile(new File("monitorLog.txt"));
+ }
+ } catch (Exception e) {
+ logFileChooser = null;
+ }
+ }
public void nextLine(String line, String raw) {
// handle display of traffic
@@ -246,7 +261,9 @@
if ( logStream==null) { // successive clicks don't restart the file
// start logging
try {
- logStream = new PrintStream (new FileOutputStream(logFileChooser.getSelectedFile()));
+ setFileChooser();
+ if (logFileChooser != null)
+ logStream = new PrintStream (new FileOutputStream(logFileChooser.getSelectedFile()));
} catch (Exception ex) {
System.err.println("exception "+ex);
}
@@ -263,6 +280,9 @@
}
public void openFileChooserButtonActionPerformed(java.awt.event.ActionEvent e) {
+ setFileChooser();
+ if (logFileChooser == null)
+ return;
// start at current file, show dialog
int retVal = logFileChooser.showSaveDialog(this);
Modified: trunk/prototypes/java/src/org/openlcb/swing/ProducerPane.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/swing/ProducerPane.java 2010-06-07 15:49:24 UTC (rev 302)
+++ trunk/prototypes/java/src/org/openlcb/swing/ProducerPane.java 2010-06-07 17:30:47 UTC (rev 303)
@@ -16,7 +16,7 @@
*/
public class ProducerPane extends JPanel {
- public ProducerPane(String name, SingleProducerNode node) throws Exception {
+ public ProducerPane(String name, SingleProducerNode node) {
this.node = node;
this.name = name;
Copied: trunk/prototypes/java/test/scenarios/BlueGoldApplet.java (from rev 292, trunk/prototypes/java/test/scenarios/BlueGoldCheck.java)
===================================================================
--- trunk/prototypes/java/test/scenarios/BlueGoldApplet.java (rev 0)
+++ trunk/prototypes/java/test/scenarios/BlueGoldApplet.java 2010-06-07 17:30:47 UTC (rev 303)
@@ -0,0 +1,388 @@
+package scenarios;
+
+import org.openlcb.*;
+import org.openlcb.implementations.*;
+import org.openlcb.swing.*;
+
+import javax.swing.*;
+import java.awt.*;
+import java.util.*;
+
+/**
+ * Simulate 6 nodes interacting on a single gather/scatter
+ * for testing blue/gold programming.
+ *
+ * Applet for web demonstration of BlueGold.
+ * Largely a duplicate of BlueGoldCheck app,
+ * modified for single-frame applet use.
+ *
+ * @author Bob Jacobsen Copyright 2009
+ * @version $Revision$
+ */
+public class BlueGoldApplet extends JApplet {
+
+ public BlueGoldApplet() {}
+
+ /**
+ * Applet starts here
+ */
+ public void start() {
+ JPanel p = new JPanel();
+ add(p);
+ p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
+ startButton = new JButton("Blue-Gold algorithm demonstration");
+ p.add(startButton);
+ startButton.addActionListener(
+ new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent e) {
+ startDemo();
+ }
+ });
+
+ }
+
+ JButton startButton;
+
+ void startDemo() {
+ startButton.setEnabled(false);
+
+ sg = new ScatterGather();
+
+ // show a monitor frame
+ JFrame f = new JFrame();
+ f.setTitle("Blue-Gold Check");
+ MonPane m = new MonPane();
+ f.add( m );
+ m.initComponents();
+ f.pack();
+ f.setVisible(true);
+ sg.register(m.getConnection());
+
+ createSampleNode(1);
+ createSampleNode(2);
+ createSampleNode(3);
+ createSampleNode(4);
+ }
+
+ ScatterGather sg;
+
+ void createSampleNode(int index) {
+ NodeID id;
+ SingleProducer producer11;
+ SingleProducer producer12;
+ SingleProducer producer13;
+ SingleConsumer consumer11;
+ SingleConsumer consumer12;
+ SingleConsumer consumer13;
+
+ id = new NodeID(new byte[]{0,0,0,0,0,(byte)index});
+
+ // create and connect the nodes
+ producer11 = new SingleProducer(id, sg.getConnection(),
+ new EventID(id, 1, 1));
+ sg.register(producer11);
+
+ producer12 = new SingleProducer(id, sg.getConnection(),
+ new EventID(id, 1, 2));
+ sg.register(producer12);
+
+ producer13 = new SingleProducer(id, sg.getConnection(),
+ new EventID(id, 1, 3));
+ sg.register(producer13);
+
+
+ consumer11 = new SingleConsumer(id, sg.getConnection(),
+ new EventID(id, 0, 1));
+ sg.register(consumer11);
+
+ consumer12 = new SingleConsumer(id, sg.getConnection(),
+ new EventID(id, 0, 2));
+ sg.register(consumer12);
+
+ consumer13 = new SingleConsumer(id, sg.getConnection(),
+ new EventID(id, 0, 3));
+ sg.register(consumer13);
+
+ // composite GUI
+ java.util.List<SingleProducer> producers
+ = new ArrayList<SingleProducer>();
+ producers.add(producer11);
+ producers.add(producer12);
+ producers.add(producer13);
+
+ java.util.List<SingleConsumer> consumers
+ = new ArrayList<SingleConsumer>();
+ consumers.add(consumer11);
+ consumers.add(consumer12);
+ consumers.add(consumer13);
+ JFrame f = new BGnodeFrame("BG simulated node "+index, producers, consumers, id, sg);
+ f.pack();
+ f.setVisible(true);
+ }
+
+
+ // frame starting positions
+ int hPos = 500;
+ int vPos = 0;
+
+ /**
+ * Captive class to demonstrate B-G protocol, will
+ * probably need to go elsewhere after seperating
+ * algorithm and Swing display.
+ */
+ class BGnodeFrame extends JFrame {
+ public BGnodeFrame(String name,
+ java.util.List<SingleProducer> producers,
+ java.util.List<SingleConsumer> consumers,
+ NodeID nid,
+ ScatterGather sg) {
+ super(name);
+
+ BGnodePanel b = new BGnodePanel(nid, producers, consumers, sg);
+ getContentPane().add( b );
+ getContentPane().setLayout(new FlowLayout());
+
+ for (int i = 0; i<consumers.size(); i++)
+ b.addConsumer(consumers.get(i), null); // null means autolabel
+ for (int i = 0; i<producers.size(); i++)
+ b.addProducer(producers.get(i), null); // null means autolabel
+
+ this.setLocation(hPos, vPos);
+ vPos+= 200;
+ }
+ }
+
+ /**
+ * Captive class to demonstrate B-G protocol, will
+ * probably need to go elsewhere after seperating
+ * algorithm and Swing display.
+ */
+ class BGnodePanel extends JPanel {
+
+ public BGnodePanel(NodeID nid,
+ java.util.List<SingleProducer> producers,
+ java.util.List<SingleConsumer> consumers,
+ ScatterGather sg) {
+ this.nid = nid;
+
+ this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
+ buttons = new JPanel();
+ buttons.setLayout(new GridLayout(2, Math.max(consumers.size(), producers.size())));
+ this.add(buttons);
+ this.add(new JSeparator());
+
+ JPanel p1 = new JPanel();
+ p1.setLayout(new FlowLayout());
+ this.add (p1);
+
+ blueButton = new JButton("Blue");
+ p1.add(blueButton);
+ blueLabel = new JLabel(" ");
+ setBlueOn(false);
+ p1.add(blueLabel);
+
+ goldButton = new JButton("Gold");
+ p1.add(goldButton);
+ goldLabel = new JLabel(" ");
+ setGoldOn(false);
+ p1.add(goldLabel);
+
+ engine = new BlueGoldExtendedEngine(nid, sg, producers, consumers) {
+ public void setBlueLightOn(boolean f) {
+ setBlueOn(f);
+ }
+ public boolean getBlueLightOn() {
+ return blueOn;
+ }
+
+ public void setBlueLightBlink(int dwell) {
+ setBlueBlink(dwell);
+ }
+
+ public void setGoldLightOn(boolean f) {
+ setGoldOn(f);
+ }
+ public boolean getGoldLightOn() {
+ return goldOn;
+ }
+
+ public void setGoldLightBlink(int dwell) {
+ setGoldBlink(dwell);
+ }
+
+ };
+
+ sg.register(engine);
+
+ blueButton.addMouseListener(new java.awt.event.MouseAdapter() {
+ public void mousePressed(java.awt.event.MouseEvent e) {
+ blueTime = System.currentTimeMillis();
+ }
+ public void mouseReleased(java.awt.event.MouseEvent e) {
+ if (System.currentTimeMillis()-blueTime < 2000)
+ engine.blueClick();
+ else
+ longBluePress();
+ }
+ });
+
+ goldButton.addMouseListener(new java.awt.event.MouseAdapter() {
+ public void mousePressed(java.awt.event.MouseEvent e) {
+ goldTime = System.currentTimeMillis();
+ }
+ public void mouseReleased(java.awt.event.MouseEvent e) {
+ if (System.currentTimeMillis()-goldTime < 2000)
+ engine.goldClick();
+ else
+ longGoldPress();
+ }
+ });
+ }
+
+ NodeID nid;
+
+ /**
+ * Handle a long (greater than 2 second) press on
+ * the blue button
+ */
+ void longBluePress() {
+ // reset selections
+ System.out.println("reset selections");
+ engine.longBluePress();
+ }
+
+ /**
+ * Handle a long (greater than 2 second) press on
+ * the gold button
+ */
+ void longGoldPress() {
+ // reset the device
+ System.out.println("reset device");
+ producers.get(0).setEventID(new EventID(nid, 1, 1));
+ producers.get(1).setEventID(new EventID(nid, 1, 2));
+ producers.get(2).setEventID(new EventID(nid, 1, 3));
+ consumers.get(0).setEventID(new EventID(nid, 0, 1));
+ consumers.get(1).setEventID(new EventID(nid, 0, 2));
+ consumers.get(2).setEventID(new EventID(nid, 0, 3));
+ }
+
+ long blueTime;
+ long goldTime;
+ JPanel buttons;
+ JButton blueButton;
+ JButton goldButton;
+ JLabel blueLabel;
+ JLabel goldLabel;
+ boolean blueOn;
+ boolean blueBlink;
+ javax.swing.Timer blueTimer = new javax.swing.Timer(500,
+ new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent e) {
+ blueOn = ! blueOn;
+ if (blueOn)
+ colorBlueOn();
+ else
+ colorBlueOff();
+ }
+ });
+
+ boolean goldOn;
+ boolean goldBlink;
+ javax.swing.Timer goldTimer = new javax.swing.Timer(500,
+ new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent e) {
+ goldOn = ! goldOn;
+ if (goldOn)
+ colorGoldOn();
+ else
+ colorGoldOff();
+ }
+ });
+
+ BlueGoldEngine engine;
+
+ public void setBlueOn(boolean t) {
+ blueBlink = false;
+ blueOn = t;
+ blueTimer.stop();
+ blueLabel.setOpaque(true);
+ if (t)
+ colorBlueOn();
+ else
+ colorBlueOff();
+ }
+
+ public void setBlueBlink(int dwell) {
+ blueBlink = true;
+ blueOn = true;
+ blueTimer.stop();
+ blueTimer.setInitialDelay(dwell);
+ blueTimer.setDelay(dwell);
+ blueTimer.start();
+ blueLabel.setOpaque(true);
+ colorBlueOn();
+ }
+ void colorBlueOff() {
+ blueLabel.setBackground(java.awt.Color.lightGray);
+ }
+ void colorBlueOn() {
+ blueLabel.setBackground(java.awt.Color.blue.brighter().brighter());
+ }
+
+ public void setGoldOn(boolean t) {
+ goldBlink = false;
+ goldOn = t;
+ goldTimer.stop();
+ goldLabel.setOpaque(true);
+ if (t)
+ colorGoldOn();
+ else
+ colorGoldOff();
+ }
+
+ public void setGoldBlink(int dwell) {
+ goldBlink = true;
+ goldOn = true;
+ goldTimer.stop();
+ goldTimer.setInitialDelay(dwell);
+ goldTimer.setDelay(dwell);
+ goldTimer.start();
+ goldLabel.setOpaque(true);
+ colorGoldOn();
+ }
+
+ void colorGoldOff() {
+ goldLabel.setBackground(java.awt.Color.lightGray);
+ }
+ void colorGoldOn() {
+ goldLabel.setBackground(java.awt.Color.yellow.brighter().brighter());
+ }
+ java.util.List<SingleProducer> producers = new ArrayList<SingleProducer>();
+ JPanel producerPanel = new JPanel();
+
+ /**
+ * Add a producer to node.
+ * Note this should be a working producer,
+ * already registered, etc
+ */
+ public void addProducer(SingleProducer n, String name) {
+ producers.add(n);
+ buttons.add(new ProducerPane(name, n));
+ }
+
+ java.util.List<SingleConsumer> consumers = new ArrayList<SingleConsumer>();
+ JPanel consumerPanel = new JPanel();
+
+ /**
+ * Add a consumer to node.
+ * Note this should be a working consumer,
+ * already registered, etc
+ */
+ public void addConsumer(SingleConsumer n, String name) {
+ consumers.add(n);
+ ConsumerPane cp = new ConsumerPane(name, n);
+ buttons.add(cp);
+ }
+ }
+
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jac...@us...> - 2010-06-08 04:31:32
|
Revision: 313
http://openlcb.svn.sourceforge.net/openlcb/?rev=313&view=rev
Author: jacobsen
Date: 2010-06-08 04:31:26 +0000 (Tue, 08 Jun 2010)
Log Message:
-----------
add image, improve text
Modified Paths:
--------------
trunk/prototypes/java/BlueGoldApplet.html
Added Paths:
-----------
trunk/prototypes/java/images/
trunk/prototypes/java/images/BlueGoldAppletNode.png
Modified: trunk/prototypes/java/BlueGoldApplet.html
===================================================================
--- trunk/prototypes/java/BlueGoldApplet.html 2010-06-08 04:20:28 UTC (rev 312)
+++ trunk/prototypes/java/BlueGoldApplet.html 2010-06-08 04:31:26 UTC (rev 313)
@@ -10,6 +10,20 @@
<p>
Press the button at the bottom to start the demonstration.
+<p>
+<a href="images/BlueGoldAppletNode.png"><img src="images/BlueGoldAppletNode.png" height="70" width="266" align="right"></a>
+You'll see a monitor window, to see what the protocol does,
+plus four windows representing nodes. Each has three consumers set
+to specific events, and three producers set to specific events.
+The producers are buttons; when you press the button, the event is sent.
+If a consumer see's its configured event, it flashes.
+
+<p>
+Originally, they are all set to unique and different EventIDs.
+You use the blue and gold buttons and lights (boxes) to configure
+the connections between producers and consumers. Blue is used
+to select the ones to be configured, and gold presses do the operations.
+
<h2>An Example</h2>
First, let's set the 1st producer in the 1st node to be programmed:
Added: trunk/prototypes/java/images/BlueGoldAppletNode.png
===================================================================
(Binary files differ)
Property changes on: trunk/prototypes/java/images/BlueGoldAppletNode.png
___________________________________________________________________
Added: svn:mime-type
+ image/png
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jac...@us...> - 2010-06-08 04:31:33
|
Revision: 313
http://openlcb.svn.sourceforge.net/openlcb/?rev=313&view=rev
Author: jacobsen
Date: 2010-06-08 04:31:26 +0000 (Tue, 08 Jun 2010)
Log Message:
-----------
add image, improve text
Modified Paths:
--------------
trunk/prototypes/java/BlueGoldApplet.html
Added Paths:
-----------
trunk/prototypes/java/images/
trunk/prototypes/java/images/BlueGoldAppletNode.png
Modified: trunk/prototypes/java/BlueGoldApplet.html
===================================================================
--- trunk/prototypes/java/BlueGoldApplet.html 2010-06-08 04:20:28 UTC (rev 312)
+++ trunk/prototypes/java/BlueGoldApplet.html 2010-06-08 04:31:26 UTC (rev 313)
@@ -10,6 +10,20 @@
<p>
Press the button at the bottom to start the demonstration.
+<p>
+<a href="images/BlueGoldAppletNode.png"><img src="images/BlueGoldAppletNode.png" height="70" width="266" align="right"></a>
+You'll see a monitor window, to see what the protocol does,
+plus four windows representing nodes. Each has three consumers set
+to specific events, and three producers set to specific events.
+The producers are buttons; when you press the button, the event is sent.
+If a consumer see's its configured event, it flashes.
+
+<p>
+Originally, they are all set to unique and different EventIDs.
+You use the blue and gold buttons and lights (boxes) to configure
+the connections between producers and consumers. Blue is used
+to select the ones to be configured, and gold presses do the operations.
+
<h2>An Example</h2>
First, let's set the 1st producer in the 1st node to be programmed:
Added: trunk/prototypes/java/images/BlueGoldAppletNode.png
===================================================================
(Binary files differ)
Property changes on: trunk/prototypes/java/images/BlueGoldAppletNode.png
___________________________________________________________________
Added: svn:mime-type
+ image/png
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jac...@us...> - 2010-06-08 04:42:53
|
Revision: 315
http://openlcb.svn.sourceforge.net/openlcb/?rev=315&view=rev
Author: jacobsen
Date: 2010-06-08 04:42:47 +0000 (Tue, 08 Jun 2010)
Log Message:
-----------
long gold resets to new unique events
Modified Paths:
--------------
trunk/prototypes/java/openlcb.jar
trunk/prototypes/java/test/scenarios/BlueGoldApplet.java
trunk/prototypes/java/test/scenarios/BlueGoldCheck.java
Modified: trunk/prototypes/java/openlcb.jar
===================================================================
(Binary files differ)
Modified: trunk/prototypes/java/test/scenarios/BlueGoldApplet.java
===================================================================
--- trunk/prototypes/java/test/scenarios/BlueGoldApplet.java 2010-06-08 04:34:30 UTC (rev 314)
+++ trunk/prototypes/java/test/scenarios/BlueGoldApplet.java 2010-06-08 04:42:47 UTC (rev 315)
@@ -240,6 +240,7 @@
}
NodeID nid;
+ int resets = 0;
/**
* Handle a long (greater than 2 second) press on
@@ -256,14 +257,15 @@
* the gold button
*/
void longGoldPress() {
+ resets++;
// reset the device
System.out.println("reset device");
- producers.get(0).setEventID(new EventID(nid, 1, 1));
- producers.get(1).setEventID(new EventID(nid, 1, 2));
- producers.get(2).setEventID(new EventID(nid, 1, 3));
- consumers.get(0).setEventID(new EventID(nid, 0, 1));
- consumers.get(1).setEventID(new EventID(nid, 0, 2));
- consumers.get(2).setEventID(new EventID(nid, 0, 3));
+ producers.get(0).setEventID(new EventID(nid, 1, 1+resets*3));
+ producers.get(1).setEventID(new EventID(nid, 1, 2+resets*3));
+ producers.get(2).setEventID(new EventID(nid, 1, 3+resets*3));
+ consumers.get(0).setEventID(new EventID(nid, 0, 1+resets*3));
+ consumers.get(1).setEventID(new EventID(nid, 0, 2+resets*3));
+ consumers.get(2).setEventID(new EventID(nid, 0, 3+resets*3));
}
long blueTime;
Modified: trunk/prototypes/java/test/scenarios/BlueGoldCheck.java
===================================================================
--- trunk/prototypes/java/test/scenarios/BlueGoldCheck.java 2010-06-08 04:34:30 UTC (rev 314)
+++ trunk/prototypes/java/test/scenarios/BlueGoldCheck.java 2010-06-08 04:42:47 UTC (rev 315)
@@ -251,6 +251,7 @@
}
NodeID nid;
+ int resets = 0;
/**
* Handle a long (greater than 2 second) press on
@@ -267,14 +268,15 @@
* the gold button
*/
void longGoldPress() {
+ resets++;
// reset the device
System.out.println("reset device");
- producers.get(0).setEventID(new EventID(nid, 1, 1));
- producers.get(1).setEventID(new EventID(nid, 1, 2));
- producers.get(2).setEventID(new EventID(nid, 1, 3));
- consumers.get(0).setEventID(new EventID(nid, 0, 1));
- consumers.get(1).setEventID(new EventID(nid, 0, 2));
- consumers.get(2).setEventID(new EventID(nid, 0, 3));
+ producers.get(0).setEventID(new EventID(nid, 1, 1+resets*3));
+ producers.get(1).setEventID(new EventID(nid, 1, 2+resets*3));
+ producers.get(2).setEventID(new EventID(nid, 1, 3+resets*3));
+ consumers.get(0).setEventID(new EventID(nid, 0, 1+resets*3));
+ consumers.get(1).setEventID(new EventID(nid, 0, 2+resets*3));
+ consumers.get(2).setEventID(new EventID(nid, 0, 3+resets*3));
}
long blueTime;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jac...@us...> - 2010-06-08 04:42:53
|
Revision: 315
http://openlcb.svn.sourceforge.net/openlcb/?rev=315&view=rev
Author: jacobsen
Date: 2010-06-08 04:42:47 +0000 (Tue, 08 Jun 2010)
Log Message:
-----------
long gold resets to new unique events
Modified Paths:
--------------
trunk/prototypes/java/openlcb.jar
trunk/prototypes/java/test/scenarios/BlueGoldApplet.java
trunk/prototypes/java/test/scenarios/BlueGoldCheck.java
Modified: trunk/prototypes/java/openlcb.jar
===================================================================
(Binary files differ)
Modified: trunk/prototypes/java/test/scenarios/BlueGoldApplet.java
===================================================================
--- trunk/prototypes/java/test/scenarios/BlueGoldApplet.java 2010-06-08 04:34:30 UTC (rev 314)
+++ trunk/prototypes/java/test/scenarios/BlueGoldApplet.java 2010-06-08 04:42:47 UTC (rev 315)
@@ -240,6 +240,7 @@
}
NodeID nid;
+ int resets = 0;
/**
* Handle a long (greater than 2 second) press on
@@ -256,14 +257,15 @@
* the gold button
*/
void longGoldPress() {
+ resets++;
// reset the device
System.out.println("reset device");
- producers.get(0).setEventID(new EventID(nid, 1, 1));
- producers.get(1).setEventID(new EventID(nid, 1, 2));
- producers.get(2).setEventID(new EventID(nid, 1, 3));
- consumers.get(0).setEventID(new EventID(nid, 0, 1));
- consumers.get(1).setEventID(new EventID(nid, 0, 2));
- consumers.get(2).setEventID(new EventID(nid, 0, 3));
+ producers.get(0).setEventID(new EventID(nid, 1, 1+resets*3));
+ producers.get(1).setEventID(new EventID(nid, 1, 2+resets*3));
+ producers.get(2).setEventID(new EventID(nid, 1, 3+resets*3));
+ consumers.get(0).setEventID(new EventID(nid, 0, 1+resets*3));
+ consumers.get(1).setEventID(new EventID(nid, 0, 2+resets*3));
+ consumers.get(2).setEventID(new EventID(nid, 0, 3+resets*3));
}
long blueTime;
Modified: trunk/prototypes/java/test/scenarios/BlueGoldCheck.java
===================================================================
--- trunk/prototypes/java/test/scenarios/BlueGoldCheck.java 2010-06-08 04:34:30 UTC (rev 314)
+++ trunk/prototypes/java/test/scenarios/BlueGoldCheck.java 2010-06-08 04:42:47 UTC (rev 315)
@@ -251,6 +251,7 @@
}
NodeID nid;
+ int resets = 0;
/**
* Handle a long (greater than 2 second) press on
@@ -267,14 +268,15 @@
* the gold button
*/
void longGoldPress() {
+ resets++;
// reset the device
System.out.println("reset device");
- producers.get(0).setEventID(new EventID(nid, 1, 1));
- producers.get(1).setEventID(new EventID(nid, 1, 2));
- producers.get(2).setEventID(new EventID(nid, 1, 3));
- consumers.get(0).setEventID(new EventID(nid, 0, 1));
- consumers.get(1).setEventID(new EventID(nid, 0, 2));
- consumers.get(2).setEventID(new EventID(nid, 0, 3));
+ producers.get(0).setEventID(new EventID(nid, 1, 1+resets*3));
+ producers.get(1).setEventID(new EventID(nid, 1, 2+resets*3));
+ producers.get(2).setEventID(new EventID(nid, 1, 3+resets*3));
+ consumers.get(0).setEventID(new EventID(nid, 0, 1+resets*3));
+ consumers.get(1).setEventID(new EventID(nid, 0, 2+resets*3));
+ consumers.get(2).setEventID(new EventID(nid, 0, 3+resets*3));
}
long blueTime;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jac...@us...> - 2010-07-03 16:30:22
|
Revision: 520
http://openlcb.svn.sourceforge.net/openlcb/?rev=520&view=rev
Author: jacobsen
Date: 2010-07-03 16:30:16 +0000 (Sat, 03 Jul 2010)
Log Message:
-----------
update to alg in C code
Modified Paths:
--------------
trunk/prototypes/java/src/org/openlcb/can/NIDa.java
trunk/prototypes/java/src/org/openlcb/can/NIDaAlgorithm.java
trunk/prototypes/java/test/org/openlcb/can/NIDaAlgorithmTest.java
Modified: trunk/prototypes/java/src/org/openlcb/can/NIDa.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/can/NIDa.java 2010-07-03 16:02:40 UTC (rev 519)
+++ trunk/prototypes/java/src/org/openlcb/can/NIDa.java 2010-07-03 16:30:16 UTC (rev 520)
@@ -9,7 +9,7 @@
* sending and receiving of CAN frames.
*
*
- * @author Bob Jacobsen Copyright 2009
+ * @author Bob Jacobsen Copyright 2009, 2010
* @version $Revision$
*/
public class NIDa {
@@ -43,8 +43,9 @@
* value. In the process, it updates the alias
* to the value implied by this seed.
*/
- protected void forceSeedValue(long seed) {
- reg = seed;
+ protected void forceSeedValue(long seed1, long seed2) {
+ lfsr1 = seed1;
+ lfsr2 = seed2;
nida = computeAliasFromGenerator();
}
@@ -65,40 +66,39 @@
*/
protected void loadSeed(NodeID nid) {
this.nid = nid;
- byte[] id = this.nid.getContents();
+ byte[] val = this.nid.getContents();
- reg = ((id[0] & 0xff) << 40)
- | ((id[1] & 0xff) << 32)
- | ((id[2] & 0xff) << 24)
- | ((id[3] & 0xff) << 16)
- | ((id[4] & 0xff) << 8)
- | ((id[5] & 0xff) << 0);
+ lfsr1 = (((long)val[0]) << 16) | (((long)val[1]) << 8) | ((long)val[2]);
+ lfsr2 = (((long)val[3]) << 16) | (((long)val[4]) << 8) | ((long)val[5]);
}
/**
* Advance the sequence generator by one step.
*/
- protected void stepGenerator() {
-
- // See H G Kuehn, CACM 8/1961
- reg = ( (512+1)*reg + 0x1B0CA37A4BA9L)
- & 0xFFFFFFFFFFFFL;
- }
+ protected void stepGenerator() {
+ // step the PRNG
+ // First, form 2^9*val
+ long temp1 = ((lfsr1<<9) | ((lfsr2>>15)&0x1FF)) & 0xFFFFFF;
+ long temp2 = (lfsr2<<9) & 0xFFFFFF;
+
+ // add
+ lfsr2 = lfsr2 + temp2 + 0x7A4BA9l;
+ lfsr1 = lfsr1 + temp1 + 0x1B0CA3l;
+
+ // carry
+ lfsr1 = (lfsr1 & 0xFFFFFF) | ((lfsr2&0xFF000000) >> 24);
+ lfsr2 = lfsr2 & 0xFFFFFF;
+ }
/**
* Reduce the current generator value to an alias value.
*/
protected int computeAliasFromGenerator() {
-
- int s1 = (int)reg&0xFFFFFF;
- int s2 = (int)(reg>>12)&0xFFFFFF;
- int s3 = (int)(reg>>24)&0xFFFFFF;
- int s4 = (int)(reg>>36)&0xFFFFFF;
-
- return s1^s2^s3^s4;
+ return (int)(lfsr1 ^ lfsr2 ^ (lfsr1>>12) ^ (lfsr2>>12) ) & 0xFFF;
}
// Generator state register
- long reg = 0xFFFFL; // unsigned
+ long lfsr1 = 0; // long to act as unsigned
+ long lfsr2 = 0;
}
Modified: trunk/prototypes/java/src/org/openlcb/can/NIDaAlgorithm.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/can/NIDaAlgorithm.java 2010-07-03 16:02:40 UTC (rev 519)
+++ trunk/prototypes/java/src/org/openlcb/can/NIDaAlgorithm.java 2010-07-03 16:30:16 UTC (rev 520)
@@ -8,7 +8,7 @@
* to and from the actual interface.
* It also requires subclassing to provide a timer function.
*
- * @author Bob Jacobsen Copyright 2009
+ * @author Bob Jacobsen Copyright 2009, 2010
* @version $Revision$
*/
public class NIDaAlgorithm {
@@ -20,9 +20,9 @@
public OpenLcbCanFrame nextFrame() {
OpenLcbCanFrame f;
- if (index<6)
+ if (index<4)
f = OpenLcbCanFrame.makeCimFrame(nida.getNIDa(), 0, 0);
- else if (index == 6) {
+ else if (index == 4) {
f = OpenLcbCanFrame.makeRimFrame(nida.getNIDa(), nid);
complete = true;
} else {
@@ -46,15 +46,16 @@
// CIM or RIM with our alias
if (complete) {
// complete, so alias is ours;: send RIM
- index = 6;
+ index = 4;
} else {
// reset and start over
index = 0;
cancelTimer();
- } nida.nextAlias();
+ }
+ nida.nextAlias();
} else {
// other frame with our alias: send RIM
- index = 6;
+ index = 4;
}
}
Modified: trunk/prototypes/java/test/org/openlcb/can/NIDaAlgorithmTest.java
===================================================================
--- trunk/prototypes/java/test/org/openlcb/can/NIDaAlgorithmTest.java 2010-07-03 16:02:40 UTC (rev 519)
+++ trunk/prototypes/java/test/org/openlcb/can/NIDaAlgorithmTest.java 2010-07-03 16:30:16 UTC (rev 520)
@@ -18,6 +18,16 @@
Assert.assertTrue("not complete", !alg.isComplete());
}
+ public void testAliasSequence() {
+ NIDa alg = new NIDa(new NodeID(new byte[]{2,3,4,5,6,7}));
+
+ Assert.assertEquals("proper 1st alias", (long)0x285, alg.getNIDa());
+
+ alg.nextAlias();
+
+ Assert.assertEquals("proper 2nd alias", (long)0x6BA, alg.getNIDa());
+ }
+
public void testFirst() {
OpenLcbCanFrame f = alg.nextFrame();
Assert.assertTrue("not complete", !alg.isComplete());
@@ -27,7 +37,7 @@
}
- public void testSeventh() {
+ public void testFifth() {
OpenLcbCanFrame f;
Assert.assertTrue("not complete", !alg.isComplete());
@@ -36,8 +46,6 @@
Assert.assertTrue((f = alg.nextFrame()).isCIM());
Assert.assertTrue((f = alg.nextFrame()).isCIM());
Assert.assertTrue((f = alg.nextFrame()).isCIM());
- Assert.assertTrue((f = alg.nextFrame()).isCIM());
- Assert.assertTrue((f = alg.nextFrame()).isCIM());
Assert.assertTrue((f = alg.nextFrame()).isRIM());
Assert.assertTrue("complete", alg.isComplete());
@@ -49,7 +57,7 @@
OpenLcbCanFrame f;
Assert.assertTrue("not complete", !alg.isComplete());
- // seventh frame is RIM
+ // fifth frame is RIM
Assert.assertTrue((f = alg.nextFrame()).isCIM());
alg.processFrame(OpenLcbCanFrame.makeCimFrame(1, 0, 0));
Assert.assertTrue((f = alg.nextFrame()).isCIM());
@@ -58,10 +66,6 @@
alg.processFrame(OpenLcbCanFrame.makeCimFrame(1, 0, 0));
Assert.assertTrue((f = alg.nextFrame()).isCIM());
alg.processFrame(OpenLcbCanFrame.makeCimFrame(1, 0, 0));
- Assert.assertTrue((f = alg.nextFrame()).isCIM());
- alg.processFrame(OpenLcbCanFrame.makeCimFrame(1, 0, 0));
- Assert.assertTrue((f = alg.nextFrame()).isCIM());
- alg.processFrame(OpenLcbCanFrame.makeCimFrame(1, 0, 0));
Assert.assertTrue((f = alg.nextFrame()).isRIM());
alg.processFrame(OpenLcbCanFrame.makeCimFrame(1, 0, 0));
@@ -80,13 +84,11 @@
// inject conflict
alg.processFrame(OpenLcbCanFrame.makeCimFrame(f.getNodeIDa(), 0, 0));
- // seventh frame after now is RIM
+ // fifth frame after now is RIM
Assert.assertTrue((f = alg.nextFrame()).isCIM());
Assert.assertTrue((f = alg.nextFrame()).isCIM());
Assert.assertTrue((f = alg.nextFrame()).isCIM());
Assert.assertTrue((f = alg.nextFrame()).isCIM());
- Assert.assertTrue((f = alg.nextFrame()).isCIM());
- Assert.assertTrue((f = alg.nextFrame()).isCIM());
Assert.assertTrue((f = alg.nextFrame()).isRIM());
Assert.assertTrue("complete", alg.isComplete());
@@ -98,13 +100,11 @@
OpenLcbCanFrame f;
Assert.assertTrue("not complete", !alg.isComplete());
- // seventh frame after start is RIM
+ // fifth frame after start is RIM
Assert.assertTrue((f = alg.nextFrame()).isCIM());
Assert.assertTrue((f = alg.nextFrame()).isCIM());
Assert.assertTrue((f = alg.nextFrame()).isCIM());
Assert.assertTrue((f = alg.nextFrame()).isCIM());
- Assert.assertTrue((f = alg.nextFrame()).isCIM());
- Assert.assertTrue((f = alg.nextFrame()).isCIM());
Assert.assertTrue((f = alg.nextFrame()).isRIM());
int nida = f.getNodeIDa();
Assert.assertTrue("complete", alg.isComplete());
@@ -133,7 +133,7 @@
f = alg1.nextFrame();
f = alg1.nextFrame();
- int expectedCount = 7;
+ int expectedCount = 5;
int count = sequentialRunner(new NIDaAlgorithm[]{alg1, alg2}, expectedCount);
debug("tSS2 converges "+count);
@@ -149,9 +149,9 @@
public void testSequentialCollisionStart2() {
// this is getting identical aliases by tricking the seed computation.
NubNIDaAlgorithm alg1 = new NubNIDaAlgorithm(new NodeID(new byte[]{10,11,12,13,14,15}));
- alg1.forceSeedValue(0xAC01L);
+ alg1.forceSeedValue(0xAC01L,0L);
NubNIDaAlgorithm alg2 = new NubNIDaAlgorithm(new NodeID(new byte[]{11,10,12,13,14,15}));
- alg2.forceSeedValue(0xAC01L);
+ alg2.forceSeedValue(0xAC01L,0L);
OpenLcbCanFrame f;
// check to make sure seeds are same; condition of test, not test itself
@@ -162,7 +162,7 @@
f = alg1.nextFrame();
f = alg1.nextFrame();
- int expectedCount = 7;
+ int expectedCount = 5;
int count = sequentialRunner(new NIDaAlgorithm[]{alg1, alg2}, 2*expectedCount);
debug("tSCS2 converges in "+count);
@@ -205,7 +205,7 @@
f = alg1.nextFrame();
f = alg1.nextFrame();
- int expectedCount = 7; // count cycles
+ int expectedCount = 5; // count cycles
int count = sequentialRunner(algs, 2*expectedCount);
debug("tSS10 converges "+count);
@@ -256,7 +256,7 @@
OpenLcbCanFrame f;
// run the startup
- int expectedCount = (6+1)*10; // count messages
+ int expectedCount = (4+1)*10; // count messages
int count = priorityRunner(algs, 2*expectedCount);
debug("tPS10 converges "+count);
@@ -301,7 +301,7 @@
// set to same seed
for (int i = 0; i<algs.length; i++)
- algs[i].forceSeedValue(0xAC01L);
+ algs[i].forceSeedValue(0xAC01L,0L);
// this group of checks is just to make sure seeds are same
// condition of test, not test itself
@@ -316,7 +316,7 @@
Assert.assertEquals("starting aliases same", alg1.getNIDa(), alg10.getNIDa());
// run the startup
- int expectedCount = 114; // messages (empirically determined, depends on NodeID bytes)
+ int expectedCount = 66; // messages (empirically determined, depends on NodeID bytes)
int count = priorityRunner(algs, 2*expectedCount);
debug("tPCS10 converges "+count);
@@ -361,7 +361,7 @@
// run the startup
- int expectedCount = 800; // messages (empirically determined, depends on NodeID bytes)
+ int expectedCount = 568; // messages (empirically determined, depends on NodeID bytes)
int count = priorityRunner(algs, 2*expectedCount);
debug("tPMNSN converges "+count);
@@ -449,12 +449,12 @@
// Local version of classes to allow forcing identical alias, state
class NubNIDaAlgorithm extends NIDaAlgorithm {
public NubNIDaAlgorithm(NodeID nid) { super(nid); this.nida = new NubNIDa(nid); }
- public void forceSeedValue(long seed) { ((NubNIDa)nida).forceSeedValue(seed); }
+ public void forceSeedValue(long seed1, long seed2) { ((NubNIDa)nida).forceSeedValue(seed1, seed2); }
public void forceAliasValue(int alias) { ((NubNIDa)nida).forceAliasValue(alias); }
}
class NubNIDa extends NIDa {
public NubNIDa(NodeID nid) { super(nid);}
- public void forceSeedValue(long seed) { super.forceSeedValue(seed); }
+ public void forceSeedValue(long seed1, long seed2 ) { super.forceSeedValue(seed1,seed2); }
public void forceAliasValue(int alias) { super.forceAliasValue(alias); }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jac...@us...> - 2010-07-03 16:30:23
|
Revision: 520
http://openlcb.svn.sourceforge.net/openlcb/?rev=520&view=rev
Author: jacobsen
Date: 2010-07-03 16:30:16 +0000 (Sat, 03 Jul 2010)
Log Message:
-----------
update to alg in C code
Modified Paths:
--------------
trunk/prototypes/java/src/org/openlcb/can/NIDa.java
trunk/prototypes/java/src/org/openlcb/can/NIDaAlgorithm.java
trunk/prototypes/java/test/org/openlcb/can/NIDaAlgorithmTest.java
Modified: trunk/prototypes/java/src/org/openlcb/can/NIDa.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/can/NIDa.java 2010-07-03 16:02:40 UTC (rev 519)
+++ trunk/prototypes/java/src/org/openlcb/can/NIDa.java 2010-07-03 16:30:16 UTC (rev 520)
@@ -9,7 +9,7 @@
* sending and receiving of CAN frames.
*
*
- * @author Bob Jacobsen Copyright 2009
+ * @author Bob Jacobsen Copyright 2009, 2010
* @version $Revision$
*/
public class NIDa {
@@ -43,8 +43,9 @@
* value. In the process, it updates the alias
* to the value implied by this seed.
*/
- protected void forceSeedValue(long seed) {
- reg = seed;
+ protected void forceSeedValue(long seed1, long seed2) {
+ lfsr1 = seed1;
+ lfsr2 = seed2;
nida = computeAliasFromGenerator();
}
@@ -65,40 +66,39 @@
*/
protected void loadSeed(NodeID nid) {
this.nid = nid;
- byte[] id = this.nid.getContents();
+ byte[] val = this.nid.getContents();
- reg = ((id[0] & 0xff) << 40)
- | ((id[1] & 0xff) << 32)
- | ((id[2] & 0xff) << 24)
- | ((id[3] & 0xff) << 16)
- | ((id[4] & 0xff) << 8)
- | ((id[5] & 0xff) << 0);
+ lfsr1 = (((long)val[0]) << 16) | (((long)val[1]) << 8) | ((long)val[2]);
+ lfsr2 = (((long)val[3]) << 16) | (((long)val[4]) << 8) | ((long)val[5]);
}
/**
* Advance the sequence generator by one step.
*/
- protected void stepGenerator() {
-
- // See H G Kuehn, CACM 8/1961
- reg = ( (512+1)*reg + 0x1B0CA37A4BA9L)
- & 0xFFFFFFFFFFFFL;
- }
+ protected void stepGenerator() {
+ // step the PRNG
+ // First, form 2^9*val
+ long temp1 = ((lfsr1<<9) | ((lfsr2>>15)&0x1FF)) & 0xFFFFFF;
+ long temp2 = (lfsr2<<9) & 0xFFFFFF;
+
+ // add
+ lfsr2 = lfsr2 + temp2 + 0x7A4BA9l;
+ lfsr1 = lfsr1 + temp1 + 0x1B0CA3l;
+
+ // carry
+ lfsr1 = (lfsr1 & 0xFFFFFF) | ((lfsr2&0xFF000000) >> 24);
+ lfsr2 = lfsr2 & 0xFFFFFF;
+ }
/**
* Reduce the current generator value to an alias value.
*/
protected int computeAliasFromGenerator() {
-
- int s1 = (int)reg&0xFFFFFF;
- int s2 = (int)(reg>>12)&0xFFFFFF;
- int s3 = (int)(reg>>24)&0xFFFFFF;
- int s4 = (int)(reg>>36)&0xFFFFFF;
-
- return s1^s2^s3^s4;
+ return (int)(lfsr1 ^ lfsr2 ^ (lfsr1>>12) ^ (lfsr2>>12) ) & 0xFFF;
}
// Generator state register
- long reg = 0xFFFFL; // unsigned
+ long lfsr1 = 0; // long to act as unsigned
+ long lfsr2 = 0;
}
Modified: trunk/prototypes/java/src/org/openlcb/can/NIDaAlgorithm.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/can/NIDaAlgorithm.java 2010-07-03 16:02:40 UTC (rev 519)
+++ trunk/prototypes/java/src/org/openlcb/can/NIDaAlgorithm.java 2010-07-03 16:30:16 UTC (rev 520)
@@ -8,7 +8,7 @@
* to and from the actual interface.
* It also requires subclassing to provide a timer function.
*
- * @author Bob Jacobsen Copyright 2009
+ * @author Bob Jacobsen Copyright 2009, 2010
* @version $Revision$
*/
public class NIDaAlgorithm {
@@ -20,9 +20,9 @@
public OpenLcbCanFrame nextFrame() {
OpenLcbCanFrame f;
- if (index<6)
+ if (index<4)
f = OpenLcbCanFrame.makeCimFrame(nida.getNIDa(), 0, 0);
- else if (index == 6) {
+ else if (index == 4) {
f = OpenLcbCanFrame.makeRimFrame(nida.getNIDa(), nid);
complete = true;
} else {
@@ -46,15 +46,16 @@
// CIM or RIM with our alias
if (complete) {
// complete, so alias is ours;: send RIM
- index = 6;
+ index = 4;
} else {
// reset and start over
index = 0;
cancelTimer();
- } nida.nextAlias();
+ }
+ nida.nextAlias();
} else {
// other frame with our alias: send RIM
- index = 6;
+ index = 4;
}
}
Modified: trunk/prototypes/java/test/org/openlcb/can/NIDaAlgorithmTest.java
===================================================================
--- trunk/prototypes/java/test/org/openlcb/can/NIDaAlgorithmTest.java 2010-07-03 16:02:40 UTC (rev 519)
+++ trunk/prototypes/java/test/org/openlcb/can/NIDaAlgorithmTest.java 2010-07-03 16:30:16 UTC (rev 520)
@@ -18,6 +18,16 @@
Assert.assertTrue("not complete", !alg.isComplete());
}
+ public void testAliasSequence() {
+ NIDa alg = new NIDa(new NodeID(new byte[]{2,3,4,5,6,7}));
+
+ Assert.assertEquals("proper 1st alias", (long)0x285, alg.getNIDa());
+
+ alg.nextAlias();
+
+ Assert.assertEquals("proper 2nd alias", (long)0x6BA, alg.getNIDa());
+ }
+
public void testFirst() {
OpenLcbCanFrame f = alg.nextFrame();
Assert.assertTrue("not complete", !alg.isComplete());
@@ -27,7 +37,7 @@
}
- public void testSeventh() {
+ public void testFifth() {
OpenLcbCanFrame f;
Assert.assertTrue("not complete", !alg.isComplete());
@@ -36,8 +46,6 @@
Assert.assertTrue((f = alg.nextFrame()).isCIM());
Assert.assertTrue((f = alg.nextFrame()).isCIM());
Assert.assertTrue((f = alg.nextFrame()).isCIM());
- Assert.assertTrue((f = alg.nextFrame()).isCIM());
- Assert.assertTrue((f = alg.nextFrame()).isCIM());
Assert.assertTrue((f = alg.nextFrame()).isRIM());
Assert.assertTrue("complete", alg.isComplete());
@@ -49,7 +57,7 @@
OpenLcbCanFrame f;
Assert.assertTrue("not complete", !alg.isComplete());
- // seventh frame is RIM
+ // fifth frame is RIM
Assert.assertTrue((f = alg.nextFrame()).isCIM());
alg.processFrame(OpenLcbCanFrame.makeCimFrame(1, 0, 0));
Assert.assertTrue((f = alg.nextFrame()).isCIM());
@@ -58,10 +66,6 @@
alg.processFrame(OpenLcbCanFrame.makeCimFrame(1, 0, 0));
Assert.assertTrue((f = alg.nextFrame()).isCIM());
alg.processFrame(OpenLcbCanFrame.makeCimFrame(1, 0, 0));
- Assert.assertTrue((f = alg.nextFrame()).isCIM());
- alg.processFrame(OpenLcbCanFrame.makeCimFrame(1, 0, 0));
- Assert.assertTrue((f = alg.nextFrame()).isCIM());
- alg.processFrame(OpenLcbCanFrame.makeCimFrame(1, 0, 0));
Assert.assertTrue((f = alg.nextFrame()).isRIM());
alg.processFrame(OpenLcbCanFrame.makeCimFrame(1, 0, 0));
@@ -80,13 +84,11 @@
// inject conflict
alg.processFrame(OpenLcbCanFrame.makeCimFrame(f.getNodeIDa(), 0, 0));
- // seventh frame after now is RIM
+ // fifth frame after now is RIM
Assert.assertTrue((f = alg.nextFrame()).isCIM());
Assert.assertTrue((f = alg.nextFrame()).isCIM());
Assert.assertTrue((f = alg.nextFrame()).isCIM());
Assert.assertTrue((f = alg.nextFrame()).isCIM());
- Assert.assertTrue((f = alg.nextFrame()).isCIM());
- Assert.assertTrue((f = alg.nextFrame()).isCIM());
Assert.assertTrue((f = alg.nextFrame()).isRIM());
Assert.assertTrue("complete", alg.isComplete());
@@ -98,13 +100,11 @@
OpenLcbCanFrame f;
Assert.assertTrue("not complete", !alg.isComplete());
- // seventh frame after start is RIM
+ // fifth frame after start is RIM
Assert.assertTrue((f = alg.nextFrame()).isCIM());
Assert.assertTrue((f = alg.nextFrame()).isCIM());
Assert.assertTrue((f = alg.nextFrame()).isCIM());
Assert.assertTrue((f = alg.nextFrame()).isCIM());
- Assert.assertTrue((f = alg.nextFrame()).isCIM());
- Assert.assertTrue((f = alg.nextFrame()).isCIM());
Assert.assertTrue((f = alg.nextFrame()).isRIM());
int nida = f.getNodeIDa();
Assert.assertTrue("complete", alg.isComplete());
@@ -133,7 +133,7 @@
f = alg1.nextFrame();
f = alg1.nextFrame();
- int expectedCount = 7;
+ int expectedCount = 5;
int count = sequentialRunner(new NIDaAlgorithm[]{alg1, alg2}, expectedCount);
debug("tSS2 converges "+count);
@@ -149,9 +149,9 @@
public void testSequentialCollisionStart2() {
// this is getting identical aliases by tricking the seed computation.
NubNIDaAlgorithm alg1 = new NubNIDaAlgorithm(new NodeID(new byte[]{10,11,12,13,14,15}));
- alg1.forceSeedValue(0xAC01L);
+ alg1.forceSeedValue(0xAC01L,0L);
NubNIDaAlgorithm alg2 = new NubNIDaAlgorithm(new NodeID(new byte[]{11,10,12,13,14,15}));
- alg2.forceSeedValue(0xAC01L);
+ alg2.forceSeedValue(0xAC01L,0L);
OpenLcbCanFrame f;
// check to make sure seeds are same; condition of test, not test itself
@@ -162,7 +162,7 @@
f = alg1.nextFrame();
f = alg1.nextFrame();
- int expectedCount = 7;
+ int expectedCount = 5;
int count = sequentialRunner(new NIDaAlgorithm[]{alg1, alg2}, 2*expectedCount);
debug("tSCS2 converges in "+count);
@@ -205,7 +205,7 @@
f = alg1.nextFrame();
f = alg1.nextFrame();
- int expectedCount = 7; // count cycles
+ int expectedCount = 5; // count cycles
int count = sequentialRunner(algs, 2*expectedCount);
debug("tSS10 converges "+count);
@@ -256,7 +256,7 @@
OpenLcbCanFrame f;
// run the startup
- int expectedCount = (6+1)*10; // count messages
+ int expectedCount = (4+1)*10; // count messages
int count = priorityRunner(algs, 2*expectedCount);
debug("tPS10 converges "+count);
@@ -301,7 +301,7 @@
// set to same seed
for (int i = 0; i<algs.length; i++)
- algs[i].forceSeedValue(0xAC01L);
+ algs[i].forceSeedValue(0xAC01L,0L);
// this group of checks is just to make sure seeds are same
// condition of test, not test itself
@@ -316,7 +316,7 @@
Assert.assertEquals("starting aliases same", alg1.getNIDa(), alg10.getNIDa());
// run the startup
- int expectedCount = 114; // messages (empirically determined, depends on NodeID bytes)
+ int expectedCount = 66; // messages (empirically determined, depends on NodeID bytes)
int count = priorityRunner(algs, 2*expectedCount);
debug("tPCS10 converges "+count);
@@ -361,7 +361,7 @@
// run the startup
- int expectedCount = 800; // messages (empirically determined, depends on NodeID bytes)
+ int expectedCount = 568; // messages (empirically determined, depends on NodeID bytes)
int count = priorityRunner(algs, 2*expectedCount);
debug("tPMNSN converges "+count);
@@ -449,12 +449,12 @@
// Local version of classes to allow forcing identical alias, state
class NubNIDaAlgorithm extends NIDaAlgorithm {
public NubNIDaAlgorithm(NodeID nid) { super(nid); this.nida = new NubNIDa(nid); }
- public void forceSeedValue(long seed) { ((NubNIDa)nida).forceSeedValue(seed); }
+ public void forceSeedValue(long seed1, long seed2) { ((NubNIDa)nida).forceSeedValue(seed1, seed2); }
public void forceAliasValue(int alias) { ((NubNIDa)nida).forceAliasValue(alias); }
}
class NubNIDa extends NIDa {
public NubNIDa(NodeID nid) { super(nid);}
- public void forceSeedValue(long seed) { super.forceSeedValue(seed); }
+ public void forceSeedValue(long seed1, long seed2 ) { super.forceSeedValue(seed1,seed2); }
public void forceAliasValue(int alias) { super.forceAliasValue(alias); }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jac...@us...> - 2010-07-03 23:05:17
|
Revision: 529
http://openlcb.svn.sourceforge.net/openlcb/?rev=529&view=rev
Author: jacobsen
Date: 2010-07-03 23:05:09 +0000 (Sat, 03 Jul 2010)
Log Message:
-----------
move to current MTIs
Modified Paths:
--------------
trunk/prototypes/java/manifest
trunk/prototypes/java/openlcb.jar
trunk/prototypes/java/src/org/openlcb/ConsumerIdentifiedMessage.java
trunk/prototypes/java/src/org/openlcb/DatagramAcknowledgedMessage.java
trunk/prototypes/java/src/org/openlcb/DatagramMessage.java
trunk/prototypes/java/src/org/openlcb/DatagramRejectedMessage.java
trunk/prototypes/java/src/org/openlcb/EventID.java
trunk/prototypes/java/src/org/openlcb/IdentifyConsumersMessage.java
trunk/prototypes/java/src/org/openlcb/IdentifyEventsMessage.java
trunk/prototypes/java/src/org/openlcb/IdentifyProducersMessage.java
trunk/prototypes/java/src/org/openlcb/InitializationCompleteMessage.java
trunk/prototypes/java/src/org/openlcb/LearnEventMessage.java
trunk/prototypes/java/src/org/openlcb/Message.java
trunk/prototypes/java/src/org/openlcb/MessageDecoder.java
trunk/prototypes/java/src/org/openlcb/NodeID.java
trunk/prototypes/java/src/org/openlcb/ProducerConsumerEventReportMessage.java
trunk/prototypes/java/src/org/openlcb/ProducerIdentifiedMessage.java
trunk/prototypes/java/src/org/openlcb/StreamDataCompleteMessage.java
trunk/prototypes/java/src/org/openlcb/StreamDataProceedMessage.java
trunk/prototypes/java/src/org/openlcb/StreamDataSendMessage.java
trunk/prototypes/java/src/org/openlcb/StreamInitReplyMessage.java
trunk/prototypes/java/src/org/openlcb/StreamInitRequestMessage.java
trunk/prototypes/java/src/org/openlcb/VerifiedNodeIDNumberMessage.java
trunk/prototypes/java/src/org/openlcb/VerifyNodeIDNumberMessage.java
trunk/prototypes/java/src/org/openlcb/can/CanFrame.java
trunk/prototypes/java/src/org/openlcb/can/NIDaAlgorithm.java
trunk/prototypes/java/src/org/openlcb/can/OpenLcbCanFrame.java
trunk/prototypes/java/src/org/openlcb/implementations/BlueGoldEngine.java
trunk/prototypes/java/test/org/openlcb/GatewayTest.java
trunk/prototypes/java/test/org/openlcb/MessageTest.java
trunk/prototypes/java/test/org/openlcb/NetTest.java
trunk/prototypes/java/test/org/openlcb/NodeIDTest.java
trunk/prototypes/java/test/org/openlcb/can/CanTest.java
trunk/prototypes/java/test/org/openlcb/can/NIDaAlgorithmTest.java
trunk/prototypes/java/test/org/openlcb/can/OpenLcbCanFrameTest.java
trunk/prototypes/java/test/org/openlcb/implementations/ScatterGatherTest.java
trunk/prototypes/java/test/tools/cansim/CanFrame.java
Added Paths:
-----------
trunk/prototypes/java/src/org/openlcb/OpenLcb.java
trunk/prototypes/java/src/org/openlcb/can/AliasMap.java
trunk/prototypes/java/src/org/openlcb/can/MessageBuilder.java
trunk/prototypes/java/src/org/openlcb/can/OpenLcbCan.java
trunk/prototypes/java/test/org/openlcb/can/AliasMapTest.java
Removed Paths:
-------------
trunk/prototypes/java/src/org/openlcb/LearnCancelMessage.java
trunk/prototypes/java/src/org/openlcb/LearnPendingMessage.java
trunk/prototypes/java/test/org/openlcb/LearnCancelMessageTest.java
trunk/prototypes/java/test/org/openlcb/LearnPendingMessageTest.java
Modified: trunk/prototypes/java/manifest
===================================================================
--- trunk/prototypes/java/manifest 2010-07-03 22:40:10 UTC (rev 528)
+++ trunk/prototypes/java/manifest 2010-07-03 23:05:09 UTC (rev 529)
@@ -4,9 +4,9 @@
Name: org.openlcb
Specification-Title: \xD2OpenLCB\xD3
-Specification-Version: \xD20.0\xD3
+Specification-Version: \xD20.2\xD3
Specification-Vendor: \xD2OpenLCB group"
Package-Title: \xD2openlcb\xD3
-Package-Version: \xD20.0\xD3
+Package-Version: \xD20.2\xD3
Package-Vendor: \xD2OpenLCB group\xD3
Modified: trunk/prototypes/java/openlcb.jar
===================================================================
(Binary files differ)
Modified: trunk/prototypes/java/src/org/openlcb/ConsumerIdentifiedMessage.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/ConsumerIdentifiedMessage.java 2010-07-03 22:40:10 UTC (rev 528)
+++ trunk/prototypes/java/src/org/openlcb/ConsumerIdentifiedMessage.java 2010-07-03 23:05:09 UTC (rev 529)
@@ -43,4 +43,6 @@
return getSourceNodeID().toString()
+" Consumer identified for "+eventID.toString();
}
+
+ public int getMTI() { return MTI_CONSUMER_IDENTIFIED; }
}
Modified: trunk/prototypes/java/src/org/openlcb/DatagramAcknowledgedMessage.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/DatagramAcknowledgedMessage.java 2010-07-03 22:40:10 UTC (rev 528)
+++ trunk/prototypes/java/src/org/openlcb/DatagramAcknowledgedMessage.java 2010-07-03 23:05:09 UTC (rev 529)
@@ -23,4 +23,6 @@
public void applyTo(MessageDecoder decoder, Connection sender) {
decoder.handleDatagramAcknowledged(this, sender);
}
+
+ public int getMTI() { return MTI_DATAGRAM_RCV_OK; }
}
Modified: trunk/prototypes/java/src/org/openlcb/DatagramMessage.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/DatagramMessage.java 2010-07-03 22:40:10 UTC (rev 528)
+++ trunk/prototypes/java/src/org/openlcb/DatagramMessage.java 2010-07-03 23:05:09 UTC (rev 529)
@@ -23,4 +23,6 @@
public void applyTo(MessageDecoder decoder, Connection sender) {
decoder.handleDatagram(this, sender);
}
+
+ public int getMTI() { return MTI_DATAGRAM; }
}
Modified: trunk/prototypes/java/src/org/openlcb/DatagramRejectedMessage.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/DatagramRejectedMessage.java 2010-07-03 22:40:10 UTC (rev 528)
+++ trunk/prototypes/java/src/org/openlcb/DatagramRejectedMessage.java 2010-07-03 23:05:09 UTC (rev 529)
@@ -23,4 +23,6 @@
public void applyTo(MessageDecoder decoder, Connection sender) {
decoder.handleDatagramRejected(this, sender);
}
+
+ public int getMTI() { return MTI_DATAGRAM_REJECTED; }
}
Modified: trunk/prototypes/java/src/org/openlcb/EventID.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/EventID.java 2010-07-03 22:40:10 UTC (rev 528)
+++ trunk/prototypes/java/src/org/openlcb/EventID.java 2010-07-03 23:05:09 UTC (rev 529)
@@ -33,6 +33,14 @@
byte[] contents;
+ public byte[] getContents() {
+ // copy to ensure immutable
+ byte[] retval = new byte[BYTECOUNT];
+ for (int i =0; i < BYTECOUNT; i++)
+ retval[i] = contents[i];
+ return retval;
+ }
+
public boolean equals(Object o){
// try to cast, else not equal
try {
Modified: trunk/prototypes/java/src/org/openlcb/IdentifyConsumersMessage.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/IdentifyConsumersMessage.java 2010-07-03 22:40:10 UTC (rev 528)
+++ trunk/prototypes/java/src/org/openlcb/IdentifyConsumersMessage.java 2010-07-03 23:05:09 UTC (rev 529)
@@ -43,4 +43,6 @@
return getSourceNodeID().toString()
+" Identify Consumers with "+eventID.toString();
}
+
+ public int getMTI() { return MTI_IDENTIFY_CONSUMERS; }
}
Modified: trunk/prototypes/java/src/org/openlcb/IdentifyEventsMessage.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/IdentifyEventsMessage.java 2010-07-03 22:40:10 UTC (rev 528)
+++ trunk/prototypes/java/src/org/openlcb/IdentifyEventsMessage.java 2010-07-03 23:05:09 UTC (rev 529)
@@ -27,4 +27,6 @@
return getSourceNodeID().toString()
+" Identify Events ";
}
+
+ public int getMTI() { return MTI_IDENTIFY_EVENTS; }
}
Modified: trunk/prototypes/java/src/org/openlcb/IdentifyProducersMessage.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/IdentifyProducersMessage.java 2010-07-03 22:40:10 UTC (rev 528)
+++ trunk/prototypes/java/src/org/openlcb/IdentifyProducersMessage.java 2010-07-03 23:05:09 UTC (rev 529)
@@ -43,4 +43,6 @@
return getSourceNodeID().toString()
+" Identify Producers with "+eventID.toString();
}
+
+ public int getMTI() { return MTI_IDENTIFY_PRODUCERS; }
}
Modified: trunk/prototypes/java/src/org/openlcb/InitializationCompleteMessage.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/InitializationCompleteMessage.java 2010-07-03 22:40:10 UTC (rev 528)
+++ trunk/prototypes/java/src/org/openlcb/InitializationCompleteMessage.java 2010-07-03 23:05:09 UTC (rev 529)
@@ -27,4 +27,6 @@
return getSourceNodeID().toString()
+" Initialization Complete";
}
+
+ public int getMTI() { return MTI_INITIALIZATION_COMPLETE; }
}
Deleted: trunk/prototypes/java/src/org/openlcb/LearnCancelMessage.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/LearnCancelMessage.java 2010-07-03 22:40:10 UTC (rev 528)
+++ trunk/prototypes/java/src/org/openlcb/LearnCancelMessage.java 2010-07-03 23:05:09 UTC (rev 529)
@@ -1,32 +0,0 @@
-package org.openlcb;
-
-/**
- * Learn Cancel message implementation
- *
- * @author Bob Jacobsen Copyright 2009
- * @version $Revision$
- */
-public class LearnCancelMessage extends Message {
-
- public LearnCancelMessage(NodeID source) {
- super(source);
- }
-
- /**
- * Implement message-type-specific
- * processing when this message
- * is received by a node.
- *<p>
- * Default is to do nothing.
- */
- @Override
- public void applyTo(MessageDecoder decoder, Connection sender) {
- decoder.handleLearnCancel(this, sender);
- }
-
- public String toString() {
- return getSourceNodeID().toString()
- +" LearnCancel";
- }
-
-}
Modified: trunk/prototypes/java/src/org/openlcb/LearnEventMessage.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/LearnEventMessage.java 2010-07-03 22:40:10 UTC (rev 528)
+++ trunk/prototypes/java/src/org/openlcb/LearnEventMessage.java 2010-07-03 23:05:09 UTC (rev 529)
@@ -43,4 +43,5 @@
+" LearnEvent "+eventID.toString();
}
+ public int getMTI() { return MTI_LEARN_EVENT; }
}
Deleted: trunk/prototypes/java/src/org/openlcb/LearnPendingMessage.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/LearnPendingMessage.java 2010-07-03 22:40:10 UTC (rev 528)
+++ trunk/prototypes/java/src/org/openlcb/LearnPendingMessage.java 2010-07-03 23:05:09 UTC (rev 529)
@@ -1,32 +0,0 @@
-package org.openlcb;
-
-/**
- * Learn Pending message implementation
- *
- * @author Bob Jacobsen Copyright 2009
- * @version $Revision$
- */
-public class LearnPendingMessage extends Message {
-
- public LearnPendingMessage(NodeID source) {
- super(source);
- }
-
- /**
- * Implement message-type-specific
- * processing when this message
- * is received by a node.
- *<p>
- * Default is to do nothing.
- */
- @Override
- public void applyTo(MessageDecoder decoder, Connection sender) {
- decoder.handleLearnPending(this, sender);
- }
-
- public String toString() {
- return getSourceNodeID().toString()
- +" LearnPending";
- }
-
-}
Modified: trunk/prototypes/java/src/org/openlcb/Message.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/Message.java 2010-07-03 22:40:10 UTC (rev 528)
+++ trunk/prototypes/java/src/org/openlcb/Message.java 2010-07-03 23:05:09 UTC (rev 529)
@@ -12,7 +12,7 @@
* @version $Revision$
* @see MessageDecoder
*/
-public class Message {
+abstract public class Message implements OpenLcb {
public Message(NodeID source) {
sourceNodeID = source;
@@ -40,11 +40,15 @@
* same type and content
*/
public boolean equals(Object o) {
- if (! this.getClass().equals(o.getClass()))
+ if (! (o instanceof Message))
return false;
Message msg = (Message) o;
+ if (this.getMTI() != msg.getMTI())
+ return false;
if (! this.sourceNodeID.equals(msg.sourceNodeID))
return false;
return true;
}
+
+ abstract public int getMTI();
}
Modified: trunk/prototypes/java/src/org/openlcb/MessageDecoder.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/MessageDecoder.java 2010-07-03 22:40:10 UTC (rev 528)
+++ trunk/prototypes/java/src/org/openlcb/MessageDecoder.java 2010-07-03 23:05:09 UTC (rev 529)
@@ -90,18 +90,6 @@
defaultHandler(msg, sender);
}
/**
- * Handle "Learn Pending" message
- */
- public void handleLearnPending(LearnPendingMessage msg, Connection sender){
- defaultHandler(msg, sender);
- }
- /**
- * Handle "Learn Cancel" message
- */
- public void handleLearnCancel(LearnCancelMessage msg, Connection sender){
- defaultHandler(msg, sender);
- }
- /**
* Handle "Learn Event" message
*/
public void handleLearnEvent(LearnEventMessage msg, Connection sender){
Modified: trunk/prototypes/java/src/org/openlcb/NodeID.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/NodeID.java 2010-07-03 22:40:10 UTC (rev 528)
+++ trunk/prototypes/java/src/org/openlcb/NodeID.java 2010-07-03 23:05:09 UTC (rev 529)
@@ -18,7 +18,7 @@
public NodeID(byte[] contents) {
if (contents == null)
throw new java.lang.IllegalArgumentException("null argument invalid");
- if (contents.length != BYTECOUNT)
+ if (contents.length < BYTECOUNT)
throw new java.lang.IllegalArgumentException("Wrong NodeID length: "+contents.length);
this.contents = new byte[BYTECOUNT];
for (int i = 0; i < BYTECOUNT; i++)
Added: trunk/prototypes/java/src/org/openlcb/OpenLcb.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/OpenLcb.java (rev 0)
+++ trunk/prototypes/java/src/org/openlcb/OpenLcb.java 2010-07-03 23:05:09 UTC (rev 529)
@@ -0,0 +1,38 @@
+package org.openlcb;
+
+public interface OpenLcb {
+
+
+ /**
+ * MTI definitions for OpenLCB.
+ */
+
+ static final int MTI_INITIALIZATION_COMPLETE = 0x3080;
+
+ static final int MTI_VERIFY_NID = 0x30A4;
+ static final int MTI_VERIFIED_NID = 0x30B0; // also 30B2
+
+ static final int MTI_IDENTIFY_CONSUMERS = 0x3242;
+ static final int MTI_IDENTIFY_CONSUMERS_RANGE = 0x3252;
+ static final int MTI_CONSUMER_IDENTIFIED = 0x3263;
+
+ static final int MTI_IDENTIFY_PRODUCERS = 0x3282;
+ static final int MTI_IDENTIFY_PRODUCERS_RANGE = 0x3292;
+ static final int MTI_PRODUCER_IDENTIFIED = 0x32A3;
+
+ static final int MTI_IDENTIFY_EVENTS = 0x32B0; // also 32B2
+
+ static final int MTI_LEARN_EVENT = 0x32C2;
+ static final int MTI_PC_EVENT_REPORT = 0x32D2;
+
+ static final int MTI_DATAGRAM = 0x3404;
+ static final int MTI_DATAGRAM_RCV_OK = 0x34C4;
+ static final int MTI_DATAGRAM_REJECTED = 0x34D4;
+
+ static final int MTI_STREAM_INIT_REQUEST = 0x34E4;
+ static final int MTI_STREAM_INIT_REPLY = 0x34F4;
+ static final int MTI_STREAM_DATA_SEND = 0x3694;
+ static final int MTI_STREAM_DATA_PROCEED = 0x36A4;
+ static final int MTI_STREAM_DATA_COMPLETE = 0x36B4;
+
+}
\ No newline at end of file
Property changes on: trunk/prototypes/java/src/org/openlcb/OpenLcb.java
___________________________________________________________________
Added: svn:keywords
+ Id Revision
Added: svn:eol-style
+ native
Modified: trunk/prototypes/java/src/org/openlcb/ProducerConsumerEventReportMessage.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/ProducerConsumerEventReportMessage.java 2010-07-03 22:40:10 UTC (rev 528)
+++ trunk/prototypes/java/src/org/openlcb/ProducerConsumerEventReportMessage.java 2010-07-03 23:05:09 UTC (rev 529)
@@ -43,4 +43,5 @@
+" Producer/Consumer Event Report with "+eventID.toString();
}
+ public int getMTI() { return MTI_PC_EVENT_REPORT; }
}
Modified: trunk/prototypes/java/src/org/openlcb/ProducerIdentifiedMessage.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/ProducerIdentifiedMessage.java 2010-07-03 22:40:10 UTC (rev 528)
+++ trunk/prototypes/java/src/org/openlcb/ProducerIdentifiedMessage.java 2010-07-03 23:05:09 UTC (rev 529)
@@ -44,4 +44,6 @@
return getSourceNodeID().toString()
+" Producer identified for "+eventID.toString();
}
+
+ public int getMTI() { return MTI_PRODUCER_IDENTIFIED; }
}
Modified: trunk/prototypes/java/src/org/openlcb/StreamDataCompleteMessage.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/StreamDataCompleteMessage.java 2010-07-03 22:40:10 UTC (rev 528)
+++ trunk/prototypes/java/src/org/openlcb/StreamDataCompleteMessage.java 2010-07-03 23:05:09 UTC (rev 529)
@@ -43,4 +43,6 @@
return getSourceNodeID().toString()
+" StreamDataComplete "+dest.toString();
}
+
+ public int getMTI() { return MTI_STREAM_DATA_COMPLETE; }
}
Modified: trunk/prototypes/java/src/org/openlcb/StreamDataProceedMessage.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/StreamDataProceedMessage.java 2010-07-03 22:40:10 UTC (rev 528)
+++ trunk/prototypes/java/src/org/openlcb/StreamDataProceedMessage.java 2010-07-03 23:05:09 UTC (rev 529)
@@ -45,4 +45,6 @@
return getSourceNodeID().toString()
+" StreamDataProceed "+dest.toString();
}
+
+ public int getMTI() { return MTI_STREAM_DATA_PROCEED; }
}
Modified: trunk/prototypes/java/src/org/openlcb/StreamDataSendMessage.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/StreamDataSendMessage.java 2010-07-03 22:40:10 UTC (rev 528)
+++ trunk/prototypes/java/src/org/openlcb/StreamDataSendMessage.java 2010-07-03 23:05:09 UTC (rev 529)
@@ -46,4 +46,6 @@
return getSourceNodeID().toString()
+" StreamDataSend "+dest.toString();
}
+
+ public int getMTI() { return MTI_STREAM_DATA_SEND; }
}
Modified: trunk/prototypes/java/src/org/openlcb/StreamInitReplyMessage.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/StreamInitReplyMessage.java 2010-07-03 22:40:10 UTC (rev 528)
+++ trunk/prototypes/java/src/org/openlcb/StreamInitReplyMessage.java 2010-07-03 23:05:09 UTC (rev 529)
@@ -54,4 +54,6 @@
+" DSID "+destStreamID
+" bsize "+bufferSize;
}
+
+ public int getMTI() { return MTI_STREAM_INIT_REPLY; }
}
Modified: trunk/prototypes/java/src/org/openlcb/StreamInitRequestMessage.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/StreamInitRequestMessage.java 2010-07-03 22:40:10 UTC (rev 528)
+++ trunk/prototypes/java/src/org/openlcb/StreamInitRequestMessage.java 2010-07-03 23:05:09 UTC (rev 529)
@@ -50,4 +50,6 @@
+" SSID "+sourceStreamID
+" bsize "+bufferSize;
}
+
+ public int getMTI() { return MTI_STREAM_INIT_REQUEST; }
}
Modified: trunk/prototypes/java/src/org/openlcb/VerifiedNodeIDNumberMessage.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/VerifiedNodeIDNumberMessage.java 2010-07-03 22:40:10 UTC (rev 528)
+++ trunk/prototypes/java/src/org/openlcb/VerifiedNodeIDNumberMessage.java 2010-07-03 23:05:09 UTC (rev 529)
@@ -27,4 +27,6 @@
return getSourceNodeID().toString()
+" Verified Node ID Number";
}
+
+ public int getMTI() { return MTI_VERIFIED_NID; }
}
Modified: trunk/prototypes/java/src/org/openlcb/VerifyNodeIDNumberMessage.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/VerifyNodeIDNumberMessage.java 2010-07-03 22:40:10 UTC (rev 528)
+++ trunk/prototypes/java/src/org/openlcb/VerifyNodeIDNumberMessage.java 2010-07-03 23:05:09 UTC (rev 529)
@@ -3,7 +3,7 @@
/**
* Verify Node ID Number message implementation
*
- * @author Bob Jacobsen Copyright 2009
+ * @author Bob Jacobsen Copyright 2009, 2010
* @version $Revision$
*/
public class VerifyNodeIDNumberMessage extends Message {
@@ -28,4 +28,6 @@
return getSourceNodeID().toString()
+" PVerify Node ID number";
}
+
+ public int getMTI() { return MTI_VERIFY_NID; }
}
Added: trunk/prototypes/java/src/org/openlcb/can/AliasMap.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/can/AliasMap.java (rev 0)
+++ trunk/prototypes/java/src/org/openlcb/can/AliasMap.java 2010-07-03 23:05:09 UTC (rev 529)
@@ -0,0 +1,38 @@
+package org.openlcb.can;
+
+import org.openlcb.*;
+
+/**
+ * Maintains a 2-way map between nodes and CAN node ID aliases.
+ *<p>
+ * Input is CAN frames, looking for VerifyNodeID frames.
+ *
+ * @author Bob Jacobsen Copyright 2010
+ * @version $Revision$
+ */
+public class AliasMap {
+
+ public AliasMap() {
+ }
+ java.util.HashMap<NodeID, Integer> iMap = new java.util.HashMap<NodeID, Integer>();
+ java.util.HashMap<Integer, NodeID> nMap = new java.util.HashMap<Integer, NodeID>();
+
+ public void processFrame(OpenLcbCanFrame f) {
+ // check type
+ if (f.isInitializationComplete()) {
+ Integer alias = new Integer(f.getSourceAlias());
+ NodeID nid = f.getNodeID();
+ nMap.put(alias, nid);
+ iMap.put(nid, alias);
+ }
+ }
+
+ public NodeID getNodeID(int alias) {
+ return nMap.get(new Integer(alias));
+ }
+ public int getAlias(NodeID nid) {
+ Integer r = iMap.get(nid);
+ if (r == null) return -1;
+ else return r.intValue();
+ }
+ }
Property changes on: trunk/prototypes/java/src/org/openlcb/can/AliasMap.java
___________________________________________________________________
Added: svn:keywords
+ Id Revision
Added: svn:eol-style
+ native
Modified: trunk/prototypes/java/src/org/openlcb/can/CanFrame.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/can/CanFrame.java 2010-07-03 22:40:10 UTC (rev 528)
+++ trunk/prototypes/java/src/org/openlcb/can/CanFrame.java 2010-07-03 23:05:09 UTC (rev 529)
@@ -16,6 +16,6 @@
public interface CanFrame {
- public long getHeader();
+ public int getHeader();
}
Added: trunk/prototypes/java/src/org/openlcb/can/MessageBuilder.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/can/MessageBuilder.java (rev 0)
+++ trunk/prototypes/java/src/org/openlcb/can/MessageBuilder.java 2010-07-03 23:05:09 UTC (rev 529)
@@ -0,0 +1,127 @@
+package org.openlcb.can;
+
+import org.openlcb.*;
+
+import java.util.List;
+
+/**
+ * Converts CAN frame messages to regular messages
+ * and vice-versa.
+ *<p>
+ * In general, the connection is one-to-one, but
+ * sometimes (datagram expansion) more than one will be
+ * created.
+ * The List is always returned, even if empty.
+ *
+ * @author Bob Jacobsen Copyright 2010
+ * @version $Revision$
+ */
+public class MessageBuilder {
+
+ public MessageBuilder(AliasMap map) {
+ this.map = map;
+ }
+
+ AliasMap map;
+
+ public List<Message> processFrame(OpenLcbCanFrame f) {
+ List<Message> retlist = new java.util.ArrayList<Message>();
+ NodeID source = map.getNodeID(f.getSourceAlias());
+
+ // check for special cases first
+
+ // then decode standard MTIs
+ switch(1) {
+
+ case OpenLcb.MTI_INITIALIZATION_COMPLETE:
+ retlist.add(new InitializationCompleteMessage(source));
+ break;
+
+ case OpenLcb.MTI_VERIFY_NID:
+ retlist.add(new VerifyNodeIDNumberMessage(source));
+ break;
+ case OpenLcb.MTI_VERIFIED_NID: // also 30B2
+ retlist.add(new VerifiedNodeIDNumberMessage(source));
+ break;
+
+ case OpenLcb.MTI_IDENTIFY_CONSUMERS:
+ retlist.add(new IdentifyConsumersMessage(source, f.getEventID()));
+ break;
+
+ case OpenLcb.MTI_CONSUMER_IDENTIFIED:
+ retlist.add(new ConsumerIdentifiedMessage(source, f.getEventID()));
+ break;
+
+ case OpenLcb.MTI_IDENTIFY_PRODUCERS:
+ retlist.add(new IdentifyProducersMessage(source, f.getEventID()));
+ break;
+
+ case OpenLcb.MTI_PRODUCER_IDENTIFIED:
+ retlist.add(new ProducerIdentifiedMessage(source, f.getEventID()));
+ break;
+
+ case OpenLcb.MTI_IDENTIFY_EVENTS: // also 32B2
+ retlist.add(new IdentifyEventsMessage(source));
+ break;
+
+ case OpenLcb.MTI_LEARN_EVENT:
+ retlist.add(new LearnEventMessage(source, f.getEventID()));
+ break;
+ case OpenLcb.MTI_PC_EVENT_REPORT:
+ retlist.add(new ProducerConsumerEventReportMessage(source, f.getEventID()));
+ break;
+
+ case OpenLcb.MTI_DATAGRAM:
+ case OpenLcb.MTI_DATAGRAM_RCV_OK:
+ case OpenLcb.MTI_DATAGRAM_REJECTED:
+
+ case OpenLcb.MTI_STREAM_INIT_REQUEST:
+ case OpenLcb.MTI_STREAM_INIT_REPLY:
+ case OpenLcb.MTI_STREAM_DATA_SEND:
+ case OpenLcb.MTI_STREAM_DATA_PROCEED:
+ case OpenLcb.MTI_STREAM_DATA_COMPLETE:
+
+ //case OpenLcb.MTI_IDENTIFY_CONSUMERS_RANGE:
+ //case OpenLcb.MTI_IDENTIFY_PRODUCERS_RANGE:
+
+ default:
+ // this is an error
+ }
+ return retlist;
+ }
+
+ public List<OpenLcbCanFrame> processMessage(Message f) {
+ List<OpenLcbCanFrame> retlist = new java.util.ArrayList<OpenLcbCanFrame>();
+ switch(f.getMTI()) {
+
+ case OpenLcb.MTI_INITIALIZATION_COMPLETE:
+
+ case OpenLcb.MTI_VERIFY_NID:
+ case OpenLcb.MTI_VERIFIED_NID: // also 30B2
+
+ case OpenLcb.MTI_IDENTIFY_CONSUMERS:
+ case OpenLcb.MTI_IDENTIFY_CONSUMERS_RANGE:
+ case OpenLcb.MTI_CONSUMER_IDENTIFIED:
+
+ case OpenLcb.MTI_IDENTIFY_PRODUCERS:
+ case OpenLcb.MTI_IDENTIFY_PRODUCERS_RANGE:
+ case OpenLcb.MTI_PRODUCER_IDENTIFIED:
+
+ case OpenLcb.MTI_IDENTIFY_EVENTS: // also 32B2
+
+ case OpenLcb.MTI_LEARN_EVENT:
+ case OpenLcb.MTI_PC_EVENT_REPORT:
+
+ case OpenLcb.MTI_DATAGRAM:
+ case OpenLcb.MTI_DATAGRAM_RCV_OK:
+ case OpenLcb.MTI_DATAGRAM_REJECTED:
+
+ case OpenLcb.MTI_STREAM_INIT_REQUEST:
+ case OpenLcb.MTI_STREAM_INIT_REPLY:
+ case OpenLcb.MTI_STREAM_DATA_SEND:
+ case OpenLcb.MTI_STREAM_DATA_PROCEED:
+ case OpenLcb.MTI_STREAM_DATA_COMPLETE:
+ }
+ return retlist;
+ }
+ }
Property changes on: trunk/prototypes/java/src/org/openlcb/can/MessageBuilder.java
___________________________________________________________________
Added: svn:keywords
+ Id Revision
Added: svn:eol-style
+ native
Modified: trunk/prototypes/java/src/org/openlcb/can/NIDaAlgorithm.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/can/NIDaAlgorithm.java 2010-07-03 22:40:10 UTC (rev 528)
+++ trunk/prototypes/java/src/org/openlcb/can/NIDaAlgorithm.java 2010-07-03 23:05:09 UTC (rev 529)
@@ -20,10 +20,12 @@
public OpenLcbCanFrame nextFrame() {
OpenLcbCanFrame f;
- if (index<4)
- f = OpenLcbCanFrame.makeCimFrame(nida.getNIDa(), 0, 0);
- else if (index == 4) {
- f = OpenLcbCanFrame.makeRimFrame(nida.getNIDa(), nid);
+ if (index<4) {
+ f = new OpenLcbCanFrame(nida.getNIDa());
+ f.setCIM(index, 0, nida.getNIDa());
+ } else if (index == 4) {
+ f = new OpenLcbCanFrame(nida.getNIDa());
+ f.setRIM(nida.getNIDa());
complete = true;
} else {
// send nothing
@@ -41,7 +43,7 @@
// System.out.println("process "+Integer.toHexString(f.getNodeIDa())
// +" vs our "+Integer.toHexString(nida.getNIDa()));
- if (f.getNodeIDa() != nida.getNIDa()) return; // not us
+ if (f.getSourceAlias() != nida.getNIDa()) return; // not us
if (f.isCIM() || f.isRIM()) {
// CIM or RIM with our alias
if (complete) {
Added: trunk/prototypes/java/src/org/openlcb/can/OpenLcbCan.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/can/OpenLcbCan.java (rev 0)
+++ trunk/prototypes/java/src/org/openlcb/can/OpenLcbCan.java 2010-07-03 23:05:09 UTC (rev 529)
@@ -0,0 +1,44 @@
+package org.openlcb.can;
+
+public interface OpenLcbCan {
+
+ /**
+ ...
[truncated message content] |
|
From: <jac...@us...> - 2010-07-03 23:05:17
|
Revision: 529
http://openlcb.svn.sourceforge.net/openlcb/?rev=529&view=rev
Author: jacobsen
Date: 2010-07-03 23:05:09 +0000 (Sat, 03 Jul 2010)
Log Message:
-----------
move to current MTIs
Modified Paths:
--------------
trunk/prototypes/java/manifest
trunk/prototypes/java/openlcb.jar
trunk/prototypes/java/src/org/openlcb/ConsumerIdentifiedMessage.java
trunk/prototypes/java/src/org/openlcb/DatagramAcknowledgedMessage.java
trunk/prototypes/java/src/org/openlcb/DatagramMessage.java
trunk/prototypes/java/src/org/openlcb/DatagramRejectedMessage.java
trunk/prototypes/java/src/org/openlcb/EventID.java
trunk/prototypes/java/src/org/openlcb/IdentifyConsumersMessage.java
trunk/prototypes/java/src/org/openlcb/IdentifyEventsMessage.java
trunk/prototypes/java/src/org/openlcb/IdentifyProducersMessage.java
trunk/prototypes/java/src/org/openlcb/InitializationCompleteMessage.java
trunk/prototypes/java/src/org/openlcb/LearnEventMessage.java
trunk/prototypes/java/src/org/openlcb/Message.java
trunk/prototypes/java/src/org/openlcb/MessageDecoder.java
trunk/prototypes/java/src/org/openlcb/NodeID.java
trunk/prototypes/java/src/org/openlcb/ProducerConsumerEventReportMessage.java
trunk/prototypes/java/src/org/openlcb/ProducerIdentifiedMessage.java
trunk/prototypes/java/src/org/openlcb/StreamDataCompleteMessage.java
trunk/prototypes/java/src/org/openlcb/StreamDataProceedMessage.java
trunk/prototypes/java/src/org/openlcb/StreamDataSendMessage.java
trunk/prototypes/java/src/org/openlcb/StreamInitReplyMessage.java
trunk/prototypes/java/src/org/openlcb/StreamInitRequestMessage.java
trunk/prototypes/java/src/org/openlcb/VerifiedNodeIDNumberMessage.java
trunk/prototypes/java/src/org/openlcb/VerifyNodeIDNumberMessage.java
trunk/prototypes/java/src/org/openlcb/can/CanFrame.java
trunk/prototypes/java/src/org/openlcb/can/NIDaAlgorithm.java
trunk/prototypes/java/src/org/openlcb/can/OpenLcbCanFrame.java
trunk/prototypes/java/src/org/openlcb/implementations/BlueGoldEngine.java
trunk/prototypes/java/test/org/openlcb/GatewayTest.java
trunk/prototypes/java/test/org/openlcb/MessageTest.java
trunk/prototypes/java/test/org/openlcb/NetTest.java
trunk/prototypes/java/test/org/openlcb/NodeIDTest.java
trunk/prototypes/java/test/org/openlcb/can/CanTest.java
trunk/prototypes/java/test/org/openlcb/can/NIDaAlgorithmTest.java
trunk/prototypes/java/test/org/openlcb/can/OpenLcbCanFrameTest.java
trunk/prototypes/java/test/org/openlcb/implementations/ScatterGatherTest.java
trunk/prototypes/java/test/tools/cansim/CanFrame.java
Added Paths:
-----------
trunk/prototypes/java/src/org/openlcb/OpenLcb.java
trunk/prototypes/java/src/org/openlcb/can/AliasMap.java
trunk/prototypes/java/src/org/openlcb/can/MessageBuilder.java
trunk/prototypes/java/src/org/openlcb/can/OpenLcbCan.java
trunk/prototypes/java/test/org/openlcb/can/AliasMapTest.java
Removed Paths:
-------------
trunk/prototypes/java/src/org/openlcb/LearnCancelMessage.java
trunk/prototypes/java/src/org/openlcb/LearnPendingMessage.java
trunk/prototypes/java/test/org/openlcb/LearnCancelMessageTest.java
trunk/prototypes/java/test/org/openlcb/LearnPendingMessageTest.java
Modified: trunk/prototypes/java/manifest
===================================================================
--- trunk/prototypes/java/manifest 2010-07-03 22:40:10 UTC (rev 528)
+++ trunk/prototypes/java/manifest 2010-07-03 23:05:09 UTC (rev 529)
@@ -4,9 +4,9 @@
Name: org.openlcb
Specification-Title: \xD2OpenLCB\xD3
-Specification-Version: \xD20.0\xD3
+Specification-Version: \xD20.2\xD3
Specification-Vendor: \xD2OpenLCB group"
Package-Title: \xD2openlcb\xD3
-Package-Version: \xD20.0\xD3
+Package-Version: \xD20.2\xD3
Package-Vendor: \xD2OpenLCB group\xD3
Modified: trunk/prototypes/java/openlcb.jar
===================================================================
(Binary files differ)
Modified: trunk/prototypes/java/src/org/openlcb/ConsumerIdentifiedMessage.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/ConsumerIdentifiedMessage.java 2010-07-03 22:40:10 UTC (rev 528)
+++ trunk/prototypes/java/src/org/openlcb/ConsumerIdentifiedMessage.java 2010-07-03 23:05:09 UTC (rev 529)
@@ -43,4 +43,6 @@
return getSourceNodeID().toString()
+" Consumer identified for "+eventID.toString();
}
+
+ public int getMTI() { return MTI_CONSUMER_IDENTIFIED; }
}
Modified: trunk/prototypes/java/src/org/openlcb/DatagramAcknowledgedMessage.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/DatagramAcknowledgedMessage.java 2010-07-03 22:40:10 UTC (rev 528)
+++ trunk/prototypes/java/src/org/openlcb/DatagramAcknowledgedMessage.java 2010-07-03 23:05:09 UTC (rev 529)
@@ -23,4 +23,6 @@
public void applyTo(MessageDecoder decoder, Connection sender) {
decoder.handleDatagramAcknowledged(this, sender);
}
+
+ public int getMTI() { return MTI_DATAGRAM_RCV_OK; }
}
Modified: trunk/prototypes/java/src/org/openlcb/DatagramMessage.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/DatagramMessage.java 2010-07-03 22:40:10 UTC (rev 528)
+++ trunk/prototypes/java/src/org/openlcb/DatagramMessage.java 2010-07-03 23:05:09 UTC (rev 529)
@@ -23,4 +23,6 @@
public void applyTo(MessageDecoder decoder, Connection sender) {
decoder.handleDatagram(this, sender);
}
+
+ public int getMTI() { return MTI_DATAGRAM; }
}
Modified: trunk/prototypes/java/src/org/openlcb/DatagramRejectedMessage.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/DatagramRejectedMessage.java 2010-07-03 22:40:10 UTC (rev 528)
+++ trunk/prototypes/java/src/org/openlcb/DatagramRejectedMessage.java 2010-07-03 23:05:09 UTC (rev 529)
@@ -23,4 +23,6 @@
public void applyTo(MessageDecoder decoder, Connection sender) {
decoder.handleDatagramRejected(this, sender);
}
+
+ public int getMTI() { return MTI_DATAGRAM_REJECTED; }
}
Modified: trunk/prototypes/java/src/org/openlcb/EventID.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/EventID.java 2010-07-03 22:40:10 UTC (rev 528)
+++ trunk/prototypes/java/src/org/openlcb/EventID.java 2010-07-03 23:05:09 UTC (rev 529)
@@ -33,6 +33,14 @@
byte[] contents;
+ public byte[] getContents() {
+ // copy to ensure immutable
+ byte[] retval = new byte[BYTECOUNT];
+ for (int i =0; i < BYTECOUNT; i++)
+ retval[i] = contents[i];
+ return retval;
+ }
+
public boolean equals(Object o){
// try to cast, else not equal
try {
Modified: trunk/prototypes/java/src/org/openlcb/IdentifyConsumersMessage.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/IdentifyConsumersMessage.java 2010-07-03 22:40:10 UTC (rev 528)
+++ trunk/prototypes/java/src/org/openlcb/IdentifyConsumersMessage.java 2010-07-03 23:05:09 UTC (rev 529)
@@ -43,4 +43,6 @@
return getSourceNodeID().toString()
+" Identify Consumers with "+eventID.toString();
}
+
+ public int getMTI() { return MTI_IDENTIFY_CONSUMERS; }
}
Modified: trunk/prototypes/java/src/org/openlcb/IdentifyEventsMessage.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/IdentifyEventsMessage.java 2010-07-03 22:40:10 UTC (rev 528)
+++ trunk/prototypes/java/src/org/openlcb/IdentifyEventsMessage.java 2010-07-03 23:05:09 UTC (rev 529)
@@ -27,4 +27,6 @@
return getSourceNodeID().toString()
+" Identify Events ";
}
+
+ public int getMTI() { return MTI_IDENTIFY_EVENTS; }
}
Modified: trunk/prototypes/java/src/org/openlcb/IdentifyProducersMessage.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/IdentifyProducersMessage.java 2010-07-03 22:40:10 UTC (rev 528)
+++ trunk/prototypes/java/src/org/openlcb/IdentifyProducersMessage.java 2010-07-03 23:05:09 UTC (rev 529)
@@ -43,4 +43,6 @@
return getSourceNodeID().toString()
+" Identify Producers with "+eventID.toString();
}
+
+ public int getMTI() { return MTI_IDENTIFY_PRODUCERS; }
}
Modified: trunk/prototypes/java/src/org/openlcb/InitializationCompleteMessage.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/InitializationCompleteMessage.java 2010-07-03 22:40:10 UTC (rev 528)
+++ trunk/prototypes/java/src/org/openlcb/InitializationCompleteMessage.java 2010-07-03 23:05:09 UTC (rev 529)
@@ -27,4 +27,6 @@
return getSourceNodeID().toString()
+" Initialization Complete";
}
+
+ public int getMTI() { return MTI_INITIALIZATION_COMPLETE; }
}
Deleted: trunk/prototypes/java/src/org/openlcb/LearnCancelMessage.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/LearnCancelMessage.java 2010-07-03 22:40:10 UTC (rev 528)
+++ trunk/prototypes/java/src/org/openlcb/LearnCancelMessage.java 2010-07-03 23:05:09 UTC (rev 529)
@@ -1,32 +0,0 @@
-package org.openlcb;
-
-/**
- * Learn Cancel message implementation
- *
- * @author Bob Jacobsen Copyright 2009
- * @version $Revision$
- */
-public class LearnCancelMessage extends Message {
-
- public LearnCancelMessage(NodeID source) {
- super(source);
- }
-
- /**
- * Implement message-type-specific
- * processing when this message
- * is received by a node.
- *<p>
- * Default is to do nothing.
- */
- @Override
- public void applyTo(MessageDecoder decoder, Connection sender) {
- decoder.handleLearnCancel(this, sender);
- }
-
- public String toString() {
- return getSourceNodeID().toString()
- +" LearnCancel";
- }
-
-}
Modified: trunk/prototypes/java/src/org/openlcb/LearnEventMessage.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/LearnEventMessage.java 2010-07-03 22:40:10 UTC (rev 528)
+++ trunk/prototypes/java/src/org/openlcb/LearnEventMessage.java 2010-07-03 23:05:09 UTC (rev 529)
@@ -43,4 +43,5 @@
+" LearnEvent "+eventID.toString();
}
+ public int getMTI() { return MTI_LEARN_EVENT; }
}
Deleted: trunk/prototypes/java/src/org/openlcb/LearnPendingMessage.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/LearnPendingMessage.java 2010-07-03 22:40:10 UTC (rev 528)
+++ trunk/prototypes/java/src/org/openlcb/LearnPendingMessage.java 2010-07-03 23:05:09 UTC (rev 529)
@@ -1,32 +0,0 @@
-package org.openlcb;
-
-/**
- * Learn Pending message implementation
- *
- * @author Bob Jacobsen Copyright 2009
- * @version $Revision$
- */
-public class LearnPendingMessage extends Message {
-
- public LearnPendingMessage(NodeID source) {
- super(source);
- }
-
- /**
- * Implement message-type-specific
- * processing when this message
- * is received by a node.
- *<p>
- * Default is to do nothing.
- */
- @Override
- public void applyTo(MessageDecoder decoder, Connection sender) {
- decoder.handleLearnPending(this, sender);
- }
-
- public String toString() {
- return getSourceNodeID().toString()
- +" LearnPending";
- }
-
-}
Modified: trunk/prototypes/java/src/org/openlcb/Message.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/Message.java 2010-07-03 22:40:10 UTC (rev 528)
+++ trunk/prototypes/java/src/org/openlcb/Message.java 2010-07-03 23:05:09 UTC (rev 529)
@@ -12,7 +12,7 @@
* @version $Revision$
* @see MessageDecoder
*/
-public class Message {
+abstract public class Message implements OpenLcb {
public Message(NodeID source) {
sourceNodeID = source;
@@ -40,11 +40,15 @@
* same type and content
*/
public boolean equals(Object o) {
- if (! this.getClass().equals(o.getClass()))
+ if (! (o instanceof Message))
return false;
Message msg = (Message) o;
+ if (this.getMTI() != msg.getMTI())
+ return false;
if (! this.sourceNodeID.equals(msg.sourceNodeID))
return false;
return true;
}
+
+ abstract public int getMTI();
}
Modified: trunk/prototypes/java/src/org/openlcb/MessageDecoder.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/MessageDecoder.java 2010-07-03 22:40:10 UTC (rev 528)
+++ trunk/prototypes/java/src/org/openlcb/MessageDecoder.java 2010-07-03 23:05:09 UTC (rev 529)
@@ -90,18 +90,6 @@
defaultHandler(msg, sender);
}
/**
- * Handle "Learn Pending" message
- */
- public void handleLearnPending(LearnPendingMessage msg, Connection sender){
- defaultHandler(msg, sender);
- }
- /**
- * Handle "Learn Cancel" message
- */
- public void handleLearnCancel(LearnCancelMessage msg, Connection sender){
- defaultHandler(msg, sender);
- }
- /**
* Handle "Learn Event" message
*/
public void handleLearnEvent(LearnEventMessage msg, Connection sender){
Modified: trunk/prototypes/java/src/org/openlcb/NodeID.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/NodeID.java 2010-07-03 22:40:10 UTC (rev 528)
+++ trunk/prototypes/java/src/org/openlcb/NodeID.java 2010-07-03 23:05:09 UTC (rev 529)
@@ -18,7 +18,7 @@
public NodeID(byte[] contents) {
if (contents == null)
throw new java.lang.IllegalArgumentException("null argument invalid");
- if (contents.length != BYTECOUNT)
+ if (contents.length < BYTECOUNT)
throw new java.lang.IllegalArgumentException("Wrong NodeID length: "+contents.length);
this.contents = new byte[BYTECOUNT];
for (int i = 0; i < BYTECOUNT; i++)
Added: trunk/prototypes/java/src/org/openlcb/OpenLcb.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/OpenLcb.java (rev 0)
+++ trunk/prototypes/java/src/org/openlcb/OpenLcb.java 2010-07-03 23:05:09 UTC (rev 529)
@@ -0,0 +1,38 @@
+package org.openlcb;
+
+public interface OpenLcb {
+
+
+ /**
+ * MTI definitions for OpenLCB.
+ */
+
+ static final int MTI_INITIALIZATION_COMPLETE = 0x3080;
+
+ static final int MTI_VERIFY_NID = 0x30A4;
+ static final int MTI_VERIFIED_NID = 0x30B0; // also 30B2
+
+ static final int MTI_IDENTIFY_CONSUMERS = 0x3242;
+ static final int MTI_IDENTIFY_CONSUMERS_RANGE = 0x3252;
+ static final int MTI_CONSUMER_IDENTIFIED = 0x3263;
+
+ static final int MTI_IDENTIFY_PRODUCERS = 0x3282;
+ static final int MTI_IDENTIFY_PRODUCERS_RANGE = 0x3292;
+ static final int MTI_PRODUCER_IDENTIFIED = 0x32A3;
+
+ static final int MTI_IDENTIFY_EVENTS = 0x32B0; // also 32B2
+
+ static final int MTI_LEARN_EVENT = 0x32C2;
+ static final int MTI_PC_EVENT_REPORT = 0x32D2;
+
+ static final int MTI_DATAGRAM = 0x3404;
+ static final int MTI_DATAGRAM_RCV_OK = 0x34C4;
+ static final int MTI_DATAGRAM_REJECTED = 0x34D4;
+
+ static final int MTI_STREAM_INIT_REQUEST = 0x34E4;
+ static final int MTI_STREAM_INIT_REPLY = 0x34F4;
+ static final int MTI_STREAM_DATA_SEND = 0x3694;
+ static final int MTI_STREAM_DATA_PROCEED = 0x36A4;
+ static final int MTI_STREAM_DATA_COMPLETE = 0x36B4;
+
+}
\ No newline at end of file
Property changes on: trunk/prototypes/java/src/org/openlcb/OpenLcb.java
___________________________________________________________________
Added: svn:keywords
+ Id Revision
Added: svn:eol-style
+ native
Modified: trunk/prototypes/java/src/org/openlcb/ProducerConsumerEventReportMessage.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/ProducerConsumerEventReportMessage.java 2010-07-03 22:40:10 UTC (rev 528)
+++ trunk/prototypes/java/src/org/openlcb/ProducerConsumerEventReportMessage.java 2010-07-03 23:05:09 UTC (rev 529)
@@ -43,4 +43,5 @@
+" Producer/Consumer Event Report with "+eventID.toString();
}
+ public int getMTI() { return MTI_PC_EVENT_REPORT; }
}
Modified: trunk/prototypes/java/src/org/openlcb/ProducerIdentifiedMessage.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/ProducerIdentifiedMessage.java 2010-07-03 22:40:10 UTC (rev 528)
+++ trunk/prototypes/java/src/org/openlcb/ProducerIdentifiedMessage.java 2010-07-03 23:05:09 UTC (rev 529)
@@ -44,4 +44,6 @@
return getSourceNodeID().toString()
+" Producer identified for "+eventID.toString();
}
+
+ public int getMTI() { return MTI_PRODUCER_IDENTIFIED; }
}
Modified: trunk/prototypes/java/src/org/openlcb/StreamDataCompleteMessage.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/StreamDataCompleteMessage.java 2010-07-03 22:40:10 UTC (rev 528)
+++ trunk/prototypes/java/src/org/openlcb/StreamDataCompleteMessage.java 2010-07-03 23:05:09 UTC (rev 529)
@@ -43,4 +43,6 @@
return getSourceNodeID().toString()
+" StreamDataComplete "+dest.toString();
}
+
+ public int getMTI() { return MTI_STREAM_DATA_COMPLETE; }
}
Modified: trunk/prototypes/java/src/org/openlcb/StreamDataProceedMessage.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/StreamDataProceedMessage.java 2010-07-03 22:40:10 UTC (rev 528)
+++ trunk/prototypes/java/src/org/openlcb/StreamDataProceedMessage.java 2010-07-03 23:05:09 UTC (rev 529)
@@ -45,4 +45,6 @@
return getSourceNodeID().toString()
+" StreamDataProceed "+dest.toString();
}
+
+ public int getMTI() { return MTI_STREAM_DATA_PROCEED; }
}
Modified: trunk/prototypes/java/src/org/openlcb/StreamDataSendMessage.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/StreamDataSendMessage.java 2010-07-03 22:40:10 UTC (rev 528)
+++ trunk/prototypes/java/src/org/openlcb/StreamDataSendMessage.java 2010-07-03 23:05:09 UTC (rev 529)
@@ -46,4 +46,6 @@
return getSourceNodeID().toString()
+" StreamDataSend "+dest.toString();
}
+
+ public int getMTI() { return MTI_STREAM_DATA_SEND; }
}
Modified: trunk/prototypes/java/src/org/openlcb/StreamInitReplyMessage.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/StreamInitReplyMessage.java 2010-07-03 22:40:10 UTC (rev 528)
+++ trunk/prototypes/java/src/org/openlcb/StreamInitReplyMessage.java 2010-07-03 23:05:09 UTC (rev 529)
@@ -54,4 +54,6 @@
+" DSID "+destStreamID
+" bsize "+bufferSize;
}
+
+ public int getMTI() { return MTI_STREAM_INIT_REPLY; }
}
Modified: trunk/prototypes/java/src/org/openlcb/StreamInitRequestMessage.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/StreamInitRequestMessage.java 2010-07-03 22:40:10 UTC (rev 528)
+++ trunk/prototypes/java/src/org/openlcb/StreamInitRequestMessage.java 2010-07-03 23:05:09 UTC (rev 529)
@@ -50,4 +50,6 @@
+" SSID "+sourceStreamID
+" bsize "+bufferSize;
}
+
+ public int getMTI() { return MTI_STREAM_INIT_REQUEST; }
}
Modified: trunk/prototypes/java/src/org/openlcb/VerifiedNodeIDNumberMessage.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/VerifiedNodeIDNumberMessage.java 2010-07-03 22:40:10 UTC (rev 528)
+++ trunk/prototypes/java/src/org/openlcb/VerifiedNodeIDNumberMessage.java 2010-07-03 23:05:09 UTC (rev 529)
@@ -27,4 +27,6 @@
return getSourceNodeID().toString()
+" Verified Node ID Number";
}
+
+ public int getMTI() { return MTI_VERIFIED_NID; }
}
Modified: trunk/prototypes/java/src/org/openlcb/VerifyNodeIDNumberMessage.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/VerifyNodeIDNumberMessage.java 2010-07-03 22:40:10 UTC (rev 528)
+++ trunk/prototypes/java/src/org/openlcb/VerifyNodeIDNumberMessage.java 2010-07-03 23:05:09 UTC (rev 529)
@@ -3,7 +3,7 @@
/**
* Verify Node ID Number message implementation
*
- * @author Bob Jacobsen Copyright 2009
+ * @author Bob Jacobsen Copyright 2009, 2010
* @version $Revision$
*/
public class VerifyNodeIDNumberMessage extends Message {
@@ -28,4 +28,6 @@
return getSourceNodeID().toString()
+" PVerify Node ID number";
}
+
+ public int getMTI() { return MTI_VERIFY_NID; }
}
Added: trunk/prototypes/java/src/org/openlcb/can/AliasMap.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/can/AliasMap.java (rev 0)
+++ trunk/prototypes/java/src/org/openlcb/can/AliasMap.java 2010-07-03 23:05:09 UTC (rev 529)
@@ -0,0 +1,38 @@
+package org.openlcb.can;
+
+import org.openlcb.*;
+
+/**
+ * Maintains a 2-way map between nodes and CAN node ID aliases.
+ *<p>
+ * Input is CAN frames, looking for VerifyNodeID frames.
+ *
+ * @author Bob Jacobsen Copyright 2010
+ * @version $Revision$
+ */
+public class AliasMap {
+
+ public AliasMap() {
+ }
+ java.util.HashMap<NodeID, Integer> iMap = new java.util.HashMap<NodeID, Integer>();
+ java.util.HashMap<Integer, NodeID> nMap = new java.util.HashMap<Integer, NodeID>();
+
+ public void processFrame(OpenLcbCanFrame f) {
+ // check type
+ if (f.isInitializationComplete()) {
+ Integer alias = new Integer(f.getSourceAlias());
+ NodeID nid = f.getNodeID();
+ nMap.put(alias, nid);
+ iMap.put(nid, alias);
+ }
+ }
+
+ public NodeID getNodeID(int alias) {
+ return nMap.get(new Integer(alias));
+ }
+ public int getAlias(NodeID nid) {
+ Integer r = iMap.get(nid);
+ if (r == null) return -1;
+ else return r.intValue();
+ }
+ }
Property changes on: trunk/prototypes/java/src/org/openlcb/can/AliasMap.java
___________________________________________________________________
Added: svn:keywords
+ Id Revision
Added: svn:eol-style
+ native
Modified: trunk/prototypes/java/src/org/openlcb/can/CanFrame.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/can/CanFrame.java 2010-07-03 22:40:10 UTC (rev 528)
+++ trunk/prototypes/java/src/org/openlcb/can/CanFrame.java 2010-07-03 23:05:09 UTC (rev 529)
@@ -16,6 +16,6 @@
public interface CanFrame {
- public long getHeader();
+ public int getHeader();
}
Added: trunk/prototypes/java/src/org/openlcb/can/MessageBuilder.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/can/MessageBuilder.java (rev 0)
+++ trunk/prototypes/java/src/org/openlcb/can/MessageBuilder.java 2010-07-03 23:05:09 UTC (rev 529)
@@ -0,0 +1,127 @@
+package org.openlcb.can;
+
+import org.openlcb.*;
+
+import java.util.List;
+
+/**
+ * Converts CAN frame messages to regular messages
+ * and vice-versa.
+ *<p>
+ * In general, the connection is one-to-one, but
+ * sometimes (datagram expansion) more than one will be
+ * created.
+ * The List is always returned, even if empty.
+ *
+ * @author Bob Jacobsen Copyright 2010
+ * @version $Revision$
+ */
+public class MessageBuilder {
+
+ public MessageBuilder(AliasMap map) {
+ this.map = map;
+ }
+
+ AliasMap map;
+
+ public List<Message> processFrame(OpenLcbCanFrame f) {
+ List<Message> retlist = new java.util.ArrayList<Message>();
+ NodeID source = map.getNodeID(f.getSourceAlias());
+
+ // check for special cases first
+
+ // then decode standard MTIs
+ switch(1) {
+
+ case OpenLcb.MTI_INITIALIZATION_COMPLETE:
+ retlist.add(new InitializationCompleteMessage(source));
+ break;
+
+ case OpenLcb.MTI_VERIFY_NID:
+ retlist.add(new VerifyNodeIDNumberMessage(source));
+ break;
+ case OpenLcb.MTI_VERIFIED_NID: // also 30B2
+ retlist.add(new VerifiedNodeIDNumberMessage(source));
+ break;
+
+ case OpenLcb.MTI_IDENTIFY_CONSUMERS:
+ retlist.add(new IdentifyConsumersMessage(source, f.getEventID()));
+ break;
+
+ case OpenLcb.MTI_CONSUMER_IDENTIFIED:
+ retlist.add(new ConsumerIdentifiedMessage(source, f.getEventID()));
+ break;
+
+ case OpenLcb.MTI_IDENTIFY_PRODUCERS:
+ retlist.add(new IdentifyProducersMessage(source, f.getEventID()));
+ break;
+
+ case OpenLcb.MTI_PRODUCER_IDENTIFIED:
+ retlist.add(new ProducerIdentifiedMessage(source, f.getEventID()));
+ break;
+
+ case OpenLcb.MTI_IDENTIFY_EVENTS: // also 32B2
+ retlist.add(new IdentifyEventsMessage(source));
+ break;
+
+ case OpenLcb.MTI_LEARN_EVENT:
+ retlist.add(new LearnEventMessage(source, f.getEventID()));
+ break;
+ case OpenLcb.MTI_PC_EVENT_REPORT:
+ retlist.add(new ProducerConsumerEventReportMessage(source, f.getEventID()));
+ break;
+
+ case OpenLcb.MTI_DATAGRAM:
+ case OpenLcb.MTI_DATAGRAM_RCV_OK:
+ case OpenLcb.MTI_DATAGRAM_REJECTED:
+
+ case OpenLcb.MTI_STREAM_INIT_REQUEST:
+ case OpenLcb.MTI_STREAM_INIT_REPLY:
+ case OpenLcb.MTI_STREAM_DATA_SEND:
+ case OpenLcb.MTI_STREAM_DATA_PROCEED:
+ case OpenLcb.MTI_STREAM_DATA_COMPLETE:
+
+ //case OpenLcb.MTI_IDENTIFY_CONSUMERS_RANGE:
+ //case OpenLcb.MTI_IDENTIFY_PRODUCERS_RANGE:
+
+ default:
+ // this is an error
+ }
+ return retlist;
+ }
+
+ public List<OpenLcbCanFrame> processMessage(Message f) {
+ List<OpenLcbCanFrame> retlist = new java.util.ArrayList<OpenLcbCanFrame>();
+ switch(f.getMTI()) {
+
+ case OpenLcb.MTI_INITIALIZATION_COMPLETE:
+
+ case OpenLcb.MTI_VERIFY_NID:
+ case OpenLcb.MTI_VERIFIED_NID: // also 30B2
+
+ case OpenLcb.MTI_IDENTIFY_CONSUMERS:
+ case OpenLcb.MTI_IDENTIFY_CONSUMERS_RANGE:
+ case OpenLcb.MTI_CONSUMER_IDENTIFIED:
+
+ case OpenLcb.MTI_IDENTIFY_PRODUCERS:
+ case OpenLcb.MTI_IDENTIFY_PRODUCERS_RANGE:
+ case OpenLcb.MTI_PRODUCER_IDENTIFIED:
+
+ case OpenLcb.MTI_IDENTIFY_EVENTS: // also 32B2
+
+ case OpenLcb.MTI_LEARN_EVENT:
+ case OpenLcb.MTI_PC_EVENT_REPORT:
+
+ case OpenLcb.MTI_DATAGRAM:
+ case OpenLcb.MTI_DATAGRAM_RCV_OK:
+ case OpenLcb.MTI_DATAGRAM_REJECTED:
+
+ case OpenLcb.MTI_STREAM_INIT_REQUEST:
+ case OpenLcb.MTI_STREAM_INIT_REPLY:
+ case OpenLcb.MTI_STREAM_DATA_SEND:
+ case OpenLcb.MTI_STREAM_DATA_PROCEED:
+ case OpenLcb.MTI_STREAM_DATA_COMPLETE:
+ }
+ return retlist;
+ }
+ }
Property changes on: trunk/prototypes/java/src/org/openlcb/can/MessageBuilder.java
___________________________________________________________________
Added: svn:keywords
+ Id Revision
Added: svn:eol-style
+ native
Modified: trunk/prototypes/java/src/org/openlcb/can/NIDaAlgorithm.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/can/NIDaAlgorithm.java 2010-07-03 22:40:10 UTC (rev 528)
+++ trunk/prototypes/java/src/org/openlcb/can/NIDaAlgorithm.java 2010-07-03 23:05:09 UTC (rev 529)
@@ -20,10 +20,12 @@
public OpenLcbCanFrame nextFrame() {
OpenLcbCanFrame f;
- if (index<4)
- f = OpenLcbCanFrame.makeCimFrame(nida.getNIDa(), 0, 0);
- else if (index == 4) {
- f = OpenLcbCanFrame.makeRimFrame(nida.getNIDa(), nid);
+ if (index<4) {
+ f = new OpenLcbCanFrame(nida.getNIDa());
+ f.setCIM(index, 0, nida.getNIDa());
+ } else if (index == 4) {
+ f = new OpenLcbCanFrame(nida.getNIDa());
+ f.setRIM(nida.getNIDa());
complete = true;
} else {
// send nothing
@@ -41,7 +43,7 @@
// System.out.println("process "+Integer.toHexString(f.getNodeIDa())
// +" vs our "+Integer.toHexString(nida.getNIDa()));
- if (f.getNodeIDa() != nida.getNIDa()) return; // not us
+ if (f.getSourceAlias() != nida.getNIDa()) return; // not us
if (f.isCIM() || f.isRIM()) {
// CIM or RIM with our alias
if (complete) {
Added: trunk/prototypes/java/src/org/openlcb/can/OpenLcbCan.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/can/OpenLcbCan.java (rev 0)
+++ trunk/prototypes/java/src/org/openlcb/can/OpenLcbCan.java 2010-07-03 23:05:09 UTC (rev 529)
@@ -0,0 +1,44 @@
+package org.openlcb.can;
+
+public interface OpenLcbCan {
+
+ /**
+ ...
[truncated message content] |
|
From: <jac...@us...> - 2010-09-27 19:40:35
|
Revision: 960
http://openlcb.svn.sourceforge.net/openlcb/?rev=960&view=rev
Author: jacobsen
Date: 2010-09-27 19:40:29 +0000 (Mon, 27 Sep 2010)
Log Message:
-----------
standard frame form
Modified Paths:
--------------
trunk/prototypes/java/src/org/openlcb/can/CanFrame.java
trunk/prototypes/java/src/org/openlcb/can/OpenLcbCanFrame.java
trunk/prototypes/java/test/tools/cansim/CanFrame.java
Modified: trunk/prototypes/java/src/org/openlcb/can/CanFrame.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/can/CanFrame.java 2010-09-27 02:59:31 UTC (rev 959)
+++ trunk/prototypes/java/src/org/openlcb/can/CanFrame.java 2010-09-27 19:40:29 UTC (rev 960)
@@ -2,14 +2,11 @@
/**
- * Very, very simple interface for a CAN frame.
+ * Simple interface for a CAN frame.
*
- * This is mostly here to make it possible to (later)
- * move to an implementation class that's hardware specific.
- *
* Immutable once created.
*
- * @author Bob Jacobsen Copyright 2009
+ * @author Bob Jacobsen Copyright 2009, 2010
* @version $Revision$
*/
@@ -18,4 +15,11 @@
public int getHeader();
+ public boolean isExtended();
+
+ public boolean isRtr();
+
+ public int getNumDataElements();
+ public int getElement(int n);
+
}
Modified: trunk/prototypes/java/src/org/openlcb/can/OpenLcbCanFrame.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/can/OpenLcbCanFrame.java 2010-09-27 02:59:31 UTC (rev 959)
+++ trunk/prototypes/java/src/org/openlcb/can/OpenLcbCanFrame.java 2010-09-27 19:40:29 UTC (rev 960)
@@ -33,6 +33,13 @@
public int getHeader() { return id; }
+ public boolean isExtended() { return true; }
+
+ public boolean isRtr() { return false; }
+
+ public int getNumDataElements() { return length; }
+ public int getElement(int n) { return data[n]; }
+
// bit 1
static final int MASK_FRAME_TYPE = 0x08000000;
Modified: trunk/prototypes/java/test/tools/cansim/CanFrame.java
===================================================================
--- trunk/prototypes/java/test/tools/cansim/CanFrame.java 2010-09-27 02:59:31 UTC (rev 959)
+++ trunk/prototypes/java/test/tools/cansim/CanFrame.java 2010-09-27 19:40:29 UTC (rev 960)
@@ -31,6 +31,10 @@
}
public int getHeader() { return header; }
+ public boolean isExtended() { return true; }
+ public boolean isRtr() { return false; }
+ public int getNumDataElements() { return bytes.length; }
+ public int getElement(int n) { return bytes[n]; }
public boolean equals(Object other) {
// try to cast, else not equal
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jac...@us...> - 2010-09-27 19:41:19
|
Revision: 961
http://openlcb.svn.sourceforge.net/openlcb/?rev=961&view=rev
Author: jacobsen
Date: 2010-09-27 19:41:13 +0000 (Mon, 27 Sep 2010)
Log Message:
-----------
direct insert
Modified Paths:
--------------
trunk/prototypes/java/src/org/openlcb/can/AliasMap.java
trunk/prototypes/java/test/org/openlcb/can/AliasMapTest.java
Modified: trunk/prototypes/java/src/org/openlcb/can/AliasMap.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/can/AliasMap.java 2010-09-27 19:40:29 UTC (rev 960)
+++ trunk/prototypes/java/src/org/openlcb/can/AliasMap.java 2010-09-27 19:41:13 UTC (rev 961)
@@ -22,11 +22,15 @@
if (f.isInitializationComplete()) {
Integer alias = new Integer(f.getSourceAlias());
NodeID nid = f.getNodeID();
- nMap.put(alias, nid);
- iMap.put(nid, alias);
+ insert(alias, nid);
}
}
+ public void insert(int alias, NodeID nid) {
+ nMap.put(alias, nid);
+ iMap.put(nid, alias);
+ }
+
public NodeID getNodeID(int alias) {
return nMap.get(new Integer(alias));
}
Modified: trunk/prototypes/java/test/org/openlcb/can/AliasMapTest.java
===================================================================
--- trunk/prototypes/java/test/org/openlcb/can/AliasMapTest.java 2010-09-27 19:40:29 UTC (rev 960)
+++ trunk/prototypes/java/test/org/openlcb/can/AliasMapTest.java 2010-09-27 19:41:13 UTC (rev 961)
@@ -30,6 +30,13 @@
Assert.assertEquals("check NodeID", new NodeID(new byte[]{0,1,2,3,4,5}), map.getNodeID(0x123));
}
+ public void testAfterInsert() {
+ AliasMap map = new AliasMap();
+
+ map.insert(0x123, new NodeID(new byte[]{0,1,2,3,4,5}));
+ Assert.assertEquals("check NodeID", new NodeID(new byte[]{0,1,2,3,4,5}), map.getNodeID(0x123));
+ }
+
// from here down is testing infrastructure
public AliasMapTest(String s) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jac...@us...> - 2010-09-27 19:42:26
|
Revision: 962
http://openlcb.svn.sourceforge.net/openlcb/?rev=962&view=rev
Author: jacobsen
Date: 2010-09-27 19:42:20 +0000 (Mon, 27 Sep 2010)
Log Message:
-----------
improve internal structure
Modified Paths:
--------------
trunk/prototypes/java/README
trunk/prototypes/java/index.html
trunk/prototypes/java/src/org/openlcb/can/MessageBuilder.java
trunk/prototypes/java/src/org/openlcb/can/package.html
Modified: trunk/prototypes/java/README
===================================================================
--- trunk/prototypes/java/README 2010-09-27 19:41:13 UTC (rev 961)
+++ trunk/prototypes/java/README 2010-09-27 19:42:20 UTC (rev 962)
@@ -1,8 +1,6 @@
-List of tests and simulations you can run:
+See the index.hmtl file for more information.
-./runtest.csh NodeIDCollisions
- Various probability calculations
+This software is copyrighted and is subject to
+license. For more information, see
-ant run
- full test suite
-
+http://openlcb.org/Licensing.html
Modified: trunk/prototypes/java/index.html
===================================================================
--- trunk/prototypes/java/index.html 2010-09-27 19:41:13 UTC (rev 961)
+++ trunk/prototypes/java/index.html 2010-09-27 19:42:20 UTC (rev 962)
@@ -3,28 +3,34 @@
<HEAD>
<META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8">
<TITLE>OpenLCB: Java Prototypes Directory</TITLE>
- <META NAME="GENERATOR" CONTENT="OpenOffice.org 3.1 (Unix)">
+ <META NAME="GENERATOR" CONTENT="OpenOffice.org 3.2 (Unix)">
<META NAME="CREATED" CONTENT="0;0">
<META NAME="CHANGEDBY" CONTENT="Bob Jacobsen">
- <META NAME="CHANGED" CONTENT="20090819;5410400">
+ <META NAME="CHANGED" CONTENT="20100927;12330100">
<META NAME="Info 1" CONTENT="">
<META NAME="Info 2" CONTENT="">
<META NAME="Info 3" CONTENT="">
<META NAME="Info 4" CONTENT="">
+ <META NAME="CHANGEDBY" CONTENT="Bob Jacobsen">
<!-- $Id$ -->
+ <STYLE TYPE="text/css">
+ <!--
+ H2.ctl { font-family: "Lucida Sans" }
+ -->
+ </STYLE>
</HEAD>
<BODY LANG="en-US" DIR="LTR">
-<H1><IMG SRC="../../web/logo-ajs-dph.png" NAME="OpenLCB" ALIGN=RIGHT WIDTH=344 HEIGHT=142 BORDER=0>
-OpenLCB Proposal Java Prototypes Directory</H1>
+<H1><IMG SRC="../../web/logo-ajs-dph.png" NAME="OpenLCB" ALIGN=RIGHT WIDTH=344 HEIGHT=142 BORDER=0>OpenLCB
+Proposal Java Prototypes Directory</H1>
<P>This directory contains prototype implementation(s) in Java of the
proposed OpenLCB specification.
</P>
<P>These are primarily intended for testing proposed algorithms, not
as a first implementation for use.
</P>
-<a href="BlueGoldApplet.html">Applet demonstration</a>
-of Blue/Gold configuration.
-
+<P><A HREF="BlueGoldApplet.html">Applet demonstration</A> of
+Blue/Gold configuration.
+</P>
<P>Major subdirectories:</P>
<DL>
<DT><A HREF="src">src</A>
@@ -32,7 +38,7 @@
Contains OpenLCB source in the org.openlcb package, and source for
OpenLCB CAN wire protocol in the org.openlcb.can package.
</DD><DT>
- <A HREF="test">test</A>
+ <A HREF="test">test</A>
</DT><DD STYLE="margin-bottom: 0.5cm">
contains test code of several types in subpackages:
</DD></DL>
@@ -49,7 +55,7 @@
tested to make sure that P/C event reports are properly routed to
nodes needing them, event reports are not routed when not needed,
etc.</P>
-<H2>Building and Running</H2>
+<H2 CLASS="western">Building and Running</H2>
<P>Java 1.5 and Ant are the standard way to build and run this code.</P>
<PRE STYLE="margin-bottom: 0.5cm">ant run</PRE><P>
will do any needed compilations and run the complete set of tests
@@ -61,11 +67,14 @@
a good idea)</P>
<P>To create an openlcb.jar file containing the currently compiled
code,</P>
-<PRE>ant jar
-</PRE><P>
+<PRE STYLE="margin-bottom: 0.5cm">ant jar</PRE><P>
Note that you might want to do an “ant clean debug” first so only
the prototype classes are put in the jar, and the test code is
omitted.</P>
+<H2 CLASS="western">License</H2>
+<P>All of the software in this directory and linked from this page is
+copyrighted by its authors. You many only use it subject to its
+<A href="../../../Licensing.html">license</a>.</P>
<P><BR><BR>
</P>
</BODY>
Modified: trunk/prototypes/java/src/org/openlcb/can/MessageBuilder.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/can/MessageBuilder.java 2010-09-27 19:41:13 UTC (rev 961)
+++ trunk/prototypes/java/src/org/openlcb/can/MessageBuilder.java 2010-09-27 19:42:20 UTC (rev 962)
@@ -9,21 +9,34 @@
* and vice-versa.
*<p>
* In general, the connection is one-to-one, but
- * sometimes (datagram expansion) more than one will be
+ * sometimes (datagram expansion) more than one frame will be
* created.
- * The List is always returned, even if empty.
*
* @author Bob Jacobsen Copyright 2010
* @version $Revision$
*/
public class MessageBuilder {
+ /**
+ * The provided AliasMap will be updated
+ * as inbound frames are processed.
+ */
public MessageBuilder(AliasMap map) {
this.map = map;
}
AliasMap map;
+ /**
+ * Accept a frame, and convert to
+ * a standard OpenLCB Message object.
+ *
+ * The returned Message is fully initialized
+ * with content, and the original frame can
+ * be dropped.
+ *
+ * The List is always returned, even if empty.
+ */
public List<Message> processFrame(OpenLcbCanFrame f) {
List<Message> retlist = new java.util.ArrayList<Message>();
NodeID source = map.getNodeID(f.getSourceAlias());
@@ -90,38 +103,155 @@
return retlist;
}
- public List<OpenLcbCanFrame> processMessage(Message f) {
- List<OpenLcbCanFrame> retlist = new java.util.ArrayList<OpenLcbCanFrame>();
- switch(f.getMTI()) {
+ /**
+ * Accept an OpenLCB Message, and convert to
+ * a standard frame object.
+ *
+ * The returned frame(s) are fully initialized
+ * with content, and the original frame can
+ * be dropped.
+ *
+ * The List is always returned, and should never be empty.
+ */
+ public List<OpenLcbCanFrame> processMessage(Message msg) {
- case OpenLcb.MTI_INITIALIZATION_COMPLETE:
-
- case OpenLcb.MTI_VERIFY_NID:
- case OpenLcb.MTI_VERIFIED_NID: // also 30B2
+ FrameBuilder f = new FrameBuilder();
+ return f.convert(msg);
+ }
+
+ private class FrameBuilder extends org.openlcb.MessageDecoder {
+ /**
+ * Catches messages that are not explicitly
+ * handled and throws an error
+ */
+ protected void defaultHandler(Message msg, Connection sender) {
+ throw new java.lang.NoSuchMethodError("no handler for Message: "+msg.toString());
+ }
- case OpenLcb.MTI_IDENTIFY_CONSUMERS:
- case OpenLcb.MTI_IDENTIFY_CONSUMERS_RANGE:
- case OpenLcb.MTI_CONSUMER_IDENTIFIED:
+ List<OpenLcbCanFrame> retlist;
- case OpenLcb.MTI_IDENTIFY_PRODUCERS:
- case OpenLcb.MTI_IDENTIFY_PRODUCERS_RANGE:
- case OpenLcb.MTI_PRODUCER_IDENTIFIED:
-
- case OpenLcb.MTI_IDENTIFY_EVENTS: // also 32B2
-
- case OpenLcb.MTI_LEARN_EVENT:
- case OpenLcb.MTI_PC_EVENT_REPORT:
-
- case OpenLcb.MTI_DATAGRAM:
- case OpenLcb.MTI_DATAGRAM_RCV_OK:
- case OpenLcb.MTI_DATAGRAM_REJECTED:
-
- case OpenLcb.MTI_STREAM_INIT_REQUEST:
- case OpenLcb.MTI_STREAM_INIT_REPLY:
- case OpenLcb.MTI_STREAM_DATA_SEND:
- case OpenLcb.MTI_STREAM_DATA_PROCEED:
- case OpenLcb.MTI_STREAM_DATA_COMPLETE:
+ List<OpenLcbCanFrame> convert(Message msg) {
+ retlist = new java.util.ArrayList<OpenLcbCanFrame>();
+
+ // Uses the double dispatch mechanism built into Message
+ put(msg, null); // no Connection needed
+
+ return retlist;
}
- return retlist;
+
+ /**
+ * Handle "Initialization Complete" message
+ */
+ public void handleInitializationComplete(InitializationCompleteMessage msg, Connection sender){
+ defaultHandler(msg, sender);
+ }
+ /**
+ * Handle "Verified Node ID Number" message
+ */
+ public void handleVerifiedNodeIDNumber(VerifiedNodeIDNumberMessage msg, Connection sender){
+ defaultHandler(msg, sender);
+ }
+ /**
+ * Handle "Verify Node ID Number" message
+ */
+ public void handleVerifyNodeIDNumber(VerifyNodeIDNumberMessage msg, Connection sender){
+ OpenLcbCanFrame f = new OpenLcbCanFrame(0x00);
+ f.setVerifiedNID(msg.getSourceNodeID());
+ f.setSourceAlias(map.getAlias(msg.getSourceNodeID()));
+ retlist.add(f);
+ }
+ /**
+ * Handle "Producer/Consumer Event Report" message
+ */
+ public void handleProducerConsumerEventReport(ProducerConsumerEventReportMessage msg, Connection sender){
+ OpenLcbCanFrame f = new OpenLcbCanFrame(0x00);
+ f.setPCEventReport(msg.getEventID());
+ f.setSourceAlias(map.getAlias(msg.getSourceNodeID()));
+ retlist.add(f);
+ }
+ /**
+ * Handle "Identify Consumers" message
+ */
+ public void handleIdentifyConsumers(IdentifyConsumersMessage msg, Connection sender){
+ defaultHandler(msg, sender);
+ }
+ /**
+ * Handle "Consumer Identified" message
+ */
+ public void handleConsumerIdentified(ConsumerIdentifiedMessage msg, Connection sender){
+ defaultHandler(msg, sender);
+ }
+ /**
+ * Handle "Identify Producers" message
+ */
+ public void handleIdentifyProducers(IdentifyProducersMessage msg, Connection sender){
+ defaultHandler(msg, sender);
+ }
+ /**
+ * Handle "Producer Identified" message
+ */
+ public void handleProducerIdentified(ProducerIdentifiedMessage msg, Connection sender){
+ defaultHandler(msg, sender);
+ }
+ /**
+ * Handle "Identify Event" message
+ */
+ public void handleIdentifyEvents(IdentifyEventsMessage msg, Connection sender){
+ defaultHandler(msg, sender);
+ }
+ /**
+ * Handle "Learn Event" message
+ */
+ public void handleLearnEvent(LearnEventMessage msg, Connection sender){
+ defaultHandler(msg, sender);
+ }
+ /**
+ * Handle "Datagram" message
+ */
+ public void handleDatagram(DatagramMessage msg, Connection sender){
+ defaultHandler(msg, sender);
+ }
+ /**
+ * Handle "Datagram Rejected" message
+ */
+ public void handleDatagramRejected(DatagramRejectedMessage msg, Connection sender){
+ defaultHandler(msg, sender);
+ }
+ /**
+ * Handle "Datagram Acknowledged" message
+ */
+ public void handleDatagramAcknowledged(DatagramAcknowledgedMessage msg, Connection sender){
+ defaultHandler(msg, sender);
+ }
+ /**
+ * Handle "Stream Init Request" message
+ */
+ public void handleStreamInitRequest(StreamInitRequestMessage msg, Connection sender){
+ defaultHandler(msg, sender);
+ }
+ /**
+ * Handle "Stream Init Reply" message
+ */
+ public void handleStreamInitReply(StreamInitReplyMessage msg, Connection sender){
+ defaultHandler(msg, sender);
+ }
+ /**
+ * Handle "Stream Data Send" message
+ */
+ public void handleStreamDataSend(StreamDataSendMessage msg, Connection sender){
+ defaultHandler(msg, sender);
+ }
+ /**
+ * Handle "Stream Data Proceed" message
+ */
+ public void handleStreamDataProceed(StreamDataProceedMessage msg, Connection sender){
+ defaultHandler(msg, sender);
+ }
+ /**
+ * Handle "Stream Data Complete" message
+ */
+ public void handleStreamDataComplete(StreamDataCompleteMessage msg, Connection sender){
+ defaultHandler(msg, sender);
+ }
}
}
Modified: trunk/prototypes/java/src/org/openlcb/can/package.html
===================================================================
--- trunk/prototypes/java/src/org/openlcb/can/package.html 2010-09-27 19:41:13 UTC (rev 961)
+++ trunk/prototypes/java/src/org/openlcb/can/package.html 2010-09-27 19:42:20 UTC (rev 962)
@@ -33,7 +33,16 @@
not have an "unsigned" modifier, we add that as a comment
on appropriate declarations.
+<p>
+The OpenLcbCanFrame class centralizes
+the frame formatting and in most cases deformatting
+specific CAN frame contents to numbers and other values.
+<p>
+The connection between the {@link org.openlcb} message classes
+(e.g. {@link org.openlcb.VerifiedNodeIDNumberMessage} et al)
+and CAN frames is through the MessageBuilder class.
+
<h2>Related Documentation</h2>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jac...@us...> - 2010-10-03 01:24:40
|
Revision: 971
http://openlcb.svn.sourceforge.net/openlcb/?rev=971&view=rev
Author: jacobsen
Date: 2010-10-03 01:24:34 +0000 (Sun, 03 Oct 2010)
Log Message:
-----------
version bump
Modified Paths:
--------------
trunk/prototypes/java/manifest
trunk/prototypes/java/src/overview.html
Modified: trunk/prototypes/java/manifest
===================================================================
--- trunk/prototypes/java/manifest 2010-10-02 15:45:12 UTC (rev 970)
+++ trunk/prototypes/java/manifest 2010-10-03 01:24:34 UTC (rev 971)
@@ -4,9 +4,9 @@
Name: org.openlcb
Specification-Title: \xD2OpenLCB\xD3
-Specification-Version: \xD20.2\xD3
+Specification-Version: \xD20.3\xD3
Specification-Vendor: \xD2OpenLCB group"
Package-Title: \xD2openlcb\xD3
-Package-Version: \xD20.2\xD3
+Package-Version: \xD20.3\xD3
Package-Vendor: \xD2OpenLCB group\xD3
Modified: trunk/prototypes/java/src/overview.html
===================================================================
--- trunk/prototypes/java/src/overview.html 2010-10-02 15:45:12 UTC (rev 970)
+++ trunk/prototypes/java/src/overview.html 2010-10-03 01:24:34 UTC (rev 971)
@@ -17,6 +17,9 @@
OpenLCB sample and test implementations.
<p>
+These are the JavaDocs for the 0.3 version of the OpenLCB library.
+
+<p>
This software is copyrighted by its authors,
and use of it is governed by a license.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jac...@us...> - 2010-10-10 23:59:12
|
Revision: 1004
http://openlcb.svn.sourceforge.net/openlcb/?rev=1004&view=rev
Author: jacobsen
Date: 2010-10-10 23:59:05 +0000 (Sun, 10 Oct 2010)
Log Message:
-----------
add datagram formatting tests
Modified Paths:
--------------
trunk/prototypes/java/src/org/openlcb/DatagramMessage.java
trunk/prototypes/java/src/org/openlcb/Message.java
trunk/prototypes/java/src/org/openlcb/can/MessageBuilder.java
trunk/prototypes/java/src/org/openlcb/can/OpenLcbCanFrame.java
trunk/prototypes/java/test/org/openlcb/can/CanTest.java
trunk/prototypes/java/test/org/openlcb/can/MessageBuilderTest.java
Added Paths:
-----------
trunk/prototypes/java/src/org/openlcb/AddressedMessage.java
Copied: trunk/prototypes/java/src/org/openlcb/AddressedMessage.java (from rev 964, trunk/prototypes/java/src/org/openlcb/Message.java)
===================================================================
--- trunk/prototypes/java/src/org/openlcb/AddressedMessage.java (rev 0)
+++ trunk/prototypes/java/src/org/openlcb/AddressedMessage.java 2010-10-10 23:59:05 UTC (rev 1004)
@@ -0,0 +1,44 @@
+package org.openlcb;
+
+/**
+ * Base for addressed OpenLCB message types
+ *<p>
+ * Messages (and therefore all subtypes) are immutable once created.
+ *<p>
+ * A Message works with a {@link MessageDecoder} object in a double dispatch
+ * pattern to do message specific-processing in e.g. a node implementation.
+ *
+ * @author Bob Jacobsen Copyright 2009, 2010
+ * @version $Revision$
+ * @see MessageDecoder
+ */
+abstract public class AddressedMessage extends Message {
+
+ public AddressedMessage(NodeID source, NodeID dest) {
+ super(source);
+ destNodeID = dest;
+ }
+
+ // cannot create without sourceID, destID
+ protected AddressedMessage() {}
+
+ NodeID destNodeID;
+
+ public NodeID getDestNodeID() { return destNodeID; }
+
+ /**
+ * To be equal, messages have to have the
+ * same type and content
+ */
+ public boolean equals(Object o) {
+ if (o == null) return false;
+ if (! (o instanceof AddressedMessage))
+ return false;
+ AddressedMessage msg = (AddressedMessage) o;
+ if (this.getDestNodeID() != msg.getDestNodeID())
+ return false;
+ else return super.equals(o);
+ }
+
+ abstract public int getMTI();
+}
Modified: trunk/prototypes/java/src/org/openlcb/DatagramMessage.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/DatagramMessage.java 2010-10-10 22:27:09 UTC (rev 1003)
+++ trunk/prototypes/java/src/org/openlcb/DatagramMessage.java 2010-10-10 23:59:05 UTC (rev 1004)
@@ -6,12 +6,15 @@
* @author Bob Jacobsen Copyright 2009
* @version $Revision$
*/
-public class DatagramMessage extends Message {
+public class DatagramMessage extends AddressedMessage {
public DatagramMessage(NodeID source, NodeID dest, int[] data) {
- super(source);
+ super(source, dest);
+ this.data = data;
}
-
+
+ int[] data;
+
/**
* Implement message-type-specific
* processing when this message
@@ -20,9 +23,13 @@
* Default is to do nothing.
*/
@Override
- public void applyTo(MessageDecoder decoder, Connection sender) {
+ public void applyTo(MessageDecoder decoder, Connection sender) {
decoder.handleDatagram(this, sender);
- }
+ }
+ public int[] getData() {
+ return data;
+ }
+
public int getMTI() { return MTI_DATAGRAM; }
}
Modified: trunk/prototypes/java/src/org/openlcb/Message.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/Message.java 2010-10-10 22:27:09 UTC (rev 1003)
+++ trunk/prototypes/java/src/org/openlcb/Message.java 2010-10-10 23:59:05 UTC (rev 1004)
@@ -19,7 +19,7 @@
}
// cannot create without sourceID
- private Message() {}
+ protected Message() {}
NodeID sourceNodeID;
Modified: trunk/prototypes/java/src/org/openlcb/can/MessageBuilder.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/can/MessageBuilder.java 2010-10-10 22:27:09 UTC (rev 1003)
+++ trunk/prototypes/java/src/org/openlcb/can/MessageBuilder.java 2010-10-10 23:59:05 UTC (rev 1004)
@@ -215,8 +215,26 @@
* Handle "Datagram" message
*/
public void handleDatagram(DatagramMessage msg, Connection sender){
- defaultHandler(msg, sender);
+ // must loop over data to send 8 byte chunks
+ int remains = msg.getData().length;
+ int j = 0;
+ // always sends at least one datagram, even with zero bytes
+ do {
+ int size = Math.min(8, remains);
+ int[] data = new int[size];
+ for (int i = 0; i<size; i++) {
+ data[i] = msg.getData()[j++];
+ }
+
+ OpenLcbCanFrame f = new OpenLcbCanFrame(0x00);
+ f.setDatagram(data, map.getAlias(msg.getDestNodeID()), remains <= 8);
+ f.setSourceAlias(map.getAlias(msg.getSourceNodeID()));
+ retlist.add(f);
+
+ remains = remains - size;
+ } while (remains > 0);
}
+
/**
* Handle "Datagram Rejected" message
*/
Modified: trunk/prototypes/java/src/org/openlcb/can/OpenLcbCanFrame.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/can/OpenLcbCanFrame.java 2010-10-10 22:27:09 UTC (rev 1003)
+++ trunk/prototypes/java/src/org/openlcb/can/OpenLcbCanFrame.java 2010-10-10 23:59:05 UTC (rev 1004)
@@ -302,6 +302,21 @@
return (getOpenLcbFormat() == MTI_FORMAT_ADDRESSED_DATAGRAM_LAST);
}
+ /**
+ * create a single datagram frame
+ */
+ void setDatagram(int[] content, int destAlias, boolean last) {
+ init(nodeAlias);
+ if (!last) {
+ setOpenLcbMTI(MTI_FORMAT_ADDRESSED_DATAGRAM,destAlias);
+ } else {
+ setOpenLcbMTI(MTI_FORMAT_ADDRESSED_DATAGRAM_LAST,destAlias);
+ }
+ length=content.length;
+ for (int i = 0; i< content.length; i++) {
+ data[i] = (byte)(content[i]&0xFF);
+ }
+ }
public boolean equals(Object other) {
// try to cast, else not equal
Modified: trunk/prototypes/java/test/org/openlcb/can/CanTest.java
===================================================================
--- trunk/prototypes/java/test/org/openlcb/can/CanTest.java 2010-10-10 22:27:09 UTC (rev 1003)
+++ trunk/prototypes/java/test/org/openlcb/can/CanTest.java 2010-10-10 23:59:05 UTC (rev 1004)
@@ -30,6 +30,7 @@
TestSuite suite = new TestSuite(CanTest.class);
suite.addTest(OpenLcbCanFrameTest.suite());
+ suite.addTest(MessageBuilderTest.suite());
suite.addTest(NIDaTest.suite());
suite.addTest(NIDaAlgorithmTest.suite());
suite.addTest(AliasMapTest.suite());
Modified: trunk/prototypes/java/test/org/openlcb/can/MessageBuilderTest.java
===================================================================
--- trunk/prototypes/java/test/org/openlcb/can/MessageBuilderTest.java 2010-10-10 22:27:09 UTC (rev 1003)
+++ trunk/prototypes/java/test/org/openlcb/can/MessageBuilderTest.java 2010-10-10 23:59:05 UTC (rev 1004)
@@ -39,11 +39,25 @@
List<OpenLcbCanFrame> list = b.processMessage(m);
- // looking for [190AF123] 01 02 03 04 05 06
+ // looking for [190AF123]
Assert.assertEquals("count", 1, list.size());
CanFrame f0 = list.get(0);
Assert.assertEquals("header", toHexString(0x190af123), toHexString(f0.getHeader()));
+ compareContent(null, f0);
+ }
+ public void testVerifiedNodeIDNumberMessage() {
+
+ Message m = new VerifiedNodeIDNumberMessage(source);
+ MessageBuilder b = new MessageBuilder(map);
+
+ List<OpenLcbCanFrame> list = b.processMessage(m);
+
+ // looking for [190BF123] 01 02 03 04 05 06
+
+ Assert.assertEquals("count", 1, list.size());
+ CanFrame f0 = list.get(0);
+ Assert.assertEquals("header", toHexString(0x190bf123), toHexString(f0.getHeader()));
compareContent(source.getContents(), f0);
}
@@ -54,33 +68,30 @@
List<OpenLcbCanFrame> list = b.processMessage(m);
- // looking for [192df123] 11 12 13 14 15 16 17 18
+ // looking for [182df123] 11 12 13 14 15 16 17 18
Assert.assertEquals("count", 1, list.size());
CanFrame f0 = list.get(0);
- Assert.assertEquals("header", toHexString(0x192Df123), toHexString(f0.getHeader()));
+ Assert.assertEquals("header", toHexString(0x182Df123), toHexString(f0.getHeader()));
compareContent(event.getContents(), f0);
}
- // not a high priority itself, but this shows
- // handling of destination address
- public void testStreamInitRequestMessage() {
- int bufferSize = 1024;
- int sourceStreamID = 7;
- Message m = new StreamInitRequestMessage(source, destination, bufferSize, sourceStreamID);
+ public void testDatagramMessageShort() {
+ int[] data = new int[]{21,22,23};
+ Message m = new DatagramMessage(source, destination, data);
MessageBuilder b = new MessageBuilder(map);
List<OpenLcbCanFrame> list = b.processMessage(m);
-
+
Assert.assertEquals("count", 1, list.size());
CanFrame f0 = list.get(0);
- Assert.assertEquals("header", toHexString(0x1E321123), toHexString(f0.getHeader()));
- compareContent(null, f0); // known to be wrong
+ Assert.assertEquals("header", toHexString(0x1D321123), toHexString(f0.getHeader()));
+ compareContent(new byte[]{21,22,23}, f0);
}
- public void testDatagramMessageShort() {
- int[] data = new int[]{21,22,23};
+ public void testDatagramMessageEight() {
+ int[] data = new int[]{21,22,23,24,25,26,27,28};
Message m = new DatagramMessage(source, destination, data);
MessageBuilder b = new MessageBuilder(map);
@@ -89,8 +100,8 @@
Assert.assertEquals("count", 1, list.size());
CanFrame f0 = list.get(0);
- Assert.assertEquals("header", toHexString(0x1C321123), toHexString(f0.getHeader()));
- compareContent(new byte[]{21,22,23}, f0);
+ Assert.assertEquals("header", toHexString(0x1D321123), toHexString(f0.getHeader()));
+ compareContent(new byte[]{21,22,23,24,25,26,27,28}, f0);
}
public void testDatagramMessageTwoFrame() {
@@ -102,11 +113,11 @@
List<OpenLcbCanFrame> list = b.processMessage(m);
- // looking for ??
- Assert.assertEquals("count", 1, list.size());
+ Assert.assertEquals("count", 2, list.size());
CanFrame f0 = list.get(0);
+ Assert.assertEquals("f0 header", toHexString(0x1C321123), toHexString(f0.getHeader()));
compareContent(new byte[]{21,22,23,24,25,26,27,28}, f0);
CanFrame f1 = list.get(1);
@@ -114,6 +125,27 @@
compareContent(new byte[]{31,32,33,34,35,36,37,38}, f1);
}
+ public void testDatagramMessageNine() {
+ int[] data = new int[]{21,22,23,24,25,26,27,28,
+ 31};
+
+ Message m = new DatagramMessage(source, destination, data);
+ MessageBuilder b = new MessageBuilder(map);
+
+ List<OpenLcbCanFrame> list = b.processMessage(m);
+
+
+ Assert.assertEquals("count", 2, list.size());
+
+ CanFrame f0 = list.get(0);
+ Assert.assertEquals("f0 header", toHexString(0x1C321123), toHexString(f0.getHeader()));
+ compareContent(new byte[]{21,22,23,24,25,26,27,28}, f0);
+
+ CanFrame f1 = list.get(1);
+ Assert.assertEquals("f1 header", toHexString(0x1D321123), toHexString(f1.getHeader()));
+ compareContent(new byte[]{31}, f1);
+ }
+
// from here down is testing infrastructure
public MessageBuilderTest(String s) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jac...@us...> - 2011-03-09 00:00:33
|
Revision: 1124
http://openlcb.svn.sourceforge.net/openlcb/?rev=1124&view=rev
Author: jacobsen
Date: 2011-03-09 00:00:27 +0000 (Wed, 09 Mar 2011)
Log Message:
-----------
jdom for XML processing
Modified Paths:
--------------
trunk/prototypes/java/manifest
Added Paths:
-----------
trunk/prototypes/java/lib/jdom.jar
Added: trunk/prototypes/java/lib/jdom.jar
===================================================================
(Binary files differ)
Property changes on: trunk/prototypes/java/lib/jdom.jar
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Modified: trunk/prototypes/java/manifest
===================================================================
--- trunk/prototypes/java/manifest 2011-03-08 22:48:00 UTC (rev 1123)
+++ trunk/prototypes/java/manifest 2011-03-09 00:00:27 UTC (rev 1124)
@@ -1,6 +1,6 @@
Manifest-Version: 1.0
Main-Class: scenarios.BlueGoldCheck
-Class-Path: lib/junit.jar
+Class-Path: lib/junit.jar lib/jdom.jar
Name: org.openlcb
Specification-Title: \xD2OpenLCB\xD3
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jac...@us...> - 2011-03-09 00:03:59
|
Revision: 1125
http://openlcb.svn.sourceforge.net/openlcb/?rev=1125&view=rev
Author: jacobsen
Date: 2011-03-09 00:03:54 +0000 (Wed, 09 Mar 2011)
Log Message:
-----------
as of today
Modified Paths:
--------------
trunk/prototypes/java/openlcb-demo.jar
trunk/prototypes/java/openlcb.jar
Modified: trunk/prototypes/java/openlcb-demo.jar
===================================================================
(Binary files differ)
Modified: trunk/prototypes/java/openlcb.jar
===================================================================
(Binary files differ)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jac...@us...> - 2011-03-09 00:05:20
|
Revision: 1128
http://openlcb.svn.sourceforge.net/openlcb/?rev=1128&view=rev
Author: jacobsen
Date: 2011-03-09 00:05:13 +0000 (Wed, 09 Mar 2011)
Log Message:
-----------
first version. Runs, but only as a skeleton
Added Paths:
-----------
trunk/prototypes/java/ConfigDemoApplet.html
trunk/prototypes/java/test/scenarios/ConfigDemoApplet.java
Copied: trunk/prototypes/java/ConfigDemoApplet.html (from rev 1123, trunk/prototypes/java/BlueGoldApplet.html)
===================================================================
--- trunk/prototypes/java/ConfigDemoApplet.html (rev 0)
+++ trunk/prototypes/java/ConfigDemoApplet.html 2011-03-09 00:05:13 UTC (rev 1128)
@@ -0,0 +1,30 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+ <title>Configuration Demo</title>
+</head>
+<body>
+This page demonstrates one possible form of an OpenLCB configuration tool.
+
+<p>
+Press the button at the bottom to start the demonstration.
+(Note: This may not work on some browsers, particularly Safari,
+depending on security settings; it's known to work on recent Firefox versions)
+
+<p>
+Explanation...
+
+<h2>How it works</h2>
+
+Explanation....
+
+<p>
+<applet code = "scenarios.ConfigDemoApplet" archive = "openlcb-demo.jar"
+ height="60"
+ width="300"
+>
+<PARAM name="URL" value="http://localhost/openlcb/trunk/prototypes/java/index.html">
+</applet>
+</body>
+</html>
Copied: trunk/prototypes/java/test/scenarios/ConfigDemoApplet.java (from rev 1112, trunk/prototypes/java/test/scenarios/BlueGoldApplet.java)
===================================================================
--- trunk/prototypes/java/test/scenarios/ConfigDemoApplet.java (rev 0)
+++ trunk/prototypes/java/test/scenarios/ConfigDemoApplet.java 2011-03-09 00:05:13 UTC (rev 1128)
@@ -0,0 +1,89 @@
+package scenarios;
+
+import org.openlcb.*;
+import org.openlcb.implementations.*;
+import org.openlcb.swing.*;
+
+import javax.swing.*;
+import java.awt.*;
+import java.io.*;
+import java.net.*;
+import java.util.*;
+
+import org.jdom.*;
+
+/**
+ * Demonstrate basic configuration from an XML file.
+ *
+ * @author Bob Jacobsen Copyright 2011
+ * @version $Revision$
+ */
+public class ConfigDemoApplet extends JApplet {
+
+ public ConfigDemoApplet() {}
+
+ /**
+ * Applet starts here
+ */
+ public void start() {
+ JPanel p = new JPanel();
+ add(p);
+ p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
+ startButton = new JButton("Start Configuration Demonstration");
+ p.add(startButton);
+ startButton.addActionListener(
+ new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent e) {
+ startDemo();
+ }
+ });
+
+ }
+
+ JButton startButton;
+
+ void startDemo() {
+ startButton.setEnabled(false);
+
+ JFrame f = new JFrame();
+ f.setTitle("Configuration Demonstration");
+ JPanel m = new JPanel();
+ f.add( m );
+
+ // read and fill
+ JTextArea t = new JTextArea();
+ m.add(t);
+
+ Element elem = new Element("Foo");
+
+ // get content
+ try {
+ // Create a URL for the desired page
+ URL url = new URL(this.getParameter("URL"));
+
+ // Read all the text returned by the server
+ BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
+ String str;
+ while ((str = in.readLine()) != null) {
+ // str is one line of text; readLine() strips the newline character(s)
+ t.append(str);
+ }
+ in.close();
+
+ } catch (MalformedURLException e) {
+ System.err.println("MalformedURLException: "+e);
+ } catch (IOException e) {
+ System.err.println("IOException: "+e);
+ }
+
+ // show
+ f.pack();
+ f.setVisible(true);
+ }
+
+
+ // frame starting positions
+ int hPos = 500;
+ int vPos = 0;
+
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jac...@us...> - 2011-03-20 05:07:51
|
Revision: 1140
http://openlcb.svn.sourceforge.net/openlcb/?rev=1140&view=rev
Author: jacobsen
Date: 2011-03-20 05:07:45 +0000 (Sun, 20 Mar 2011)
Log Message:
-----------
add JDOM
Modified Paths:
--------------
trunk/prototypes/java/runtest.bat
trunk/prototypes/java/runtest.csh
Modified: trunk/prototypes/java/runtest.bat
===================================================================
--- trunk/prototypes/java/runtest.bat 2011-03-20 04:34:29 UTC (rev 1139)
+++ trunk/prototypes/java/runtest.bat 2011-03-20 05:07:45 UTC (rev 1140)
@@ -1 +1 @@
-java -noverify -Dsun.java2d.noddraw -Djava.library.path=.:lib/ -cp .;classes;lib/junit.jar $1 $2 $3
+java -noverify -Dsun.java2d.noddraw -Djava.library.path=.:lib/ -cp .;classes;lib/junit.jar;lib/jdom.jar $1 $2 $3
Modified: trunk/prototypes/java/runtest.csh
===================================================================
--- trunk/prototypes/java/runtest.csh 2011-03-20 04:34:29 UTC (rev 1139)
+++ trunk/prototypes/java/runtest.csh 2011-03-20 05:07:45 UTC (rev 1140)
@@ -12,5 +12,5 @@
-Dapple.laf.useScreenMenuBar=true \
-Dlog4j.ignoreTCL=true \
-Djava.library.path=.:lib/ \
- -cp .:classes:lib/junit.jar \
+ -cp .:classes:lib/junit.jar:lib/jdom.jar \
$1 $2 $3
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jac...@us...> - 2011-03-20 20:39:45
|
Revision: 1158
http://openlcb.svn.sourceforge.net/openlcb/?rev=1158&view=rev
Author: jacobsen
Date: 2011-03-20 20:39:39 +0000 (Sun, 20 Mar 2011)
Log Message:
-----------
add icon library
Modified Paths:
--------------
trunk/prototypes/java/manifest
trunk/prototypes/java/runtest.bat
trunk/prototypes/java/runtest.csh
Added Paths:
-----------
trunk/prototypes/java/lib/jlfgr-1_0.jar
Added: trunk/prototypes/java/lib/jlfgr-1_0.jar
===================================================================
(Binary files differ)
Property changes on: trunk/prototypes/java/lib/jlfgr-1_0.jar
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Modified: trunk/prototypes/java/manifest
===================================================================
--- trunk/prototypes/java/manifest 2011-03-20 18:35:11 UTC (rev 1157)
+++ trunk/prototypes/java/manifest 2011-03-20 20:39:39 UTC (rev 1158)
@@ -1,6 +1,6 @@
Manifest-Version: 1.0
Main-Class: scenarios.BlueGoldCheck
-Class-Path: lib/junit.jar lib/jdom.jar
+Class-Path: lib/junit.jar lib/jdom.jar lib/jlfgr-1_0.jar
Name: org.openlcb
Specification-Title: \xD2OpenLCB\xD3
Modified: trunk/prototypes/java/runtest.bat
===================================================================
--- trunk/prototypes/java/runtest.bat 2011-03-20 18:35:11 UTC (rev 1157)
+++ trunk/prototypes/java/runtest.bat 2011-03-20 20:39:39 UTC (rev 1158)
@@ -1 +1 @@
-java -noverify -Dsun.java2d.noddraw -Djava.library.path=.:lib/ -cp .;classes;lib/junit.jar;lib/jdom.jar $1 $2 $3
+java -noverify -Dsun.java2d.noddraw -Djava.library.path=.:lib/ -cp .;classes;lib/junit.jar;lib/jdom.jar;lib/jlfgr-1_0.jar $1 $2 $3
Modified: trunk/prototypes/java/runtest.csh
===================================================================
--- trunk/prototypes/java/runtest.csh 2011-03-20 18:35:11 UTC (rev 1157)
+++ trunk/prototypes/java/runtest.csh 2011-03-20 20:39:39 UTC (rev 1158)
@@ -12,5 +12,5 @@
-Dapple.laf.useScreenMenuBar=true \
-Dlog4j.ignoreTCL=true \
-Djava.library.path=.:lib/ \
- -cp .:classes:lib/junit.jar:lib/jdom.jar \
+ -cp .:classes:lib/junit.jar:lib/jdom.jar:lib/jlfgr-1_0.jar \
$1 $2 $3
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jac...@us...> - 2011-03-20 20:41:45
|
Revision: 1160
http://openlcb.svn.sourceforge.net/openlcb/?rev=1160&view=rev
Author: jacobsen
Date: 2011-03-20 20:41:38 +0000 (Sun, 20 Mar 2011)
Log Message:
-----------
better handling of maps and groups
Modified Paths:
--------------
trunk/prototypes/java/ConfigDemoApplet.html
trunk/prototypes/java/src/org/openlcb/cdi/swing/CdiPanel.java
Modified: trunk/prototypes/java/ConfigDemoApplet.html
===================================================================
--- trunk/prototypes/java/ConfigDemoApplet.html 2011-03-20 20:40:00 UTC (rev 1159)
+++ trunk/prototypes/java/ConfigDemoApplet.html 2011-03-20 20:41:38 UTC (rev 1160)
@@ -24,7 +24,7 @@
height="60"
width="300"
>
-<PARAM name="URL" value="http://localhost/openlcb/trunk/prototypes/java/index.html">
+<PARAM name="URL" value="http://localhost/openlcb/trunk/prototypes/java/Servo4.xml">
</applet>
</body>
</html>
Modified: trunk/prototypes/java/src/org/openlcb/cdi/swing/CdiPanel.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/cdi/swing/CdiPanel.java 2011-03-20 20:40:00 UTC (rev 1159)
+++ trunk/prototypes/java/src/org/openlcb/cdi/swing/CdiPanel.java 2011-03-20 20:41:38 UTC (rev 1160)
@@ -23,56 +23,224 @@
public void loadCDI(CdiRep c) {
add(createIdentificationPane(c));
+
+ java.util.List<CdiRep.Segment> segments = c.getSegments();
+ for (int i=0; i<segments.size(); i++) {
+ add(createSegmentPane(segments.get(i)));
+ }
}
JPanel createIdentificationPane(CdiRep c) {
JPanel p = new JPanel();
p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
- p.setBorder(BorderFactory.createTitledBorder("Identification"));
+ p.setAlignmentX(Component.LEFT_ALIGNMENT);
+ //p.setBorder(BorderFactory.createTitledBorder("Identification"));
+
+ CdiRep.Identification id = c.getIdentification();
- JPanel p1;
+ JPanel p1 = new JPanel();
+ p.add(p1);
+ p1.setLayout(new util.javaworld.GridLayout2(4,2));
- p1 = new JPanel();
- p1.setLayout(new FlowLayout());
- p.add(p1);
p1.add(new JLabel("Manufacturer: "));
- p1.add(new JLabel(c.getIdentification().getManufacturer()));
+ p1.add(new JLabel(id.getManufacturer()));
- p1 = new JPanel();
- p1.setLayout(new FlowLayout());
- p.add(p1);
p1.add(new JLabel("Model: "));
- p1.add(new JLabel(c.getIdentification().getModel()));
+ p1.add(new JLabel(id.getModel()));
- p1 = new JPanel();
- p1.setLayout(new FlowLayout());
- p.add(p1);
p1.add(new JLabel("Hardware Version: "));
- p1.add(new JLabel(c.getIdentification().getHardwareVersion()));
+ p1.add(new JLabel(id.getHardwareVersion()));
- p1 = new JPanel();
- p1.setLayout(new FlowLayout());
- p.add(p1);
p1.add(new JLabel("Software Version: "));
- p1.add(new JLabel(c.getIdentification().getSoftwareVersion()));
+ p1.add(new JLabel(id.getSoftwareVersion()));
// include map if present
+ JPanel p2 = createPropertyPane(id.getMap());
+ if (p2!=null) p.add(p2);
- CdiRep.Map map = c.getIdentification().getMap();
+ return new util.CollapsiblePanel("Identification", p);
+
+ }
+
+ JPanel createPropertyPane(CdiRep.Map map) {
if (map != null) {
+ JPanel p2 = new JPanel();
+ p2.setBorder(BorderFactory.createTitledBorder("Properties"));
+
java.util.List keys = map.getKeys();
+ if (keys.size() == 0) return null;
+
+ p2.setLayout(new util.javaworld.GridLayout2(keys.size(),2));
+
for (int i = 0; i<keys.size(); i++) {
String key = (String)keys.get(i);
- p1 = new JPanel();
- p1.setLayout(new FlowLayout());
- p.add(p1);
- p1.add(new JLabel(key+": "));
- p1.add(new JLabel(map.getEntry(key)));
+ p2.add(new JLabel(key+": "));
+ p2.add(new JLabel(map.getEntry(key)));
}
+ return p2;
+ } else
+ return null;
+ }
+
+ JPanel createSegmentPane(CdiRep.Segment item) {
+ JPanel p = new JPanel();
+ p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
+ p.setAlignmentX(Component.LEFT_ALIGNMENT);
+ String name = "Segment"+(item.getName()!=null?(": "+item.getName()):"");
+ //p.setBorder(BorderFactory.createTitledBorder(name));
+
+ String d = item.getDescription();
+ if (d!=null) p.add(createDescriptionPane(d));
+
+ // include map if present
+ JPanel p2 = createPropertyPane(item.getMap());
+ if (p2!=null) p.add(p2);
+
+ // find and process items
+ java.util.List<CdiRep.Item> items = item.getItems();
+ if (items != null) {
+ for (int i=0; i<items.size(); i++) {
+ CdiRep.Item it = (CdiRep.Item) items.get(i);
+ if (it instanceof CdiRep.Group) p.add(createGroupPane((CdiRep.Group)it));
+ else if (it instanceof CdiRep.Bit) p.add(createBitPane((CdiRep.Bit)it));
+ else if (it instanceof CdiRep.Int) p.add(createIntPane((CdiRep.Int)it));
+ else if (it instanceof CdiRep.EventID) p.add(createEventIdPane((CdiRep.EventID)it));
+ }
}
+ return new util.CollapsiblePanel(name, p);
+ }
+
+ JPanel createDescriptionPane(String d) {
+ if (d == null) return null;
+ JPanel p = new JPanel();
+ p.setLayout(new BorderLayout());
+ p.setAlignmentX(Component.LEFT_ALIGNMENT);
+ JTextArea area = new JTextArea(d);
+ area.setAlignmentX(Component.LEFT_ALIGNMENT);
+ area.setFont(UIManager.getFont("Label.font"));
+ area.setEditable(false);
+ area.setOpaque(false);
+ area.setWrapStyleWord(true);
+ area.setLineWrap(true);
+ p.add(area);
return p;
}
+
+ JPanel createGroupPane(CdiRep.Group item) {
+ JPanel p = new JPanel();
+ p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
+ p.setAlignmentX(Component.LEFT_ALIGNMENT);
+ String name = "Group"+(item.getName()!=null?(": "+item.getName()):"");
+ p.setBorder(BorderFactory.createTitledBorder(name));
+
+ String d = item.getDescription();
+ if (d!=null) p.add(createDescriptionPane(d));
+
+ // include map if present
+ JPanel p2 = createPropertyPane(item.getMap());
+ if (p2!=null) p.add(p2);
+
+ // find and process items
+ java.util.List<CdiRep.Item> items = item.getItems();
+ if (items != null) {
+ for (int i=0; i<items.size(); i++) {
+ CdiRep.Item it = (CdiRep.Item) items.get(i);
+ if (it instanceof CdiRep.Group) p.add(createGroupPane((CdiRep.Group)it));
+ else if (it instanceof CdiRep.Bit) p.add(createBitPane((CdiRep.Bit)it));
+ else if (it instanceof CdiRep.Int) p.add(createIntPane((CdiRep.Int)it));
+ else if (it instanceof CdiRep.EventID) p.add(createEventIdPane((CdiRep.EventID)it));
+ }
+ }
+
+ return p;
+ }
+
+ JPanel createBitPane(CdiRep.Bit item) {
+ JPanel p = new JPanel();
+ p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
+ p.setAlignmentX(Component.LEFT_ALIGNMENT);
+ String name = "Bit"+(item.getName()!=null?(": "+item.getName()):"");
+ p.setBorder(BorderFactory.createTitledBorder(name));
+
+ String d = item.getDescription();
+ if (d!=null) p.add(createDescriptionPane(d));
+
+ // see if map is present
+ String[] labels;
+ CdiRep.Map map = item.getMap();
+ if ((map != null) && (map.getKeys().size()>=2)) {
+ // first two map values are labels, must be present
+ java.util.List<String> keys = map.getKeys();
+ labels = new String[]{map.getEntry(keys.get(0)),map.getEntry(keys.get(1))};
+ } else {
+ labels = new String[]{"On","Off"};
+ }
+
+ JPanel p3 = new JPanel();
+ p3.setLayout(new FlowLayout());
+ p.add(p3);
+ p3.add(new JComboBox(labels));
+ p3.add(new JButton("Read"));
+ p3.add(new JButton("Write"));
+
+ return p;
+ }
+
+ JPanel createEventIdPane(CdiRep.EventID item) {
+ JPanel p = new JPanel();
+ p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
+ p.setAlignmentX(Component.LEFT_ALIGNMENT);
+ String name = "EventID"+(item.getName()!=null?(": "+item.getName()):"");
+ p.setBorder(BorderFactory.createTitledBorder(name));
+
+ String d = item.getDescription();
+ if (d!=null) p.add(createDescriptionPane(d));
+
+ JPanel p3 = new JPanel();
+ p3.setAlignmentX(Component.LEFT_ALIGNMENT);
+ p3.setLayout(new FlowLayout());
+ p.add(p3);
+
+ p3.add(new JTextField(24));
+
+ p3.add(new JButton("Read"));
+ p3.add(new JButton("Write"));
+
+ return p;
+ }
+
+ JPanel createIntPane(CdiRep.Int item) {
+ JPanel p = new JPanel();
+ p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
+ p.setAlignmentX(Component.LEFT_ALIGNMENT);
+ String name = "Integer"+(item.getName()!=null?(": "+item.getName()):"");
+ p.setBorder(BorderFactory.createTitledBorder(name));
+
+ String d = item.getDescription();
+ if (d!=null) p.add(createDescriptionPane(d));
+
+ JPanel p3 = new JPanel();
+ p3.setAlignmentX(Component.LEFT_ALIGNMENT);
+ p3.setLayout(new FlowLayout());
+ p.add(p3);
+
+ // see if map is present
+ String[] labels;
+ CdiRep.Map map = item.getMap();
+ if ((map != null) && (map.getKeys().size()>=0)) {
+ // map present, make selection box
+ p3.add(new JComboBox(map.getValues().toArray(new String[]{""})));
+ } else {
+ // map not present, just an entry box
+ p3.add(new JTextField(24));
+ }
+
+ p3.add(new JButton("Read"));
+ p3.add(new JButton("Write"));
+
+ return p;
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jac...@us...> - 2011-03-20 20:42:41
|
Revision: 1162
http://openlcb.svn.sourceforge.net/openlcb/?rev=1162&view=rev
Author: jacobsen
Date: 2011-03-20 20:42:35 +0000 (Sun, 20 Mar 2011)
Log Message:
-----------
more accessors
Modified Paths:
--------------
trunk/prototypes/java/src/org/openlcb/cdi/CdiRep.java
trunk/prototypes/java/src/org/openlcb/cdi/jdom/JdomCdiRep.java
trunk/prototypes/java/test/org/openlcb/cdi/jdom/JdomCdiRepTest.java
Modified: trunk/prototypes/java/src/org/openlcb/cdi/CdiRep.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/cdi/CdiRep.java 2011-03-20 20:42:04 UTC (rev 1161)
+++ trunk/prototypes/java/src/org/openlcb/cdi/CdiRep.java 2011-03-20 20:42:35 UTC (rev 1162)
@@ -21,11 +21,15 @@
public Identification getIdentification();
- public java.util.List getSegments();
+ public java.util.List<Segment> getSegments();
public static interface Segment {
public int getSpace();
public java.util.List<Item> getItems();
+
+ public String getName();
+ public String getDescription();
+ public Map getMap();
}
public static interface Item {
@@ -41,6 +45,7 @@
public static interface Map {
public String getEntry(String key);
public java.util.List<String> getKeys();
+ public java.util.List<String> getValues();
}
public static interface EventID extends Item {
Modified: trunk/prototypes/java/src/org/openlcb/cdi/jdom/JdomCdiRep.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/cdi/jdom/JdomCdiRep.java 2011-03-20 20:42:04 UTC (rev 1161)
+++ trunk/prototypes/java/src/org/openlcb/cdi/jdom/JdomCdiRep.java 2011-03-20 20:42:35 UTC (rev 1162)
@@ -55,9 +55,9 @@
return new Identification(id);
}
- public java.util.List getSegments() {
+ public java.util.List<CdiRep.Segment> getSegments() {
java.util.List list = root.getChildren("segment");
- java.util.ArrayList result = new java.util.ArrayList();
+ java.util.ArrayList<CdiRep.Segment> result = new java.util.ArrayList<CdiRep.Segment>();
for (int i = 0; i<list.size(); i++) {
result.add(new Segment((Element)list.get(i)));
}
@@ -68,7 +68,35 @@
* Comment implementation of finding the list of contained Items
*/
static class Nested {
- public java.util.List<CdiRep.Item> getItems() { return null; }
+ public String getName() {
+ Element d = e.getChild("name");
+ if (d==null) return null;
+ return d.getText();
+ }
+ public String getDescription() {
+ Element d = e.getChild("description");
+ if (d==null) return null;
+ return d.getText();
+ }
+ public Map getMap() {
+ return new Map(e.getChild("map"));
+ }
+
+ public java.util.List<CdiRep.Item> getItems() {
+ java.util.List<CdiRep.Item> list = new java.util.ArrayList<CdiRep.Item>();
+ if (e == null) return list;
+ java.util.List elements = e.getChildren();
+ for (int i = 0; i<elements.size(); i++) {
+ // some elements aren't contained items
+ Element element = (Element)elements.get(i);
+ if ("group".equals(element.getName())) list.add(new Group(element));
+ else if ("bit".equals(element.getName())) list.add(new Bit(element));
+ else if ("int".equals(element.getName())) list.add(new Int(element));
+ else if ("eventid".equals(element.getName())) list.add(new EventID(element));
+ }
+ return list;
+ }
+
Nested(Element e) { this.e = e; }
Element e;
}
@@ -101,19 +129,39 @@
public java.util.List<String> getKeys() {
java.util.ArrayList<String> list = new java.util.ArrayList<String>();
+ if (map == null) return list;
java.util.List relations = map.getChildren("relation");
+ if (relations == null) return list;
for (int i = 0; i<relations.size(); i++) {
list.add(((Element)relations.get(i)).getChild("property").getText());
}
return list;
}
+ public java.util.List<String> getValues() {
+ java.util.ArrayList<String> list = new java.util.ArrayList<String>();
+ if (map == null) return list;
+ java.util.List relations = map.getChildren("relation");
+ if (relations == null) return list;
+ for (int i = 0; i<relations.size(); i++) {
+ list.add(((Element)relations.get(i)).getChild("value").getText());
+ }
+ return list;
+ }
Element map;
}
public static class Item implements CdiRep.Item {
- public String getName() { return null; }
- public String getDescription() { return null; }
+ public String getName() {
+ Element d = e.getChild("name");
+ if (d==null) return null;
+ return d.getText();
+ }
+ public String getDescription() {
+ Element d = e.getChild("description");
+ if (d==null) return null;
+ return d.getText();
+ }
public Map getMap() {
return new Map(e.getChild("map"));
}
@@ -122,11 +170,6 @@
Element e;
}
public static class Group extends Nested implements CdiRep.Group {
- public String getName() { return null; }
- public String getDescription() { return null; }
- public Map getMap() {
- return new Map(e.getChild("map"));
- }
Group(Element e) { super(e); }
}
Modified: trunk/prototypes/java/test/org/openlcb/cdi/jdom/JdomCdiRepTest.java
===================================================================
--- trunk/prototypes/java/test/org/openlcb/cdi/jdom/JdomCdiRepTest.java 2011-03-20 20:42:04 UTC (rev 1161)
+++ trunk/prototypes/java/test/org/openlcb/cdi/jdom/JdomCdiRepTest.java 2011-03-20 20:42:35 UTC (rev 1162)
@@ -20,15 +20,15 @@
}
public void testGetIdent() {
- CdiRep rep = new JdomCdiRep(getSample());
+ CdiRep rep = new JdomCdiRep(SampleFactory.getBasicSample());
CdiRep.Identification id = rep.getIdentification();
Assert.assertNotNull(id);
- Assert.assertEquals("mfg", "mfg1", id.getManufacturer());
- Assert.assertEquals("model", "mod1", id.getModel());
- Assert.assertEquals("hardware", "hard1", id.getHardwareVersion());
- Assert.assertEquals("software", "soft1", id.getSoftwareVersion());
+ Assert.assertEquals("mfg", "OpenLCB Prototype", id.getManufacturer());
+ Assert.assertEquals("model", "Basic sketch", id.getModel());
+ Assert.assertEquals("hardware", "Arduino (any)", id.getHardwareVersion());
+ Assert.assertEquals("software", "0.4", id.getSoftwareVersion());
}
public void testMap() {
@@ -64,7 +64,7 @@
}
public void testSegments() {
- CdiRep rep = new JdomCdiRep(getSample());
+ CdiRep rep = new JdomCdiRep(SampleFactory.getBasicSample());
java.util.List list = rep.getSegments();
@@ -73,37 +73,33 @@
CdiRep.Segment segment;
segment = (CdiRep.Segment)list.get(0);
Assert.assertNotNull(segment);
- Assert.assertEquals("space", 2, segment.getSpace());
+ Assert.assertEquals("space", 0, segment.getSpace());
+ Assert.assertEquals("name", "Content", segment.getName());
+ Assert.assertEquals("description", "Variables for controlling general operation", segment.getDescription());
segment = (CdiRep.Segment)list.get(1);
Assert.assertNotNull(segment);
- Assert.assertEquals("space", 0, segment.getSpace());
+ Assert.assertEquals("space", 1, segment.getSpace());
+ Assert.assertEquals("name", "Resets", segment.getName());
+ Assert.assertEquals("description", "Memory locations controlling resets", segment.getDescription());
}
-
- // from here down is testing infrastructure
-
- Element getSample() {
- Element root = new Element("cdi");
- root.addContent(
- new Element("identification")
- .addContent(new Element("manufacturer").addContent("mfg1"))
- .addContent(new Element("model").addContent("mod1"))
- .addContent(new Element("hardwareVersion").addContent("hard1"))
- .addContent(new Element("softwareVersion").addContent("soft1"))
- );
+ public void testGroupsInSegments() {
+ CdiRep rep = new JdomCdiRep(SampleFactory.getBasicSample());
- root.addContent(
- new Element("segment").setAttribute("space","2")
- );
-
- root.addContent(
- new Element("segment")
- );
-
- return root;
+ java.util.List list = rep.getSegments();
+
+ Assert.assertEquals("len", 2, list.size());
+
+ CdiRep.Segment segment;
+ segment = (CdiRep.Segment)list.get(0);
+ Assert.assertNotNull(segment);
+
+ java.util.List<CdiRep.Item> items = segment.getItems();
+ Assert.assertNotNull(items);
+ Assert.assertEquals("contents length",3,items.size());
}
-
+
public JdomCdiRepTest(String s) {
super(s);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jac...@us...> - 2011-03-20 20:52:40
|
Revision: 1165
http://openlcb.svn.sourceforge.net/openlcb/?rev=1165&view=rev
Author: jacobsen
Date: 2011-03-20 20:52:35 +0000 (Sun, 20 Mar 2011)
Log Message:
-----------
version 0.4
Modified Paths:
--------------
trunk/prototypes/java/manifest
trunk/prototypes/java/src/overview.html
Modified: trunk/prototypes/java/manifest
===================================================================
--- trunk/prototypes/java/manifest 2011-03-20 20:51:55 UTC (rev 1164)
+++ trunk/prototypes/java/manifest 2011-03-20 20:52:35 UTC (rev 1165)
@@ -4,9 +4,9 @@
Name: org.openlcb
Specification-Title: \xD2OpenLCB\xD3
-Specification-Version: \xD20.3\xD3
+Specification-Version: \xD20.4\xD3
Specification-Vendor: \xD2OpenLCB group"
Package-Title: \xD2openlcb\xD3
-Package-Version: \xD20.3\xD3
+Package-Version: \xD20.4\xD3
Package-Vendor: \xD2OpenLCB group\xD3
Modified: trunk/prototypes/java/src/overview.html
===================================================================
--- trunk/prototypes/java/src/overview.html 2011-03-20 20:51:55 UTC (rev 1164)
+++ trunk/prototypes/java/src/overview.html 2011-03-20 20:52:35 UTC (rev 1165)
@@ -17,7 +17,7 @@
OpenLCB sample and test implementations.
<p>
-These are the JavaDocs for the 0.3 version of the OpenLCB library.
+These are the JavaDocs for the 0.4 version of the OpenLCB library.
<p>
This software is copyrighted by its authors,
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jac...@us...> - 2011-03-20 20:54:06
|
Revision: 1168
http://openlcb.svn.sourceforge.net/openlcb/?rev=1168&view=rev
Author: jacobsen
Date: 2011-03-20 20:54:00 +0000 (Sun, 20 Mar 2011)
Log Message:
-----------
version 0.4
Modified Paths:
--------------
trunk/prototypes/java/openlcb-demo.jar
trunk/prototypes/java/openlcb.jar
Modified: trunk/prototypes/java/openlcb-demo.jar
===================================================================
(Binary files differ)
Modified: trunk/prototypes/java/openlcb.jar
===================================================================
(Binary files differ)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jac...@us...> - 2011-03-22 04:45:56
|
Revision: 1169
http://openlcb.svn.sourceforge.net/openlcb/?rev=1169&view=rev
Author: jacobsen
Date: 2011-03-22 04:45:50 +0000 (Tue, 22 Mar 2011)
Log Message:
-----------
add replicated groups
Modified Paths:
--------------
trunk/prototypes/java/src/org/openlcb/cdi/CdiRep.java
trunk/prototypes/java/src/org/openlcb/cdi/jdom/JdomCdiRep.java
trunk/prototypes/java/src/org/openlcb/cdi/swing/CdiPanel.java
trunk/prototypes/java/test/org/openlcb/cdi/jdom/JdomCdiRepTest.java
trunk/prototypes/java/test/org/openlcb/cdi/jdom/SampleFactory.java
Modified: trunk/prototypes/java/src/org/openlcb/cdi/CdiRep.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/cdi/CdiRep.java 2011-03-20 20:54:00 UTC (rev 1168)
+++ trunk/prototypes/java/src/org/openlcb/cdi/CdiRep.java 2011-03-22 04:45:50 UTC (rev 1169)
@@ -40,6 +40,7 @@
public static interface Group extends Item {
public java.util.List<Item> getItems();
+ public int getReplication();
}
public static interface Map {
Modified: trunk/prototypes/java/src/org/openlcb/cdi/jdom/JdomCdiRep.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/cdi/jdom/JdomCdiRep.java 2011-03-20 20:54:00 UTC (rev 1168)
+++ trunk/prototypes/java/src/org/openlcb/cdi/jdom/JdomCdiRep.java 2011-03-22 04:45:50 UTC (rev 1169)
@@ -170,6 +170,13 @@
Element e;
}
public static class Group extends Nested implements CdiRep.Group {
+ public int getReplication() {
+ Attribute a = e.getAttribute("replication");
+ try {
+ if (a == null) return 0;
+ else return a.getIntValue();
+ } catch (org.jdom.DataConversionException e) { return 0; }
+ }
Group(Element e) { super(e); }
}
Modified: trunk/prototypes/java/src/org/openlcb/cdi/swing/CdiPanel.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/cdi/swing/CdiPanel.java 2011-03-20 20:54:00 UTC (rev 1168)
+++ trunk/prototypes/java/src/org/openlcb/cdi/swing/CdiPanel.java 2011-03-22 04:45:50 UTC (rev 1169)
@@ -148,18 +148,23 @@
JPanel p2 = createPropertyPane(item.getMap());
if (p2!=null) p.add(p2);
- // find and process items
- java.util.List<CdiRep.Item> items = item.getItems();
- if (items != null) {
- for (int i=0; i<items.size(); i++) {
- CdiRep.Item it = (CdiRep.Item) items.get(i);
- if (it instanceof CdiRep.Group) p.add(createGroupPane((CdiRep.Group)it));
- else if (it instanceof CdiRep.Bit) p.add(createBitPane((CdiRep.Bit)it));
- else if (it instanceof CdiRep.Int) p.add(createIntPane((CdiRep.Int)it));
- else if (it instanceof CdiRep.EventID) p.add(createEventIdPane((CdiRep.EventID)it));
+ // find and process items as replicated
+ int rep = item.getReplication();
+ if (rep == 0) rep = 1; // default
+
+ for (int i = 0; i < rep; i++) {
+ java.util.List<CdiRep.Item> items = item.getItems();
+ if (items != null) {
+ for (int j=0; j<items.size(); j++) {
+ CdiRep.Item it = (CdiRep.Item) items.get(j);
+ if (it instanceof CdiRep.Group) p.add(createGroupPane((CdiRep.Group)it));
+ else if (it instanceof CdiRep.Bit) p.add(createBitPane((CdiRep.Bit)it));
+ else if (it instanceof CdiRep.Int) p.add(createIntPane((CdiRep.Int)it));
+ else if (it instanceof CdiRep.EventID) p.add(createEventIdPane((CdiRep.EventID)it));
+ }
}
}
-
+
return p;
}
@@ -235,7 +240,7 @@
// see if map is present
String[] labels;
CdiRep.Map map = item.getMap();
- if ((map != null) && (map.getKeys().size()>=0)) {
+ if ((map != null) && (map.getKeys().size()>0)) {
// map present, make selection box
p3.add(new JComboBox(map.getValues().toArray(new String[]{""})));
} else {
Modified: trunk/prototypes/java/test/org/openlcb/cdi/jdom/JdomCdiRepTest.java
===================================================================
--- trunk/prototypes/java/test/org/openlcb/cdi/jdom/JdomCdiRepTest.java 2011-03-20 20:54:00 UTC (rev 1168)
+++ trunk/prototypes/java/test/org/openlcb/cdi/jdom/JdomCdiRepTest.java 2011-03-22 04:45:50 UTC (rev 1169)
@@ -68,7 +68,7 @@
java.util.List list = rep.getSegments();
- Assert.assertEquals("len", 2, list.size());
+ Assert.assertEquals("len", 3, list.size());
CdiRep.Segment segment;
segment = (CdiRep.Segment)list.get(0);
@@ -89,7 +89,7 @@
java.util.List list = rep.getSegments();
- Assert.assertEquals("len", 2, list.size());
+ Assert.assertEquals("len", 3, list.size());
CdiRep.Segment segment;
segment = (CdiRep.Segment)list.get(0);
Modified: trunk/prototypes/java/test/org/openlcb/cdi/jdom/SampleFactory.java
===================================================================
--- trunk/prototypes/java/test/org/openlcb/cdi/jdom/SampleFactory.java 2011-03-20 20:54:00 UTC (rev 1168)
+++ trunk/prototypes/java/test/org/openlcb/cdi/jdom/SampleFactory.java 2011-03-22 04:45:50 UTC (rev 1169)
@@ -105,6 +105,24 @@
)
);
+ root.addContent(
+ new Element("segment").setAttribute("space","3").setAttribute("origin","0")
+ .addContent(new Element("name").addContent("Demos"))
+ .addContent(new Element("description").addContent("Demonstrations of various CDI capabilities"))
+ .addContent(new Element("group").setAttribute("replication","2")
+ .addContent(new Element("name").addContent("Outer Group"))
+ .addContent(new Element("description").addContent("The contents of this group are replicated by 2"))
+ .addContent(new Element("group").setAttribute("replication","3")
+ .addContent(new Element("name").addContent("Inner Group"))
+ .addContent(new Element("description").addContent("The contents of this group are replicated by 3"))
+ .addContent(new Element("int").setAttribute("size","1")
+ .addContent(new Element("name").addContent("Int inside groups"))
+ .addContent(new Element("description").addContent("This is inside a 2x3 group"))
+ )
+ )
+ )
+ );
+
return root;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jac...@us...> - 2011-03-22 05:46:43
|
Revision: 1170
http://openlcb.svn.sourceforge.net/openlcb/?rev=1170&view=rev
Author: jacobsen
Date: 2011-03-22 05:46:37 +0000 (Tue, 22 Mar 2011)
Log Message:
-----------
with rep groups
Modified Paths:
--------------
trunk/prototypes/java/openlcb-demo.jar
trunk/prototypes/java/openlcb.jar
Modified: trunk/prototypes/java/openlcb-demo.jar
===================================================================
(Binary files differ)
Modified: trunk/prototypes/java/openlcb.jar
===================================================================
(Binary files differ)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|