private class WSI603A.WindTask
extends java.lang.Object
implements java.lang.Runnable
Modifier and Type | Field and Description |
---|---|
private java.lang.String |
ANEMOMETER_NAME
Data name.
|
private int |
COMMAND_ADDRESS
Command buffer address.
|
private int |
COMMAND_INDEX
Response buffer command index.
|
private int[] |
direction
Windvane data buffer.
|
private int |
directionIndex
Windvane sampling index.
|
private boolean |
initialize
Flag to initialize sensor.
|
private int |
LED_GET_STATUS_INDEX
Response buffer LED status index.
|
private int |
RESPONSE_ADDRESS
Response buffer address.
|
private int |
RESPONSE_BUFFER_LENGTH
Response buffer size.
|
private int |
RESPONSE_CHECKSUM_INDEX
Response buffer checksum byte index.
|
private int |
RESPONSE_DATA_LENGTH
Response data length.
|
private int[] |
solar
Solar averaging buffer.
|
private int |
SOLAR_INTENSITY_INDEX
Response buffer solar intensity index.
|
private java.lang.String |
SOLAR_NAME
Data name.
|
private int |
solarIndex
Solar averaging buffer index.
|
private int[] |
speed
Anemometer averaging buffer.
|
private int |
speedIndex
Anemometer averaging buffer index.
|
private int |
WIND_DIRECTION_INDEX
Response buffer wind direction index.
|
private int |
WIND_SPEED_INDEX
Response buffer wind speed index.
|
private java.lang.String |
WINDVANE_NAME
Data name.
|
Modifier | Constructor and Description |
---|---|
private |
WindTask() |
Modifier and Type | Method and Description |
---|---|
private void |
accessDevice()
Access device and process data.
|
private void |
checksum(byte[] data,
int length,
byte checksum)
Performs a checksum on received data.
|
private void |
executeCommand(byte[] command)
Executes a command, then spins in a loop waiting for it to complete.
|
private java.lang.Number |
getAverageSpeed()
Gets the average wind speed in meters/sec.
|
private java.lang.Number |
getDirection()
Gets windvane direction.
|
private java.lang.Number |
getSolarIntensity()
Gets solar intensity.
|
private void |
initDevice()
Initializes the sensor for operation.
|
private byte[] |
readResponse()
Reads the response buffer, performs checksum for validation.
|
void |
run()
Gets the implementation specific read task data from the WSI603A and
posts it to the data exchange.
|
private void |
writeBytes(int address,
byte[] data)
Writes a data buffer to the DS2760 and reads it back for validation.
|
private final java.lang.String ANEMOMETER_NAME
private final java.lang.String SOLAR_NAME
private final java.lang.String WINDVANE_NAME
private final int COMMAND_ADDRESS
private final int RESPONSE_ADDRESS
private final int RESPONSE_BUFFER_LENGTH
private final int RESPONSE_CHECKSUM_INDEX
private final int RESPONSE_DATA_LENGTH
private final int COMMAND_INDEX
private final int WIND_SPEED_INDEX
private final int WIND_DIRECTION_INDEX
private final int LED_GET_STATUS_INDEX
private final int SOLAR_INTENSITY_INDEX
private final int[] speed
private int speedIndex
private final int[] solar
private int solarIndex
private final int[] direction
private int directionIndex
private boolean initialize
public void run()
run
in interface java.lang.Runnable
private void initDevice() throws com.dalsemi.onewire.OneWireException, ServiceException
Note: the LED control command needs to be the last command sent to the device on initialization, because the WSI-603A uses a standing LED command to send the weather data.
com.dalsemi.onewire.OneWireException
- if 1-Wire communication fails.ServiceException
- if initialization fails.private void accessDevice() throws com.dalsemi.onewire.OneWireException, ServiceException
com.dalsemi.onewire.OneWireException
- if 1-Wire communication fails.ServiceException
- if initialization fails.private java.lang.Number getAverageSpeed()
private java.lang.Number getSolarIntensity()
private java.lang.Number getDirection() throws ValueException
ValueException
- if data is out of range.private void executeCommand(byte[] command) throws com.dalsemi.onewire.OneWireException, ServiceException
command
- to execute.com.dalsemi.onewire.OneWireException
- if 1-Wire communication fails.ServiceException
- if a command times out or validation fails.private byte[] readResponse() throws com.dalsemi.onewire.OneWireException, ServiceException
com.dalsemi.onewire.OneWireException
- if 1-Wire communication fails.ServiceException
- if validation fails.private void writeBytes(int address, byte[] data) throws com.dalsemi.onewire.OneWireException, ServiceException
address
- in memory to write.data
- to write.com.dalsemi.onewire.OneWireException
- if 1-Wire communication fails.ServiceException
- if data validation fails.private void checksum(byte[] data, int length, byte checksum) throws ServiceException
data
- to check, including the checksum.length
- of the datachecksum
- value the data sum should equal.ServiceException
- if checksum doesn't match, or no data.