Example #1
1
 /**
  * Starts a native process on the server
  *
  * @param command the command to start the process
  * @param dir the dir in which the process starts
  */
 static String startProcess(String command, String dir) throws IOException {
   StringBuffer ret = new StringBuffer();
   String[] comm = new String[3];
   comm[0] = COMMAND_INTERPRETER[0];
   comm[1] = COMMAND_INTERPRETER[1];
   comm[2] = command;
   long start = System.currentTimeMillis();
   try {
     // Start process
     Process ls_proc = Runtime.getRuntime().exec(comm, null, new File(dir));
     // Get input and error streams
     BufferedInputStream ls_in = new BufferedInputStream(ls_proc.getInputStream());
     BufferedInputStream ls_err = new BufferedInputStream(ls_proc.getErrorStream());
     boolean end = false;
     while (!end) {
       int c = 0;
       while ((ls_err.available() > 0) && (++c <= 1000)) {
         ret.append(conv2Html(ls_err.read()));
       }
       c = 0;
       while ((ls_in.available() > 0) && (++c <= 1000)) {
         ret.append(conv2Html(ls_in.read()));
       }
       try {
         ls_proc.exitValue();
         // if the process has not finished, an exception is thrown
         // else
         while (ls_err.available() > 0) ret.append(conv2Html(ls_err.read()));
         while (ls_in.available() > 0) ret.append(conv2Html(ls_in.read()));
         end = true;
       } catch (IllegalThreadStateException ex) {
         // Process is running
       }
       // The process is not allowed to run longer than given time.
       if (System.currentTimeMillis() - start > MAX_PROCESS_RUNNING_TIME) {
         ls_proc.destroy();
         end = true;
         ret.append("!!!! Process has timed out, destroyed !!!!!");
       }
       try {
         Thread.sleep(50);
       } catch (InterruptedException ie) {
       }
     }
   } catch (IOException e) {
     ret.append("Error: " + e);
   }
   return ret.toString();
 }
  public static void main(String args[]) throws Exception {
    long begin, end;

    begin = System.currentTimeMillis();

    String logConfig = System.getProperty("log-config");
    if (logConfig == null) logConfig = "log-config.txt";

    PropertyConfigurator.configure(logConfig);

    if (args.length != 6) {
      System.err.println(
          "java -mx512M org.itc.irst.tcc.sre.util.StatisticalSignificance gold baseline preferred iterations confidence-level stat");
      System.exit(0);
    }

    String g = args[0];
    String b = args[1];
    String p = args[2];
    int n = Integer.parseInt(args[3]);
    double c = Double.parseDouble(args[4]);
    String s = args[5];
    new StatisticalSignificance(new File(g), new File(b), new File(p), n, c, s);

    //
    end = System.currentTimeMillis();
    logger.info("evaluation done in " + (end - begin) + " ms");
  } // end main
 /**
  * This method runs the Runnable and measures how long it takes.
  *
  * @param r is the Runnable for the task that we want to measure
  * @return the time it took to execute this task
  */
 public static long time(Runnable r) {
   long time = -System.currentTimeMillis();
   r.run();
   time += System.currentTimeMillis();
   System.out.println("Took " + time + "ms");
   return time;
 }
 // BEGIN KAWIGIEDIT TESTING
 // Generated by KawigiEdit-pf 2.3.0
 private static boolean KawigiEdit_RunTest(int testNum, int p0, boolean hasAnswer, int p1) {
   System.out.print("Test " + testNum + ": [" + p0);
   System.out.println("]");
   EmoticonsDiv1 obj;
   int answer;
   obj = new EmoticonsDiv1();
   long startTime = System.currentTimeMillis();
   answer = obj.printSmiles(p0);
   long endTime = System.currentTimeMillis();
   boolean res;
   res = true;
   System.out.println("Time: " + (endTime - startTime) / 1000.0 + " seconds");
   if (hasAnswer) {
     System.out.println("Desired answer:");
     System.out.println("\t" + p1);
   }
   System.out.println("Your answer:");
   System.out.println("\t" + answer);
   if (hasAnswer) {
     res = answer == p1;
   }
   if (!res) {
     System.out.println("DOESN'T MATCH!!!!");
   } else if ((endTime - startTime) / 1000.0 >= 2) {
     System.out.println("FAIL the timeout");
     res = false;
   } else if (hasAnswer) {
     System.out.println("Match :-)");
   } else {
     System.out.println("OK, but is it right?");
   }
   System.out.println("");
   return res;
 }
 // BEGIN KAWIGIEDIT TESTING
 // Generated by KawigiEdit 2.1.8 (beta) modified by pivanof
 private static boolean KawigiEdit_RunTest(
     int testNum, int p0, int p1, boolean hasAnswer, String p2) {
   System.out.print("Test " + testNum + ": [" + p0 + "," + p1);
   System.out.println("]");
   KLastNonZeroDigits obj;
   String answer;
   obj = new KLastNonZeroDigits();
   long startTime = System.currentTimeMillis();
   answer = obj.getKDigits(p0, p1);
   long endTime = System.currentTimeMillis();
   boolean res;
   res = true;
   System.out.println("Time: " + (endTime - startTime) / 1000.0 + " seconds");
   if (hasAnswer) {
     System.out.println("Desired answer:");
     System.out.println("\t" + "\"" + p2 + "\"");
   }
   System.out.println("Your answer:");
   System.out.println("\t" + "\"" + answer + "\"");
   if (hasAnswer) {
     res = answer.equals(p2);
   }
   if (!res) {
     System.out.println("DOESN'T MATCH!!!!");
   } else if ((endTime - startTime) / 1000.0 >= 2) {
     System.out.println("FAIL the timeout");
     res = false;
   } else if (hasAnswer) {
     System.out.println("Match :-)");
   } else {
     System.out.println("OK, but is it right?");
   }
   System.out.println("");
   return res;
 }
 // BEGIN KAWIGIEDIT TESTING
 // Generated by KawigiEdit 2.1.4 (beta) modified by pivanof
 private static boolean KawigiEdit_RunTest(
     int testNum, int[] p0, int[] p1, int[] p2, boolean hasAnswer, int p3) {
   System.out.print("Test " + testNum + ": [" + "{");
   for (int i = 0; p0.length > i; ++i) {
     if (i > 0) {
       System.out.print(",");
     }
     System.out.print(p0[i]);
   }
   System.out.print("}" + "," + "{");
   for (int i = 0; p1.length > i; ++i) {
     if (i > 0) {
       System.out.print(",");
     }
     System.out.print(p1[i]);
   }
   System.out.print("}" + "," + "{");
   for (int i = 0; p2.length > i; ++i) {
     if (i > 0) {
       System.out.print(",");
     }
     System.out.print(p2[i]);
   }
   System.out.print("}");
   System.out.println("]");
   KeyDungeonDiv2 obj;
   int answer;
   obj = new KeyDungeonDiv2();
   long startTime = System.currentTimeMillis();
   answer = obj.countDoors(p0, p1, p2);
   long endTime = System.currentTimeMillis();
   boolean res;
   res = true;
   System.out.println("Time: " + (endTime - startTime) / 1000.0 + " seconds");
   if (hasAnswer) {
     System.out.println("Desired answer:");
     System.out.println("\t" + p3);
   }
   System.out.println("Your answer:");
   System.out.println("\t" + answer);
   if (hasAnswer) {
     res = answer == p3;
   }
   if (!res) {
     System.out.println("DOESN'T MATCH!!!!");
   } else if ((endTime - startTime) / 1000.0 >= 2) {
     System.out.println("FAIL the timeout");
     res = false;
   } else if (hasAnswer) {
     System.out.println("Match :-)");
   } else {
     System.out.println("OK, but is it right?");
   }
   System.out.println("");
   return res;
 }
Example #7
0
 private void setTick(Info info, String time) {
   int addon = 0;
   try {
     addon = Integer.parseInt(time);
   } catch (NumberFormatException e) {
     info.sendMessage(
         "Format exception.  Command should be !setTick # where # is the number of minutes till the next tick.");
   }
   tickSetter = info.getSender();
   tickTime = System.currentTimeMillis();
   OFFSET = (Utils.getRealMinutes(info) + addon) % 15;
   info.sendMessage("Tick set to " + OFFSET + " minutes off.");
 }
Example #8
0
 private void chkFPS() {
   if (fpsCount == 0) {
     fpsTime = System.currentTimeMillis() / 1000;
     fpsCount++;
     return;
   }
   fpsCount++;
   long time = System.currentTimeMillis() / 1000;
   if (time != fpsTime) {
     lastFPS = fpsCount;
     fpsCount = 1;
     fpsTime = time;
   }
 }
  public static void main(String[] args) {
    long start = System.currentTimeMillis();
    Scanner input = new Scanner(System.in);
    int numberOfTestCases = input.nextInt();
    ArrayList<Integer> order = new ArrayList<Integer>(numberOfTestCases);
    int previousKey = -1;
    int previousValue = 0;
    int cycleNumber = 0;

    Map<Integer, Integer> testCases = new TreeMap<Integer, Integer>();

    for (int i = 0; i < numberOfTestCases; i++) {
      int numberOfCycles = input.nextInt();
      testCases.put(numberOfCycles, 1);
      order.add(numberOfCycles);
    }

    for (Map.Entry<Integer, Integer> entry : testCases.entrySet()) {
      int numberOfCycles;
      int initialHeight;

      if (previousKey == -1) {
        numberOfCycles = entry.getKey();
        initialHeight = entry.getValue();
      } else {
        numberOfCycles = entry.getKey() - previousKey;
        initialHeight = previousValue;
      }

      for (int i = 0; i < numberOfCycles; i++) {
        if (cycleNumber % 2 == 0) {
          initialHeight *= 2;
        } else {
          initialHeight += 1;
        }
        cycleNumber++;
      }

      entry.setValue(initialHeight);
      previousKey = entry.getKey();
      previousValue = initialHeight;
    }

    for (Integer element : order) {
      System.out.println(testCases.get(element));
    }

    long elapsed = System.currentTimeMillis() - start;
    System.out.println("time: " + elapsed);
  }
