use of us.mn.state.dot.tms.CommProtocol in project iris by mnit-rtmc.
the class CommConfigModel method createColumns.
/**
* Create the columns in the model
*/
@Override
protected ArrayList<ProxyColumn<CommConfig>> createColumns() {
ArrayList<ProxyColumn<CommConfig>> cols = new ArrayList<ProxyColumn<CommConfig>>(9);
cols.add(new ProxyColumn<CommConfig>("comm.config", 60) {
public Object getValueAt(CommConfig cc) {
return cc.getName();
}
});
cols.add(new ProxyColumn<CommConfig>("device.description", 220) {
public Object getValueAt(CommConfig cc) {
return cc.getDescription();
}
public boolean isEditable(CommConfig cc) {
return canWrite(cc, "description");
}
public void setValueAt(CommConfig cc, Object value) {
cc.setDescription(value.toString().trim());
}
});
cols.add(new ProxyColumn<CommConfig>("comm.config.protocol", 140) {
public Object getValueAt(CommConfig cc) {
return CommProtocol.fromOrdinal(cc.getProtocol());
}
public boolean isEditable(CommConfig cc) {
return canWrite(cc, "protocol");
}
public void setValueAt(CommConfig cc, Object value) {
if (value instanceof CommProtocol) {
CommProtocol cp = (CommProtocol) value;
cc.setProtocol((short) cp.ordinal());
}
}
protected TableCellEditor createCellEditor() {
JComboBox<CommProtocol> cbx = new JComboBox<CommProtocol>(CommProtocol.valuesSorted());
return new DefaultCellEditor(cbx);
}
});
cols.add(new ProxyColumn<CommConfig>("comm.config.modem", 56, Boolean.class) {
public Object getValueAt(CommConfig cc) {
return cc.getModem();
}
public boolean isEditable(CommConfig cc) {
return canWrite(cc, "modem");
}
public void setValueAt(CommConfig cc, Object value) {
if (value instanceof Boolean)
cc.setModem((Boolean) value);
}
});
cols.add(new ProxyColumn<CommConfig>("comm.config.timeout_ms", 60) {
public Object getValueAt(CommConfig cc) {
return cc.getTimeoutMs();
}
public boolean isEditable(CommConfig cc) {
return canWrite(cc, "timeoutMs");
}
public void setValueAt(CommConfig cc, Object value) {
if (value instanceof Integer)
cc.setTimeoutMs((Integer) value);
}
protected TableCellEditor createCellEditor() {
return new TimeoutCellEditor(MAX_TIMEOUT_MS);
}
});
cols.add(new PeriodColumn("comm.config.poll_period_sec", CommConfig.VALID_PERIODS, 92) {
protected int getPeriodSec(CommConfig cc) {
return cc.getPollPeriodSec();
}
protected void setPeriodSec(CommConfig cc, int s) {
cc.setPollPeriodSec(s);
}
public boolean isEditable(CommConfig cc) {
return canWrite(cc, "pollPeriodSec");
}
});
cols.add(new PeriodColumn("comm.config.long_poll_period_sec", CommConfig.VALID_PERIODS, 92) {
protected int getPeriodSec(CommConfig cc) {
return cc.getLongPollPeriodSec();
}
protected void setPeriodSec(CommConfig cc, int s) {
cc.setLongPollPeriodSec(s);
}
public boolean isEditable(CommConfig cc) {
return canWrite(cc, "longPollPeriodSec");
}
});
cols.add(new PeriodColumn("comm.config.idle_disconnect_sec", CommConfig.VALID_DISCONNECT, 108) {
protected int getPeriodSec(CommConfig cc) {
return cc.getIdleDisconnectSec();
}
protected void setPeriodSec(CommConfig cc, int s) {
cc.setIdleDisconnectSec(s);
}
public boolean isEditable(CommConfig cc) {
return canWrite(cc, "idleDisconnectSec");
}
});
cols.add(new PeriodColumn("comm.config.no_response_disconnect_sec", CommConfig.VALID_DISCONNECT, 108) {
protected int getPeriodSec(CommConfig cc) {
return cc.getNoResponseDisconnectSec();
}
protected void setPeriodSec(CommConfig cc, int s) {
cc.setNoResponseDisconnectSec(s);
}
public boolean isEditable(CommConfig cc) {
return canWrite(cc, "noResponseDisconnectSec");
}
});
return cols;
}
use of us.mn.state.dot.tms.CommProtocol in project iris by mnit-rtmc.
the class CommConfigImpl method doSetProtocol.
/**
* Set the communication protocol
*/
public void doSetProtocol(short p) throws TMSException {
CommProtocol cp = CommProtocol.fromOrdinal(p);
if (cp == null)
throw new ChangeVetoException("Invalid protocol: " + p);
if (cp != protocol) {
store.update(this, "protocol", p);
setProtocol(p);
}
}
use of us.mn.state.dot.tms.CommProtocol in project iris by mnit-rtmc.
the class MndotProperty method validateResponse.
/**
* Validate a response packet.
* @param c Controller receiving response.
* @param pkt Response packet.
* @throws IOException on errors parsing the packet.
*/
private static void validateResponse(ControllerImpl c, byte[] pkt) throws IOException {
if (pkt.length < 3)
throw new ParsingException("TOO SHORT");
validateChecksum(pkt);
if (pkt.length != pkt[OFF_LENGTH] + 3)
throw new ParsingException("INVALID LENGTH");
CommProtocol cp = c.getCommProtocol();
if (parseDrop(pkt, cp) != c.getDrop())
throw new ParsingException("DROP ADDRESS MISMATCH");
parseStatus(parseStat(pkt, cp));
}
use of us.mn.state.dot.tms.CommProtocol in project iris by mnit-rtmc.
the class CommConfigImpl method setProtocol.
/**
* Set the communication protocol
*/
@Override
public void setProtocol(short p) {
testGateArmDisable(name, "set protocol 0");
CommProtocol cp = CommProtocol.fromOrdinal(p);
if (cp != null) {
protocol = cp;
testGateArmDisable(name, "set protocol 1");
}
CommLinkImpl.recreatePollers(this);
}
use of us.mn.state.dot.tms.CommProtocol in project iris by mnit-rtmc.
the class MndotProperty method dropCat.
/**
* Make the initical drop/category byte.
* @param c Controller.
* @param cat Category code.
* @return Combined drop/category byte.
*/
private static byte dropCat(ControllerImpl c, CatCode cat) throws IOException {
int drop = c.getDrop();
CommProtocol cp = c.getCommProtocol();
if (cp == CommProtocol.MNDOT_5) {
if (drop < 1 || drop > 31)
throw new InvalidAddressException(drop);
return (byte) (drop << 3 | cat.ordinal());
} else {
if (drop < 1 || drop > 15)
throw new InvalidAddressException(drop);
return (byte) (drop << 4 | cat.ordinal());
}
}
Aggregations