コード例 #1
0
  public void count_bip_exits(String hostname) {
    int[] pos;

    pos = (int[]) mbips.get(hostname);
    if (pos == null) {
      pos = make_int_array(MBIPS_NUM_POS);
      mbips.put(hostname, pos);
    }

    ++pos[MBIPS_BIPS_EXITTED_POS];
    return;
  }
コード例 #2
0
ファイル: Note.java プロジェクト: dcboutte/guitar-logic
  public static Map<String, String[]> fillMap() {

    // HashMap to keep track of each notes intervals and neighboring notes
    Map<String, String[]> intervals = new HashMap<String, String[]>();

    // Array of all possible notes
    String[] allNotes = {"A", "A#", "B", "C", "C#", "D", "D#", "E", "F", "G", "G#"};

    // Loop through every note and populate our hash map
    for (String i : allNotes) {
      intervals.put(i, new String[4]);
    }
    ;

    // Update the map so all notes are covered
    intervals.put("A", new String[] {"1", "1", "B", "G"});
    intervals.put("B", new String[] {"0.5", "1", "C", "A"});
    intervals.put("C", new String[] {"1", "0.5", "D", "B"});
    intervals.put("D", new String[] {"1", "1", "E", "C"});
    intervals.put("E", new String[] {"0.5", "1", "F", "D"});
    intervals.put("F", new String[] {"1", "0.5", "G", "E"});
    intervals.put("G", new String[] {"1", "1", "A", "F"});

    return intervals;
  }
コード例 #3
0
  public void count_account_stat(String hostname, AccountStatisticReturnVal acstat) {
    double[] pos;

    pos = (double[]) mtimes.get(hostname);
    if (pos == null) {
      pos = make_double_array(MTIMES_NUM_POS);
      mtimes.put(hostname, pos);
    }

    pos[MTIMES_CPU_TIME_POS] += acstat.get_cpu_time();
    pos[MTIMES_WALL_TIME_POS] += acstat.get_wall_time();
    return;
  }
コード例 #4
0
ファイル: DBFactoryTree.java プロジェクト: tedvals/fleetmng
 /** ** Returns an OrderedMap of defined primary keys ** @return map of defined primary keys */
 public Map<DBField, Object> getKeyMap() {
   Map<DBField, Object> keyMap = new OrderedMap<DBField, Object>(); // ordered key list
   if (this.dbFactory != null) {
     DBField keyField[] = this.dbFactory.getKeyFields();
     for (int i = 0; i < keyField.length; i++) {
       String key = keyField[i].getName();
       Object val = null;
       if (this.dbRecord != null) {
         // all key values will be defined
         val = this.dbRecord.getFieldValue(key);
       } else {
         // use parent keys
         DBFactoryTree parent = this.getParentNode();
         for (; (parent != null) && (val == null); parent = parent.getParentNode()) {
           DBRecord dbr = parent.getDBRecord();
           if (dbr == null) {
             // stop at the first undefined ancestor
             break;
           } else if (dbr.hasField(key)) {
             // try getting key value from ancestor
             DBField parFld = dbr.getField(key);
             if ((parFld != null) && parFld.isPrimaryKey()) {
               // primary key fields only
               val = dbr.getFieldValue(key);
             }
           }
         }
       }
       // save key DBField and value
       if (val != null) {
         keyMap.put(keyField[i], val);
       } else {
         keyMap.put(keyField[i], null);
       }
     }
   }
   return keyMap;
 }
コード例 #5
0
  public boolean convalida() {
    boolean tuttoOk = true;
    Map<String, String> errori = new HashMap<String, String>();

    if ((nome == null) || nome.equals("")) {
      tuttoOk = false;
      request.setAttribute("nome", nome);
      errori.put("nome", "campo obbligatorio");
    }

    if ((descrizione == null) || descrizione.equals("")) {
      tuttoOk = false;
      request.setAttribute("descrizione", descrizione);
      errori.put("descrizione", "campo obbligatorio");
    }

    if ((codice == null) || codice.equals("")) {
      tuttoOk = false;
      request.setAttribute("codice", codice);
      errori.put("codice", "campo obbligatorio");
    }

    if (!isInteger(disponibilita)) {
      tuttoOk = false;
      request.setAttribute("disponibilita", disponibilita);
      errori.put("disponibilita", "formato non valido");
    }

    if (!isInteger(prezzo)) {
      tuttoOk = false;
      request.setAttribute("prezzo", prezzo);
      errori.put("prezzo", "formato non valido");
    }
    if (!tuttoOk) request.setAttribute("errori", errori);
    HttpSession sess = request.getSession();
    sess.setAttribute("errori", errori);
    return tuttoOk;
  }
