本文整理汇总了Java中lejos.hardware.port.Port类的典型用法代码示例。如果您正苦于以下问题:Java Port类的具体用法?Java Port怎么用?Java Port使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Port类属于lejos.hardware.port包,在下文中一共展示了Port类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: initRegulatedMotor
import lejos.hardware.port.Port; //导入依赖的package包/类
private void initRegulatedMotor(ActorPort actorPort, Actor actorType, Port hardwarePort) {
this.lcd.clear();
// Hal.formatInfoMessage("Initializing motor on port " + actorPort, this.lcd);
switch ( actorType.getName() ) {
case LARGE:
this.lejosRegulatedMotors.put(actorPort, new EV3LargeRegulatedMotor(hardwarePort));
break;
case MEDIUM:
this.lejosRegulatedMotors.put(actorPort, new EV3MediumRegulatedMotor(hardwarePort));
break;
case REGULATED:
this.lejosRegulatedMotors.put(actorPort, new NXTRegulatedMotor(hardwarePort));
break;
default:
throw new DbcException("Actor type " + actorType.getName() + " does not exists!");
}
}
开发者ID:OpenRoberta,项目名称:robertalab-ev3lejos-v0,代码行数:18,代码来源:DeviceHandler.java
示例2: getActualSensorConfig
import lejos.hardware.port.Port; //导入依赖的package包/类
/**
* Initialise sensor ports and retrieve their modename.<br>
*
* @return sensorname per port in an array
*/
private String[] getActualSensorConfig() {
int sensorCount = 4;
String[] actualSensorConfig = new String[sensorCount];
Port[] p = new Port[sensorCount];
p[0] = LocalEV3.get().getPort("S1");
p[1] = LocalEV3.get().getPort("S2");
p[2] = LocalEV3.get().getPort("S3");
p[3] = LocalEV3.get().getPort("S4");
for ( int i = 0; i < actualSensorConfig.length; i++ ) {
actualSensorConfig[i] = getSensorName(p[i]).trim(); // remove spaces
// map the sensor mode names to lejos sensor class names!
actualSensorConfig[i] = this.sensorModes.getProperty(actualSensorConfig[i]);
}
return actualSensorConfig;
}
开发者ID:OpenRoberta,项目名称:robertalab-ev3lejos-v0,代码行数:21,代码来源:RobertaFunctions.java
示例3: BasicMotor
import lejos.hardware.port.Port; //导入依赖的package包/类
/**
* Constructor
*
* @param motorPort port
*/
public BasicMotor(final Port motorPort) {
if(!this.getPlatform().equals(EV3DevPlatform.EV3BRICK)){
throw new RuntimeException("This device is not supported in this platform");
}
final String port = this.getMotorPort(motorPort);
log.debug("Detecting motor on port: {}", port);
this.detect(LEGO_PORT, port);
log.debug("Setting port in mode: {}", DC_MOTOR);
this.setStringAttribute(MODE, DC_MOTOR);
Delay.msDelay(500);
this.detect(DC_MOTOR, port);
}
开发者ID:ev3dev-lang-java,项目名称:ev3dev-lang-java,代码行数:21,代码来源:BasicMotor.java
示例4: EV3DevSensorDevice
import lejos.hardware.port.Port; //导入依赖的package包/类
/**
* Every device connected in a EV3 Brick with EV3Dev appears in /sys/class in a determinated category.
* It is necessary to indicate the type and ports.
*
* @param portName The ports where is connected the sensors or the actuators.
* @param mode mode
* @param device device
*/
protected EV3DevSensorDevice(final Port portName, final String mode, final String device) {
final String port = this.getSensorPort(portName);
//EV3 Brick detect in a automatic way the sensors
if(this.getPlatform().equals(EV3DevPlatform.EV3BRICK)){
this.detect(LEGO_SENSOR, port);
}else {
//With Pi Boards, it is necessary to detect in 2 paths the sensors
this.detect(LEGO_PORT, port);
log.info("detected lego port: {}", this.PATH_DEVICE);
this.setStringAttribute(MODE, mode);
this.setStringAttribute(DEVICE, device);
Delay.msDelay(1000);
this.detect(LEGO_SENSOR, port);
log.info("detected lego sensor: {}", this.PATH_DEVICE);
}
}
开发者ID:ev3dev-lang-java,项目名称:ev3dev-lang-java,代码行数:30,代码来源:EV3DevSensorDevice.java
示例5: getSensorPort
import lejos.hardware.port.Port; //导入依赖的package包/类
private static Port getSensorPort(String p) throws EV3ScriptException {
switch (p) {
case "1":
case EV3Constants.S1:
return SensorPort.S1;
case "2":
case EV3Constants.S2:
return SensorPort.S2;
case "3":
case EV3Constants.S3:
return SensorPort.S3;
case "4":
case EV3Constants.S4:
return SensorPort.S4;
}
throw new EV3ScriptException(EV3ScriptException.INVALID_SENSOR_PORT, MapBuilder.buildHashMap("port", p).build());
}
开发者ID:jbenech,项目名称:gnikrap,代码行数:18,代码来源:SimpleEV3Brick.java
示例6: SimpleEV3ColorSensor
import lejos.hardware.port.Port; //导入依赖的package包/类
public SimpleEV3ColorSensor(Port port) {
delegate = new EV3ColorSensor(port);
logger = SensorMonitorFactory.getLogger(port);
// Reflected light mode
reflectedLightMode = delegate.getRedMode();
reflectedLightSample = new float[reflectedLightMode.sampleSize()];
// Ambient light mode
ambientLightMode = delegate.getAmbientMode();
ambientLightSample = new float[ambientLightMode.sampleSize()];
// Color mode
colorMode = delegate.getColorIDMode();
colorModeSample = new float[colorMode.sampleSize()];
}
开发者ID:jbenech,项目名称:gnikrap,代码行数:14,代码来源:SimpleEV3ColorSensor.java
示例7: RMIRemoteSampleProvider
import lejos.hardware.port.Port; //导入依赖的package包/类
protected RMIRemoteSampleProvider(String portName, String sensorName, String modeName) throws RemoteException {
super(0);
try {
Class<?> c = Class.forName(sensorName);
Class<?>[] params = new Class<?>[1];
params[0] = Port.class;
Constructor<?> con = c.getConstructor(params);
Object[] args = new Object[1];
args[0] = LocalEV3.get().getPort(portName);
Object obj = con.newInstance(args);
provider = (SampleProvider) obj;
closer = (Closeable) obj;
} catch (Exception e) {
e.printStackTrace();
}
}
开发者ID:SnakeSVx,项目名称:ev3,代码行数:17,代码来源:RMIRemoteSampleProvider.java
示例8: MediumRegulatedMotor
import lejos.hardware.port.Port; //导入依赖的package包/类
public MediumRegulatedMotor(Port motorPort) throws IOException {
super(motorPort);
this.motor = createMotor(motorPort);
this.motortype = Motors.MediumRegulatedMotor;
this.motorState = new RegulatedMotorMessages.MotorState();
}
开发者ID:Echtzeitsysteme,项目名称:mindroid,代码行数:8,代码来源:MediumRegulatedMotor.java
示例9: EV3UltrasonicSensor
import lejos.hardware.port.Port; //导入依赖的package包/类
public EV3UltrasonicSensor(Port sensorPort, SensorMessages.SensorMode_ mode) {
super(SensorSampleRates.SENS_ULTRASONIC_SAMPLERATE);
isSensorCreated = create(sensorPort, Sensors.EV3UltrasonicSensor,mode); //Creates Lejos.EV3ColorSensor. acceptable
if(isSensorCreated){
sendSensorData();
}
System.out.println(toString());;
}
开发者ID:Echtzeitsysteme,项目名称:mindroid,代码行数:11,代码来源:EV3UltrasonicSensor.java
示例10: EV3IRSensor
import lejos.hardware.port.Port; //导入依赖的package包/类
public EV3IRSensor(Port sensorPort, SensorMessages.SensorMode_ mode) {
super(SensorSampleRates.SENS_IR_SAMPLERATE);
isSensorCreated = create(sensorPort, Sensors.EV3IRSensor,mode); //Creates Lejos.EV3ColorSensor. acceptable
if(isSensorCreated){
sendSensorData();
}
System.out.println(toString());;
}
开发者ID:Echtzeitsysteme,项目名称:mindroid,代码行数:9,代码来源:EV3IRSensor.java
示例11: EV3TouchSensor
import lejos.hardware.port.Port; //导入依赖的package包/类
public EV3TouchSensor(Port sensorPort, SensorMessages.SensorMode_ mode) {
super(SensorSampleRates.SENS_TOUCH_SAMPLERATE);
isSensorCreated = create(sensorPort, Sensors.EV3TouchSensor,mode); //Creates Lejos.EV3ColorSensor. acceptable
if(isSensorCreated){
sendSensorData();
}
System.out.println(toString());;
}
开发者ID:Echtzeitsysteme,项目名称:mindroid,代码行数:11,代码来源:EV3TouchSensor.java
示例12: EV3GyroSensor
import lejos.hardware.port.Port; //导入依赖的package包/类
public EV3GyroSensor(Port sensorPort, SensorMessages.SensorMode_ mode) {
super(SensorSampleRates.SENS_GYRO_SAMPLERATE);
isSensorCreated = create(sensorPort, Sensors.EV3GyroSensor,mode); //Creates Lejos.EV3ColorSensor. acceptable
if(isSensorCreated){
sendSensorData();
}
System.out.println(toString());;}
开发者ID:Echtzeitsysteme,项目名称:mindroid,代码行数:8,代码来源:EV3GyroSensor.java
示例13: EV3ColorSensor
import lejos.hardware.port.Port; //导入依赖的package包/类
public EV3ColorSensor(Port sensorPort,SensorMessages.SensorMode_ mode){
super(SensorSampleRates.SENS_COLOR_SAMPLERATE);
isSensorCreated = create(sensorPort,Sensors.EV3ColorSensor,mode); //Creates Lejos.EV3ColorSensor. acceptable
if(isSensorCreated){
sendSensorData();
}
System.out.println(toString());;
}
开发者ID:Echtzeitsysteme,项目名称:mindroid,代码行数:10,代码来源:EV3ColorSensor.java
示例14: create
import lejos.hardware.port.Port; //导入依赖的package包/类
protected boolean create(Port sensorPort,Sensors sensortype,SensorMessages.SensorMode_ sensormode) {
assert sensortype != null && sensorPort != null && sensormode != null;
this.sensorPort = sensorPort;
switch(sensortype){
case EV3ColorSensor:
this.sensor = new EV3ColorSensor(sensorPort);
this.sensortype = Sensors.EV3ColorSensor;
break;
case EV3UltrasonicSensor:
this.sensor = new EV3UltrasonicSensor(sensorPort);
this.sensortype = Sensors.EV3UltrasonicSensor;
break;
case EV3GyroSensor:
this.sensor = new EV3GyroSensor(sensorPort);
this.sensortype = Sensors.EV3GyroSensor;
break;
case EV3IRSensor:
this.sensor = new EV3IRSensor(sensorPort);
this.sensortype = Sensors.EV3IRSensor;
break;
case EV3TouchSensor:
this.sensor = new EV3TouchSensor(sensorPort);
this.sensortype = Sensors.EV3TouchSensor;
break;
default: return false;
}
if(sensor != null && setSensorMode(sensormode)){
this.sensormode = sensormode;
}
return true;
}
开发者ID:Echtzeitsysteme,项目名称:mindroid,代码行数:35,代码来源:AbstractSensor.java
示例15: createMotorEndpoint
import lejos.hardware.port.Port; //导入依赖的package包/类
/**
*
* @param port
* @param motorType
* @param networkPort
* @throws IOException
*/
private boolean createMotorEndpoint(Port port, Motors motorType, int networkPort) {
try {
return mm.createMotorEndpoint(port,motorType,networkPort);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return false;
}
开发者ID:Echtzeitsysteme,项目名称:mindroid,代码行数:17,代码来源:DeviceManager.java
示例16: TouchSensor
import lejos.hardware.port.Port; //导入依赖的package包/类
TouchSensor(Port port) {
touched = Observable.using(
() -> createSensor(port),
sensor -> new Sampler(() -> sensor.getTouchMode()).sample(),
sensor -> closeSensor(sensor)
)
.share()
.map(sample -> sample.values[sample.offset])
.distinctUntilChanged()
.map(value -> value == 1);
}
开发者ID:jweijers,项目名称:EV3-robots,代码行数:12,代码来源:TouchSensor.java
示例17: Canon
import lejos.hardware.port.Port; //导入依赖的package包/类
public Canon(Port canonEnginePort, Port rotationEnginePort) {
canonEngine = new EV3MediumRegulatedMotor(canonEnginePort);
rotationEngine = new EV3LargeRegulatedMotor(rotationEnginePort);
resetEngine(canonEngine);
resetEngine(rotationEngine);
}
开发者ID:jweijers,项目名称:EV3-robots,代码行数:8,代码来源:Canon.java
示例18: openPort
import lejos.hardware.port.Port; //导入依赖的package包/类
private static void openPort(Port p) {
try {
UARTPort port = brick().getPort(p.getName()).open(UARTPort.class);
port.close();
System.out.println("Port opened " + p);
} catch (Exception e) {
System.out.println("Could not open port " + p);
}
}
开发者ID:bdeneuter,项目名称:rx-mindstorms,代码行数:10,代码来源:Robot.java
示例19: initMotor
import lejos.hardware.port.Port; //导入依赖的package包/类
private void initMotor(ActorPort actorPort, Actor actorType, Port hardwarePort) {
if ( actorType != null ) {
if ( actorType.isRegulated() ) {
initRegulatedMotor(actorPort, actorType, hardwarePort);
} else {
initUnregulatedMotor(actorPort, hardwarePort);
}
}
}
开发者ID:OpenRoberta,项目名称:robertalab-ev3lejos-v0,代码行数:10,代码来源:DeviceHandler.java
示例20: initSensor
import lejos.hardware.port.Port; //导入依赖的package包/类
private void initSensor(SensorPort sensorPort, Sensor sensorType, Port hardwarePort) {
if ( sensorType != null && isUsed(sensorType) ) {
this.lcd.clear();
// Hal.formatInfoMessage("Initializing " + sensorType.getComponentType().getShortName() + " on port " + sensorPort + " ...", this.lcd);
switch ( sensorType.getType() ) {
case COLOR:
this.lejosSensors.put(sensorPort, sensorSampleProviders(new EV3ColorSensor(hardwarePort)));
break;
case INFRARED:
this.lejosSensors.put(sensorPort, sensorSampleProviders(new EV3IRSensor(hardwarePort)));
break;
case GYRO:
this.gyroSensor = new EV3GyroSensor(hardwarePort);
this.lejosSensors.put(sensorPort, sensorSampleProviders(this.gyroSensor));
break;
case TOUCH:
this.lejosSensors.put(sensorPort, sensorSampleProviders(new EV3TouchSensor(hardwarePort)));
break;
case ULTRASONIC:
this.lejosSensors.put(sensorPort, sensorSampleProviders(new EV3UltrasonicSensor(hardwarePort)));
break;
case COMPASS_HI_TEC:
this.hiTechnicCompass = new HiTechnicCompass(hardwarePort);
this.lejosSensors.put(sensorPort, sensorSampleProviders(this.hiTechnicCompass));
break;
case SOUND:
this.lejosSensors.put(sensorPort, sensorSampleProviders(new NXTSoundSensor(hardwarePort)));
break;
default:
throw new DbcException("Sensor type " + sensorType.getType() + " does not exists!");
}
}
}
开发者ID:OpenRoberta,项目名称:robertalab-ev3lejos-v0,代码行数:34,代码来源:DeviceHandler.java
注:本文中的lejos.hardware.port.Port类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论