use of jmri.jmrix.rps.Measurement in project JMRI by JMRI.
the class DebuggerFrame method doMeasurementFromPositionFields.
void doMeasurementFromPositionFields() {
// contain dummy Reading
Reading r = new Reading(id.getText(), new double[] { 0., 0., 0., 0. });
Measurement m = new Measurement(r, Double.valueOf(x.getText()).doubleValue(), Double.valueOf(y.getText()).doubleValue(), Double.valueOf(z.getText()).doubleValue(), Engine.instance().getVSound(), 0, "Position Data");
lastPoint = m;
Distributor.instance().submitMeasurement(m);
}
use of jmri.jmrix.rps.Measurement in project JMRI by JMRI.
the class RpsTrackingPanel method getToolTipText.
/**
* Provide tool tip text that depends on what's under the cursor.
* <p>
* Names either a measurement point or a region.
*
* @return null if no object under mouse; this suppresses ToolTip
*/
@Override
public String getToolTipText(MouseEvent e) {
// get mouse coordinates
try {
Point mouse = e.getPoint();
Point2D userPt = currentAT.inverseTransform(new Point2D.Double(mouse.x, mouse.y), null);
// find the path object containing it, if any
for (int i = measurementRepList.size() - 1; i >= 0; i--) {
MeasurementRep r = measurementRepList.get(i);
if (r.contains(userPt)) {
Measurement m = r.measurement;
return "ID " + m.getID() + " at " + m.getX() + "," + m.getY();
}
}
// find the region containing it, if any
// Go through backwards to find the top if overlaps
List<Region> l = Model.instance().getRegions();
for (int i = l.size() - 1; i >= 0; i--) {
Shape s = l.get(i).getPath();
if (s.contains(userPt)) {
return "Region: " + l.get(i).toString() + ", at " + userPt.getX() + "," + userPt.getY();
}
}
// found nothing, just display location
return "" + userPt.getX() + "," + userPt.getY();
} catch (Exception ex) {
}
// or return default
return null;
}
use of jmri.jmrix.rps.Measurement in project JMRI by JMRI.
the class PollDataModel method getValueAt.
@Override
public Object getValueAt(int r, int c) {
// r is row number, from 0
Measurement m;
if (Engine.instance() == null) {
log.warn("returning null because of missing Engine.instance()");
}
if (Engine.instance().getTransmitter(r) == null) {
log.warn("returning null because of missing Engine.instance().getTransmitter(" + r + ")");
}
double val;
switch(c) {
case NAMECOL:
return Engine.instance().getTransmitter(r).getRosterName();
case IDCOL:
return Engine.instance().getTransmitter(r).getID();
case ADDRCOL:
return Integer.valueOf(Engine.instance().getTransmitter(r).getAddress());
case LONGCOL:
return Boolean.valueOf(Engine.instance().getTransmitter(r).isLongAddress());
case POLLCOL:
return Boolean.valueOf(Engine.instance().getTransmitter(r).isPolled());
case TYPECOL:
JComboBox<String> b = new JComboBox<String>(new String[] { "F2", "F3", "BSCI" });
return b;
case LASTXCOL:
m = Engine.instance().getTransmitter(r).getLastMeasurement();
if (m == null) {
return null;
}
val = m.getX();
return new Double(val);
case LASTYCOL:
m = Engine.instance().getTransmitter(r).getLastMeasurement();
if (m == null) {
return null;
}
val = m.getY();
return new Double(val);
case LASTZCOL:
m = Engine.instance().getTransmitter(r).getLastMeasurement();
if (m == null) {
return null;
}
val = m.getZ();
return new Double(val);
case LASTTIME:
m = Engine.instance().getTransmitter(r).getLastMeasurement();
if (m == null) {
return null;
}
int time = m.getReading().getTime();
return Integer.valueOf(time);
default:
return null;
}
}
use of jmri.jmrix.rps.Measurement in project JMRI by JMRI.
the class RpsTrackingFrameTest method testShow.
@Test
public void testShow() {
Assume.assumeFalse(GraphicsEnvironment.isHeadless());
new Engine() {
void reset() {
_instance = null;
}
}.reset();
Engine.instance().setMaxReceiverNumber(2);
Engine.instance().setReceiver(1, new Receiver(new Point3d(12., 12., 0.)));
Engine.instance().setReceiver(2, new Receiver(new Point3d(12., 12., 0.)));
RpsTrackingFrame f = new RpsTrackingFrame("Test RPS Tracking");
f.initComponents();
f.setVisible(true);
// use local access
RpsTrackingPanel p = f.panel;
Reading loco = new Reading("21", null);
Measurement m = new Measurement(loco, 0.0, 0.0, 0.0, 0.133, 5, "source");
p.notify(m);
loco = new Reading("21", null);
m = new Measurement(loco, 5., 5., 0.0, 0.133, 5, "source");
p.notify(m);
loco = new Reading("21", null);
m = new Measurement(loco, 0., 5., 0.0, 0.133, 5, "source");
p.notify(m);
loco = new Reading("21", null);
m = new Measurement(loco, 5., 0., 0.0, 0.133, 5, "source");
p.notify(m);
Assert.assertNotNull("found frame", f);
f.dispose();
}
Aggregations