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();
}
}
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;
}
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;
}
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)));
}
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;
}
Aggregations