Search in sources :

Example 1 with ControllerConfiguration

use of com.qualcomm.robotcore.hardware.configuration.ControllerConfiguration 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 ControllerConfiguration

use of com.qualcomm.robotcore.hardware.configuration.ControllerConfiguration in project robotcode by OutoftheBoxFTC.

the class DeviceInfoAdapter method getView.

@Override
public View getView(int pos, View convertView, ViewGroup parent) {
    View row = convertView;
    if (row == null) {
        LayoutInflater inflater = editActivity.getLayoutInflater();
        row = inflater.inflate(list_id, parent, false);
    }
    ControllerConfiguration controllerConfiguration = deviceControllers.get(pos);
    String serialNum = editActivity.formatSerialNumber(editActivity, controllerConfiguration);
    TextView displayNum = (TextView) row.findViewById(android.R.id.text2);
    displayNum.setText(serialNum);
    String name = deviceControllers.get(pos).getName();
    TextView text = (TextView) row.findViewById(android.R.id.text1);
    text.setText(name);
    return row;
}
Also used : LayoutInflater(android.view.LayoutInflater) ControllerConfiguration(com.qualcomm.robotcore.hardware.configuration.ControllerConfiguration) TextView(android.widget.TextView) TextView(android.widget.TextView) View(android.view.View)

Example 3 with ControllerConfiguration

use of com.qualcomm.robotcore.hardware.configuration.ControllerConfiguration in project robotcode by OutoftheBoxFTC.

the class EditUSBDeviceActivity method completeSwapConfiguration.

protected boolean completeSwapConfiguration(int requestCodeValue, int resultCode, Intent data) {
    if (resultCode == RESULT_OK) {
        RequestCode requestCode = RequestCode.fromValue(requestCodeValue);
        if (requestCode == EditSwapUsbDevices.requestCode) {
            // Find out whom the user picked to swap with. Be careful about object identities
            EditParameters returnedParameters = EditParameters.fromIntent(this, data);
            SerialNumber swappeeSerialNumber = ((ControllerConfiguration) returnedParameters.getConfiguration()).getSerialNumber();
            ControllerConfiguration swappee = getRobotConfigMap().get(swappeeSerialNumber);
            if (swappee != null) {
                // He swapped with something already in the configuration
                robotConfigMap.swapSerialNumbers(controllerConfiguration, swappee);
            } else {
                // He must have swapped with an extra device
                robotConfigMap.setSerialNumber(controllerConfiguration, swappeeSerialNumber);
                controllerConfiguration.setKnownToBeAttached(true);
            }
            // Adjust 'extraDevices' to accommodate the swap
            determineExtraUSBDevices();
            // Update the UI
            refreshAfterSwap();
            return true;
        }
    }
    return false;
}
Also used : SerialNumber(com.qualcomm.robotcore.util.SerialNumber) ControllerConfiguration(com.qualcomm.robotcore.hardware.configuration.ControllerConfiguration)

Example 4 with ControllerConfiguration

use of com.qualcomm.robotcore.hardware.configuration.ControllerConfiguration in project robotcode by OutoftheBoxFTC.

the class EditUSBDeviceActivity method isSwappable.

protected boolean isSwappable() {
    List<ControllerConfiguration> swapCandidates = getRobotConfigMap().getEligibleSwapTargets(controllerConfiguration, scannedDevices, this);
    SerialNumber fixCandidate = getFixableCandidate();
    // We need swap candidates, but not just the one that we'd automatically 'fix' to
    return !swapCandidates.isEmpty() && (fixCandidate == null || !(swapCandidates.size() == 1 && swapCandidates.get(0).getSerialNumber().equals(fixCandidate)));
}
Also used : SerialNumber(com.qualcomm.robotcore.util.SerialNumber) ControllerConfiguration(com.qualcomm.robotcore.hardware.configuration.ControllerConfiguration)

Example 5 with ControllerConfiguration

use of com.qualcomm.robotcore.hardware.configuration.ControllerConfiguration in project robotcode by OutoftheBoxFTC.

the class FtcConfigurationActivity method handleCommandRequestParticularConfigurationResp.

protected CallbackResult handleCommandRequestParticularConfigurationResp(String extra) throws RobotCoreException {
    ReadXMLFileHandler readXMLFileHandler = new ReadXMLFileHandler();
    List<ControllerConfiguration> controllerList = readXMLFileHandler.parse(new StringReader(extra));
    buildControllersFromXMLResults(controllerList);
    populateListAndWarnDevices();
    return CallbackResult.HANDLED;
}
Also used : ReadXMLFileHandler(com.qualcomm.robotcore.hardware.configuration.ReadXMLFileHandler) StringReader(java.io.StringReader) LegacyModuleControllerConfiguration(com.qualcomm.robotcore.hardware.configuration.LegacyModuleControllerConfiguration) ControllerConfiguration(com.qualcomm.robotcore.hardware.configuration.ControllerConfiguration) ServoControllerConfiguration(com.qualcomm.robotcore.hardware.configuration.ServoControllerConfiguration) MotorControllerConfiguration(com.qualcomm.robotcore.hardware.configuration.MotorControllerConfiguration)

Aggregations

ControllerConfiguration (com.qualcomm.robotcore.hardware.configuration.ControllerConfiguration)15 MotorControllerConfiguration (com.qualcomm.robotcore.hardware.configuration.MotorControllerConfiguration)7 ServoControllerConfiguration (com.qualcomm.robotcore.hardware.configuration.ServoControllerConfiguration)7 SerialNumber (com.qualcomm.robotcore.util.SerialNumber)6 BuiltInConfigurationType (com.qualcomm.robotcore.hardware.configuration.BuiltInConfigurationType)5 ConfigurationType (com.qualcomm.robotcore.hardware.configuration.ConfigurationType)5 LegacyModuleControllerConfiguration (com.qualcomm.robotcore.hardware.configuration.LegacyModuleControllerConfiguration)5 ReadXMLFileHandler (com.qualcomm.robotcore.hardware.configuration.ReadXMLFileHandler)5 View (android.view.View)3 TextView (android.widget.TextView)3 RobotCoreException (com.qualcomm.robotcore.exception.RobotCoreException)3 MatrixControllerConfiguration (com.qualcomm.robotcore.hardware.configuration.MatrixControllerConfiguration)3 ArrayList (java.util.ArrayList)3 Map (java.util.Map)3 AdapterView (android.widget.AdapterView)2 ListView (android.widget.ListView)2 DeviceConfiguration (com.qualcomm.robotcore.hardware.configuration.DeviceConfiguration)2 MotorConfiguration (com.qualcomm.robotcore.hardware.configuration.MotorConfiguration)2 HashMap (java.util.HashMap)2 LinkedList (java.util.LinkedList)2