Dallas Semiconductor 1-Wire API 1.00 Alpha: Interface ClockContainer

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.dalsemi.onewire.container
Interface ClockContainer

All Superinterfaces:
  OneWireSensor

All Known Implementing Classes:
  OneWireContainer04, OneWireContainer21, OneWireContainer24, OneWireContainer27, OneWireContainer26

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.

### Features

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

### Usage

`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();
         clockcontainer.setClock(system_time,state);
         clockcontainer.writeDevice(state);

         //now try to disable to clock oscillator
         if (clockcontainer.canDisableClock())
         {
              state = clockcontainer.readDevice();
              clockcontainer.setClockRunEnable(false,state);
              clockcontainer.writeDevice(state);
         }

Version:
  0.00, 28 Aug 2000
See Also:
  `OneWireSensor`, `ADContainer`, `TemperatureContainer`, `PotentiometerContainer`, `SwitchContainer`

Method Summary
`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'.

Methods inherited from interface com.dalsemi.onewire.container.OneWireSensor
`readDevice, writeDevice`

Method Detail

### hasClockAlarm

    public boolean hasClockAlarm()

  Checks to see if the clock has an alarm feature.
  Returns:
    true if the Real-Time clock has an alarm
  See Also:
    `getClockAlarm(byte[])`, `isClockAlarmEnabled(byte[])`, `isClockAlarming(byte[])`, `setClockAlarm(long,byte[])`, `setClockAlarmEnable(boolean,byte[])`

### canDisableClock

    public boolean canDisableClock()

  Checks to see if the clock can be disabled.
  Returns:
    true if the clock can be enabled and disabled
  See Also:
    `isClockRunning(byte[])`, `setClockRunEnable(boolean,byte[])`

### getClockResolution

    public long getClockResolution()

  Gets the clock resolution in milliseconds.
  Returns:
    the clock resolution in milliseconds

### getClock

    public long getClock(byte[] state)

  Extracts the Real-Time clock value in milliseconds.
  Parameters:
    `state` - current state of the device returned from `readDevice()`
  Returns:
    the time represented in this clock in milliseconds since 1970
  See Also:
    `OneWireSensor.readDevice()`, `setClock(long,byte[])`

### getClockAlarm

    public long getClockAlarm(byte[] state)
                       throws OneWireException

  Extracts the clock alarm value for the Real-Time clock.
  Parameters:
    `state` - current state of the device returned from `readDevice()`
  Returns:
    the set value of the clock alarm in milliseconds since 1970
  Throws:
    `OneWireException` - if this device does not have clock alarms
  See Also:
    `OneWireSensor.readDevice()`, `hasClockAlarm()`, `isClockAlarmEnabled(byte[])`, `isClockAlarming(byte[])`, `setClockAlarm(long,byte[])`, `setClockAlarmEnable(boolean,byte[])`

### isClockAlarming

    public boolean isClockAlarming(byte[] state)

  Checks if the clock alarm flag has been set. This will occur when the value of the Real-Time clock equals the value of the clock alarm.
  Parameters:
    `state` - current state of the device returned from `readDevice()`
  Returns:
    true if the Real-Time clock is alarming
  See Also:
    `OneWireSensor.readDevice()`, `hasClockAlarm()`, `isClockAlarmEnabled(byte[])`, `getClockAlarm(byte[])`, `setClockAlarm(long,byte[])`, `setClockAlarmEnable(boolean,byte[])`

### isClockAlarmEnabled

    public boolean isClockAlarmEnabled(byte[] state)

  Checks if the clock alarm is enabled.
  Parameters:
    `state` - current state of the device returned from `readDevice()`
  Returns:
    true if clock alarm is enabled
  See Also:
    `OneWireSensor.readDevice()`, `hasClockAlarm()`, `isClockAlarming(byte[])`, `getClockAlarm(byte[])`, `setClockAlarm(long,byte[])`, `setClockAlarmEnable(boolean,byte[])`

### isClockRunning

    public boolean isClockRunning(byte[] state)

  Checks if the device's oscillator is enabled. The clock will not increment if the clock oscillator is not enabled.
  Parameters:
    `state` - current state of the device returned from `readDevice()`
  Returns:
    true if the clock is running
  See Also:
    `OneWireSensor.readDevice()`, `canDisableClock()`, `setClockRunEnable(boolean,byte[])`

### setClock

    public void setClock(long time,
                         byte[] state)

  Sets the Real-Time clock. The method `writeDevice()` must be called to finalize changes to the device. Note that multiple 'set' methods can be called before one call to `writeDevice()`.
  Parameters:
    `time` - new value for the Real-Time clock, in milliseconds since January 1, 1970
    `state` - current state of the device returned from `readDevice()`
  See Also:
    `OneWireSensor.writeDevice(byte[])`, `getClock(byte[])`

### setClockAlarm

    public void setClockAlarm(long time,
                              byte[] state)
                       throws OneWireException

  Sets the clock alarm. The method `writeDevice()` must be called to finalize changes to the device. Note that multiple 'set' methods can be called before one call to `writeDevice()`. Also note that not all clock devices have alarms. Check to see if this device has alarms first by calling the `hasClockAlarm()` method.
  Parameters:
    `time` - - new value for the Real-Time clock alarm, in milliseconds since January 1, 1970
    `state` - current state of the device returned from `readDevice()`
  Throws:
    `OneWireException` - if this device does not have clock alarms
  See Also:
    `OneWireSensor.writeDevice(byte[])`, `hasClockAlarm()`, `isClockAlarmEnabled(byte[])`, `getClockAlarm(byte[])`, `isClockAlarming(byte[])`, `setClockAlarmEnable(boolean,byte[])`

### setClockRunEnable

    public void setClockRunEnable(boolean runEnable,
                                  byte[] state)
                           throws OneWireException

  Enables or disables the oscillator, turning the clock 'on' and 'off'. The method `writeDevice()` must be called to finalize changes to the device. Note that multiple 'set' methods can be called before one call to `writeDevice()`. Also note that not all clock devices can disable their oscillators. Check to see if this device can disable its oscillator first by calling the `canDisableClock()` method.
  Parameters:
    `runEnable` - true to enable the clock oscillator
    `state` - current state of the device returned from `readDevice()`
  Throws:
    `OneWireException` - if the clock oscillator cannot be disabled
  See Also:
    `OneWireSensor.writeDevice(byte[])`, `canDisableClock()`, `isClockRunning(byte[])`

### setClockAlarmEnable

    public void setClockAlarmEnable(boolean alarmEnable,
                                    byte[] state)
                             throws OneWireException

  Enables or disables the clock alarm. The method `writeDevice()` must be called to finalize changes to the device. Note that multiple 'set' methods can be called before one call to `writeDevice()`. Also note that not all clock devices have alarms. Check to see if this device has alarms first by calling the `hasClockAlarm()` method.
  Parameters:
    `alarmEnable` - true to enable the clock alarm
    `state` - current state of the device returned from `readDevice()`
  Throws:
    `OneWireException` - if this device does not have clock alarms
  See Also:
    `OneWireSensor.writeDevice(byte[])`, `hasClockAlarm()`, `isClockAlarmEnabled(byte[])`, `getClockAlarm(byte[])`, `setClockAlarm(long,byte[])`, `isClockAlarming(byte[])`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD