Skip to content
Permalink
Browse files

MERG CBUS Tests

and a few tweaks
CBUS Slot Monitor
CBUS Dummy Node
CBUS Event Table
  • Loading branch information...
icklesteve committed Apr 1, 2019
1 parent 3746ef8 commit c275a736949ccd0507aebeb452f3f234f4f3abb6
@@ -427,6 +427,17 @@ MAutoRevTip = Reverses block direction on loco direction change
High = High
Low = Low
Speed = Speed
EngineState = Engine State:
Active = Active
Inactive = Inactive
Consisted = Consisted
Consistmaster = Consist Master
Lights = Lights:
RelDirection = Rel Direction:
EStop = E Stop
LocoID = Loco ID
Long = Long
Steps = Steps

# Cbus Simulation Items
MenuAdd = Add
@@ -515,7 +526,7 @@ ERR_THROTTLE_TIMEOUT = Throttle request (RLOC) timed out
# FW Weed day month : FD Freeze Real : FM Month Day : FT temperature :
# FH Hour : FI Minute : CH Characters :ET Event Number # : EV# Event Variable # :
OPC_AD = Addr
OPC_CA = Consist addr
OPC_CA = Consist ID
OPC_CH = Chars
OPC_CS = CS
OPC_CV = CV
@@ -39,6 +39,10 @@ public CbusThrottleManager(CanSystemConnectionMemo memo) {

public void dispose() {
tc.removeCanListener(this);
if (throttleRequestTimer != null ) {
throttleRequestTimer.stop();
throttleRequestTimer = null;
}
}

TrafficController tc;
@@ -79,7 +79,7 @@ public CbusEventTableAction( CbusEventTableDataModel model) {
public File _saveFile = null;
private String _saveFileName = null;
public boolean _saved = false;
private boolean sessionConfirmDeleteRow=true; // display confirm popup
protected boolean sessionConfirmDeleteRow=true; // display confirm popup

private void updatejmricell(int row, Boolean ison, String name){
String bb;
@@ -1,7 +1,6 @@
package jmri.jmrix.can.cbus.eventtable;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JTable;
import javax.swing.JTextField;
import java.util.ArrayList;
@@ -231,8 +230,7 @@ public static int getPreferredWidth(int col) {
case STLR_OFF_COLUMN:
return new JTextField(20).getPreferredSize().width;
default:
log.warn("width {} undefined",col);
return new JLabel(" <unknown> ").getPreferredSize().width; // NOI18N
return new JTextField(" <unknown> ").getPreferredSize().width; // NOI18N
}
}

@@ -298,7 +296,6 @@ public static int getColumnWidth(int col) {
case STATE_COLUMN:
return Enum.class;
default:
log.warn("no class set col {}",col);
return null;
}
}
@@ -377,7 +374,6 @@ public Object getValueAt(int row, int col) {
case STLR_OFF_COLUMN:
return _mainArray.get(row).getStlOff();
default:
log.error("internal state inconsistent with table request for row {} col {}", row, col);
return null;
}
}
@@ -398,7 +394,7 @@ public void setValueAt(Object value, int row, int col) {
}
else if (col == STATE_COLUMN) {
_mainArray.get(row).setState( (CbusTableEvent.EvState) value );
ThreadingUtil.runOnGUI( ()->{ fireTableCellUpdated(row, STATE_COLUMN); });
updateGuiCell(row,col);
}
else if (col == DELETE_BUTTON_COLUMN) {
ThreadingUtil.runOnGUI( ()->{ ta.buttonDeleteClicked(row); });
@@ -417,41 +413,47 @@ else if (col == STATUS_REQUEST_BUTTON_COLUMN) {
}
else if (col == SESSION_ON_COLUMN) {
_mainArray.get(row).bumpSessionOn();
ThreadingUtil.runOnGUI( ()->{ fireTableCellUpdated(row,SESSION_ON_COLUMN); });
ThreadingUtil.runOnGUI( ()->{ fireTableCellUpdated(row,SESSION_TOTAL_COLUMN); });
updateGuiCell(row,col);
updateGuiCell(row,SESSION_TOTAL_COLUMN);
}
else if (col == SESSION_OFF_COLUMN) {
_mainArray.get(row).bumpSessionOff();
ThreadingUtil.runOnGUI( ()->{ fireTableCellUpdated(row,SESSION_OFF_COLUMN); });
ThreadingUtil.runOnGUI( ()->{ fireTableCellUpdated(row,SESSION_TOTAL_COLUMN); });
updateGuiCell(row,col);
updateGuiCell(row,SESSION_TOTAL_COLUMN);
}
else if (col == SESSION_IN_COLUMN) {
_mainArray.get(row).bumpSessionIn();
ThreadingUtil.runOnGUI( ()->{ fireTableCellUpdated(row, SESSION_IN_COLUMN); });
updateGuiCell(row,col);
}
else if (col == CANID_COLUMN) {
_mainArray.get(row).setCanId( (Integer) value);
ThreadingUtil.runOnGUI( ()->{ fireTableCellUpdated(row, CANID_COLUMN); });
updateGuiCell(row,col);
}
else if (col == SESSION_OUT_COLUMN) {
_mainArray.get(row).bumpSessionOut();
ThreadingUtil.runOnGUI( ()->{ fireTableCellUpdated(row, SESSION_OUT_COLUMN); });
updateGuiCell(row,col);
}
else if (col == LATEST_TIMESTAMP_COLUMN) {
_mainArray.get(row).setDate( new Date() );
ThreadingUtil.runOnGUI( ()->{ fireTableCellUpdated(row, LATEST_TIMESTAMP_COLUMN); });
updateGuiCell(row,col);
}
else if (col == STLR_ON_COLUMN) {
_mainArray.get(row).setStlOn( (String) value );
ThreadingUtil.runOnGUI( ()->{ fireTableCellUpdated(row, STLR_ON_COLUMN); });
updateGuiCell(row,col);
}
else if (col == STLR_OFF_COLUMN) {
_mainArray.get(row).setStlOff( (String) value );
ThreadingUtil.runOnGUI( ()->{ fireTableCellUpdated(row, STLR_OFF_COLUMN); });
updateGuiCell(row,col);
}
// table is dirty
ta._saved = false;
}

