protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   this.f97a = this;
   setContentView(R.layout.activity_autoconfigure);
   this.f103g = new Utility(this);
   this.f98b = (Button) findViewById(R.id.configureLegacy);
   this.f99c = (Button) findViewById(R.id.configureUSB);
   try {
     this.f100d = new HardwareDeviceManager(this.f97a, null);
   } catch (RobotCoreException e) {
     this.f103g.complainToast("Failed to open the Device Manager", this.f97a);
     DbgLog.error("Failed to open deviceManager: " + e.toString());
     DbgLog.logStacktrace(e);
   }
 }
 private void m55a(String str) {
   this.f103g.writeXML(this.f101e);
   try {
     this.f103g.writeToFile(str + ".xml");
     this.f103g.saveToPreferences(str, R.string.pref_hardware_config_filename);
     this.f103g.updateHeader(
         str, R.string.pref_hardware_config_filename, R.id.active_filename, R.id.included_header);
     Toast.makeText(this.f97a, "AutoConfigure " + str + " Successful", 0).show();
   } catch (RobotCoreException e) {
     this.f103g.complainToast(e.getMessage(), this.f97a);
     DbgLog.error(e.getMessage());
   } catch (IOException e2) {
     this.f103g.complainToast("Found " + e2.getMessage() + "\n Please fix and re-save", this.f97a);
     DbgLog.error(e2.getMessage());
   }
 }
Exemplo n.º 3
0
    public void run() {
      while (true) {
        RobocolDatagram datagram = EventLoopManager.this.socket.recv(); // what's the timeout?
        if (EventLoopManager.this.receivingProhibited || EventLoopManager.this.socket.isClosed()) {
          return;
        }

        if (datagram == null) {
          Thread.yield();
        } else {
          if (RobotLog.hasGlobalErrorMsg()) {
            EventLoopManager.this.buildAndSendTelemetry(
                "SYSTEM_TELEMETRY", RobotLog.getGlobalErrorMsg());
          }

          try {
            switch (EventLoopManager.SyntheticClass_1.a[datagram.getMsgType().ordinal()]) {
              case 1:
                EventLoopManager.this.onGamepadDatagram(datagram);
                break;
              case 2:
                EventLoopManager.this.onHeartbeatDatagramReceived(datagram);
                break;
              case 3:
                EventLoopManager.this.onConnectionDatagram(datagram);
                break;
              case 4:
                EventLoopManager.this.onCommandDatagram(datagram);
                break;
              case 5:
                EventLoopManager.this.onEmptyDatagram();
                break;
              default:
                EventLoopManager.this.onUnknownDatagram(datagram);
            }
          } catch (RobotCoreException var3) {
            RobotLog.w("RobotCore event loop cannot process event: " + var3.toString());
          }
        }
      }
    }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_ftc_configuration);

    RobotLog.writeLogcatToDisk(this, 1024);
    this.context = this;
    utility = new Utility(this);
    scanButton = (Button) findViewById(R.id.scanButton);
    buildInfoButtons();

    try {
      deviceManager = new ModernRoboticsDeviceManager(context, null);
      // deviceManager = new MockDeviceManager(context, null);
    } catch (RobotCoreException e) {
      utility.complainToast("Failed to open the Device Manager", context);
      DbgLog.error("Failed to open deviceManager: " + e.toString());
      DbgLog.logStacktrace(e);
    }

    preferences = PreferenceManager.getDefaultSharedPreferences(this);
  }
Exemplo n.º 5
0
  public static void logStacktrace(RobotCoreException e) {
    RobotLog.e(e.toString());
    for (StackTraceElement el : e.getStackTrace()) {
      RobotLog.e(el.toString());
    }

    if (e.isChainedException()) {
      RobotLog.e("Exception chained from:");
      if (e.getChainedException() instanceof RobotCoreException) {
        logStacktrace((RobotCoreException) e.getChainedException());
      } else {
        logStacktrace(e.getChainedException());
      }
    }
  }
