Package lejos.hardware.device
Class DeviceIdentifier
- java.lang.Object
-
- lejos.hardware.Device
-
- lejos.hardware.device.DeviceIdentifier
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,EV3SensorConstants
public class DeviceIdentifier extends Device implements EV3SensorConstants
-
-
Field Summary
Fields Modifier and Type Field Description protected static intANALOG_ID_VARprotected ConfigurationPortconfigPortprotected static java.util.List<java.util.AbstractMap.SimpleEntry<java.lang.Integer,java.lang.String>>EV3AnalogMapprotected static longMIN_TIMEprotected longopenTimeprotected Portportprotected static longVALID_TIME-
Fields inherited from interface lejos.hardware.sensor.EV3SensorConstants
ADC_REF, ADC_RES, CMD_AUTOMATIC, CMD_COL_AMB, CMD_COL_BLU, CMD_COL_COL, CMD_COL_GRN, CMD_COL_RED, CMD_CONNECTED, CMD_DISCONNECTED, CMD_FLOAT, CMD_NONE, CMD_PIN1, CMD_PIN5, CMD_SET, CONN_DAISYCHAIN, CONN_ERROR, CONN_INPUT_DUMB, CONN_INPUT_UART, CONN_NONE, CONN_NXT_COLOR, CONN_NXT_DUMB, CONN_NXT_IIC, CONN_OUTPUT_DUMB, CONN_OUTPUT_INTELLIGENT, CONN_OUTPUT_TACHO, CONN_UNKNOWN, IIC_DATA_LENGTH, MAX_DEVICE_DATALENGTH, MOTORS, PORTS, STATUS_BUSY, STATUS_FAIL, STATUS_OK, STATUS_STOP, TYPE_ERROR, TYPE_IIC_UNKNOWN, TYPE_MINITACHO, TYPE_NEWTACHO, TYPE_NONE, TYPE_NXT_COLOR, TYPE_NXT_IIC, TYPE_NXT_LIGHT, TYPE_NXT_SOUND, TYPE_NXT_TEST, TYPE_NXT_TOUCH, TYPE_TACHO, TYPE_TERMINAL, TYPE_THIRD_PARTY_END, TYPE_THIRD_PARTY_START, TYPE_UNKNOWN, UART_MAX_MODES
-
-
Constructor Summary
Constructors Constructor Description DeviceIdentifier(Port port)Create an instance of the device identifier for a particular port
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Close the sensor.java.lang.StringgetDeviceSignature(boolean full)return the signature of the attached device.intgetDeviceType()This method returns information on the sensor/motor that is attached to the specified port.protected java.lang.StringgetEV3DumbSignature()Returns the signature for a dumb EV3 sensorprotected java.lang.StringgetI2CSignature(boolean full)Returns the signature for a i2c sensorprotected java.lang.StringgetMotorSignature()Returns the signature for a motor/output deviceprotected java.lang.StringgetNXTDumbSignature()Returns the signature for a dumb NXT sensorintgetPortType()Get the type classification for the port.protected java.lang.StringgetUARTSignature()Returns the signature for a UART sensorprotected voidopenConfigPort()protected voidwaitValid()Wait until the identification data for this port is valid-
Methods inherited from class lejos.hardware.Device
releaseOnClose
-
-
-
-
Field Detail
-
ANALOG_ID_VAR
protected static final int ANALOG_ID_VAR
- See Also:
- Constant Field Values
-
VALID_TIME
protected static final long VALID_TIME
- See Also:
- Constant Field Values
-
MIN_TIME
protected static final long MIN_TIME
- See Also:
- Constant Field Values
-
openTime
protected long openTime
-
port
protected Port port
-
configPort
protected ConfigurationPort configPort
-
EV3AnalogMap
protected static java.util.List<java.util.AbstractMap.SimpleEntry<java.lang.Integer,java.lang.String>> EV3AnalogMap
-
-
Constructor Detail
-
DeviceIdentifier
public DeviceIdentifier(Port port)
Create an instance of the device identifier for a particular port- Parameters:
port- The port to operate with
-
-
Method Detail
-
close
public void close()
Description copied from class:DeviceClose the sensor. Close associated resources.
-
openConfigPort
protected void openConfigPort()
-
waitValid
protected void waitValid()
Wait until the identification data for this port is valid
-
getPortType
public int getPortType()
Get the type classification for the port. If a sensor is attached to the port this will identify the connection type (CONN_NONE, CONN_INPUT_UART etc.). See the class EV3SensorConstants for the actual values- Returns:
- The type of the port
-
getDeviceType
public int getDeviceType()
This method returns information on the sensor/motor that is attached to the specified port. Note that only very basic sensor identification information may be available for some sensor types. It may be necessary to actually open the sensor to allow it to be identified in further detail.- Returns:
- the sensor type
-
getNXTDumbSignature
protected java.lang.String getNXTDumbSignature()
Returns the signature for a dumb NXT sensor- Returns:
- string identifying the device
-
getI2CSignature
protected java.lang.String getI2CSignature(boolean full)
Returns the signature for a i2c sensor- Returns:
- string identifying the device
-
getEV3DumbSignature
protected java.lang.String getEV3DumbSignature()
Returns the signature for a dumb EV3 sensor- Returns:
- string identifying the device
-
getUARTSignature
protected java.lang.String getUARTSignature()
Returns the signature for a UART sensor- Returns:
- string identifying the device
-
getMotorSignature
protected java.lang.String getMotorSignature()
Returns the signature for a motor/output device- Returns:
- string identifying the device
-
getDeviceSignature
public java.lang.String getDeviceSignature(boolean full)
return the signature of the attached device. This signature can be used to identify the actual device. Note that identification may require that the device is opened.- Parameters:
full- true to return all available information, false for basic information- Returns:
- a string signature
-
-