private void updateGuiCell( int row, int col){
ThreadingUtil.runOnGUI( ()->{
fireTableCellUpdated(row, col);
});
}

/**
* Report whether table has changed.
@@ -525,6 +527,7 @@ public void reply(CanReply m) { // incoming cbus message
public void parseMessage( int canid, int node, int event, CbusTableEvent.EvState state, int in, int out) {

int existingRow = seeIfEventOnTable( node, event);

if (existingRow<0) {
int on=0;
int off=0;
@@ -3,6 +3,7 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import jmri.jmrix.can.cbus.simulator.CbusDummyNode;

// import org.slf4j.Logger;
// import org.slf4j.LoggerFactory;
@@ -42,6 +43,9 @@
*/
public static void setTraits( CbusNode node ){

// defaults
node.setsendsWRACKonNVSET(true);

if ( node.getParameter(1) == 165 ) { // MERG MODULE
if ( node.getParameter(3) == 29 ) { // CANPAN

@@ -50,7 +54,56 @@ public static void setTraits( CbusNode node ){
}
}
}


// reset a Dummy Node to its virgin condition
public static void setDummyNodeParameters( CbusDummyNode thisNode, int manu, int type ){

if ( manu == 165 ) { // MERG MODULE
if ( type == 29 ) { // CANPAN

int[] _params = new int[]{
20, /* 0 num parameters */
165, /* 1 manufacturer ID */
89, /* 2 Minor code version */
29, /* 3 Manufacturer module identifier */
128, /* 4 Number of supported events */
13, /* 5 Number of Event Variables per event */
1, /* 6 Number of Node Variables */
1, /* 7 Major version */
13, /* 8 Node flags */
13, /* 9 Processor type */
1, /* 10 Bus type */
0, /* 11 load address, 1/4 bytes */
8, /* 12 load address, 2/4 bytes */
0, /* 13 load address, 3/4 bytes */
0, /* 14 load address, 4/4 bytes */
0, /* 15 CPU manufacturer's id 1/4 */
0, /* 16 CPU manufacturer's id 2/4 */
0, /* 17 CPU manufacturer's id 3/4 */
0, /* 18 CPU manufacturer's id 4/4 */
1, /* 19 CPU manufacturer code */
1, /* 20 Beta revision */
};

thisNode.setParameters(_params);
thisNode.setNVs( new int[]{ 1 , 0 } );
}
else {

// default MERG module in SLiM mode
thisNode.setParameters( new int[]{ 8,165,0,0,0,0,0,0,0 } );
thisNode.setNVs( new int[]{ 0 } );
}
}
else {
thisNode.setParameters( new int[]{ 7,165,0,0,0,0,0,0 } );
thisNode.setNVs( new int[]{ 0 } );
}

setTraits( thisNode );

}

/**
* Return a string representation of a decoded Module Manufacturer
* @param man manufacturer int
@@ -4,6 +4,9 @@
import javax.annotation.Nonnull;
import jmri.jmrix.can.cbus.CbusEvent;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Class to represent an event stored on a node.
*
@@ -34,11 +37,15 @@ public CbusNodeEvent( int nn, int en, int thisnode, int index, int maxEvVar){
/**
* Set the value of the event variable array by index
*
* @param index variable array index, index 0 should be total variables in array
* @param index event variable index, minimum 1
* @param value min 0 max 255
*/
public void setEvVar(int index, int value) {
_evVarArr[(index-1)]=value;
if ( index < 1 ) {
log.error("Event Index needs to be > 0");
} else {
_evVarArr[(index-1)]=value;
}
}

/**
@@ -137,5 +144,7 @@ public int getIndex(){
public int getNumEvVars() {
return _evVarArr.length;
}

private static final Logger log = LoggerFactory.getLogger(CbusNodeEvent.class);

}

0 comments on commit c275a73

Please sign in to comment.
You can’t perform that action at this time.