|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
1-Wire sensor interface class for basic sensor operations.
Typically the operations of 1-Wire Sensors are memory mapped so
writing to a particular location causes the state to change. To
accommodate this type of architecture and reduce the number of 1-
Wire operations that need to take place, a 'read-modify-write'
technique is used. Each Sensor interface is derived from this
super-interface that contain just two methods:
readDevice
,
writeDevice
. The
read returns a byte array and the write takes a byte array. The
byte array is the state of the device. The interfaces that
extend this interface have 'get' and 'set' methods that
manipulate the byte array. So a OneWireSensor operation is:
SwitchContainer
instance 'sw':
byte[] state = sw.readDevice();
if (sw.hasLevelSensing())
{
for (int ch = 0; ch < sw.getNumberChannels(state); ch++)
{
System.out.print("Level for channel " + ch + " is : ");
if (sw.getLevel(ch, state))
System.out.println("HIGH");
else
System.out.println("HIGH");
}
}
else
System.out.println("This SwitchContainer can not sense level");
ClockContainer
instance 'cl':
byte[] state = cl.readDevice();
cl.setClock((new Date().getTime()), state);
cl.setClockRunEnable(true, state);
cl.writeDevice(state);
ADContainer
,
ClockContainer
,
PotentiometerContainer
,
SwitchContainer
,
TemperatureContainer
Method Summary | |
byte[] |
readDevice()
Retrieves the 1-Wire device sensor state. |
void |
writeDevice(byte[] state)
Writes the 1-Wire device sensor state that have been changed by 'set' methods. |
Method Detail |
public byte[] readDevice() throws OneWireIOException, OneWireException
OneWireIOException
- on a 1-Wire communication error such as
reading an incorrect CRC from a 1-Wire device. This could be
caused by a physical interruption in the 1-Wire Network due to
shorts or a newly arriving 1-Wire device issuing a 'presence pulse'.OneWireException
- on a communication or setup error with the 1-Wire
adapterpublic void writeDevice(byte[] state) throws OneWireIOException, OneWireException
state
- 1-Wire device sensor stateOneWireIOException
- on a 1-Wire communication error such as
reading an incorrect CRC from a 1-Wire device. This could be
caused by a physical interruption in the 1-Wire Network due to
shorts or a newly arriving 1-Wire device issuing a 'presence pulse'.OneWireException
- on a communication or setup error with the 1-Wire
adapter
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |