
public class BaseSensor extends EV3DevSensorDevice 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 |
protected static int |
SWITCH_DELAY |
LEGO_ANALOG_SENSOR, LEGO_UART_SENSOR, SENSOR_MODE, SENSOR_MODESADDRESS, DEVICE, LEGO_PORT, LEGO_SENSOR, MODE, PATH_DEVICEDEVICE_ROOT_PATHBRICKPI, EV3BRICK, PISTORMS| Constructor and Description |
|---|
BaseSensor(java.lang.String sensorPort,
java.lang.String mode) |
BaseSensor(java.lang.String sensorPort,
java.lang.String mode,
java.lang.String device) |
| Modifier and Type | Method and Description |
|---|---|
void |
fetchSample(float[] sample,
int offset) |
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 sensors mode
|
private boolean |
isValid(int mode) |
int |
sampleSize() |
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 sensors.
|
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 sensors to settle in the new mode.
|
protected void |
switchMode(java.lang.String newMode,
long switchDelay) |
detect, getIntegerAttribute, getStringAttribute, setIntegerAttribute, setStringAttributegetMotorPort, getPlatform, getSensorPortprotected static final int SWITCH_DELAY
protected int currentMode
protected java.lang.String currentModeS
protected SensorMode[] modes
java.util.ArrayList<java.lang.String> modeList
public BaseSensor(java.lang.String sensorPort,
java.lang.String mode,
java.lang.String device)
public BaseSensor(java.lang.String sensorPort,
java.lang.String mode)
protected void setModes(SensorMode[] m)
m - An array containing a list of modespublic java.util.ArrayList<java.lang.String> getAvailableModes()
SensorModesgetAvailableModes in interface SensorModespublic SensorMode getMode(int mode)
SensorModesgetMode in interface SensorModesmode - the mode numberpublic SensorMode getMode(java.lang.String modeName)
SensorModesgetMode in interface SensorModesmodeName - the name/description of the modeprivate boolean isValid(int mode)
private int getIndex(java.lang.String modeName)
public java.lang.String getName()
SensorModegetName in interface SensorModepublic int sampleSize()
public void fetchSample(float[] sample,
int offset)
public void setCurrentMode(int mode)
SensorModessetCurrentMode in interface SensorModesmode - 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)
SensorModessetCurrentMode in interface SensorModesmodeName - the name of the mode. name corresponds with the item value of the list from getAvailableModes().public int getCurrentMode()
SensorModesgetCurrentMode in interface SensorModespublic int getModeCount()
SensorModesgetModeCount in interface SensorModesprotected 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)