Search in sources :

Example 1 with RobotConfigFile

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();
    }
}
Also used : ReadXMLFileHandler(com.qualcomm.robotcore.hardware.configuration.ReadXMLFileHandler) RobotConfigFile(com.qualcomm.ftccommon.configuration.RobotConfigFile) Command(com.qualcomm.robotcore.robocol.Command) ArrayList(java.util.ArrayList) RobotCoreException(com.qualcomm.robotcore.exception.RobotCoreException) ControllerConfiguration(com.qualcomm.robotcore.hardware.configuration.ControllerConfiguration) WriteXMLFileHandler(com.qualcomm.robotcore.hardware.configuration.WriteXMLFileHandler)

Example 2 with RobotConfigFile

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();
    }
}
Also used : RobotConfigFile(com.qualcomm.ftccommon.configuration.RobotConfigFile) RobotCoreException(com.qualcomm.robotcore.exception.RobotCoreException) IOException(java.io.IOException)

Example 3 with RobotConfigFile

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));
}
Also used : RobotConfigFile(com.qualcomm.ftccommon.configuration.RobotConfigFile) Command(com.qualcomm.robotcore.robocol.Command)

Example 4 with RobotConfigFile

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));
}
Also used : RobotConfigFile(com.qualcomm.ftccommon.configuration.RobotConfigFile) Command(com.qualcomm.robotcore.robocol.Command)

Example 5 with RobotConfigFile

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();
}
Also used : HardwareFactory(com.qualcomm.hardware.HardwareFactory) FtcEventLoop(com.qualcomm.ftccommon.FtcEventLoop) RobotConfigFile(com.qualcomm.ftccommon.configuration.RobotConfigFile) OpModeRegister(com.qualcomm.robotcore.eventloop.opmode.OpModeRegister) Resources(android.content.res.Resources) FtcEventLoopIdle(com.qualcomm.ftccommon.FtcEventLoopIdle)

Aggregations

RobotConfigFile (com.qualcomm.ftccommon.configuration.RobotConfigFile)13 Command (com.qualcomm.robotcore.robocol.Command)4 Resources (android.content.res.Resources)3 UsbDevice (android.hardware.usb.UsbDevice)3 WifiManager (android.net.wifi.WifiManager)3 View (android.view.View)3 WebView (android.webkit.WebView)3 TextView (android.widget.TextView)3 ProgrammingModeControllerImpl (com.google.blocks.ftcrobotcontroller.ProgrammingModeControllerImpl)3 ProgrammingWebHandlers (com.google.blocks.ftcrobotcontroller.ProgrammingWebHandlers)3 FtcEventLoop (com.qualcomm.ftccommon.FtcEventLoop)3 FtcEventLoopIdle (com.qualcomm.ftccommon.FtcEventLoopIdle)3 RobotConfigFileManager (com.qualcomm.ftccommon.configuration.RobotConfigFileManager)3 HardwareFactory (com.qualcomm.hardware.HardwareFactory)3 OpModeRegister (com.qualcomm.robotcore.eventloop.opmode.OpModeRegister)3 Utility (com.qualcomm.robotcore.hardware.configuration.Utility)3 Dimmer (com.qualcomm.robotcore.util.Dimmer)3 ImmersiveMode (com.qualcomm.robotcore.util.ImmersiveMode)3 PreferencesHelper (org.firstinspires.ftc.robotcore.internal.system.PreferencesHelper)3 RobotCoreException (com.qualcomm.robotcore.exception.RobotCoreException)2