|
From: <jac...@us...> - 2009-11-09 06:05:43
|
Revision: 124
http://openlcb.svn.sourceforge.net/openlcb/?rev=124&view=rev
Author: jacobsen
Date: 2009-11-09 06:05:33 +0000 (Mon, 09 Nov 2009)
Log Message:
-----------
tests run with 21bit
Modified Paths:
--------------
trunk/prototypes/java/src/org/nmra/net/can/NIDa.java
trunk/prototypes/java/src/org/nmra/net/can/NIDaAlgorithm.java
trunk/prototypes/java/src/org/nmra/net/can/NmraNetCanFrame.java
trunk/prototypes/java/test/org/nmra/net/can/NIDaAlgorithmTest.java
trunk/prototypes/java/test/org/nmra/net/can/NIDaTest.java
Modified: trunk/prototypes/java/src/org/nmra/net/can/NIDa.java
===================================================================
--- trunk/prototypes/java/src/org/nmra/net/can/NIDa.java 2009-11-09 06:02:43 UTC (rev 123)
+++ trunk/prototypes/java/src/org/nmra/net/can/NIDa.java 2009-11-09 06:05:33 UTC (rev 124)
@@ -67,21 +67,12 @@
this.nid = nid;
byte[] id = this.nid.getContents();
- // simplest starting point
- //reg = id[0]+id[1]+id[2]+id[3]+id[4]+id[5];
-
- // prototype v1
- reg = id[0] ^ id[1] <<5 ^ id[2] <<10 ^ id[3] <<15 ^ id[4] << 20 ^ id[5] << 24;
- if (reg == 0)
- reg = ( id[0] << 23)+(id[1] << 19)+(id[2] << 15)+(id[3] << 11)+(id[4] << 7)+id[5];
- if (reg == 0)
- reg = 0xAC01;
-
- // prototype v2
- reg = id[0] ^ (id[1] <<5) ^ (id[2] <<10) ^ (id[3] <<15)
- ^ (id[4] << 20) ^ (id[5] << 24)
- ^ ((id[3]^id[4]^id[5])<<8);
-
+ 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);
}
/**
@@ -89,34 +80,22 @@
*/
protected void stepGenerator() {
- // 16-bit shift register PRNG algorithm from e.g.
- // <a href="http://en.wikipedia.org/wiki/Linear_feedback_shift_register">Wikipedia Linear Feedback Shift Register</a> page.
- //long bit = (reg & 0x0001) ^
- // ((reg & 0x0004) >> 2) ^
- // ((reg & 0x0008) >> 3) ^
- // ((reg & 0x0020) >> 5);
- //reg = (reg >> 1) | (bit << 15);
-
- // prototype V1
- // see <http://en.wikipedia.org/wiki/Linear_feedback_shift_register> example 2
- reg = (reg >> 1) ^ (-(reg & 1) & 0xd0000001);
+ // See H G Kuehn, CACM 8/1961
+ reg = ( (512+1)*reg + 0x1B0CA37A4BA9L)
+ & 0xFFFFFFFFFFFFL;
}
/**
* Reduce the current generator value to an alias value.
*/
protected int computeAliasFromGenerator() {
- int retval;
- // just return low bits, but force non-zero
- //retval = (int) (reg & 0xFFFF);
- //if (retval == 0) retval = 1;
+ int s1 = (int)reg&0xFFFFFF;
+ int s2 = (int)(reg>>12)&0xFFFFFF;
+ int s3 = (int)(reg>>24)&0xFFFFFF;
+ int s4 = (int)(reg>>36)&0xFFFFFF;
- // merge 32 bits to just 16
- retval = (int) ( (reg ^ (reg >>16) ) & 0xFFFF);
- if (retval == 0) retval = 1;
-
- return retval;
+ return s1^s2^s3^s4;
}
// Generator state register
Modified: trunk/prototypes/java/src/org/nmra/net/can/NIDaAlgorithm.java
===================================================================
--- trunk/prototypes/java/src/org/nmra/net/can/NIDaAlgorithm.java 2009-11-09 06:02:43 UTC (rev 123)
+++ trunk/prototypes/java/src/org/nmra/net/can/NIDaAlgorithm.java 2009-11-09 06:05:33 UTC (rev 124)
@@ -37,7 +37,10 @@
public void processFrame(NmraNetCanFrame f) {
if (f == null) return; // as a convenience, ignore
-
+
+ // System.out.println("process "+Integer.toHexString(f.getNodeIDa())
+ // +" vs our "+Integer.toHexString(nida.getNIDa()));
+
if (f.getNodeIDa() != nida.getNIDa()) return; // not us
if (f.isCIM() || f.isRIM()) {
// CIM or RIM with our alias
Modified: trunk/prototypes/java/src/org/nmra/net/can/NmraNetCanFrame.java
===================================================================
--- trunk/prototypes/java/src/org/nmra/net/can/NmraNetCanFrame.java 2009-11-09 06:02:43 UTC (rev 123)
+++ trunk/prototypes/java/src/org/nmra/net/can/NmraNetCanFrame.java 2009-11-09 06:05:33 UTC (rev 124)
@@ -15,17 +15,17 @@
public class NmraNetCanFrame implements org.nmra.net.can.CanFrame {
public static NmraNetCanFrame makeCimFrame(int alias, int num, int val) {
- return new NmraNetCanFrame( (0<<26) | (alias&0xffff));
+ return new NmraNetCanFrame( (0<<26) | (alias&0xffffff));
}
public static NmraNetCanFrame makeRimFrame(int alias, NodeID n) {
- return new NmraNetCanFrame( (1<<26) | (alias&0xffff),
+ return new NmraNetCanFrame( (1<<26) | (alias&0xffffff),
n.getContents());
}
static int makeHeader(int alias) {
return
- (alias&0xFFFF);
+ (alias&0xFFFFFF);
}
// data is stored in completed form as
@@ -78,7 +78,7 @@
public long getHeader() { return header; }
- public int getNodeIDa() { return (int)getHeader()&0xFFFF; }
+ public int getNodeIDa() { return (int)getHeader()&0xFFFFFF; }
public boolean isCIM() { return (getTypeField() == TypeField.CHECKIDMESSAGE); }
public boolean isRIM() { return (getTypeField() == TypeField.RESERVEDIDMESSAGE); }
@@ -100,5 +100,12 @@
return false;
}
}
-
+
+ public String toString() {
+ return "Type: "+getTypeField()
+ + " NIDa: "+getNodeIDa()
+ + " isCIM: "+isCIM()
+ + " isRIM: "+isRIM();
+
+ }
}
Modified: trunk/prototypes/java/test/org/nmra/net/can/NIDaAlgorithmTest.java
===================================================================
--- trunk/prototypes/java/test/org/nmra/net/can/NIDaAlgorithmTest.java 2009-11-09 06:02:43 UTC (rev 123)
+++ trunk/prototypes/java/test/org/nmra/net/can/NIDaAlgorithmTest.java 2009-11-09 06:05:33 UTC (rev 124)
@@ -77,7 +77,7 @@
// start
Assert.assertTrue((f = alg.nextFrame()).isCIM());
- // conflict
+ // inject conflict
alg.processFrame(NmraNetCanFrame.makeCimFrame(f.getNodeIDa(), 0, 0));
// seventh frame after now is RIM
@@ -111,7 +111,7 @@
Assert.assertEquals((f = alg.nextFrame()), null);
- // conflict
+ // inject conflict
alg.processFrame(NmraNetCanFrame.makeCimFrame(nida, 0, 0));
// still active
Modified: trunk/prototypes/java/test/org/nmra/net/can/NIDaTest.java
===================================================================
--- trunk/prototypes/java/test/org/nmra/net/can/NIDaTest.java 2009-11-09 06:02:43 UTC (rev 123)
+++ trunk/prototypes/java/test/org/nmra/net/can/NIDaTest.java 2009-11-09 06:05:33 UTC (rev 124)
@@ -40,7 +40,15 @@
last = na.getNIDa();
Assert.assertTrue("5", first!=last);
}
-
+
+ // print the first few from a zero seed, not normally done
+ public void XtestListValues() {
+ for (int i = 0; i< 200; i++) {
+ System.out.println("0x"+Integer.toHexString(na.getNIDa()));
+ na.nextAlias();
+ }
+ }
+
// test takes a couple minutes, not normally done
public void XtestAltPRNG() {
// http://en.wikipedia.org/wiki/Linear_feedback_shift_register
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jac...@us...> - 2009-11-09 06:05:43
|
Revision: 124
http://openlcb.svn.sourceforge.net/openlcb/?rev=124&view=rev
Author: jacobsen
Date: 2009-11-09 06:05:33 +0000 (Mon, 09 Nov 2009)
Log Message:
-----------
tests run with 21bit
Modified Paths:
--------------
trunk/prototypes/java/src/org/nmra/net/can/NIDa.java
trunk/prototypes/java/src/org/nmra/net/can/NIDaAlgorithm.java
trunk/prototypes/java/src/org/nmra/net/can/NmraNetCanFrame.java
trunk/prototypes/java/test/org/nmra/net/can/NIDaAlgorithmTest.java
trunk/prototypes/java/test/org/nmra/net/can/NIDaTest.java
Modified: trunk/prototypes/java/src/org/nmra/net/can/NIDa.java
===================================================================
--- trunk/prototypes/java/src/org/nmra/net/can/NIDa.java 2009-11-09 06:02:43 UTC (rev 123)
+++ trunk/prototypes/java/src/org/nmra/net/can/NIDa.java 2009-11-09 06:05:33 UTC (rev 124)
@@ -67,21 +67,12 @@
this.nid = nid;
byte[] id = this.nid.getContents();
- // simplest starting point
- //reg = id[0]+id[1]+id[2]+id[3]+id[4]+id[5];
-
- // prototype v1
- reg = id[0] ^ id[1] <<5 ^ id[2] <<10 ^ id[3] <<15 ^ id[4] << 20 ^ id[5] << 24;
- if (reg == 0)
- reg = ( id[0] << 23)+(id[1] << 19)+(id[2] << 15)+(id[3] << 11)+(id[4] << 7)+id[5];
- if (reg == 0)
- reg = 0xAC01;
-
- // prototype v2
- reg = id[0] ^ (id[1] <<5) ^ (id[2] <<10) ^ (id[3] <<15)
- ^ (id[4] << 20) ^ (id[5] << 24)
- ^ ((id[3]^id[4]^id[5])<<8);
-
+ 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);
}
/**
@@ -89,34 +80,22 @@
*/
protected void stepGenerator() {
- // 16-bit shift register PRNG algorithm from e.g.
- // <a href="http://en.wikipedia.org/wiki/Linear_feedback_shift_register">Wikipedia Linear Feedback Shift Register</a> page.
- //long bit = (reg & 0x0001) ^
- // ((reg & 0x0004) >> 2) ^
- // ((reg & 0x0008) >> 3) ^
- // ((reg & 0x0020) >> 5);
- //reg = (reg >> 1) | (bit << 15);
-
- // prototype V1
- // see <http://en.wikipedia.org/wiki/Linear_feedback_shift_register> example 2
- reg = (reg >> 1) ^ (-(reg & 1) & 0xd0000001);
+ // See H G Kuehn, CACM 8/1961
+ reg = ( (512+1)*reg + 0x1B0CA37A4BA9L)
+ & 0xFFFFFFFFFFFFL;
}
/**
* Reduce the current generator value to an alias value.
*/
protected int computeAliasFromGenerator() {
- int retval;
- // just return low bits, but force non-zero
- //retval = (int) (reg & 0xFFFF);
- //if (retval == 0) retval = 1;
+ int s1 = (int)reg&0xFFFFFF;
+ int s2 = (int)(reg>>12)&0xFFFFFF;
+ int s3 = (int)(reg>>24)&0xFFFFFF;
+ int s4 = (int)(reg>>36)&0xFFFFFF;
- // merge 32 bits to just 16
- retval = (int) ( (reg ^ (reg >>16) ) & 0xFFFF);
- if (retval == 0) retval = 1;
-
- return retval;
+ return s1^s2^s3^s4;
}
// Generator state register
Modified: trunk/prototypes/java/src/org/nmra/net/can/NIDaAlgorithm.java
===================================================================
--- trunk/prototypes/java/src/org/nmra/net/can/NIDaAlgorithm.java 2009-11-09 06:02:43 UTC (rev 123)
+++ trunk/prototypes/java/src/org/nmra/net/can/NIDaAlgorithm.java 2009-11-09 06:05:33 UTC (rev 124)
@@ -37,7 +37,10 @@
public void processFrame(NmraNetCanFrame f) {
if (f == null) return; // as a convenience, ignore
-
+
+ // System.out.println("process "+Integer.toHexString(f.getNodeIDa())
+ // +" vs our "+Integer.toHexString(nida.getNIDa()));
+
if (f.getNodeIDa() != nida.getNIDa()) return; // not us
if (f.isCIM() || f.isRIM()) {
// CIM or RIM with our alias
Modified: trunk/prototypes/java/src/org/nmra/net/can/NmraNetCanFrame.java
===================================================================
--- trunk/prototypes/java/src/org/nmra/net/can/NmraNetCanFrame.java 2009-11-09 06:02:43 UTC (rev 123)
+++ trunk/prototypes/java/src/org/nmra/net/can/NmraNetCanFrame.java 2009-11-09 06:05:33 UTC (rev 124)
@@ -15,17 +15,17 @@
public class NmraNetCanFrame implements org.nmra.net.can.CanFrame {
public static NmraNetCanFrame makeCimFrame(int alias, int num, int val) {
- return new NmraNetCanFrame( (0<<26) | (alias&0xffff));
+ return new NmraNetCanFrame( (0<<26) | (alias&0xffffff));
}
public static NmraNetCanFrame makeRimFrame(int alias, NodeID n) {
- return new NmraNetCanFrame( (1<<26) | (alias&0xffff),
+ return new NmraNetCanFrame( (1<<26) | (alias&0xffffff),
n.getContents());
}
static int makeHeader(int alias) {
return
- (alias&0xFFFF);
+ (alias&0xFFFFFF);
}
// data is stored in completed form as
@@ -78,7 +78,7 @@
public long getHeader() { return header; }
- public int getNodeIDa() { return (int)getHeader()&0xFFFF; }
+ public int getNodeIDa() { return (int)getHeader()&0xFFFFFF; }
public boolean isCIM() { return (getTypeField() == TypeField.CHECKIDMESSAGE); }
public boolean isRIM() { return (getTypeField() == TypeField.RESERVEDIDMESSAGE); }
@@ -100,5 +100,12 @@
return false;
}
}
-
+
+ public String toString() {
+ return "Type: "+getTypeField()
+ + " NIDa: "+getNodeIDa()
+ + " isCIM: "+isCIM()
+ + " isRIM: "+isRIM();
+
+ }
}
Modified: trunk/prototypes/java/test/org/nmra/net/can/NIDaAlgorithmTest.java
===================================================================
--- trunk/prototypes/java/test/org/nmra/net/can/NIDaAlgorithmTest.java 2009-11-09 06:02:43 UTC (rev 123)
+++ trunk/prototypes/java/test/org/nmra/net/can/NIDaAlgorithmTest.java 2009-11-09 06:05:33 UTC (rev 124)
@@ -77,7 +77,7 @@
// start
Assert.assertTrue((f = alg.nextFrame()).isCIM());
- // conflict
+ // inject conflict
alg.processFrame(NmraNetCanFrame.makeCimFrame(f.getNodeIDa(), 0, 0));
// seventh frame after now is RIM
@@ -111,7 +111,7 @@
Assert.assertEquals((f = alg.nextFrame()), null);
- // conflict
+ // inject conflict
alg.processFrame(NmraNetCanFrame.makeCimFrame(nida, 0, 0));
// still active
Modified: trunk/prototypes/java/test/org/nmra/net/can/NIDaTest.java
===================================================================
--- trunk/prototypes/java/test/org/nmra/net/can/NIDaTest.java 2009-11-09 06:02:43 UTC (rev 123)
+++ trunk/prototypes/java/test/org/nmra/net/can/NIDaTest.java 2009-11-09 06:05:33 UTC (rev 124)
@@ -40,7 +40,15 @@
last = na.getNIDa();
Assert.assertTrue("5", first!=last);
}
-
+
+ // print the first few from a zero seed, not normally done
+ public void XtestListValues() {
+ for (int i = 0; i< 200; i++) {
+ System.out.println("0x"+Integer.toHexString(na.getNIDa()));
+ na.nextAlias();
+ }
+ }
+
// test takes a couple minutes, not normally done
public void XtestAltPRNG() {
// http://en.wikipedia.org/wiki/Linear_feedback_shift_register
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jac...@us...> - 2011-03-20 17:51:11
|
Revision: 1156
http://openlcb.svn.sourceforge.net/openlcb/?rev=1156&view=rev
Author: jacobsen
Date: 2011-03-20 17:51:05 +0000 (Sun, 20 Mar 2011)
Log Message:
-----------
2nd rev of CDI demo applet, identification OK, segments not yet
Modified Paths:
--------------
trunk/prototypes/java/test/org/openlcb/NetTest.java
trunk/prototypes/java/test/scenarios/ConfigDemoApplet.java
trunk/prototypes/java/test/scenarios/Scenarios.java
Added Paths:
-----------
trunk/prototypes/java/src/org/openlcb/cdi/
trunk/prototypes/java/src/org/openlcb/cdi/CdiRep.java
trunk/prototypes/java/src/org/openlcb/cdi/jdom/
trunk/prototypes/java/src/org/openlcb/cdi/jdom/JdomCdiReader.java
trunk/prototypes/java/src/org/openlcb/cdi/jdom/JdomCdiRep.java
trunk/prototypes/java/src/org/openlcb/cdi/swing/
trunk/prototypes/java/src/org/openlcb/cdi/swing/CdiPanel.java
trunk/prototypes/java/src/org/openlcb/jdom/
trunk/prototypes/java/test/org/openlcb/cdi/
trunk/prototypes/java/test/org/openlcb/cdi/PackageTest.java
trunk/prototypes/java/test/org/openlcb/cdi/jdom/
trunk/prototypes/java/test/org/openlcb/cdi/jdom/JdomCdiRepTest.java
trunk/prototypes/java/test/org/openlcb/cdi/jdom/PackageTest.java
trunk/prototypes/java/test/org/openlcb/cdi/jdom/SampleFactory.java
trunk/prototypes/java/test/scenarios/cdi/
trunk/prototypes/java/test/scenarios/cdi/swing/
Added: trunk/prototypes/java/src/org/openlcb/cdi/CdiRep.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/cdi/CdiRep.java (rev 0)
+++ trunk/prototypes/java/src/org/openlcb/cdi/CdiRep.java 2011-03-20 17:51:05 UTC (rev 1156)
@@ -0,0 +1,57 @@
+package org.openlcb.cdi;
+
+/**
+ * Interface representing CDI information.
+ * <p>
+ * Generally, the CDI XML will be read into an
+ * object implementing this interface.
+ *
+ * @author Bob Jacobsen Copyright 2011
+ * @version $Revision: -1 $
+ */
+public interface CdiRep {
+
+ public static interface Identification {
+ public String getManufacturer();
+ public String getModel();
+ public String getHardwareVersion();
+ public String getSoftwareVersion();
+ public Map getMap();
+ }
+
+ public Identification getIdentification();
+
+ public java.util.List getSegments();
+
+ public static interface Segment {
+ public int getSpace();
+ public java.util.List<Item> getItems();
+ }
+
+ public static interface Item {
+ public String getName();
+ public String getDescription();
+ public Map getMap();
+ }
+
+ public static interface Group extends Item {
+ public java.util.List<Item> getItems();
+ }
+
+ public static interface Map {
+ public String getEntry(String key);
+ public java.util.List<String> getKeys();
+ }
+
+ public static interface EventID extends Item {
+ }
+ public static interface Int extends Item {
+ public int getDefault();
+ public int getMin();
+ public int getMax();
+ }
+ public static interface Bit extends Item {
+ public boolean getDefault();
+ }
+
+}
Added: trunk/prototypes/java/src/org/openlcb/cdi/jdom/JdomCdiReader.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/cdi/jdom/JdomCdiReader.java (rev 0)
+++ trunk/prototypes/java/src/org/openlcb/cdi/jdom/JdomCdiReader.java 2011-03-20 17:51:05 UTC (rev 1156)
@@ -0,0 +1,52 @@
+package org.openlcb.cdi.jdom;
+
+import org.openlcb.cdi.*;
+
+import java.io.*;
+import org.jdom.*;
+import org.jdom.input.SAXBuilder;
+
+/**
+ * JDOM-based OpenLCB loader
+ *
+ * @author Bob Jacobsen Copyright 2011
+ * @version $Revision: -1 $
+ */
+public class JdomCdiReader {
+
+ Element getHeadFromReader(Reader rdr) throws Exception {
+ SAXBuilder builder = new SAXBuilder("org.apache.xerces.parsers.SAXParser",false); // argument controls validation
+
+ //builder.setEntityResolver(new jmri.util.JmriLocalEntityResolver());
+ builder.setFeature("http://apache.org/xml/features/xinclude", true);
+ builder.setFeature("http://apache.org/xml/features/xinclude/fixup-base-uris", false);
+
+ // for schema validation. Not needed for DTDs, so continue if not found now
+ try {
+ builder.setFeature("http://apache.org/xml/features/validation/schema", false);
+ builder.setFeature("http://apache.org/xml/features/validation/schema-full-checking", false);
+
+ // parse namespaces, including the noNamespaceSchema
+ builder.setFeature("http://xml.org/sax/features/namespaces", true);
+
+ } catch (Exception e) {
+ System.err.println("Could not set schema validation feature: "+e);
+ }
+
+ Document doc;
+ try {
+ doc = builder.build(rdr);
+ return doc.getRootElement();
+ } catch (JDOMException e) {
+ System.err.println("Could not create Document: "+e);
+ throw new Exception(e);
+ } catch (IOException e) {
+ System.err.println("Could not create Document: "+e);
+ throw new Exception(e);
+ }
+ }
+
+ public CdiRep getRep(Element root) {
+ return new JdomCdiRep(root);
+ }
+}
Added: trunk/prototypes/java/src/org/openlcb/cdi/jdom/JdomCdiRep.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/cdi/jdom/JdomCdiRep.java (rev 0)
+++ trunk/prototypes/java/src/org/openlcb/cdi/jdom/JdomCdiRep.java 2011-03-20 17:51:05 UTC (rev 1156)
@@ -0,0 +1,150 @@
+package org.openlcb.cdi.jdom;
+
+import org.openlcb.cdi.CdiRep;
+
+import org.jdom.*;
+
+/**
+ * Implement the CdiRep interface using
+ * JDOM for reading the underlying XML.
+ *
+ * @author Bob Jacobsen Copyright 2011
+ * @version $Revision: -1 $
+ */
+public class JdomCdiRep implements CdiRep {
+
+ public JdomCdiRep(Element root) {
+ this.root = root;
+ }
+
+ public static class Identification implements CdiRep.Identification {
+ public String getManufacturer() {
+ Element c = id.getChild("manufacturer");
+ if (c == null) return null;
+ return c.getText();
+ }
+ public String getModel() {
+ Element c = id.getChild("model");
+ if (c == null) return null;
+ return c.getText();
+ }
+ public String getHardwareVersion() {
+ Element c = id.getChild("hardwareVersion");
+ if (c == null) return null;
+ return c.getText();
+ }
+ public String getSoftwareVersion() {
+ Element c = id.getChild("softwareVersion");
+ if (c == null) return null;
+ return c.getText();
+ }
+
+ public Map getMap() {
+ return new Map(id.getChild("map"));
+ }
+
+ Identification(Element id) {
+ this.id = id;
+ }
+ Element id;
+ }
+
+ public Identification getIdentification() {
+ Element id = root.getChild("identification");
+ if (id == null) return null;
+ return new Identification(id);
+ }
+
+ public java.util.List getSegments() {
+ java.util.List list = root.getChildren("segment");
+ java.util.ArrayList result = new java.util.ArrayList();
+ for (int i = 0; i<list.size(); i++) {
+ result.add(new Segment((Element)list.get(i)));
+ }
+ return result;
+ }
+
+ /**
+ * Comment implementation of finding the list of contained Items
+ */
+ static class Nested {
+ public java.util.List<CdiRep.Item> getItems() { return null; }
+ Nested(Element e) { this.e = e; }
+ Element e;
+ }
+
+ public static class Segment extends Nested implements CdiRep.Segment {
+ public int getSpace() {
+ Attribute a = e.getAttribute("space");
+ try {
+ if (a == null) return 0;
+ else return a.getIntValue();
+ } catch (org.jdom.DataConversionException e) { return 0; }
+ }
+
+ Segment(Element segment) { super(segment); }
+ }
+
+ public static class Map implements CdiRep.Map {
+ Map(Element map) {
+ this.map = map;
+ }
+
+ public String getEntry(String key) {
+ java.util.List relations = map.getChildren("relation");
+ for (int i = 0; i<relations.size(); i++) {
+ if (key.equals(((Element)relations.get(i)).getChild("property").getText()) )
+ return ((Element)relations.get(i)).getChild("value").getText();
+ }
+ return null;
+ }
+
+ public java.util.List<String> getKeys() {
+ java.util.ArrayList<String> list = new java.util.ArrayList<String>();
+ java.util.List relations = map.getChildren("relation");
+ for (int i = 0; i<relations.size(); i++) {
+ list.add(((Element)relations.get(i)).getChild("property").getText());
+ }
+ return list;
+ }
+
+ Element map;
+ }
+
+ public static class Item implements CdiRep.Item {
+ public String getName() { return null; }
+ public String getDescription() { return null; }
+ public Map getMap() {
+ return new Map(e.getChild("map"));
+ }
+
+ Item(Element e) { this.e = e; }
+ 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); }
+ }
+ public static class EventID extends Item implements CdiRep.EventID {
+ EventID(Element e) { super(e); }
+ }
+ public static class Int extends Item implements CdiRep.Int {
+ public int getDefault() { return 0; }
+ public int getMin() { return 0; }
+ public int getMax() { return 0; }
+
+ Int(Element e) { super(e); }
+ }
+ public static class Bit extends Item implements CdiRep.Bit {
+ public boolean getDefault() { return false; }
+
+ Bit(Element e) { super(e); }
+ }
+
+ Element root;
+}
Added: trunk/prototypes/java/src/org/openlcb/cdi/swing/CdiPanel.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/cdi/swing/CdiPanel.java (rev 0)
+++ trunk/prototypes/java/src/org/openlcb/cdi/swing/CdiPanel.java 2011-03-20 17:51:05 UTC (rev 1156)
@@ -0,0 +1,78 @@
+package org.openlcb.cdi.swing;
+
+import javax.swing.*;
+import java.awt.*;
+
+import org.openlcb.cdi.CdiRep;
+
+/**
+ * Simple example CDI display.
+ *
+ * Works with a CDI reader.
+ *
+ * @author Bob Jacobsen Copyright 2011
+ * @version $Revision: -1 $
+ */
+public class CdiPanel extends JPanel {
+
+ public CdiPanel () { super(); }
+
+ public void initComponents() {
+ setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
+ }
+
+ public void loadCDI(CdiRep c) {
+ add(createIdentificationPane(c));
+ }
+
+ JPanel createIdentificationPane(CdiRep c) {
+ JPanel p = new JPanel();
+ p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
+ p.setBorder(BorderFactory.createTitledBorder("Identification"));
+
+ JPanel p1;
+
+ p1 = new JPanel();
+ p1.setLayout(new FlowLayout());
+ p.add(p1);
+ p1.add(new JLabel("Manufacturer: "));
+ p1.add(new JLabel(c.getIdentification().getManufacturer()));
+
+ p1 = new JPanel();
+ p1.setLayout(new FlowLayout());
+ p.add(p1);
+ p1.add(new JLabel("Model: "));
+ p1.add(new JLabel(c.getIdentification().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 = new JPanel();
+ p1.setLayout(new FlowLayout());
+ p.add(p1);
+ p1.add(new JLabel("Software Version: "));
+ p1.add(new JLabel(c.getIdentification().getSoftwareVersion()));
+
+ // include map if present
+
+ CdiRep.Map map = c.getIdentification().getMap();
+ if (map != null) {
+ java.util.List keys = map.getKeys();
+ 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)));
+
+ }
+ }
+
+ return p;
+ }
+}
Modified: trunk/prototypes/java/test/org/openlcb/NetTest.java
===================================================================
--- trunk/prototypes/java/test/org/openlcb/NetTest.java 2011-03-20 17:33:19 UTC (rev 1155)
+++ trunk/prototypes/java/test/org/openlcb/NetTest.java 2011-03-20 17:51:05 UTC (rev 1156)
@@ -56,6 +56,7 @@
// test implementation classes
suite.addTest(org.openlcb.implementations.ImplementationsTest.suite());
suite.addTest(org.openlcb.swing.SwingTest.suite());
+ suite.addTest(org.openlcb.cdi.PackageTest.suite());
// test CAN classes
suite.addTest(org.openlcb.can.CanTest.suite());
Added: trunk/prototypes/java/test/org/openlcb/cdi/PackageTest.java
===================================================================
--- trunk/prototypes/java/test/org/openlcb/cdi/PackageTest.java (rev 0)
+++ trunk/prototypes/java/test/org/openlcb/cdi/PackageTest.java 2011-03-20 17:51:05 UTC (rev 1156)
@@ -0,0 +1,37 @@
+package org.openlcb.cdi;
+
+import junit.framework.Assert;
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+/**
+ * @author Bob Jacobsen Copyright 2011
+ * @version $Revision: 34 $
+ */
+public class PackageTest extends TestCase {
+
+ public void testStart() {
+ }
+
+ // from here down is testing infrastructure
+
+ public PackageTest(String s) {
+ super(s);
+ }
+
+ // Main entry point
+ static public void main(String[] args) {
+ String[] testCaseName = {PackageTest.class.getName()};
+ junit.swingui.TestRunner.main(testCaseName);
+ }
+
+ // test suite from all defined tests
+ public static Test suite() {
+ TestSuite suite = new TestSuite(PackageTest.class);
+
+ suite.addTest(org.openlcb.cdi.jdom.PackageTest.suite());
+
+ return suite;
+ }
+}
Added: trunk/prototypes/java/test/org/openlcb/cdi/jdom/JdomCdiRepTest.java
===================================================================
--- trunk/prototypes/java/test/org/openlcb/cdi/jdom/JdomCdiRepTest.java (rev 0)
+++ trunk/prototypes/java/test/org/openlcb/cdi/jdom/JdomCdiRepTest.java 2011-03-20 17:51:05 UTC (rev 1156)
@@ -0,0 +1,123 @@
+package org.openlcb.cdi.jdom;
+
+import junit.framework.Assert;
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.jdom.*;
+
+import org.openlcb.cdi.CdiRep;
+
+/**
+ * @author Bob Jacobsen Copyright 2011
+ * @version $Revision: 34 $
+ */
+public class JdomCdiRepTest extends TestCase {
+
+ public void testCtor() {
+ new JdomCdiRep(null);
+ }
+
+ public void testGetIdent() {
+ CdiRep rep = new JdomCdiRep(getSample());
+
+ 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());
+ }
+
+ public void testMap() {
+ Element e = new Element("map")
+ .addContent(new Element("relation")
+ .addContent(new Element("property").addContent("prop1"))
+ .addContent(new Element("value").addContent("val1"))
+ )
+ .addContent(new Element("relation")
+ .addContent(new Element("property").addContent("prop2"))
+ .addContent(new Element("value").addContent("val2"))
+ )
+ .addContent(new Element("relation")
+ .addContent(new Element("property").addContent("prop3"))
+ .addContent(new Element("value").addContent("val3"))
+ )
+ ;
+
+ JdomCdiRep.Map map = new JdomCdiRep.Map(e);
+
+ Assert.assertEquals("prop1 value","val1",map.getEntry("prop1"));
+ Assert.assertEquals("prop2 value","val2",map.getEntry("prop2"));
+ Assert.assertEquals("prop3 value","val3",map.getEntry("prop3"));
+
+ Assert.assertEquals("non-existant value",null,map.getEntry("propX"));
+
+ java.util.List list = map.getKeys();
+ Assert.assertNotNull(list);
+ Assert.assertEquals("num keys", 3, list.size());
+ Assert.assertEquals("key1", "prop1", list.get(0));
+ Assert.assertEquals("key2", "prop2", list.get(1));
+ Assert.assertEquals("key3", "prop3", list.get(2));
+ }
+
+ public void testSegments() {
+ CdiRep rep = new JdomCdiRep(getSample());
+
+ java.util.List list = rep.getSegments();
+
+ Assert.assertEquals("len", 2, list.size());
+
+ CdiRep.Segment segment;
+ segment = (CdiRep.Segment)list.get(0);
+ Assert.assertNotNull(segment);
+ Assert.assertEquals("space", 2, segment.getSpace());
+
+ segment = (CdiRep.Segment)list.get(1);
+ Assert.assertNotNull(segment);
+ Assert.assertEquals("space", 0, segment.getSpace());
+ }
+
+ // 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"))
+ );
+
+ root.addContent(
+ new Element("segment").setAttribute("space","2")
+ );
+
+ root.addContent(
+ new Element("segment")
+ );
+
+ return root;
+ }
+
+ public JdomCdiRepTest(String s) {
+ super(s);
+ }
+
+ // Main entry point
+ static public void main(String[] args) {
+ String[] testCaseName = {JdomCdiRepTest.class.getName()};
+ junit.swingui.TestRunner.main(testCaseName);
+ }
+
+ // test suite from all defined tests
+ public static Test suite() {
+ TestSuite suite = new TestSuite(JdomCdiRepTest.class);
+
+ return suite;
+ }
+}
Added: trunk/prototypes/java/test/org/openlcb/cdi/jdom/PackageTest.java
===================================================================
--- trunk/prototypes/java/test/org/openlcb/cdi/jdom/PackageTest.java (rev 0)
+++ trunk/prototypes/java/test/org/openlcb/cdi/jdom/PackageTest.java 2011-03-20 17:51:05 UTC (rev 1156)
@@ -0,0 +1,37 @@
+package org.openlcb.cdi.jdom;
+
+import junit.framework.Assert;
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+/**
+ * @author Bob Jacobsen Copyright 2011
+ * @version $Revision: 34 $
+ */
+public class PackageTest extends TestCase {
+
+ public void testStart() {
+ }
+
+ // from here down is testing infrastructure
+
+ public PackageTest(String s) {
+ super(s);
+ }
+
+ // Main entry point
+ static public void main(String[] args) {
+ String[] testCaseName = {PackageTest.class.getName()};
+ junit.swingui.TestRunner.main(testCaseName);
+ }
+
+ // test suite from all defined tests
+ public static Test suite() {
+ TestSuite suite = new TestSuite(PackageTest.class);
+
+ suite.addTest(JdomCdiRepTest.suite());
+
+ return suite;
+ }
+}
Added: trunk/prototypes/java/test/org/openlcb/cdi/jdom/SampleFactory.java
===================================================================
--- trunk/prototypes/java/test/org/openlcb/cdi/jdom/SampleFactory.java (rev 0)
+++ trunk/prototypes/java/test/org/openlcb/cdi/jdom/SampleFactory.java 2011-03-20 17:51:05 UTC (rev 1156)
@@ -0,0 +1,42 @@
+package org.openlcb.cdi.jdom;
+
+import org.jdom.*;
+
+import org.openlcb.cdi.CdiRep;
+
+/**
+ * Static methods for creating sample XML trees.
+ *
+ * @author Bob Jacobsen Copyright 2011
+ * @version $Revision: 34 $
+ */
+public class SampleFactory {
+
+ public static Element getBasicSample() {
+ 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"))
+ .addContent(new Element("map").addContent(
+ new Element("relation")
+ .addContent(new Element("property").addContent("extra property"))
+ .addContent(new Element("value").addContent("extra value"))
+ ))
+ );
+
+ root.addContent(
+ new Element("segment").setAttribute("space","2")
+ );
+
+ root.addContent(
+ new Element("segment")
+ );
+
+ return root;
+ }
+
+}
Modified: trunk/prototypes/java/test/scenarios/ConfigDemoApplet.java
===================================================================
--- trunk/prototypes/java/test/scenarios/ConfigDemoApplet.java 2011-03-20 17:33:19 UTC (rev 1155)
+++ trunk/prototypes/java/test/scenarios/ConfigDemoApplet.java 2011-03-20 17:51:05 UTC (rev 1156)
@@ -3,6 +3,7 @@
import org.openlcb.*;
import org.openlcb.implementations.*;
import org.openlcb.swing.*;
+import org.openlcb.cdi.swing.*;
import javax.swing.*;
import java.awt.*;
@@ -47,15 +48,28 @@
JFrame f = new JFrame();
f.setTitle("Configuration Demonstration");
- JPanel m = new JPanel();
+ CdiPanel m = new CdiPanel();
+ m.initComponents();
+ m.loadCDI(
+ new org.openlcb.cdi.jdom.JdomCdiRep(
+ org.openlcb.cdi.jdom.SampleFactory.getBasicSample()
+ )
+ );
+
f.add( m );
- // read and fill
- JTextArea t = new JTextArea();
- m.add(t);
-
- Element elem = new Element("Foo");
-
+ // show
+ f.pack();
+ f.setVisible(true);
+ }
+
+
+ // frame starting positions
+ int hPos = 500;
+ int vPos = 0;
+
+ // load content
+ void loadSample(JTextArea t) {
// get content
try {
// Create a URL for the desired page
@@ -75,15 +89,17 @@
} catch (IOException e) {
System.err.println("IOException: "+e);
}
-
- // show
- f.pack();
- f.setVisible(true);
}
+ // For running as a JUnit test
+ static public void runTest() {
+ ConfigDemoApplet app = new ConfigDemoApplet();
+ app.start();
+ app.startDemo();
+ }
+ // Main entry point for standalone run
+ static public void main(String[] args) {
+ runTest();
+ }
- // frame starting positions
- int hPos = 500;
- int vPos = 0;
-
}
Modified: trunk/prototypes/java/test/scenarios/Scenarios.java
===================================================================
--- trunk/prototypes/java/test/scenarios/Scenarios.java 2011-03-20 17:33:19 UTC (rev 1155)
+++ trunk/prototypes/java/test/scenarios/Scenarios.java 2011-03-20 17:51:05 UTC (rev 1156)
@@ -20,6 +20,11 @@
BlueGoldCheck.runTest();
}
+ // ConfigDemoApplet not JUnit so can run standalone
+ public void testConfigDemoApplet() throws Exception {
+ ConfigDemoApplet.runTest();
+ }
+
// from here down is testing infrastructure
public Scenarios(String s) {
@@ -43,7 +48,7 @@
suite.addTest(scenarios.can.CanScenarios.suite());
- // BlueGoldCheck done above
+ // Applets done above
return suite;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jac...@us...> - 2012-02-04 20:35:48
|
Revision: 1727
http://openlcb.svn.sourceforge.net/openlcb/?rev=1727&view=rev
Author: jacobsen
Date: 2012-02-04 20:35:42 +0000 (Sat, 04 Feb 2012)
Log Message:
-----------
carries value as long
Modified Paths:
--------------
trunk/prototypes/java/src/org/openlcb/ProtocolIdentification.java
trunk/prototypes/java/src/org/openlcb/ProtocolIdentificationReplyMessage.java
trunk/prototypes/java/test/org/openlcb/ProtocolIdentificationReplyMessageTest.java
Modified: trunk/prototypes/java/src/org/openlcb/ProtocolIdentification.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/ProtocolIdentification.java 2012-02-04 20:34:53 UTC (rev 1726)
+++ trunk/prototypes/java/src/org/openlcb/ProtocolIdentification.java 2012-02-04 20:35:42 UTC (rev 1727)
@@ -46,5 +46,14 @@
return retval;
}
}
-
+
+ long value = 0; // multiple bits, e.g. from a node
+
+ public ProtocolIdentification( ProtocolIdentificationReplyMessage msg) {
+ value = msg.getValue();
+ }
+ public ProtocolIdentification() {
+ value = 0;
+ }
+
}
Modified: trunk/prototypes/java/src/org/openlcb/ProtocolIdentificationReplyMessage.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/ProtocolIdentificationReplyMessage.java 2012-02-04 20:34:53 UTC (rev 1726)
+++ trunk/prototypes/java/src/org/openlcb/ProtocolIdentificationReplyMessage.java 2012-02-04 20:35:42 UTC (rev 1727)
@@ -14,10 +14,29 @@
@ThreadSafe
public class ProtocolIdentificationReplyMessage extends Message {
- public ProtocolIdentificationReplyMessage(NodeID source) {
+ public ProtocolIdentificationReplyMessage(NodeID source, long value) {
super(source);
+ this.value = value;
}
+ long value;
+
+ public long getValue() { return value; }
+
+ /**
+ * 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 ProtocolIdentificationReplyMessage))
+ return false;
+ ProtocolIdentificationReplyMessage msg = (ProtocolIdentificationReplyMessage) o;
+ if (this.value != msg.getValue())
+ return false;
+ return super.equals(o);
+ }
+
/**
* Implement message-type-specific
* processing when this message
@@ -29,9 +48,10 @@
public void applyTo(MessageDecoder decoder, Connection sender) {
decoder.handleProtocolIdentificationReply(this, sender);
}
+
public String toString() {
return getSourceNodeID().toString()
- +" Protocol Identification Reply ";
+ +" Protocol Identification Reply with value "+value;
}
public int getMTI() { return MTI_PROTOCOL_IDENT_REPLY; }
Modified: trunk/prototypes/java/test/org/openlcb/ProtocolIdentificationReplyMessageTest.java
===================================================================
--- trunk/prototypes/java/test/org/openlcb/ProtocolIdentificationReplyMessageTest.java 2012-02-04 20:34:53 UTC (rev 1726)
+++ trunk/prototypes/java/test/org/openlcb/ProtocolIdentificationReplyMessageTest.java 2012-02-04 20:35:42 UTC (rev 1727)
@@ -17,23 +17,33 @@
public void testEqualsSame() {
Message m1 = new ProtocolIdentificationReplyMessage(
- nodeID1);
+ nodeID1, 12);
Message m2 = new ProtocolIdentificationReplyMessage(
- nodeID1);
+ nodeID1, 12);
Assert.assertTrue(m1.equals(m2));
}
public void testNotEqualsDifferentNode() {
Message m1 = new ProtocolIdentificationReplyMessage(
- nodeID1);
+ nodeID1, 12);
Message m2 = new ProtocolIdentificationReplyMessage(
- nodeID2);
+ nodeID2, 12);
Assert.assertTrue( ! m1.equals(m2));
}
+ public void testNotEqualsDifferentValue() {
+ Message m1 = new ProtocolIdentificationReplyMessage(
+ nodeID1, 12);
+ Message m2 = new ProtocolIdentificationReplyMessage(
+ nodeID1, 13);
+
+ Assert.assertTrue( ! m1.equals(m2));
+ }
+
+
public void testHandling() {
result = false;
Node n = new Node(){
@@ -42,7 +52,7 @@
result = true;
}
};
- Message m = new ProtocolIdentificationReplyMessage(nodeID1);
+ Message m = new ProtocolIdentificationReplyMessage(nodeID1, 21);
n.put(m, null);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jac...@us...> - 2012-06-15 17:40:32
|
Revision: 2429
http://openlcb.svn.sourceforge.net/openlcb/?rev=2429&view=rev
Author: jacobsen
Date: 2012-06-15 17:40:25 +0000 (Fri, 15 Jun 2012)
Log Message:
-----------
type
Modified Paths:
--------------
trunk/prototypes/java/src/org/openlcb/MessageDecoder.java
trunk/prototypes/java/src/org/openlcb/OpenLcb.java
trunk/prototypes/java/test/org/openlcb/PackageTest.java
Added Paths:
-----------
trunk/prototypes/java/src/org/openlcb/OptionalIntRejectedMessage.java
trunk/prototypes/java/test/org/openlcb/OptionalIntRejectedMessageTest.java
Modified: trunk/prototypes/java/src/org/openlcb/MessageDecoder.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/MessageDecoder.java 2012-06-14 04:59:25 UTC (rev 2428)
+++ trunk/prototypes/java/src/org/openlcb/MessageDecoder.java 2012-06-15 17:40:25 UTC (rev 2429)
@@ -170,4 +170,10 @@
public void handleSimpleNodeIdentInfoReply(SimpleNodeIdentInfoReplyMessage msg, Connection sender){
defaultHandler(msg, sender);
}
+ /**
+ * Handle "Optional Interaction Rejected" message
+ */
+ public void handleOptionalIntRejected(OptionalIntRejectedMessage msg, Connection sender){
+ defaultHandler(msg, sender);
+ }
}
Modified: trunk/prototypes/java/src/org/openlcb/OpenLcb.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/OpenLcb.java 2012-06-14 04:59:25 UTC (rev 2428)
+++ trunk/prototypes/java/src/org/openlcb/OpenLcb.java 2012-06-15 17:40:25 UTC (rev 2429)
@@ -15,6 +15,8 @@
static final int MTI_VERIFY_NID = 0x10A4;
static final int MTI_VERIFIED_NID = 0x10B0;
+
+ static final int MTI_OPT_INT_REJECTED = 0x30C0;
static final int MTI_IDENTIFY_CONSUMERS = 0x1242;
static final int MTI_IDENTIFY_CONSUMERS_RANGE = 0x3252;
Copied: trunk/prototypes/java/src/org/openlcb/OptionalIntRejectedMessage.java (from rev 2428, trunk/prototypes/java/src/org/openlcb/SimpleNodeIdentInfoRequestMessage.java)
===================================================================
--- trunk/prototypes/java/src/org/openlcb/OptionalIntRejectedMessage.java (rev 0)
+++ trunk/prototypes/java/src/org/openlcb/OptionalIntRejectedMessage.java 2012-06-15 17:40:25 UTC (rev 2429)
@@ -0,0 +1,61 @@
+package org.openlcb;
+
+// For annotations
+import net.jcip.annotations.*;
+import edu.umd.cs.findbugs.annotations.*;
+
+/**
+ * Optional Interaction Rejected message
+ *
+ * @author Bob Jacobsen Copyright 2012
+ * @version $Revision: 529 $
+ */
+@Immutable
+@ThreadSafe
+public class OptionalIntRejectedMessage extends AddressedMessage {
+
+ public OptionalIntRejectedMessage(NodeID source, NodeID dest, int mti, int code) {
+ super(source, dest);
+ this.mti = mti;
+ this.code = code;
+ }
+
+ int mti;
+ int code;
+
+ public int getMti() { return mti; }
+
+ public int getCode() { return code; }
+
+ /**
+ * 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 OptionalIntRejectedMessage))
+ return false;
+ if (this.mti != ((OptionalIntRejectedMessage)o).getMti() ) return false;
+ if (this.code != ((OptionalIntRejectedMessage)o).getCode() ) return false;
+ return super.equals(o);
+ }
+
+ /**
+ * 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.handleOptionalIntRejected(this, sender);
+ }
+
+ public String toString() {
+ return getSourceNodeID().toString()
+ +" Optional Interaction Rejected";
+ }
+
+ public int getMTI() { return MTI_OPT_INT_REJECTED; }
+}
Copied: trunk/prototypes/java/test/org/openlcb/OptionalIntRejectedMessageTest.java (from rev 2428, trunk/prototypes/java/test/org/openlcb/SimpleNodeIdentInfoRequestMessageTest.java)
===================================================================
--- trunk/prototypes/java/test/org/openlcb/OptionalIntRejectedMessageTest.java (rev 0)
+++ trunk/prototypes/java/test/org/openlcb/OptionalIntRejectedMessageTest.java 2012-06-15 17:40:25 UTC (rev 2429)
@@ -0,0 +1,96 @@
+package org.openlcb;
+
+import junit.framework.Assert;
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+/**
+ * @author Bob Jacobsen Copyright 2012
+ * @version $Revision$
+ */
+public class OptionalIntRejectedMessageTest extends TestCase {
+ boolean result;
+
+ NodeID nodeID1 = new NodeID(new byte[]{1,2,3,4,5,6});
+ NodeID nodeID2 = new NodeID(new byte[]{0,0,0,0,0,0});
+
+ public void testEqualsSame() {
+ Message m1 = new OptionalIntRejectedMessage(
+ nodeID1,nodeID2,0,1);
+ Message m2 = new OptionalIntRejectedMessage(
+ nodeID1,nodeID2,0,1);
+
+ Assert.assertTrue(m1.equals(m2));
+ }
+
+ public void testNotEqualsDifferentSrcNode() {
+ Message m1 = new OptionalIntRejectedMessage(
+ nodeID1,nodeID2,0,1);
+ Message m2 = new OptionalIntRejectedMessage(
+ nodeID2,nodeID2,0,1);
+
+ Assert.assertTrue( ! m1.equals(m2));
+ }
+
+ public void testNotEqualsDifferentDstNode() {
+ Message m1 = new OptionalIntRejectedMessage(
+ nodeID1,nodeID2,0,1);
+ Message m2 = new OptionalIntRejectedMessage(
+ nodeID1,nodeID1,0,1);
+
+ Assert.assertTrue( ! m1.equals(m2));
+ }
+
+ public void testNotEqualsDifferentCode() {
+ Message m1 = new OptionalIntRejectedMessage(
+ nodeID1,nodeID2,0,1);
+ Message m2 = new OptionalIntRejectedMessage(
+ nodeID1,nodeID2,0,2);
+
+ Assert.assertTrue( ! m1.equals(m2));
+ }
+
+ public void testNotEqualsDifferentMti() {
+ Message m1 = new OptionalIntRejectedMessage(
+ nodeID1,nodeID2,0,1);
+ Message m2 = new OptionalIntRejectedMessage(
+ nodeID1,nodeID2,2,1);
+
+ Assert.assertTrue( ! m1.equals(m2));
+ }
+
+
+ public void testHandling() {
+ result = false;
+ Node n = new Node(){
+ @Override
+ public void handleOptionalIntRejected(OptionalIntRejectedMessage msg, Connection sender){
+ result = true;
+ }
+ };
+ Message m = new OptionalIntRejectedMessage(nodeID1, nodeID2, 0, 1);
+
+ n.put(m, null);
+
+ Assert.assertTrue(result);
+ }
+
+ // from here down is testing infrastructure
+
+ public OptionalIntRejectedMessageTest(String s) {
+ super(s);
+ }
+
+ // Main entry point
+ static public void main(String[] args) {
+ String[] testCaseName = {OptionalIntRejectedMessageTest.class.getName()};
+ junit.swingui.TestRunner.main(testCaseName);
+ }
+
+ // test suite from all defined tests
+ public static Test suite() {
+ TestSuite suite = new TestSuite(OptionalIntRejectedMessageTest.class);
+ return suite;
+ }
+}
Modified: trunk/prototypes/java/test/org/openlcb/PackageTest.java
===================================================================
--- trunk/prototypes/java/test/org/openlcb/PackageTest.java 2012-06-14 04:59:25 UTC (rev 2428)
+++ trunk/prototypes/java/test/org/openlcb/PackageTest.java 2012-06-15 17:40:25 UTC (rev 2429)
@@ -44,6 +44,8 @@
// specific message types (uses Node, IDs)
suite.addTest(InitializationCompleteMessageTest.suite());
+ suite.addTest(OptionalIntRejectedMessageTest.suite());
+
suite.addTest(VerifiedNodeIDNumberMessageTest.suite());
suite.addTest(VerifyNodeIDNumberMessageTest.suite());
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <br...@us...> - 2016-07-14 17:11:14
|
Revision: 4150
http://sourceforge.net/p/openlcb/svn/4150
Author: bracz
Date: 2016-07-14 17:11:11 +0000 (Thu, 14 Jul 2016)
Log Message:
-----------
Fixes DccProxyCache after being broken by changes in RemoteTrainNode.
Modified Paths:
--------------
trunk/prototypes/java/src/org/openlcb/implementations/throttle/dcc/DccProxyCache.java
trunk/prototypes/java/test/org/openlcb/implementations/throttle/dcc/DccProxyCacheTest.java
Added Paths:
-----------
trunk/prototypes/java/src/org/openlcb/implementations/throttle/dcc/RemoteDccProxy.java
Modified: trunk/prototypes/java/src/org/openlcb/implementations/throttle/dcc/DccProxyCache.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/implementations/throttle/dcc/DccProxyCache.java 2016-07-14 17:10:49 UTC (rev 4149)
+++ trunk/prototypes/java/src/org/openlcb/implementations/throttle/dcc/DccProxyCache.java 2016-07-14 17:11:11 UTC (rev 4150)
@@ -12,13 +12,13 @@
* @author Bob Jacobsen Copyright 2012
* @version $Revision$
*/
-public class DccProxyCache extends AbstractNodeCache<RemoteTrainNode> {
+public class DccProxyCache extends AbstractNodeCache<RemoteDccProxy> {
public DccProxyCache() {
super(new EventID("01.01.00.00.00.00.04.01"));
}
- protected RemoteTrainNode newObject(NodeID id) {
- return new RemoteTrainNode(id);
+ protected RemoteDccProxy newObject(NodeID id) {
+ return new RemoteDccProxy(id);
}
}
Added: trunk/prototypes/java/src/org/openlcb/implementations/throttle/dcc/RemoteDccProxy.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/implementations/throttle/dcc/RemoteDccProxy.java (rev 0)
+++ trunk/prototypes/java/src/org/openlcb/implementations/throttle/dcc/RemoteDccProxy.java 2016-07-14 17:11:11 UTC (rev 4150)
@@ -0,0 +1,18 @@
+package org.openlcb.implementations.throttle.dcc;
+
+import org.openlcb.NodeID;
+
+/**
+ * Created by bracz on 1/17/16.
+ */
+public class RemoteDccProxy {
+ NodeID node;
+
+ RemoteDccProxy(NodeID node) {
+ this.node = node;
+ }
+
+ public NodeID getNodeId() {
+ return node;
+ }
+}
Modified: trunk/prototypes/java/test/org/openlcb/implementations/throttle/dcc/DccProxyCacheTest.java
===================================================================
--- trunk/prototypes/java/test/org/openlcb/implementations/throttle/dcc/DccProxyCacheTest.java 2016-07-14 17:10:49 UTC (rev 4149)
+++ trunk/prototypes/java/test/org/openlcb/implementations/throttle/dcc/DccProxyCacheTest.java 2016-07-14 17:11:11 UTC (rev 4150)
@@ -52,7 +52,7 @@
Assert.assertTrue(cache.getList() != null);
Assert.assertEquals(1, cache.getList().size());
- RemoteTrainNode tn = cache.getList().get(0);
+ RemoteDccProxy tn = cache.getList().get(0);
Assert.assertTrue(tn.getNodeId().equals(new NodeID(new byte[]{1,1,0,0,4,4})));
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jac...@us...> - 2009-11-16 23:18:43
|
Revision: 155
http://openlcb.svn.sourceforge.net/openlcb/?rev=155&view=rev
Author: jacobsen
Date: 2009-11-16 23:18:33 +0000 (Mon, 16 Nov 2009)
Log Message:
-----------
bulk rename to openlcb
Modified Paths:
--------------
trunk/prototypes/java/test/AllTest.java
trunk/prototypes/java/test/package.html
trunk/prototypes/java/test/scenarios/BlueGoldCheck.java
trunk/prototypes/java/test/scenarios/NineOnALink.java
trunk/prototypes/java/test/scenarios/TwoBuses.java
trunk/prototypes/java/test/scenarios/TwoBusesFiltered.java
trunk/prototypes/java/test/scenarios/can/NineOnASegment.java
trunk/prototypes/java/test/scenarios/can/TwoOnASegment.java
trunk/prototypes/java/test/scenarios/can/package.html
trunk/prototypes/java/test/simulations/package.html
trunk/prototypes/java/test/tools/cansim/CanFrame.java
trunk/prototypes/java/test/tools/cansim/package.html
trunk/prototypes/java/test/tools/package.html
Added Paths:
-----------
trunk/prototypes/java/.classpath
trunk/prototypes/java/src/org/openlcb/
trunk/prototypes/java/src/org/openlcb/Connection.java
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/Gateway.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/LearnCancelMessage.java
trunk/prototypes/java/src/org/openlcb/LearnEventMessage.java
trunk/prototypes/java/src/org/openlcb/LearnPendingMessage.java
trunk/prototypes/java/src/org/openlcb/Message.java
trunk/prototypes/java/src/org/openlcb/MessageDecoder.java
trunk/prototypes/java/src/org/openlcb/Node.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/SingleLinkNode.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/
trunk/prototypes/java/src/org/openlcb/can/CanFrame.java
trunk/prototypes/java/src/org/openlcb/can/NIDa.java
trunk/prototypes/java/src/org/openlcb/can/NIDaAlgorithm.java
trunk/prototypes/java/src/org/openlcb/can/NmraNetCanFrame.java
trunk/prototypes/java/src/org/openlcb/can/package.html
trunk/prototypes/java/src/org/openlcb/implementations/
trunk/prototypes/java/src/org/openlcb/implementations/BlueGoldEngine.java
trunk/prototypes/java/src/org/openlcb/implementations/DatagramReceiver.java
trunk/prototypes/java/src/org/openlcb/implementations/DatagramTransmitter.java
trunk/prototypes/java/src/org/openlcb/implementations/EventFilterGateway.java
trunk/prototypes/java/src/org/openlcb/implementations/ScatterGather.java
trunk/prototypes/java/src/org/openlcb/implementations/SingleConsumer.java
trunk/prototypes/java/src/org/openlcb/implementations/SingleConsumerNode.java
trunk/prototypes/java/src/org/openlcb/implementations/SingleProducer.java
trunk/prototypes/java/src/org/openlcb/implementations/SingleProducerNode.java
trunk/prototypes/java/src/org/openlcb/implementations/StreamReceiver.java
trunk/prototypes/java/src/org/openlcb/implementations/StreamTransmitter.java
trunk/prototypes/java/src/org/openlcb/implementations/package.html
trunk/prototypes/java/src/org/openlcb/package.html
trunk/prototypes/java/src/org/openlcb/swing/
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
trunk/prototypes/java/src/org/openlcb/swing/package.html
trunk/prototypes/java/test/org/openlcb/
trunk/prototypes/java/test/org/openlcb/ConsumerIdentifiedMessageTest.java
trunk/prototypes/java/test/org/openlcb/EventIDTest.java
trunk/prototypes/java/test/org/openlcb/GatewayTest.java
trunk/prototypes/java/test/org/openlcb/IdentifyConsumersMessageTest.java
trunk/prototypes/java/test/org/openlcb/IdentifyEventsMessageTest.java
trunk/prototypes/java/test/org/openlcb/IdentifyProducersMessageTest.java
trunk/prototypes/java/test/org/openlcb/InitializationCompleteMessageTest.java
trunk/prototypes/java/test/org/openlcb/LearnCancelMessageTest.java
trunk/prototypes/java/test/org/openlcb/LearnEventMessageTest.java
trunk/prototypes/java/test/org/openlcb/LearnPendingMessageTest.java
trunk/prototypes/java/test/org/openlcb/MessageDecoderTest.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/NodeTest.java
trunk/prototypes/java/test/org/openlcb/ProducerConsumerEventReportMessageTest.java
trunk/prototypes/java/test/org/openlcb/ProducerIdentifiedMessageTest.java
trunk/prototypes/java/test/org/openlcb/SingleLinkNodeTest.java
trunk/prototypes/java/test/org/openlcb/VerifiedNodeIDNumberMessageTest.java
trunk/prototypes/java/test/org/openlcb/VerifyNodeIDNumberMessageTest.java
trunk/prototypes/java/test/org/openlcb/can/
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/NIDaTest.java
trunk/prototypes/java/test/org/openlcb/can/NmraNetCanFrameTest.java
trunk/prototypes/java/test/org/openlcb/implementations/
trunk/prototypes/java/test/org/openlcb/implementations/BlueGoldEngineTest.java
trunk/prototypes/java/test/org/openlcb/implementations/DatagramReceiverTest.java
trunk/prototypes/java/test/org/openlcb/implementations/DatagramTransmitterTest.java
trunk/prototypes/java/test/org/openlcb/implementations/EventFilterGatewayTest.java
trunk/prototypes/java/test/org/openlcb/implementations/ImplementationsTest.java
trunk/prototypes/java/test/org/openlcb/implementations/ScatterGatherTest.java
trunk/prototypes/java/test/org/openlcb/implementations/SingleConsumerNodeTest.java
trunk/prototypes/java/test/org/openlcb/implementations/SingleProducerNodeTest.java
trunk/prototypes/java/test/org/openlcb/implementations/StreamReceiverTest.java
trunk/prototypes/java/test/org/openlcb/implementations/StreamTransmitterTest.java
trunk/prototypes/java/test/org/openlcb/swing/
trunk/prototypes/java/test/org/openlcb/swing/MonPaneTest.java
trunk/prototypes/java/test/org/openlcb/swing/SwingTest.java
Removed Paths:
-------------
trunk/prototypes/java/src/org/nmra/net/Connection.java
trunk/prototypes/java/src/org/nmra/net/ConsumerIdentifiedMessage.java
trunk/prototypes/java/src/org/nmra/net/DatagramAcknowledgedMessage.java
trunk/prototypes/java/src/org/nmra/net/DatagramMessage.java
trunk/prototypes/java/src/org/nmra/net/DatagramRejectedMessage.java
trunk/prototypes/java/src/org/nmra/net/EventID.java
trunk/prototypes/java/src/org/nmra/net/Gateway.java
trunk/prototypes/java/src/org/nmra/net/IdentifyConsumersMessage.java
trunk/prototypes/java/src/org/nmra/net/IdentifyEventsMessage.java
trunk/prototypes/java/src/org/nmra/net/IdentifyProducersMessage.java
trunk/prototypes/java/src/org/nmra/net/InitializationCompleteMessage.java
trunk/prototypes/java/src/org/nmra/net/LearnCancelMessage.java
trunk/prototypes/java/src/org/nmra/net/LearnEventMessage.java
trunk/prototypes/java/src/org/nmra/net/LearnPendingMessage.java
trunk/prototypes/java/src/org/nmra/net/Message.java
trunk/prototypes/java/src/org/nmra/net/MessageDecoder.java
trunk/prototypes/java/src/org/nmra/net/Node.java
trunk/prototypes/java/src/org/nmra/net/NodeID.java
trunk/prototypes/java/src/org/nmra/net/ProducerConsumerEventReportMessage.java
trunk/prototypes/java/src/org/nmra/net/ProducerIdentifiedMessage.java
trunk/prototypes/java/src/org/nmra/net/SingleLinkNode.java
trunk/prototypes/java/src/org/nmra/net/StreamDataCompleteMessage.java
trunk/prototypes/java/src/org/nmra/net/StreamDataProceedMessage.java
trunk/prototypes/java/src/org/nmra/net/StreamDataSendMessage.java
trunk/prototypes/java/src/org/nmra/net/StreamInitReplyMessage.java
trunk/prototypes/java/src/org/nmra/net/StreamInitRequestMessage.java
trunk/prototypes/java/src/org/nmra/net/VerifiedNodeIDNumberMessage.java
trunk/prototypes/java/src/org/nmra/net/VerifyNodeIDNumberMessage.java
trunk/prototypes/java/src/org/nmra/net/can/CanFrame.java
trunk/prototypes/java/src/org/nmra/net/can/NIDa.java
trunk/prototypes/java/src/org/nmra/net/can/NIDaAlgorithm.java
trunk/prototypes/java/src/org/nmra/net/can/NmraNetCanFrame.java
trunk/prototypes/java/src/org/nmra/net/can/package.html
trunk/prototypes/java/src/org/nmra/net/implementations/BlueGoldEngine.java
trunk/prototypes/java/src/org/nmra/net/implementations/DatagramReceiver.java
trunk/prototypes/java/src/org/nmra/net/implementations/DatagramTransmitter.java
trunk/prototypes/java/src/org/nmra/net/implementations/EventFilterGateway.java
trunk/prototypes/java/src/org/nmra/net/implementations/ScatterGather.java
trunk/prototypes/java/src/org/nmra/net/implementations/SingleConsumer.java
trunk/prototypes/java/src/org/nmra/net/implementations/SingleConsumerNode.java
trunk/prototypes/java/src/org/nmra/net/implementations/SingleProducer.java
trunk/prototypes/java/src/org/nmra/net/implementations/SingleProducerNode.java
trunk/prototypes/java/src/org/nmra/net/implementations/StreamReceiver.java
trunk/prototypes/java/src/org/nmra/net/implementations/StreamTransmitter.java
trunk/prototypes/java/src/org/nmra/net/implementations/package.html
trunk/prototypes/java/src/org/nmra/net/package.html
trunk/prototypes/java/src/org/nmra/net/swing/ConsumerPane.java
trunk/prototypes/java/src/org/nmra/net/swing/MonPane.java
trunk/prototypes/java/src/org/nmra/net/swing/ProducerPane.java
trunk/prototypes/java/src/org/nmra/net/swing/package.html
trunk/prototypes/java/test/org/nmra/net/ConsumerIdentifiedMessageTest.java
trunk/prototypes/java/test/org/nmra/net/EventIDTest.java
trunk/prototypes/java/test/org/nmra/net/GatewayTest.java
trunk/prototypes/java/test/org/nmra/net/IdentifyConsumersMessageTest.java
trunk/prototypes/java/test/org/nmra/net/IdentifyEventsMessageTest.java
trunk/prototypes/java/test/org/nmra/net/IdentifyProducersMessageTest.java
trunk/prototypes/java/test/org/nmra/net/InitializationCompleteMessageTest.java
trunk/prototypes/java/test/org/nmra/net/LearnCancelMessageTest.java
trunk/prototypes/java/test/org/nmra/net/LearnEventMessageTest.java
trunk/prototypes/java/test/org/nmra/net/LearnPendingMessageTest.java
trunk/prototypes/java/test/org/nmra/net/MessageDecoderTest.java
trunk/prototypes/java/test/org/nmra/net/MessageTest.java
trunk/prototypes/java/test/org/nmra/net/NetTest.java
trunk/prototypes/java/test/org/nmra/net/NodeIDTest.java
trunk/prototypes/java/test/org/nmra/net/NodeTest.java
trunk/prototypes/java/test/org/nmra/net/ProducerConsumerEventReportMessageTest.java
trunk/prototypes/java/test/org/nmra/net/ProducerIdentifiedMessageTest.java
trunk/prototypes/java/test/org/nmra/net/SingleLinkNodeTest.java
trunk/prototypes/java/test/org/nmra/net/VerifiedNodeIDNumberMessageTest.java
trunk/prototypes/java/test/org/nmra/net/VerifyNodeIDNumberMessageTest.java
trunk/prototypes/java/test/org/nmra/net/can/CanTest.java
trunk/prototypes/java/test/org/nmra/net/can/NIDaAlgorithmTest.java
trunk/prototypes/java/test/org/nmra/net/can/NIDaTest.java
trunk/prototypes/java/test/org/nmra/net/can/NmraNetCanFrameTest.java
trunk/prototypes/java/test/org/nmra/net/implementations/BlueGoldEngineTest.java
trunk/prototypes/java/test/org/nmra/net/implementations/DatagramReceiverTest.java
trunk/prototypes/java/test/org/nmra/net/implementations/DatagramTransmitterTest.java
trunk/prototypes/java/test/org/nmra/net/implementations/EventFilterGatewayTest.java
trunk/prototypes/java/test/org/nmra/net/implementations/ImplementationsTest.java
trunk/prototypes/java/test/org/nmra/net/implementations/ScatterGatherTest.java
trunk/prototypes/java/test/org/nmra/net/implementations/SingleConsumerNodeTest.java
trunk/prototypes/java/test/org/nmra/net/implementations/SingleProducerNodeTest.java
trunk/prototypes/java/test/org/nmra/net/implementations/StreamReceiverTest.java
trunk/prototypes/java/test/org/nmra/net/implementations/StreamTransmitterTest.java
trunk/prototypes/java/test/org/nmra/net/swing/MonPaneTest.java
trunk/prototypes/java/test/org/nmra/net/swing/SwingTest.java
Property Changed:
----------------
trunk/prototypes/java/nbproject/
Added: trunk/prototypes/java/.classpath
===================================================================
--- trunk/prototypes/java/.classpath (rev 0)
+++ trunk/prototypes/java/.classpath 2009-11-16 23:18:33 UTC (rev 155)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry excluding="**/.cvsignore|**/COPYING" kind="src" output="classes" path="src"/>
+ <classpathentry excluding="**/.cvsignore|**/COPYING" kind="src" path="test"/>
+ <classpathentry kind="var" path="JRE_LIB" sourcepath="JRE_SRC"/>
+ <classpathentry kind="output" path="classes"/>
+</classpath>
Property changes on: trunk/prototypes/java/nbproject
___________________________________________________________________
Added: svn:ignore
+ private
Deleted: trunk/prototypes/java/src/org/nmra/net/Connection.java
===================================================================
--- trunk/prototypes/java/src/org/nmra/net/Connection.java 2009-11-16 22:47:09 UTC (rev 154)
+++ trunk/prototypes/java/src/org/nmra/net/Connection.java 2009-11-16 23:18:33 UTC (rev 155)
@@ -1,22 +0,0 @@
-package org.nmra.net;
-
-/**
- * Interface for receiving NMRAnet messages.
- * <p>
- * Generally, nodes send messages by delivering them to Connections.
- *
- * @author Bob Jacobsen Copyright 2009
- * @version $Revision$
- */
-public interface Connection {
-
- /**
- * Put a message to this connection.
- * @param sender Node that is sending the message, used
- * for tracking, logging, etc.
- * (This models a two-ended connection to whatever
- * communications link is used)
- */
- public void put(Message msg, Connection sender);
-
-}
Deleted: trunk/prototypes/java/src/org/nmra/net/ConsumerIdentifiedMessage.java
===================================================================
--- trunk/prototypes/java/src/org/nmra/net/ConsumerIdentifiedMessage.java 2009-11-16 22:47:09 UTC (rev 154)
+++ trunk/prototypes/java/src/org/nmra/net/ConsumerIdentifiedMessage.java 2009-11-16 23:18:33 UTC (rev 155)
@@ -1,46 +0,0 @@
-package org.nmra.net;
-
-/**
- * Consumer Identified message implementation
- *
- * @author Bob Jacobsen Copyright 2009
- * @version $Revision$
- */
-public class ConsumerIdentifiedMessage extends Message {
-
- public ConsumerIdentifiedMessage(NodeID source, EventID eventID) {
- super(source);
- if (eventID == null)
- throw new IllegalArgumentException("EventID cannot be null");
- this.eventID = eventID;
- }
-
- EventID eventID;
-
- // because EventID is immutable, can directly return object
- public EventID getEventID() {
- return eventID;
- }
-
- /**
- * 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.handleConsumerIdentified(this, sender);
- }
-
- public boolean equals(Object o) {
- if (!super.equals(o)) return false;
- ConsumerIdentifiedMessage p = (ConsumerIdentifiedMessage) o;
- return eventID.equals(p.eventID);
- }
- public String toString() {
- return getSourceNodeID().toString()
- +" Consumer identified for "+eventID.toString();
- }
-}
Deleted: trunk/prototypes/java/src/org/nmra/net/DatagramAcknowledgedMessage.java
===================================================================
--- trunk/prototypes/java/src/org/nmra/net/DatagramAcknowledgedMessage.java 2009-11-16 22:47:09 UTC (rev 154)
+++ trunk/prototypes/java/src/org/nmra/net/DatagramAcknowledgedMessage.java 2009-11-16 23:18:33 UTC (rev 155)
@@ -1,26 +0,0 @@
-package org.nmra.net;
-
-/**
- * Datagram Acknowledged message implementation
- *
- * @author Bob Jacobsen Copyright 2009
- * @version $Revision$
- */
-public class DatagramAcknowledgedMessage extends Message {
-
- public DatagramAcknowledgedMessage(NodeID source, NodeID dest) {
- 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.handleDatagramAcknowledged(this, sender);
- }
-}
Deleted: trunk/prototypes/java/src/org/nmra/net/DatagramMessage.java
===================================================================
--- trunk/prototypes/java/src/org/nmra/net/DatagramMessage.java 2009-11-16 22:47:09 UTC (rev 154)
+++ trunk/prototypes/java/src/org/nmra/net/DatagramMessage.java 2009-11-16 23:18:33 UTC (rev 155)
@@ -1,26 +0,0 @@
-package org.nmra.net;
-
-/**
- * Datagram message implementation
- *
- * @author Bob Jacobsen Copyright 2009
- * @version $Revision$
- */
-public class DatagramMessage extends Message {
-
- public DatagramMessage(NodeID source, NodeID dest, int[] data) {
- 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.handleDatagram(this, sender);
- }
-}
Deleted: trunk/prototypes/java/src/org/nmra/net/DatagramRejectedMessage.java
===================================================================
--- trunk/prototypes/java/src/org/nmra/net/DatagramRejectedMessage.java 2009-11-16 22:47:09 UTC (rev 154)
+++ trunk/prototypes/java/src/org/nmra/net/DatagramRejectedMessage.java 2009-11-16 23:18:33 UTC (rev 155)
@@ -1,26 +0,0 @@
-package org.nmra.net;
-
-/**
- * Datagram Rejected message implementation
- *
- * @author Bob Jacobsen Copyright 2009
- * @version $Revision$
- */
-public class DatagramRejectedMessage extends Message {
-
- public DatagramRejectedMessage(NodeID source, NodeID dest) {
- 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.handleDatagramRejected(this, sender);
- }
-}
Deleted: trunk/prototypes/java/src/org/nmra/net/EventID.java
===================================================================
--- trunk/prototypes/java/src/org/nmra/net/EventID.java 2009-11-16 22:47:09 UTC (rev 154)
+++ trunk/prototypes/java/src/org/nmra/net/EventID.java 2009-11-16 23:18:33 UTC (rev 155)
@@ -1,69 +0,0 @@
-package org.nmra.net;
-
-/**
- * Common EventID implementation.
- * <p>
- * EventID objects are immutable once created.
- *
- * @author Bob Jacobsen Copyright 2009
- * @version $Revision$
- */
-public class EventID {
-
- static final int BYTECOUNT = 8;
-
- public EventID(NodeID node, int b7, int b8) {
- this.contents = new byte[BYTECOUNT];
- for (int i = 0; i < BYTECOUNT-2; i++)
- this.contents[i] = node.contents[i];
-
- this.contents[6] = (byte)b7;
- this.contents[7] = (byte)b8;
- }
-
- public EventID(byte[] contents) {
- if (contents == null)
- throw new java.lang.IllegalArgumentException("null argument invalid");
- if (contents.length != BYTECOUNT)
- throw new java.lang.IllegalArgumentException("Wrong EventID length: "+contents.length);
- this.contents = new byte[BYTECOUNT];
- for (int i = 0; i < BYTECOUNT; i++)
- this.contents[i] = contents[i];
- }
-
- byte[] contents;
-
- public boolean equals(Object o){
- // try to cast, else not equal
- try {
- EventID other = (EventID) o;
- for (int i = 0; i<BYTECOUNT; i++)
- if (other.contents[i] != this.contents[i]) return false;
- return true;
- } catch (Exception e) {
- return false;
- }
- }
- public int hashCode() {
- return contents[0]<<21
- +contents[1]<<18
- +contents[2]<<15
- +contents[3]<<12
- +contents[4]<<9
- +contents[5]<<6
- +contents[6]<<3
- +contents[7];
- }
-
- public String toString() {
- return "Event:"
- +contents[0]+","
- +contents[1]+","
- +contents[2]+","
- +contents[3]+","
- +contents[4]+","
- +contents[5]+","
- +contents[6]+","
- +contents[7];
- }
-}
Deleted: trunk/prototypes/java/src/org/nmra/net/Gateway.java
===================================================================
--- trunk/prototypes/java/src/org/nmra/net/Gateway.java 2009-11-16 22:47:09 UTC (rev 154)
+++ trunk/prototypes/java/src/org/nmra/net/Gateway.java 2009-11-16 23:18:33 UTC (rev 155)
@@ -1,73 +0,0 @@
-package org.nmra.net;
-
-/**
- * Base for NRMAnet gateway implementations.
- *<p>
- * Provides two connections, called "East" and "West"
- *
- * @author Bob Jacobsen Copyright 2009
- * @version $Revision$
- */
-public class Gateway extends MessageDecoder {
- public Gateway() {
- }
-
- /**
- * Provide a connection object for use by
- * the East node.
- */
- public Connection getEastConnection() {
- eastInputConnection = new Connection() {
- public void put(Message msg, Connection sender) {
- sendMessageToWest(msg, sender);
- }
- };
- return eastInputConnection;
- }
-
- // forward from east to west
- protected void sendMessageToWest(Message msg, Connection sender) {
- if (westOutputConnection == null)
- throw new AssertionError("west was null when message sent");
- westOutputConnection.put(msg, westInputConnection);
- }
-
- public void registerEast(Connection c) {
- if (eastOutputConnection != null)
- throw new AssertionError("east already registered");
- eastOutputConnection = c;
- }
-
- protected Connection eastOutputConnection; // what I send to on east side
- protected Connection eastInputConnection; // to me, I show as sender on east side
-
- /**
- * Provide a connection object for use by
- * the West node.
- */
- public Connection getWestConnection() {
- westInputConnection = new Connection() {
- public void put(Message msg, Connection sender) {
- sendMessageToEast(msg, sender);
- }
- };
- return westInputConnection;
- }
-
- // forward from west to east
- protected void sendMessageToEast(Message msg, Connection sender) {
- if (eastOutputConnection == null)
- throw new AssertionError("east was null when message sent");
- eastOutputConnection.put(msg, eastInputConnection);
- }
-
- public void registerWest(Connection c) {
- if (westOutputConnection != null)
- throw new AssertionError("west already registered");
- westOutputConnection = c;
- }
-
- protected Connection westOutputConnection; // what I send to on west side
- protected Connection westInputConnection; // to me, I show as sender on west side
-
-}
\ No newline at end of file
Deleted: trunk/prototypes/java/src/org/nmra/net/IdentifyConsumersMessage.java
===================================================================
--- trunk/prototypes/java/src/org/nmra/net/IdentifyConsumersMessage.java 2009-11-16 22:47:09 UTC (rev 154)
+++ trunk/prototypes/java/src/org/nmra/net/IdentifyConsumersMessage.java 2009-11-16 23:18:33 UTC (rev 155)
@@ -1,46 +0,0 @@
-package org.nmra.net;
-
-/**
- * Identify Consumers message implementation
- *
- * @author Bob Jacobsen Copyright 2009
- * @version $Revision$
- */
-public class IdentifyConsumersMessage extends Message {
-
- public IdentifyConsumersMessage(NodeID source, EventID event) {
- super(source);
- this.eventID = event;
- }
-
- EventID eventID = null;
- /**
- * 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.handleIdentifyConsumers(this, sender);
- }
-
- /**
- * To be equal, messages have to have the
- * same type and content
- */
- @Override
- public boolean equals(Object o) {
- if (!super.equals(o)) return false; // also checks type
- IdentifyConsumersMessage msg = (IdentifyConsumersMessage) o;
- if (! this.eventID.equals(msg.eventID))
- return false;
- return true;
- }
-
- public String toString() {
- return getSourceNodeID().toString()
- +" Identify Consumers with "+eventID.toString();
- }
-}
Deleted: trunk/prototypes/java/src/org/nmra/net/IdentifyEventsMessage.java
===================================================================
--- trunk/prototypes/java/src/org/nmra/net/IdentifyEventsMessage.java 2009-11-16 22:47:09 UTC (rev 154)
+++ trunk/prototypes/java/src/org/nmra/net/IdentifyEventsMessage.java 2009-11-16 23:18:33 UTC (rev 155)
@@ -1,30 +0,0 @@
-package org.nmra.net;
-
-/**
- * Identify Events message implementation
- *
- * @author Bob Jacobsen Copyright 2009
- * @version $Revision$
- */
-public class IdentifyEventsMessage extends Message {
-
- public IdentifyEventsMessage(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.handleIdentifyEvents(this, sender);
- }
- public String toString() {
- return getSourceNodeID().toString()
- +" Identify Events ";
- }
-}
Deleted: trunk/prototypes/java/src/org/nmra/net/IdentifyProducersMessage.java
===================================================================
--- trunk/prototypes/java/src/org/nmra/net/IdentifyProducersMessage.java 2009-11-16 22:47:09 UTC (rev 154)
+++ trunk/prototypes/java/src/org/nmra/net/IdentifyProducersMessage.java 2009-11-16 23:18:33 UTC (rev 155)
@@ -1,46 +0,0 @@
-package org.nmra.net;
-
-/**
- * Identify Producers message implementation
- *
- * @author Bob Jacobsen Copyright 2009
- * @version $Revision$
- */
-public class IdentifyProducersMessage extends Message {
-
- public IdentifyProducersMessage(NodeID source, EventID eventID) {
- super(source);
- this.eventID = eventID;
- }
-
- EventID eventID;
- /**
- * 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.handleIdentifyProducers(this, sender);
- }
-
- /**
- * To be equal, messages have to have the
- * same type and content
- */
- @Override
- public boolean equals(Object o) {
- if (!super.equals(o)) return false; // also checks type
- IdentifyProducersMessage msg = (IdentifyProducersMessage) o;
- if (! this.eventID.equals(msg.eventID))
- return false;
- return true;
- }
-
- public String toString() {
- return getSourceNodeID().toString()
- +" Identify Producers with "+eventID.toString();
- }
-}
Deleted: trunk/prototypes/java/src/org/nmra/net/InitializationCompleteMessage.java
===================================================================
--- trunk/prototypes/java/src/org/nmra/net/InitializationCompleteMessage.java 2009-11-16 22:47:09 UTC (rev 154)
+++ trunk/prototypes/java/src/org/nmra/net/InitializationCompleteMessage.java 2009-11-16 23:18:33 UTC (rev 155)
@@ -1,30 +0,0 @@
-package org.nmra.net;
-
-/**
- * Initialization Complete message implementation
- *
- * @author Bob Jacobsen Copyright 2009
- * @version $Revision$
- */
-public class InitializationCompleteMessage extends Message {
-...
[truncated message content] |
|
From: <jac...@us...> - 2009-11-16 23:18:47
|
Revision: 155
http://openlcb.svn.sourceforge.net/openlcb/?rev=155&view=rev
Author: jacobsen
Date: 2009-11-16 23:18:33 +0000 (Mon, 16 Nov 2009)
Log Message:
-----------
bulk rename to openlcb
Modified Paths:
--------------
trunk/prototypes/java/test/AllTest.java
trunk/prototypes/java/test/package.html
trunk/prototypes/java/test/scenarios/BlueGoldCheck.java
trunk/prototypes/java/test/scenarios/NineOnALink.java
trunk/prototypes/java/test/scenarios/TwoBuses.java
trunk/prototypes/java/test/scenarios/TwoBusesFiltered.java
trunk/prototypes/java/test/scenarios/can/NineOnASegment.java
trunk/prototypes/java/test/scenarios/can/TwoOnASegment.java
trunk/prototypes/java/test/scenarios/can/package.html
trunk/prototypes/java/test/simulations/package.html
trunk/prototypes/java/test/tools/cansim/CanFrame.java
trunk/prototypes/java/test/tools/cansim/package.html
trunk/prototypes/java/test/tools/package.html
Added Paths:
-----------
trunk/prototypes/java/.classpath
trunk/prototypes/java/src/org/openlcb/
trunk/prototypes/java/src/org/openlcb/Connection.java
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/Gateway.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/LearnCancelMessage.java
trunk/prototypes/java/src/org/openlcb/LearnEventMessage.java
trunk/prototypes/java/src/org/openlcb/LearnPendingMessage.java
trunk/prototypes/java/src/org/openlcb/Message.java
trunk/prototypes/java/src/org/openlcb/MessageDecoder.java
trunk/prototypes/java/src/org/openlcb/Node.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/SingleLinkNode.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/
trunk/prototypes/java/src/org/openlcb/can/CanFrame.java
trunk/prototypes/java/src/org/openlcb/can/NIDa.java
trunk/prototypes/java/src/org/openlcb/can/NIDaAlgorithm.java
trunk/prototypes/java/src/org/openlcb/can/NmraNetCanFrame.java
trunk/prototypes/java/src/org/openlcb/can/package.html
trunk/prototypes/java/src/org/openlcb/implementations/
trunk/prototypes/java/src/org/openlcb/implementations/BlueGoldEngine.java
trunk/prototypes/java/src/org/openlcb/implementations/DatagramReceiver.java
trunk/prototypes/java/src/org/openlcb/implementations/DatagramTransmitter.java
trunk/prototypes/java/src/org/openlcb/implementations/EventFilterGateway.java
trunk/prototypes/java/src/org/openlcb/implementations/ScatterGather.java
trunk/prototypes/java/src/org/openlcb/implementations/SingleConsumer.java
trunk/prototypes/java/src/org/openlcb/implementations/SingleConsumerNode.java
trunk/prototypes/java/src/org/openlcb/implementations/SingleProducer.java
trunk/prototypes/java/src/org/openlcb/implementations/SingleProducerNode.java
trunk/prototypes/java/src/org/openlcb/implementations/StreamReceiver.java
trunk/prototypes/java/src/org/openlcb/implementations/StreamTransmitter.java
trunk/prototypes/java/src/org/openlcb/implementations/package.html
trunk/prototypes/java/src/org/openlcb/package.html
trunk/prototypes/java/src/org/openlcb/swing/
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
trunk/prototypes/java/src/org/openlcb/swing/package.html
trunk/prototypes/java/test/org/openlcb/
trunk/prototypes/java/test/org/openlcb/ConsumerIdentifiedMessageTest.java
trunk/prototypes/java/test/org/openlcb/EventIDTest.java
trunk/prototypes/java/test/org/openlcb/GatewayTest.java
trunk/prototypes/java/test/org/openlcb/IdentifyConsumersMessageTest.java
trunk/prototypes/java/test/org/openlcb/IdentifyEventsMessageTest.java
trunk/prototypes/java/test/org/openlcb/IdentifyProducersMessageTest.java
trunk/prototypes/java/test/org/openlcb/InitializationCompleteMessageTest.java
trunk/prototypes/java/test/org/openlcb/LearnCancelMessageTest.java
trunk/prototypes/java/test/org/openlcb/LearnEventMessageTest.java
trunk/prototypes/java/test/org/openlcb/LearnPendingMessageTest.java
trunk/prototypes/java/test/org/openlcb/MessageDecoderTest.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/NodeTest.java
trunk/prototypes/java/test/org/openlcb/ProducerConsumerEventReportMessageTest.java
trunk/prototypes/java/test/org/openlcb/ProducerIdentifiedMessageTest.java
trunk/prototypes/java/test/org/openlcb/SingleLinkNodeTest.java
trunk/prototypes/java/test/org/openlcb/VerifiedNodeIDNumberMessageTest.java
trunk/prototypes/java/test/org/openlcb/VerifyNodeIDNumberMessageTest.java
trunk/prototypes/java/test/org/openlcb/can/
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/NIDaTest.java
trunk/prototypes/java/test/org/openlcb/can/NmraNetCanFrameTest.java
trunk/prototypes/java/test/org/openlcb/implementations/
trunk/prototypes/java/test/org/openlcb/implementations/BlueGoldEngineTest.java
trunk/prototypes/java/test/org/openlcb/implementations/DatagramReceiverTest.java
trunk/prototypes/java/test/org/openlcb/implementations/DatagramTransmitterTest.java
trunk/prototypes/java/test/org/openlcb/implementations/EventFilterGatewayTest.java
trunk/prototypes/java/test/org/openlcb/implementations/ImplementationsTest.java
trunk/prototypes/java/test/org/openlcb/implementations/ScatterGatherTest.java
trunk/prototypes/java/test/org/openlcb/implementations/SingleConsumerNodeTest.java
trunk/prototypes/java/test/org/openlcb/implementations/SingleProducerNodeTest.java
trunk/prototypes/java/test/org/openlcb/implementations/StreamReceiverTest.java
trunk/prototypes/java/test/org/openlcb/implementations/StreamTransmitterTest.java
trunk/prototypes/java/test/org/openlcb/swing/
trunk/prototypes/java/test/org/openlcb/swing/MonPaneTest.java
trunk/prototypes/java/test/org/openlcb/swing/SwingTest.java
Removed Paths:
-------------
trunk/prototypes/java/src/org/nmra/net/Connection.java
trunk/prototypes/java/src/org/nmra/net/ConsumerIdentifiedMessage.java
trunk/prototypes/java/src/org/nmra/net/DatagramAcknowledgedMessage.java
trunk/prototypes/java/src/org/nmra/net/DatagramMessage.java
trunk/prototypes/java/src/org/nmra/net/DatagramRejectedMessage.java
trunk/prototypes/java/src/org/nmra/net/EventID.java
trunk/prototypes/java/src/org/nmra/net/Gateway.java
trunk/prototypes/java/src/org/nmra/net/IdentifyConsumersMessage.java
trunk/prototypes/java/src/org/nmra/net/IdentifyEventsMessage.java
trunk/prototypes/java/src/org/nmra/net/IdentifyProducersMessage.java
trunk/prototypes/java/src/org/nmra/net/InitializationCompleteMessage.java
trunk/prototypes/java/src/org/nmra/net/LearnCancelMessage.java
trunk/prototypes/java/src/org/nmra/net/LearnEventMessage.java
trunk/prototypes/java/src/org/nmra/net/LearnPendingMessage.java
trunk/prototypes/java/src/org/nmra/net/Message.java
trunk/prototypes/java/src/org/nmra/net/MessageDecoder.java
trunk/prototypes/java/src/org/nmra/net/Node.java
trunk/prototypes/java/src/org/nmra/net/NodeID.java
trunk/prototypes/java/src/org/nmra/net/ProducerConsumerEventReportMessage.java
trunk/prototypes/java/src/org/nmra/net/ProducerIdentifiedMessage.java
trunk/prototypes/java/src/org/nmra/net/SingleLinkNode.java
trunk/prototypes/java/src/org/nmra/net/StreamDataCompleteMessage.java
trunk/prototypes/java/src/org/nmra/net/StreamDataProceedMessage.java
trunk/prototypes/java/src/org/nmra/net/StreamDataSendMessage.java
trunk/prototypes/java/src/org/nmra/net/StreamInitReplyMessage.java
trunk/prototypes/java/src/org/nmra/net/StreamInitRequestMessage.java
trunk/prototypes/java/src/org/nmra/net/VerifiedNodeIDNumberMessage.java
trunk/prototypes/java/src/org/nmra/net/VerifyNodeIDNumberMessage.java
trunk/prototypes/java/src/org/nmra/net/can/CanFrame.java
trunk/prototypes/java/src/org/nmra/net/can/NIDa.java
trunk/prototypes/java/src/org/nmra/net/can/NIDaAlgorithm.java
trunk/prototypes/java/src/org/nmra/net/can/NmraNetCanFrame.java
trunk/prototypes/java/src/org/nmra/net/can/package.html
trunk/prototypes/java/src/org/nmra/net/implementations/BlueGoldEngine.java
trunk/prototypes/java/src/org/nmra/net/implementations/DatagramReceiver.java
trunk/prototypes/java/src/org/nmra/net/implementations/DatagramTransmitter.java
trunk/prototypes/java/src/org/nmra/net/implementations/EventFilterGateway.java
trunk/prototypes/java/src/org/nmra/net/implementations/ScatterGather.java
trunk/prototypes/java/src/org/nmra/net/implementations/SingleConsumer.java
trunk/prototypes/java/src/org/nmra/net/implementations/SingleConsumerNode.java
trunk/prototypes/java/src/org/nmra/net/implementations/SingleProducer.java
trunk/prototypes/java/src/org/nmra/net/implementations/SingleProducerNode.java
trunk/prototypes/java/src/org/nmra/net/implementations/StreamReceiver.java
trunk/prototypes/java/src/org/nmra/net/implementations/StreamTransmitter.java
trunk/prototypes/java/src/org/nmra/net/implementations/package.html
trunk/prototypes/java/src/org/nmra/net/package.html
trunk/prototypes/java/src/org/nmra/net/swing/ConsumerPane.java
trunk/prototypes/java/src/org/nmra/net/swing/MonPane.java
trunk/prototypes/java/src/org/nmra/net/swing/ProducerPane.java
trunk/prototypes/java/src/org/nmra/net/swing/package.html
trunk/prototypes/java/test/org/nmra/net/ConsumerIdentifiedMessageTest.java
trunk/prototypes/java/test/org/nmra/net/EventIDTest.java
trunk/prototypes/java/test/org/nmra/net/GatewayTest.java
trunk/prototypes/java/test/org/nmra/net/IdentifyConsumersMessageTest.java
trunk/prototypes/java/test/org/nmra/net/IdentifyEventsMessageTest.java
trunk/prototypes/java/test/org/nmra/net/IdentifyProducersMessageTest.java
trunk/prototypes/java/test/org/nmra/net/InitializationCompleteMessageTest.java
trunk/prototypes/java/test/org/nmra/net/LearnCancelMessageTest.java
trunk/prototypes/java/test/org/nmra/net/LearnEventMessageTest.java
trunk/prototypes/java/test/org/nmra/net/LearnPendingMessageTest.java
trunk/prototypes/java/test/org/nmra/net/MessageDecoderTest.java
trunk/prototypes/java/test/org/nmra/net/MessageTest.java
trunk/prototypes/java/test/org/nmra/net/NetTest.java
trunk/prototypes/java/test/org/nmra/net/NodeIDTest.java
trunk/prototypes/java/test/org/nmra/net/NodeTest.java
trunk/prototypes/java/test/org/nmra/net/ProducerConsumerEventReportMessageTest.java
trunk/prototypes/java/test/org/nmra/net/ProducerIdentifiedMessageTest.java
trunk/prototypes/java/test/org/nmra/net/SingleLinkNodeTest.java
trunk/prototypes/java/test/org/nmra/net/VerifiedNodeIDNumberMessageTest.java
trunk/prototypes/java/test/org/nmra/net/VerifyNodeIDNumberMessageTest.java
trunk/prototypes/java/test/org/nmra/net/can/CanTest.java
trunk/prototypes/java/test/org/nmra/net/can/NIDaAlgorithmTest.java
trunk/prototypes/java/test/org/nmra/net/can/NIDaTest.java
trunk/prototypes/java/test/org/nmra/net/can/NmraNetCanFrameTest.java
trunk/prototypes/java/test/org/nmra/net/implementations/BlueGoldEngineTest.java
trunk/prototypes/java/test/org/nmra/net/implementations/DatagramReceiverTest.java
trunk/prototypes/java/test/org/nmra/net/implementations/DatagramTransmitterTest.java
trunk/prototypes/java/test/org/nmra/net/implementations/EventFilterGatewayTest.java
trunk/prototypes/java/test/org/nmra/net/implementations/ImplementationsTest.java
trunk/prototypes/java/test/org/nmra/net/implementations/ScatterGatherTest.java
trunk/prototypes/java/test/org/nmra/net/implementations/SingleConsumerNodeTest.java
trunk/prototypes/java/test/org/nmra/net/implementations/SingleProducerNodeTest.java
trunk/prototypes/java/test/org/nmra/net/implementations/StreamReceiverTest.java
trunk/prototypes/java/test/org/nmra/net/implementations/StreamTransmitterTest.java
trunk/prototypes/java/test/org/nmra/net/swing/MonPaneTest.java
trunk/prototypes/java/test/org/nmra/net/swing/SwingTest.java
Property Changed:
----------------
trunk/prototypes/java/nbproject/
Added: trunk/prototypes/java/.classpath
===================================================================
--- trunk/prototypes/java/.classpath (rev 0)
+++ trunk/prototypes/java/.classpath 2009-11-16 23:18:33 UTC (rev 155)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry excluding="**/.cvsignore|**/COPYING" kind="src" output="classes" path="src"/>
+ <classpathentry excluding="**/.cvsignore|**/COPYING" kind="src" path="test"/>
+ <classpathentry kind="var" path="JRE_LIB" sourcepath="JRE_SRC"/>
+ <classpathentry kind="output" path="classes"/>
+</classpath>
Property changes on: trunk/prototypes/java/nbproject
___________________________________________________________________
Added: svn:ignore
+ private
Deleted: trunk/prototypes/java/src/org/nmra/net/Connection.java
===================================================================
--- trunk/prototypes/java/src/org/nmra/net/Connection.java 2009-11-16 22:47:09 UTC (rev 154)
+++ trunk/prototypes/java/src/org/nmra/net/Connection.java 2009-11-16 23:18:33 UTC (rev 155)
@@ -1,22 +0,0 @@
-package org.nmra.net;
-
-/**
- * Interface for receiving NMRAnet messages.
- * <p>
- * Generally, nodes send messages by delivering them to Connections.
- *
- * @author Bob Jacobsen Copyright 2009
- * @version $Revision$
- */
-public interface Connection {
-
- /**
- * Put a message to this connection.
- * @param sender Node that is sending the message, used
- * for tracking, logging, etc.
- * (This models a two-ended connection to whatever
- * communications link is used)
- */
- public void put(Message msg, Connection sender);
-
-}
Deleted: trunk/prototypes/java/src/org/nmra/net/ConsumerIdentifiedMessage.java
===================================================================
--- trunk/prototypes/java/src/org/nmra/net/ConsumerIdentifiedMessage.java 2009-11-16 22:47:09 UTC (rev 154)
+++ trunk/prototypes/java/src/org/nmra/net/ConsumerIdentifiedMessage.java 2009-11-16 23:18:33 UTC (rev 155)
@@ -1,46 +0,0 @@
-package org.nmra.net;
-
-/**
- * Consumer Identified message implementation
- *
- * @author Bob Jacobsen Copyright 2009
- * @version $Revision$
- */
-public class ConsumerIdentifiedMessage extends Message {
-
- public ConsumerIdentifiedMessage(NodeID source, EventID eventID) {
- super(source);
- if (eventID == null)
- throw new IllegalArgumentException("EventID cannot be null");
- this.eventID = eventID;
- }
-
- EventID eventID;
-
- // because EventID is immutable, can directly return object
- public EventID getEventID() {
- return eventID;
- }
-
- /**
- * 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.handleConsumerIdentified(this, sender);
- }
-
- public boolean equals(Object o) {
- if (!super.equals(o)) return false;
- ConsumerIdentifiedMessage p = (ConsumerIdentifiedMessage) o;
- return eventID.equals(p.eventID);
- }
- public String toString() {
- return getSourceNodeID().toString()
- +" Consumer identified for "+eventID.toString();
- }
-}
Deleted: trunk/prototypes/java/src/org/nmra/net/DatagramAcknowledgedMessage.java
===================================================================
--- trunk/prototypes/java/src/org/nmra/net/DatagramAcknowledgedMessage.java 2009-11-16 22:47:09 UTC (rev 154)
+++ trunk/prototypes/java/src/org/nmra/net/DatagramAcknowledgedMessage.java 2009-11-16 23:18:33 UTC (rev 155)
@@ -1,26 +0,0 @@
-package org.nmra.net;
-
-/**
- * Datagram Acknowledged message implementation
- *
- * @author Bob Jacobsen Copyright 2009
- * @version $Revision$
- */
-public class DatagramAcknowledgedMessage extends Message {
-
- public DatagramAcknowledgedMessage(NodeID source, NodeID dest) {
- 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.handleDatagramAcknowledged(this, sender);
- }
-}
Deleted: trunk/prototypes/java/src/org/nmra/net/DatagramMessage.java
===================================================================
--- trunk/prototypes/java/src/org/nmra/net/DatagramMessage.java 2009-11-16 22:47:09 UTC (rev 154)
+++ trunk/prototypes/java/src/org/nmra/net/DatagramMessage.java 2009-11-16 23:18:33 UTC (rev 155)
@@ -1,26 +0,0 @@
-package org.nmra.net;
-
-/**
- * Datagram message implementation
- *
- * @author Bob Jacobsen Copyright 2009
- * @version $Revision$
- */
-public class DatagramMessage extends Message {
-
- public DatagramMessage(NodeID source, NodeID dest, int[] data) {
- 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.handleDatagram(this, sender);
- }
-}
Deleted: trunk/prototypes/java/src/org/nmra/net/DatagramRejectedMessage.java
===================================================================
--- trunk/prototypes/java/src/org/nmra/net/DatagramRejectedMessage.java 2009-11-16 22:47:09 UTC (rev 154)
+++ trunk/prototypes/java/src/org/nmra/net/DatagramRejectedMessage.java 2009-11-16 23:18:33 UTC (rev 155)
@@ -1,26 +0,0 @@
-package org.nmra.net;
-
-/**
- * Datagram Rejected message implementation
- *
- * @author Bob Jacobsen Copyright 2009
- * @version $Revision$
- */
-public class DatagramRejectedMessage extends Message {
-
- public DatagramRejectedMessage(NodeID source, NodeID dest) {
- 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.handleDatagramRejected(this, sender);
- }
-}
Deleted: trunk/prototypes/java/src/org/nmra/net/EventID.java
===================================================================
--- trunk/prototypes/java/src/org/nmra/net/EventID.java 2009-11-16 22:47:09 UTC (rev 154)
+++ trunk/prototypes/java/src/org/nmra/net/EventID.java 2009-11-16 23:18:33 UTC (rev 155)
@@ -1,69 +0,0 @@
-package org.nmra.net;
-
-/**
- * Common EventID implementation.
- * <p>
- * EventID objects are immutable once created.
- *
- * @author Bob Jacobsen Copyright 2009
- * @version $Revision$
- */
-public class EventID {
-
- static final int BYTECOUNT = 8;
-
- public EventID(NodeID node, int b7, int b8) {
- this.contents = new byte[BYTECOUNT];
- for (int i = 0; i < BYTECOUNT-2; i++)
- this.contents[i] = node.contents[i];
-
- this.contents[6] = (byte)b7;
- this.contents[7] = (byte)b8;
- }
-
- public EventID(byte[] contents) {
- if (contents == null)
- throw new java.lang.IllegalArgumentException("null argument invalid");
- if (contents.length != BYTECOUNT)
- throw new java.lang.IllegalArgumentException("Wrong EventID length: "+contents.length);
- this.contents = new byte[BYTECOUNT];
- for (int i = 0; i < BYTECOUNT; i++)
- this.contents[i] = contents[i];
- }
-
- byte[] contents;
-
- public boolean equals(Object o){
- // try to cast, else not equal
- try {
- EventID other = (EventID) o;
- for (int i = 0; i<BYTECOUNT; i++)
- if (other.contents[i] != this.contents[i]) return false;
- return true;
- } catch (Exception e) {
- return false;
- }
- }
- public int hashCode() {
- return contents[0]<<21
- +contents[1]<<18
- +contents[2]<<15
- +contents[3]<<12
- +contents[4]<<9
- +contents[5]<<6
- +contents[6]<<3
- +contents[7];
- }
-
- public String toString() {
- return "Event:"
- +contents[0]+","
- +contents[1]+","
- +contents[2]+","
- +contents[3]+","
- +contents[4]+","
- +contents[5]+","
- +contents[6]+","
- +contents[7];
- }
-}
Deleted: trunk/prototypes/java/src/org/nmra/net/Gateway.java
===================================================================
--- trunk/prototypes/java/src/org/nmra/net/Gateway.java 2009-11-16 22:47:09 UTC (rev 154)
+++ trunk/prototypes/java/src/org/nmra/net/Gateway.java 2009-11-16 23:18:33 UTC (rev 155)
@@ -1,73 +0,0 @@
-package org.nmra.net;
-
-/**
- * Base for NRMAnet gateway implementations.
- *<p>
- * Provides two connections, called "East" and "West"
- *
- * @author Bob Jacobsen Copyright 2009
- * @version $Revision$
- */
-public class Gateway extends MessageDecoder {
- public Gateway() {
- }
-
- /**
- * Provide a connection object for use by
- * the East node.
- */
- public Connection getEastConnection() {
- eastInputConnection = new Connection() {
- public void put(Message msg, Connection sender) {
- sendMessageToWest(msg, sender);
- }
- };
- return eastInputConnection;
- }
-
- // forward from east to west
- protected void sendMessageToWest(Message msg, Connection sender) {
- if (westOutputConnection == null)
- throw new AssertionError("west was null when message sent");
- westOutputConnection.put(msg, westInputConnection);
- }
-
- public void registerEast(Connection c) {
- if (eastOutputConnection != null)
- throw new AssertionError("east already registered");
- eastOutputConnection = c;
- }
-
- protected Connection eastOutputConnection; // what I send to on east side
- protected Connection eastInputConnection; // to me, I show as sender on east side
-
- /**
- * Provide a connection object for use by
- * the West node.
- */
- public Connection getWestConnection() {
- westInputConnection = new Connection() {
- public void put(Message msg, Connection sender) {
- sendMessageToEast(msg, sender);
- }
- };
- return westInputConnection;
- }
-
- // forward from west to east
- protected void sendMessageToEast(Message msg, Connection sender) {
- if (eastOutputConnection == null)
- throw new AssertionError("east was null when message sent");
- eastOutputConnection.put(msg, eastInputConnection);
- }
-
- public void registerWest(Connection c) {
- if (westOutputConnection != null)
- throw new AssertionError("west already registered");
- westOutputConnection = c;
- }
-
- protected Connection westOutputConnection; // what I send to on west side
- protected Connection westInputConnection; // to me, I show as sender on west side
-
-}
\ No newline at end of file
Deleted: trunk/prototypes/java/src/org/nmra/net/IdentifyConsumersMessage.java
===================================================================
--- trunk/prototypes/java/src/org/nmra/net/IdentifyConsumersMessage.java 2009-11-16 22:47:09 UTC (rev 154)
+++ trunk/prototypes/java/src/org/nmra/net/IdentifyConsumersMessage.java 2009-11-16 23:18:33 UTC (rev 155)
@@ -1,46 +0,0 @@
-package org.nmra.net;
-
-/**
- * Identify Consumers message implementation
- *
- * @author Bob Jacobsen Copyright 2009
- * @version $Revision$
- */
-public class IdentifyConsumersMessage extends Message {
-
- public IdentifyConsumersMessage(NodeID source, EventID event) {
- super(source);
- this.eventID = event;
- }
-
- EventID eventID = null;
- /**
- * 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.handleIdentifyConsumers(this, sender);
- }
-
- /**
- * To be equal, messages have to have the
- * same type and content
- */
- @Override
- public boolean equals(Object o) {
- if (!super.equals(o)) return false; // also checks type
- IdentifyConsumersMessage msg = (IdentifyConsumersMessage) o;
- if (! this.eventID.equals(msg.eventID))
- return false;
- return true;
- }
-
- public String toString() {
- return getSourceNodeID().toString()
- +" Identify Consumers with "+eventID.toString();
- }
-}
Deleted: trunk/prototypes/java/src/org/nmra/net/IdentifyEventsMessage.java
===================================================================
--- trunk/prototypes/java/src/org/nmra/net/IdentifyEventsMessage.java 2009-11-16 22:47:09 UTC (rev 154)
+++ trunk/prototypes/java/src/org/nmra/net/IdentifyEventsMessage.java 2009-11-16 23:18:33 UTC (rev 155)
@@ -1,30 +0,0 @@
-package org.nmra.net;
-
-/**
- * Identify Events message implementation
- *
- * @author Bob Jacobsen Copyright 2009
- * @version $Revision$
- */
-public class IdentifyEventsMessage extends Message {
-
- public IdentifyEventsMessage(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.handleIdentifyEvents(this, sender);
- }
- public String toString() {
- return getSourceNodeID().toString()
- +" Identify Events ";
- }
-}
Deleted: trunk/prototypes/java/src/org/nmra/net/IdentifyProducersMessage.java
===================================================================
--- trunk/prototypes/java/src/org/nmra/net/IdentifyProducersMessage.java 2009-11-16 22:47:09 UTC (rev 154)
+++ trunk/prototypes/java/src/org/nmra/net/IdentifyProducersMessage.java 2009-11-16 23:18:33 UTC (rev 155)
@@ -1,46 +0,0 @@
-package org.nmra.net;
-
-/**
- * Identify Producers message implementation
- *
- * @author Bob Jacobsen Copyright 2009
- * @version $Revision$
- */
-public class IdentifyProducersMessage extends Message {
-
- public IdentifyProducersMessage(NodeID source, EventID eventID) {
- super(source);
- this.eventID = eventID;
- }
-
- EventID eventID;
- /**
- * 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.handleIdentifyProducers(this, sender);
- }
-
- /**
- * To be equal, messages have to have the
- * same type and content
- */
- @Override
- public boolean equals(Object o) {
- if (!super.equals(o)) return false; // also checks type
- IdentifyProducersMessage msg = (IdentifyProducersMessage) o;
- if (! this.eventID.equals(msg.eventID))
- return false;
- return true;
- }
-
- public String toString() {
- return getSourceNodeID().toString()
- +" Identify Producers with "+eventID.toString();
- }
-}
Deleted: trunk/prototypes/java/src/org/nmra/net/InitializationCompleteMessage.java
===================================================================
--- trunk/prototypes/java/src/org/nmra/net/InitializationCompleteMessage.java 2009-11-16 22:47:09 UTC (rev 154)
+++ trunk/prototypes/java/src/org/nmra/net/InitializationCompleteMessage.java 2009-11-16 23:18:33 UTC (rev 155)
@@ -1,30 +0,0 @@
-package org.nmra.net;
-
-/**
- * Initialization Complete message implementation
- *
- * @author Bob Jacobsen Copyright 2009
- * @version $Revision$
- */
-public class InitializationCompleteMessage extends Message {
-...
[truncated message content] |
|
From: <jac...@us...> - 2009-11-16 23:53:24
|
Revision: 160
http://openlcb.svn.sourceforge.net/openlcb/?rev=160&view=rev
Author: jacobsen
Date: 2009-11-16 23:53:15 +0000 (Mon, 16 Nov 2009)
Log Message:
-----------
rename
Modified Paths:
--------------
trunk/prototypes/java/src/org/openlcb/MessageDecoder.java
trunk/prototypes/java/src/org/openlcb/implementations/BlueGoldEngine.java
trunk/prototypes/java/src/org/openlcb/implementations/DatagramReceiver.java
trunk/prototypes/java/src/org/openlcb/implementations/DatagramTransmitter.java
trunk/prototypes/java/src/org/openlcb/implementations/SingleConsumer.java
trunk/prototypes/java/src/org/openlcb/implementations/SingleConsumerNode.java
trunk/prototypes/java/src/org/openlcb/implementations/SingleProducerNode.java
trunk/prototypes/java/src/org/openlcb/implementations/StreamReceiver.java
trunk/prototypes/java/src/org/openlcb/implementations/StreamTransmitter.java
trunk/prototypes/java/src/org/openlcb/package.html
trunk/prototypes/java/test/package.html
Modified: trunk/prototypes/java/src/org/openlcb/MessageDecoder.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/MessageDecoder.java 2009-11-16 23:49:19 UTC (rev 159)
+++ trunk/prototypes/java/src/org/openlcb/MessageDecoder.java 2009-11-16 23:53:15 UTC (rev 160)
@@ -2,7 +2,7 @@
/**
* This class provides a basic double-dispatch mechanism for handling
- * messages. NMRAnet messages in this implementation
+ * messages. OpenLCB messages in this implementation
* are of separate type. To simplify the operation of
* specific Node implementions, this base class provides
* a dispatch mechanism, in cooperation with the Message types,
Modified: trunk/prototypes/java/src/org/openlcb/implementations/BlueGoldEngine.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/implementations/BlueGoldEngine.java 2009-11-16 23:49:19 UTC (rev 159)
+++ trunk/prototypes/java/src/org/openlcb/implementations/BlueGoldEngine.java 2009-11-16 23:53:15 UTC (rev 160)
@@ -3,7 +3,7 @@
import org.openlcb.*;
/**
- * Example of a NMRAnet algorithm for doing configuration with
+ * Example of a OpenLCB algorithm for doing configuration with
* small number of buttons.
*<p>
* This handles both "configuring" and "being configured"
Modified: trunk/prototypes/java/src/org/openlcb/implementations/DatagramReceiver.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/implementations/DatagramReceiver.java 2009-11-16 23:49:19 UTC (rev 159)
+++ trunk/prototypes/java/src/org/openlcb/implementations/DatagramReceiver.java 2009-11-16 23:53:15 UTC (rev 160)
@@ -3,7 +3,7 @@
import org.openlcb.*;
/**
- * Example of receiving a NMRAnet datagram.
+ * Example of receiving a OpenLCB datagram.
*<p>
*
* @author Bob Jacobsen Copyright 2009
Modified: trunk/prototypes/java/src/org/openlcb/implementations/DatagramTransmitter.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/implementations/DatagramTransmitter.java 2009-11-16 23:49:19 UTC (rev 159)
+++ trunk/prototypes/java/src/org/openlcb/implementations/DatagramTransmitter.java 2009-11-16 23:53:15 UTC (rev 160)
@@ -3,7 +3,7 @@
import org.openlcb.*;
/**
- * Example of sending a NMRAnet datagram.
+ * Example of sending a OpenLCB datagram.
*<p>
*
* @author Bob Jacobsen Copyright 2009
Modified: trunk/prototypes/java/src/org/openlcb/implementations/SingleConsumer.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/implementations/SingleConsumer.java 2009-11-16 23:49:19 UTC (rev 159)
+++ trunk/prototypes/java/src/org/openlcb/implementations/SingleConsumer.java 2009-11-16 23:53:15 UTC (rev 160)
@@ -3,10 +3,10 @@
import org.openlcb.*;
/**
- * Example of a NMRAnet node that consumes one Event.
+ * Example of a OpenLCB node that consumes one Event.
*<p>
* The event doesn't cause much to happen, but e.g.
- * a {@link org.nmra.net.swing.ConsumerPane} can display
+ * a {@link org.openlcb.swing.ConsumerPane} can display
* it.
*
* @author Bob Jacobsen Copyright 2009
Modified: trunk/prototypes/java/src/org/openlcb/implementations/SingleConsumerNode.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/implementations/SingleConsumerNode.java 2009-11-16 23:49:19 UTC (rev 159)
+++ trunk/prototypes/java/src/org/openlcb/implementations/SingleConsumerNode.java 2009-11-16 23:53:15 UTC (rev 160)
@@ -3,7 +3,7 @@
import org.openlcb.*;
/**
- * Example of a NMRAnet node that consumes one Event.
+ * Example of a OpenLCB node that consumes one Event.
*<p>
* The event doesn't cause much to happen, but e.g.
* a {@link org.nmra.net.swing.ConsumerPane} can display
Modified: trunk/prototypes/java/src/org/openlcb/implementations/SingleProducerNode.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/implementations/SingleProducerNode.java 2009-11-16 23:49:19 UTC (rev 159)
+++ trunk/prototypes/java/src/org/openlcb/implementations/SingleProducerNode.java 2009-11-16 23:53:15 UTC (rev 160)
@@ -3,7 +3,7 @@
import org.openlcb.*;
/**
- * Example of a NMRAnet node that produces one Event.
+ * Example of a OpenLCB node that produces one Event.
*
* @author Bob Jacobsen Copyright 2009
* @version $Revision$
Modified: trunk/prototypes/java/src/org/openlcb/implementations/StreamReceiver.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/implementations/StreamReceiver.java 2009-11-16 23:49:19 UTC (rev 159)
+++ trunk/prototypes/java/src/org/openlcb/implementations/StreamReceiver.java 2009-11-16 23:53:15 UTC (rev 160)
@@ -3,7 +3,7 @@
import org.openlcb.*;
/**
- * Example of receiving a NMRAnet stream.
+ * Example of receiving a OpenLCB stream.
*<p>
*
* @author Bob Jacobsen Copyright 2009
Modified: trunk/prototypes/java/src/org/openlcb/implementations/StreamTransmitter.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/implementations/StreamTransmitter.java 2009-11-16 23:49:19 UTC (rev 159)
+++ trunk/prototypes/java/src/org/openlcb/implementations/StreamTransmitter.java 2009-11-16 23:53:15 UTC (rev 160)
@@ -3,7 +3,7 @@
import org.openlcb.*;
/**
- * Example of sending a NMRAnet stream.
+ * Example of sending a OpenLCB stream.
*<p>
* This implementation is limited to sending
* from a fixed-size input array. The protocol
Modified: trunk/prototypes/java/src/org/openlcb/package.html
===================================================================
--- trunk/prototypes/java/src/org/openlcb/package.html 2009-11-16 23:49:19 UTC (rev 159)
+++ trunk/prototypes/java/src/org/openlcb/package.html 2009-11-16 23:53:15 UTC (rev 160)
@@ -14,11 +14,11 @@
</head>
<body bgcolor="white">
-Basic interfaces and classes for a test implemention of NMRAnet.
+Basic interfaces and classes for a test implemention of OpenLCB.
<p>
This is not intended as a base for production implementations,
but rather a convenient toolset for creating tests and demonstrations
-of NMRAnet protocols.
+of OpenLCB protocols.
<!-- Put @see and @since tags down here. -->
<!-- @see foo.Bar -->
Modified: trunk/prototypes/java/test/package.html
===================================================================
--- trunk/prototypes/java/test/package.html 2009-11-16 23:49:19 UTC (rev 159)
+++ trunk/prototypes/java/test/package.html 2009-11-16 23:53:15 UTC (rev 160)
@@ -19,7 +19,7 @@
<p>
Subpackages:
<ul>
-<li>org.nmra.net - unit tests of specific classes in the src tree
+<li>org.openlcb - unit tests of specific classes in the src tree
<li>tools - tool and simulation implementations
</ul>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jac...@us...> - 2009-11-16 23:53:24
|
Revision: 160
http://openlcb.svn.sourceforge.net/openlcb/?rev=160&view=rev
Author: jacobsen
Date: 2009-11-16 23:53:15 +0000 (Mon, 16 Nov 2009)
Log Message:
-----------
rename
Modified Paths:
--------------
trunk/prototypes/java/src/org/openlcb/MessageDecoder.java
trunk/prototypes/java/src/org/openlcb/implementations/BlueGoldEngine.java
trunk/prototypes/java/src/org/openlcb/implementations/DatagramReceiver.java
trunk/prototypes/java/src/org/openlcb/implementations/DatagramTransmitter.java
trunk/prototypes/java/src/org/openlcb/implementations/SingleConsumer.java
trunk/prototypes/java/src/org/openlcb/implementations/SingleConsumerNode.java
trunk/prototypes/java/src/org/openlcb/implementations/SingleProducerNode.java
trunk/prototypes/java/src/org/openlcb/implementations/StreamReceiver.java
trunk/prototypes/java/src/org/openlcb/implementations/StreamTransmitter.java
trunk/prototypes/java/src/org/openlcb/package.html
trunk/prototypes/java/test/package.html
Modified: trunk/prototypes/java/src/org/openlcb/MessageDecoder.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/MessageDecoder.java 2009-11-16 23:49:19 UTC (rev 159)
+++ trunk/prototypes/java/src/org/openlcb/MessageDecoder.java 2009-11-16 23:53:15 UTC (rev 160)
@@ -2,7 +2,7 @@
/**
* This class provides a basic double-dispatch mechanism for handling
- * messages. NMRAnet messages in this implementation
+ * messages. OpenLCB messages in this implementation
* are of separate type. To simplify the operation of
* specific Node implementions, this base class provides
* a dispatch mechanism, in cooperation with the Message types,
Modified: trunk/prototypes/java/src/org/openlcb/implementations/BlueGoldEngine.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/implementations/BlueGoldEngine.java 2009-11-16 23:49:19 UTC (rev 159)
+++ trunk/prototypes/java/src/org/openlcb/implementations/BlueGoldEngine.java 2009-11-16 23:53:15 UTC (rev 160)
@@ -3,7 +3,7 @@
import org.openlcb.*;
/**
- * Example of a NMRAnet algorithm for doing configuration with
+ * Example of a OpenLCB algorithm for doing configuration with
* small number of buttons.
*<p>
* This handles both "configuring" and "being configured"
Modified: trunk/prototypes/java/src/org/openlcb/implementations/DatagramReceiver.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/implementations/DatagramReceiver.java 2009-11-16 23:49:19 UTC (rev 159)
+++ trunk/prototypes/java/src/org/openlcb/implementations/DatagramReceiver.java 2009-11-16 23:53:15 UTC (rev 160)
@@ -3,7 +3,7 @@
import org.openlcb.*;
/**
- * Example of receiving a NMRAnet datagram.
+ * Example of receiving a OpenLCB datagram.
*<p>
*
* @author Bob Jacobsen Copyright 2009
Modified: trunk/prototypes/java/src/org/openlcb/implementations/DatagramTransmitter.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/implementations/DatagramTransmitter.java 2009-11-16 23:49:19 UTC (rev 159)
+++ trunk/prototypes/java/src/org/openlcb/implementations/DatagramTransmitter.java 2009-11-16 23:53:15 UTC (rev 160)
@@ -3,7 +3,7 @@
import org.openlcb.*;
/**
- * Example of sending a NMRAnet datagram.
+ * Example of sending a OpenLCB datagram.
*<p>
*
* @author Bob Jacobsen Copyright 2009
Modified: trunk/prototypes/java/src/org/openlcb/implementations/SingleConsumer.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/implementations/SingleConsumer.java 2009-11-16 23:49:19 UTC (rev 159)
+++ trunk/prototypes/java/src/org/openlcb/implementations/SingleConsumer.java 2009-11-16 23:53:15 UTC (rev 160)
@@ -3,10 +3,10 @@
import org.openlcb.*;
/**
- * Example of a NMRAnet node that consumes one Event.
+ * Example of a OpenLCB node that consumes one Event.
*<p>
* The event doesn't cause much to happen, but e.g.
- * a {@link org.nmra.net.swing.ConsumerPane} can display
+ * a {@link org.openlcb.swing.ConsumerPane} can display
* it.
*
* @author Bob Jacobsen Copyright 2009
Modified: trunk/prototypes/java/src/org/openlcb/implementations/SingleConsumerNode.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/implementations/SingleConsumerNode.java 2009-11-16 23:49:19 UTC (rev 159)
+++ trunk/prototypes/java/src/org/openlcb/implementations/SingleConsumerNode.java 2009-11-16 23:53:15 UTC (rev 160)
@@ -3,7 +3,7 @@
import org.openlcb.*;
/**
- * Example of a NMRAnet node that consumes one Event.
+ * Example of a OpenLCB node that consumes one Event.
*<p>
* The event doesn't cause much to happen, but e.g.
* a {@link org.nmra.net.swing.ConsumerPane} can display
Modified: trunk/prototypes/java/src/org/openlcb/implementations/SingleProducerNode.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/implementations/SingleProducerNode.java 2009-11-16 23:49:19 UTC (rev 159)
+++ trunk/prototypes/java/src/org/openlcb/implementations/SingleProducerNode.java 2009-11-16 23:53:15 UTC (rev 160)
@@ -3,7 +3,7 @@
import org.openlcb.*;
/**
- * Example of a NMRAnet node that produces one Event.
+ * Example of a OpenLCB node that produces one Event.
*
* @author Bob Jacobsen Copyright 2009
* @version $Revision$
Modified: trunk/prototypes/java/src/org/openlcb/implementations/StreamReceiver.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/implementations/StreamReceiver.java 2009-11-16 23:49:19 UTC (rev 159)
+++ trunk/prototypes/java/src/org/openlcb/implementations/StreamReceiver.java 2009-11-16 23:53:15 UTC (rev 160)
@@ -3,7 +3,7 @@
import org.openlcb.*;
/**
- * Example of receiving a NMRAnet stream.
+ * Example of receiving a OpenLCB stream.
*<p>
*
* @author Bob Jacobsen Copyright 2009
Modified: trunk/prototypes/java/src/org/openlcb/implementations/StreamTransmitter.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/implementations/StreamTransmitter.java 2009-11-16 23:49:19 UTC (rev 159)
+++ trunk/prototypes/java/src/org/openlcb/implementations/StreamTransmitter.java 2009-11-16 23:53:15 UTC (rev 160)
@@ -3,7 +3,7 @@
import org.openlcb.*;
/**
- * Example of sending a NMRAnet stream.
+ * Example of sending a OpenLCB stream.
*<p>
* This implementation is limited to sending
* from a fixed-size input array. The protocol
Modified: trunk/prototypes/java/src/org/openlcb/package.html
===================================================================
--- trunk/prototypes/java/src/org/openlcb/package.html 2009-11-16 23:49:19 UTC (rev 159)
+++ trunk/prototypes/java/src/org/openlcb/package.html 2009-11-16 23:53:15 UTC (rev 160)
@@ -14,11 +14,11 @@
</head>
<body bgcolor="white">
-Basic interfaces and classes for a test implemention of NMRAnet.
+Basic interfaces and classes for a test implemention of OpenLCB.
<p>
This is not intended as a base for production implementations,
but rather a convenient toolset for creating tests and demonstrations
-of NMRAnet protocols.
+of OpenLCB protocols.
<!-- Put @see and @since tags down here. -->
<!-- @see foo.Bar -->
Modified: trunk/prototypes/java/test/package.html
===================================================================
--- trunk/prototypes/java/test/package.html 2009-11-16 23:49:19 UTC (rev 159)
+++ trunk/prototypes/java/test/package.html 2009-11-16 23:53:15 UTC (rev 160)
@@ -19,7 +19,7 @@
<p>
Subpackages:
<ul>
-<li>org.nmra.net - unit tests of specific classes in the src tree
+<li>org.openlcb - unit tests of specific classes in the src tree
<li>tools - tool and simulation implementations
</ul>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jac...@us...> - 2009-11-16 23:56:29
|
Revision: 161
http://openlcb.svn.sourceforge.net/openlcb/?rev=161&view=rev
Author: jacobsen
Date: 2009-11-16 23:56:19 +0000 (Mon, 16 Nov 2009)
Log Message:
-----------
rename
Modified Paths:
--------------
trunk/prototypes/java/index.html
trunk/prototypes/java/manifest
trunk/prototypes/java/test/scenarios/can/NineOnASegment.java
Modified: trunk/prototypes/java/index.html
===================================================================
--- trunk/prototypes/java/index.html 2009-11-16 23:53:15 UTC (rev 160)
+++ trunk/prototypes/java/index.html 2009-11-16 23:56:19 UTC (rev 161)
@@ -14,9 +14,9 @@
<!-- $Id$ -->
</HEAD>
<BODY LANG="en-US" DIR="LTR">
-<H1>9.6 Proposal Java Prototypes Directory</H1>
+<H1>OpenLCB Proposal Java Prototypes Directory</H1>
<P>This directory contains prototype implementation(s) in Java of the
-S9.6 proposed NMRAnet specification.
+proposed OpenLCB specification.
</P>
<P>These are primarily intended for testing proposed algorithms, not
as a first implementation for use.
@@ -25,8 +25,8 @@
<DL>
<DT>src
</DT><DD>
- Contains NMRAnet source in the org.nmra.net package, and source for
- NMRAnet CAN wire protocol in the org.nmra.net.can package.
+ Contains OpenLCB source in the org.openlcb package, and source for
+ OpenLCB CAN wire protocol in the org.openlcb.can package.
</DD><DT>
test
</DT><DD STYLE="margin-bottom: 0.5cm">
@@ -34,14 +34,14 @@
</DD></DL>
<UL>
<LI><DD STYLE="margin-bottom: 0.5cm">
- org.nmra.net – unit tests for the implementation code</DD><LI><DD STYLE="margin-bottom: 0.5cm">
+ org.openlcb – unit tests for the implementation code</DD><LI><DD STYLE="margin-bottom: 0.5cm">
tools – various non-NMRAnet implementation for testing, including
a small CAN segment simulator</DD><LI><DD STYLE="margin-bottom: 0.5cm">
- scenarios – tests of operation of multiple NMRAnet classes
- simulating various NMRAnet use scenarios</DD></UL>
+ scenarios – tests of operation of multiple OpenLCB classes
+ simulating various OpenLCB use scenarios</DD></UL>
<P>For example, <A HREF="test/scenarios/TwoBusesFiltered.java">test/scenarios/TwoBusesFiltered.java</A>
-contains a scenario where two NMRAnet CAN segments are connected via
-a TCP/IP link and filtering gateways. The NMRA net implementation is
+contains a scenario where two OpenLCB CAN segments are connected via
+a TCP/IP link and filtering gateways. The OpenLCB implementation is
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>
Modified: trunk/prototypes/java/manifest
===================================================================
--- trunk/prototypes/java/manifest 2009-11-16 23:53:15 UTC (rev 160)
+++ trunk/prototypes/java/manifest 2009-11-16 23:56:19 UTC (rev 161)
@@ -2,11 +2,11 @@
Main-Class: scenarios.BlueGoldCheck
Class-Path: lib/junit.jar
-Name: org.nmra.nmranet
-Specification-Title: \xD2NMRAnet\xD3
+Name: org.openlcb
+Specification-Title: \xD2OpenLCB\xD3
Specification-Version: \xD20.0\xD3
-Specification-Vendor: \xD2NMRAnet WG"
-Package-Title: \xD2nmranet\xD3
+Specification-Vendor: \xD2OpenLCB group"
+Package-Title: \xD2openlcb\xD3
Package-Version: \xD20.0\xD3
-Package-Vendor: \xD2NMRAnet WG\xD3
+Package-Vendor: \xD2OpenLCB group\xD3
Modified: trunk/prototypes/java/test/scenarios/can/NineOnASegment.java
===================================================================
--- trunk/prototypes/java/test/scenarios/can/NineOnASegment.java 2009-11-16 23:53:15 UTC (rev 160)
+++ trunk/prototypes/java/test/scenarios/can/NineOnASegment.java 2009-11-16 23:56:19 UTC (rev 161)
@@ -9,7 +9,7 @@
import junit.framework.TestSuite;
/**
- * Simulate nine nodes interacting on a single CAN bus NMRAnet segment.
+ * Simulate nine nodes interacting on a single CAN bus OpenLCB segment.
*
* <ul>
* <li>Nodes 1,2,3 send Event A to 8,9
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jac...@us...> - 2009-11-16 23:56:31
|
Revision: 161
http://openlcb.svn.sourceforge.net/openlcb/?rev=161&view=rev
Author: jacobsen
Date: 2009-11-16 23:56:19 +0000 (Mon, 16 Nov 2009)
Log Message:
-----------
rename
Modified Paths:
--------------
trunk/prototypes/java/index.html
trunk/prototypes/java/manifest
trunk/prototypes/java/test/scenarios/can/NineOnASegment.java
Modified: trunk/prototypes/java/index.html
===================================================================
--- trunk/prototypes/java/index.html 2009-11-16 23:53:15 UTC (rev 160)
+++ trunk/prototypes/java/index.html 2009-11-16 23:56:19 UTC (rev 161)
@@ -14,9 +14,9 @@
<!-- $Id$ -->
</HEAD>
<BODY LANG="en-US" DIR="LTR">
-<H1>9.6 Proposal Java Prototypes Directory</H1>
+<H1>OpenLCB Proposal Java Prototypes Directory</H1>
<P>This directory contains prototype implementation(s) in Java of the
-S9.6 proposed NMRAnet specification.
+proposed OpenLCB specification.
</P>
<P>These are primarily intended for testing proposed algorithms, not
as a first implementation for use.
@@ -25,8 +25,8 @@
<DL>
<DT>src
</DT><DD>
- Contains NMRAnet source in the org.nmra.net package, and source for
- NMRAnet CAN wire protocol in the org.nmra.net.can package.
+ Contains OpenLCB source in the org.openlcb package, and source for
+ OpenLCB CAN wire protocol in the org.openlcb.can package.
</DD><DT>
test
</DT><DD STYLE="margin-bottom: 0.5cm">
@@ -34,14 +34,14 @@
</DD></DL>
<UL>
<LI><DD STYLE="margin-bottom: 0.5cm">
- org.nmra.net – unit tests for the implementation code</DD><LI><DD STYLE="margin-bottom: 0.5cm">
+ org.openlcb – unit tests for the implementation code</DD><LI><DD STYLE="margin-bottom: 0.5cm">
tools – various non-NMRAnet implementation for testing, including
a small CAN segment simulator</DD><LI><DD STYLE="margin-bottom: 0.5cm">
- scenarios – tests of operation of multiple NMRAnet classes
- simulating various NMRAnet use scenarios</DD></UL>
+ scenarios – tests of operation of multiple OpenLCB classes
+ simulating various OpenLCB use scenarios</DD></UL>
<P>For example, <A HREF="test/scenarios/TwoBusesFiltered.java">test/scenarios/TwoBusesFiltered.java</A>
-contains a scenario where two NMRAnet CAN segments are connected via
-a TCP/IP link and filtering gateways. The NMRA net implementation is
+contains a scenario where two OpenLCB CAN segments are connected via
+a TCP/IP link and filtering gateways. The OpenLCB implementation is
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>
Modified: trunk/prototypes/java/manifest
===================================================================
--- trunk/prototypes/java/manifest 2009-11-16 23:53:15 UTC (rev 160)
+++ trunk/prototypes/java/manifest 2009-11-16 23:56:19 UTC (rev 161)
@@ -2,11 +2,11 @@
Main-Class: scenarios.BlueGoldCheck
Class-Path: lib/junit.jar
-Name: org.nmra.nmranet
-Specification-Title: \xD2NMRAnet\xD3
+Name: org.openlcb
+Specification-Title: \xD2OpenLCB\xD3
Specification-Version: \xD20.0\xD3
-Specification-Vendor: \xD2NMRAnet WG"
-Package-Title: \xD2nmranet\xD3
+Specification-Vendor: \xD2OpenLCB group"
+Package-Title: \xD2openlcb\xD3
Package-Version: \xD20.0\xD3
-Package-Vendor: \xD2NMRAnet WG\xD3
+Package-Vendor: \xD2OpenLCB group\xD3
Modified: trunk/prototypes/java/test/scenarios/can/NineOnASegment.java
===================================================================
--- trunk/prototypes/java/test/scenarios/can/NineOnASegment.java 2009-11-16 23:53:15 UTC (rev 160)
+++ trunk/prototypes/java/test/scenarios/can/NineOnASegment.java 2009-11-16 23:56:19 UTC (rev 161)
@@ -9,7 +9,7 @@
import junit.framework.TestSuite;
/**
- * Simulate nine nodes interacting on a single CAN bus NMRAnet segment.
+ * Simulate nine nodes interacting on a single CAN bus OpenLCB segment.
*
* <ul>
* <li>Nodes 1,2,3 send Event A to 8,9
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jac...@us...> - 2009-11-17 00:01:25
|
Revision: 162
http://openlcb.svn.sourceforge.net/openlcb/?rev=162&view=rev
Author: jacobsen
Date: 2009-11-17 00:01:18 +0000 (Tue, 17 Nov 2009)
Log Message:
-----------
rename
Modified Paths:
--------------
trunk/prototypes/java/src/org/openlcb/can/NIDaAlgorithm.java
trunk/prototypes/java/test/org/openlcb/can/CanTest.java
trunk/prototypes/java/test/org/openlcb/can/NIDaAlgorithmTest.java
Added Paths:
-----------
trunk/prototypes/java/src/org/openlcb/can/OpenLcbCanFrame.java
trunk/prototypes/java/test/org/openlcb/can/OpenLcbCanFrameTest.java
Removed Paths:
-------------
trunk/prototypes/java/src/org/openlcb/can/NmraNetCanFrame.java
trunk/prototypes/java/test/org/openlcb/can/NmraNetCanFrameTest.java
Modified: trunk/prototypes/java/src/org/openlcb/can/NIDaAlgorithm.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/can/NIDaAlgorithm.java 2009-11-16 23:56:19 UTC (rev 161)
+++ trunk/prototypes/java/src/org/openlcb/can/NIDaAlgorithm.java 2009-11-17 00:01:18 UTC (rev 162)
@@ -18,12 +18,12 @@
nida = new NIDa(n);
}
- public NmraNetCanFrame nextFrame() {
- NmraNetCanFrame f;
+ public OpenLcbCanFrame nextFrame() {
+ OpenLcbCanFrame f;
if (index<6)
- f = NmraNetCanFrame.makeCimFrame(nida.getNIDa(), 0, 0);
+ f = OpenLcbCanFrame.makeCimFrame(nida.getNIDa(), 0, 0);
else if (index == 6) {
- f = NmraNetCanFrame.makeRimFrame(nida.getNIDa(), nid);
+ f = OpenLcbCanFrame.makeRimFrame(nida.getNIDa(), nid);
complete = true;
} else {
// send nothing
@@ -35,7 +35,7 @@
public long getNIDa() { return nida.getNIDa(); }
- public void processFrame(NmraNetCanFrame f) {
+ public void processFrame(OpenLcbCanFrame f) {
if (f == null) return; // as a convenience, ignore
// System.out.println("process "+Integer.toHexString(f.getNodeIDa())
Deleted: trunk/prototypes/java/src/org/openlcb/can/NmraNetCanFrame.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/can/NmraNetCanFrame.java 2009-11-16 23:56:19 UTC (rev 161)
+++ trunk/prototypes/java/src/org/openlcb/can/NmraNetCanFrame.java 2009-11-17 00:01:18 UTC (rev 162)
@@ -1,111 +0,0 @@
-package org.openlcb.can;
-
-import org.openlcb.*;
-
-/**
- * Carry and work with a CAN frame in NMRAnet format.
- *
- * Immutable once created.
- *
- * @author Bob Jacobsen Copyright 2009
- * @version $Revision$
- */
-
-
-public class NmraNetCanFrame implements org.openlcb.can.CanFrame {
-
- public static NmraNetCanFrame makeCimFrame(int alias, int num, int val) {
- return new NmraNetCanFrame( (0<<26) | (alias&0xffffff));
- }
-
- public static NmraNetCanFrame makeRimFrame(int alias, NodeID n) {
- return new NmraNetCanFrame( (1<<26) | (alias&0xffffff),
- n.getContents());
- }
-
- static int makeHeader(int alias) {
- return
- (alias&0xFFFFFF);
- }
-
- // data is stored in completed form as
- // a header and data content; accessors go
- // back and forth to individual fields.
- long header;
- byte[] bytes;
-
- public NmraNetCanFrame(long header) {
- this.header = header;
- }
-
- public NmraNetCanFrame(long header, byte[] bytes) {
- this(header);
- if (bytes.length > 8) {
- throw new IllegalArgumentException("payload too long: "+bytes);
- }
- this.bytes = bytes;
- }
-
- public enum MessageType {
- PCIR,
- example;
- }
-
- public boolean isDidPresent() {
- return (header&0x0000001) != 0;
- }
-
- // Frame itself is immutable
- static public long setDidPresent(long header, boolean present) {
- return header | 0x0000001;
- }
-
- public enum TypeField {
- CHECKIDMESSAGE,
- RESERVEDIDMESSAGE,
- CANMESSAGE,
- NMRANETCOMMONMESSAGE;
- }
-
- public TypeField getTypeField() {
- return TypeField.values()[(int)((getHeader() & 0x0C000000) >> 26)];
- }
-
- // Frame itself is immutable
- static public long setTypeField(long header, TypeField v) {
- return (header&~0x0C000000)|(v.ordinal() << 26);
- }
-
- public long getHeader() { return header; }
-
- public int getNodeIDa() { return (int)getHeader()&0xFFFFFF; }
-
- public boolean isCIM() { return (getTypeField() == TypeField.CHECKIDMESSAGE); }
- public boolean isRIM() { return (getTypeField() == TypeField.RESERVEDIDMESSAGE); }
-
- public boolean equals(Object other) {
- // try to cast, else not equal
- try {
- NmraNetCanFrame c = (NmraNetCanFrame) other;
- if (this.header != c.header) return false;
- if (this.bytes == null && c.bytes == null) return true;
- if (this.bytes == null && c.bytes != null) return false;
- if (this.bytes != null && c.bytes == null) return false;
- if (this.bytes.length != c.bytes.length) return false;
- for (int i = 0; i < this.bytes.length; i++) {
- if (this.bytes[i] != c.bytes[i]) return false;
- }
- return true;
- } catch (Exception e) {
- return false;
- }
- }
-
- public String toString() {
- return "Type: "+getTypeField()
- + " NIDa: "+getNodeIDa()
- + " isCIM: "+isCIM()
- + " isRIM: "+isRIM();
-
- }
-}
Copied: trunk/prototypes/java/src/org/openlcb/can/OpenLcbCanFrame.java (from rev 159, trunk/prototypes/java/src/org/openlcb/can/NmraNetCanFrame.java)
===================================================================
--- trunk/prototypes/java/src/org/openlcb/can/OpenLcbCanFrame.java (rev 0)
+++ trunk/prototypes/java/src/org/openlcb/can/OpenLcbCanFrame.java 2009-11-17 00:01:18 UTC (rev 162)
@@ -0,0 +1,111 @@
+package org.openlcb.can;
+
+import org.openlcb.*;
+
+/**
+ * Carry and work with a CAN frame in OpenLCB format.
+ *
+ * Immutable once created.
+ *
+ * @author Bob Jacobsen Copyright 2009
+ * @version $Revision$
+ */
+
+
+public class OpenLcbCanFrame implements org.openlcb.can.CanFrame {
+
+ public static OpenLcbCanFrame makeCimFrame(int alias, int num, int val) {
+ return new OpenLcbCanFrame( (0<<26) | (alias&0xffffff));
+ }
+
+ public static OpenLcbCanFrame makeRimFrame(int alias, NodeID n) {
+ return new OpenLcbCanFrame( (1<<26) | (alias&0xffffff),
+ n.getContents());
+ }
+
+ static int makeHeader(int alias) {
+ return
+ (alias&0xFFFFFF);
+ }
+
+ // data is stored in completed form as
+ // a header and data content; accessors go
+ // back and forth to individual fields.
+ long header;
+ byte[] bytes;
+
+ public OpenLcbCanFrame(long header) {
+ this.header = header;
+ }
+
+ public OpenLcbCanFrame(long header, byte[] bytes) {
+ this(header);
+ if (bytes.length > 8) {
+ throw new IllegalArgumentException("payload too long: "+bytes);
+ }
+ this.bytes = bytes;
+ }
+
+ public enum MessageType {
+ PCIR,
+ example;
+ }
+
+ public boolean isDidPresent() {
+ return (header&0x0000001) != 0;
+ }
+
+ // Frame itself is immutable
+ static public long setDidPresent(long header, boolean present) {
+ return header | 0x0000001;
+ }
+
+ public enum TypeField {
+ CHECKIDMESSAGE,
+ RESERVEDIDMESSAGE,
+ CANMESSAGE,
+ NMRANETCOMMONMESSAGE;
+ }
+
+ public TypeField getTypeField() {
+ return TypeField.values()[(int)((getHeader() & 0x0C000000) >> 26)];
+ }
+
+ // Frame itself is immutable
+ static public long setTypeField(long header, TypeField v) {
+ return (header&~0x0C000000)|(v.ordinal() << 26);
+ }
+
+ public long getHeader() { return header; }
+
+ public int getNodeIDa() { return (int)getHeader()&0xFFFFFF; }
+
+ public boolean isCIM() { return (getTypeField() == TypeField.CHECKIDMESSAGE); }
+ public boolean isRIM() { return (getTypeField() == TypeField.RESERVEDIDMESSAGE); }
+
+ public boolean equals(Object other) {
+ // try to cast, else not equal
+ try {
+ OpenLcbCanFrame c = (OpenLcbCanFrame) other;
+ if (this.header != c.header) return false;
+ if (this.bytes == null && c.bytes == null) return true;
+ if (this.bytes == null && c.bytes != null) return false;
+ if (this.bytes != null && c.bytes == null) return false;
+ if (this.bytes.length != c.bytes.length) return false;
+ for (int i = 0; i < this.bytes.length; i++) {
+ if (this.bytes[i] != c.bytes[i]) return false;
+ }
+ return true;
+ } catch (Exception e) {
+ return false;
+ }
+ }
+
+ public String toString() {
+ return "Type: "+getTypeField()
+ + " NIDa: "+getNodeIDa()
+ + " isCIM: "+isCIM()
+ + " isRIM: "+isRIM();
+
+ }
+}
Modified: trunk/prototypes/java/test/org/openlcb/can/CanTest.java
===================================================================
--- trunk/prototypes/java/test/org/openlcb/can/CanTest.java 2009-11-16 23:56:19 UTC (rev 161)
+++ trunk/prototypes/java/test/org/openlcb/can/CanTest.java 2009-11-17 00:01:18 UTC (rev 162)
@@ -29,7 +29,7 @@
public static Test suite() {
TestSuite suite = new TestSuite(CanTest.class);
- suite.addTest(NmraNetCanFrameTest.suite());
+ suite.addTest(OpenLcbCanFrameTest.suite());
suite.addTest(NIDaTest.suite());
suite.addTest(NIDaAlgorithmTest.suite());
Modified: trunk/prototypes/java/test/org/openlcb/can/NIDaAlgorithmTest.java
===================================================================
--- trunk/prototypes/java/test/org/openlcb/can/NIDaAlgorithmTest.java 2009-11-16 23:56:19 UTC (rev 161)
+++ trunk/prototypes/java/test/org/openlcb/can/NIDaAlgorithmTest.java 2009-11-17 00:01:18 UTC (rev 162)
@@ -19,7 +19,7 @@
}
public void testFirst() {
- NmraNetCanFrame f = alg.nextFrame();
+ OpenLcbCanFrame f = alg.nextFrame();
Assert.assertTrue("not complete", !alg.isComplete());
// first frame is CIM
@@ -28,7 +28,7 @@
}
public void testSeventh() {
- NmraNetCanFrame f;
+ OpenLcbCanFrame f;
Assert.assertTrue("not complete", !alg.isComplete());
// seventh frame is RIM
@@ -46,24 +46,24 @@
}
public void testNotAConflict() {
- NmraNetCanFrame f;
+ OpenLcbCanFrame f;
Assert.assertTrue("not complete", !alg.isComplete());
// seventh frame is RIM
Assert.assertTrue((f = alg.nextFrame()).isCIM());
- alg.processFrame(NmraNetCanFrame.makeCimFrame(1, 0, 0));
+ alg.processFrame(OpenLcbCanFrame.makeCimFrame(1, 0, 0));
Assert.assertTrue((f = alg.nextFrame()).isCIM());
- alg.processFrame(NmraNetCanFrame.makeCimFrame(1, 0, 0));
+ alg.processFrame(OpenLcbCanFrame.makeCimFrame(1, 0, 0));
Assert.assertTrue((f = alg.nextFrame()).isCIM());
- alg.processFrame(NmraNetCanFrame.makeCimFrame(1, 0, 0));
+ alg.processFrame(OpenLcbCanFrame.makeCimFrame(1, 0, 0));
Assert.assertTrue((f = alg.nextFrame()).isCIM());
- alg.processFrame(NmraNetCanFrame.makeCimFrame(1, 0, 0));
+ alg.processFrame(OpenLcbCanFrame.makeCimFrame(1, 0, 0));
Assert.assertTrue((f = alg.nextFrame()).isCIM());
- alg.processFrame(NmraNetCanFrame.makeCimFrame(1, 0, 0));
+ alg.processFrame(OpenLcbCanFrame.makeCimFrame(1, 0, 0));
Assert.assertTrue((f = alg.nextFrame()).isCIM());
- alg.processFrame(NmraNetCanFrame.makeCimFrame(1, 0, 0));
+ alg.processFrame(OpenLcbCanFrame.makeCimFrame(1, 0, 0));
Assert.assertTrue((f = alg.nextFrame()).isRIM());
- alg.processFrame(NmraNetCanFrame.makeCimFrame(1, 0, 0));
+ alg.processFrame(OpenLcbCanFrame.makeCimFrame(1, 0, 0));
Assert.assertTrue("complete", alg.isComplete());
@@ -71,14 +71,14 @@
}
public void testConflictAfterOne() {
- NmraNetCanFrame f;
+ OpenLcbCanFrame f;
Assert.assertTrue("not complete", !alg.isComplete());
// start
Assert.assertTrue((f = alg.nextFrame()).isCIM());
// inject conflict
- alg.processFrame(NmraNetCanFrame.makeCimFrame(f.getNodeIDa(), 0, 0));
+ alg.processFrame(OpenLcbCanFrame.makeCimFrame(f.getNodeIDa(), 0, 0));
// seventh frame after now is RIM
Assert.assertTrue((f = alg.nextFrame()).isCIM());
@@ -95,7 +95,7 @@
}
public void testLatecomerConflict() {
- NmraNetCanFrame f;
+ OpenLcbCanFrame f;
Assert.assertTrue("not complete", !alg.isComplete());
// seventh frame after start is RIM
@@ -112,7 +112,7 @@
Assert.assertEquals((f = alg.nextFrame()), null);
// inject conflict
- alg.processFrame(NmraNetCanFrame.makeCimFrame(nida, 0, 0));
+ alg.processFrame(OpenLcbCanFrame.makeCimFrame(nida, 0, 0));
// still active
Assert.assertTrue("complete", alg.isComplete());
@@ -123,7 +123,7 @@
public void testSequentialStart2() {
NIDaAlgorithm alg1 = new NIDaAlgorithm(new NodeID(new byte[]{10,11,12,13,14,15}));
NIDaAlgorithm alg2 = new NIDaAlgorithm(new NodeID(new byte[]{20,21,22,23,24,25}));
- NmraNetCanFrame f;
+ OpenLcbCanFrame f;
// check to make sure seeds are different; condition of test, not test itself
Assert.assertTrue("starting aliases should differ",
@@ -152,7 +152,7 @@
alg1.forceSeedValue(0xAC01L);
NubNIDaAlgorithm alg2 = new NubNIDaAlgorithm(new NodeID(new byte[]{11,10,12,13,14,15}));
alg2.forceSeedValue(0xAC01L);
- NmraNetCanFrame f;
+ OpenLcbCanFrame f;
// check to make sure seeds are same; condition of test, not test itself
Assert.assertTrue("starting aliases should agree",
@@ -191,7 +191,7 @@
NIDaAlgorithm alg8 = new NIDaAlgorithm(new NodeID(new byte[]{80,81,82,83,14,15}));
NIDaAlgorithm alg9 = new NIDaAlgorithm(new NodeID(new byte[]{90,91,92,93,14,15}));
NIDaAlgorithm alg10 = new NIDaAlgorithm(new NodeID(new byte[]{100,101,102,103,14,15}));
- NmraNetCanFrame f;
+ OpenLcbCanFrame f;
NIDaAlgorithm[] algs = new NIDaAlgorithm[]
{alg1, alg2, alg3, alg4, alg5, alg6, alg7, alg8, alg9, alg10};
@@ -253,7 +253,7 @@
algs[i].getNIDa()!=algs[j].getNIDa());
- NmraNetCanFrame f;
+ OpenLcbCanFrame f;
// run the startup
int expectedCount = (6+1)*10; // count messages
@@ -294,7 +294,7 @@
NubNIDaAlgorithm alg8 = new NubNIDaAlgorithm(new NodeID(new byte[]{10,11,22,23,24,15}));
NubNIDaAlgorithm alg9 = new NubNIDaAlgorithm(new NodeID(new byte[]{10,21,22,23,24,15}));
NubNIDaAlgorithm alg10 = new NubNIDaAlgorithm(new NodeID(new byte[]{20,21,22,23,24,15}));
- NmraNetCanFrame f;
+ OpenLcbCanFrame f;
NubNIDaAlgorithm[] algs = new NubNIDaAlgorithm[]
{alg1, alg2, alg3, alg4, alg5, alg6, alg7, alg8, alg9, alg10};
@@ -383,7 +383,7 @@
* and sending to others.
*/
int sequentialRunner(NIDaAlgorithm[] algs, int nCycles) {
- NmraNetCanFrame f;
+ OpenLcbCanFrame f;
for (int i = 0; i < nCycles; i++) {
for (int j = 0; j < algs.length; j++) { // provides next message
f = algs[j].nextFrame();
@@ -410,8 +410,8 @@
* simulates nodes sending very fast, so that CAN arbitrates.
*/
int priorityRunner(NIDaAlgorithm[] algs, int nCycles) {
- NmraNetCanFrame[] q = new NmraNetCanFrame[algs.length];
- NmraNetCanFrame f;
+ OpenLcbCanFrame[] q = new OpenLcbCanFrame[algs.length];
+ OpenLcbCanFrame f;
// start with 1st one each wants to send
for (int j = 0; j < algs.length; j++)
q[j] = algs[j].nextFrame();
Deleted: trunk/prototypes/java/test/org/openlcb/can/NmraNetCanFrameTest.java
===================================================================
--- trunk/prototypes/java/test/org/openlcb/can/NmraNetCanFrameTest.java 2009-11-16 23:56:19 UTC (rev 161)
+++ trunk/prototypes/java/test/org/openlcb/can/NmraNetCanFrameTest.java 2009-11-17 00:01:18 UTC (rev 162)
@@ -1,123 +0,0 @@
-
-package org.openlcb.can;
-
-import junit.framework.Assert;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-import org.openlcb.*;
-
-/**
- * @author Bob Jacobsen Copyright 2009
- * @version $Revision$
- */
-public class NmraNetCanFrameTest extends TestCase {
- public void testStart() {
- }
-
- public void testSimpleEquals() {
- CanFrame cf12a = new NmraNetCanFrame(12);
- CanFrame cf12b = new NmraNetCanFrame(12);
- CanFrame cf13 = new NmraNetCanFrame(13);
-
- Assert.assertTrue("12a equals 12a", cf12a.equals(cf12a));
- Assert.assertTrue("12a equals 12b", cf12a.equals(cf12b));
- Assert.assertTrue("12a not equals 13", !cf12a.equals(cf13));
- }
-
- public void testSimpleEqualObject() {
- Object cf12a = new NmraNetCanFrame(12);
- Object cf12b = new NmraNetCanFrame(12);
- Object cf13 = new NmraNetCanFrame(13);
-
- Assert.assertTrue("12a equals 12a", cf12a.equals(cf12a));
- Assert.assertTrue("12a equals 12b", cf12a.equals(cf12b));
- Assert.assertTrue("12a not equals 13", !cf12a.equals(cf13));
- }
-
- public void testSetTypeFieldBasic(){
- Assert.assertEquals("0x00, CheckID ", 0x00,
- NmraNetCanFrame.setTypeField(0,NmraNetCanFrame.TypeField.CHECKIDMESSAGE));
- Assert.assertEquals("0x01, CheckID ", 0x01,
- NmraNetCanFrame.setTypeField(1,NmraNetCanFrame.TypeField.CHECKIDMESSAGE));
-
- Assert.assertEquals("0x00, ReservedID ", 0x04000000,
- NmraNetCanFrame.setTypeField(0,NmraNetCanFrame.TypeField.RESERVEDIDMESSAGE));
- Assert.assertEquals("0x01, ReservedID ", 0x04000001,
- NmraNetCanFrame.setTypeField(1,NmraNetCanFrame.TypeField.RESERVEDIDMESSAGE));
-
- Assert.assertEquals("0x00, NMRAnet message ", 0x0C000000,
- NmraNetCanFrame.setTypeField(0,NmraNetCanFrame.TypeField.NMRANETCOMMONMESSAGE));
- Assert.assertEquals("0x01, NMRAnet message ", 0x0C000001,
- NmraNetCanFrame.setTypeField(1,NmraNetCanFrame.TypeField.NMRANETCOMMONMESSAGE));
-
- Assert.assertEquals("0x00, CAN msg ", 0x08000000,
- NmraNetCanFrame.setTypeField(0,NmraNetCanFrame.TypeField.CANMESSAGE));
- Assert.assertEquals("0x01, CAN msg ", 0x08000001,
- NmraNetCanFrame.setTypeField(1,NmraNetCanFrame.TypeField.CANMESSAGE));
-
- }
-
- public void testGetTypeField(){
- NmraNetCanFrame c;
- c = new NmraNetCanFrame(
- NmraNetCanFrame.setTypeField(1,
- NmraNetCanFrame.TypeField.CHECKIDMESSAGE));
- Assert.assertEquals("CHECKIDMESSAGE", NmraNetCanFrame.TypeField.CHECKIDMESSAGE, c.getTypeField());
-
- c = new NmraNetCanFrame(
- NmraNetCanFrame.setTypeField(1,
- NmraNetCanFrame.TypeField.RESERVEDIDMESSAGE));
- Assert.assertEquals("RESERVEDIDMESSAGE", NmraNetCanFrame.TypeField.RESERVEDIDMESSAGE, c.getTypeField());
-
- c = new NmraNetCanFrame(
- NmraNetCanFrame.setTypeField(1,
- NmraNetCanFrame.TypeField.NMRANETCOMMONMESSAGE));
- Assert.assertEquals("NMRANETCOMMONMESSAGE", NmraNetCanFrame.TypeField.NMRANETCOMMONMESSAGE, c.getTypeField());
-
- c = new NmraNetCanFrame(
- NmraNetCanFrame.setTypeField(1,
- NmraNetCanFrame.TypeField.CANMESSAGE));
- Assert.assertEquals("CANMESSAGE", NmraNetCanFrame.TypeField.CANMESSAGE, c.getTypeField());
-
- }
-
- public void testTypeFieldCoding() {
- Assert.assertEquals("count",4, NmraNetCanFrame.TypeField.values().length);
- Assert.assertEquals("CHECKIDMESSAGE", 0, NmraNetCanFrame.TypeField.CHECKIDMESSAGE.ordinal());
- Assert.assertEquals("RESERVEDIDMESSAGE", 1, NmraNetCanFrame.TypeField.RESERVEDIDMESSAGE.ordinal());
- Assert.assertEquals("CANMESSAGE", 2, NmraNetCanFrame.TypeField.CANMESSAGE.ordinal());
- Assert.assertEquals("NMRANETCOMMONMESSAGE", 3, NmraNetCanFrame.TypeField.NMRANETCOMMONMESSAGE.ordinal());
- }
-
- public void testMakeCim() {
- NmraNetCanFrame f = NmraNetCanFrame.makeCimFrame(0, 0, 0);
- Assert.assertTrue(f.isCIM());
- Assert.assertTrue(!f.isRIM());
- }
-
- public void testMakeRim() {
- NmraNetCanFrame f = NmraNetCanFrame.makeRimFrame(0,
- new NodeID(new byte[]{10,11,12,13,14,15}));
- Assert.assertTrue(!f.isCIM());
- Assert.assertTrue(f.isRIM());
- }
-
- // from here down is testing infrastructure
-
- public NmraNetCanFrameTest(String s) {
- super(s);
- }
-
- // Main entry point
- static public void main(String[] args) {
- String[] testCaseName = {NmraNetCanFrameTest.class.getName()};
- junit.swingui.TestRunner.main(testCaseName);
- }
-
- // test suite from all defined tests
- public static Test suite() {
- TestSuite suite = new TestSuite(NmraNetCanFrameTest.class);
- return suite;
- }
-}
Copied: trunk/prototypes/java/test/org/openlcb/can/OpenLcbCanFrameTest.java (from rev 159, trunk/prototypes/java/test/org/openlcb/can/NmraNetCanFrameTest.java)
===================================================================
--- trunk/prototypes/java/test/org/openlcb/can/OpenLcbCanFrameTest.java (rev 0)
+++ trunk/prototypes/java/test/org/openlcb/can/OpenLcbCanFrameTest.java 2009-11-17 00:01:18 UTC (rev 162)
@@ -0,0 +1,123 @@
+
+package org.openlcb.can;
+
+import junit.framework.Assert;
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+import org.openlcb.*;
+
+/**
+ * @author Bob Jacobsen Copyright 2009
+ * @version $Revision$
+ */
+public class OpenLcbCanFrameTest extends TestCase {
+ public void testStart() {
+ }
+
+ public void testSimpleEquals() {
+ CanFrame cf12a = new OpenLcbCanFrame(12);
+ CanFrame cf12b = new OpenLcbCanFrame(12);
+ CanFrame cf13 = new OpenLcbCanFrame(13);
+
+ Assert.assertTrue("12a equals 12a", cf12a.equals(cf12a));
+ Assert.assertTrue("12a equals 12b", cf12a.equals(cf12b));
+ Assert.assertTrue("12a not equals 13", !cf12a.equals(cf13));
+ }
+
+ public void testSimpleEqualObject() {
+ Object cf12a = new OpenLcbCanFrame(12);
+ Object cf12b = new OpenLcbCanFrame(12);
+ Object cf13 = new OpenLcbCanFrame(13);
+
+ Assert.assertTrue("12a equals 12a", cf12a.equals(cf12a));
+ Assert.assertTrue("12a equals 12b", cf12a.equals(cf12b));
+ Assert.assertTrue("12a not equals 13", !cf12a.equals(cf13));
+ }
+
+ public void testSetTypeFieldBasic(){
+ Assert.assertEquals("0x00, CheckID ", 0x00,
+ OpenLcbCanFrame.setTypeField(0,OpenLcbCanFrame.TypeField.CHECKIDMESSAGE));
+ Assert.assertEquals("0x01, CheckID ", 0x01,
+ OpenLcbCanFrame.setTypeField(1,OpenLcbCanFrame.TypeField.CHECKIDMESSAGE));
+
+ Assert.assertEquals("0x00, ReservedID ", 0x04000000,
+ OpenLcbCanFrame.setTypeField(0,OpenLcbCanFrame.TypeField.RESERVEDIDMESSAGE));
+ Assert.assertEquals("0x01, ReservedID ", 0x04000001,
+ OpenLcbCanFrame.setTypeField(1,OpenLcbCanFrame.TypeField.RESERVEDIDMESSAGE));
+
+ Assert.assertEquals("0x00, NMRAnet message ", 0x0C000000,
+ OpenLcbCanFrame.setTypeField(0,OpenLcbCanFrame.TypeField.NMRANETCOMMONMESSAGE));
+ Assert.assertEquals("0x01, NMRAnet message ", 0x0C000001,
+ OpenLcbCanFrame.setTypeField(1,OpenLcbCanFrame.TypeField.NMRANETCOMMONMESSAGE));
+
+ Assert.assertEquals("0x00, CAN msg ", 0x08000000,
+ OpenLcbCanFrame.setTypeField(0,OpenLcbCanFrame.TypeField.CANMESSAGE));
+ Assert.assertEquals("0x01, CAN msg ", 0x08000001,
+ OpenLcbCanFrame.setTypeField(1,OpenLcbCanFrame.TypeField.CANMESSAGE));
+
+ }
+
+ public void testGetTypeField(){
+ OpenLcbCanFrame c;
+ c = new OpenLcbCanFrame(
+ OpenLcbCanFrame.setTypeField(1,
+ OpenLcbCanFrame.TypeField.CHECKIDMESSAGE));
+ Assert.assertEquals("CHECKIDMESSAGE", OpenLcbCanFrame.TypeField.CHECKIDMESSAGE, c.getTypeField());
+
+ c = new OpenLcbCanFrame(
+ OpenLcbCanFrame.setTypeField(1,
+ OpenLcbCanFrame.TypeField.RESERVEDIDMESSAGE));
+ Assert.assertEquals("RESERVEDIDMESSAGE", OpenLcbCanFrame.TypeField.RESERVEDIDMESSAGE, c.getTypeField());
+
+ c = new OpenLcbCanFrame(
+ OpenLcbCanFrame.setTypeField(1,
+ OpenLcbCanFrame.TypeField.NMRANETCOMMONMESSAGE));
+ Assert.assertEquals("NMRANETCOMMONMESSAGE", OpenLcbCanFrame.TypeField.NMRANETCOMMONMESSAGE, c.getTypeField());
+
+ c = new OpenLcbCanFrame(
+ OpenLcbCanFrame.setTypeField(1,
+ OpenLcbCanFrame.TypeField.CANMESSAGE));
+ Assert.assertEquals("CANMESSAGE", OpenLcbCanFrame.TypeField.CANMESSAGE, c.getTypeField());
+
+ }
+
+ public void testTypeFieldCoding() {
+ Assert.assertEquals("count",4, OpenLcbCanFrame.TypeField.values().length);
+ Assert.assertEquals("CHECKIDMESSAGE", 0, OpenLcbCanFrame.TypeField.CHECKIDMESSAGE.ordinal());
+ Assert.assertEquals("RESERVEDIDMESSAGE", 1, OpenLcbCanFrame.TypeField.RESERVEDIDMESSAGE.ordinal());
+ Assert.assertEquals("CANMESSAGE", 2, OpenLcbCanFrame.TypeField.CANMESSAGE.ordinal());
+ Assert.assertEquals("NMRANETCOMMONMESSAGE", 3, OpenLcbCanFrame.TypeField.NMRANETCOMMONMESSAGE.ordinal());
+ }
+
+ public void testMakeCim() {
+ OpenLcbCanFrame f = OpenLcbCanFrame.makeCimFrame(0, 0, 0);
+ Assert.assertTrue(f.isCIM());
+ Assert.assertTrue(!f.isRIM());
+ }
+
+ public void testMakeRim() {
+ OpenLcbCanFrame f = OpenLcbCanFrame.makeRimFrame(0,
+ new NodeID(new byte[]{10,11,12,13,14,15}));
+ Assert.assertTrue(!f.isCIM());
+ Assert.assertTrue(f.isRIM());
+ }
+
+ // from here down is testing infrastructure
+
+ public OpenLcbCanFrameTest(String s) {
+ super(s);
+ }
+
+ // Main entry point
+ static public void main(String[] args) {
+ String[] testCaseName = {OpenLcbCanFrameTest.class.getName()};
+ junit.swingui.TestRunner.main(testCaseName);
+ }
+
+ // test suite from all defined tests
+ public static Test suite() {
+ TestSuite suite = new TestSuite(OpenLcbCanFrameTest.class);
+ return suite;
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jac...@us...> - 2009-11-17 00:01:28
|
Revision: 162
http://openlcb.svn.sourceforge.net/openlcb/?rev=162&view=rev
Author: jacobsen
Date: 2009-11-17 00:01:18 +0000 (Tue, 17 Nov 2009)
Log Message:
-----------
rename
Modified Paths:
--------------
trunk/prototypes/java/src/org/openlcb/can/NIDaAlgorithm.java
trunk/prototypes/java/test/org/openlcb/can/CanTest.java
trunk/prototypes/java/test/org/openlcb/can/NIDaAlgorithmTest.java
Added Paths:
-----------
trunk/prototypes/java/src/org/openlcb/can/OpenLcbCanFrame.java
trunk/prototypes/java/test/org/openlcb/can/OpenLcbCanFrameTest.java
Removed Paths:
-------------
trunk/prototypes/java/src/org/openlcb/can/NmraNetCanFrame.java
trunk/prototypes/java/test/org/openlcb/can/NmraNetCanFrameTest.java
Modified: trunk/prototypes/java/src/org/openlcb/can/NIDaAlgorithm.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/can/NIDaAlgorithm.java 2009-11-16 23:56:19 UTC (rev 161)
+++ trunk/prototypes/java/src/org/openlcb/can/NIDaAlgorithm.java 2009-11-17 00:01:18 UTC (rev 162)
@@ -18,12 +18,12 @@
nida = new NIDa(n);
}
- public NmraNetCanFrame nextFrame() {
- NmraNetCanFrame f;
+ public OpenLcbCanFrame nextFrame() {
+ OpenLcbCanFrame f;
if (index<6)
- f = NmraNetCanFrame.makeCimFrame(nida.getNIDa(), 0, 0);
+ f = OpenLcbCanFrame.makeCimFrame(nida.getNIDa(), 0, 0);
else if (index == 6) {
- f = NmraNetCanFrame.makeRimFrame(nida.getNIDa(), nid);
+ f = OpenLcbCanFrame.makeRimFrame(nida.getNIDa(), nid);
complete = true;
} else {
// send nothing
@@ -35,7 +35,7 @@
public long getNIDa() { return nida.getNIDa(); }
- public void processFrame(NmraNetCanFrame f) {
+ public void processFrame(OpenLcbCanFrame f) {
if (f == null) return; // as a convenience, ignore
// System.out.println("process "+Integer.toHexString(f.getNodeIDa())
Deleted: trunk/prototypes/java/src/org/openlcb/can/NmraNetCanFrame.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/can/NmraNetCanFrame.java 2009-11-16 23:56:19 UTC (rev 161)
+++ trunk/prototypes/java/src/org/openlcb/can/NmraNetCanFrame.java 2009-11-17 00:01:18 UTC (rev 162)
@@ -1,111 +0,0 @@
-package org.openlcb.can;
-
-import org.openlcb.*;
-
-/**
- * Carry and work with a CAN frame in NMRAnet format.
- *
- * Immutable once created.
- *
- * @author Bob Jacobsen Copyright 2009
- * @version $Revision$
- */
-
-
-public class NmraNetCanFrame implements org.openlcb.can.CanFrame {
-
- public static NmraNetCanFrame makeCimFrame(int alias, int num, int val) {
- return new NmraNetCanFrame( (0<<26) | (alias&0xffffff));
- }
-
- public static NmraNetCanFrame makeRimFrame(int alias, NodeID n) {
- return new NmraNetCanFrame( (1<<26) | (alias&0xffffff),
- n.getContents());
- }
-
- static int makeHeader(int alias) {
- return
- (alias&0xFFFFFF);
- }
-
- // data is stored in completed form as
- // a header and data content; accessors go
- // back and forth to individual fields.
- long header;
- byte[] bytes;
-
- public NmraNetCanFrame(long header) {
- this.header = header;
- }
-
- public NmraNetCanFrame(long header, byte[] bytes) {
- this(header);
- if (bytes.length > 8) {
- throw new IllegalArgumentException("payload too long: "+bytes);
- }
- this.bytes = bytes;
- }
-
- public enum MessageType {
- PCIR,
- example;
- }
-
- public boolean isDidPresent() {
- return (header&0x0000001) != 0;
- }
-
- // Frame itself is immutable
- static public long setDidPresent(long header, boolean present) {
- return header | 0x0000001;
- }
-
- public enum TypeField {
- CHECKIDMESSAGE,
- RESERVEDIDMESSAGE,
- CANMESSAGE,
- NMRANETCOMMONMESSAGE;
- }
-
- public TypeField getTypeField() {
- return TypeField.values()[(int)((getHeader() & 0x0C000000) >> 26)];
- }
-
- // Frame itself is immutable
- static public long setTypeField(long header, TypeField v) {
- return (header&~0x0C000000)|(v.ordinal() << 26);
- }
-
- public long getHeader() { return header; }
-
- public int getNodeIDa() { return (int)getHeader()&0xFFFFFF; }
-
- public boolean isCIM() { return (getTypeField() == TypeField.CHECKIDMESSAGE); }
- public boolean isRIM() { return (getTypeField() == TypeField.RESERVEDIDMESSAGE); }
-
- public boolean equals(Object other) {
- // try to cast, else not equal
- try {
- NmraNetCanFrame c = (NmraNetCanFrame) other;
- if (this.header != c.header) return false;
- if (this.bytes == null && c.bytes == null) return true;
- if (this.bytes == null && c.bytes != null) return false;
- if (this.bytes != null && c.bytes == null) return false;
- if (this.bytes.length != c.bytes.length) return false;
- for (int i = 0; i < this.bytes.length; i++) {
- if (this.bytes[i] != c.bytes[i]) return false;
- }
- return true;
- } catch (Exception e) {
- return false;
- }
- }
-
- public String toString() {
- return "Type: "+getTypeField()
- + " NIDa: "+getNodeIDa()
- + " isCIM: "+isCIM()
- + " isRIM: "+isRIM();
-
- }
-}
Copied: trunk/prototypes/java/src/org/openlcb/can/OpenLcbCanFrame.java (from rev 159, trunk/prototypes/java/src/org/openlcb/can/NmraNetCanFrame.java)
===================================================================
--- trunk/prototypes/java/src/org/openlcb/can/OpenLcbCanFrame.java (rev 0)
+++ trunk/prototypes/java/src/org/openlcb/can/OpenLcbCanFrame.java 2009-11-17 00:01:18 UTC (rev 162)
@@ -0,0 +1,111 @@
+package org.openlcb.can;
+
+import org.openlcb.*;
+
+/**
+ * Carry and work with a CAN frame in OpenLCB format.
+ *
+ * Immutable once created.
+ *
+ * @author Bob Jacobsen Copyright 2009
+ * @version $Revision$
+ */
+
+
+public class OpenLcbCanFrame implements org.openlcb.can.CanFrame {
+
+ public static OpenLcbCanFrame makeCimFrame(int alias, int num, int val) {
+ return new OpenLcbCanFrame( (0<<26) | (alias&0xffffff));
+ }
+
+ public static OpenLcbCanFrame makeRimFrame(int alias, NodeID n) {
+ return new OpenLcbCanFrame( (1<<26) | (alias&0xffffff),
+ n.getContents());
+ }
+
+ static int makeHeader(int alias) {
+ return
+ (alias&0xFFFFFF);
+ }
+
+ // data is stored in completed form as
+ // a header and data content; accessors go
+ // back and forth to individual fields.
+ long header;
+ byte[] bytes;
+
+ public OpenLcbCanFrame(long header) {
+ this.header = header;
+ }
+
+ public OpenLcbCanFrame(long header, byte[] bytes) {
+ this(header);
+ if (bytes.length > 8) {
+ throw new IllegalArgumentException("payload too long: "+bytes);
+ }
+ this.bytes = bytes;
+ }
+
+ public enum MessageType {
+ PCIR,
+ example;
+ }
+
+ public boolean isDidPresent() {
+ return (header&0x0000001) != 0;
+ }
+
+ // Frame itself is immutable
+ static public long setDidPresent(long header, boolean present) {
+ return header | 0x0000001;
+ }
+
+ public enum TypeField {
+ CHECKIDMESSAGE,
+ RESERVEDIDMESSAGE,
+ CANMESSAGE,
+ NMRANETCOMMONMESSAGE;
+ }
+
+ public TypeField getTypeField() {
+ return TypeField.values()[(int)((getHeader() & 0x0C000000) >> 26)];
+ }
+
+ // Frame itself is immutable
+ static public long setTypeField(long header, TypeField v) {
+ return (header&~0x0C000000)|(v.ordinal() << 26);
+ }
+
+ public long getHeader() { return header; }
+
+ public int getNodeIDa() { return (int)getHeader()&0xFFFFFF; }
+
+ public boolean isCIM() { return (getTypeField() == TypeField.CHECKIDMESSAGE); }
+ public boolean isRIM() { return (getTypeField() == TypeField.RESERVEDIDMESSAGE); }
+
+ public boolean equals(Object other) {
+ // try to cast, else not equal
+ try {
+ OpenLcbCanFrame c = (OpenLcbCanFrame) other;
+ if (this.header != c.header) return false;
+ if (this.bytes == null && c.bytes == null) return true;
+ if (this.bytes == null && c.bytes != null) return false;
+ if (this.bytes != null && c.bytes == null) return false;
+ if (this.bytes.length != c.bytes.length) return false;
+ for (int i = 0; i < this.bytes.length; i++) {
+ if (this.bytes[i] != c.bytes[i]) return false;
+ }
+ return true;
+ } catch (Exception e) {
+ return false;
+ }
+ }
+
+ public String toString() {
+ return "Type: "+getTypeField()
+ + " NIDa: "+getNodeIDa()
+ + " isCIM: "+isCIM()
+ + " isRIM: "+isRIM();
+
+ }
+}
Modified: trunk/prototypes/java/test/org/openlcb/can/CanTest.java
===================================================================
--- trunk/prototypes/java/test/org/openlcb/can/CanTest.java 2009-11-16 23:56:19 UTC (rev 161)
+++ trunk/prototypes/java/test/org/openlcb/can/CanTest.java 2009-11-17 00:01:18 UTC (rev 162)
@@ -29,7 +29,7 @@
public static Test suite() {
TestSuite suite = new TestSuite(CanTest.class);
- suite.addTest(NmraNetCanFrameTest.suite());
+ suite.addTest(OpenLcbCanFrameTest.suite());
suite.addTest(NIDaTest.suite());
suite.addTest(NIDaAlgorithmTest.suite());
Modified: trunk/prototypes/java/test/org/openlcb/can/NIDaAlgorithmTest.java
===================================================================
--- trunk/prototypes/java/test/org/openlcb/can/NIDaAlgorithmTest.java 2009-11-16 23:56:19 UTC (rev 161)
+++ trunk/prototypes/java/test/org/openlcb/can/NIDaAlgorithmTest.java 2009-11-17 00:01:18 UTC (rev 162)
@@ -19,7 +19,7 @@
}
public void testFirst() {
- NmraNetCanFrame f = alg.nextFrame();
+ OpenLcbCanFrame f = alg.nextFrame();
Assert.assertTrue("not complete", !alg.isComplete());
// first frame is CIM
@@ -28,7 +28,7 @@
}
public void testSeventh() {
- NmraNetCanFrame f;
+ OpenLcbCanFrame f;
Assert.assertTrue("not complete", !alg.isComplete());
// seventh frame is RIM
@@ -46,24 +46,24 @@
}
public void testNotAConflict() {
- NmraNetCanFrame f;
+ OpenLcbCanFrame f;
Assert.assertTrue("not complete", !alg.isComplete());
// seventh frame is RIM
Assert.assertTrue((f = alg.nextFrame()).isCIM());
- alg.processFrame(NmraNetCanFrame.makeCimFrame(1, 0, 0));
+ alg.processFrame(OpenLcbCanFrame.makeCimFrame(1, 0, 0));
Assert.assertTrue((f = alg.nextFrame()).isCIM());
- alg.processFrame(NmraNetCanFrame.makeCimFrame(1, 0, 0));
+ alg.processFrame(OpenLcbCanFrame.makeCimFrame(1, 0, 0));
Assert.assertTrue((f = alg.nextFrame()).isCIM());
- alg.processFrame(NmraNetCanFrame.makeCimFrame(1, 0, 0));
+ alg.processFrame(OpenLcbCanFrame.makeCimFrame(1, 0, 0));
Assert.assertTrue((f = alg.nextFrame()).isCIM());
- alg.processFrame(NmraNetCanFrame.makeCimFrame(1, 0, 0));
+ alg.processFrame(OpenLcbCanFrame.makeCimFrame(1, 0, 0));
Assert.assertTrue((f = alg.nextFrame()).isCIM());
- alg.processFrame(NmraNetCanFrame.makeCimFrame(1, 0, 0));
+ alg.processFrame(OpenLcbCanFrame.makeCimFrame(1, 0, 0));
Assert.assertTrue((f = alg.nextFrame()).isCIM());
- alg.processFrame(NmraNetCanFrame.makeCimFrame(1, 0, 0));
+ alg.processFrame(OpenLcbCanFrame.makeCimFrame(1, 0, 0));
Assert.assertTrue((f = alg.nextFrame()).isRIM());
- alg.processFrame(NmraNetCanFrame.makeCimFrame(1, 0, 0));
+ alg.processFrame(OpenLcbCanFrame.makeCimFrame(1, 0, 0));
Assert.assertTrue("complete", alg.isComplete());
@@ -71,14 +71,14 @@
}
public void testConflictAfterOne() {
- NmraNetCanFrame f;
+ OpenLcbCanFrame f;
Assert.assertTrue("not complete", !alg.isComplete());
// start
Assert.assertTrue((f = alg.nextFrame()).isCIM());
// inject conflict
- alg.processFrame(NmraNetCanFrame.makeCimFrame(f.getNodeIDa(), 0, 0));
+ alg.processFrame(OpenLcbCanFrame.makeCimFrame(f.getNodeIDa(), 0, 0));
// seventh frame after now is RIM
Assert.assertTrue((f = alg.nextFrame()).isCIM());
@@ -95,7 +95,7 @@
}
public void testLatecomerConflict() {
- NmraNetCanFrame f;
+ OpenLcbCanFrame f;
Assert.assertTrue("not complete", !alg.isComplete());
// seventh frame after start is RIM
@@ -112,7 +112,7 @@
Assert.assertEquals((f = alg.nextFrame()), null);
// inject conflict
- alg.processFrame(NmraNetCanFrame.makeCimFrame(nida, 0, 0));
+ alg.processFrame(OpenLcbCanFrame.makeCimFrame(nida, 0, 0));
// still active
Assert.assertTrue("complete", alg.isComplete());
@@ -123,7 +123,7 @@
public void testSequentialStart2() {
NIDaAlgorithm alg1 = new NIDaAlgorithm(new NodeID(new byte[]{10,11,12,13,14,15}));
NIDaAlgorithm alg2 = new NIDaAlgorithm(new NodeID(new byte[]{20,21,22,23,24,25}));
- NmraNetCanFrame f;
+ OpenLcbCanFrame f;
// check to make sure seeds are different; condition of test, not test itself
Assert.assertTrue("starting aliases should differ",
@@ -152,7 +152,7 @@
alg1.forceSeedValue(0xAC01L);
NubNIDaAlgorithm alg2 = new NubNIDaAlgorithm(new NodeID(new byte[]{11,10,12,13,14,15}));
alg2.forceSeedValue(0xAC01L);
- NmraNetCanFrame f;
+ OpenLcbCanFrame f;
// check to make sure seeds are same; condition of test, not test itself
Assert.assertTrue("starting aliases should agree",
@@ -191,7 +191,7 @@
NIDaAlgorithm alg8 = new NIDaAlgorithm(new NodeID(new byte[]{80,81,82,83,14,15}));
NIDaAlgorithm alg9 = new NIDaAlgorithm(new NodeID(new byte[]{90,91,92,93,14,15}));
NIDaAlgorithm alg10 = new NIDaAlgorithm(new NodeID(new byte[]{100,101,102,103,14,15}));
- NmraNetCanFrame f;
+ OpenLcbCanFrame f;
NIDaAlgorithm[] algs = new NIDaAlgorithm[]
{alg1, alg2, alg3, alg4, alg5, alg6, alg7, alg8, alg9, alg10};
@@ -253,7 +253,7 @@
algs[i].getNIDa()!=algs[j].getNIDa());
- NmraNetCanFrame f;
+ OpenLcbCanFrame f;
// run the startup
int expectedCount = (6+1)*10; // count messages
@@ -294,7 +294,7 @@
NubNIDaAlgorithm alg8 = new NubNIDaAlgorithm(new NodeID(new byte[]{10,11,22,23,24,15}));
NubNIDaAlgorithm alg9 = new NubNIDaAlgorithm(new NodeID(new byte[]{10,21,22,23,24,15}));
NubNIDaAlgorithm alg10 = new NubNIDaAlgorithm(new NodeID(new byte[]{20,21,22,23,24,15}));
- NmraNetCanFrame f;
+ OpenLcbCanFrame f;
NubNIDaAlgorithm[] algs = new NubNIDaAlgorithm[]
{alg1, alg2, alg3, alg4, alg5, alg6, alg7, alg8, alg9, alg10};
@@ -383,7 +383,7 @@
* and sending to others.
*/
int sequentialRunner(NIDaAlgorithm[] algs, int nCycles) {
- NmraNetCanFrame f;
+ OpenLcbCanFrame f;
for (int i = 0; i < nCycles; i++) {
for (int j = 0; j < algs.length; j++) { // provides next message
f = algs[j].nextFrame();
@@ -410,8 +410,8 @@
* simulates nodes sending very fast, so that CAN arbitrates.
*/
int priorityRunner(NIDaAlgorithm[] algs, int nCycles) {
- NmraNetCanFrame[] q = new NmraNetCanFrame[algs.length];
- NmraNetCanFrame f;
+ OpenLcbCanFrame[] q = new OpenLcbCanFrame[algs.length];
+ OpenLcbCanFrame f;
// start with 1st one each wants to send
for (int j = 0; j < algs.length; j++)
q[j] = algs[j].nextFrame();
Deleted: trunk/prototypes/java/test/org/openlcb/can/NmraNetCanFrameTest.java
===================================================================
--- trunk/prototypes/java/test/org/openlcb/can/NmraNetCanFrameTest.java 2009-11-16 23:56:19 UTC (rev 161)
+++ trunk/prototypes/java/test/org/openlcb/can/NmraNetCanFrameTest.java 2009-11-17 00:01:18 UTC (rev 162)
@@ -1,123 +0,0 @@
-
-package org.openlcb.can;
-
-import junit.framework.Assert;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-import org.openlcb.*;
-
-/**
- * @author Bob Jacobsen Copyright 2009
- * @version $Revision$
- */
-public class NmraNetCanFrameTest extends TestCase {
- public void testStart() {
- }
-
- public void testSimpleEquals() {
- CanFrame cf12a = new NmraNetCanFrame(12);
- CanFrame cf12b = new NmraNetCanFrame(12);
- CanFrame cf13 = new NmraNetCanFrame(13);
-
- Assert.assertTrue("12a equals 12a", cf12a.equals(cf12a));
- Assert.assertTrue("12a equals 12b", cf12a.equals(cf12b));
- Assert.assertTrue("12a not equals 13", !cf12a.equals(cf13));
- }
-
- public void testSimpleEqualObject() {
- Object cf12a = new NmraNetCanFrame(12);
- Object cf12b = new NmraNetCanFrame(12);
- Object cf13 = new NmraNetCanFrame(13);
-
- Assert.assertTrue("12a equals 12a", cf12a.equals(cf12a));
- Assert.assertTrue("12a equals 12b", cf12a.equals(cf12b));
- Assert.assertTrue("12a not equals 13", !cf12a.equals(cf13));
- }
-
- public void testSetTypeFieldBasic(){
- Assert.assertEquals("0x00, CheckID ", 0x00,
- NmraNetCanFrame.setTypeField(0,NmraNetCanFrame.TypeField.CHECKIDMESSAGE));
- Assert.assertEquals("0x01, CheckID ", 0x01,
- NmraNetCanFrame.setTypeField(1,NmraNetCanFrame.TypeField.CHECKIDMESSAGE));
-
- Assert.assertEquals("0x00, ReservedID ", 0x04000000,
- NmraNetCanFrame.setTypeField(0,NmraNetCanFrame.TypeField.RESERVEDIDMESSAGE));
- Assert.assertEquals("0x01, ReservedID ", 0x04000001,
- NmraNetCanFrame.setTypeField(1,NmraNetCanFrame.TypeField.RESERVEDIDMESSAGE));
-
- Assert.assertEquals("0x00, NMRAnet message ", 0x0C000000,
- NmraNetCanFrame.setTypeField(0,NmraNetCanFrame.TypeField.NMRANETCOMMONMESSAGE));
- Assert.assertEquals("0x01, NMRAnet message ", 0x0C000001,
- NmraNetCanFrame.setTypeField(1,NmraNetCanFrame.TypeField.NMRANETCOMMONMESSAGE));
-
- Assert.assertEquals("0x00, CAN msg ", 0x08000000,
- NmraNetCanFrame.setTypeField(0,NmraNetCanFrame.TypeField.CANMESSAGE));
- Assert.assertEquals("0x01, CAN msg ", 0x08000001,
- NmraNetCanFrame.setTypeField(1,NmraNetCanFrame.TypeField.CANMESSAGE));
-
- }
-
- public void testGetTypeField(){
- NmraNetCanFrame c;
- c = new NmraNetCanFrame(
- NmraNetCanFrame.setTypeField(1,
- NmraNetCanFrame.TypeField.CHECKIDMESSAGE));
- Assert.assertEquals("CHECKIDMESSAGE", NmraNetCanFrame.TypeField.CHECKIDMESSAGE, c.getTypeField());
-
- c = new NmraNetCanFrame(
- NmraNetCanFrame.setTypeField(1,
- NmraNetCanFrame.TypeField.RESERVEDIDMESSAGE));
- Assert.assertEquals("RESERVEDIDMESSAGE", NmraNetCanFrame.TypeField.RESERVEDIDMESSAGE, c.getTypeField());
-
- c = new NmraNetCanFrame(
- NmraNetCanFrame.setTypeField(1,
- NmraNetCanFrame.TypeField.NMRANETCOMMONMESSAGE));
- Assert.assertEquals("NMRANETCOMMONMESSAGE", NmraNetCanFrame.TypeField.NMRANETCOMMONMESSAGE, c.getTypeField());
-
- c = new NmraNetCanFrame(
- NmraNetCanFrame.setTypeField(1,
- NmraNetCanFrame.TypeField.CANMESSAGE));
- Assert.assertEquals("CANMESSAGE", NmraNetCanFrame.TypeField.CANMESSAGE, c.getTypeField());
-
- }
-
- public void testTypeFieldCoding() {
- Assert.assertEquals("count",4, NmraNetCanFrame.TypeField.values().length);
- Assert.assertEquals("CHECKIDMESSAGE", 0, NmraNetCanFrame.TypeField.CHECKIDMESSAGE.ordinal());
- Assert.assertEquals("RESERVEDIDMESSAGE", 1, NmraNetCanFrame.TypeField.RESERVEDIDMESSAGE.ordinal());
- Assert.assertEquals("CANMESSAGE", 2, NmraNetCanFrame.TypeField.CANMESSAGE.ordinal());
- Assert.assertEquals("NMRANETCOMMONMESSAGE", 3, NmraNetCanFrame.TypeField.NMRANETCOMMONMESSAGE.ordinal());
- }
-
- public void testMakeCim() {
- NmraNetCanFrame f = NmraNetCanFrame.makeCimFrame(0, 0, 0);
- Assert.assertTrue(f.isCIM());
- Assert.assertTrue(!f.isRIM());
- }
-
- public void testMakeRim() {
- NmraNetCanFrame f = NmraNetCanFrame.makeRimFrame(0,
- new NodeID(new byte[]{10,11,12,13,14,15}));
- Assert.assertTrue(!f.isCIM());
- Assert.assertTrue(f.isRIM());
- }
-
- // from here down is testing infrastructure
-
- public NmraNetCanFrameTest(String s) {
- super(s);
- }
-
- // Main entry point
- static public void main(String[] args) {
- String[] testCaseName = {NmraNetCanFrameTest.class.getName()};
- junit.swingui.TestRunner.main(testCaseName);
- }
-
- // test suite from all defined tests
- public static Test suite() {
- TestSuite suite = new TestSuite(NmraNetCanFrameTest.class);
- return suite;
- }
-}
Copied: trunk/prototypes/java/test/org/openlcb/can/OpenLcbCanFrameTest.java (from rev 159, trunk/prototypes/java/test/org/openlcb/can/NmraNetCanFrameTest.java)
===================================================================
--- trunk/prototypes/java/test/org/openlcb/can/OpenLcbCanFrameTest.java (rev 0)
+++ trunk/prototypes/java/test/org/openlcb/can/OpenLcbCanFrameTest.java 2009-11-17 00:01:18 UTC (rev 162)
@@ -0,0 +1,123 @@
+
+package org.openlcb.can;
+
+import junit.framework.Assert;
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+import org.openlcb.*;
+
+/**
+ * @author Bob Jacobsen Copyright 2009
+ * @version $Revision$
+ */
+public class OpenLcbCanFrameTest extends TestCase {
+ public void testStart() {
+ }
+
+ public void testSimpleEquals() {
+ CanFrame cf12a = new OpenLcbCanFrame(12);
+ CanFrame cf12b = new OpenLcbCanFrame(12);
+ CanFrame cf13 = new OpenLcbCanFrame(13);
+
+ Assert.assertTrue("12a equals 12a", cf12a.equals(cf12a));
+ Assert.assertTrue("12a equals 12b", cf12a.equals(cf12b));
+ Assert.assertTrue("12a not equals 13", !cf12a.equals(cf13));
+ }
+
+ public void testSimpleEqualObject() {
+ Object cf12a = new OpenLcbCanFrame(12);
+ Object cf12b = new OpenLcbCanFrame(12);
+ Object cf13 = new OpenLcbCanFrame(13);
+
+ Assert.assertTrue("12a equals 12a", cf12a.equals(cf12a));
+ Assert.assertTrue("12a equals 12b", cf12a.equals(cf12b));
+ Assert.assertTrue("12a not equals 13", !cf12a.equals(cf13));
+ }
+
+ public void testSetTypeFieldBasic(){
+ Assert.assertEquals("0x00, CheckID ", 0x00,
+ OpenLcbCanFrame.setTypeField(0,OpenLcbCanFrame.TypeField.CHECKIDMESSAGE));
+ Assert.assertEquals("0x01, CheckID ", 0x01,
+ OpenLcbCanFrame.setTypeField(1,OpenLcbCanFrame.TypeField.CHECKIDMESSAGE));
+
+ Assert.assertEquals("0x00, ReservedID ", 0x04000000,
+ OpenLcbCanFrame.setTypeField(0,OpenLcbCanFrame.TypeField.RESERVEDIDMESSAGE));
+ Assert.assertEquals("0x01, ReservedID ", 0x04000001,
+ OpenLcbCanFrame.setTypeField(1,OpenLcbCanFrame.TypeField.RESERVEDIDMESSAGE));
+
+ Assert.assertEquals("0x00, NMRAnet message ", 0x0C000000,
+ OpenLcbCanFrame.setTypeField(0,OpenLcbCanFrame.TypeField.NMRANETCOMMONMESSAGE));
+ Assert.assertEquals("0x01, NMRAnet message ", 0x0C000001,
+ OpenLcbCanFrame.setTypeField(1,OpenLcbCanFrame.TypeField.NMRANETCOMMONMESSAGE));
+
+ Assert.assertEquals("0x00, CAN msg ", 0x08000000,
+ OpenLcbCanFrame.setTypeField(0,OpenLcbCanFrame.TypeField.CANMESSAGE));
+ Assert.assertEquals("0x01, CAN msg ", 0x08000001,
+ OpenLcbCanFrame.setTypeField(1,OpenLcbCanFrame.TypeField.CANMESSAGE));
+
+ }
+
+ public void testGetTypeField(){
+ OpenLcbCanFrame c;
+ c = new OpenLcbCanFrame(
+ OpenLcbCanFrame.setTypeField(1,
+ OpenLcbCanFrame.TypeField.CHECKIDMESSAGE));
+ Assert.assertEquals("CHECKIDMESSAGE", OpenLcbCanFrame.TypeField.CHECKIDMESSAGE, c.getTypeField());
+
+ c = new OpenLcbCanFrame(
+ OpenLcbCanFrame.setTypeField(1,
+ OpenLcbCanFrame.TypeField.RESERVEDIDMESSAGE));
+ Assert.assertEquals("RESERVEDIDMESSAGE", OpenLcbCanFrame.TypeField.RESERVEDIDMESSAGE, c.getTypeField());
+
+ c = new OpenLcbCanFrame(
+ OpenLcbCanFrame.setTypeField(1,
+ OpenLcbCanFrame.TypeField.NMRANETCOMMONMESSAGE));
+ Assert.assertEquals("NMRANETCOMMONMESSAGE", OpenLcbCanFrame.TypeField.NMRANETCOMMONMESSAGE, c.getTypeField());
+
+ c = new OpenLcbCanFrame(
+ OpenLcbCanFrame.setTypeField(1,
+ OpenLcbCanFrame.TypeField.CANMESSAGE));
+ Assert.assertEquals("CANMESSAGE", OpenLcbCanFrame.TypeField.CANMESSAGE, c.getTypeField());
+
+ }
+
+ public void testTypeFieldCoding() {
+ Assert.assertEquals("count",4, OpenLcbCanFrame.TypeField.values().length);
+ Assert.assertEquals("CHECKIDMESSAGE", 0, OpenLcbCanFrame.TypeField.CHECKIDMESSAGE.ordinal());
+ Assert.assertEquals("RESERVEDIDMESSAGE", 1, OpenLcbCanFrame.TypeField.RESERVEDIDMESSAGE.ordinal());
+ Assert.assertEquals("CANMESSAGE", 2, OpenLcbCanFrame.TypeField.CANMESSAGE.ordinal());
+ Assert.assertEquals("NMRANETCOMMONMESSAGE", 3, OpenLcbCanFrame.TypeField.NMRANETCOMMONMESSAGE.ordinal());
+ }
+
+ public void testMakeCim() {
+ OpenLcbCanFrame f = OpenLcbCanFrame.makeCimFrame(0, 0, 0);
+ Assert.assertTrue(f.isCIM());
+ Assert.assertTrue(!f.isRIM());
+ }
+
+ public void testMakeRim() {
+ OpenLcbCanFrame f = OpenLcbCanFrame.makeRimFrame(0,
+ new NodeID(new byte[]{10,11,12,13,14,15}));
+ Assert.assertTrue(!f.isCIM());
+ Assert.assertTrue(f.isRIM());
+ }
+
+ // from here down is testing infrastructure
+
+ public OpenLcbCanFrameTest(String s) {
+ super(s);
+ }
+
+ // Main entry point
+ static public void main(String[] args) {
+ String[] testCaseName = {OpenLcbCanFrameTest.class.getName()};
+ junit.swingui.TestRunner.main(testCaseName);
+ }
+
+ // test suite from all defined tests
+ public static Test suite() {
+ TestSuite suite = new TestSuite(OpenLcbCanFrameTest.class);
+ return suite;
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jac...@us...> - 2009-11-17 00:06:21
|
Revision: 163
http://openlcb.svn.sourceforge.net/openlcb/?rev=163&view=rev
Author: jacobsen
Date: 2009-11-17 00:06:13 +0000 (Tue, 17 Nov 2009)
Log Message:
-----------
rename
Modified Paths:
--------------
trunk/prototypes/java/build.xml
trunk/prototypes/java/index.html
trunk/prototypes/java/src/org/openlcb/Connection.java
trunk/prototypes/java/src/org/openlcb/SingleLinkNode.java
trunk/prototypes/java/src/org/openlcb/can/package.html
trunk/prototypes/java/test/org/openlcb/can/OpenLcbCanFrameTest.java
Modified: trunk/prototypes/java/build.xml
===================================================================
--- trunk/prototypes/java/build.xml 2009-11-17 00:01:18 UTC (rev 162)
+++ trunk/prototypes/java/build.xml 2009-11-17 00:06:13 UTC (rev 163)
@@ -1,12 +1,12 @@
-<!-- Ant build.xml file for NMRAnet development -->
+<!-- Ant build.xml file for OpenLCB development -->
<!-- Bob Jacobsen, Copyright 2009 -->
<!-- Revision $Revision: 370 $ -->
-<project name="NMRAnet" default="run" basedir=".">
+<project name="OpenLCB" default="run" basedir=".">
<!-- basedir="." means all paths are relative to the "java" subdir. -->
<description>
- Provides build services for NMRAnet development
+ Provides build services for OpenLCB development
</description>
<!-- options you might want to change during development, -->
@@ -131,17 +131,17 @@
author="true"
version="false"
use="true"
- windowtitle="NMRAnet S9.6">
- <group title="Core" packages="org.nmra.net"/>
+ windowtitle="OpenLCB">
+ <group title="Core" packages="org.openlcb"/>
<classpath refid="project.class.path" />
- <doctitle><![CDATA[<h1>NMRAnet API</h1>]]></doctitle>
+ <doctitle><![CDATA[<h1>OpenLCB API</h1>]]></doctitle>
<link href="http://java.sun.com/j2se/1.4.1/docs/api/" />
</javadoc>
</target>
<target name="jar" description="create working jar file with current contents">
- <jar jarfile="${jartarget}/nmranet.jar"
+ <jar jarfile="${jartarget}/openlcb.jar"
basedir="${target}"
manifest="manifest"
compress="true" /> <!-- compress="true" is default -->
Modified: trunk/prototypes/java/index.html
===================================================================
--- trunk/prototypes/java/index.html 2009-11-17 00:01:18 UTC (rev 162)
+++ trunk/prototypes/java/index.html 2009-11-17 00:06:13 UTC (rev 163)
@@ -2,7 +2,7 @@
<HTML>
<HEAD>
<META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8">
- <TITLE>NMRAnet: Java Prototypes Directory</TITLE>
+ <TITLE>OpenLCB: Java Prototypes Directory</TITLE>
<META NAME="GENERATOR" CONTENT="OpenOffice.org 3.1 (Unix)">
<META NAME="CREATED" CONTENT="0;0">
<META NAME="CHANGEDBY" CONTENT="Bob Jacobsen">
@@ -35,7 +35,7 @@
<UL>
<LI><DD STYLE="margin-bottom: 0.5cm">
org.openlcb – unit tests for the implementation code</DD><LI><DD STYLE="margin-bottom: 0.5cm">
- tools – various non-NMRAnet implementation for testing, including
+ tools – various non-OpenLCB implementation for testing, including
a small CAN segment simulator</DD><LI><DD STYLE="margin-bottom: 0.5cm">
scenarios – tests of operation of multiple OpenLCB classes
simulating various OpenLCB use scenarios</DD></UL>
@@ -55,7 +55,7 @@
<PRE STYLE="margin-bottom: 0.5cm">ant javadoc</PRE><P>
(We don't keep JavaDoc files in SVN yet, but that might eventually be
a good idea)</P>
-<P>To create an nmranet.jar file containing the currently compiled
+<P>To create an openlcb.jar file containing the currently compiled
code,</P>
<PRE>ant jar
</PRE><P>
Modified: trunk/prototypes/java/src/org/openlcb/Connection.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/Connection.java 2009-11-17 00:01:18 UTC (rev 162)
+++ trunk/prototypes/java/src/org/openlcb/Connection.java 2009-11-17 00:06:13 UTC (rev 163)
@@ -1,7 +1,7 @@
package org.openlcb;
/**
- * Interface for receiving NMRAnet messages.
+ * Interface for receiving OpenLCB messages.
* <p>
* Generally, nodes send messages by delivering them to Connections.
*
Modified: trunk/prototypes/java/src/org/openlcb/SingleLinkNode.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/SingleLinkNode.java 2009-11-17 00:01:18 UTC (rev 162)
+++ trunk/prototypes/java/src/org/openlcb/SingleLinkNode.java 2009-11-17 00:06:13 UTC (rev 163)
@@ -1,7 +1,7 @@
package org.openlcb;
/**
- * Base for NMRAnet nodes that have only a single connection to the
+ * Base for OpenLCB nodes that have only a single connection to the
* outside world.
*
* @author Bob Jacobsen Copyright 2009
Modified: trunk/prototypes/java/src/org/openlcb/can/package.html
===================================================================
--- trunk/prototypes/java/src/org/openlcb/can/package.html 2009-11-17 00:01:18 UTC (rev 162)
+++ trunk/prototypes/java/src/org/openlcb/can/package.html 2009-11-17 00:06:13 UTC (rev 163)
@@ -14,7 +14,7 @@
</head>
<body bgcolor="white">
-CAN-specific NMRAnet functionality.
+CAN-specific OpenLCB functionality.
<p>
This package does not provide a CAN implementation; that's
Modified: trunk/prototypes/java/test/org/openlcb/can/OpenLcbCanFrameTest.java
===================================================================
--- trunk/prototypes/java/test/org/openlcb/can/OpenLcbCanFrameTest.java 2009-11-17 00:01:18 UTC (rev 162)
+++ trunk/prototypes/java/test/org/openlcb/can/OpenLcbCanFrameTest.java 2009-11-17 00:06:13 UTC (rev 163)
@@ -46,9 +46,9 @@
Assert.assertEquals("0x01, ReservedID ", 0x04000001,
OpenLcbCanFrame.setTypeField(1,OpenLcbCanFrame.TypeField.RESERVEDIDMESSAGE));
- Assert.assertEquals("0x00, NMRAnet message ", 0x0C000000,
+ Assert.assertEquals("0x00, OpenLCB message ", 0x0C000000,
OpenLcbCanFrame.setTypeField(0,OpenLcbCanFrame.TypeField.NMRANETCOMMONMESSAGE));
- Assert.assertEquals("0x01, NMRAnet message ", 0x0C000001,
+ Assert.assertEquals("0x01, OpenLCB message ", 0x0C000001,
OpenLcbCanFrame.setTypeField(1,OpenLcbCanFrame.TypeField.NMRANETCOMMONMESSAGE));
Assert.assertEquals("0x00, CAN msg ", 0x08000000,
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jac...@us...> - 2009-11-17 00:06:24
|
Revision: 163
http://openlcb.svn.sourceforge.net/openlcb/?rev=163&view=rev
Author: jacobsen
Date: 2009-11-17 00:06:13 +0000 (Tue, 17 Nov 2009)
Log Message:
-----------
rename
Modified Paths:
--------------
trunk/prototypes/java/build.xml
trunk/prototypes/java/index.html
trunk/prototypes/java/src/org/openlcb/Connection.java
trunk/prototypes/java/src/org/openlcb/SingleLinkNode.java
trunk/prototypes/java/src/org/openlcb/can/package.html
trunk/prototypes/java/test/org/openlcb/can/OpenLcbCanFrameTest.java
Modified: trunk/prototypes/java/build.xml
===================================================================
--- trunk/prototypes/java/build.xml 2009-11-17 00:01:18 UTC (rev 162)
+++ trunk/prototypes/java/build.xml 2009-11-17 00:06:13 UTC (rev 163)
@@ -1,12 +1,12 @@
-<!-- Ant build.xml file for NMRAnet development -->
+<!-- Ant build.xml file for OpenLCB development -->
<!-- Bob Jacobsen, Copyright 2009 -->
<!-- Revision $Revision: 370 $ -->
-<project name="NMRAnet" default="run" basedir=".">
+<project name="OpenLCB" default="run" basedir=".">
<!-- basedir="." means all paths are relative to the "java" subdir. -->
<description>
- Provides build services for NMRAnet development
+ Provides build services for OpenLCB development
</description>
<!-- options you might want to change during development, -->
@@ -131,17 +131,17 @@
author="true"
version="false"
use="true"
- windowtitle="NMRAnet S9.6">
- <group title="Core" packages="org.nmra.net"/>
+ windowtitle="OpenLCB">
+ <group title="Core" packages="org.openlcb"/>
<classpath refid="project.class.path" />
- <doctitle><![CDATA[<h1>NMRAnet API</h1>]]></doctitle>
+ <doctitle><![CDATA[<h1>OpenLCB API</h1>]]></doctitle>
<link href="http://java.sun.com/j2se/1.4.1/docs/api/" />
</javadoc>
</target>
<target name="jar" description="create working jar file with current contents">
- <jar jarfile="${jartarget}/nmranet.jar"
+ <jar jarfile="${jartarget}/openlcb.jar"
basedir="${target}"
manifest="manifest"
compress="true" /> <!-- compress="true" is default -->
Modified: trunk/prototypes/java/index.html
===================================================================
--- trunk/prototypes/java/index.html 2009-11-17 00:01:18 UTC (rev 162)
+++ trunk/prototypes/java/index.html 2009-11-17 00:06:13 UTC (rev 163)
@@ -2,7 +2,7 @@
<HTML>
<HEAD>
<META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8">
- <TITLE>NMRAnet: Java Prototypes Directory</TITLE>
+ <TITLE>OpenLCB: Java Prototypes Directory</TITLE>
<META NAME="GENERATOR" CONTENT="OpenOffice.org 3.1 (Unix)">
<META NAME="CREATED" CONTENT="0;0">
<META NAME="CHANGEDBY" CONTENT="Bob Jacobsen">
@@ -35,7 +35,7 @@
<UL>
<LI><DD STYLE="margin-bottom: 0.5cm">
org.openlcb – unit tests for the implementation code</DD><LI><DD STYLE="margin-bottom: 0.5cm">
- tools – various non-NMRAnet implementation for testing, including
+ tools – various non-OpenLCB implementation for testing, including
a small CAN segment simulator</DD><LI><DD STYLE="margin-bottom: 0.5cm">
scenarios – tests of operation of multiple OpenLCB classes
simulating various OpenLCB use scenarios</DD></UL>
@@ -55,7 +55,7 @@
<PRE STYLE="margin-bottom: 0.5cm">ant javadoc</PRE><P>
(We don't keep JavaDoc files in SVN yet, but that might eventually be
a good idea)</P>
-<P>To create an nmranet.jar file containing the currently compiled
+<P>To create an openlcb.jar file containing the currently compiled
code,</P>
<PRE>ant jar
</PRE><P>
Modified: trunk/prototypes/java/src/org/openlcb/Connection.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/Connection.java 2009-11-17 00:01:18 UTC (rev 162)
+++ trunk/prototypes/java/src/org/openlcb/Connection.java 2009-11-17 00:06:13 UTC (rev 163)
@@ -1,7 +1,7 @@
package org.openlcb;
/**
- * Interface for receiving NMRAnet messages.
+ * Interface for receiving OpenLCB messages.
* <p>
* Generally, nodes send messages by delivering them to Connections.
*
Modified: trunk/prototypes/java/src/org/openlcb/SingleLinkNode.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/SingleLinkNode.java 2009-11-17 00:01:18 UTC (rev 162)
+++ trunk/prototypes/java/src/org/openlcb/SingleLinkNode.java 2009-11-17 00:06:13 UTC (rev 163)
@@ -1,7 +1,7 @@
package org.openlcb;
/**
- * Base for NMRAnet nodes that have only a single connection to the
+ * Base for OpenLCB nodes that have only a single connection to the
* outside world.
*
* @author Bob Jacobsen Copyright 2009
Modified: trunk/prototypes/java/src/org/openlcb/can/package.html
===================================================================
--- trunk/prototypes/java/src/org/openlcb/can/package.html 2009-11-17 00:01:18 UTC (rev 162)
+++ trunk/prototypes/java/src/org/openlcb/can/package.html 2009-11-17 00:06:13 UTC (rev 163)
@@ -14,7 +14,7 @@
</head>
<body bgcolor="white">
-CAN-specific NMRAnet functionality.
+CAN-specific OpenLCB functionality.
<p>
This package does not provide a CAN implementation; that's
Modified: trunk/prototypes/java/test/org/openlcb/can/OpenLcbCanFrameTest.java
===================================================================
--- trunk/prototypes/java/test/org/openlcb/can/OpenLcbCanFrameTest.java 2009-11-17 00:01:18 UTC (rev 162)
+++ trunk/prototypes/java/test/org/openlcb/can/OpenLcbCanFrameTest.java 2009-11-17 00:06:13 UTC (rev 163)
@@ -46,9 +46,9 @@
Assert.assertEquals("0x01, ReservedID ", 0x04000001,
OpenLcbCanFrame.setTypeField(1,OpenLcbCanFrame.TypeField.RESERVEDIDMESSAGE));
- Assert.assertEquals("0x00, NMRAnet message ", 0x0C000000,
+ Assert.assertEquals("0x00, OpenLCB message ", 0x0C000000,
OpenLcbCanFrame.setTypeField(0,OpenLcbCanFrame.TypeField.NMRANETCOMMONMESSAGE));
- Assert.assertEquals("0x01, NMRAnet message ", 0x0C000001,
+ Assert.assertEquals("0x01, OpenLCB message ", 0x0C000001,
OpenLcbCanFrame.setTypeField(1,OpenLcbCanFrame.TypeField.NMRANETCOMMONMESSAGE));
Assert.assertEquals("0x00, CAN msg ", 0x08000000,
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jac...@us...> - 2009-11-17 00:08:37
|
Revision: 164
http://openlcb.svn.sourceforge.net/openlcb/?rev=164&view=rev
Author: jacobsen
Date: 2009-11-17 00:08:30 +0000 (Tue, 17 Nov 2009)
Log Message:
-----------
rename
Modified Paths:
--------------
trunk/prototypes/java/src/org/openlcb/can/OpenLcbCanFrame.java
trunk/prototypes/java/src/org/openlcb/implementations/SingleConsumerNode.java
trunk/prototypes/java/test/org/openlcb/can/OpenLcbCanFrameTest.java
Modified: trunk/prototypes/java/src/org/openlcb/can/OpenLcbCanFrame.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/can/OpenLcbCanFrame.java 2009-11-17 00:06:13 UTC (rev 163)
+++ trunk/prototypes/java/src/org/openlcb/can/OpenLcbCanFrame.java 2009-11-17 00:08:30 UTC (rev 164)
@@ -64,7 +64,7 @@
CHECKIDMESSAGE,
RESERVEDIDMESSAGE,
CANMESSAGE,
- NMRANETCOMMONMESSAGE;
+ OPENLCBCOMMONMESSAGE;
}
public TypeField getTypeField() {
Modified: trunk/prototypes/java/src/org/openlcb/implementations/SingleConsumerNode.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/implementations/SingleConsumerNode.java 2009-11-17 00:06:13 UTC (rev 163)
+++ trunk/prototypes/java/src/org/openlcb/implementations/SingleConsumerNode.java 2009-11-17 00:08:30 UTC (rev 164)
@@ -6,7 +6,7 @@
* Example of a OpenLCB node that consumes one Event.
*<p>
* The event doesn't cause much to happen, but e.g.
- * a {@link org.nmra.net.swing.ConsumerPane} can display
+ * a {@link org.openlcb.swing.ConsumerPane} can display
* it.
*
* @author Bob Jacobsen Copyright 2009
Modified: trunk/prototypes/java/test/org/openlcb/can/OpenLcbCanFrameTest.java
===================================================================
--- trunk/prototypes/java/test/org/openlcb/can/OpenLcbCanFrameTest.java 2009-11-17 00:06:13 UTC (rev 163)
+++ trunk/prototypes/java/test/org/openlcb/can/OpenLcbCanFrameTest.java 2009-11-17 00:08:30 UTC (rev 164)
@@ -47,9 +47,9 @@
OpenLcbCanFrame.setTypeField(1,OpenLcbCanFrame.TypeField.RESERVEDIDMESSAGE));
Assert.assertEquals("0x00, OpenLCB message ", 0x0C000000,
- OpenLcbCanFrame.setTypeField(0,OpenLcbCanFrame.TypeField.NMRANETCOMMONMESSAGE));
+ OpenLcbCanFrame.setTypeField(0,OpenLcbCanFrame.TypeField.OPENLCBCOMMONMESSAGE));
Assert.assertEquals("0x01, OpenLCB message ", 0x0C000001,
- OpenLcbCanFrame.setTypeField(1,OpenLcbCanFrame.TypeField.NMRANETCOMMONMESSAGE));
+ OpenLcbCanFrame.setTypeField(1,OpenLcbCanFrame.TypeField.OPENLCBCOMMONMESSAGE));
Assert.assertEquals("0x00, CAN msg ", 0x08000000,
OpenLcbCanFrame.setTypeField(0,OpenLcbCanFrame.TypeField.CANMESSAGE));
@@ -72,8 +72,8 @@
c = new OpenLcbCanFrame(
OpenLcbCanFrame.setTypeField(1,
- OpenLcbCanFrame.TypeField.NMRANETCOMMONMESSAGE));
- Assert.assertEquals("NMRANETCOMMONMESSAGE", OpenLcbCanFrame.TypeField.NMRANETCOMMONMESSAGE, c.getTypeField());
+ OpenLcbCanFrame.TypeField.OPENLCBCOMMONMESSAGE));
+ Assert.assertEquals("OPENLCBCOMMONMESSAGE", OpenLcbCanFrame.TypeField.OPENLCBCOMMONMESSAGE, c.getTypeField());
c = new OpenLcbCanFrame(
OpenLcbCanFrame.setTypeField(1,
@@ -87,7 +87,7 @@
Assert.assertEquals("CHECKIDMESSAGE", 0, OpenLcbCanFrame.TypeField.CHECKIDMESSAGE.ordinal());
Assert.assertEquals("RESERVEDIDMESSAGE", 1, OpenLcbCanFrame.TypeField.RESERVEDIDMESSAGE.ordinal());
Assert.assertEquals("CANMESSAGE", 2, OpenLcbCanFrame.TypeField.CANMESSAGE.ordinal());
- Assert.assertEquals("NMRANETCOMMONMESSAGE", 3, OpenLcbCanFrame.TypeField.NMRANETCOMMONMESSAGE.ordinal());
+ Assert.assertEquals("OPENLCBCOMMONMESSAGE", 3, OpenLcbCanFrame.TypeField.OPENLCBCOMMONMESSAGE.ordinal());
}
public void testMakeCim() {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jac...@us...> - 2009-11-17 00:08:42
|
Revision: 164
http://openlcb.svn.sourceforge.net/openlcb/?rev=164&view=rev
Author: jacobsen
Date: 2009-11-17 00:08:30 +0000 (Tue, 17 Nov 2009)
Log Message:
-----------
rename
Modified Paths:
--------------
trunk/prototypes/java/src/org/openlcb/can/OpenLcbCanFrame.java
trunk/prototypes/java/src/org/openlcb/implementations/SingleConsumerNode.java
trunk/prototypes/java/test/org/openlcb/can/OpenLcbCanFrameTest.java
Modified: trunk/prototypes/java/src/org/openlcb/can/OpenLcbCanFrame.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/can/OpenLcbCanFrame.java 2009-11-17 00:06:13 UTC (rev 163)
+++ trunk/prototypes/java/src/org/openlcb/can/OpenLcbCanFrame.java 2009-11-17 00:08:30 UTC (rev 164)
@@ -64,7 +64,7 @@
CHECKIDMESSAGE,
RESERVEDIDMESSAGE,
CANMESSAGE,
- NMRANETCOMMONMESSAGE;
+ OPENLCBCOMMONMESSAGE;
}
public TypeField getTypeField() {
Modified: trunk/prototypes/java/src/org/openlcb/implementations/SingleConsumerNode.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/implementations/SingleConsumerNode.java 2009-11-17 00:06:13 UTC (rev 163)
+++ trunk/prototypes/java/src/org/openlcb/implementations/SingleConsumerNode.java 2009-11-17 00:08:30 UTC (rev 164)
@@ -6,7 +6,7 @@
* Example of a OpenLCB node that consumes one Event.
*<p>
* The event doesn't cause much to happen, but e.g.
- * a {@link org.nmra.net.swing.ConsumerPane} can display
+ * a {@link org.openlcb.swing.ConsumerPane} can display
* it.
*
* @author Bob Jacobsen Copyright 2009
Modified: trunk/prototypes/java/test/org/openlcb/can/OpenLcbCanFrameTest.java
===================================================================
--- trunk/prototypes/java/test/org/openlcb/can/OpenLcbCanFrameTest.java 2009-11-17 00:06:13 UTC (rev 163)
+++ trunk/prototypes/java/test/org/openlcb/can/OpenLcbCanFrameTest.java 2009-11-17 00:08:30 UTC (rev 164)
@@ -47,9 +47,9 @@
OpenLcbCanFrame.setTypeField(1,OpenLcbCanFrame.TypeField.RESERVEDIDMESSAGE));
Assert.assertEquals("0x00, OpenLCB message ", 0x0C000000,
- OpenLcbCanFrame.setTypeField(0,OpenLcbCanFrame.TypeField.NMRANETCOMMONMESSAGE));
+ OpenLcbCanFrame.setTypeField(0,OpenLcbCanFrame.TypeField.OPENLCBCOMMONMESSAGE));
Assert.assertEquals("0x01, OpenLCB message ", 0x0C000001,
- OpenLcbCanFrame.setTypeField(1,OpenLcbCanFrame.TypeField.NMRANETCOMMONMESSAGE));
+ OpenLcbCanFrame.setTypeField(1,OpenLcbCanFrame.TypeField.OPENLCBCOMMONMESSAGE));
Assert.assertEquals("0x00, CAN msg ", 0x08000000,
OpenLcbCanFrame.setTypeField(0,OpenLcbCanFrame.TypeField.CANMESSAGE));
@@ -72,8 +72,8 @@
c = new OpenLcbCanFrame(
OpenLcbCanFrame.setTypeField(1,
- OpenLcbCanFrame.TypeField.NMRANETCOMMONMESSAGE));
- Assert.assertEquals("NMRANETCOMMONMESSAGE", OpenLcbCanFrame.TypeField.NMRANETCOMMONMESSAGE, c.getTypeField());
+ OpenLcbCanFrame.TypeField.OPENLCBCOMMONMESSAGE));
+ Assert.assertEquals("OPENLCBCOMMONMESSAGE", OpenLcbCanFrame.TypeField.OPENLCBCOMMONMESSAGE, c.getTypeField());
c = new OpenLcbCanFrame(
OpenLcbCanFrame.setTypeField(1,
@@ -87,7 +87,7 @@
Assert.assertEquals("CHECKIDMESSAGE", 0, OpenLcbCanFrame.TypeField.CHECKIDMESSAGE.ordinal());
Assert.assertEquals("RESERVEDIDMESSAGE", 1, OpenLcbCanFrame.TypeField.RESERVEDIDMESSAGE.ordinal());
Assert.assertEquals("CANMESSAGE", 2, OpenLcbCanFrame.TypeField.CANMESSAGE.ordinal());
- Assert.assertEquals("NMRANETCOMMONMESSAGE", 3, OpenLcbCanFrame.TypeField.NMRANETCOMMONMESSAGE.ordinal());
+ Assert.assertEquals("OPENLCBCOMMONMESSAGE", 3, OpenLcbCanFrame.TypeField.OPENLCBCOMMONMESSAGE.ordinal());
}
public void testMakeCim() {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jac...@us...> - 2010-05-26 00:58:57
|
Revision: 195
http://openlcb.svn.sourceforge.net/openlcb/?rev=195&view=rev
Author: jacobsen
Date: 2010-05-26 00:58:51 +0000 (Wed, 26 May 2010)
Log Message:
-----------
doc directory
Modified Paths:
--------------
trunk/prototypes/java/index.html
trunk/prototypes/java/test/scenarios/BlueGoldCheck.java
Modified: trunk/prototypes/java/index.html
===================================================================
--- trunk/prototypes/java/index.html 2010-05-24 00:46:06 UTC (rev 194)
+++ trunk/prototypes/java/index.html 2010-05-26 00:58:51 UTC (rev 195)
@@ -23,12 +23,12 @@
</P>
<P>Major subdirectories:</P>
<DL>
- <DT>src
+ <DT><A HREF="src">src</A>
</DT><DD>
Contains OpenLCB source in the org.openlcb package, and source for
OpenLCB CAN wire protocol in the org.openlcb.can package.
</DD><DT>
- test
+ <A HREF="test">test</A>
</DT><DD STYLE="margin-bottom: 0.5cm">
contains test code of several types in subpackages:
</DD></DL>
Modified: trunk/prototypes/java/test/scenarios/BlueGoldCheck.java
===================================================================
--- trunk/prototypes/java/test/scenarios/BlueGoldCheck.java 2010-05-24 00:46:06 UTC (rev 194)
+++ trunk/prototypes/java/test/scenarios/BlueGoldCheck.java 2010-05-26 00:58:51 UTC (rev 195)
@@ -58,28 +58,28 @@
// create and connect the nodes
producer11 = new SingleProducer(id, sg.getConnection(),
- new EventID(id, index, 1));
+ new EventID(id, 1, 1));
sg.register(producer11);
producer12 = new SingleProducer(id, sg.getConnection(),
- new EventID(id, index, 2));
+ new EventID(id, 1, 2));
sg.register(producer12);
producer13 = new SingleProducer(id, sg.getConnection(),
- new EventID(id, index, 3));
+ new EventID(id, 1, 3));
sg.register(producer13);
consumer11 = new SingleConsumer(id, sg.getConnection(),
- new EventID(id, index, 1));
+ new EventID(id, 0, 1));
sg.register(consumer11);
consumer12 = new SingleConsumer(id, sg.getConnection(),
- new EventID(id, index, 2));
+ new EventID(id, 0, 2));
sg.register(consumer12);
consumer13 = new SingleConsumer(id, sg.getConnection(),
- new EventID(id, index, 3));
+ new EventID(id, 0, 3));
sg.register(consumer13);
// composite GUI
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jac...@us...> - 2010-05-26 00:58:58
|
Revision: 195
http://openlcb.svn.sourceforge.net/openlcb/?rev=195&view=rev
Author: jacobsen
Date: 2010-05-26 00:58:51 +0000 (Wed, 26 May 2010)
Log Message:
-----------
doc directory
Modified Paths:
--------------
trunk/prototypes/java/index.html
trunk/prototypes/java/test/scenarios/BlueGoldCheck.java
Modified: trunk/prototypes/java/index.html
===================================================================
--- trunk/prototypes/java/index.html 2010-05-24 00:46:06 UTC (rev 194)
+++ trunk/prototypes/java/index.html 2010-05-26 00:58:51 UTC (rev 195)
@@ -23,12 +23,12 @@
</P>
<P>Major subdirectories:</P>
<DL>
- <DT>src
+ <DT><A HREF="src">src</A>
</DT><DD>
Contains OpenLCB source in the org.openlcb package, and source for
OpenLCB CAN wire protocol in the org.openlcb.can package.
</DD><DT>
- test
+ <A HREF="test">test</A>
</DT><DD STYLE="margin-bottom: 0.5cm">
contains test code of several types in subpackages:
</DD></DL>
Modified: trunk/prototypes/java/test/scenarios/BlueGoldCheck.java
===================================================================
--- trunk/prototypes/java/test/scenarios/BlueGoldCheck.java 2010-05-24 00:46:06 UTC (rev 194)
+++ trunk/prototypes/java/test/scenarios/BlueGoldCheck.java 2010-05-26 00:58:51 UTC (rev 195)
@@ -58,28 +58,28 @@
// create and connect the nodes
producer11 = new SingleProducer(id, sg.getConnection(),
- new EventID(id, index, 1));
+ new EventID(id, 1, 1));
sg.register(producer11);
producer12 = new SingleProducer(id, sg.getConnection(),
- new EventID(id, index, 2));
+ new EventID(id, 1, 2));
sg.register(producer12);
producer13 = new SingleProducer(id, sg.getConnection(),
- new EventID(id, index, 3));
+ new EventID(id, 1, 3));
sg.register(producer13);
consumer11 = new SingleConsumer(id, sg.getConnection(),
- new EventID(id, index, 1));
+ new EventID(id, 0, 1));
sg.register(consumer11);
consumer12 = new SingleConsumer(id, sg.getConnection(),
- new EventID(id, index, 2));
+ new EventID(id, 0, 2));
sg.register(consumer12);
consumer13 = new SingleConsumer(id, sg.getConnection(),
- new EventID(id, index, 3));
+ new EventID(id, 0, 3));
sg.register(consumer13);
// composite GUI
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jac...@us...> - 2010-05-27 01:58:43
|
Revision: 210
http://openlcb.svn.sourceforge.net/openlcb/?rev=210&view=rev
Author: jacobsen
Date: 2010-05-27 01:58:37 +0000 (Thu, 27 May 2010)
Log Message:
-----------
new Blue/Gold 'extended' implementation
Modified Paths:
--------------
trunk/prototypes/java/src/org/openlcb/implementations/BlueGoldEngine.java
trunk/prototypes/java/test/scenarios/BlueGoldCheck.java
Added Paths:
-----------
trunk/prototypes/java/src/org/openlcb/implementations/BlueGoldExtendedEngine.java
Modified: trunk/prototypes/java/src/org/openlcb/implementations/BlueGoldEngine.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/implementations/BlueGoldEngine.java 2010-05-26 19:06:52 UTC (rev 209)
+++ trunk/prototypes/java/src/org/openlcb/implementations/BlueGoldEngine.java 2010-05-27 01:58:37 UTC (rev 210)
@@ -68,6 +68,7 @@
}
// exit
setBlueLightOn(false);
+ setGoldLightOn(false);
selectedPC = -1;
}
@@ -79,12 +80,18 @@
// Methods to be overridden in using classes
public void setBlueLightOn(boolean f) {
}
+ public boolean getBlueLightOn() {
+ return false;
+ }
public void setBlueLightBlink(int dwell) {
}
public void setGoldLightOn(boolean f) {
}
+ public boolean getGoldLightOn() {
+ return false;
+ }
public void setGoldLightBlink(int dwell) {
}
@@ -120,7 +127,10 @@
}
protected void sendLearnEventMessage(EventID eid) {
- c.put(new LearnEventMessage(nid, eid), this);
+ LearnEventMessage msg = new LearnEventMessage(nid, eid);
+ c.put(msg, this);
+ // also process here
+ handleLearnEvent(msg, null);
}
EventID getEventID(int n) {
Added: trunk/prototypes/java/src/org/openlcb/implementations/BlueGoldExtendedEngine.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/implementations/BlueGoldExtendedEngine.java (rev 0)
+++ trunk/prototypes/java/src/org/openlcb/implementations/BlueGoldExtendedEngine.java 2010-05-27 01:58:37 UTC (rev 210)
@@ -0,0 +1,103 @@
+package org.openlcb.implementations;
+
+import org.openlcb.*;
+
+/**
+ * Example of a OpenLCB algorithm for doing configuration with
+ * small number of buttons. This an extended form that allows
+ * multiple selection and deselection.
+ *<p>
+ *<ul>
+ *<li>On learners, push blue to choose a C/P, then gold to put that C/P in learn mode
+ * (complete cycle turns off blue light and starts over)
+ *<li>On the teaching node, push gold to choose teach mode, then
+ * blue to select a C/P,
+ * push Gold to send the TeachEvent message
+ *</ul>
+ *<p>
+ * This handles both "configuring" and "being configured"
+ * cases. It also handles both consumers and producers
+ * via working with the
+ * {@link SingleConsumerNode} and {@link SingleProducerNode}
+ * example classes.
+ * <p>
+ * For button inputs, it currently has only "click" operations.
+ * Perhaps "down" and "up" will be needed eventually.
+ * Similarly, it only does "on" and "off" for the two lights.
+ * @author Bob Jacobsen Copyright 2010
+ * @version $Revision$
+ */
+public class BlueGoldExtendedEngine extends BlueGoldEngine {
+
+ boolean[] isSelectedPC;
+
+ public void goldClick() {
+ if (getGoldLightOn() && getBlueLightOn()) {
+ // in teach mode, send LearnEvent
+ if (selectedPC >= 0) { // redundant, as blue is on
+ // have a selected P or C
+ sendLearnEventMessage(getEventID(selectedPC));
+ setGoldLightOn(false);
+ setBlueLightOn(false);
+ selectedPC = -1;
+ return;
+ }
+ } else if (!getGoldLightOn() && getBlueLightOn()) {
+ // in learn mode, select item
+ if (selectedPC >= 0) { // redundant, as blue is on
+ isSelectedPC[selectedPC] = true;
+ selectedPC = -1;
+ setBlueLightOn(false);
+ }
+ } else if (!getGoldLightOn() && !getBlueLightOn()) {
+ // starting up, light gold
+ setGoldLightOn(true);
+ } else { // gold on, blue off
+ // give up
+ setGoldLightOn(false);
+ setBlueLightOn(false);
+ selectedPC = -1;
+ for (boolean p : isSelectedPC) p = false;
+ }
+ }
+
+ public void blueClick() {
+ // click updates selection
+ selectedPC++;
+ //check if wrapping
+ if (selectedPC >= producers.size()+consumers.size()) {
+ // yes, turn off light until next time
+ selectedPC = -1;
+ setBlueLightOn(false);
+ } else {
+ // no, make sure light is on
+ setBlueLightOn(true);
+ }
+ return;
+ }
+
+ public void handleLearnEvent(LearnEventMessage msg, Connection sender){
+ // learn
+ for (int i=0; i<isSelectedPC.length; i++) {
+ if (isSelectedPC[i]) {
+ EventID eid = msg.getEventID();
+ System.out.println("Set "+i+" to "+eid);
+ setEventID(i, eid);
+ }
+ isSelectedPC[i] = false;
+ }
+ // exit
+ setBlueLightOn(false);
+ setGoldLightOn(false);
+ selectedPC = -1;
+ }
+
+ public BlueGoldExtendedEngine(NodeID nid, ScatterGather sg,
+ java.util.List<SingleProducer> producers,
+ java.util.List<SingleConsumer> consumers) {
+ super(nid, sg, producers, consumers);
+
+ isSelectedPC = new boolean[producers.size()+consumers.size()];
+ for (boolean p : isSelectedPC) p = false;
+ }
+}
Property changes on: trunk/prototypes/java/src/org/openlcb/implementations/BlueGoldExtendedEngine.java
___________________________________________________________________
Added: svn:keywords
+ Id Revision
Added: svn:eol-style
+ native
Modified: trunk/prototypes/java/test/scenarios/BlueGoldCheck.java
===================================================================
--- trunk/prototypes/java/test/scenarios/BlueGoldCheck.java 2010-05-26 19:06:52 UTC (rev 209)
+++ trunk/prototypes/java/test/scenarios/BlueGoldCheck.java 2010-05-27 01:58:37 UTC (rev 210)
@@ -198,10 +198,13 @@
setGoldOn(false);
p1.add(goldLabel);
- engine = new BlueGoldEngine(nid, sg, producers, consumers) {
+ 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);
@@ -210,6 +213,9 @@
public void setGoldLightOn(boolean f) {
setGoldOn(f);
}
+ public boolean getGoldLightOn() {
+ return goldOn;
+ }
public void setGoldLightBlink(int dwell) {
setGoldBlink(dwell);
@@ -314,7 +320,7 @@
else
colorBlueOff();
}
-
+
public void setBlueBlink(int dwell) {
blueBlink = true;
blueOn = true;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jac...@us...> - 2010-05-27 01:58:46
|
Revision: 210
http://openlcb.svn.sourceforge.net/openlcb/?rev=210&view=rev
Author: jacobsen
Date: 2010-05-27 01:58:37 +0000 (Thu, 27 May 2010)
Log Message:
-----------
new Blue/Gold 'extended' implementation
Modified Paths:
--------------
trunk/prototypes/java/src/org/openlcb/implementations/BlueGoldEngine.java
trunk/prototypes/java/test/scenarios/BlueGoldCheck.java
Added Paths:
-----------
trunk/prototypes/java/src/org/openlcb/implementations/BlueGoldExtendedEngine.java
Modified: trunk/prototypes/java/src/org/openlcb/implementations/BlueGoldEngine.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/implementations/BlueGoldEngine.java 2010-05-26 19:06:52 UTC (rev 209)
+++ trunk/prototypes/java/src/org/openlcb/implementations/BlueGoldEngine.java 2010-05-27 01:58:37 UTC (rev 210)
@@ -68,6 +68,7 @@
}
// exit
setBlueLightOn(false);
+ setGoldLightOn(false);
selectedPC = -1;
}
@@ -79,12 +80,18 @@
// Methods to be overridden in using classes
public void setBlueLightOn(boolean f) {
}
+ public boolean getBlueLightOn() {
+ return false;
+ }
public void setBlueLightBlink(int dwell) {
}
public void setGoldLightOn(boolean f) {
}
+ public boolean getGoldLightOn() {
+ return false;
+ }
public void setGoldLightBlink(int dwell) {
}
@@ -120,7 +127,10 @@
}
protected void sendLearnEventMessage(EventID eid) {
- c.put(new LearnEventMessage(nid, eid), this);
+ LearnEventMessage msg = new LearnEventMessage(nid, eid);
+ c.put(msg, this);
+ // also process here
+ handleLearnEvent(msg, null);
}
EventID getEventID(int n) {
Added: trunk/prototypes/java/src/org/openlcb/implementations/BlueGoldExtendedEngine.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/implementations/BlueGoldExtendedEngine.java (rev 0)
+++ trunk/prototypes/java/src/org/openlcb/implementations/BlueGoldExtendedEngine.java 2010-05-27 01:58:37 UTC (rev 210)
@@ -0,0 +1,103 @@
+package org.openlcb.implementations;
+
+import org.openlcb.*;
+
+/**
+ * Example of a OpenLCB algorithm for doing configuration with
+ * small number of buttons. This an extended form that allows
+ * multiple selection and deselection.
+ *<p>
+ *<ul>
+ *<li>On learners, push blue to choose a C/P, then gold to put that C/P in learn mode
+ * (complete cycle turns off blue light and starts over)
+ *<li>On the teaching node, push gold to choose teach mode, then
+ * blue to select a C/P,
+ * push Gold to send the TeachEvent message
+ *</ul>
+ *<p>
+ * This handles both "configuring" and "being configured"
+ * cases. It also handles both consumers and producers
+ * via working with the
+ * {@link SingleConsumerNode} and {@link SingleProducerNode}
+ * example classes.
+ * <p>
+ * For button inputs, it currently has only "click" operations.
+ * Perhaps "down" and "up" will be needed eventually.
+ * Similarly, it only does "on" and "off" for the two lights.
+ * @author Bob Jacobsen Copyright 2010
+ * @version $Revision$
+ */
+public class BlueGoldExtendedEngine extends BlueGoldEngine {
+
+ boolean[] isSelectedPC;
+
+ public void goldClick() {
+ if (getGoldLightOn() && getBlueLightOn()) {
+ // in teach mode, send LearnEvent
+ if (selectedPC >= 0) { // redundant, as blue is on
+ // have a selected P or C
+ sendLearnEventMessage(getEventID(selectedPC));
+ setGoldLightOn(false);
+ setBlueLightOn(false);
+ selectedPC = -1;
+ return;
+ }
+ } else if (!getGoldLightOn() && getBlueLightOn()) {
+ // in learn mode, select item
+ if (selectedPC >= 0) { // redundant, as blue is on
+ isSelectedPC[selectedPC] = true;
+ selectedPC = -1;
+ setBlueLightOn(false);
+ }
+ } else if (!getGoldLightOn() && !getBlueLightOn()) {
+ // starting up, light gold
+ setGoldLightOn(true);
+ } else { // gold on, blue off
+ // give up
+ setGoldLightOn(false);
+ setBlueLightOn(false);
+ selectedPC = -1;
+ for (boolean p : isSelectedPC) p = false;
+ }
+ }
+
+ public void blueClick() {
+ // click updates selection
+ selectedPC++;
+ //check if wrapping
+ if (selectedPC >= producers.size()+consumers.size()) {
+ // yes, turn off light until next time
+ selectedPC = -1;
+ setBlueLightOn(false);
+ } else {
+ // no, make sure light is on
+ setBlueLightOn(true);
+ }
+ return;
+ }
+
+ public void handleLearnEvent(LearnEventMessage msg, Connection sender){
+ // learn
+ for (int i=0; i<isSelectedPC.length; i++) {
+ if (isSelectedPC[i]) {
+ EventID eid = msg.getEventID();
+ System.out.println("Set "+i+" to "+eid);
+ setEventID(i, eid);
+ }
+ isSelectedPC[i] = false;
+ }
+ // exit
+ setBlueLightOn(false);
+ setGoldLightOn(false);
+ selectedPC = -1;
+ }
+
+ public BlueGoldExtendedEngine(NodeID nid, ScatterGather sg,
+ java.util.List<SingleProducer> producers,
+ java.util.List<SingleConsumer> consumers) {
+ super(nid, sg, producers, consumers);
+
+ isSelectedPC = new boolean[producers.size()+consumers.size()];
+ for (boolean p : isSelectedPC) p = false;
+ }
+}
Property changes on: trunk/prototypes/java/src/org/openlcb/implementations/BlueGoldExtendedEngine.java
___________________________________________________________________
Added: svn:keywords
+ Id Revision
Added: svn:eol-style
+ native
Modified: trunk/prototypes/java/test/scenarios/BlueGoldCheck.java
===================================================================
--- trunk/prototypes/java/test/scenarios/BlueGoldCheck.java 2010-05-26 19:06:52 UTC (rev 209)
+++ trunk/prototypes/java/test/scenarios/BlueGoldCheck.java 2010-05-27 01:58:37 UTC (rev 210)
@@ -198,10 +198,13 @@
setGoldOn(false);
p1.add(goldLabel);
- engine = new BlueGoldEngine(nid, sg, producers, consumers) {
+ 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);
@@ -210,6 +213,9 @@
public void setGoldLightOn(boolean f) {
setGoldOn(f);
}
+ public boolean getGoldLightOn() {
+ return goldOn;
+ }
public void setGoldLightBlink(int dwell) {
setGoldBlink(dwell);
@@ -314,7 +320,7 @@
else
colorBlueOff();
}
-
+
public void setBlueBlink(int dwell) {
blueBlink = true;
blueOn = true;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jac...@us...> - 2010-05-27 13:44:13
|
Revision: 215
http://openlcb.svn.sourceforge.net/openlcb/?rev=215&view=rev
Author: jacobsen
Date: 2010-05-27 13:44:07 +0000 (Thu, 27 May 2010)
Log Message:
-----------
long blue press resets selections
Modified Paths:
--------------
trunk/prototypes/java/src/org/openlcb/implementations/BlueGoldEngine.java
trunk/prototypes/java/src/org/openlcb/implementations/BlueGoldExtendedEngine.java
trunk/prototypes/java/test/scenarios/BlueGoldCheck.java
Modified: trunk/prototypes/java/src/org/openlcb/implementations/BlueGoldEngine.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/implementations/BlueGoldEngine.java 2010-05-27 02:21:57 UTC (rev 214)
+++ trunk/prototypes/java/src/org/openlcb/implementations/BlueGoldEngine.java 2010-05-27 13:44:07 UTC (rev 215)
@@ -41,6 +41,8 @@
}
}
+ public void longGoldPress() {}
+
public void blueClick() {
// click updates selection
selectedPC++;
@@ -59,6 +61,8 @@
return;
}
+ public void longBluePress() {}
+
public void handleLearnEvent(LearnEventMessage msg, Connection sender){
// learn
if (selectedPC >= 0) {
Modified: trunk/prototypes/java/src/org/openlcb/implementations/BlueGoldExtendedEngine.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/implementations/BlueGoldExtendedEngine.java 2010-05-27 02:21:57 UTC (rev 214)
+++ trunk/prototypes/java/src/org/openlcb/implementations/BlueGoldExtendedEngine.java 2010-05-27 13:44:07 UTC (rev 215)
@@ -76,6 +76,15 @@
return;
}
+ public void longBluePress() {
+ // reset selections, leave gold alone
+ for (int i=0; i<isSelectedPC.length; i++) {
+ isSelectedPC[i] = false;
+ }
+ selectedPC = -1;
+ setBlueLightOn(false);
+ }
+
public void handleLearnEvent(LearnEventMessage msg, Connection sender){
// learn
for (int i=0; i<isSelectedPC.length; i++) {
Modified: trunk/prototypes/java/test/scenarios/BlueGoldCheck.java
===================================================================
--- trunk/prototypes/java/test/scenarios/BlueGoldCheck.java 2010-05-27 02:21:57 UTC (rev 214)
+++ trunk/prototypes/java/test/scenarios/BlueGoldCheck.java 2010-05-27 13:44:07 UTC (rev 215)
@@ -257,7 +257,9 @@
* the blue button
*/
void longBluePress() {
- // nothing
+ // reset selections
+ System.out.println("reset selections");
+ engine.longBluePress();
}
/**
@@ -266,7 +268,7 @@
*/
void longGoldPress() {
// reset the device
- System.out.println("reset");
+ 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));
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jac...@us...> - 2010-05-27 13:44:13
|
Revision: 215
http://openlcb.svn.sourceforge.net/openlcb/?rev=215&view=rev
Author: jacobsen
Date: 2010-05-27 13:44:07 +0000 (Thu, 27 May 2010)
Log Message:
-----------
long blue press resets selections
Modified Paths:
--------------
trunk/prototypes/java/src/org/openlcb/implementations/BlueGoldEngine.java
trunk/prototypes/java/src/org/openlcb/implementations/BlueGoldExtendedEngine.java
trunk/prototypes/java/test/scenarios/BlueGoldCheck.java
Modified: trunk/prototypes/java/src/org/openlcb/implementations/BlueGoldEngine.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/implementations/BlueGoldEngine.java 2010-05-27 02:21:57 UTC (rev 214)
+++ trunk/prototypes/java/src/org/openlcb/implementations/BlueGoldEngine.java 2010-05-27 13:44:07 UTC (rev 215)
@@ -41,6 +41,8 @@
}
}
+ public void longGoldPress() {}
+
public void blueClick() {
// click updates selection
selectedPC++;
@@ -59,6 +61,8 @@
return;
}
+ public void longBluePress() {}
+
public void handleLearnEvent(LearnEventMessage msg, Connection sender){
// learn
if (selectedPC >= 0) {
Modified: trunk/prototypes/java/src/org/openlcb/implementations/BlueGoldExtendedEngine.java
===================================================================
--- trunk/prototypes/java/src/org/openlcb/implementations/BlueGoldExtendedEngine.java 2010-05-27 02:21:57 UTC (rev 214)
+++ trunk/prototypes/java/src/org/openlcb/implementations/BlueGoldExtendedEngine.java 2010-05-27 13:44:07 UTC (rev 215)
@@ -76,6 +76,15 @@
return;
}
+ public void longBluePress() {
+ // reset selections, leave gold alone
+ for (int i=0; i<isSelectedPC.length; i++) {
+ isSelectedPC[i] = false;
+ }
+ selectedPC = -1;
+ setBlueLightOn(false);
+ }
+
public void handleLearnEvent(LearnEventMessage msg, Connection sender){
// learn
for (int i=0; i<isSelectedPC.length; i++) {
Modified: trunk/prototypes/java/test/scenarios/BlueGoldCheck.java
===================================================================
--- trunk/prototypes/java/test/scenarios/BlueGoldCheck.java 2010-05-27 02:21:57 UTC (rev 214)
+++ trunk/prototypes/java/test/scenarios/BlueGoldCheck.java 2010-05-27 13:44:07 UTC (rev 215)
@@ -257,7 +257,9 @@
* the blue button
*/
void longBluePress() {
- // nothing
+ // reset selections
+ System.out.println("reset selections");
+ engine.longBluePress();
}
/**
@@ -266,7 +268,7 @@
*/
void longGoldPress() {
// reset the device
- System.out.println("reset");
+ 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));
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jac...@us...> - 2010-06-07 17:30:55
|
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.
|