use of javax.vecmath.Point3d in project JMRI by JMRI.
the class Engine method loadAlignment.
public void loadAlignment(File file) throws org.jdom2.JDOMException, IOException {
// start by getting the file
PositionFile pf = new PositionFile();
pf.loadFile(file);
// get VSound
setVSound(pf.getVSound());
// get offset
setOffset(pf.getOffset());
// get algorithm
setAlgorithm(pf.getAlgorithm());
// get receivers
// count from 1
setMaxReceiverNumber(pf.maxReceiver());
Point3d p;
boolean a;
int min;
int max;
for (int i = 1; i <= getMaxReceiverNumber(); i++) {
p = pf.getReceiverPosition(i);
if (p == null) {
continue;
}
a = pf.getReceiverActive(i);
min = pf.getReceiverMin(i);
max = pf.getReceiverMax(i);
log.debug("load " + i + " with " + p);
Receiver r = new Receiver(p);
r.setActive(a);
r.setMinTime(min);
r.setMaxTime(max);
setReceiver(i, r);
}
}
use of javax.vecmath.Point3d in project JMRI by JMRI.
the class Engine method notify.
@Override
public void notify(Reading r) {
// This implementation creates a new Calculator
// each time to ensure that the most recent
// receiver positions are used; this should be
// replaced with some notification system
// to reduce the work done.
// ok to send next poll
log.debug("po false " + r.getID());
pollOutstanding = false;
// make a list of receiver positions to provide
// to the new Calculator. Missing/unconfigured receivers
// are null.
Point3d[] list = new Point3d[receivers.length];
for (int i = 0; i < receivers.length; i++) {
if (receivers[i] == null) {
list[i] = null;
// skip receivers not present
continue;
}
Point3d p = getReceiverPosition(i);
if (p != null) {
// recievers numbered from 1
receivers[i].setLastTime((int) r.getValue(i));
log.debug(" " + i + "th value min " + receivers[i].getMinTime() + " < time " + r.getValue(i) + " < max " + receivers[i].getMaxTime() + " at " + p);
if (receivers[i].isActive() && (receivers[i].getMinTime() <= r.getValue(i)) && (r.getValue(i) <= receivers[i].getMaxTime())) {
list[i] = p;
} else {
list[i] = null;
}
} else {
list[i] = null;
log.error("Unexpected null position from receiver " + i);
}
}
Calculator c = Algorithms.newCalculator(list, getVSound(), getOffset(), getAlgorithm());
Measurement m = c.convert(r, lastPoint);
saveLastMeasurement(r.getID(), m);
lastPoint = m;
Distributor.instance().submitMeasurement(m);
}
use of javax.vecmath.Point3d in project JMRI by JMRI.
the class RpsReporter method notify.
@Override
public void notify(Measurement r) {
Point3d p = new Point3d(r.getX(), r.getY(), r.getZ());
Integer id = Integer.valueOf(r.getReading().getID());
// ignore if code not OK
if (!r.isOkPoint()) {
return;
}
// ignore if not in Z fiducial volume
if (r.getZ() > 20 || r.getZ() < -20) {
return;
}
if (log.isDebugEnabled()) {
log.debug("starting " + getSystemName());
}
if (region.isInside(p)) {
notifyInRegion(id);
} else {
notifyOutOfRegion(id);
}
}
Aggregations