예제 #1
0
파일: Effect.java 프로젝트: linhua55/trime
  public void reset() {
    Config config = Config.get();
    vibrateOn = config.getBoolean("key_vibrate");
    duration = config.getInt("key_vibrate_duration");
    if (vibrateOn && (vibrator == null)) {
      vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
    }

    soundOn = config.getBoolean("key_sound");
    volume = config.getFloat("key_sound_volume");
    if (soundOn && (audioManager == null)) {
      audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
    }

    isSpeakCommit = config.getBoolean("speak_commit");
    isSpeakKey = config.getBoolean("speak_key");
    if (mTTS == null && (isSpeakCommit || isSpeakKey)) {
      mTTS =
          new TextToSpeech(
              context,
              new TextToSpeech.OnInitListener() {
                public void onInit(int status) {
                  // 初始化結果
                }
              });
    }
  }
예제 #2
0
  public static void start(Config conf, String[] args) {
    // this is redundant to jpf.report.<publisher>.start=..config..
    // but nobody can remember this (it's only used to produce complete reports)

    if (logger == null) {
      logger = initLogging(conf);
    }

    if (!checkArgs(args)) {
      return;
    }

    setNativeClassPath(conf); // in case we have to find a shell

    // check if there is a shell class specification, in which case we just delegate
    JPFShell shell = conf.getInstance("shell", JPFShell.class);
    if (shell != null) {
      shell.start(args); // responsible for exception handling itself

    } else {
      // no shell, we start JPF directly
      LogManager.printStatus(logger);
      conf.printStatus(logger);

      // this has to be done after we checked&consumed all "-.." arguments
      // this is NOT about checking properties!
      checkUnknownArgs(args);

      try {
        JPF jpf = new JPF(conf);
        jpf.run();

      } catch (ExitException x) {
        logger.severe("JPF terminated");

        // this is how we get most runtime config exceptions
        if (x.shouldReport()) {
          x.printStackTrace();
        }

        /**
         * Throwable cause = x.getCause(); if ((cause != null) && conf.getBoolean("pass_exceptions",
         * false)) { cause.fillInStackTrace(); throw cause; }
         */
      } catch (JPFException jx) {
        logger.severe("JPF exception, terminating: " + jx.getMessage());
        if (conf.getBoolean("jpf.print_exception_stack")) {

          Throwable cause = jx.getCause();
          if (cause != null && cause != jx) {
            cause.printStackTrace();
          } else {
            jx.printStackTrace();
          }
        }
        // pass this on, caller has to handle
        throw jx;
      }
    }
  }
예제 #3
0
 /**
  * This method is used to display debugging messages with formatted output.
  *
  * @param msg the debug message to display
  */
 public void debug(String msg) {
   if (options.getBoolean("bc.server.debug")) {
     for (String line : msg.split("\n")) {
       System.out.printf("[server:debug] %s\n", line);
     }
   }
 }
  private static void createDevices() {
    interrupt = new Interrupt(privilege);
    timer = new Timer(privilege);

    if (Config.getBoolean("Machine.bank")) bank = new ElevatorBank(privilege);

    if (Config.getBoolean("Machine.processor")) {
      if (numPhysPages == -1) numPhysPages = Config.getInteger("Processor.numPhysPages");
      processor = new Processor(privilege, numPhysPages);
    }

    if (Config.getBoolean("Machine.console")) console = new StandardConsole(privilege);

    if (Config.getBoolean("Machine.stubFileSystem"))
      stubFileSystem = new StubFileSystem(privilege, testDirectory);

    if (Config.getBoolean("Machine.networkLink")) networkLink = new NetworkLink(privilege);
  }
예제 #5
0
 @Override
 public void onEnable() {
   setupStatic(this);
   this.getCommand("noitem").setExecutor(new CmdNoItem());
   PluginManager pm = getServer().getPluginManager();
   pm.registerEvents(new Listeners(), this);
   if (Config.getBoolean("Auto-Download-Updates")) {
     new Updater(this, this.getFile(), Updater.UpdateType.DEFAULT, true);
   } else if (Config.getBoolean("CheckForUpdates")) {
     new Updater(this, this.getFile(), Updater.UpdateType.NO_DOWNLOAD, true);
   }
   new VaultHook();
   try {
     if (!new Metrics(this).start()) {
       this.getLogger().warning("Could not start metrics!");
     }
   } catch (IOException e) {
     e.printStackTrace();
   }
 }
예제 #6
0
  /**
   * Initializes a new server.
   *
   * @param options the configuration to use
   * @param mode the mode to run the server in
   * @param proxies the proxies to send messages to
   */
  public Server(Config options, Mode mode, Proxy... proxies) {
    this.matches = new ArrayDeque<>();
    this.finished = new ArrayDeque<>();

    this.mode = mode;

    this.proxyWriter = new ProxyWriter(proxies, options.getBoolean("bc.server.debug"));

    this.options = options;
    this.state = State.NOT_READY;
  }
