use of com.qualcomm.robotcore.hardware.configuration.ConfigurationType in project robotcode by OutoftheBoxFTC.
the class HardwareFactory method buildI2cDevices.
private void buildI2cDevices(List<DeviceConfiguration> list, HardwareMap map, DeviceManager deviceMgr, I2cController i2cController) {
for (DeviceConfiguration deviceConfiguration : list) {
ConfigurationType devType = deviceConfiguration.getConfigurationType();
if (devType == BuiltInConfigurationType.I2C_DEVICE) {
mapI2cDevice(map, deviceMgr, i2cController, deviceConfiguration);
continue;
}
if (devType == BuiltInConfigurationType.I2C_DEVICE_SYNCH) {
mapI2cDeviceSynch(map, deviceMgr, i2cController, deviceConfiguration);
continue;
}
if (devType == BuiltInConfigurationType.IR_SEEKER_V3) {
mapIrSeekerV3Device(map, deviceMgr, i2cController, deviceConfiguration);
continue;
}
if (devType == BuiltInConfigurationType.ADAFRUIT_COLOR_SENSOR) {
mapAdafruitColorSensor(map, deviceMgr, i2cController, deviceConfiguration);
continue;
}
if (devType == BuiltInConfigurationType.COLOR_SENSOR) {
mapModernRoboticsColorSensor(map, deviceMgr, i2cController, deviceConfiguration);
continue;
}
if (devType == BuiltInConfigurationType.GYRO) {
mapModernRoboticsGyro(map, deviceMgr, i2cController, deviceConfiguration);
continue;
}
if (devType == BuiltInConfigurationType.NOTHING) {
// nothing to do
continue;
}
if (devType.isDeviceFlavor(UserConfigurationType.Flavor.I2C)) {
if (devType instanceof UserI2cSensorType) {
mapUserI2cDevice(map, deviceMgr, i2cController, deviceConfiguration);
continue;
}
}
RobotLog.w("Unexpected device type connected to I2c Controller while parsing XML: " + devType.toString());
}
}
use of com.qualcomm.robotcore.hardware.configuration.ConfigurationType in project robotcode by OutoftheBoxFTC.
the class EditMotorListActivity method localizeSpinner.
@Override
protected void localizeSpinner(View itemView) {
Spinner spinner = (Spinner) itemView.findViewById(this.idItemSpinner);
Comparator<ConfigurationType> comparator = new Comparator<ConfigurationType>() {
@Override
public int compare(ConfigurationType lhs, ConfigurationType rhs) {
// Make sure 'nothing' is first, and 'unspecified' is second
if (lhs == rhs) {
return 0;
}
if (lhs == BuiltInConfigurationType.NOTHING) {
return -1;
}
if (rhs == BuiltInConfigurationType.NOTHING) {
return 1;
}
if (lhs == unspecifiedMotorType) {
return -1;
}
if (rhs == unspecifiedMotorType) {
return 1;
}
// they'll be distinguished using an outer level comparator
return 0;
}
};
localizeConfigTypeSpinnerTypes(ConfigurationType.DisplayNameFlavor.Normal, spinner, Arrays.asList(this.configurationTypes), comparator);
}
use of com.qualcomm.robotcore.hardware.configuration.ConfigurationType in project robotcode by OutoftheBoxFTC.
the class HardwareFactory method mapUsbLegacyModule.
private void mapUsbLegacyModule(HardwareMap map, DeviceManager deviceMgr, LegacyModuleControllerConfiguration ctrlConf) throws RobotCoreException, InterruptedException {
if (!ctrlConf.isEnabled()) {
return;
}
LegacyModule legacyModule = deviceMgr.createUsbLegacyModule(ctrlConf.getSerialNumber(), ctrlConf.getName());
map.legacyModule.put(ctrlConf.getName(), legacyModule);
for (DeviceConfiguration devConf : ctrlConf.getDevices()) {
ConfigurationType devType = devConf.getConfigurationType();
if (devType == BuiltInConfigurationType.GYRO) {
mapNxtGyroSensor(map, deviceMgr, legacyModule, devConf);
} else if (devType == BuiltInConfigurationType.COMPASS) {
mapNxtCompassSensor(map, deviceMgr, legacyModule, devConf);
} else if (devType == BuiltInConfigurationType.IR_SEEKER) {
mapNxtIrSeekerSensor(map, deviceMgr, legacyModule, devConf);
} else if (devType == BuiltInConfigurationType.LIGHT_SENSOR) {
mapNxtLightSensor(map, deviceMgr, legacyModule, devConf);
} else if (devType == BuiltInConfigurationType.ACCELEROMETER) {
mapNxtAccelerationSensor(map, deviceMgr, legacyModule, devConf);
} else if (devType == BuiltInConfigurationType.MOTOR_CONTROLLER) {
mapNxtDcMotorController(map, deviceMgr, legacyModule, devConf);
} else if (devType == BuiltInConfigurationType.SERVO_CONTROLLER) {
mapNxtServoController(map, deviceMgr, legacyModule, devConf);
} else if (devType == BuiltInConfigurationType.TOUCH_SENSOR) {
mapNxtTouchSensor(map, deviceMgr, legacyModule, devConf);
} else if (devType == BuiltInConfigurationType.TOUCH_SENSOR_MULTIPLEXER) {
mapNxtTouchSensorMultiplexer(map, deviceMgr, legacyModule, devConf);
} else if (devType == BuiltInConfigurationType.ULTRASONIC_SENSOR) {
mapSonarSensor(map, deviceMgr, legacyModule, devConf);
} else if (devType == BuiltInConfigurationType.COLOR_SENSOR) {
mapNxtColorSensor(map, deviceMgr, legacyModule, devConf);
} else if (devType == BuiltInConfigurationType.MATRIX_CONTROLLER) {
mapMatrixController(map, deviceMgr, legacyModule, devConf);
} else if (devType == BuiltInConfigurationType.NOTHING) {
// nothing to do
} else {
RobotLog.w("Unexpected device type connected to Legacy Module while parsing XML: " + devType.toString());
}
}
}
use of com.qualcomm.robotcore.hardware.configuration.ConfigurationType in project robotcode by OutoftheBoxFTC.
the class FtcConfigurationActivity method populateList.
/**
* Populates the list with the relevant controllers from the deviceControllers variable.
* That variable is either from scanned devices, or read in from an xml file.
*/
private void populateList() {
ListView controllerListView = (ListView) findViewById(R.id.controllersList);
// Before we launch, we want the scan to have completed
try {
scannedDevices = usbScanManager.awaitScannedDevices();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
// Make sure we'll report serial numbers correctly as attached or not
tellControllersAboutAttachment();
DeviceInfoAdapter adapter = new DeviceInfoAdapter(this, android.R.layout.simple_list_item_2, new LinkedList<ControllerConfiguration>(getRobotConfigMap().controllerConfigurations()));
controllerListView.setAdapter(adapter);
controllerListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View v, int pos, long arg3) {
ControllerConfiguration controllerConfiguration = (ControllerConfiguration) adapterView.getItemAtPosition(pos);
ConfigurationType itemType = controllerConfiguration.getConfigurationType();
if (itemType == BuiltInConfigurationType.MOTOR_CONTROLLER) {
EditParameters parameters = initParameters(ModernRoboticsConstants.INITIAL_MOTOR_PORT, MotorConfiguration.class, controllerConfiguration, ((MotorControllerConfiguration) controllerConfiguration).getMotors());
parameters.setConfigurationTypes(MotorConfiguration.getAllMotorConfigurationTypes());
handleLaunchEdit(EditMotorControllerActivity.requestCode, EditMotorControllerActivity.class, parameters);
} else if (itemType == BuiltInConfigurationType.SERVO_CONTROLLER) {
EditParameters parameters = initParameters(ModernRoboticsConstants.INITIAL_SERVO_PORT, ServoConfiguration.class, controllerConfiguration, ((ServoControllerConfiguration) controllerConfiguration).getServos());
handleLaunchEdit(EditServoControllerActivity.requestCode, EditServoControllerActivity.class, parameters);
} else if (itemType == BuiltInConfigurationType.LEGACY_MODULE_CONTROLLER) {
EditParameters parameters = initParameters(0, DeviceConfiguration.class, controllerConfiguration, ((LegacyModuleControllerConfiguration) controllerConfiguration).getDevices());
handleLaunchEdit(EditLegacyModuleControllerActivity.requestCode, EditLegacyModuleControllerActivity.class, parameters);
} else if (itemType == BuiltInConfigurationType.DEVICE_INTERFACE_MODULE) {
EditParameters parameters = initParameters(0, DeviceConfiguration.class, controllerConfiguration, ((DeviceInterfaceModuleConfiguration) controllerConfiguration).getDevices());
handleLaunchEdit(EditDeviceInterfaceModuleActivity.requestCode, EditDeviceInterfaceModuleActivity.class, parameters);
} else if (itemType == BuiltInConfigurationType.LYNX_USB_DEVICE) {
EditParameters parameters = initParameters(0, LynxModuleConfiguration.class, controllerConfiguration, ((LynxUsbDeviceConfiguration) controllerConfiguration).getDevices());
handleLaunchEdit(EditLynxUsbDeviceActivity.requestCode, EditLynxUsbDeviceActivity.class, parameters);
}
}
});
}
use of com.qualcomm.robotcore.hardware.configuration.ConfigurationType in project robotcode by OutoftheBoxFTC.
the class EditI2cDevicesActivityAbstract method localizeSpinner.
@Override
protected void localizeSpinner(View itemView) {
Spinner spinner = (Spinner) itemView.findViewById(this.idItemSpinner);
Comparator<ConfigurationType> comparator = new Comparator<ConfigurationType>() {
@Override
public int compare(ConfigurationType lhs, ConfigurationType rhs) {
// Make sure 'nothing' is first
if (lhs == rhs) {
return 0;
}
if (lhs == BuiltInConfigurationType.NOTHING) {
return -1;
}
if (rhs == BuiltInConfigurationType.NOTHING) {
return 1;
}
// they'll be distinguished using an outer level comparator
return 0;
}
};
localizeConfigTypeSpinnerTypes(ConfigurationType.DisplayNameFlavor.Normal, spinner, Arrays.asList(this.configurationTypes), comparator);
}
Aggregations