Example #10
0
  /**
   * Statically analyze a query for various properties.
   *
   * @param query the query to analyze
   * @param params parameters for the query; if necessary parameters are left out they will be
   *     listed as required variables in the analysis
   * @return a query analysis facet
   */
  public QueryAnalysis analyze(String query, Object... params) {
    if (presub) query = presub(query, params);

    long t1 = System.currentTimeMillis(), t2 = 0, t3 = 0;
    DBBroker broker = null;
    try {
      broker = db.acquireBroker();
      prepareContext(broker);
      final org.exist.source.Source source = buildQuerySource(query, params, "analyze");
      final XQuery xquery = broker.getXQueryService();
      final XQueryPool pool = xquery.getXQueryPool();
      CompiledXQuery compiledQuery = pool.borrowCompiledXQuery(broker, source);
      try {
        AnalysisXQueryContext context;
        if (compiledQuery == null) {
          context = new AnalysisXQueryContext(broker, AccessContext.INTERNAL_PREFIX_LOOKUP);
          buildXQueryStaticContext(context, false);
          buildXQueryDynamicContext(context, params, null, false);
          t2 = System.currentTimeMillis();
          compiledQuery = xquery.compile(context, source);
          t3 = System.currentTimeMillis();
        } else {
          context = (AnalysisXQueryContext) compiledQuery.getContext();
          t2 = System.currentTimeMillis();
        }
        return new QueryAnalysis(
            compiledQuery,
            Collections.unmodifiableSet(context.requiredVariables),
            Collections.unmodifiableSet(context.requiredFunctions));
      } finally {
        if (compiledQuery != null) pool.returnCompiledXQuery(source, compiledQuery);
      }
    } catch (XPathException e) {
      LOG.warn(
          "query compilation failed --  "
              + query
              + "  -- "
              + (params == null ? "" : " with params " + Arrays.asList(params))
              + (bindings.isEmpty() ? "" : " and bindings " + bindings));
      throw new DatabaseException("failed to compile query", e);
    } catch (IOException e) {
      throw new DatabaseException("unexpected exception", e);
    } catch (PermissionDeniedException e) {
      throw new DatabaseException("permission denied", e);
    } finally {
      db.releaseBroker(broker);
      STATS.update(query, t1, t2, t3, 0, System.currentTimeMillis());
    }
  }
 // BEGIN KAWIGIEDIT TESTING
 // Generated by KawigiEdit-pf 2.3.0
 private static boolean KawigiEdit_RunTest(
     int testNum, int[] p0, int[] p1, boolean hasAnswer, double p2) {
   System.out.print("Test " + testNum + ": [" + "{");
   for (int i = 0; p0.length > i; ++i) {
     if (i > 0) {
       System.out.print(",");
     }
     System.out.print(p0[i]);
   }
   System.out.print("}" + "," + "{");
   for (int i = 0; p1.length > i; ++i) {
     if (i > 0) {
       System.out.print(",");
     }
     System.out.print(p1[i]);
   }
   System.out.print("}");
   System.out.println("]");
   GreaterGame obj;
   double answer;
   obj = new GreaterGame();
   long startTime = System.currentTimeMillis();
   answer = obj.calc(p0, p1);
   long endTime = System.currentTimeMillis();
   boolean res;
   res = true;
   System.out.println("Time: " + (endTime - startTime) / 1000.0 + " seconds");
   if (hasAnswer) {
     System.out.println("Desired answer:");
     System.out.println("\t" + p2);
   }
   System.out.println("Your answer:");
   System.out.println("\t" + answer);
   if (hasAnswer) {
     res = answer == answer && Math.abs(p2 - answer) <= 1e-9 * Math.max(1.0, Math.abs(p2));
   }
   if (!res) {
     System.out.println("DOESN'T MATCH!!!!");
   } else if ((endTime - startTime) / 1000.0 >= 2) {
     System.out.println("FAIL the timeout");
     res = false;
   } else if (hasAnswer) {
     System.out.println("Match :-)");
   } else {
     System.out.println("OK, but is it right?");
   }
   System.out.println("");
   return res;
 }
