コード例 #1
0
 @Override
 public int hashCode() {
   return t.hashCode();
 }
コード例 #2
0
ファイル: CC430MoteType.java プロジェクト: kkrentz/contiki
  public boolean configureAndInit(
      Container parentContainer, Simulation simulation, boolean visAvailable)
      throws MoteTypeCreationException {

    /* If visualized, show compile dialog and let user configure */
    if (visAvailable && !simulation.isQuickSetup()) {

      /* Create unique identifier */
      if (getIdentifier() == null) {
        int counter = 0;
        boolean identifierOK = false;
        while (!identifierOK) {
          identifierOK = true;

          counter++;
          setIdentifier("cc430-" + counter);

          for (MoteType existingMoteType : simulation.getMoteTypes()) {
            if (existingMoteType == this) {
              continue;
            }
            if (existingMoteType.getIdentifier().equals(getIdentifier())) {
              identifierOK = false;
              break;
            }
          }
        }
      }

      /* Create initial description */
      if (getDescription() == null) {
        setDescription("CC430 Mote Type #" + getIdentifier());
      }

      return MspCompileDialog.showDialog(parentContainer, simulation, this, "cc430");
    }

    /* Not visualized: Compile Contiki immediately */
    if (getIdentifier() == null) {
      throw new MoteTypeCreationException("No identifier");
    }

    final MessageList compilationOutput = MessageContainer.createMessageList(visAvailable);

    if (getCompileCommands() != null) {
      /* Handle multiple compilation commands one by one */
      String[] arr = getCompileCommands().split("\n");
      for (String cmd : arr) {
        if (cmd.trim().isEmpty()) {
          continue;
        }

        try {
          CompileContiki.compile(
              cmd,
              null,
              null /* Do not observe output firmware file */,
              getContikiSourceFile().getParentFile(),
              null,
              null,
              compilationOutput,
              true);
        } catch (Exception e) {
          MoteTypeCreationException newException =
              new MoteTypeCreationException("Mote type creation failed: " + e.getMessage());
          newException = (MoteTypeCreationException) newException.initCause(e);
          newException.setCompilationOutput(compilationOutput);

          /* Print last 10 compilation errors to console */
          MessageContainer[] messages = compilationOutput.getMessages();
          for (int i = messages.length - 10; i < messages.length; i++) {
            if (i < 0) {
              continue;
            }
            logger.fatal(">> " + messages[i]);
          }

          logger.fatal("Compilation error: " + e.getMessage());
          throw newException;
        }
      }
    }

    if (getContikiFirmwareFile() == null || !getContikiFirmwareFile().exists()) {
      throw new MoteTypeCreationException(
          "Contiki firmware file does not exist: " + getContikiFirmwareFile());
    }
    return true;
  }
コード例 #3
0
 @Override
 public String toString() {
   return t.getDescription();
 }