コード例 #1
0
 public LinearLift(FTCRobot robot, LinearOpMode curOpMode) {
   this.robot = robot;
   this.curOpMode = curOpMode;
   try {
     this.liftAngleMotor = curOpMode.hardwareMap.dcMotor.get("liftAngleMotor");
     liftAngleMotorAvailable = true;
   } catch (Exception e) {
     DbgLog.error(String.format("%s . Device skipped", e.getMessage()));
   }
   try {
     this.liftArmLengthMotor = curOpMode.hardwareMap.dcMotor.get("liftArmLengthMotor");
     liftArmLengthMotorAvailable = true;
   } catch (Exception e) {
     DbgLog.error(String.format("%s . Device skipped", e.getMessage()));
   }
 }
コード例 #2
0
 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());
   }
 }
コード例 #3
0
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {

    if (resultCode == RESULT_CANCELED) {
      return;
    }
    Serializable extra = null;
    if (requestCode == 1) {
      extra = data.getSerializableExtra(EditMotorControllerActivity.EDIT_MOTOR_CONTROLLER_CONFIG);
    } else if (requestCode == 2) {
      extra = data.getSerializableExtra(EditServoControllerActivity.EDIT_SERVO_ACTIVITY);
    } else if (requestCode == 3) {
      extra = data.getSerializableExtra(EditLegacyModuleControllerActivity.EDIT_LEGACY_CONFIG);
    }
    if (extra != null) {
      ControllerConfiguration newC = (ControllerConfiguration) extra;
      scannedDevices.put(newC.getSerialNumber(), newC.configTypeToDeviceType(newC.getType()));
      deviceControllers.put(newC.getSerialNumber(), newC);
      populateList();

      String name = preferredFilename;
      // only update the filename if it hasn't already been updated to have "unsaved" in it
      if (!name.toLowerCase().contains(Utility.UNSAVED.toLowerCase())) {
        name = Utility.UNSAVED + " " + preferredFilename;
        utility.saveToPreferences(name, R.string.pref_hardware_config_filename);
        preferredFilename = name;
      }

    } else {
      DbgLog.error(
          "Received Result with an incorrect request code: " + String.valueOf(requestCode));
    }
  }
コード例 #4
0
 public void run() {
   try {
     DbgLog.msg("Scanning USB bus");
     this.f92a.f93a.scannedDevices = this.f92a.f93a.f100d.scanForUsbDevices();
   } catch (RobotCoreException e) {
     DbgLog.error("Device scan failed");
   }
   this.f92a.f93a.runOnUiThread(new C00321(this));
 }
コード例 #5
0
 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);
   }
 }
コード例 #6
0
  public void file_delete_button(View v) {
    String filenameWExt = getFileName(v, true);
    File file = new File(Utility.CONFIG_FILES_DIR + filenameWExt);

    if (file.exists()) {
      file.delete();
    } else {
      utility.complainToast("That file does not exist: " + filenameWExt, context);
      DbgLog.error("Tried to delete a file that does not exist: " + filenameWExt);
    }

    fileList = utility.getXMLFiles();
    utility.saveToPreferences(Utility.NO_FILE, R.string.pref_hardware_config_filename);
    utility.updateHeader(
        Utility.NO_FILE,
        R.string.pref_hardware_config_filename,
        R.id.active_filename,
        R.id.included_header);
    populate();
  }
コード例 #7
0
  @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);
  }
コード例 #8
0
  /**
   * This method parses the XML of the active configuration file, and calls methods to populate the
   * appropriate data structures to the configuration information can be displayed to the user.
   */
  private void readFile() {
    ReadXMLFileHandler parser = new ReadXMLFileHandler(context);

    if (preferredFilename.equalsIgnoreCase(Utility.NO_FILE)) {
      // don't try to parse if there's no file
      return;
    }

    InputStream inputStream = null;
    try {
      inputStream =
          new FileInputStream(Utility.CONFIG_FILES_DIR + preferredFilename + Utility.FILE_EXT);
    } catch (FileNotFoundException e) {
      DbgLog.error("File was not found: " + preferredFilename);
      DbgLog.logStacktrace(e);
      utility.complainToast("That file was not found: " + preferredFilename, context);
      return;
    }
    ArrayList<ControllerConfiguration> controllerList =
        (ArrayList<ControllerConfiguration>) parser.parse(inputStream);
    buildHashMap(controllerList);
    populateList();
    warnIfNoDevices();
  }