Search in sources :

Example 31 with Point3d

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);
    }
}
Also used : Point3d(javax.vecmath.Point3d)

Example 32 with Point3d

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);
}
Also used : Point3d(javax.vecmath.Point3d)

Example 33 with Point3d

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);
    }
}
Also used : Point3d(javax.vecmath.Point3d)

Aggregations

Point3d (javax.vecmath.Point3d)33 Test (org.junit.Test)16 Ignore (org.junit.Ignore)8 Reading (jmri.jmrix.rps.Reading)4 Receiver (jmri.jmrix.rps.Receiver)4 File (java.io.File)3 Measurement (jmri.jmrix.rps.Measurement)3 Engine (jmri.jmrix.rps.Engine)2 PositionFile (jmri.jmrix.rps.PositionFile)2 Region (jmri.jmrix.rps.Region)2 Element (org.jdom2.Element)2 BasicStroke (java.awt.BasicStroke)1 Graphics2D (java.awt.Graphics2D)1 Point (java.awt.Point)1 Shape (java.awt.Shape)1 Stroke (java.awt.Stroke)1 AffineTransform (java.awt.geom.AffineTransform)1 BoxLayout (javax.swing.BoxLayout)1 JmriJFrame (jmri.util.JmriJFrame)1