Example #12
0
 public String getUprate() {
   long time = System.currentTimeMillis() - starttime;
   if (time != 0) {
     long uprate = currSize * 1000 / time;
     return convertFileSize(uprate) + "/s";
   } else return "n/a";
 }
Example #13
0
 public String getTimeElapsed() {
   long time = (System.currentTimeMillis() - starttime) / 1000l;
   if (time - 60l >= 0) {
     if (time % 60 >= 10) return time / 60 + ":" + (time % 60) + "m";
     else return time / 60 + ":0" + (time % 60) + "m";
   } else return time < 10 ? "0" + time + "s" : time + "s";
 }
  public void getValues(long[] values) {
    values[0] = (long) (scalingFactor * getLatitude());
    values[1] = (long) (scalingFactor * getLongitude());
    values[2] = (long) (scalingFactor * getHeading());

    values[3] = System.currentTimeMillis();
  }
  /**
   * Sets the time in milliseconds of the last activity related to this <tt>Conference</tt> to the
   * current system time.
   */
  public void touch() {
    long now = System.currentTimeMillis();

    synchronized (this) {
      if (getLastActivityTime() < now) lastActivityTime = now;
    }
  }
Example #16
0
 private void tick(Info info) {
   if (Utils.shouldDefer(info)) return;
   // else
   if (OFFSET == -1) {
     info.sendMessage(
         "Tick not sychronized yet. Wait for the next tick and execute /msg "
             + info.getBot().getName()
             + " !setTickor find out how long until the next tick and execute /msg "
             + info.getBot().getName()
             + " !setTick <mins>");
     return;
   }
   int timeRemaining = 15 - ((15 + Utils.getRealMinutes(info) - OFFSET) % 15);
   long daysSinceSet = (System.currentTimeMillis() - tickTime) / (1000 * 60 * 60 * 24);
   info.sendMessage(
       timeRemaining + " minutes until the next tick (last set " + daysSinceSet + " days ago)");
 }
Example #17
0
    public abstract static class Message {
      public final long time = System.currentTimeMillis();

      public abstract Text text();

      public abstract Tex tex();

      public abstract Coord sz();
    }
Example #18
0
 public static void main(String[] args) throws IOException {
   //		in = new BufferedReader(new InputStreamReader(System.in));
   //		out = new PrintWriter(new BufferedOutputStream(System.out));
   String file = "C-large";
   in = new BufferedReader(new FileReader(file + ".in"));
   out = new PrintWriter(new FileOutputStream(file + "_" + System.currentTimeMillis() + ".out"));
   solve();
   out.flush();
 }
