⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 contikimotetypedialog.java

📁 传感器网络操作系统contiki。 被广泛应用于环境检测、结构健康监测等等。包括路由协议
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
      ccFlags = ccFlags.replace("$(ARFILE)", arFile.getPath().replace(File.separatorChar, '/'));      String javaHome = System.getenv().get("JAVA_HOME");      if (javaHome == null) {        javaHome = "";      }      link1 = link1.replace("$(JAVA_HOME)", javaHome);      link2 = link2.replace("$(JAVA_HOME)", javaHome);      ar1 = ar1.replace("$(JAVA_HOME)", javaHome);      ar2 = ar2.replace("$(JAVA_HOME)", javaHome);      ccFlags = ccFlags.replace("$(JAVA_HOME)", javaHome);      for (File sourceFile : sourceFiles) {        if (sourceFile.isDirectory()) {          // Add directory to search path          sourceDirs += " "              + sourceFile.getPath().replace(File.separatorChar, '/');          ccFlags += " -I"              + sourceFile.getPath().replace(File.separatorChar, '/');        } else if (sourceFile.isFile()) {          // Add both file name and directory          if (sourceFile.getParent() != null) {            sourceDirs += " "                + sourceFile.getParent().replace(File.separatorChar, '/');          }          sourceFileNames += " " + sourceFile.getName();        } else {          // Add filename and hope Contiki knows where to find it...          sourceFileNames += " " + sourceFile.getName();        }      }      // Add communication stack source files      sourceFileNames += commStack.getSourceFilenamesString();      logger.info("-- Compiling --");      logger.info("Project dirs: " + sourceDirs);      logger.info("Project sources: " + sourceFileNames);      logger.info("Compiler flags: " + ccFlags);      String[] env = new String[]{          "CONTIKI=" + contikiDir.getPath().replace(File.separatorChar, '/'),          "TARGET=cooja", "TYPEID=" + identifier,          "LINK_COMMAND_1=" + link1,          "LINK_COMMAND_2=" + link2,          "AR_COMMAND_1=" + ar1,          "AR_COMMAND_2=" + ar2,          "EXTRA_CC_ARGS=" + ccFlags,          "SYMBOLS=" + (includeSymbols?"1":""),          "CC=" + GUI.getExternalToolsSetting("PATH_C_COMPILER"),          "LD=" + GUI.getExternalToolsSetting("PATH_LINKER"),          "AR=" + GUI.getExternalToolsSetting("PATH_AR"),          "PROJECTDIRS=" + sourceDirs,          "PROJECT_SOURCEFILES=" + sourceFileNames,          "PATH=" + System.getenv("PATH")};/*      System.out.print("Full command:\n");      System.out.print((new File(".").getAbsolutePath()) + "/> ");      for (String s: cmd)        System.out.print(s + " ");      System.out.println();      System.out.println("Environment:\n");      for (String s: env)        System.out.print(s + "\n");*/      Process p = Runtime.getRuntime().exec(cmd, env, null);      final BufferedReader input = new BufferedReader(new InputStreamReader(p          .getInputStream()));      final BufferedReader err = new BufferedReader(new InputStreamReader(p          .getErrorStream()));      Thread readInput = new Thread(new Runnable() {        public void run() {          String readLine;          try {            while ((readLine = input.readLine()) != null) {              if (outputStream != null && readLine != null) {                outputStream.println(readLine);              }            }          } catch (IOException e) {            logger.warn("Error while reading from process");          }        }      }, "read input stream thread");      Thread readError = new Thread(new Runnable() {        public void run() {          String readLine;          try {            while ((readLine = err.readLine()) != null) {              if (errorStream != null && readLine != null) {                errorStream.println(readLine);              }            }          } catch (IOException e) {            logger.warn("Error while reading from process");          }        }      }, "read input stream thread");      readInput.start();      readError.start();      while (readInput.isAlive() || readError.isAlive()) {        Thread.sleep(100);      }      input.close();      err.close();      p.waitFor();      if (p.exitValue() != 0) {        logger.fatal("Make file returned error: " + p.exitValue());        return false;      }    } catch (Exception e) {      logger.fatal("Error while compiling library: " + e);      e.printStackTrace();      return false;    }    return true;  }  /**   * Scans a directory for sourcefiles which defines a Contiki process.   *   * @param rootDirectory   *          Top directory to search in   * @return Process definitions found under rootDirectory, {sourcefile,   *         processname}   */  public static Vector<String[]> scanForProcesses(File rootDirectory) {    if (!rootDirectory.isDirectory()) {      logger.fatal("Not a directory: " + rootDirectory);      return null;    }    if (!rootDirectory.exists()) {      logger.fatal("Does not exist: " + rootDirectory);      return null;    }    Vector<String[]> processes = new Vector<String[]>();    // Scan in rootDirectory    try {      String line;      String cmdString = GUI.getExternalToolsSetting("CMD_GREP_PROCESSES")          + " '" + rootDirectory.getPath().replace(File.separatorChar, '/')          + "'/*.[ch]";      Pattern pattern = Pattern.compile(GUI          .getExternalToolsSetting("REGEXP_PARSE_PROCESSES"));      String[] cmd = new String[3];      cmd[0] = GUI.getExternalToolsSetting("PATH_SHELL");      cmd[1] = "-c";      cmd[2] = cmdString;      Process p = Runtime.getRuntime().exec(cmd);      BufferedReader input = new BufferedReader(new InputStreamReader(p          .getInputStream()));      while ((line = input.readLine()) != null) {        Matcher matcher = pattern.matcher(line);        if (matcher.find()) {          processes.add(new String[]{matcher.group(1), matcher.group(2)});        }      }      input.close();//      BufferedReader err = new BufferedReader(new InputStreamReader(p//          .getErrorStream()));//      if (err.ready())//        logger.warn("Error occured during scan:");//      while ((line = err.readLine()) != null) {//        logger.warn(line);//      }//      err.close();    } catch (IOException err) {      logger.fatal("Error while scanning for processes: " + err);      err.printStackTrace();    } catch (Exception err) {      logger.fatal("Error while scanning for processes: " + err);      err.printStackTrace();    }    return processes;  }  /**   * Scans a directory and all subdirectories for sourcefiles which defines a   * Contiki sensor.   *   * @param rootDirectory   *          Top directory to search in   * @return Sensor definitions found under rootDirectory, {sourcefile,   *         sensorname}   */  public static Vector<String[]> scanForSensors(File rootDirectory) {    if (!rootDirectory.isDirectory()) {      logger.fatal("Not a directory: " + rootDirectory);      return null;    }    if (!rootDirectory.exists()) {      logger.fatal("Does not exist: " + rootDirectory);      return null;    }    Vector<String[]> sensors = new Vector<String[]>();    // Scan in rootDirectory    try {      String line;      String cmdString = GUI.getExternalToolsSetting("CMD_GREP_SENSORS") + " '"          + rootDirectory.getPath().replace(File.separatorChar, '/') + "'";      Pattern pattern = Pattern.compile(GUI          .getExternalToolsSetting("REGEXP_PARSE_SENSORS"));      String[] cmd = new String[3];      cmd[0] = GUI.getExternalToolsSetting("PATH_SHELL");      cmd[1] = "-c";      cmd[2] = cmdString;      Process p = Runtime.getRuntime().exec(cmd);      BufferedReader input = new BufferedReader(new InputStreamReader(p          .getInputStream()));      while ((line = input.readLine()) != null) {        Matcher matcher = pattern.matcher(line);        if (matcher.find()) {          sensors.add(new String[]{matcher.group(1), matcher.group(2)});        }      }      input.close();      BufferedReader err = new BufferedReader(new InputStreamReader(p          .getErrorStream()));      if (err.ready()) {        logger.warn("Error occured during scan:");      }      while ((line = err.readLine()) != null) {        logger.warn(line);      }      err.close();    } catch (IOException err) {      logger.fatal("Error while scanning for sensors: " + err);      err.printStackTrace();    } catch (Exception err) {      logger.fatal("Error while scanning for sensors: " + err);      err.printStackTrace();    }    return sensors;  }  /**   * Scans a directory and all subdirectories for sourcefiles which defines a   * COOJA core interface.   *   * @param rootDirectory   *          Top directory to search in   * @return Core interface definitions found under rootDirectory, {sourcefile,   *         interfacename}   */  public static Vector<String[]> scanForInterfaces(File rootDirectory) {    if (!rootDirectory.isDirectory()) {      logger.fatal("Not a directory: " + rootDirectory);      return null;    }    if (!rootDirectory.exists()) {      logger.fatal("Does not exist: " + rootDirectory);      return null;    }    Vector<String[]> interfaces = new Vector<String[]>();    // Scan in rootDirectory    try {      String line;      String cmdString = GUI.getExternalToolsSetting("CMD_GREP_INTERFACES")          + " '" + rootDirectory.getPath().replace(File.separatorChar, '/')          + "'";      Pattern pattern = Pattern.compile(GUI          .getExternalToolsSetting("REGEXP_PARSE_INTERFACES"));      String[] cmd = new String[3];      cmd[0] = GUI.getExternalToolsSetting("PATH_SHELL");      cmd[1] = "-c";      cmd[2] = cmdString;      Process p = Runtime.getRuntime().exec(cmd);      BufferedReader input = new BufferedReader(new InputStreamReader(p          .getInputStream()));      while ((line = input.readLine()) != null) {        Matcher matcher = pattern.matcher(line);        if (matcher.find()) {          interfaces.add(new String[]{matcher.group(1), matcher.group(2)});        }      }      input.close();      BufferedReader err = new BufferedReader(new InputStreamReader(p          .getErrorStream()));      if (err.ready()) {        logger.warn("Error occured during scan:");      }      while ((line = err.readLine()) != null) {        logger.warn(line);      }      err.close();    } catch (IOException err) {      logger.fatal("Error while scanning for interfaces: " + err);      err.printStackTrace();    } catch (Exception err) {      logger.fatal("Error while scanning for interfaces: " + err);      err.printStackTrace();    }    return interfaces;  }  /**   * Scans given file for an autostart expression and returns all process names   * found.   *   * @param sourceFile   *          Source file to scan   * @return Autostart process names or null   * @throws FileNotFoundException   *           Given file not found   * @throws IOException   *           IO Exception   */  public static Vector<String> parseAutostartProcesses(File sourceFile)      throws FileNotFoundException, IOException {    // Open file for reading    BufferedReader sourceFileReader = new BufferedReader(new FileReader(        sourceFile));    // Find which processes were set to autostart    String line;    String autostartExpression = "^AUTOSTART_PROCESSES([^$]*)$";    Pattern pattern = Pattern.compile(autostartExpression);    Vector<String> foundProcesses = new Vector<String>();    while ((line = sourceFileReader.readLine()) != null) {      Matcher matcher = pattern.matcher(line);      if (matcher.find()) {        // Parse autostart processes        String[] allProcesses = matcher.group(1).split(",");        for (String autostartProcess : allProcesses) {          foundProcesses.add(autostartProcess.replaceAll("[&; \\(\\)]", ""));        }      }    }    return foundProcesses;  }  private boolean autoSelectDependencyProcesses(String processName,      String sourceFilename, boolean confirmSelection) {    // Locate source file    File sourceFile = new File(textCoreDir.getText(), sourceFilename);    boolean foundFile = sourceFile.exists();    if (!foundFile) {      for (File projectDir : myGUI.getProjectDirs(

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -