use of com.qualcomm.robotcore.hardware.RobotConfigNameable in project robotcode by OutoftheBoxFTC.
the class LynxModule method getHealthStatusWarningMessage.
/**
* Returns a status warning message indicative of the health of the indicated device, or an
* empty string if no such message is currently applicable.
*/
@NonNull
public static String getHealthStatusWarningMessage(HardwareDeviceHealth hardwareDeviceHealth) {
switch(hardwareDeviceHealth.getHealthStatus()) {
case UNHEALTHY:
String name = null;
if (hardwareDeviceHealth instanceof RobotConfigNameable) {
name = ((RobotConfigNameable) hardwareDeviceHealth).getUserConfiguredName();
if (name != null) {
name = AppUtil.getDefContext().getString(R.string.quotes, name);
}
}
if (name == null && hardwareDeviceHealth instanceof HardwareDevice) {
HardwareDevice hardwareDevice = (HardwareDevice) hardwareDeviceHealth;
String typeDescription = hardwareDevice.getDeviceName();
String connectionInfo = hardwareDevice.getConnectionInfo();
name = AppUtil.getDefContext().getString(R.string.hwDeviceDescriptionAndConnection, typeDescription, connectionInfo);
}
if (name == null) {
name = AppUtil.getDefContext().getString(R.string.hwPoorlyNamedDevice);
}
return AppUtil.getDefContext().getString(R.string.unhealthyDevice, name);
default:
return "";
}
}
Aggregations