Example #19
0
 public SimulationResults() {
   mResultsDateTime = new Date(System.currentTimeMillis());
   mSimulatorAlias = null;
   mSimulatorParameters = null;
   mResultsSymbolNames = null;
   mResultsTimeValues = null;
   mResultsSymbolValues = null;
   mResultsFinalSymbolFluctuations = null;
   mModelName = null;
 }
Example #20
0
 public String getTimeEstimated() {
   if (currSize == 0) return "n/a";
   long time = System.currentTimeMillis() - starttime;
   time = totalSize * time / currSize;
   time /= 1000l;
   if (time - 60l >= 0) {
     if (time % 60 >= 10) return time / 60 + ":" + (time % 60) + "m";
     else return time / 60 + ":0" + (time % 60) + "m";
   } else return time < 10 ? "0" + time + "s" : time + "s";
 }
Example #21
0
  public static void tdsp() {
    // node list used for store path
    ArrayList<Long> pathNodeList = new ArrayList<Long>();

    // test start end node
    // OSMOutput.generateStartEndlNodeKML(START_NODE, END_NODE, nodeHashMap);
    // test count time
    long begintime = System.currentTimeMillis();

    LocationInfo startLoc = new LocationInfo(OSMRouteParam.START_LAT, OSMRouteParam.START_LON);
    LocationInfo endLoc = new LocationInfo(OSMRouteParam.END_LAT, OSMRouteParam.END_LON);
    NodeInfo start = startLoc.searchNode();
    NodeInfo end = endLoc.searchNode();

    double cost;
    // routing using A* algorithm with priority queue
    // cost = routingAStar(start.getNodeId(), end.getNodeId(), OSMRouteParam.START_TIME,
    // OSMRouteParam.DAY_INDEX, pathNodeList);

    // routing using A* algorithm with fibonacci heap
    // cost = routingAStarFibonacci(start.getNodeId(), end.getNodeId(), OSMRouteParam.START_TIME,
    // OSMRouteParam.DAY_INDEX, pathNodeList);

    // routing using bidirectional hierarchy search
    cost =
        routingHierarchy(
            start.getNodeId(),
            end.getNodeId(),
            OSMRouteParam.START_TIME,
            OSMRouteParam.DAY_INDEX,
            pathNodeList);

    long endtime = System.currentTimeMillis();
    long response = (endtime - begintime);
    System.out.println("routing cost: " + cost + " s, response time: " + response + " ms");

    // output kml
    OSMOutput.generatePathKML(pathNodeList);
    // OSMOutput.generatePathNodeKML(pathNodeList);

    String turnByTurn = turnByTurn(pathNodeList);
    System.out.println(turnByTurn);
  }
 private int checkMobileBuffer(String mobile, String msg) {
   long currTime = System.currentTimeMillis() / 1000; // secs
   int currDay = getDay(System.currentTimeMillis());
   MobileBufferInfo info = MobileBuffer.lookup(mobile);
   if (info == null) { // not exist --> create new
     MobileBuffer.add(mobile, new MobileBufferInfo(mobile, currTime, 0, 1, 0, 0, msg));
     return 1; // OK
   }
   // EXIST --> update
   int result = 0;
   long lastTime = info.mo_Time;
   if (lastTime <= 0) { // added by MT thread (no MO before) --> update
     info.mo_Counter = 1; // first MO
     result = 1; // OK
   } else if (currDay != getDay(lastTime * 1000)) { // new day/date
     // //////////////////////////////////////////////////////////
     // /////// CLEAR BUFFER FOR PREVIOUS DAY ////////////////////
     MobileBuffer.clearAll();
     // //////////////////////////////////////////////////////////
     result = 1; // OK
   } else {
     info.mo_Counter++;
     // DKTRUNG 0904098489 Check spam
     if ((currTime - lastTime) < Constants.MIN_TIME_BETWEEN_MO && msg.equals(info.msg)) {
       result = 2; // send too fast
     } else if (info.mo_Counter >= Constants.MAX_MO_PER_DAY) {
       // reach max value --> send inform to user
       result = info.mo_Counter;
       // } else if (info.mo_Counter > Constants.MAX_MO_PER_DAY) {
       // send too many
       // result = info.mo_Counter;
     } else {
       result = 1; // OK
     }
   }
   if (result <= 1) {
     info.msg = msg;
     info.mo_Time = currTime;
     MobileBuffer.update(mobile, info);
   }
   return result;
 }
  /**
   * Main program.
   *
   * <p>\u0040param args Program parameters.
   */
  public static void main(String[] args) {
    //  Initialize.
    try {
      if (!initialize(args)) {
        System.exit(1);
      }
      //  Process all files.

      long startTime = System.currentTimeMillis();

      int filesProcessed = processFiles(args);

      long processingTime = (System.currentTimeMillis() - startTime + 999) / 1000;

      //  Terminate.

      terminate(filesProcessed, processingTime);
    } catch (Exception e) {
      System.out.println(e.getMessage());
    }
  }