예제 #7
0
  public static void main(String[] args) {
    Config.parseCommandLine(args);
    Config.dumpParams(System.out);

    if (Config.getPrepare() && Config.getUnion() && Config.getStratified()) {
      throw new RuntimeException(
          "Current Implementation of stratified deletions"
              + " with prepared statements maps one list of parameters to every query"
              + " and thus doesn't work with union");
    }

    try {
      // NOTE:  a general user will actually call open, importUpdates, etc.
      // but instead we are calling lower-level routines right now, to test.

      RepositorySchemaDAO dao = new FlatFileRepositoryDAO(Config.getSchemaFile());
      OrchestraSystem system = dao.loadAllPeers();
      List<String> tables = SqlEngine.getNamesOfAllTables(system, false, false, true);
      //			List<String> tables = SqlEngine.getNamesOfAllTables(system, true, true, true);

      SqlDb d = new SqlDb(tables, system.getAllSchemas(), system);
      if (Config.getApply()) {
        d.connect();
      }
      SqlEngine tcd =
          new SqlEngine(
              d, // null,
              system);

      Peer p = system.getPeers().iterator().next();

      try {
        if (Config.getApply() && !Config.getBoolean("scalability2"))
          createDatabase(Config.getProperty("schema"), d);

        Debug.println("+++ Basic System Schema +++");
        for (String t : tables) Debug.print(t + "\t");
        Debug.println("");

        Debug.println("+++ Mappings +++");
        List<Mapping> mappings = system.getAllSystemMappings(true);
        for (Mapping s : mappings) Debug.println(s.toString());

        Debug.println("+++ Inverted/Composed Mappings with Provenance Relations +++");
        List<Rule> ruleSet = tcd.computeTranslationRules();

        //				for(RelationContext rel : tcd.getState().getIdbs()){
        //					List<RelationContext> p = tcd.getState().provenanceTablesForRelation(rel);
        //
        //					System.out.println("Provenance tables for " + rel + ": " + p);
        //				}

        for (Rule r : ruleSet) Debug.println(r.toString());

        boolean origApply = true;
        if (Config.getBoolean("scalability2")) {
          origApply = Config.getApply();
          Config.setApply(false);
        }

        if (Config.getApply()) tcd.migrate();

        if (Config.getBoolean("scalability2")) {
          Config.setApply(origApply);
        }

        // DeltaRules ourRules =
        tcd.computeDeltaRules();

        Debug.println("+++ Insertion Rules +++");
        List<DatalogSequence> insRules = tcd.getIncrementalInsertionProgram();
        insRules.get(0).printString();
        insRules.get(1).printString();
        insRules.get(2).printString();

        List<DatalogSequence> delRules = tcd.getIncrementalDeletionProgram();
        Debug.println("+++ Deletion Rules +++");
        delRules.get(0).printString();
        delRules.get(1).printString();
        delRules.get(2).printString();

        List<String> newTables =
            SqlEngine.getNamesOfAllTablesFromDeltas(/*ourRules,*/ system, true, true, true);
        d.setAllTables(newTables);

        if (Config.getBoolean("scalability")) {
          runScalability(tcd, d, p);
        } else if (Config.getBoolean("scalability1")) {
          runScalability1(tcd, d, p);
        } else if (Config.getBoolean("scalability2")) {
          runScalability2(tcd, d, p);
        } else if (Config.getBoolean("nullscycles")) {
          runAllnoMigrateInsOnly(tcd, p);
        } else if (Config.getDebug()) {
          runOnce(tcd, p);
        } else {
          //					runAllmigrateEveryTime(system, tcd, d, tables);
          runAllnoMigrate(tcd, d, p);
        }

        tcd.finalize();
        //				tcd.clean();
        if (Config.getApply()) {
          d.disconnect();
        }

      } catch (Exception e) {
        e.printStackTrace();
        tcd.clean();
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
예제 #8
0
 @Test
 public void getBoolFalseOther() throws Exception {
   final Config config = new Config();
   config.overrideConfig("asynchbase.bool", "blarg");
   assertFalse(config.getBoolean("asynchbase.bool"));
 }
예제 #9
0
 @Test
 public void getBoolFalseDoesNotExist() throws Exception {
   final Config config = new Config();
   assertFalse(config.getBoolean("asynchbase.nosuchkey"));
 }
예제 #10
0
 @Test(expected = NullPointerException.class)
 public void getBoolFalseNull() throws Exception {
   final Config config = new Config();
   config.overrideConfig("asynchbase.null", null);
   config.getBoolean("asynchbase.null");
 }
예제 #11
0
 @Test
 public void getBoolYesCaseInsensitive() throws Exception {
   final Config config = new Config();
   config.overrideConfig("asynchbase.bool", "YeS");
   assertTrue(config.getBoolean("asynchbase.bool"));
 }
예제 #12
0
 @Test
 public void getBool1() throws Exception {
   final Config config = new Config();
   config.overrideConfig("asynchbase.bool", "1");
   assertTrue(config.getBoolean("asynchbase.bool"));
 }