コード例 #6
0
  /**
   * When scanning a robot we need to add it to the collection of scanned objects so it can be used
   * later for updates to the bots movement.
   */
  public void onScannedRobot(ScannedRobotEvent e) {
    double targetBearing = getHeading() + e.getBearing();
    double tmpX = getX() + e.getDistance() * Math.sin(Math.toRadians(targetBearing));
    double tmpY = getY() + e.getDistance() * Math.cos(Math.toRadians(targetBearing));
    String name = e.getName();

    if (name.equals(GOAL_NAME)) {
      foundGoal = true;
    }

    obstacles.put(name, new Enemy(tmpX, tmpY, e.getBearing()));

    setTurnRadarRight(getRadarTurnRemaining());
  }
コード例 #7
0
 @RequestMapping(value = CLIENT_HEARTBEAT_PATH)
 public @ResponseBody int heartBeat(
     @RequestParam(value = "username") String uName, HttpServletResponse response) {
   try {
     if (!user_vidNameMap.containsKey(uName)) {
       response.setStatus(402); // client not connected
       return 0;
     }
     userAliveMap.put(uName, new Long(System.currentTimeMillis() + TTL));
     return TTL;
   } catch (Exception e) {
     System.err.println(e.getMessage());
     return FAILED;
   }
 }
コード例 #8
0
  @RequestMapping(value = CLIENT_CONNECT_PATH, method = RequestMethod.POST)
  public @ResponseBody int connectClient(@RequestBody String allVid) {
    try {
      int reply = FAILED;
      String[] videos = allVid.split(",");
      String uName = videos[0].trim();
      videos = java.util.Arrays.copyOfRange(videos, 1, videos.length);
      // System.out.println("Client connect"+hostAdder+" "+uName+" "+ Arrays.asList(videos));
      int ans = masterService.psConnectClient(hostAdder, uName, videos);
      // System.out.println("ans =" +ans +" "+FAILED);
      while (ans == PS_NOT_CONNECTED) {
        reconnectToMS();
        ans = masterService.psConnectClient(hostAdder, uName, videos);
      }
      if (ans == FAILED) return FAILED;
      // System.out.println("Clinet "+ uName + " connected");

      if (user_vidNameMap.containsKey(uName)) {
        reply = CLIENT_ALREADY_CONNECTED;
      } else {
        reply = CLIENT_CONNECTED;
        user_vidNameMap.put(uName, new HashSet<String>());
      }
      // System.out.println("Clinet "+ uName + " connected");

      Set<String> vidSet = user_vidNameMap.get(uName);
      for (int i = 0; i < videos.length; i++) {
        String temp = videos[i].trim();
        // System.out.println("add video");

        if (!temp.equals("")) {
          vidSet.add(temp);
          addTovidName_UserMap(uName, temp);
        }
      }
      // System.out.println("Clinet "+ uName + " connected");

      userAliveMap.put(uName, new Long(System.currentTimeMillis() + TTL));
      // System.out.println("Clinet "+ uName + " connected");

      activeUsers.add(uName);
      System.out.println("Clinet " + uName + " connected");
      return reply;
    } catch (Exception e) {
      System.out.println("Error: " + e.getMessage());
      return FAILED;
    }
  }
コード例 #9
0
ファイル: ZigBee.java プロジェクト: rossbiro/Arduino
  void updateAddress64(long address64) {
    synchronized (this) {
      if (serialNumber != null && serialNumber.longValue() == address64) {
        return;
      }

      if (serialNumber != null) {
        knownNodes.remove(serialNumber);
      }

      if (address64 != -1 && address64 != 0) {
        serialNumber = new Long(address64);
        knownNodes.put(serialNumber, this);
        sendMessage("SERIALNO");
        sendStaticMessage("SERIALNO");
      }
    }
  }
