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


Java AisMessage类代码示例

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


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

示例1: getAisMessage

import dk.dma.ais.message.AisMessage; //导入依赖的package包/类
public AisMessage getAisMessage(int mmsi, int repeat) throws SentenceException, SixbitException {
    AisMessage aisMessage;
    if (msgId == 14) {
        AisMessage14 msg14 = new AisMessage14();
        msg14.setUserId(mmsi);
        msg14.setRepeat(repeat);
        msg14.setMessage(binArray);
        aisMessage = msg14;
    } else if (msgId == 8) {
        AisMessage8 msg8 = new AisMessage8();
        msg8.setRepeat(repeat);
        msg8.setUserId(mmsi);
        msg8.setBinary(binArray);
        aisMessage = msg8;

    } else {
        throw new SentenceException("BBM can only contain AIS message 8 or 14");
    }

    return aisMessage;
}
 
开发者ID:videgro,项目名称:Ships,代码行数:22,代码来源:Bbm.java

示例2: getAisMessage

import dk.dma.ais.message.AisMessage; //导入依赖的package包/类
public AisMessage getAisMessage(int mmsi, int repeat, int retransmit) throws SentenceException, SixbitException {
    AisMessage aisMessage;
    if (msgId == 12) {
        AisMessage12 msg12 = new AisMessage12();
        msg12.setDestination(getDestination());
        msg12.setUserId(mmsi);
        msg12.setSeqNum(getSequence());
        msg12.setRepeat(repeat);
        msg12.setRetransmit(retransmit);
        msg12.setMessage(binArray);
        aisMessage = msg12;
    } else if (msgId == 6) {
        AisMessage6 msg6 = new AisMessage6();
        msg6.setSeqNum(getSequence());
        msg6.setDestination(getDestination());
        msg6.setUserId(mmsi);
        msg6.setBinary(binArray);
        aisMessage = msg6;
    } else {
        throw new SentenceException("ABM can only contain AIS message 6 or 12");
    }

    return aisMessage;
}
 
开发者ID:videgro,项目名称:Ships,代码行数:25,代码来源:Abm.java

示例3: isShipAllowed

import dk.dma.ais.message.AisMessage; //导入依赖的package包/类
protected boolean isShipAllowed(AisMessage aisMessage) {
    if (allowedShipTypes.size() > 0) {

        // Ship type message
        if (aisMessage instanceof AisMessage5) {

            // if ship type is allowed, we add ship mmsi to allowedShips map
            AisMessage5 m = (AisMessage5) aisMessage;
            ShipTypeCargo shipTypeCargo = new ShipTypeCargo(m.getShipType());
            if (allowedShipTypes.containsKey(shipTypeCargo.getShipType())) {
                allowedShips.put(m.getUserId(), true);
            }
            // It's not a position message, so we return false
            return false;
        }

        // if ship isn't in allowedShips we don't process the message
        if (!allowedShips.containsKey(aisMessage.getUserId())) {
            return false;
        }
    }
    return true;
}
 
开发者ID:dma-ais,项目名称:AisCoverage,代码行数:24,代码来源:AbstractCalculator.java

示例4: accept

import dk.dma.ais.message.AisMessage; //导入依赖的package包/类
/**
 * Receive and process one AisPacket.
 *
 * @param packet The AisPacket to process.
 */
public void accept(final AisPacket packet) {
    statisticsService.incUnfilteredPacketCount();
    if (filterPacket(packet)) {
        statisticsService.incFilteredPacketCount();

        AisMessage message = packet.tryGetAisMessage();
        if (message == null) {
            LOG.warn("Invalid packet: " + packet.getStringMessage());
            return;
        }
        updateApplicationStatistics(message);

        doWork(packet);
    }
}
 
开发者ID:dma-ais,项目名称:AisAbnormal,代码行数:21,代码来源:PacketHandlerImpl.java

示例5: makeVdm

