Exemplo n.º 1
0
 /**
  * Simple example, printing the number of sensors found, and then the identity and value of each
  * sensor, sleeping a second between each sensor reading.
  *
  * @param args not used.
  * @throws Exception
  */
 public static void main(String[] args) throws Exception {
   Set<Sensor> sensors = Sensors.getSensors();
   System.out.println(String.format("Found %d sensors!", sensors.size()));
   while (true) {
     for (Sensor sensor : sensors) {
       System.out.println(
           String.format(
               "%s(%s):%3.2f%s",
               sensor.getPhysicalQuantity(),
               sensor.getID(),
               sensor.getValue(),
               sensor.getUnitString()));
       Thread.sleep(1000);
     }
     System.out.println("");
     System.out.flush();
   }
 }