|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.dalsemi.onewire.container.OneWireContainer | +--com.dalsemi.onewire.container.OneWireContainer21
The DS1921L-F5X Thermochron iButtons are rugged, self-sufficient systems that, once setup for a mission, measure temperature and record the result in a protected memory section. The recording is doneat a user-defined rate, both as a direct storage of temperature values at incrementing memory addresses and as a histogram. Up to 2048 periodic temperature readings may be taken on each mission. If a temperature value leaves a user specified range, the thermochron will record when this happened and how long the condition occured for.
Example of starting a mission with this container: // ds1921 previously setup as a OneWireContainer21 ds1921.clearMemory(); // read the current state of the device byte[] state = ds1921.readDevice(); // enable rollover ds1921.setFlag(ds1921.CONTROL_REGISTER, ds1921.ROLLOVER_ENABLE_FLAG, true, state); // set the high temperature alarm to 28 C ds1921.setTemperatureAlarm(ds1921.ALARM_HIGH, 28.0, state); // set the low temperature alarm to 23 C ds1921.setTemperatureAlarm(ds1921.ALARM_LOW, 23.0, state); // set the clock alarm to occur weekly, mondays at 12:30:45 pm ds1921.setClockAlarm(12, 30, 45, 2, ds1921.ONCE_PER_WEEK, state); // set the real time clock to the system's current clock ds1921.setClock((new Date(System.currentTimeMillis())).getTime(), state); // set the mission to start in 2 minutes ds1921.setMissionStartDelay(2,state); // make sure the clock is set to run ds1921.setClockRunEnable(true, state); // make sure the clock alarm is enabled ds1921.setClockAlarmEnable(true, state); // write all that information out ds1921.writeDevice(state); // now enable the mission with a sample rate of 1 minute ds1921.enableMission(1);
Field Summary | |
static int |
CONTROL_REGISTER
Address of the control register. |
static byte |
MEMORY_CLEAR_ENABLE_FLAG
CONTROL REGISTER FLAG: Must be enabled to enable the clear memory function. |
static byte |
MEMORY_CLEARED_FLAG
STATUS REGISTER FLAG: Will read back true if the memory has been cleared. |
static byte |
MISSION_ENABLE_FLAG
CONTROL REGISTER FLAG: When DISABLED, the mission will start as soon as the sample rate is written. |
static byte |
MISSION_IN_PROGRESS_FLAG
STATUS REGISTER FLAG: Will read back true when a mission is in progress. |
static byte |
ONCE_PER_DAY
Alarm frequency setting. |
static byte |
ONCE_PER_HOUR
Alarm frequency setting. |
static byte |
ONCE_PER_MINUTE
Alarm frequency setting |
static byte |
ONCE_PER_SECOND
Alarm frequency setting. |
static byte |
ONCE_PER_WEEK
Alarm frequency setting. |
static byte |
OSCILLATOR_ENABLE_FLAG
CONTROL REGISTER FLAG: When DISABLED, the real time clock will start working. |
static byte |
ROLLOVER_ENABLE_FLAG
CONTROL REGISTER FLAG: When enabled, the device will begin overwriting the earlier temperature measurements when the memory becomes full. |
static byte |
SAMPLE_IN_PROGRESS_FLAG
STATUS REGISTER FLAG: Will read back true when a mission temperature conversion is in progress To be used with getFlag. |
static int |
STATUS_REGISTER
Address of the status register. |
static byte |
TEMP_CORE_BUSY_FLAG
STATUS REGISTER FLAG: Will read back true if a temperature conversion of any kind is in progress. |
static byte |
TEMP_HIGH_SEARCH_FLAG
CONTROL REGISTER FLAG: When enabled, the device will respond to conditional search command if the temperature has reached the high temperature threshold. |
static byte |
TEMP_LOW_SEARCH_FLAG
CONTROL REGISTER FLAG: When enabled, the device will respond to conditional search command if the temperature has reached the low temperature threshold. |
static byte |
TEMPERATURE_HIGH_ALARM
Type of alarm triggered when the temperature goes above the temperature threshold. |
static byte |
TEMPERATURE_HIGH_FLAG
STATUS REGISTER FLAG: Will read back true when the temperature during a mission reaches or exceeds the temperature high threshold. |
static byte |
TEMPERATURE_LOW_ALARM
Type of alarm triggered when temperature goes below the temperature threshold. |
static byte |
TEMPERATURE_LOW_FLAG
STATUS REGISTER FLAG: Will read back true when a temperature equal to or below the low temperature threshold was detected on a mission. |
static byte |
TIMER_ALARM
Type of alarm triggered when time reaches that set in alarm clock regs. |
static byte |
TIMER_ALARM_FLAG
STATUS REGISTER FLAG: Will read back true when a clock alarm has occured. |
static byte |
TIMER_ALARM_SEARCH_FLAG
CONTROL REGISTER FLAG: When enabled, the device will respond to conditional search command if a timer alarm has occured. |
Fields inherited from interface com.dalsemi.onewire.container.TemperatureContainer |
ALARM_HIGH, ALARM_LOW |
Constructor Summary | |
OneWireContainer21()
Default constructor |
|
OneWireContainer21(DSPortAdapter sourceAdapter,
byte[] newAddress)
Create a container with a provided adapter object and the address of the iButton or 1-Wire device. |
|
OneWireContainer21(DSPortAdapter sourceAdapter,
long newAddress)
Create a container with a provided adapter object and the address of the iButton or 1-Wire device. |
|
OneWireContainer21(DSPortAdapter sourceAdapter,
java.lang.String newAddress)
Create a container with a provided adapter object and the address of the iButton or 1-Wire device. |
Method Summary | |
boolean |
canDisableClock()
Query to see if the clock can be disabled. |
void |
clearMemory()
Clears the memory - Must be run before setup for a new mission. |
double |
decodeTemperature(byte tempByte)
Convert a temperature from the DS1921 byte format to degrees celcius. |
void |
disableMission()
Disable a mission that is in progress. |
void |
doTemperatureConvert(byte[] state)
Perform an temperature conversion. |
void |
enableMission(int sampleRate)
Tells the DS1921 to begin its mission. |
byte |
encodeTemperature(double temperature)
Convert a temperature (degrees celcius) to a byte formatted for the DS1921. |
byte[] |
getAlarmHistory(byte alarmBit)
Returns an array containing the alarm log. |
boolean |
getAlarmStatus(byte alarmBit,
byte[] state)
Returns true if the specified alarm has been triggered. |
java.util.Calendar |
getAlarmTime(byte[] state)
Get the alarm clock time settings. |
java.lang.String |
getAlternateNames()
Return the alternate Dallas Semiconductor part number or name. |
long |
getClock(byte[] state)
This method extracts the Clock Value in milliseconds from the state data retrieved from the 'readDevice()' method. |
long |
getClockAlarm(byte[] state)
This method extracts the Clock Alarm Value from the provided state data retrieved from the 'readDevice()' method. |
long |
getClockResolution()
Query to get the clock resolution in milliseconds |
java.lang.String |
getDescription()
Return a short description of the function of the iButton type. |
int |
getDeviceSamplesCounter(byte[] state)
Read the device samples counter and determine the number of samples taken by this device. |
long |
getFirstLogOffset(byte[] state)
This method is a convenience method to help determine the times for values in a temperature log. |
boolean |
getFlag(int register,
byte bitMask)
Get the flag located in the specified register and return its status. |
boolean |
getFlag(int register,
byte bitMask,
byte[] state)
Get the flag located in the specified register and return its status. |
int |
getMaxSpeed()
Returns the maximum speed this iButton or 1-Wire device can communicate at. |
double |
getMaxTemperature()
Query to get the maximum temperature in degrees C. |
java.util.Enumeration |
getMemoryBanks()
Return an enumeration of memory banks. |
double |
getMinTemperature()
Query to get the minimum temperature in degrees C. |
int |
getMissionSamplesCounter(byte[] state)
Read the Mission Samples Counter and determine the number of samples taken on this mission. |
java.util.Calendar |
getMissionTimeStamp(byte[] state)
Returns the date and time that the Mission was first started. |
java.lang.String |
getName()
Returns the Dallas Semiconductor part number of the iButton as a string. |
int |
getSampleRate(byte[] state)
Return the rate at which the DS1921 takes temperature measurements. |
double |
getTemperature(byte[] state)
This method extracts the Temperature Value in degrees C from the state data retrieved from the 'readDevice()' method. |
double |
getTemperatureAlarm(int alarmType,
byte[] state)
This method extracts the specified Alarm value in degrees C from the state data retrieved from the 'readDevice()' method. |
double |
getTemperatureAlarmResolution()
Query to get the high/low resolution in degrees C. |
int[] |
getTemperatureHistogram()
Return an array of int values representing the 63 counter bins holding the DS1921 histogram data. For the temperature histogram the DS1921 provides 63 bins that each consist of a 16-bit non rolling-over binary counter that is incremented each time a temperature value acquired during a mission falls into the range of the bin. |
byte[] |
getTemperatureLog(byte[] state)
Return the log of temperature measurements. |
double |
getTemperatureResolution(byte[] state)
This method extracts the current resolution in degrees C from the state data retrieved from the 'readDevice()' method. |
double[] |
getTemperatureResolutions()
Query to get an array of available resolutions in degrees C. |
boolean |
hasClockAlarm()
Query to see if the clock has an alarm feature. |
boolean |
hasSelectableTemperatureResolution()
Query to see if this device has selectable resolution. |
boolean |
hasTemperatureAlarms()
Query to see if this temperature measuring device has high/low trip alarms. |
boolean |
isClockAlarmEnabled(byte[] state)
This method checks if the Clock Alarm is enabled from the provided state data retrieved from the 'readDevice()' method. |
boolean |
isClockAlarming(byte[] state)
This method checks if the Clock Alarm flag has been set from the state data retrieved from the 'readDevice()' method. |
boolean |
isClockRunning(byte[] state)
This method checks if the device's oscilator is enabled. |
byte |
readByte(int memAddr)
Read a single byte from the DS1921. |
byte[] |
readDevice()
This method retrieves the 1-Wire device sensor state. |
void |
setClock(long time,
byte[] state)
This method sets the Clock time in the provided state data Use the method 'writeDevice()' with this data to finalize the change to the device. |
void |
setClockAlarm(int hours,
int minutes,
int seconds,
int day,
int alarmFrequency,
byte[] state)
Set the DS1921's alarm clock's time. |
void |
setClockAlarm(long time,
byte[] state)
This method sets the Clock Alarm in the provided state data. |
void |
setClockAlarmEnable(boolean alarmEnable,
byte[] state)
This method sets the Clock Alarm enable. |
void |
setClockRunEnable(boolean runEnable,
byte[] state)
This method sets the oscillator enable to the specified value. |
void |
setFlag(int register,
byte bitMask,
boolean flagValue)
Set the flag located in the specified register. |
void |
setFlag(int register,
byte bitMask,
boolean flagValue,
byte[] state)
Method setFlag |
void |
setMissionStartDelay(int missionStartDelay,
byte[] state)
Sets the time to wait before starting the mission. |
void |
setSpeedCheck(boolean doSpeedCheck)
To ensure that all parts can talk to the onewire bus at their desired speed, each method contains a call to doSpeed(). |
void |
setTemperatureAlarm(int alarmType,
double alarmValue,
byte[] state)
This method sets the alarm value in degrees C in the provided state data. |
void |
setTemperatureResolution(double resolution,
byte[] state)
This method sets the current resolution in degrees C in the provided state data. |
void |
writeByte(int memAddr,
byte source)
Write a byte of data into the DS1921's memory. |
void |
writeDevice(byte[] state)
This method write the 1-Wire device sensor state that have been changed by the 'set' methods. |
Methods inherited from class com.dalsemi.onewire.container.OneWireContainer |
doSpeed, getAdapter, getAddress, getAddressAsLong, getAddressAsString, isAlarming, isPresent, setSpeed, setupContainer, setupContainer, setupContainer |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int STATUS_REGISTER
public static final int CONTROL_REGISTER
public static final byte ONCE_PER_SECOND
public static final byte ONCE_PER_MINUTE
public static final byte ONCE_PER_HOUR
public static final byte ONCE_PER_DAY
public static final byte ONCE_PER_WEEK
public static final byte TEMPERATURE_LOW_ALARM
public static final byte TEMPERATURE_HIGH_ALARM
public static final byte TIMER_ALARM
public static final byte TIMER_ALARM_SEARCH_FLAG
public static final byte TEMP_HIGH_SEARCH_FLAG
public static final byte TEMP_LOW_SEARCH_FLAG
public static final byte ROLLOVER_ENABLE_FLAG
public static final byte MISSION_ENABLE_FLAG
public static final byte MEMORY_CLEAR_ENABLE_FLAG
public static final byte OSCILLATOR_ENABLE_FLAG
public static final byte TIMER_ALARM_FLAG
public static final byte TEMPERATURE_HIGH_FLAG
public static final byte TEMPERATURE_LOW_FLAG
public static final byte SAMPLE_IN_PROGRESS_FLAG
public static final byte MISSION_IN_PROGRESS_FLAG
public static final byte MEMORY_CLEARED_FLAG
public static final byte TEMP_CORE_BUSY_FLAG
Constructor Detail |
public OneWireContainer21()
public OneWireContainer21(DSPortAdapter sourceAdapter, byte[] newAddress)
sourceAdapter
- adapter object required to communicate with
this iButton.newAddress
- address of this 1-Wire devicepublic OneWireContainer21(DSPortAdapter sourceAdapter, long newAddress)
sourceAdapter
- adapter object required to communicate with
this iButton.newAddress
- address of this 1-Wire devicepublic OneWireContainer21(DSPortAdapter sourceAdapter, java.lang.String newAddress)
sourceAdapter
- adapter object required to communicate with
this iButton.newAddress
- address of this 1-Wire deviceMethod Detail |
public java.util.Enumeration getMemoryBanks()
getMemoryBanks
in class OneWireContainer
com.dalsemi.onewire.container.OneWireContainer
public void setSpeedCheck(boolean doSpeedCheck)
doSpeedCheck
- True if you want doSpeed() called before every
onewire bus access. False to skip this expensive
call.public int getMaxSpeed()
getMaxSpeed
in class OneWireContainer
public java.lang.String getName()
getName
in class OneWireContainer
public java.lang.String getAlternateNames()
getAlternateNames
in class OneWireContainer
public java.lang.String getDescription()
getDescription
in class OneWireContainer
public double decodeTemperature(byte tempByte)
tempByte
- raw DS1921 temperature reading.public byte encodeTemperature(double temperature)
temperature
- the temperature to convert.public void writeByte(int memAddr, byte source) throws OneWireIOException, OneWireException
memAddr
- the address to write the byte at. (Usually in
the range of 0x200-0x21F)source
- the data byte to write to memory.OneWireIOException
- Data wasnt written properly [ recoverable ]OneWireException
- Part could not be found [ fatal ]public byte readByte(int memAddr) throws OneWireIOException, OneWireException
int
- representation of the address to read from.memAddr
- The address to read from. Registers begin at address
0x200 and end at address 0x21F.OneWireIOException
- Data was not read correctly [ recoverable ]OneWireException
- Could not find the part [ fatal ]public boolean getFlag(int register, byte bitMask) throws OneWireIOException, OneWireException
register
- address of register containing the flag.bitMask
- bitmask representing the flag. There are 7
valid parameters for each register. See "FIELD SUMMARY" for a listing.OneWireIOException
- Data was not read correctly [ recoverable ]OneWireException
- Could not find the part [ fatal ]public boolean getFlag(int register, byte bitMask, byte[] state)
register
- address of register containing the flag.bitMask
- bitmask representing the flag. There are 7
valid parameters for each register. See "FIELD SUMMARY" for a listing.state
- State of Thermocron returned from readDevice().public void setFlag(int register, byte bitMask, boolean flagValue) throws OneWireIOException, OneWireException
register
- the address of the target register.
Valid parameters: CONTROL_REGISTER, STATUS_REGISTER.
bitMask
- bitmask representing the flag. There are 7
valid parameters for each register. See "FIELD SUMMARY" for details.flagValue
- value to set flag at.OneWireIOException
- Data was not written correctly [ recoverable ]OneWireException
- Could not find the part [ fatal ]public void setFlag(int register, byte bitMask, boolean flagValue, byte[] state)
register
- bitMask
- flagValue
- state
- public void enableMission(int sampleRate) throws OneWireIOException, OneWireException
sampleRate
- the number of minutes to wait in between temp readings.OneWireIOException
- Mission was not started [ recoverable ]OneWireException
- Could not find the part [ fatal ]public void disableMission() throws OneWireIOException, OneWireException
OneWireIOException
- Mission was not stopped [ recoverable ]OneWireException
- Could not find the part [ fatal ]public void setMissionStartDelay(int missionStartDelay, byte[] state)
missionStartDelay
- specifies the time, in minutes, to delay.state
- State of Thermocron returned from readDevice().public void clearMemory() throws OneWireIOException, OneWireException
OneWireIOException
- Memory was not cleared [ recoverable ]OneWireException
- Could not find the part [ fatal ]public java.util.Calendar getAlarmTime(byte[] state)
state
- State of Thermocron returned from readDevice().public void setClockAlarm(int hours, int minutes, int seconds, int day, int alarmFrequency, byte[] state)
hours
- The hour of the day for the clock alarmminutes
- The minute setting for the clock alarmseconds
- The second setting for the clock alarmday
- The day of the week for the clock alarm. The value
must be between 1 (Sunday) and 7 (Saturday).alarmFrequency
- representation of the alarm frequency.
Valid parameters are: ONCE_PER_SECOND, ONCE_PER_MINUTE, ONCE_PER_HOUR, ONCE_PER_DAY, ONCE_PER_WEEK.
state
- State of Thermocron returned from readDevice().public int getSampleRate(byte[] state)
state
- State of Thermocron returned from readDevice().public int getMissionSamplesCounter(byte[] state)
state
- State of Thermocron returned from readDevice().public int getDeviceSamplesCounter(byte[] state)
state
- State of Thermocron returned from readDevice().public java.util.Calendar getMissionTimeStamp(byte[] state)
state
- State of Thermocron returned from readDevice().public long getFirstLogOffset(byte[] state)
state
- State of Thermocron returned from readDevice().public byte[] getTemperatureLog(byte[] state) throws OneWireIOException, OneWireException
state
- State of Thermocron returned from readDevice().OneWireIOException
- Did not read the memory [ recoverable ]OneWireException
- Could not find the part [ fatal ]public int[] getTemperatureHistogram() throws OneWireIOException, OneWireException
OneWireIOException
- Did not read the memory [ recoverable ]OneWireException
- Could not find the part [ fatal ]public boolean getAlarmStatus(byte alarmBit, byte[] state) throws OneWireIOException, OneWireException
alarmBit
- a bitmask indicating the alarm to check.
Acceptable parameters: TEMPERATURE_LOW_ALARM, TEMPERATURE_HIGH_ALARM,
TIMER_ALARM.state
- State of Thermocron returned from readDevice().public byte[] getAlarmHistory(byte alarmBit) throws OneWireIOException, OneWireException
alarmBit
- representing the alarm log to get.
Acceptable parameters: TEMPERATURE_LOW_ALARM, TEMPERATURE_HIGH_ALARM.
byte[] data = ds1921.getAlarmHistory(TEMPERATURE_HIGH_ALARM);
. . .
for (int i=0;i < data.length/4; i++)
{
start_offset = (data [i * 4] & 0x0ff)
| ((data [i * 4 + 1] << 8) & 0x0ff00)
| ((data [i * 4 + 2] << 16) & 0x0ff0000);
violation_count = 0x0ff & data[i*4+3];
. . .
// note: you may find it useful to multiply start_offset
// by getSampleRate() in order to get the number of
// minutes into the mission that the violation occurred
// on. You can do the same with violation_count
// to determine how long the violation lasted.
OneWireIOException
- Did not read the memory [ recoverable ]OneWireException
- Could not find the part [ fatal ]public byte[] readDevice() throws OneWireIOException, OneWireException
readDevice
in interface OneWireSensor
OneWireIOException
- OneWireException
- Could not find the part [ fatal ]public void writeDevice(byte[] state) throws OneWireIOException, OneWireException
writeDevice
in interface OneWireSensor
state
- byte array of clock register page contentsOneWireIOException
- OneWireException
- Could not find the part [ fatal ]public boolean hasTemperatureAlarms()
hasTemperatureAlarms
in interface TemperatureContainer
public boolean hasSelectableTemperatureResolution()
hasSelectableTemperatureResolution
in interface TemperatureContainer
public double[] getTemperatureResolutions()
getTemperatureResolutions
in interface TemperatureContainer
public double getTemperatureAlarmResolution()
getTemperatureAlarmResolution
in interface TemperatureContainer
public double getMaxTemperature()
getMaxTemperature
in interface TemperatureContainer
public double getMinTemperature()
getMinTemperature
in interface TemperatureContainer
public void doTemperatureConvert(byte[] state) throws OneWireIOException, OneWireException
doTemperatureConvert
in interface TemperatureContainer
state
- byte array of device stateOneWireIOException
- OneWireException
- Could not find the part [ fatal ]public double getTemperature(byte[] state)
getTemperature
in interface TemperatureContainer
state
- byte array of device statepublic double getTemperatureAlarm(int alarmType, byte[] state)
getTemperatureAlarm
in interface TemperatureContainer
alarmType
- integer, indicating trip type ALARM_HIGH (1)
or ALARM_LOW (0)state
- byte array of device statepublic double getTemperatureResolution(byte[] state)
getTemperatureResolution
in interface TemperatureContainer
state
- byte array of device statepublic void setTemperatureAlarm(int alarmType, double alarmValue, byte[] state)
setTemperatureAlarm
in interface TemperatureContainer
alarmType
- integer, indicating trip type ALARM_HIGH (1)
or ALARM_LOW (0)alarmValue
- double, high trip value in degrees Cstate
- byte array of device statepublic void setTemperatureResolution(double resolution, byte[] state) throws OneWireException, OneWireIOException
setTemperatureResolution
in interface TemperatureContainer
resolution
- double, temperature resolution in degrees Cstate
- byte array of device statepublic boolean hasClockAlarm()
hasClockAlarm
in interface ClockContainer
public boolean canDisableClock()
canDisableClock
in interface ClockContainer
public long getClockResolution()
getClockResolution
in interface ClockContainer
public long getClock(byte[] state)
getClock
in interface ClockContainer
state
- byte array of device statepublic long getClockAlarm(byte[] state)
getClockAlarm
in interface ClockContainer
state
- byte array of device statepublic boolean isClockAlarming(byte[] state)
isClockAlarming
in interface ClockContainer
state
- byte array of device statepublic boolean isClockAlarmEnabled(byte[] state)
isClockAlarmEnabled
in interface ClockContainer
state
- byte array of device statepublic boolean isClockRunning(byte[] state)
isClockRunning
in interface ClockContainer
state
- byte array of device statepublic void setClock(long time, byte[] state)
setClock
in interface ClockContainer
time
- millisecond value (from 1970) the user
wants the Clock set to.state
- byte array of device statepublic void setClockAlarm(long time, byte[] state) throws OneWireException
setClockAlarm
in interface ClockContainer
time
- millisecond value (from 1970) the user
wants the Clock alarm set to.state
- byte array of device statepublic void setClockRunEnable(boolean runEnable, byte[] state)
setClockRunEnable
in interface ClockContainer
runEnable
- boolean, true if want the clock oscillator to
be enabled.state
- byte array of device statepublic void setClockAlarmEnable(boolean alarmEnable, byte[] state)
setClockAlarmEnable
in interface ClockContainer
alarmEnable
- boolean, true to enable the clock alarmstate
- byte array of device state
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |