|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
Interface class for 1-Wire® devices that contain Real-Time clocks. This class should be implemented for each Clock type 1-Wire device.
ClockContainer extends com.dalsemi.onewire.container.OneWireSensor, so the general usage
model applies to any ClockContainer:
ClockContainer 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);
}
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 |
public boolean hasClockAlarm()
getClockAlarm(byte[]),
isClockAlarmEnabled(byte[]),
isClockAlarming(byte[]),
setClockAlarm(long,byte[]),
setClockAlarmEnable(boolean,byte[])public boolean canDisableClock()
isClockRunning(byte[]),
setClockRunEnable(boolean,byte[])public long getClockResolution()
public long getClock(byte[] state)
state - current state of the device returned from readDevice()OneWireSensor.readDevice(),
setClock(long,byte[])
public long getClockAlarm(byte[] state)
throws OneWireException
state - current state of the device returned from readDevice()OneWireException - if this device does not have clock alarmsOneWireSensor.readDevice(),
hasClockAlarm(),
isClockAlarmEnabled(byte[]),
isClockAlarming(byte[]),
setClockAlarm(long,byte[]),
setClockAlarmEnable(boolean,byte[])public boolean isClockAlarming(byte[] state)
state - current state of the device returned from readDevice()OneWireSensor.readDevice(),
hasClockAlarm(),
isClockAlarmEnabled(byte[]),
getClockAlarm(byte[]),
setClockAlarm(long,byte[]),
setClockAlarmEnable(boolean,byte[])public boolean isClockAlarmEnabled(byte[] state)
state - current state of the device returned from readDevice()OneWireSensor.readDevice(),
hasClockAlarm(),
isClockAlarming(byte[]),
getClockAlarm(byte[]),
setClockAlarm(long,byte[]),
setClockAlarmEnable(boolean,byte[])public boolean isClockRunning(byte[] state)
state - current state of the device returned from readDevice()OneWireSensor.readDevice(),
canDisableClock(),
setClockRunEnable(boolean,byte[])
public void setClock(long time,
byte[] state)
writeDevice() must be called to finalize
changes to the device. Note that multiple 'set' methods can
be called before one call to writeDevice().time - new value for the Real-Time clock, in milliseconds
since January 1, 1970state - current state of the device returned from readDevice()OneWireSensor.writeDevice(byte[]),
getClock(byte[])
public void setClockAlarm(long time,
byte[] state)
throws OneWireException
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.time - - new value for the Real-Time clock alarm, in milliseconds
since January 1, 1970state - current state of the device returned from readDevice()OneWireException - if this device does not have clock alarmsOneWireSensor.writeDevice(byte[]),
hasClockAlarm(),
isClockAlarmEnabled(byte[]),
getClockAlarm(byte[]),
isClockAlarming(byte[]),
setClockAlarmEnable(boolean,byte[])
public void setClockRunEnable(boolean runEnable,
byte[] state)
throws OneWireException
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.runEnable - true to enable the clock oscillatorstate - current state of the device returned from readDevice()OneWireException - if the clock oscillator cannot be disabledOneWireSensor.writeDevice(byte[]),
canDisableClock(),
isClockRunning(byte[])
public void setClockAlarmEnable(boolean alarmEnable,
byte[] state)
throws OneWireException
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.alarmEnable - true to enable the clock alarmstate - current state of the device returned from readDevice()OneWireException - if this device does not have clock alarmsOneWireSensor.writeDevice(byte[]),
hasClockAlarm(),
isClockAlarmEnabled(byte[]),
getClockAlarm(byte[]),
setClockAlarm(long,byte[]),
isClockAlarming(byte[])
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||