use of com.neuronrobotics.sdk.commands.bcs.io.GetChannelModeCommand in project java-bowler by NeuronRobotics.
the class DyIOChannel method resync.
/**
* Live query the device for its mode and cache it.
*
* @param all - should all channels be refreshed.
*/
public void resync(boolean all) {
if (all) {
getDevice().resync();
return;
}
BowlerDatagram bd = getDevice().send(new GetChannelModeCommand(number));
// System.out.println(bd);
fireModeChangeEvent(DyIOChannelMode.get(bd.getData().getByte(1)));
throw new RuntimeException();
}
use of com.neuronrobotics.sdk.commands.bcs.io.GetChannelModeCommand in project java-bowler by NeuronRobotics.
the class DyIO method getAllChannelModes.
public ArrayList<DyIOChannelMode> getAllChannelModes() {
ArrayList<DyIOChannelMode> modes = new ArrayList<DyIOChannelMode>();
BowlerDatagram response;
ByteList bl;
if (isLegacyParser()) {
try {
response = send(new GetChannelModeCommand());
} catch (Exception e) {
if (getInternalChannels().size() == 0) {
Log.error("Initilization failed once, retrying");
try {
response = send(new GetChannelModeCommand());
} catch (Exception e2) {
e2.printStackTrace();
setMuteResyncOnModeChange(false);
throw new DyIOCommunicationException("DyIO failed to report during initialization. Could not determine DyIO configuration: " + e2.getMessage());
}
} else {
setMuteResyncOnModeChange(false);
return null;
}
}
if (response == null)
checkFirmwareRev();
// if(getAddress().equals(new MACAddress(MACAddress.BROADCAST))) {
setAddress(response.getAddress());
// }
@SuppressWarnings("unused") int count = 0;
if (getDyIOChannelCount() != null) {
count = getDyIOChannelCount();
}
bl = response.getData();
Log.error("Using old parsing model");
} else {
Object[] args = send("bcs.io.*;0.3;;", BowlerMethod.GET, "gacm", new Object[] {});
bl = (ByteList) args[0];
}
for (int i = 0; i < bl.size(); i++) {
DyIOChannelMode cm = DyIOChannelMode.get(bl.getByte(i));
modes.add(cm);
}
return modes;
}
Aggregations