import dk.dma.ais.message.AisMessage; //导入依赖的package包/类
/**
 * Make a single VDM from this BBM
 * 
 * @param mmsi
 * @param repeat
 * @return
 * @throws SixbitException
 * @throws SentenceException
 */
public Vdm makeVdm(int mmsi, int repeat) throws SixbitException, SentenceException {
    AisMessage aisMessage = getAisMessage(mmsi, repeat);
    Vdm vdm = new Vdm();
    vdm.setMsgId(getMsgId());
    vdm.setMessageData(aisMessage);
    vdm.setSequence(getSequence());
    vdm.setChannel(getChannel());
    return vdm;
}
 
开发者ID:videgro,项目名称:Ships,代码行数:19,代码来源:Bbm.java

示例6: setMessageData

import dk.dma.ais.message.AisMessage; //导入依赖的package包/类
/**
 * Set the binary encapsulated data from AIS message
 * 
 * @param aisMessage
 * @throws SixbitException
 */
public void setMessageData(AisMessage aisMessage) throws SixbitException {
    this.msgId = aisMessage.getMsgId();
    SixbitEncoder encoder = aisMessage.getEncoded();
    sixbitString = new StringBuilder(encoder.encode());
    padBits = encoder.getPadBits();
}
 
开发者ID:videgro,项目名称:Ships,代码行数:13,代码来源:EncapsulatedSentence.java

示例7: createSentences

import dk.dma.ais.message.AisMessage; //导入依赖的package包/类
/**
 * Make max 80 chars length sentences from AIS message given sequence number
 * 
 * If all VDM fields are used, 61 chars are left for encoded AIS message
 * 
 * @param aisMessage
 * @param sequence
 * @return array of sentence parts
 * @throws IllegalArgumentException
 * @throws SixbitException
 */
public static String[] createSentences(AisMessage aisMessage, int sequence) throws SixbitException {
    // Encode the AIS message to get full string
    SixbitEncoder encoder = aisMessage.getEncoded();
    String encoded = encoder.encode();
    int padBits = encoder.getPadBits();

    // Number of sentences necessary
    int sentenceCount = encoded.length() / DATA_SENTENCE_MAX_LENGTH + 1;
    String[] sentences = new String[sentenceCount];

    // Split the string
    for (int i = 0; i < sentenceCount; i++) {
        int start = i * DATA_SENTENCE_MAX_LENGTH;
        int end;
        int partPadBits = 0;
        if (i < sentenceCount - 1) {
            end = start + DATA_SENTENCE_MAX_LENGTH;
        } else {
            end = encoded.length();
            partPadBits = padBits;
        }
        String partEncoded = encoded.substring(start, end);

        Vdm vdm = new Vdm();
        vdm.setMsgId(aisMessage.getMsgId());
        vdm.setTalker("AI");
        vdm.setTotal(sentenceCount);
        vdm.setNum(i + 1);
        vdm.setSequence(sequence);
        vdm.setSixbitString(partEncoded);
        vdm.setPadBits(partPadBits);

        sentences[i] = vdm.getEncoded();
    }

    return sentences;
}
 
开发者ID:videgro,项目名称:Ships,代码行数:49,代码来源:Vdm.java

示例8: makeVdm

import dk.dma.ais.message.AisMessage; //导入依赖的package包/类
/**
 * Make a single VDM from this ABM
 * 
 * @param mmsi
 * @param repeat
 * @param retransmit
 * @return
 * @throws SixbitException
 * @throws SentenceException
 */
public Vdm makeVdm(int mmsi, int repeat, int retransmit) throws SixbitException, SentenceException {
    AisMessage aisMessage = getAisMessage(mmsi, repeat, retransmit);

    Vdm vdm = new Vdm();
    vdm.setMsgId(getMsgId());
    vdm.setMessageData(aisMessage);
    vdm.setSequence(getSequence());
    vdm.setChannel(getChannel());

    return vdm;
}
 
开发者ID:videgro,项目名称:Ships,代码行数:22,代码来源:Abm.java

示例9: tryGetAisMessage

