Esempio n. 1
0
  /**
   * Get a vehicle by cartracker id from the cached list, if the vehicle does not exist it will be
   * created.
   *
   * @param cartrackerID
   * @return The found or newly created vehicle.
   */
  @Override
  public Vehicle getOrCreateVehicleById(String cartrackerID) {
    Vehicle returnVehicle = null;

    Iterator<Vehicle> it = vehicles.iterator();
    while (it.hasNext()) {
      Vehicle vehicle = it.next();
      if (cartrackerID.equals(vehicle.getCarTrackerID())) {
        returnVehicle = vehicle;
        break;
      }
    }

    /* Vehicle does not exist, lets create a new one */
    if (returnVehicle == null) {
      try {
        /* Also create a vehicle ownership */
        GregorianCalendar registerdate = new GregorianCalendar();
        registerdate.add(Calendar.YEAR, -3);
        VehicleOwnership vehicleOwnership = new VehicleOwnership();
        vehicleOwnership.setContributeGPSData(true);
        vehicleOwnership.setRegistrationdate((GregorianCalendar) registerdate.clone());
        vehicleOwnership.setRegistrationExperationDate(null);
        try {
          // create new user with incrementing name
          userDAO = new UserDAOImpl(emf);
          loginDAO = new LoginDAOImpl(em);
          UserDto user =
              userDAO.register(
                  "user" + USER_ID++ + "name", "aidas123", "*****@*****.**");
          MovementUser mUser = loginDAO.register(user.getUsername(), user.getEmail());
          vehicleOwnership.setUser(mUser);
        } catch (UserSystemException ex) {
          Logger.getLogger(MovementsDAOImpl.class.getName()).log(Level.SEVERE, null, ex);
        }

        // create car
        returnVehicle = new Vehicle(cartrackerID);
        returnVehicle.setLicensePlate(itLicensePlates.next());
        List<VehicleOwnership> owners = new ArrayList();
        owners.add(vehicleOwnership);
        returnVehicle.setVehicleOwners(owners);
        em.persist(returnVehicle);

        vehicleOwnership.setVehicle(returnVehicle);
        em.persist(vehicleOwnership);
        Logger.getLogger(MovementsDAOImpl.class.getName())
            .log(Level.WARNING, "Created new vehicle with ID" + cartrackerID);

        this.vehicles.add(returnVehicle);
      } catch (Exception ex) {
        Logger.getLogger(MovementsDAOImpl.class.getName()).log(Level.SEVERE, null, ex);
      }
    }

    return returnVehicle;
  }
  private XMLGregorianCalendar getTimeToXmlTime(long lastModified)
      throws DatatypeConfigurationException {

    GregorianCalendar gc = new GregorianCalendar(TimeZone.getTimeZone("UTC"));

    gc.setTime(new Date(lastModified));

    XMLGregorianCalendar xmlTime = DatatypeFactory.newInstance().newXMLGregorianCalendar(gc);
    return xmlTime;
  }
Esempio n. 3
0
 public void jButtonStart_actionPerformed(ActionEvent e) {
   GregorianCalendar now = new GregorianCalendar();
   if (now.before(new GregorianCalendar(2005, 12, 31))) {
     jButtonStop.setEnabled(true);
     server = new Server(this);
     server.start();
     //        System.out.println(System.getProperty("sun.boot.class.path"));
     statusBar.setText("Server is running...");
     jButtonStart.setEnabled(false);
     jButtonConfig.setEnabled(false);
   } else {
     JOptionPane.showMessageDialog(
         this,
         "Evaluation License has expired or is obsolete;\nplease contact vendor for renewal.",
         "License Error",
         JOptionPane.ERROR_MESSAGE);
   }
 }
Esempio n. 4
0
 /** Sets the time of the next scheduled raid */
 private void setNextRaid(Info info) {
   String raidTime = info.getMessage().substring(13);
   raidTime = substituteTimeZone(raidTime);
   try {
     SimpleDateFormat parser = new SimpleDateFormat("yyyy-MM-dd HH:mm z");
     Date date = parser.parse(raidTime);
     TimeZone z = parser.getTimeZone();
     GregorianCalendar cal = new GregorianCalendar(z);
     cal.setTime(date);
     raids.put(info.getChannel(), cal);
     saveRaids();
     info.sendMessage("Raid time set.");
   } catch (ParseException e) {
     info.sendMessage(
         "Date format was bad.  Date format is like \"2008-11-26 21:45 EST\".  You entered "
             + raidTime);
   }
 }
