use of jmri.jmrix.rps.Reading in project JMRI by JMRI.
the class DebuggerFrame method getReadingFromTimeFields.
Reading getReadingFromTimeFields() {
double[] values = new double[NUMSENSORS + 1];
// parse input
for (int i = 0; i <= NUMSENSORS; i++) {
values[i] = 0.;
if ((timep.times[i] != null) && !timep.times[i].getText().equals("")) {
values[i] = Double.valueOf(timep.times[i].getText()).doubleValue();
}
}
// get the id number and make reading
Reading r = new Reading(id.getText(), values);
return r;
}
use of jmri.jmrix.rps.Reading 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.Reading in project JMRI by JMRI.
the class DebuggerFrame method doReadingFromTimeFields.
void doReadingFromTimeFields() {
// get the reading
Reading r = getReadingFromTimeFields();
// and forward
Distributor.instance().submitReading(r);
}
use of jmri.jmrix.rps.Reading in project JMRI by JMRI.
the class AlignmentPanel method load.
void load() {
try {
// request the filename from an open dialog
fci.rescanCurrentDirectory();
int retVal = fci.showOpenDialog(this);
// handle selection or cancel
if (retVal == JFileChooser.APPROVE_OPTION) {
File file = fci.getSelectedFile();
if (log.isInfoEnabled()) {
log.info("located file " + file + " for load");
}
// handle the file
PositionFile pf = new PositionFile();
pf.loadFile(file);
Point3d p;
Reading r;
for (int i = 0; i < NREADINGS; i++) {
p = pf.getCalibrationPosition(i);
if (p != null) {
lines[i].setPoint(p);
} else {
lines[i].setPoint(new Point3d(0.f, 0.f, 0.f));
}
}
for (int i = 0; i < NREADINGS; i++) {
r = pf.getCalibrationReading(i);
lines[i].reset();
if (r != null) {
lines[i].setReading(r);
}
}
} else {
log.info("load cancelled in open dialog");
}
} catch (Exception e) {
log.error("exception during load: " + e);
}
}
use of jmri.jmrix.rps.Reading in project JMRI by JMRI.
the class SerialAdapterTest method testStringParsing12.
@Test
public void testStringParsing12() throws java.io.IOException {
// String input = "DATA,TIME,1,2,3,4,5,6,7,8,9,10,11,12";
String input = "1,2,3,4,5,6,7,8,9,10,11,12";
new Engine() {
{
_instance = this;
setDefaultAlignment();
}
@Override
protected void setInitialAlignment() {
setDefaultAlignment();
}
};
SerialAdapter s = new SerialAdapter();
Reading r = s.makeReading(input);
Assert.assertEquals("n sample OK", 12, r.getNValues());
Assert.assertTrue("val 1", 0.001 > Math.abs(r.getValue(1) - 1.));
Assert.assertTrue("val 2", 0.001 > Math.abs(r.getValue(2) - 2.));
Assert.assertTrue("val 3", 0.001 > Math.abs(r.getValue(3) - 3.));
}
Aggregations