Interface ClockContainer

  • All Superinterfaces:
    All Known Subinterfaces:
    All Known Implementing Classes:
    OneWireContainer04, OneWireContainer21, OneWireContainer24, OneWireContainer26, OneWireContainer27, OneWireContainer41

    public interface ClockContainer
    extends OneWireSensor

    Interface class for 1-Wire® devices that contain Real-Time clocks. This class should be implemented for each Clock type 1-Wire device.


    • Supports clock alarm enabling and setting on devices with clock alarms
    • Supports enabling and disabling the clock on devices that can disable their oscillators


    ClockContainer extends com.dalsemi.onewire.container.OneWireSensor, so the general usage model applies to any ClockContainer:

    1. readDevice()
    2. perform operations on the ClockContainer
    3. writeDevice(byte[])

    Consider this interaction with a ClockContainer that reads from the Real-Time clock, then tries to set it to the system's current clock setting before disabling the oscillator:

         //clockcontainer is a com.dalsemi.onewire.container.ClockContainer
         byte[] state = clockcontainer.readDevice();
         long current_time = clockcontainer.getClock(state);
         System.out.println("Current time is :"+(new Date(current_time)));
         long system_time = System.currentTimeMillis();
         //now try to disable to clock oscillator
         if (clockcontainer.canDisableClock())
              state = clockcontainer.readDevice();
    See Also:
    OneWireSensor, ADContainer, TemperatureContainer, PotentiometerContainer, SwitchContainer
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      boolean canDisableClock()
      Checks to see if the clock can be disabled.
      long getClock​(byte[] state)
      Extracts the Real-Time clock value in milliseconds.
      long getClockAlarm​(byte[] state)
      Extracts the clock alarm value for the Real-Time clock.
      long getClockResolution()
      Gets the clock resolution in milliseconds.
      boolean hasClockAlarm()
      Checks to see if the clock has an alarm feature.
      boolean isClockAlarmEnabled​(byte[] state)
      Checks if the clock alarm is enabled.
      boolean isClockAlarming​(byte[] state)
      Checks if the clock alarm flag has been set.
      boolean isClockRunning​(byte[] state)
      Checks if the device's oscillator is enabled.
      void setClock​(long time, byte[] state)
      Sets the Real-Time clock.
      void setClockAlarm​(long time, byte[] state)
      Sets the clock alarm.
      void setClockAlarmEnable​(boolean alarmEnable, byte[] state)
      Enables or disables the clock alarm.
      void setClockRunEnable​(boolean runEnable, byte[] state)
      Enables or disables the oscillator, turning the clock 'on' and 'off'.