Example #24
0
  private class Notification {
    public final Channel chan;
    public final Text chnm;
    public final Channel.Message msg;
    public final long time = System.currentTimeMillis();

    private Notification(Channel chan, Channel.Message msg) {
      this.chan = chan;
      this.msg = msg;
      this.chnm = chansel.nf.render(chan.name(), Color.WHITE);
    }
  }
  private void saveData(TelemetryData data) {
    PrintWriter out;
    boolean newFile = false;

    if (saveCnt > 25000) {
      File logFile;
      int i;

      logFile = new File(telemetryDir + 99 + ".log");
      logFile.delete();
      newFile = true;

      for (i = 99; i > 0; i--) {
        logFile = new File(telemetryDir + (i - 1) + ".log");
        logFile.renameTo(new File(telemetryDir + i + ".log"));
      }
      saveCnt = 0;
    }

    try {
      String text = "";
      SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.GERMAN);

      saveCnt++;
      out = new PrintWriter(new FileOutputStream(telemetryDir + "0.log", true));
      if (newFile) {
        text =
            "Time\tLatitude\tLongitude\tSpeed\tAcceleration X\tAcceleration Y\tAcceleration Z\tCoG\tOrientation Y\tOrientation Z\n\n";
        out.print(text);
      }
      text = dateFormat.format(new Date(System.currentTimeMillis())) + "\t";
      if (posValid) text = text + lastLat + "\t" + lastLon + "\t" + m_lastSpeed + "\t";
      else text = text + "-\t-\t-\t";
      text =
          text
              + data.getAccelX()
              + "\t"
              + data.getAccelY()
              + "\t"
              + data.getAccelZ()
              + "\t"
              + data.CoG
              + "\t"
              + data.getOrientY()
              + "\t"
              + data.getOrientZ()
              + "\n\n";
      out.print(text);
      out.close();
    } catch (IOException ioe) {
    }
  }
  public void onSensorChanged(SensorEvent event) {
    synchronized (this) {
      switch (event.sensor.getType()) {
        case Sensor.TYPE_ACCELEROMETER:
          scanData.getTelemetryData().addAccel(event.values[0], event.values[1], event.values[2]);
          break;
        case Sensor.TYPE_ORIENTATION:
          scanData.getTelemetryData().addOrient(event.values[0], event.values[1], event.values[2]);
          break;
      }
      if (lastTelemetryTime == 0) lastTelemetryTime = System.currentTimeMillis();
      else if (System.currentTimeMillis() - lastTelemetryTime > 750) {
        TelemetryData submitData = new TelemetryData();

        submitData.set(scanData.getTelemetryData());
        if (scanData.isStoreTele()) saveData(submitData);
        scanData.getTelemetryData().reset();
        OWMapAtAndroid.sendMessage(OWMapAtAndroid.ScannerHandler.MSG_TELEMETRY, 0, 0, submitData);
        lastTelemetryTime = System.currentTimeMillis();
      }
    }
  }
