use of com.qualcomm.ftccommon.configuration.RobotConfigFile in project robotcode by OutoftheBoxFTC.
the class FtcEventLoopBase method sendUIState.
protected void sendUIState() {
RobotConfigFile configFile = robotCfgFileMgr.getActiveConfig();
String serialized = configFile.toString();
networkConnectionHandler.sendCommand(new Command(CommandList.CMD_NOTIFY_ACTIVE_CONFIGURATION, serialized));
// Send the user device type list
UserConfigurationTypeManager.getInstance().sendUserDeviceTypes();
// We might get a request in really soon, before we're fully together. Wait: the driver
// station doesn't retry if we were to ignore (might not need any more, as we send this
// state more frequently than we used to)
this.registeredOpModes.waitOpModesRegistered();
// Send the opmode list
String opModeList = SimpleGson.getInstance().toJson(registeredOpModes.getOpModes());
networkConnectionHandler.sendCommand(new Command(CommandList.CMD_NOTIFY_OP_MODE_LIST, opModeList));
// Subclasses might send other state too
}
use of com.qualcomm.ftccommon.configuration.RobotConfigFile in project FTC-2017 by FIRST-4030.
the class FtcRobotControllerActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// robustify against onCreate() following onDestroy() but using the same app instance, which apparently does happen
RobotLog.onApplicationStart();
RobotLog.vv(TAG, "onCreate()");
// do this way instead of inherit to help AppInventor
ThemedActivity.appAppThemeToActivity(getTag(), this);
Assert.assertTrue(FtcRobotControllerWatchdogService.isFtcRobotControllerActivity(AppUtil.getInstance().getRootActivity()));
Assert.assertTrue(AppUtil.getInstance().isRobotController());
// a stand-alone USB-connected module?
if (LynxConstants.isRevControlHub()) {
if (LynxConstants.disableDragonboard()) {
// Double-sure check that the Lynx Module can operate over USB, etc, then get out of Dodge
RobotLog.vv(TAG, "disabling Dragonboard and exiting robot controller");
DragonboardLynxDragonboardIsPresentPin.getInstance().setState(false);
AppUtil.getInstance().finishRootActivityAndExitApp();
} else {
// Double-sure check that we can talk to the DB over the serial TTY
DragonboardLynxDragonboardIsPresentPin.getInstance().setState(true);
}
}
context = this;
utility = new Utility(this);
DeviceNameManager.getInstance().start(deviceNameManagerStartResult);
PreferenceRemoterRC.getInstance().start(prefRemoterStartResult);
receivedUsbAttachmentNotifications = new ConcurrentLinkedQueue<UsbDevice>();
eventLoop = null;
setContentView(R.layout.activity_ftc_controller);
preferencesHelper = new PreferencesHelper(TAG, context);
preferencesHelper.writeBooleanPrefIfDifferent(context.getString(R.string.pref_rc_connected), true);
preferencesHelper.getSharedPreferences().registerOnSharedPreferenceChangeListener(sharedPreferencesListener);
entireScreenLayout = (LinearLayout) findViewById(R.id.entire_screen);
buttonMenu = (ImageButton) findViewById(R.id.menu_buttons);
buttonMenu.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
AppUtil.getInstance().openOptionsMenuFor(FtcRobotControllerActivity.this);
}
});
BlocksOpMode.setActivityAndWebView(this, (WebView) findViewById(R.id.webViewBlocksRuntime));
ClassManagerFactory.registerFilters();
ClassManagerFactory.processAllClasses();
cfgFileMgr = new RobotConfigFileManager(this);
// Clean up 'dirty' status after a possible crash
RobotConfigFile configFile = cfgFileMgr.getActiveConfig();
if (configFile.isDirty()) {
configFile.markClean();
cfgFileMgr.setActiveConfig(false, configFile);
}
textDeviceName = (TextView) findViewById(R.id.textDeviceName);
textNetworkConnectionStatus = (TextView) findViewById(R.id.textNetworkConnectionStatus);
textRobotStatus = (TextView) findViewById(R.id.textRobotStatus);
textOpMode = (TextView) findViewById(R.id.textOpMode);
textErrorMessage = (TextView) findViewById(R.id.textErrorMessage);
textGamepad[0] = (TextView) findViewById(R.id.textGamepad1);
textGamepad[1] = (TextView) findViewById(R.id.textGamepad2);
immersion = new ImmersiveMode(getWindow().getDecorView());
dimmer = new Dimmer(this);
dimmer.longBright();
programmingWebHandlers = new ProgrammingWebHandlers();
programmingModeController = new ProgrammingModeControllerImpl(this, (TextView) findViewById(R.id.textRemoteProgrammingMode), programmingWebHandlers);
updateUI = createUpdateUI();
callback = createUICallback(updateUI);
PreferenceManager.setDefaultValues(this, R.xml.app_settings, false);
WifiManager wifiManager = (WifiManager) getApplicationContext().getSystemService(Context.WIFI_SERVICE);
wifiLock = wifiManager.createWifiLock(WifiManager.WIFI_MODE_FULL_HIGH_PERF, "");
hittingMenuButtonBrightensScreen();
wifiLock.acquire();
callback.networkConnectionUpdate(WifiDirectAssistant.Event.DISCONNECTED);
readNetworkType();
ServiceController.startService(FtcRobotControllerWatchdogService.class);
bindToService();
logPackageVersions();
}
use of com.qualcomm.ftccommon.configuration.RobotConfigFile in project Relic_Main by TeamOverdrive.
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();
}
Aggregations