Skip to content

Commit

Permalink
Javadoc and IDE warnings
Browse files Browse the repository at this point in the history
Also some minor formatting and whitespace changes
  • Loading branch information
rhwood committed Feb 20, 2017
1 parent 22d253a commit 73fc568
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 26 deletions.
2 changes: 1 addition & 1 deletion build.xml
Expand Up @@ -1550,7 +1550,7 @@
</packageset>
<arg value="-Xdoclint:all,-missing"/><!-- remove -missing to get warnings about missing javadoc tags -->
<arg value="-Xmaxwarns"/>
<arg value="3950"/><!-- change from default 100 warnings -->
<arg value="3900"/><!-- change from default 100 warnings -->
<arg value="-quiet"/>
<arg value="-splitindex"/>
<!-- disable output of custom @navassoc tag - used for UML image generation -->
Expand Down
40 changes: 29 additions & 11 deletions java/src/jmri/TransitSectionAction.java
@@ -1,6 +1,5 @@
package jmri;


/**
* This class holds information and options for a Action to be applied when an
* automated train enters, exits, or is inside of a Section in a Transit.
Expand Down Expand Up @@ -34,9 +33,11 @@
*/
public class TransitSectionAction {

/**
/*
* Constants representing the "when" (when the action is to be initiated) of
* the Action
*
* TODO: Convert to ENUM
*/
public static final int NUM_WHENS = 8; // Must correspond to the number of entries below
public static final int ENTRY = 1; // On entry to Section
Expand All @@ -48,8 +49,10 @@ public class TransitSectionAction {
public static final int SENSORACTIVE = 7; // When specified Sensor changes to Active
public static final int SENSORINACTIVE = 8; // When specified Sensor changtes to Inactive
// other action 'whens" may be defined here
/**
/*
* Constants designating the "what" (the action to be taken) of the Action
*
* TODO: Convert to ENUM
*/
public static final int PAUSE = 1; // pause for the number of fast minutes in mDataWhat (e.g. station stop)
public static final int SETMAXSPEED = 2; // set maximum train speed to value entered
Expand All @@ -60,9 +63,9 @@ public class TransitSectionAction {
public static final int STARTBELL = 7; // start bell (only works with sound decoder, function 1 ON)
public static final int STOPBELL = 8; // stop bell (only works with sound decoder, function 1 OFF)
public static final int SOUNDHORN = 9; // sound horn for specified number of milliseconds
// (only works with sound decoder, function 2)
// (only works with sound decoder, function 2)
public static final int SOUNDHORNPATTERN = 10; // sound horn according to specified pattern
// (only works with sound decoder, function 2)
// (only works with sound decoder, function 2)
public static final int LOCOFUNCTION = 11; // execute the specified decoder function
public static final int SETSENSORACTIVE = 12; // set specified sensor active (offers access to Logix)
public static final int SETSENSORINACTIVE = 13; // set specified sensor inactive
Expand All @@ -72,15 +75,31 @@ public class TransitSectionAction {
// other action 'whats" may be defined here, increment NUM_WHATS to match

/**
* Main constructor method
* Create a TransitSectionAction.
*
* @param when one of
* {@link #ENTRY}, {@link #EXIT}, {@link #BLOCKENTRY}, {@link #BLOCKEXIT}, {@link #TRAINSTOP}, {@link #TRAINSTART}, {@link #SENSORACTIVE}, {@link #SENSORINACTIVE}
* @param what one of
* {@link #PAUSE}, {@link #SETMAXSPEED}, {@link #SETCURRENTSPEED}, {@link #RAMPTRAINSPEED}, {@link #TOMANUALMODE}, {@link #SETLIGHT}, {@link #STARTBELL}, {@link #STOPBELL}, {@link #SOUNDHORN}, {@link #SOUNDHORNPATTERN}, {@link #LOCOFUNCTION}, {@link #SETSENSORACTIVE}, {@link #SETSENSORINACTIVE}, {@link #HOLDSIGNAL}, {@link #RELEASESIGNAL}
*/
public TransitSectionAction(int when, int what) {
mWhen = when;
mWhat = what;
}

/**
* Convenience constructor
* Create a TransitSectionAction.
*
* @param when one of
* {@link #ENTRY}, {@link #EXIT}, {@link #BLOCKENTRY}, {@link #BLOCKEXIT}, {@link #TRAINSTOP}, {@link #TRAINSTART}, {@link #SENSORACTIVE}, {@link #SENSORINACTIVE}
* @param what one of
* {@link #PAUSE}, {@link #SETMAXSPEED}, {@link #SETCURRENTSPEED}, {@link #RAMPTRAINSPEED}, {@link #TOMANUALMODE}, {@link #SETLIGHT}, {@link #STARTBELL}, {@link #STOPBELL}, {@link #SOUNDHORN}, {@link #SOUNDHORNPATTERN}, {@link #LOCOFUNCTION}, {@link #SETSENSORACTIVE}, {@link #SETSENSORINACTIVE}, {@link #HOLDSIGNAL}, {@link #RELEASESIGNAL}
* @param dataWhen a data element for when
* @param dataWhat1 a data element for what
* @param dataWhat2 a data element for what
* @param sWhen typically a readable description of when or the name of
* the triggering sensors
* @param sWhat typically a readable description of what
*/
public TransitSectionAction(int when, int what, int dataWhen, int dataWhat1, int dataWhat2, String sWhen, String sWhat) {
mWhen = when;
Expand All @@ -101,7 +120,7 @@ public TransitSectionAction(int when, int what, int dataWhen, int dataWhat1, int
private String mStringWhen = "";
private String mStringWhat = "";

/**
/*
* Access methods
*/
public int getWhenCode() {
Expand Down Expand Up @@ -160,7 +179,7 @@ public void setStringWhat(String s) {
mStringWhat = s;
}

/**
/*
* operational instance variables - flags and data for executing the action
* (see jmri.jmrit.dispatcher.AutoActiveTrain.java)
*/
Expand All @@ -185,7 +204,7 @@ public void initialize() {
_sensorListener = null;
}

/**
/*
* Operational access methods
*/
public Thread getWaitingThread() {
Expand Down Expand Up @@ -257,4 +276,3 @@ public void dispose() {
disposeSensorListener();
}
}

39 changes: 25 additions & 14 deletions java/src/jmri/configurexml/BlockManagerXml.java
Expand Up @@ -138,9 +138,9 @@ public Element store(Object o) {

if (b.getDeniedBlocks().size() > 0) {
Element denied = new Element("deniedBlocks");
for (String deniedBlock : b.getDeniedBlocks()) {
b.getDeniedBlocks().forEach((deniedBlock) -> {
denied.addContent(new Element("block").addContent(deniedBlock));
}
});
elem.addContent(denied);
}

Expand Down Expand Up @@ -206,8 +206,8 @@ void addBeanSetting(Element e, BeanSetting bs) {
* <p>
* The BlockManager in the InstanceManager is created automatically.
*
* @param sharedBlocks Element containing the block elements to load.
* @param perNodeBlocks Per-node block elements to load.
* @param sharedBlocks Element containing the block elements to load
* @param perNodeBlocks Per-node block elements to load
* @return true if successful
* @throws jmri.configurexml.JmriConfigureXmlException if error during load
*/
Expand Down Expand Up @@ -241,9 +241,13 @@ public boolean load(Element sharedBlocks, Element perNodeBlocks) throws JmriConf
/**
* Utility method to load the individual Block objects.
*
* @param element Element holding one block
* @param element Element containing one block
* @throws jmri.configurexml.JmriConfigureXmlException if element contains
* malformed or
* schematically invalid
* XMl
*/
public void loadBlock(Element element) throws jmri.configurexml.JmriConfigureXmlException {
public void loadBlock(Element element) throws JmriConfigureXmlException {
if (element.getAttribute("systemName") == null) {
log.warn("unexpected null in systemName " + element + " " + element.getAttributes());
return;
Expand All @@ -268,7 +272,7 @@ public void loadBlock(Element element) throws jmri.configurexml.JmriConfigureXml
}
if (element.getAttribute("length") != null) {
// load length in millimeters
block.setLength(Float.valueOf(element.getAttribute("length").getValue()).floatValue());
block.setLength(Float.parseFloat(element.getAttribute("length").getValue()));
}
if (element.getAttribute("curve") != null) {
// load curve attribute
Expand Down Expand Up @@ -345,29 +349,36 @@ public void loadBlock(Element element) throws jmri.configurexml.JmriConfigureXml

int startSize = block.getPaths().size();
int loadCount = 0;

for (int i = 0; i < paths.size(); i++) {
Element path = paths.get(i);
if (loadPath(block, path)) loadCount++;
if (loadPath(block, path)) {
loadCount++;
}
}

if (startSize > 0 && loadCount > 0) {
log.warn("Added " + loadCount++ + " paths to block " + sysName + " that already had " + startSize + " blocks.");
}

if (startSize + loadCount != block.getPaths().size()) {
log.error("Started with " + startSize + " paths in block " + sysName + ", added "+loadCount+" but final count is "+block.getPaths().size()+"; something not right.");
log.error("Started with " + startSize + " paths in block " + sysName + ", added " + loadCount + " but final count is " + block.getPaths().size() + "; something not right.");
}

}

/**
* Load path into an existing Block.
* Load path into an existing Block from XML.
*
* @param block Block to receive path
* @param element Element containing path information
* @return true if path added to block; false otherwise
* @throws jmri.configurexml.JmriConfigureXmlException if element contains
* malformed or
* schematically invalid
* XMl
*/
public boolean loadPath(Block block, Element element) throws jmri.configurexml.JmriConfigureXmlException {
public boolean loadPath(Block block, Element element) throws JmriConfigureXmlException {
// load individual path
int toDir = 0;
int fromDir = 0;
Expand Down Expand Up @@ -395,7 +406,7 @@ public boolean loadPath(Block block, Element element) throws jmri.configurexml.J
}

// check if path already in block
if (!block.hasPath(path)) {
if (!block.hasPath(path)) {
block.addPath(path);
return true;
} else {
Expand Down

0 comments on commit 73fc568

Please sign in to comment.