Example #27
0
 public NodeInfo(Integer pNodeNumber) {
   packetTimesPointer = 0;
   packetSkipsPointer = 0;
   neighbors = new NeighborInfo[5];
   for (int i = 0; i < 5; i++) neighbors[i] = new NeighborInfo();
   packetTimes = new long[SensorAnalyzer.HISTORY_LENGTH];
   packetSkips = new long[SensorAnalyzer.HISTORY_LENGTH];
   yieldHistory = new double[SensorAnalyzer.YIELD_HISTORY_LENGTH];
   depthHistory = new byte[SensorAnalyzer.YIELD_HISTORY_LENGTH];
   lastTime = System.currentTimeMillis() - 500;
   nodeNumber = pNodeNumber;
   value = -1; // if it doesn't change from this value nothing will be written
   infoString = "[none]";
 }
Example #28
0
 public Contribution(
     Uri localUri,
     String remoteUri,
     String filename,
     String description,
     long dataLength,
     Date dateCreated,
     Date dateUploaded,
     String creator,
     String editSummary) {
   super(
       localUri, remoteUri, filename, description, dataLength, dateCreated, dateUploaded, creator);
   this.editSummary = editSummary;
   timestamp = new Date(System.currentTimeMillis());
 }
  // =====================================================
  // setEXIFpictureMetadaten()
  //
  // Aus dem Image-Original werden die EXIF-Daten f�r die
  // PM_PictureMetadatenX geholt und eingetragen
  // =====================================================
  public static void setEXIFpictureMetadaten(PM_Picture picture) {

    PM_PictureImageMetadaten imageMetadaten = picture.getImageMetadaten();

    // ----------------------------------------------------
    // FujiFilm Makernote:  SequenceNummer --> virtPicture
    // ----------------------------------------------------

    // -------------------------------------------------------
    // Date
    // ------------------------------------------------------

    String tagDatum = "Date/Time Original";
    String description = "";
    if (imageMetadaten.hasTag(tagDatum)) {
      description = imageMetadaten.getDescription(tagDatum);
    }

    // ----------------------------------------------------
    // Datum nicht vorhanden oder ung�ltig
    // ----------------------------------------------------
    Date myDate = null;
    if (description.length() == 0 || description.equals("0000:00:00 00:00:00")) {
      //			  System.out.println("......  Datum = " + description + " kann nicht konvertiert
      // werden");
      File f = picture.getFileOriginal();
      Date date = new Date(f.lastModified());
      picture.meta.setDateImport(date);
      picture.meta.setDateCurrent(new Date(date.getTime()));
      return;
    }

    // ----------------------------------------------------
    // g�ltiges Datum gefunden
    // ----------------------------------------------------
    DateFormat df = new SimpleDateFormat("yyyy:MM:dd HH:mm:ss");
    try {
      myDate = df.parse(description);
    } catch (ParseException e) {
      //           System.out.println("ParseException fuer Datum = " + description);
      myDate = new Date(System.currentTimeMillis()); // default
    }
    picture.meta.setDateImport(myDate);
    picture.meta.setDateCurrent(new Date(myDate.getTime()));
  }
Example #30
0
  public void decay() {

    long curtime = System.currentTimeMillis();
    msgRate = calcMsgRate(curtime - lastTime);
    msgYield = calcMsgYield(curtime - lastTime);
    // also cycle the yield history.
    if (yieldHistoryCounter++ > SensorAnalyzer.YIELD_INTERVAL) {
      yieldHistoryCounter = 0;
      depthHistory[yieldHistoryPointer] = (byte) hopcount;
      yieldHistory[yieldHistoryPointer++] = yield();

      yieldHistoryPointer %= yieldHistory.length;
      if (panel != null) panel.repaint();
      if (link_panel != null) link_panel.get_new_data();
    }
    if (active) {
      active = false;
      return;
    }

    if (curtime - lastTime >= AVERAGE_INTERVAL) {
      if (self_calc != false) infoString = msgCount + " msgs ";
      else infoString = "";
      if (panel != null) panel.YieldLabel.setText(String.valueOf(percent_yield()) + " %");
    }
    int best = 0;
    int best_parent = 0;
    for (int i = 0; i < parent_count.length; i++) {
      if (parent_count[i] > best) {
        best_parent = i;
        best = parent_count[i];
      }
    }
    primary_parent = best_parent;
    best = 0;
    for (int i = 0; i < parent_count.length; i++) {
      if (parent_count[i] > best && i != primary_parent) {
        best_parent = i;
        best = parent_count[i];
      }
    }
    secondary_parent = best_parent;
  }