public class BaseSensor extends EV3DevDevice implements SensorModes
Modifier and Type | Field and Description |
---|---|
protected int |
currentMode |
protected java.lang.String |
currentModeS |
(package private) java.util.ArrayList<java.lang.String> |
modeList |
protected SensorMode[] |
modes |
private static java.lang.String |
SENSOR_MODE |
private static java.lang.String |
SENSOR_MODES |
private static java.lang.String |
SYSTEM_CLASS_NAME |
PATH_DEVICE
Constructor and Description |
---|
BaseSensor(java.lang.String sensorPort) |
Modifier and Type | Method and Description |
---|---|
void |
fetchSample(float[] sample,
int offset)
Fetches a sample from a sensor or filter.
|
java.util.ArrayList<java.lang.String> |
getAvailableModes()
Return a list of string descriptions for the sensors available modes.
|
int |
getCurrentMode()
Gets the index number of the current mode.
|
private int |
getIndex(java.lang.String modeName) |
SensorMode |
getMode(int mode)
Return the sample provider interface for the requested mode
|
SensorMode |
getMode(java.lang.String modeName)
Return the sample provider for the request mode
|
int |
getModeCount()
Gets the number of supported modes
|
java.lang.String |
getName()
return a string description of this sensor mode
|
private boolean |
isValid(int mode) |
int |
sampleSize()
Returns the number of elements in a sample.
|
void |
setCurrentMode(int mode)
Sets the current mode for fetching samples
|
void |
setCurrentMode(java.lang.String modeName)
Sets the current mode for fetching samples
|
protected void |
setModes(SensorMode[] m)
Define the set of modes to be made available for this sensor.
|
protected void |
switchMode(int newMode,
long switchDelay)
Switch to the selected mode (if not already in that mode) and delay for the
specified period to allow the sensor to settle in the new mode.
|
protected void |
switchMode(java.lang.String newMode,
long switchDelay) |
connect, getIntegerAttribute, getStringAttribute, setIntegerAttribute, setStringAttribute
getElements, readFloat, readInteger, readString, writeInteger, writeString
close, releaseOnClose
private static final java.lang.String SYSTEM_CLASS_NAME
private static final java.lang.String SENSOR_MODES
private static final java.lang.String SENSOR_MODE
protected int currentMode
protected java.lang.String currentModeS
protected SensorMode[] modes
java.util.ArrayList<java.lang.String> modeList
protected void setModes(SensorMode[] m)
m
- An array containing a list of modespublic java.util.ArrayList<java.lang.String> getAvailableModes()
SensorModes
getAvailableModes
in interface SensorModes
public SensorMode getMode(int mode)
SensorModes
getMode
in interface SensorModes
mode
- the mode numberpublic SensorMode getMode(java.lang.String modeName)
SensorModes
getMode
in interface SensorModes
modeName
- the name/description of the modeprivate boolean isValid(int mode)
private int getIndex(java.lang.String modeName)
public java.lang.String getName()
SensorMode
getName
in interface SensorMode
public int sampleSize()
SampleProvider
sampleSize
in interface SampleProvider
public void fetchSample(float[] sample, int offset)
SampleProvider
fetchSample
in interface SampleProvider
sample
- The array to store the sample in.offset
- The elements of the sample are stored in the array starting at the offset position.public void setCurrentMode(int mode)
SensorModes
setCurrentMode
in interface SensorModes
mode
- the index number of the mode. Index number corresponds with the item order of the list from getAvailableModes().public void setCurrentMode(java.lang.String modeName)
SensorModes
setCurrentMode
in interface SensorModes
modeName
- the name of the mode. name corresponds with the item value of the list from getAvailableModes().public int getCurrentMode()
SensorModes
getCurrentMode
in interface SensorModes
public int getModeCount()
SensorModes
getModeCount
in interface SensorModes
protected void switchMode(int newMode, long switchDelay)
newMode
- The mode to switch to.switchDelay
- Time in mS to delay after the switch.protected void switchMode(java.lang.String newMode, long switchDelay)