Package lejos.remote.nxt
Class RemoteNXTIOPort
- java.lang.Object
-
- lejos.remote.nxt.RemoteNXTIOPort
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,BasicSensorPort,IOPort,EV3SensorConstants,SensorConstants
- Direct Known Subclasses:
RemoteNXTAnalogPort,RemoteNXTI2CPort,RemoteNXTMotorPort
public abstract class RemoteNXTIOPort extends java.lang.Object implements IOPort, BasicSensorPort, EV3SensorConstants
This class provides the base operations for remote NXT sensor ports.- Author:
- Lawrie Griffiths
-
-
Field Summary
Fields Modifier and Type Field Description protected intcurrentModeprotected static byte[]dcprotected NXTCommandnxtCommandprotected static RemoteNXTIOPort[][]openPortsprotected intportprotected RemoteNXTPortrefprotected inttyp-
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
-
Fields inherited from interface lejos.hardware.sensor.SensorConstants
BLACK, BLANK_INDEX, BLUE, BLUE_INDEX, BROWN, GREEN, GREEN_INDEX, MAX_TYPE, MIN_TYPE, MODE_RAW, NXT_ADC_RES, RED, RED_INDEX, TYPE_ANGLE, TYPE_COLORBLUE, TYPE_COLORFULL, TYPE_COLORGREEN, TYPE_COLORNONE, TYPE_COLORRED, TYPE_CUSTOM, TYPE_HIGHSPEED, TYPE_HIGHSPEED_9V, TYPE_HISPEED, TYPE_LIGHT_ACTIVE, TYPE_LIGHT_INACTIVE, TYPE_LOWSPEED, TYPE_LOWSPEED_9V, TYPE_NO_SENSOR, TYPE_REFLECTION, TYPE_SOUND_DB, TYPE_SOUND_DBA, TYPE_SWITCH, TYPE_TEMPERATURE, WHITE, YELLOW
-
-
Constructor Summary
Constructors Constructor Description RemoteNXTIOPort(NXTCommand nxtCommand)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Close the port, the port can not be used after this call.intgetMode()Get the current operating mode of the sensorjava.lang.StringgetName()Return the string representing this portintgetType()Get the current type setting.booleanopen(int typ, int port, RemoteNXTPort ref)Open the sensor port.booleansetMode(int mode)Set the current operating mode for the sensor attached to the port.booleansetPinMode(int mode)Set the port pins up ready for use.booleansetType(int type)Set the operating type for the attached sensor.booleansetTypeAndMode(int type, int mode)
-
-
-
Field Detail
-
port
protected int port
-
typ
protected int typ
-
ref
protected RemoteNXTPort ref
-
dc
protected static byte[] dc
-
currentMode
protected int currentMode
-
openPorts
protected static RemoteNXTIOPort[][] openPorts
-
nxtCommand
protected NXTCommand nxtCommand
-
-
Constructor Detail
-
RemoteNXTIOPort
public RemoteNXTIOPort(NXTCommand nxtCommand)
-
-
Method Detail
-
getName
public java.lang.String getName()
Return the string representing this port
-
getMode
public int getMode()
Get the current operating mode of the sensor- Specified by:
getModein interfaceBasicSensorPort- Returns:
- the current mode
-
getType
public int getType()
Get the current type setting. Note that types are typically used to control the operation of Legacy and i2c sensors. They are normally not used for EV3 sensors.- Specified by:
getTypein interfaceBasicSensorPort- Returns:
- the current sensor type
-
setMode
public boolean setMode(int mode)
Set the current operating mode for the sensor attached to the port.- Specified by:
setModein interfaceBasicSensorPort- Parameters:
mode- the new mode- Returns:
- true if the mode has been accepted
-
setType
public boolean setType(int type)
Set the operating type for the attached sensor. Normally type setting is only used with legacy sensors and for i2c devices (to set the speed and operating voltage). It is not normally used with EV3 sensors.- Specified by:
setTypein interfaceBasicSensorPort- Returns:
- true if type accepted
-
setTypeAndMode
public boolean setTypeAndMode(int type, int mode)- Specified by:
setTypeAndModein interfaceBasicSensorPort
-
open
public boolean open(int typ, int port, RemoteNXTPort ref)Open the sensor port. Ensure that the port is only opened once.- Parameters:
typ- The type of port motor/sensorport- the port numberref- the Port ref for this port- Returns:
- true if success
-
close
public void close()
Close the port, the port can not be used after this call.
-
setPinMode
public boolean setPinMode(int mode)
Set the port pins up ready for use.- Specified by:
setPinModein interfaceIOPort- Parameters:
mode- The EV3 pin mode- Returns:
- true if the operation succeeds false if it fails
-
-