Esempio n. 5
0
 /**
  * Set calendar to this week's Monday; set year and week combo boxes to the currently set date;
  * set the date labels appropriately; and, refresh the review table.
  */
 private void updateYearWeekDates() {
   yearWeekCalendar.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
   yearWeekCalendar.set(Calendar.HOUR_OF_DAY, 0);
   yearWeekCalendar.set(Calendar.MINUTE, 0);
   yearWeekCalendar.set(Calendar.SECOND, 0);
   yearWeekCalendar.set(Calendar.MILLISECOND, 0);
   yearCB.setSelectedItem(yearWeekCalendar.get(Calendar.YEAR));
   weekCB.setSelectedItem(yearWeekCalendar.get(Calendar.WEEK_OF_YEAR));
   fromDate.setDate(yearWeekCalendar);
   yearWeekCalendar.add(Calendar.DAY_OF_MONTH, 7);
   toDate.setDate(yearWeekCalendar);
   yearWeekCalendar.add(Calendar.DAY_OF_MONTH, -7);
   refreshReviewTable();
 }
Esempio n. 6
0
 /** Return a time stamp string accurate to sec: yyyy-mm-dd hh:mm:ss */
 public static String getCurrentTimeStamp() {
   GregorianCalendar calendar = new java.util.GregorianCalendar();
   int y = calendar.get(Calendar.YEAR);
   int m = calendar.get(Calendar.MONTH) + 1; // zero-based for months
   int d = calendar.get(Calendar.DAY_OF_MONTH);
   int h = calendar.get(Calendar.HOUR_OF_DAY);
   int min = calendar.get(Calendar.MINUTE);
   int sec = calendar.get(Calendar.SECOND);
   String sy = String.valueOf(y);
   String sm = m < 10 ? "0" + m : String.valueOf(m);
   String sd = d < 10 ? "0" + d : String.valueOf(d);
   String sh = h < 10 ? "0" + h : String.valueOf(h);
   String smin = min < 10 ? "0" + min : String.valueOf(min);
   String ssec = sec < 10 ? "0" + sec : String.valueOf(sec);
   return new StringBuffer()
       .append(sy)
       .append("-")
       .append(sm)
       .append("-")
       .append(sd)
       .append(" ")
       .append(sh)
       .append(":")
       .append(smin)
       .append(":")
       .append(ssec)
       .toString();
 }
Esempio n. 7
0
 {
   addItem("Custom");
   int currentYear = yearWeekCalendar.get(Calendar.YEAR);
   for (int year = currentYear - 5; year <= currentYear + 5; year++) addItem(year);
   addActionListener(
       new ActionListener() {
         @Override
         public void actionPerformed(ActionEvent ae) {
           if (yearCB.getSelectedIndex() == 0) return;
           yearWeekCalendar.set(Calendar.YEAR, (Integer) yearCB.getSelectedItem());
           updateYearWeekDates();
         }
       });
 }
Esempio n. 8
0
  // Generates a unique filename based on the current date and time.
  private String getUniqueFileName() {

    GregorianCalendar now = new GregorianCalendar();
    String fileName =
        ""
            + now.get(Calendar.YEAR)
            + now.get(Calendar.MONTH)
            + now.get(Calendar.DATE)
            + now.get(Calendar.HOUR_OF_DAY)
            + now.get(Calendar.MINUTE)
            + now.get(Calendar.SECOND)
            + now.get(Calendar.MILLISECOND);

    return fileName + ".jpg";
  }
