public class EnvironmentCustomer extends Object
EnviroCustomer envCustomer = new EnviroCustomer();
envCustomer.addVariable(EnviroData.WATER_TEMP);
envCustomer.addVariable(EnviroData.SALINITY);
envCustomer.setUpdatePeriod(5*1000); // 5 secs.
envCustomer.addListener(new EnviroAdapter()
{
// Override methods of interest
public void updateWaterTemp(double value,double lat, double lon, double depth, Date time)
{
// Do something with value
}
public void updateSalinity(double value,double lat, double lon, double depth, Date time)
{
// Do something with value
}
// The following are typically called immediately before the update* methods.
public double getLatitude()
{
return myCurrentLatitude;
}
public double getLongitude()
{
return myCurrentLongitude;
}
public double getDepth()
{
return myCurrentDepth();
}
public Date getTime()
{
return myCurrentTime;
}
});
envCustomer.startUpdates();
// At end of mission:
envCustomer.stopUpdates();
This class retrieves data from the EnviroData instance, one of which (per physical machine)
retrieves the data. It, in turn, is configured through the configuration/c_environ.xml file, which
describes the data source(s).| Modifier and Type | Class and Description |
|---|---|
static class |
EnvironmentCustomer.EnviroAdapter
Convenience class implementing EnviroListener.
|
static interface |
EnvironmentCustomer.EnviroListener
Definition of the interface for listeners to receive updates from this EnviroCustomer object.
|
| Constructor and Description |
|---|
EnvironmentCustomer(boolean relativeTime) |
| Modifier and Type | Method and Description |
|---|---|
void |
addListener(EnvironmentCustomer.EnviroListener list)
Add a listener for updates.
|
void |
addVariable(int var)
Add a variable to the list of variables which will be reported at the next scheduled update.
|
void |
removeAllListeners() |
void |
setUpdatePeriod(long period)
Set the period between variable updates.
|
void |
setVariableList(Set<Integer> vars)
Adds all variables in the set to the list of variables which will be reported at the next
scheduled update.
|
void |
startUpdates()
Begin data updates at the previously set update period (default: 60 seconds)
|
void |
stopUpdates()
Stop updates.
|
void |
unsetVariableList(Set<Integer> vars)
Removes all variables in the set from the list of variables which will be reported at the next
scheduled update.
|
public void startUpdates()
public void stopUpdates()
public void setUpdatePeriod(long period)
period - units = millisecondspublic void addVariable(int var)
var - int value from EnviroDatapublic void setVariableList(Set<Integer> vars)
vars - Set of Integers objects representing variable IDs in EnviroDatapublic void unsetVariableList(Set<Integer> vars)
vars - Set of Integers objects representing variable IDs in EnviroDatapublic void addListener(EnvironmentCustomer.EnviroListener list)
list - object implementing the EnviroListener interfacepublic void removeAllListeners()