import dk.dma.ais.message.AisMessage; //导入依赖的package包/类
public AisMessage tryGetAisMessage() {
    try {
        return getAisMessage();
    } catch (AisMessageException i){
        return null;
    }
      catch ( SixbitException ignore) {
        return null;
    }
}
 
开发者ID:videgro,项目名称:Ships,代码行数:11,代码来源:AisPacket.java

示例10: AisTargetEntry

import dk.dma.ais.message.AisMessage; //导入依赖的package包/类
public AisTargetEntry(AisPacket packet) {
    AisMessage aisMessage = packet.tryGetAisMessage();        
    this.anonId = ++anonymousCounter;
    mmsiAnonIdMap.put(aisMessage.getUserId(), this.anonId);
    anonIdMap.put(this.anonId, aisMessage.getUserId());
    this.target = AisTarget.createTarget(aisMessage);
}
 
开发者ID:dma-ais,项目名称:AisView,代码行数:8,代码来源:AisTargetEntry.java

示例11: update

import dk.dma.ais.message.AisMessage; //导入依赖的package包/类
public boolean update(AisPacket packet) {
    boolean targetReplaced = false;
    AisMessage aisMessage = packet.tryGetAisMessage();
    sourceData.update(packet);
    // We want to avoid to update a target position with an older position
    // than the last one received
    boolean oldPos = false;
    if (aisMessage instanceof IVesselPositionMessage) {
        Date thisReport = null;
        // Get timestamp for message tag or fallback to time now
        thisReport = aisMessage.getVdm().getTimestamp();
        if (thisReport == null) {
            thisReport = new Date();
        }
        if (lastReport != null) {
            // We will not update if this report is older than last
            if (thisReport.before(lastReport)) {
                oldPos = true;
            }
        }
        lastReport = thisReport;
    }
    // Update target data
    if (!oldPos) {
        try {
            target.update(aisMessage);
        } catch (IllegalArgumentException e) {
            // Trying to update target with report of different type of target.
            // Replace target with new target
            target = AisTarget.createTarget(aisMessage);
            target.update(aisMessage);
            targetReplaced = true;
        }
    }

    return targetReplaced;
}
 
开发者ID:dma-ais,项目名称:AisView,代码行数:38,代码来源:AisTargetEntry.java

示例12: accept

import dk.dma.ais.message.AisMessage; //导入依赖的package包/类
public void accept(final AisPacket packet) {
    if (cancel) {
        return;
    }

    statisticsService.incUnfilteredPacketCount();
    if (downSampleFilter.rejectedByFilter(packet)) {
        return;
    }
    statisticsService.incFilteredPacketCount();

    long n = statisticsService.getFilteredPacketCount();
    if (n % 100000L == 0) {
        LOG.debug(n + " packets through filter.");
    }

    // Get AisMessage from packet or drop
    AisMessage message = packet.tryGetAisMessage();
    if (message == null) {
        return;
    }
    statisticsService.incMessageCount();

    if (message instanceof IPositionMessage) {
        statisticsService.incPosMsgCount();
    } else if (message instanceof AisMessage5) {
        statisticsService.incStatMsgCount();
    }

    if (multiThreaded) {
        Object stripe = assignStripe(message);
        workerThreads.submit(new Task(packet, stripe));
    } else {
        doWork(packet);
    }
}
 
开发者ID:dma-ais,项目名称:AisAbnormal,代码行数:37,代码来源:PacketHandlerImpl.java

示例13: updateApplicationStatistics

import dk.dma.ais.message.AisMessage; //导入依赖的package包/类
private void updateApplicationStatistics(AisMessage message) {
    statisticsService.incMessageCount();

    if (message instanceof IPositionMessage) {
        statisticsService.incPosMsgCount();
    } else if (message instanceof AisMessage5) {
        statisticsService.incStatMsgCount();
    }
}
 
开发者ID:dma-ais,项目名称:AisAbnormal,代码行数:10,代码来源:PacketHandlerImpl.java