コード例 #10
0
  /** ** Add SMS Gateway support provider */
  public static void AddSMSGateway(String name, SMSOutboundGateway smsGW) {

    /* validate name */
    if (StringTools.isBlank(name)) {
      Print.logWarn("SMS Gateway name is blank");
      return;
    } else if (smsGW == null) {
      Print.logWarn("SMS Gateway handler is null");
      return;
    }

    /* initialize map? */
    if (SmsGatewayHandlerMap == null) {
      SmsGatewayHandlerMap = new HashMap<String, SMSOutboundGateway>();
    }

    /* save handler */
    SmsGatewayHandlerMap.put(name.toLowerCase(), smsGW);
    Print.logDebug("Added SMS Gateway Handler: " + name);
  }
コード例 #11
0
ファイル: ZigBee.java プロジェクト: rossbiro/Arduino
  // Doesn't check the argument is appropriate for the command.
  // Using Number won't handle -0 properly.
  // Also won't handle packets longer than 32k properly.
  public byte[] buildLocalCommand(Command c, byte api, String command, Object argument)
      throws ZigBeeException {
    int length = getArgumentLength(argument) + 6 + command.length();
    byte[] packet = new byte[length];
    packet[0] = 0x7e;
    packet[1] = intToByte((length - 4) >> 8);
    packet[2] = intToByte(length - 4);
    packet[3] = api;
    packet[4] = ++currentId;
    synchronized (outstandingCommands) {
      outstandingCommands.put(currentId, c);
    }

    for (int i = 0; i < command.length(); ++i) {
      packet[5 + i] = (byte) command.charAt(i);
    }
    putArgumentBytes(packet, 5 + command.length(), argument);
    computeChecksum(packet);
    return packet;
  }
コード例 #12
0
  private void startUpload(int index) {
    if (NavigineApp.Navigation == null) return;

    String userHash = NavigineApp.Settings.getString("user_hash", "");
    if (userHash.length() == 0) return;

    LocationInfo info = mInfoList.get(index);
    String location = new String(info.title);
    Log.d(TAG, String.format(Locale.ENGLISH, "Start upload: %s", location));

    synchronized (mLoaderMap) {
      if (!mLoaderMap.containsKey(location)) {
        LoaderState loader = new LoaderState();
        loader.location = location;
        loader.type = UPLOAD;
        loader.id = LocationLoader.startLocationUploader(location, info.archiveFile, true);
        mLoaderMap.put(location, loader);
      }
    }
    mAdapter.updateList();
  }
コード例 #13
0
ファイル: ZigBee.java プロジェクト: rossbiro/Arduino
  // Doesn't check the argument is appropriate for the command.
  // Using Number won't handle -0 properly.
  // Also won't handle packets longer than 32k properly.
  public byte[] buildRemoteCommand(Command c, byte api, String command, Object argument)
      throws ZigBeeException {
    synchronized (this) { // don't want something to change while we are building the command.
      int length = getArgumentLength(argument) + 17 + command.length(); // Address is 10 bytes
      byte[] packet = new byte[length];
      packet[0] = 0x7e;
      packet[1] = intToByte((length - 4) >> 8);
      packet[2] = intToByte(length - 4);
      packet[3] = api;
      packet[4] = ++currentId;
      synchronized (outstandingCommands) {
        outstandingCommands.put(currentId, c);
      }

      if (currentId == -1) {
        // never assing id 0 to a packet. it means no id.
        currentId = 0;
      }
      putAddress64(packet, 5, serialNumber);
      if (address == null) {
        putAddress16(packet, 13, (short) -2);
      } else {
        putAddress16(packet, 13, address);
      }

      if (c.command == ZigBeeCommands.AC) {
        packet[15] = 0x2; // apply changes.
      } else {
        packet[15] = 0x0;
      }

      for (int i = 0; i < command.length(); ++i) {
        packet[16 + i] = (byte) command.charAt(i);
      }

      putArgumentBytes(packet, 16 + command.length(), argument);
      computeChecksum(packet);
      return packet;
    }
  }