• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java AisMessage类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: setOriginalMessage

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


示例17: update

import dk.dma.ais.message.AisMessage; //导入依赖的package包/类
public void update(AisPacket packet) {
    AisMessage message = packet.tryGetAisMessage();
    if (message == null) {
        return;
    }

    this.lastSourceRegion = null;
    // Get source region from Gatehouse tag
    if (message.getTags() != null) {
        for (IProprietaryTag tag : message.getTags()) {
            if (tag instanceof GatehouseSourceTag) {
                GatehouseSourceTag ghTag = (GatehouseSourceTag) tag;
                this.lastSourceRegion = ghTag.getRegion();
            }
        }
    }
    this.lastTagging = packet.getTags();

    // Update times of reception of time
    Long now = System.currentTimeMillis();

    SourceType sourceType = lastTagging.getSourceType();
    if (sourceType == null) {
        sourceType = SourceType.TERRESTRIAL;
    }
    sourceTypeTime.put(sourceType.encode(), now);

    Country srcCnt = lastTagging.getSourceCountry();
    if (srcCnt != null) {
        sourceCountryTime.put(srcCnt.getThreeLetter(), now);
    }

    if (lastSourceRegion != null) {
        sourceRegionTime.put(lastSourceRegion, now);
    }

    if (lastTagging.getSourceBs() != null) {
        sourceBsTime.put(Integer.toString(lastTagging.getSourceBs()), now);
    }

    if (lastTagging.getSourceId() != null) {
        sourceSystemTime.put(lastTagging.getSourceId(), now);
    }

}
 
开发者ID:dma-ais,项目名称:AisView,代码行数:46,代码来源:TargetSourceData.java


示例18: addTarget

import dk.dma.ais.message.AisMessage; //导入依赖的package包/类
@Override
public void addTarget(TargetInfo vesselTarget, int anonId) {


    if (!vesselTarget.hasPositionInfo() || vesselTarget.getPosition() == null) {
        return;
    }
    
    float cog = vesselTarget.getCog()/10.0f;
    //float sog = vesselTarget.getSog();
    Double lat = vesselTarget.getPosition().getLatitude();
    Double lon = vesselTarget.getPosition().getLongitude();

    
    String vesselClass;
    ShipTypeCargo shipTypeCargo = new ShipTypeCargo(vesselTarget.getStaticShipType());
    

    Byte navStatus = vesselTarget.getNavStatus();        
    
    vesselClass = vesselTarget.getTargetType().toString();


    // Round cog to nearest 10
    long cogL = Math.round(cog / 10.0) * 10;
    if (cogL == 360) {
        cogL = 0;
    }

    ArrayList<String> list = new ArrayList<String>();
    
    list.add(Long.toString(cogL));
    list.add(String.format(Locale.US, "%.5f", lat));
    list.add(String.format(Locale.US, "%.5f", lon));
    list.add(vesselClass);
    ShipTypeMapper.ShipTypeColor color = ShipTypeMapper.ShipTypeColor.GREY;
    if (shipTypeCargo != null) {
        color = shipTypeMapper.getColor(shipTypeCargo.getShipType());
    }
    list.add(Integer.toString(color.ordinal()));
    
    list.add((navStatus != null && (navStatus == 1 || navStatus ==5)) ? "1" : "0");
    
    list.add(Long.toString(vesselTarget.getMmsi()));     
    
    String name = "N/A";
    String callsign = "N/A";
    String imoNo = "N/A";
            
    
    AisTargetType att = vesselTarget.getTargetType();
    if (vesselTarget.hasStaticInfo() && (att == AisTargetType.A || att == AisTargetType.B)) {
        AisVesselStatic avs = (att == AisTargetType.A) ? new AisClassAStatic() : new AisClassBStatic();            
        
        for (AisPacket p: vesselTarget.getStaticPackets()) {
            AisMessage m = p.tryGetAisMessage();
            
            if (m != null && m instanceof AisMessage5) {
                AisMessage5 am5 = (AisMessage5)m;
                imoNo = (am5.getImo() > 0) ? Long.toString(am5.getImo()) : "N/A";
                avs.update(am5);
            } else if (m != null && m instanceof AisStaticCommon ) {
                avs.update((AisStaticCommon)m);
            }
        }
        
        name = AisMessage.trimText(avs.getName());
        callsign = AisMessage.trimText(avs.getCallsign());

        
    }

    list.add(name);
    list.add(callsign);
    list.add(imoNo);
    
    vessels.put(anonId, list);    
    vesselCount++;
    
}
 
开发者ID:dma-ais,项目名称:AisView,代码行数:81,代码来源:VesselList.java


示例19: assignStripe

import dk.dma.ais.message.AisMessage; //导入依赖的package包/类
private static Object assignStripe(AisMessage message) {
    return Integer.valueOf(Math.abs(hash(message.getUserId())) % NUMBER_OF_CORES);
}
 
开发者ID:dma-ais,项目名称:AisAbnormal,代码行数:4,代码来源:PacketHandlerImpl.java


示例20: countCellsFromFeed

import dk.dma.ais.message.AisMessage; //导入依赖的package包/类
@Test
public void countCellsFromFeed() throws IOException, InterruptedException {        
    final Set<Integer> mmsis = new HashSet<>();
    final Set<Cell> cells = new HashSet<>();
    final Grid grid = Grid.createSize(200);
    final AtomicReference<Long> mCount = new AtomicReference<>(0L);
    long start = System.currentTimeMillis();
    final DownSampleFilter df = new DownSampleFilter(0);
    
    //AisReader reader = AisReaders.createReaderFromFile("/tmp/ais_dk_76h.txt.gz");
    AisReader reader = AisReaders.createReaderFromFile("src/test/resources/ais-sample.txt.gz");
    reader.registerPacketHandler(new Consumer<AisPacket>() {
        @Override
        public void accept(AisPacket p) {
            if (df.rejectedByFilter(p)) {
                return;
            }
            AisMessage m = p.tryGetAisMessage();
            if (m == null) {
                return;
            }
            mCount.set(mCount.get() + 1);                
            // Only look at class a position reports
            if (!(m instanceof AisPositionMessage)) {
                return;
            }                
            mmsis.add(m.getUserId());                
            AisPositionMessage posM = (AisPositionMessage)m;
            Position pos = posM.getValidPosition();
            if (pos == null) {
                return;
            }
            cells.add(grid.getCell(pos));
        }            
    });
    
    reader.start();
    reader.join();
    
    long elapsed = (System.currentTimeMillis() - start) / 1000;
    double rate = (double)mCount.get() / (double)elapsed;
    System.out.println(String.format("%-30s %9d", "Elapsed s", elapsed));
    System.out.println(String.format("%-30s %9.0f msg/sec", "Message rate", rate));
    System.out.println(String.format("%-30s %9d", "Unique mmsi", mmsis.size()));
    System.out.println(String.format("%-30s %9d", "Unique cells", cells.size()));
}
 
开发者ID:dma-ais,项目名称:AisAbnormal,代码行数:47,代码来源:GridTest.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java FadeInDownAnimator类代码示例发布时间:2022-05-22
下一篇:
Java AbstractBottomUpParser类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap