当前位置: 首页>>代码示例>>Java>>正文


Java SensorEvent类代码示例

本文整理汇总了Java中com.zuehlke.carrera.relayapi.messages.SensorEvent的典型用法代码示例。如果您正苦于以下问题:Java SensorEvent类的具体用法?Java SensorEvent怎么用?Java SensorEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SensorEvent类属于com.zuehlke.carrera.relayapi.messages包,在下文中一共展示了SensorEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main1

import com.zuehlke.carrera.relayapi.messages.SensorEvent; //导入依赖的package包/类
public static void main1(String[] args)
        throws IOException, InterruptedException, TimeoutException {

    connectionFactory = new ConnectionFactory();
    String POWER_QUEUE = "/app/pilots/power";
    String json = new JacksonSerializer().serialize(new PowerControl(200, "team", "access", 0L));
    Connection conn = connectionFactory.newConnection();
    Channel ch = conn.createChannel();
    //ch.queueDeclare(POWER_QUEUE, true, false, false, null);
    AMQP.BasicProperties props = new AMQP.BasicProperties.Builder().expiration("0").build();
    ch.basicPublish("", POWER_QUEUE, props, json.getBytes());

    String SENSOR_QUEUE = "/topic/pilots/starterkit/sensor";
    SensorEvent sensorEvent = SensorEvent.createEmptyCarSensor().withRaceTrackId("simulator");
    json = new JacksonSerializer().serialize(sensorEvent);

    //ch.queueDeclare(SENSOR_QUEUE, true, false, false, null);
    ch.basicPublish("", SENSOR_QUEUE, props, json.getBytes());

    ch.close();
    conn.close();
}
 
开发者ID:zhaar,项目名称:Neuralnet-IoT-Car,代码行数:23,代码来源:ConfirmDontLoseMessages.java

示例2: onReceive

import com.zuehlke.carrera.relayapi.messages.SensorEvent; //导入依赖的package包/类
@Override
public void onReceive(Object message) throws Exception {

    if ( message instanceof SensorEvent ) {
        handleSensorEvent((SensorEvent) message);

    } else if ( message instanceof PenaltyMessage) {
        handlePenaltyMessage ();

    } else if ( message instanceof RaceStartMessage) {
        handleRaceStart();

      } else if(message instanceof RoundTimeMessage) {
        handleRoundTime((RoundTimeMessage) message);

    } else {
        unhandled(message);
    }
}
 
开发者ID:zhaar,项目名称:Neuralnet-IoT-Car,代码行数:20,代码来源:PowerUpUntilPenalty.java

示例3: onReceive

import com.zuehlke.carrera.relayapi.messages.SensorEvent; //导入依赖的package包/类
@Override
public void onReceive(Object message) throws Exception {

    if ( message instanceof SensorEvent ) {
        handleSensorEvent((SensorEvent) message);

    } else if ( message instanceof VelocityMessage ) {
        handleVelocityMessage((VelocityMessage) message);

    } else if ( message instanceof PenaltyMessage) {
        handlePenaltyMessage ((PenaltyMessage) message);

    } else if ( message instanceof RaceStartMessage) {
        handleRaceStart();

    } else {
        unhandled(message);
    }
}
 
开发者ID:FastAndFurious,项目名称:fnf.AkkaStarterKit,代码行数:20,代码来源:PowerUpUntilPenalty.java

示例4: storeEvent

import com.zuehlke.carrera.relayapi.messages.SensorEvent; //导入依赖的package包/类
public void storeEvent(Object message) {

            if (message instanceof SensorEvent) {
                com.zuehlke.carrera.javapilot.eventStorage.events.SensorEvent event = new com.zuehlke.carrera.javapilot.eventStorage.events.SensorEvent(
                        (SensorEvent) message);
                storeEvent(event);
                visualizer.sendSensorEvent(event, this.currentRaceTimeStamp);
                visualizer.sendTrackElement(trackAnalyzer.analyzeMessage(event));

            } else if (message instanceof VelocityMessage) {
                VelocityEvent velocityEvent = new VelocityEvent((VelocityMessage)message);
                storeEvent(velocityEvent);
                visualizer.sendVelocityEvent(velocityEvent, this.currentRaceTimeStamp);

            } else if (message instanceof PenaltyMessage ) {
               storeEvent((PenaltyMessage) message );

            } else if ( message instanceof RoundTimeMessage ) {
                RoundEvent roundEvent = new RoundEvent((RoundTimeMessage) message);
                storeEvent(roundEvent);
                visualizer.sendRoundEvent(roundEvent);
            } else if(message instanceof  RaceStartMessage) {
                this.currentRaceTimeStamp = new Date().getTime();
            }
    }
 
开发者ID:ValisStigma,项目名称:LazyDrivers,代码行数:26,代码来源:eventStorage.java

示例5: main

