Interface TemperatureContainer

  • All Superinterfaces:
    All Known Implementing Classes:
    OneWireContainer10, OneWireContainer21, OneWireContainer22, OneWireContainer26, OneWireContainer28, OneWireContainer30, OneWireContainer41, OneWireContainer42

    public interface TemperatureContainer
    extends OneWireSensor
    1-Wire temperature interface class for basic temperature measuring operations. This class should be implemented for each temperature type 1-Wire device.

    The TemperatureContainer methods can be organized into the following categories:


    Example 1

    Display some features of TemperatureContainer instance 'tc':
       // Read High and Low Alarms
       if (!tc.hasTemperatureAlarms())
          System.out.println("Temperature alarms not supported");
          byte[] state     = tc.readDevice();
          double alarmLow  = tc.getTemperatureAlarm(TemperatureContainer.ALARM_LOW, state);
          double alarmHigh = tc.getTemperatureAlarm(TemperatureContainer.ALARM_HIGH, state);
          System.out.println("Alarm: High = " + alarmHigh + ", Low = " + alarmLow);
       }             }

    Example 2

    Gets temperature reading from a TemperatureContainer instance 'tc':
       double lastTemperature;
       // get the current resolution and other settings of the device (done only once)
       byte[] state = tc.readDevice();
       do // loop to read the temp
          // perform a temperature conversion
          // read the result of the conversion
          state = tc.readDevice();
          // extract the result out of state
          lastTemperature = tc.getTemperature(state);
       }while (!done);
    The reason the conversion and the reading are separated is that one may want to do a conversion without reading the result. One could take advantage of the alarm features of a device by setting a threshold and doing conversions until the device is alarming. For example:
       // get the current resolution of the device
       byte [] state = tc.readDevice();
       // set the trips
       tc.setTemperatureAlarm(TemperatureContainer.ALARM_HIGH, 50, state);
       tc.setTemperatureAlarm(TemperatureContainer.ALARM_LOW, 20, state);
       do // loop on conversions until an alarm occurs
       } while (!tc.isAlarming());

    Example 3

    Sets the temperature resolution of a TemperatureContainer instance 'tc':
       byte[] state = tc.readDevice();
       if (tc.hasSelectableTemperatureResolution())
          double[] resolution = tc.getTemperatureResolutions();
          tc.setTemperatureResolution(resolution [resolution.length - 1], state);
    See Also:
    OneWireContainer10, OneWireContainer21, OneWireContainer26, OneWireContainer28, OneWireContainer30