Esempio n. 9
0
  private void nextRaid(Info info) {
    GregorianCalendar nextRaid = raids.get(info.getChannel());
    GregorianCalendar now = Utils.getRealDate(info);
    int diffMins = (int) ((nextRaid.getTimeInMillis() - now.getTimeInMillis()) / 1000 / 60);
    if (nextRaid.compareTo(now) < 0) {
      info.sendMessage("There is no future raid set.");
      return;
    }
    String tz = info.getMessage().substring(9).trim();
    tz = substituteTimeZone(tz);
    TimeZone timeZone;
    if (tz.length() == 0) timeZone = tZF("GMT");
    else timeZone = tZF(tz);
    formatter.setTimeZone(timeZone);

    String ret = "The next raid is scheduled for " + formatter.format(nextRaid.getTime());
    ret = ret + getTimeDifference(diffMins);
    info.sendMessage(ret);
  }
Esempio n. 10
0
 /** Refreshes the label's text according to the current date. */
 private void refresh() {
   setText(dateFormat.format(calendar.getTime()));
 }
Esempio n. 11
0
 /**
  * Obtains the date associated with the label.
  *
  * @return The date.
  */
 Date getDate() {
   return calendar.getTime();
 }
Esempio n. 12
0
 /**
  * A method used to set the date externally (not through {@link DateChooser}).
  *
  * @param calendar The calendar to clone.
  */
 void setDate(GregorianCalendar calendar) {
   this.calendar = (GregorianCalendar) calendar.clone();
   refresh();
 }
Esempio n. 13
0
  /**
   * Creates the java help
   *
   * @param path the path where to create the java help
   * @param lang the spoken language
   */
  private void createJavaHelp(File path, String lang) {
    File pages = new File(path, "pages");
    if (pages.exists()) deleteDir(pages);
    pages.mkdir();

    File javahelpsearch = new File(path, SEARCH_DIR);
    if (javahelpsearch.exists()) deleteDir(javahelpsearch);

    File helpset_file = new File(path, HELPSET_NAME_BASE + lang + HELPSET_NAME_SUFFIX);
    File config_file = null;
    File map_file = null;
    File tam_file = null;

    String underscore = "";

    if (helpset_file.exists()) {
      // There is a helpset corresponding to the current language
      map_file = new File(path, MAP_NAME_BASE + lang + MAP_NAME_SUFFIX);
      tam_file = new File(path, TAM_NAME_BASE + lang + TAM_NAME_SUFFIX);
      underscore = "_" + lang;
    } else {
      // There is no helpset : we use the default one
      map_file = new File(path + "Map.jhm");
      tam_file = new File(path + "TAM.xml");
    }

    config_file = new File(path, CONFIG_FILE);

    if (config_file.exists()) config_file.delete();
    if (map_file.exists()) map_file.delete();
    if (tam_file.exists()) tam_file.delete();

    boolean test = true;

    try {
      // Generates the jhm and copy the file for objects
      // Generates the TAM.xml file
      test = test && map_file.createNewFile();
      test = test && tam_file.createNewFile();
      File lang_dir = new File(path, "Main_pages/" + lang);
      test = test && lang_dir.exists();
      if (test) {
        print = new PrintWriter(new BufferedWriter(new FileWriter(map_file)));
        // debut  + images
        print.println(
            "<?xml version='1.0' encoding='ISO-8859-1' ?>\n "
                + "<!DOCTYPE map\n"
                + "PUBLIC \"-//Sun Microsystems Inc.//DTD JavaHelp Map Version 1.0//EN\"\n"
                + "\"http://java.sun.com/products/javahelp/map_1_0.dtd\">\n"
                + "\n"
                + "<map version=\"1.0\">\n"
                + "<mapID target=\"image\" url=\"Main_pages/logo_cbs_petit.gif\" />\n"
                + "<mapID target=\"tamicon\" url=\"Main_pages/tam.gif\" />\n"
                + "<mapID target=\"fileicon\" url=\"Main_pages/file.gif\" />\n"
                + "<mapID target=\""
                + FIRST_PAGE
                + "\" url=\"pages/"
                + FIRST_PAGE
                + ".html\" />");

        print2 = new PrintWriter(new BufferedWriter(new FileWriter(tam_file)));
        print2.println(
            " <?xml version='1.0' encoding='ISO-8859-1'  ?> \n "
                + "<!DOCTYPE toc \n"
                + "PUBLIC \"-//Sun Microsystems Inc.//DTD JavaHelp TOC Version 2.0//EN\"\n"
                + "\"../dtd/toc_2_0.dtd\">\n"
                + "<toc version=\"2.0\"> \n<tocitem text=\""
                + getTitle(new File(path, "Main_pages/" + lang + "/" + FIRST_PAGE + ".html"))
                + "\" target=\""
                + FIRST_PAGE
                + "\" image=\"image\">");
        copyFile(
            new File(path, "Main_pages/" + lang + "/" + FIRST_PAGE + ".html"),
            new File(path, "pages/" + FIRST_PAGE + ".html"));

        // generation of the tree
        File[] list_lang_dir = lang_dir.listFiles();
        for (int a = 0; a < list_lang_dir.length; a++) {
          if (!list_lang_dir[a].getName().equals("CVS")
              && list_lang_dir[a].isFile()
              && !list_lang_dir[a].getName().equals(FIRST_PAGE + ".html")) {
            mapAndTocForFile(list_lang_dir[a], path, underscore);
          }
        }

        // Ends
        print.println("</map>");
        print.close();

        print2.println("</tocitem>\n</toc>");
        print2.close();

        test = test && config_file.createNewFile();
        if (test) {
          // Generates the config file
          print = new PrintWriter(new BufferedWriter(new FileWriter(config_file)));
          print.print("IndexRemove " + path.getAbsolutePath());
          print.close();
        }
      }
    } catch (Exception e) {
      LOG.error("Error getHelp " + e);
    }
    // Generates the search database
    String[] args =
        new String[] {
          pages.getAbsolutePath(),
          "-c",
          config_file.getAbsolutePath(),
          "-db",
          javahelpsearch.getAbsolutePath(),
          "-locale",
          lang
        };
    // Indexer indexer=new Indexer();
    // FIXME help desactived
    //		Indexer.main(args);

    Calendar c = GregorianCalendar.getInstance();
    c.setTime(new Date());
    int day = c.get(Calendar.DAY_OF_MONTH);
    int month = c.get(Calendar.MONTH) + 1;
    int year = c.get(Calendar.YEAR);
    int hour = c.get(Calendar.HOUR_OF_DAY);
    int minute = c.get(Calendar.MINUTE);
    int seconds = c.get(Calendar.SECOND);

    File log = new File(path, LOG_FILE);
    try {
      log.createNewFile();
      PrintWriter printlog = new PrintWriter(new BufferedWriter(new FileWriter(log)));
      printlog.println("Language " + lang);
      printlog.println(
          "Date : " + year + " " + month + " " + day + " " + hour + " " + minute + " " + seconds);
      printlog.close();
    } catch (Exception e) {
      LOG.error("Error while creating log " + e);
    }
  }
Esempio n. 14
0
  private void writeRecord(DataOutput dataOutput, Object[] objectArray) throws IOException {

    dataOutput.write((byte) ' ');
    for (int j = 0; j < this.header.fieldArray.length; j++) {
      /* iterate throught fields */

      switch (this.header.fieldArray[j].getDataType()) {
        case 'C':
          if (objectArray[j] != null) {

            String str_value = objectArray[j].toString();
            dataOutput.write(
                Utils.textPadding(
                    str_value, characterSetName, this.header.fieldArray[j].getFieldLength()));
          } else {

            dataOutput.write(
                Utils.textPadding(
                    "", this.characterSetName, this.header.fieldArray[j].getFieldLength()));
          }

          break;

        case 'D':
          if (objectArray[j] != null) {

            GregorianCalendar calendar = new GregorianCalendar();
            calendar.setTime((Date) objectArray[j]);
            dataOutput.write(String.valueOf(calendar.get(Calendar.YEAR)).getBytes());
            dataOutput.write(
                Utils.textPadding(
                    String.valueOf(calendar.get(Calendar.MONTH) + 1),
                    this.characterSetName,
                    2,
                    Utils.ALIGN_RIGHT,
                    (byte) '0'));
            dataOutput.write(
                Utils.textPadding(
                    String.valueOf(calendar.get(Calendar.DAY_OF_MONTH)),
                    this.characterSetName,
                    2,
                    Utils.ALIGN_RIGHT,
                    (byte) '0'));
          } else {

            dataOutput.write("        ".getBytes());
          }

          break;

        case 'F':
          if (objectArray[j] != null) {

            dataOutput.write(
                Utils.doubleFormating(
                    (Double) objectArray[j],
                    this.characterSetName,
                    this.header.fieldArray[j].getFieldLength(),
                    this.header.fieldArray[j].getDecimalCount()));
          } else {

            dataOutput.write(
                Utils.textPadding(
                    " ",
                    this.characterSetName,
                    this.header.fieldArray[j].getFieldLength(),
                    Utils.ALIGN_RIGHT));
          }

          break;

        case 'N':
          if (objectArray[j] != null) {

            dataOutput.write(
                Utils.doubleFormating(
                    (Double) objectArray[j],
                    this.characterSetName,
                    this.header.fieldArray[j].getFieldLength(),
                    this.header.fieldArray[j].getDecimalCount()));
          } else {

            dataOutput.write(
                Utils.textPadding(
                    " ",
                    this.characterSetName,
                    this.header.fieldArray[j].getFieldLength(),
                    Utils.ALIGN_RIGHT));
          }

          break;
        case 'L':
          if (objectArray[j] != null) {

            if ((Boolean) objectArray[j] == Boolean.TRUE) {

              dataOutput.write((byte) 'T');
            } else {

              dataOutput.write((byte) 'F');
            }
          } else {

            dataOutput.write((byte) '?');
          }

          break;

        case 'M':
          break;

        default:
          throw new DBFException("Unknown field type " + this.header.fieldArray[j].getDataType());
      }
    } /* iterating through the fields */
  }
Esempio n. 15
0
 protected String createDateHeader(int expires) {
   final Calendar utc = GregorianCalendar.getInstance(TimeZone.getTimeZone("UTC"));
   utc.add(Calendar.SECOND, expires);
   return toHttpDate(utc.getTime());
 }
Esempio n. 16
0
  /**
   * Method main
   *
   * @param args
   * @throws OneWireException
   * @throws OneWireIOException
   */
  public static void main(String[] args) throws OneWireIOException, OneWireException {
    boolean show_history = false;
    boolean show_log = false;
    boolean show_histogram = false;
    boolean pre_kill = false;
    boolean post_kill = false;
    boolean usedefault = false;
    DSPortAdapter access = null;
    String adapter_name = null;
    String port_name = null;

    if ((args == null) || (args.length < 1) || (args[0].indexOf("_") == -1)) {
      try {
        access = OneWireAccessProvider.getDefaultAdapter();

        if (access == null) throw new Exception();
      } catch (Exception e) {
        System.out.println("Couldn't get default adapter!");
        printUsageString();

        return;
      }

      usedefault = true;
    }

    if ((args != null) && (args.length > 0) && (usedefault)) {
      String arg = args[0];

      if (arg.indexOf("a") != -1) show_history = true;

      if (arg.indexOf("l") != -1) show_log = true;

      if (arg.indexOf("h") != -1) show_histogram = true;

      if (arg.indexOf("k") != -1) pre_kill = true;

      if (arg.indexOf("s") != -1) post_kill = true;
    }

    if (!usedefault) {
      StringTokenizer st = new StringTokenizer(args[0], "_");

      if (st.countTokens() != 2) {
        printUsageString();

        return;
      }

      if (args.length > 1) {
        String arg = args[1];

        if (arg.indexOf("a") != -1) show_history = true;

        if (arg.indexOf("l") != -1) show_log = true;

        if (arg.indexOf("h") != -1) show_histogram = true;

        if (arg.indexOf("k") != -1) pre_kill = true;

        if (arg.indexOf("s") != -1) post_kill = true;
      }

      adapter_name = st.nextToken();
      port_name = st.nextToken();

      System.out.println("Adapter Name: " + adapter_name);
      System.out.println("Port Name: " + port_name);
    }

    if (access == null) {
      try {
        access = OneWireAccessProvider.getAdapter(adapter_name, port_name);
      } catch (Exception e) {
        System.out.println("That is not a valid adapter/port combination.");

        Enumeration en = OneWireAccessProvider.enumerateAllAdapters();

        while (en.hasMoreElements()) {
          DSPortAdapter temp = (DSPortAdapter) en.nextElement();

          System.out.println("Adapter: " + temp.getAdapterName());

          Enumeration f = temp.getPortNames();

          while (f.hasMoreElements()) {
            System.out.println("   Port name : " + ((String) f.nextElement()));
          }
        }

        return;
      }
    }

    access.adapterDetected();
    access.targetFamily(0x21);
    access.beginExclusive(true);
    access.reset();
    access.setSearchAllDevices();

    boolean next = access.findFirstDevice();

    if (!next) {
      System.out.println("Could not find any DS1921 Thermocrons!");

      return;
    }

    OneWireContainer21 owc = new OneWireContainer21();

    owc.setupContainer(access, access.getAddressAsLong());

    // put the part into overdrive...make it sizzle!
    owc.setSpeed(access.SPEED_OVERDRIVE, true);

    // let's gather our information here...
    long t1 = System.currentTimeMillis();

    if (pre_kill) {
      try {
        owc.disableMission();
      } catch (Exception e) {
        System.out.println("Couldn't end mission before reading: " + e.toString());
      }
    }

    boolean mission_in_progress = owc.getFlag(owc.STATUS_REGISTER, owc.MISSION_IN_PROGRESS_FLAG);
    byte[] state;

    Calendar cal = Calendar.getInstance();

    // first, check to make sure that the thermochron isn't
    // sampling, or at least that a sample isn't about to occur.
    boolean isSampling = false;
    do {
      state = owc.readDevice();
      cal.setTime(new Date(owc.getClock(state)));

      isSampling =
          mission_in_progress
              && (owc.getFlag(owc.STATUS_REGISTER, owc.SAMPLE_IN_PROGRESS_FLAG, state)
                  || (cal.get(Calendar.SECOND) > 55));

      if (isSampling) {
        // wait for current sample to finish
        try {
          Thread.sleep(1000);
        } catch (InterruptedException ie) {;
        }
      }
    } while (isSampling);

    int mission_count = owc.getMissionSamplesCounter(state);
    int device_count = owc.getDeviceSamplesCounter(state);
    long rtc = owc.getClock(state);
    long next_alarm = owc.getClockAlarm(state);
    Calendar time_stamp = owc.getMissionTimeStamp(state);
    int sample_rate = owc.getSampleRate(state);
    double high_alarm = owc.getTemperatureAlarm(owc.ALARM_HIGH, state);
    double low_alarm = owc.getTemperatureAlarm(owc.ALARM_LOW, state);
    int[] histogram = owc.getTemperatureHistogram();
    byte[] log = owc.getTemperatureLog(state);
    byte[] high_history = owc.getAlarmHistory(owc.TEMPERATURE_HIGH_ALARM);
    byte[] low_history = owc.getAlarmHistory(owc.TEMPERATURE_LOW_ALARM);
    long t2 = System.currentTimeMillis();
    boolean clock_enabled = owc.isClockRunning(state);
    boolean alarm_enabled = owc.isClockAlarmEnabled(state);
    boolean clock_alarm = owc.isClockAlarming(state);
    boolean rollover = owc.getFlag(owc.CONTROL_REGISTER, owc.ROLLOVER_ENABLE_FLAG, state);
    double current_temp = 0;
    String mission_in_progress_string;

    if (!mission_in_progress) {
      owc.doTemperatureConvert(state);

      current_temp = owc.getTemperature(state);
      mission_in_progress_string = "- NO MISSION IN PROGRESS AT THIS TIME";
    } else mission_in_progress_string = "- MISSION IS CURRENTLY RUNNING";

    // spew all this data
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

    System.out.println("Dallas Semiconductor DS1921 Thermocron Mission Summary Demo");
    System.out.println("-----------------------------------------------------------");
    System.out.println("- Device ID : " + owc.getAddressAsString());
    System.out.println(mission_in_progress_string);

    if (!mission_in_progress) {
      System.out.println("- Current Temperature : " + current_temp);
    } else System.out.println("- Cannot read current temperature with mission in progress");

    System.out.println("-----------------------------------------------------------");
    System.out.println("- Number of mission samples: " + mission_count);
    System.out.println("- Total number of samples  : " + device_count);
    System.out.println("- Real Time Clock          : " + (clock_enabled ? "ENABLED" : "DISABLED"));
    System.out.println("- Real Time Clock Value    : " + (new Date(rtc)));
    System.out.println("- Clock Alarm              : " + (alarm_enabled ? "ENABLED" : "DISABLED"));

    if (alarm_enabled) {
      System.out.println(
          "- Clock Alarm Status       : " + (clock_alarm ? "ALARMING" : "NOT ALARMING"));
      System.out.println("- Next alarm occurs at     : " + (new Date(next_alarm)));
    }

    System.out.println("- Last mission started     : " + time_stamp.getTime());
    System.out.println("- Sample rate              : Every " + sample_rate + " minutes");
    System.out.println("- High temperature alarm   : " + high_alarm);
    System.out.println("- Low temperature alarm    : " + low_alarm);
    System.out.println("- Rollover enabled         : " + (rollover ? "YES" : "NO"));
    System.out.println("- Time to read Thermocron  : " + (t2 - t1) + " milliseconds");
    System.out.println("-----------------------------------------------------------");

    if (show_history) {
      int start_offset, violation_count;

      System.out.println("-");
      System.out.println("-                   ALARM HISTORY");

      if (low_history.length == 0) {
        System.out.println("- No violations against the low temperature alarm.");
        System.out.println("-");
      }

      for (int i = 0; i < low_history.length / 4; i++) {
        start_offset =
            (low_history[i * 4] & 0x0ff)
                | ((low_history[i * 4 + 1] << 8) & 0x0ff00)
                | ((low_history[i * 4 + 2] << 16) & 0x0ff0000);
        violation_count = 0x0ff & low_history[i * 4 + 3];

        System.out.println("- Low alarm started at     : " + (start_offset * sample_rate));
        System.out.println(
            "-                          : Lasted " + (violation_count * sample_rate) + " minutes");
      }

      if (high_history.length == 0) {
        System.out.println("- No violations against the high temperature alarm.");
        System.out.println("-");
      }

      for (int i = 0; i < high_history.length / 4; i++) {
        start_offset =
            (high_history[i * 4] & 0x0ff)
                | ((high_history[i * 4 + 1] << 8) & 0x0ff00)
                | ((high_history[i * 4 + 2] << 16) & 0x0ff0000);
        violation_count = 0x0ff & high_history[i * 4 + 3];

        System.out.println("- High alarm started at    : " + (start_offset * sample_rate));
        System.out.println(
            "-                          : Lasted " + (violation_count * sample_rate) + " minutes");
      }

      System.out.println("-----------------------------------------------------------");
    }

    if (show_log) {
      long time = time_stamp.getTime().getTime() + owc.getFirstLogOffset(state);

      System.out.println("-");
      System.out.println("-                   TEMPERATURE LOG");

      GregorianCalendar gc = new GregorianCalendar();
      for (int i = 0; i < log.length; i++) {
        gc.setTime(new Date(time));
        System.out.println("- Temperature recorded at  : " + (gc.getTime()));
        System.out.println("-                     was  : " + owc.decodeTemperature(log[i]) + " C");

        time += sample_rate * 60 * 1000;
      }

      System.out.println("-----------------------------------------------------------");
    }

    if (show_histogram) {
      double resolution = owc.getTemperatureResolution();
      double histBinWidth = owc.getHistogramBinWidth();
      double start = owc.getHistogramLowTemperature();

      System.out.println("-");
      System.out.println("-                   TEMPERATURE HISTOGRAM");

      for (int i = 0; i < histogram.length; i++) {
        System.out.println(
            "- Histogram entry          : "
                + histogram[i]
                + " at temperature "
                + start
                + " to "
                + (start + (histBinWidth - resolution))
                + " C");

        start += histBinWidth;
      }
    }

    if (post_kill) {
      try {
        owc.disableMission();
      } catch (Exception e) {
        System.out.println("Couldn't end mission after reading: " + e.toString());
      }
    }

    access.endExclusive();
    access.freePort();
    access = null;
    System.out.println("Finished.");
  }