import com.zuehlke.carrera.relayapi.messages.SensorEvent; //导入依赖的package包/类
public static void main(String[] args)
        throws IOException, InterruptedException, TimeoutException {

    connectionFactory = new ConnectionFactory();
    String POWER_QUEUE = "/app/pilots/power";
    String json = new JacksonSerializer().serialize(new PowerControl(200, "team", "access", 0L));
    Connection conn = connectionFactory.newConnection();
    Channel ch = conn.createChannel();
    //ch.queueDeclare(POWER_QUEUE, true, false, false, null);
    AMQP.BasicProperties props = new AMQP.BasicProperties.Builder().expiration("0").build();
    ch.basicPublish("", POWER_QUEUE, props, json.getBytes());

    String SENSOR_QUEUE = "/topic/pilots/starterkit/sensor";
    SensorEvent sensorEvent = SensorEvent.createEmptyCarSensor().withRaceTrackId("simulator");
    json = new JacksonSerializer().serialize(sensorEvent);

    //ch.queueDeclare(SENSOR_QUEUE, true, false, false, null);
    ch.basicPublish("", SENSOR_QUEUE, props, json.getBytes());

    ch.close();
    conn.close();
}
 
开发者ID:ValisStigma,项目名称:LazyDrivers,代码行数:23,代码来源:ConfirmDontLoseMessages.java

示例6: SpeedAnalyseRacer

import com.zuehlke.carrera.relayapi.messages.SensorEvent; //导入依赖的package包/类
public SpeedAnalyseRacer(ActorHandler handler){
    this.handler = handler;

    preRacing = new ActorMessage<SensorEvent>(SensorEvent.class){
        @Override
        public void onRecieve(SensorEvent message) {
            if(handler.getStartPower() != 0){
                if(!startedRacingPhase) {
                    setPower(handler.getStartPower());
                } else {
                    initializeRacing();
                }
            }
        }
    };

    this.registerMessage(preRacing);

    accel = new Accel(this);
    accelerationRacer = new AccelerationRacer(this, accel);
    handleTrack();
}
 
开发者ID:ValisStigma,项目名称:LazyDrivers,代码行数:23,代码来源:SpeedAnalyseRacer.java

示例7: initNextTrackElement

import com.zuehlke.carrera.relayapi.messages.SensorEvent; //导入依赖的package包/类
private void initNextTrackElement(SensorEvent message, DirectionHistory.Direction currentDir) {
    if(currentTrackElement != null) {
        currentTrackElement.setDistance(accel.getDistance(lastTrackElementSpeed,lastTrackElementTime,message.getTimeStamp()));
        setOrAdd(currentPosition, currentTrackElement);
        setCurrentPos(currentPosition+1);

    }
    lastTrackElementSpeed = accel.getVelocity(message.getTimeStamp());
    lastTrackElementTime = message.getTimeStamp();
    currentTrackElement = new TrackDirection(currentDir, 0);
    if (currentPositionLastRound > 0) {
        TrackDirection lastEle = dirHistory.get(currentPositionLastRound);
        currentTrackElement.isLRSwitch = lastEle.isLRSwitch;
        currentTrackElement.standartPower = lastEle.nextPower;
        currentTrackElement.curvePowerUp = lastEle.curvePowerUp;
        currentTrackElement.raisedStraightPower = lastEle.raisedStraightPower;
        currentTrackElement.millisRaisedStraight = lastEle.millisRaisedStraight;
        System.out.println("New Elem Power++"+lastEle.nextPower);
        currentTrackElement.nextPower = lastEle.nextPower;
    }
    currentTrackElement.startTime = lastTrackElementTime;
    currentTrackElement.startSpeed = lastTrackElementSpeed;
}
 
开发者ID:ValisStigma,项目名称:LazyDrivers,代码行数:24,代码来源:SpeedAnalyseRacer.java

示例8: ProbeRacer

import com.zuehlke.carrera.relayapi.messages.SensorEvent; //导入依赖的package包/类
public ProbeRacer(ActorHandler handler) {
    this.handler = handler;

    this.registerMessage(new ActorMessage<SensorEvent>(SensorEvent.class) {
        @Override
        public void onRecieve(SensorEvent message) {
            if (    handler.directionHistory.historyDirection().equals(DirectionHistory.Direction.LEFT) ||
                    handler.directionHistory.historyDirection().equals(DirectionHistory.Direction.RIGHT)){
                if(current == curvePower) System.out.println();
                current -= steps;
                if(current < (straightPower*1.5)) current = (int)(straightPower*1.5);
                System.out.print(", "+current);
                setPower(current);
            }else {
                current = curvePower;
                setPower(straightPower);
            }
        }
    });
}
 
开发者ID:ValisStigma,项目名称:LazyDrivers,代码行数:21,代码来源:ProbeRacer.java

示例9: BoostRacer

import com.zuehlke.carrera.relayapi.messages.SensorEvent; //导入依赖的package包/类
public BoostRacer(ActorHandler handler) {
    this.handler = handler;

    this.registerMessage(new ActorMessage<SensorEvent>(SensorEvent.class) {
        @Override
        public void onRecieve(SensorEvent message) {
            if(handler.directionHistory.currentDirection().equals(handler.directionHistory.lastDirection())){
                if(counter == 0) {
                    handler.actors.get(StaticRacer.class).startWork();
                    handler.actors.get(BoostRacer.class).stopWork();
                }
                counter = (counter + 1) % boostTimes;
                setPower(boostPower);
            }
        }
    });
}
 
