use of com.qualcomm.ftccommon.configuration.RobotConfigFile in project robotcode by OutoftheBoxFTC.
the class FtcEventLoopBase method handleCommandRequestParticularConfiguration.
/*
* The driver station wants the contents of the configuration file.
*/
protected void handleCommandRequestParticularConfiguration(String data) {
RobotConfigFile file = robotCfgFileMgr.getConfigFromString(data);
ReadXMLFileHandler parser = new ReadXMLFileHandler();
if (file.isNoConfig()) {
// don't try to parse if there's no file
return;
}
try {
WriteXMLFileHandler writeXMLFileHandler = new WriteXMLFileHandler(activityContext);
ArrayList<ControllerConfiguration> deviceList = (ArrayList<ControllerConfiguration>) parser.parse(file.getXml());
String xmlData = writeXMLFileHandler.toXml(deviceList);
RobotLog.vv(FtcConfigurationActivity.TAG, "FtcEventLoop: handleCommandRequestParticularConfigFile, data: " + xmlData);
networkConnectionHandler.sendCommand(new Command(CommandList.CMD_REQUEST_PARTICULAR_CONFIGURATION_RESP, xmlData));
} catch (RobotCoreException e) {
e.printStackTrace();
}
}
use of com.qualcomm.ftccommon.configuration.RobotConfigFile in project robotcode by OutoftheBoxFTC.
the class FtcEventLoopBase method handleCommandSaveConfiguration.
protected void handleCommandSaveConfiguration(String fileInfo) {
String[] fileInfoArray = fileInfo.split(RobotConfigFileManager.FILE_LIST_COMMAND_DELIMITER);
try {
RobotConfigFile cfgFile = robotCfgFileMgr.getConfigFromString(fileInfoArray[0]);
robotCfgFileMgr.writeToFile(cfgFile, false, fileInfoArray[1]);
robotCfgFileMgr.setActiveConfigAndUpdateUI(false, cfgFile);
} catch (RobotCoreException | IOException e) {
e.printStackTrace();
}
}
use of com.qualcomm.ftccommon.configuration.RobotConfigFile in project robotcode by OutoftheBoxFTC.
the class FtcEventLoopBase method handleCommandRequestConfigurations.
/**
* Serialize the entire list of config file metadata and send to the driver station
*/
protected void handleCommandRequestConfigurations() {
ArrayList<RobotConfigFile> fileList = robotCfgFileMgr.getXMLFiles();
String objsSerialized = RobotConfigFileManager.serializeXMLConfigList(fileList);
networkConnectionHandler.sendCommand(new Command(CommandList.CMD_REQUEST_CONFIGURATIONS_RESP, objsSerialized));
}
use of com.qualcomm.ftccommon.configuration.RobotConfigFile in project robotcode by OutoftheBoxFTC.
the class FtcEventLoopBase method handleCommandRequestConfigurationTemplates.
/**
* Serialize the entire list of config file metadata and send to the driver station
*/
protected void handleCommandRequestConfigurationTemplates() {
ArrayList<RobotConfigFile> fileList = robotCfgFileMgr.getXMLTemplates();
String objsSerialized = RobotConfigFileManager.serializeXMLConfigList(fileList);
networkConnectionHandler.sendCommand(new Command(CommandList.CMD_REQUEST_CONFIGURATION_TEMPLATES_RESP, objsSerialized));
}
use of com.qualcomm.ftccommon.configuration.RobotConfigFile in project robotcode by OutoftheBoxFTC.
the class FtcRobotControllerActivity method requestRobotSetup.
private void requestRobotSetup() {
if (controllerService == null) {
return;
}
HardwareFactory factory;
RobotConfigFile file = cfgFileMgr.getActiveConfigAndUpdateUI();
HardwareFactory hardwareFactory = new HardwareFactory(context);
try {
hardwareFactory.setXmlPullParser(file.getXml());
} catch (Resources.NotFoundException e) {
file = RobotConfigFile.noConfig(cfgFileMgr);
hardwareFactory.setXmlPullParser(file.getXml());
cfgFileMgr.setActiveConfigAndUpdateUI(false, file);
}
factory = hardwareFactory;
OpModeRegister userOpModeRegister = createOpModeRegister();
eventLoop = new FtcEventLoop(factory, userOpModeRegister, callback, this, programmingModeController);
FtcEventLoopIdle idleLoop = new FtcEventLoopIdle(factory, userOpModeRegister, callback, this, programmingModeController);
controllerService.setCallback(callback);
controllerService.setupRobot(eventLoop, idleLoop);
passReceivedUsbAttachmentsToEventLoop();
}
Aggregations