use of com.neuronrobotics.sdk.common.IDeviceConnectionEventListener in project bowler-script-kernel by CommonWealthRobotics.
the class FileWatchDeviceWrapper method watch.
public static FileChangeWatcher watch(BowlerAbstractDevice device, File code, IFileChangeListener cadWatcher) {
try {
FileChangeWatcher watcher = FileChangeWatcher.watch(code);
watcher.addIFileChangeListener(cadWatcher);
device.addConnectionEventListener(new IDeviceConnectionEventListener() {
@Override
public void onDisconnect(BowlerAbstractDevice arg0) {
// TODO Auto-generated method stub
watcher.removeIFileChangeListener(cadWatcher);
}
@Override
public void onConnect(BowlerAbstractDevice arg0) {
// TODO Auto-generated method stub
}
});
return watcher;
} catch (IOException e) {
// TODO Auto-generated catch block
// BowlerStudioController.highlightException(code, e);
}
return null;
}
use of com.neuronrobotics.sdk.common.IDeviceConnectionEventListener in project bowler-script-kernel by CommonWealthRobotics.
the class MobileBaseCadManager method get.
public static MobileBaseCadManager get(MobileBase device) {
if (cadmap.get(device) == null) {
IMobileBaseUIlocal ui2 = new IMobileBaseUIlocal();
device.addConnectionEventListener(new IDeviceConnectionEventListener() {
@Override
public void onDisconnect(BowlerAbstractDevice source) {
// TODO Auto-generated method stub
ui2.list.clear();
}
@Override
public void onConnect(BowlerAbstractDevice source) {
// TODO Auto-generated method stub
}
});
return get(device, ui2);
}
return cadmap.get(device);
}
use of com.neuronrobotics.sdk.common.IDeviceConnectionEventListener in project java-bowler by NeuronRobotics.
the class Jfx3dManager method attachArm.
public void attachArm(final DHParameterKinematics model) {
master = model.getFactory().getDyio();
if (master != null)
new DigitalInputChannel(master, 23).addDigitalInputListener(new IDigitalInputListener() {
@Override
public void onDigitalValueChange(DigitalInputChannel source, final boolean isHigh) {
// System.err.println("Button pressed");
Platform.runLater(new Runnable() {
@Override
public void run() {
if (!isHigh) {
ObservableList<Node> cadBits = lookGroup.getChildren();
for (Node n : cadBits) {
double x = n.getTranslateX();
double y = n.getTranslateY();
double z = n.getTranslateZ();
// if (threedBoundCheck(x, y, z,/selsectedAffine, 10)) {
if (MeshView.class.isInstance(n)) {
System.out.println("Selecting Object");
selectedObject = (MeshView) n;
} else {
System.out.println("Not Touching " + n.getClass());
}
// }
}
if (selectedObject != null) {
System.out.println("Grabbing Object ");
selectedObject.getTransforms().clear();
selectedObject.getTransforms().addAll(robotBase, selsectedAffine);
}
} else {
// button released, look for devices
if (selectedObject != null) {
// freeze it in place
selectedObject.getTransforms().clear();
selectedObject.getTransforms().addAll(robotBase, selsectedAffine.clone());
selectedObject = null;
}
}
}
});
}
});
Platform.runLater(new Runnable() {
@Override
public void run() {
ArrayList<DHLink> links = model.getDhChain().getLinks();
for (DHLink dh : links) {
final Axis a = new Axis(15);
a.getChildren().add(new Sphere(5));
a.getTransforms().add(dh.getListener());
manipulator.getChildren().add(a);
if (master != null)
master.addConnectionEventListener(new IDeviceConnectionEventListener() {
@Override
public void onDisconnect(BowlerAbstractDevice source) {
// TODO Auto-generated method stub
manipulator.getChildren().remove(a);
a.getTransforms().clear();
}
@Override
public void onConnect(BowlerAbstractDevice source) {
// TODO Auto-generated method stub
}
});
}
// get the affine of the tip of the chain
selsectedAffine = links.get(links.size() - 1).getListener();
robotBase.setTx(100);
robotBase.setTy(100);
robotBase.setTz(-5);
manipulator.getTransforms().add(robotBase);
world.getChildren().addAll(manipulator);
}
});
}
use of com.neuronrobotics.sdk.common.IDeviceConnectionEventListener in project BowlerStudio by CommonWealthRobotics.
the class AbstractBowlerStudioTab method setDevice.
public void setDevice(BowlerAbstractDevice pm) {
myNames = new ArrayList<>();
if (getMyNameSpaces().length > 0) {
for (int i = 0; i < getMyNameSpaces().length; i++) {
myNames.add(getMyNameSpaces()[i]);
}
if (!isMyNamespace(pm.getNamespaces())) {
throw new RuntimeException("Device and namespaces are incompatible ");
}
}
setOnCloseRequest(this);
initializeUI(pm);
pm.addConnectionEventListener(new IDeviceConnectionEventListener() {
@Override
public void onDisconnect(BowlerAbstractDevice source) {
// if the device disconnects, close the tab
if (source == pm && source != null) {
requestClose();
if (MobileBase.class.isInstance(pm)) {
MobileBase dev = (MobileBase) pm;
try {
for (CSG p : MobileBaseCadManager.get(dev).getBasetoCadMap().get(dev)) BowlerStudioController.removeObject(p);
for (DHParameterKinematics leg : dev.getAllDHChains()) for (CSG p : MobileBaseCadManager.get(dev).getDHtoCadMap().get(leg)) BowlerStudioController.removeObject(p);
} catch (Throwable e) {
}
}
} else {
// Not a bug, expected to ensure one device disconnects the rest of the dependent devices
// System.err.println("Device type was "+source.getClass()+" named "+source.getScriptingName()+" expected "+pm.getClass()+" named "+pm.getScriptingName());
// new Exception().printStackTrace();
}
}
@Override
public void onConnect(BowlerAbstractDevice source) {
// TODO Auto-generated method stub
}
});
}
Aggregations