开发者ID:ValisStigma,项目名称:LazyDrivers,代码行数:18,代码来源:BoostRacer.java

示例10: onReceive

import com.zuehlke.carrera.relayapi.messages.SensorEvent; //导入依赖的package包/类
@Override
public void onReceive(Object o) throws Exception {
    if (o instanceof RaceStartMessage){
        raceStartTime = ((RaceStartMessage) o).getTimestamp();
    }
    if (raceStartTime == 0){
        if (o instanceof SensorEvent){
            raceStartTime = ((SensorEvent) o).getTimeStamp();
        }
    }

    actors.values().stream().filter(actor -> actor.isWorking()).forEach(actor -> {
        actor.actorRef.forward(o, getContext());
        //System.out.println("fw to : "+actor.actor.getClass().toString());
    });
}
 
开发者ID:ValisStigma,项目名称:LazyDrivers,代码行数:17,代码来源:ActorHandler.java

示例11: StartRacer

import com.zuehlke.carrera.relayapi.messages.SensorEvent; //导入依赖的package包/类
public StartRacer(ActorHandler handler, Class nextRacer){
    this.handler = handler;

    this.registerMessage(new ActorMessage<SensorEvent>(SensorEvent.class) {
        @Override
        public void onRecieve(SensorEvent message) {
            gyr.shift(message.getG()[2]);
            if (gyr.currentStDev() < 10) {
                startPower += 1;
                setPower(startPower);
            }else{
                handler.setStartPower(startPower);
                handler.actors.get(StartRacer.class).stopWork();
                //handler.actors.get(nextRacer).startWork();
            }
        }
    });
}
 
开发者ID:ValisStigma,项目名称:LazyDrivers,代码行数:19,代码来源:StartRacer.java

示例12: isAboveThreshold

import com.zuehlke.carrera.relayapi.messages.SensorEvent; //导入依赖的package包/类
public boolean isAboveThreshold(SensorEvent event) {
    switch ( observable ) {
        case A0:
            return event.getA()[0] > threshold;
        case A1:
            return event.getA()[1] > threshold;
        case A2:
            return event.getA()[2] > threshold;
        case G0:
            return event.getG()[0] > threshold;
        case G1:
            return event.getG()[1] > threshold;
        case G2:
            return event.getG()[2] > threshold;
        case M0:
            return event.getM()[0] > threshold;
        case M1:
            return event.getM()[1] > threshold;
        case M2:
            return event.getM()[2] > threshold;
    }
    return false;
}
 
开发者ID:ValisStigma,项目名称:LazyDrivers,代码行数:24,代码来源:ThresholdConfiguration.java

示例13: onReceive

import com.zuehlke.carrera.relayapi.messages.SensorEvent; //导入依赖的package包/类
@Override
public void onReceive(Object message) throws Exception {

    if ( message instanceof SensorEvent ) {
        handleSensorEvent((SensorEvent) message);

    } else if ( message instanceof PenaltyMessage) {
        handlePenaltyMessage ( (PenaltyMessage) message );

    } else if ( message instanceof RaceStartMessage) {
        handleRaceStart();

    } else {
        unhandled(message);
    }
}
 
开发者ID:ValisStigma,项目名称:LazyDrivers,代码行数:17,代码来源:PowerUpUntilPenalty.java

示例14: handleSensorEvent

import com.zuehlke.carrera.relayapi.messages.SensorEvent; //导入依赖的package包/类
/**
 * Strategy: increase quickly when standing still to overcome haptic friction
 * then increase slowly. Probing phase will be ended by the first penalty
 * @param message the sensor event coming in
 */
private void handleSensorEvent(SensorEvent message) {

    double gyrz = gyrozHistory.shift(message.getG()[2]);
     show ((int)gyrz);

    if (probing) {
        if (iAmStillStanding()) {
            increase(5);
        } else if (message.getTimeStamp() > lastIncrease + duration) {
            lastIncrease = message.getTimeStamp();
            increase(3);
        }
    }

    kobayashi.tell(new PowerAction(currentPower), getSelf());
}
 
开发者ID:ValisStigma,项目名称:LazyDrivers,代码行数:22,代码来源:PowerUpUntilPenalty.java

示例15: handleSensorEvent

import com.zuehlke.carrera.relayapi.messages.SensorEvent; //导入依赖的package包/类
private void handleSensorEvent(SensorEvent message) {
	if (isSample(message)) {
		handleSample(message);
	} else {
		strategy.forward(message, getContext());
	}
}
 
开发者ID:FastAndFurious,项目名称:fnf.AkkaStarterKit,代码行数:8,代码来源:JavaPilotActor.java


注:本文中的com.zuehlke.carrera.relayapi.messages.SensorEvent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。