示例14: handle

import dk.dma.ais.message.AisMessage; //导入依赖的package包/类
/**
 * Converts an AIS NMEA string to a signalK JSON object
 * See https://github.com/dma-ais/AisLib
 * 
 * HD-SF. Free raw AIS data feed for non-commercial use.
 * hd-sf.com:9009
 * 
 * @param bodyStr
 * @param device - the serial or other device the data was recieved over.
 * @return
 * @throws Exception 
 */
public SignalKModel handle(String bodyStr, String device) throws Exception {

	if (logger.isDebugEnabled())
		logger.debug("Processing AIS:" + bodyStr);

	if (StringUtils.isBlank(bodyStr) || !bodyStr.startsWith("!AIVDM")) {
		return null;
	}

	try {
		List<AisPacket> packets = handleLine(bodyStr);
		AisVesselInfo vInfo = null;
		SignalKModel model = SignalKModelFactory.getCleanInstance();
		for (AisPacket packet : packets) {
			if (packet != null && packet.isValidMessage()) {
				// process message here
				AisMessage message = packet.getAisMessage();
				if (logger.isDebugEnabled())
					logger.debug("AisMessage:" + message.getClass() + ":" + message.toString());
				
				// 1,2,3
				if (message instanceof AisPositionMessage) {
					vInfo = new AisVesselInfo((AisPositionMessage) message);
				}
				// 5,19,24
				if (message instanceof AisStaticCommon) {
					vInfo = new AisVesselInfo((AisStaticCommon) message);
				}
				if (message instanceof AisMessage18) {
					vInfo = new AisVesselInfo((AisMessage18) message);
				}
				if (vInfo != null) {
					if(StringUtils.isBlank(device))device=UNKNOWN;
					String ts = Util.getIsoTimeString(packet.getBestTimestamp());
					String aisVessel = vessels + dot + String.valueOf(vInfo.getUserId())+dot;
					//A general rule of sources.protocol.bus.device.data
					String srcRef = sources+".ais."+device+dot+String.valueOf(vInfo.getUserId())+dot+vInfo.getMsgType();
					//create ais source entry
					model.put(srcRef, packet.getStringMessage(),device,ts);
					
					if(vInfo.getName()!=null){
						model.getFullData().put(aisVessel+name, vInfo.getName());
					}
					model.put(aisVessel+mmsi, String.valueOf(vInfo.getUserId()), sourceRef, ts);
					model.put(aisVessel+ nav_state, navStatusMap.get(vInfo.getNavStatus()), sourceRef, ts);
					if (vInfo.getPosition() != null) {
						model.putPosition(aisVessel+ nav_position, vInfo.getPosition().getLatitude(), vInfo.getPosition().getLongitude(), 0.0, srcRef, ts);
					}
					model.put(aisVessel+ nav_courseOverGroundTrue, Math.toRadians(((double) vInfo.getCog()) / 10), srcRef, ts);
					model.put(aisVessel+ nav_speedOverGround, Util.kntToMs(((double) vInfo.getSog()) / 10), srcRef, ts);
					model.put(aisVessel+ nav_headingTrue, Math.toRadians(((double) vInfo.getTrueHeading()) / 10), srcRef);
					if (vInfo.getCallsign() != null) {
						model.put(aisVessel+ communication_callsignVhf, vInfo.getCallsign(), srcRef, ts);
					}
				}
			}
		}
		return model;

	} catch (Exception e) {
		logger.debug(e.getMessage(), e);
		logger.error(e.getMessage() + " : " + bodyStr);
		throw e;
	}

}
 
开发者ID:SignalK,项目名称:signalk-core-java,代码行数:79,代码来源:AISHandler.java

示例15: getOriginalMessage

import dk.dma.ais.message.AisMessage; //导入依赖的package包/类
public AisMessage getOriginalMessage() {
    return originalMessage;
}
 
开发者ID:dma-ais,项目名称:AisCoverage,代码行数:4,代码来源:CustomMessage.java


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