Exemplo n.º 6
0
 /**
  * Set a global error message
  *
  * <p>Sets the global error message, with the exceptions message appended. Then it rethrows the
  * given exception.
  *
  * @param message error message
  * @param e a RobotCoreException
  * @throws RobotCoreException
  */
 public static void setGlobalErrorMsgAndThrow(String message, RobotCoreException e)
     throws RobotCoreException {
   setGlobalErrorMsg(message + "\n" + e.getMessage());
   throw e;
 }
Exemplo n.º 7
0
    public void run() {
      RobotLog.v("EventLoopRunnable has started");

      try {
        ElapsedTime elapsedEventLoop = new ElapsedTime();
        double sMinLoopInterval = 0.001D;
        long msLoopIntervalStep = 5L;

        while (!Thread.interrupted()) {
          while (elapsedEventLoop.time() < sMinLoopInterval) {
            Thread.sleep(msLoopIntervalStep);
          }

          elapsedEventLoop.reset();
          if (RobotLog.hasGlobalErrorMsg()) {
            EventLoopManager.this.buildAndSendTelemetry(
                "SYSTEM_TELEMETRY", RobotLog.getGlobalErrorMsg());
          }

          if (EventLoopManager.this.elapsedSinceHeartbeatReceived.startTime() == 0.0D) {
            Thread.sleep(500L);
          } else if (EventLoopManager.this.elapsedSinceHeartbeatReceived.time() > 2.0D) {
            EventLoopManager.this.handleDroppedConnection();
            EventLoopManager.this.currentPeerAddressAndPort = null;
            EventLoopManager.this.elapsedSinceHeartbeatReceived = new ElapsedTime(0L);
          }

          Iterator syncdDeviceIterator = EventLoopManager.this.syncdDevices.iterator();
          SyncdDevice syncdDevice;
          while (syncdDeviceIterator.hasNext()) {
            syncdDevice = (SyncdDevice) syncdDeviceIterator.next();
            syncdDevice.blockUntilReady();
          }

          boolean unblockOnException = false;

          try {
            unblockOnException = true;
            EventLoopManager.this.eventLoop.loop();
            unblockOnException = false;
          } catch (Exception e) {
            RobotLog.e("Event loop threw an exception");
            RobotLog.logStacktrace(e);
            String exceptionMessage =
                e.getClass().getSimpleName()
                    + (e.getMessage() != null ? " - " + e.getMessage() : "");
            RobotLog.setGlobalErrorMsg(
                "User code threw an uncaught exception: " + exceptionMessage);
            EventLoopManager.this.buildAndSendTelemetry(
                "SYSTEM_TELEMETRY", RobotLog.getGlobalErrorMsg());
            throw new RobotCoreException("EventLoop Exception in loop()");
          } finally {
            if (unblockOnException) {
              Iterator var9 = EventLoopManager.this.syncdDevices.iterator();

              while (var9.hasNext()) {
                SyncdDevice var10 = (SyncdDevice) var9.next();
                var10.startBlockingWork();
              }
            }
          }

          syncdDeviceIterator = EventLoopManager.this.syncdDevices.iterator();

          while (syncdDeviceIterator.hasNext()) {
            syncdDevice = (SyncdDevice) syncdDeviceIterator.next();
            syncdDevice.startBlockingWork();
          }
        }
      } catch (InterruptedException var20) {
        RobotLog.v("EventLoopRunnable interrupted");
        EventLoopManager.this.reportRobotStatus(RobotState.STOPPED);
      } catch (RobotCoreException var21) {
        RobotLog.v("RobotCoreException in EventLoopManager: " + var21.getMessage());
        EventLoopManager.this.reportRobotStatus(RobotState.EMERGENCY_STOP);
        EventLoopManager.this.buildAndSendTelemetry(
            "SYSTEM_TELEMETRY", RobotLog.getGlobalErrorMsg());
      }

      try {
        EventLoopManager.this.eventLoop.teardown();
      } catch (Exception var17) {
        RobotLog.w("Caught exception during looper teardown: " + var17.toString());
        RobotLog.logStacktrace(var17);
        if (RobotLog.hasGlobalErrorMsg()) {
          EventLoopManager.this.buildAndSendTelemetry(
              "SYSTEM_TELEMETRY", RobotLog.getGlobalErrorMsg());
        }
      }

      RobotLog.v("EventLoopRunnable has exited");
    }