use of artisynth.core.probes.Probe in project artisynth_core by artisynth.
the class Workspace method oldScanProbes.
private static void oldScanProbes(ReaderTokenizer rtok, RootModel rootModel) throws IOException {
// myInputProbes.clear();
// myOutputProbes.clear()
rootModel.removeAllInputProbes();
rootModel.removeAllOutputProbes();
rootModel.removeAllWayPoints();
// myOutputProbes.add(myWayPoints); will be read from file
// boolean isInvalid = false;
rtok.scanToken('[');
while (rtok.nextToken() != ']') {
if (!rtok.tokenIsWord()) {
throw new IOException("Expecting type identifier for probe, got " + rtok);
}
Class probeClass = null;
if ((probeClass = ClassAliases.resolveClass(rtok.sval)) == null) {
throw new IOException("Unknown resolve probe class: " + rtok.sval);
}
Object probeObj = null;
if (probeClass == WayPointProbe.class) {
probeObj = rootModel.getWayPoints();
} else {
try {
probeObj = probeClass.newInstance();
} catch (Exception e) {
throw new IOException("Can't instantiate probe class " + probeClass.getName() + ", line " + rtok.lineno());
}
}
if (probeObj instanceof Probe) {
if (((Probe) probeObj).isInput()) {
Probe iprobe = (Probe) probeObj;
try {
ScanWriteUtils.scanfull(rtok, iprobe, rootModel);
rootModel.addInputProbe(iprobe);
} catch (IOException e) {
String errMsg = "scan probe failed, ";
if (rtok.getResourceName() != null) {
errMsg += "file=" + rtok.getResourceName() + ", ";
}
System.err.println(errMsg + e.getMessage());
}
} else {
Probe oprobe = (Probe) probeObj;
try {
ScanWriteUtils.scanfull(rtok, oprobe, rootModel);
if (!(oprobe instanceof WayPointProbe)) {
// waypoint probe is
// already added
rootModel.addOutputProbe(oprobe);
}
} catch (IOException e) {
String errMsg = "scan probe failed, ";
if (rtok.getResourceName() != null) {
errMsg += "file=" + rtok.getResourceName() + ", ";
}
System.err.println(errMsg + e.getMessage());
}
}
} else {
// throw new IOException("Probe object " + probeClass.getName()
// + " is not a probe, line " + rtok.lineno());
// isInvalid = true;
}
}
}
Aggregations