use of com.qualcomm.robotcore.robocol.Command in project robotcode by OutoftheBoxFTC.
the class ConfigureFromTemplateActivity method onStart.
@Override
protected void onStart() {
super.onStart();
this.robotConfigFileManager.updateActiveConfigHeader(this.currentCfgFile);
if (!remoteConfigure) {
configurationList = robotConfigFileManager.getXMLFiles();
templateList = robotConfigFileManager.getXMLTemplates();
warnIfNoTemplates();
} else {
// Ask the RC to send us (the DS) the list of extant configs and templates. Do the configurations
// first before the templates so that they'll arrive before the user has anything to click on.
networkConnectionHandler.sendCommand(new Command(CommandList.CMD_REQUEST_CONFIGURATIONS));
networkConnectionHandler.sendCommand(new Command(CommandList.CMD_REQUEST_CONFIGURATION_TEMPLATES));
}
populate();
}
use of com.qualcomm.robotcore.robocol.Command in project robotcode by OutoftheBoxFTC.
the class ConfigureFromTemplateActivity method getTemplateAndThen.
protected void getTemplateAndThen(final RobotConfigFile templateMeta, final TemplateProcessor processor) {
if (remoteConfigure) {
// Look in cache if we have it, otherwise ask for it from RC
String template = remoteTemplates.get(templateMeta.getName());
if (template != null) {
XmlPullParser xmlPullParser = xmlPullParserFromString(template);
processor.processTemplate(templateMeta, xmlPullParser);
} else {
synchronized (receivedConfigProcessors) {
receivedConfigProcessors.addLast(new StringProcessor() {
@Override
public void processString(String template) {
// Remember it in the cache for next time
remoteTemplates.put(templateMeta.getName(), template);
// Process it now
XmlPullParser xmlPullParser = xmlPullParserFromString(template);
processor.processTemplate(templateMeta, xmlPullParser);
}
});
networkConnectionHandler.sendCommand(new Command(CommandList.CMD_REQUEST_PARTICULAR_CONFIGURATION, templateMeta.toString()));
}
}
} else {
processor.processTemplate(templateMeta, templateMeta.getXml());
}
}
use of com.qualcomm.robotcore.robocol.Command in project robotcode by OutoftheBoxFTC.
the class FtcEventLoop method handleCommandDiscoverLynxModules.
protected void handleCommandDiscoverLynxModules(String extra) throws RobotCoreException, InterruptedException {
RobotLog.vv(FtcConfigurationActivity.TAG, "handling command DiscoverLynxModules");
final SerialNumber serialNumber = new SerialNumber(extra);
final USBScanManager usbScanManager = startUsbScanMangerIfNecessary();
// Start a scan and wait for it to complete, but if a scan is already in progress, then just wait for that one to finish
final ThreadPool.SingletonResult<LynxModuleMetaList> future = this.usbScanManager.startLynxModuleEnumerationIfNecessary(serialNumber);
// Actually carry out the scan in a worker thread so that we don't hold up the receive loop for
// full second or more that carrying out the discovery will take.
ThreadPool.getDefault().execute(new Runnable() {
@Override
public void run() {
try {
LynxModuleMetaList lynxModules = future.await();
if (lynxModules == null) {
lynxModules = new LynxModuleMetaList(serialNumber);
}
// Package up the raw module list and send that back to the DS
String data = usbScanManager.packageCommandResponse(lynxModules);
RobotLog.vv(FtcConfigurationActivity.TAG, "DiscoverLynxModules data='%s'", data);
networkConnectionHandler.sendCommand(new Command(CommandList.CMD_DISCOVER_LYNX_MODULES_RESP, data));
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
}
});
}
use of com.qualcomm.robotcore.robocol.Command in project robotcode by OutoftheBoxFTC.
the class FtcEventLoopBase method handleCommandRequestInspectionReport.
/**
* Return an inspection report of this (robot controller) device back to the caller
*/
protected void handleCommandRequestInspectionReport() {
InspectionState inspectionState = new InspectionState();
// Modified for OpenRC: Call new initializeForDs method (includes version of OpenRC)
inspectionState.initializeForDs();
String serialized = inspectionState.serialize();
networkConnectionHandler.sendCommand(new Command(CommandList.CMD_REQUEST_INSPECTION_REPORT_RESP, serialized));
}
use of com.qualcomm.robotcore.robocol.Command in project robotcode by OutoftheBoxFTC.
the class FtcEventLoopBase method sendUIState.
protected void sendUIState() {
RobotConfigFile configFile = robotCfgFileMgr.getActiveConfig();
String serialized = configFile.toString();
networkConnectionHandler.sendCommand(new Command(CommandList.CMD_NOTIFY_ACTIVE_CONFIGURATION, serialized));
// Send the user device type list
UserConfigurationTypeManager.getInstance().sendUserDeviceTypes();
// We might get a request in really soon, before we're fully together. Wait: the driver
// station doesn't retry if we were to ignore (might not need any more, as we send this
// state more frequently than we used to)
this.registeredOpModes.waitOpModesRegistered();
// Send the opmode list
String opModeList = SimpleGson.getInstance().toJson(registeredOpModes.getOpModes());
networkConnectionHandler.sendCommand(new Command(CommandList.CMD_NOTIFY_OP_MODE_LIST, opModeList));
// Subclasses might send other state too
}
Aggregations