Search in sources :

Example 11 with RobotConfigFile

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
}
Also used : RobotConfigFile(com.qualcomm.ftccommon.configuration.RobotConfigFile) Command(com.qualcomm.robotcore.robocol.Command)

Example 12 with RobotConfigFile

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();
}
Also used : WifiManager(android.net.wifi.WifiManager) ImmersiveMode(com.qualcomm.robotcore.util.ImmersiveMode) UsbDevice(android.hardware.usb.UsbDevice) View(android.view.View) WebView(android.webkit.WebView) TextView(android.widget.TextView) RobotConfigFileManager(com.qualcomm.ftccommon.configuration.RobotConfigFileManager) PreferencesHelper(org.firstinspires.ftc.robotcore.internal.system.PreferencesHelper) ProgrammingModeControllerImpl(com.google.blocks.ftcrobotcontroller.ProgrammingModeControllerImpl) Utility(com.qualcomm.robotcore.hardware.configuration.Utility) RobotConfigFile(com.qualcomm.ftccommon.configuration.RobotConfigFile) Dimmer(com.qualcomm.robotcore.util.Dimmer) TextView(android.widget.TextView) ProgrammingWebHandlers(com.google.blocks.ftcrobotcontroller.ProgrammingWebHandlers)

Example 13 with RobotConfigFile

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();
}
Also used : HardwareFactory(com.qualcomm.hardware.HardwareFactory) FtcEventLoop(com.qualcomm.ftccommon.FtcEventLoop) RobotConfigFile(com.qualcomm.ftccommon.configuration.RobotConfigFile) OpModeRegister(com.qualcomm.robotcore.eventloop.opmode.OpModeRegister) Resources(android.content.res.Resources) FtcEventLoopIdle(com.qualcomm.ftccommon.FtcEventLoopIdle)

Aggregations

RobotConfigFile (com.qualcomm.ftccommon.configuration.RobotConfigFile)13 Command (com.qualcomm.robotcore.robocol.Command)4 Resources (android.content.res.Resources)3 UsbDevice (android.hardware.usb.UsbDevice)3 WifiManager (android.net.wifi.WifiManager)3 View (android.view.View)3 WebView (android.webkit.WebView)3 TextView (android.widget.TextView)3 ProgrammingModeControllerImpl (com.google.blocks.ftcrobotcontroller.ProgrammingModeControllerImpl)3 ProgrammingWebHandlers (com.google.blocks.ftcrobotcontroller.ProgrammingWebHandlers)3 FtcEventLoop (com.qualcomm.ftccommon.FtcEventLoop)3 FtcEventLoopIdle (com.qualcomm.ftccommon.FtcEventLoopIdle)3 RobotConfigFileManager (com.qualcomm.ftccommon.configuration.RobotConfigFileManager)3 HardwareFactory (com.qualcomm.hardware.HardwareFactory)3 OpModeRegister (com.qualcomm.robotcore.eventloop.opmode.OpModeRegister)3 Utility (com.qualcomm.robotcore.hardware.configuration.Utility)3 Dimmer (com.qualcomm.robotcore.util.Dimmer)3 ImmersiveMode (com.qualcomm.robotcore.util.ImmersiveMode)3 PreferencesHelper (org.firstinspires.ftc.robotcore.internal.system.PreferencesHelper)3 RobotCoreException (com.qualcomm.robotcore.exception.RobotCoreException)2