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

Java AisPacket类代码示例

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

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



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

示例1: handleLine

import dk.dma.ais.packet.AisPacket; //导入依赖的package包/类
/**
 * Handle a String message, returning a list of AisPackets
 * 
 * @param line
 * @return
 */
public List<AisPacket> handleLine(String messageString) throws IOException {
	if (logger.isDebugEnabled())
		logger.debug("AIS Received : " + messageString);
	// Check for ABK
	if (Abk.isAbk(messageString)) {
		if (logger.isDebugEnabled())
			logger.debug("AIS Received ABK: " + messageString);
		return null;
	}

	try {
		List<AisPacket> packets = new ArrayList<AisPacket>();
		String[] lines = messageString.split("\\r?\\n");

		for (String line : lines) {
			packets.add(packetParser.readLine(line));
		}
		return packets;
	} catch (SentenceException se) {
		if (logger.isDebugEnabled())
			logger.info("AIS Sentence error: " + se.getMessage() + " line: " + messageString);
		throw new IOException(se);

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


示例2: startAisBus

import dk.dma.ais.packet.AisPacket; //导入依赖的package包/类
private void startAisBus(Consumer<AisPacket> packetConsumer) {
    LOG.debug("Starting AisBus");
    try {
        DistributerConsumer distributor = new DistributerConsumer();
        distributor.getConsumers().add(packetConsumer);
        distributor.init();
        aisBus.registerConsumer(distributor);
        aisBus.start();
        aisBus.startConsumers();
        aisBus.startProviders();
    } catch (Exception e) {
        LOG.error("Failed to start AisBus", e);
        exit(-1);
    }
    LOG.debug("AisBus started");
}
 
开发者ID:dma-ais,项目名称:AisTrack,代码行数:17,代码来源:AisTrackService.java


示例3: receiveUnfiltered

import dk.dma.ais.packet.AisPacket; //导入依赖的package包/类
public void receiveUnfiltered(AisPacket packet) {
    unfiltCount++;
    
    //extract relevant information from packet
    CustomMessage message = dataHandler.packetToCustomMessage(packet);
    if(message == null){
        return;
    }
    
    String key = message.getKey();
    
    //Add to doublet buffer.
    CustomMessage existing = doubletBuffer.get(key);
    if (existing == null) {
        doubletBuffer.put(key, message);
    }else{
        existing.addSourceMMSI(message.getSourceList().iterator().next());
    }

}
 
开发者ID:dma-ais,项目名称:AisCoverage,代码行数:21,代码来源:CoverageHandler.java


示例4: getStaticInfo

import dk.dma.ais.packet.AisPacket; //导入依赖的package包/类
@GET
@Path("/static/{mmsi : \\d+}")
@Produces(MediaType.TEXT_PLAIN)
public StreamingOutput getStaticInfo(@Context UriInfo info,
        @PathParam("mmsi") int mmsi) {
    QueryParameterHelper qh = new QueryParameterHelper(info);

    Predicate<AisPacketSource> pred = qh.getSourcePredicate();
    pred = (pred == null) ? e -> true : pred;

    TargetTracker tt = get(TargetTracker.class);
    TargetInfo ti = tt.get(mmsi, pred);
    List<AisPacket> l = java.util.Arrays.asList(ti.getStaticPackets());

    Iterable<AisPacket> p = applyFilters(l.stream(), qh);
    
    return StreamingUtil.createStreamingOutput(p,
            qh.getOutputSink());
}
 
开发者ID:dma-ais,项目名称:AisView,代码行数:20,代码来源:TrackerResource.java


示例5: getPositionInfo

import dk.dma.ais.packet.AisPacket; //导入依赖的package包/类
@GET
@Path("/dynamic/{mmsi : \\d+}")
@Produces(MediaType.TEXT_PLAIN)
public StreamingOutput getPositionInfo(@Context UriInfo info,
        @PathParam("mmsi") int mmsi) {
    QueryParameterHelper qh = new QueryParameterHelper(info);

    Predicate<AisPacketSource> pred = qh.getSourcePredicate();
    pred = (pred == null) ? e -> true : pred;

    TargetTracker tt = get(TargetTracker.class);
    TargetInfo ti = tt.get(mmsi, pred);

    // convert TargetInfo to Stream<AisPacket> and then Iterable<AisPacket>
    // after applying filters
    Iterable<AisPacket> packets = applyFilters(
            Arrays.asList(new TargetInfo[] { ti }).stream()
                    .map(e -> e.getPositionPacket()), qh);

    return StreamingUtil.createStreamingOutput(packets,
            qh.getOutputSink());
}
 
开发者ID:dma-ais,项目名称:AisView,代码行数:23,代码来源:TrackerResource.java


示例6: getPositions

import dk.dma.ais.packet.AisPacket; //导入依赖的package包/类
@GET
@Path("/dynamic/")
@Produces(MediaType.TEXT_PLAIN)
public StreamingOutput getPositions(@Context UriInfo info) {
    QueryParameterHelper qh = new QueryParameterHelper(info);
    Predicate<AisPacketSource> predSource = qh.getSourcePredicate();
    predSource = (predSource == null) ? e -> true : predSource;

    Predicate<TargetInfo> predTarget = qh.getTargetPredicate();
    predTarget = predTarget.and(TargetInfoFilters.filterOnHasPosition());
    predTarget = (qh.getArea() != null) ? qh.getTargetAreaFilter() : predTarget;

    TargetTracker tt = get(TargetTracker.class);

    Stream<TargetInfo> s = tt.stream(predSource, predTarget);
    Stream<AisPacket> sPacket = s.map(e -> e.getPositionPacket()).filter(
            o -> o != null);

    Iterable<AisPacket> packets = applyFilters(sPacket, qh);

    
    
    return StreamingUtil.createStreamingOutput(packets,
            qh.getOutputSink());
}
 
开发者ID:dma-ais,项目名称:AisView,代码行数:26,代码来源:TrackerResource.java


示例7: getPacketStream

import dk.dma.ais.packet.AisPacket; //导入依赖的package包/类
protected Stream<AisPacket> getPacketStream(UriInfo info, QueryParameterHelper qh) {
    Predicate<AisPacketSource> predSource = qh.getSourcePredicate();
    predSource = (predSource == null) ? e -> true : predSource;

    Predicate<TargetInfo> predTarget = qh.getTargetPredicate();
    predTarget = (predTarget == null) ? e -> true : predTarget;

    predTarget = (qh.getArea() != null) ? qh.getTargetAreaFilter() : predTarget;

    TargetTracker tt = get(TargetTracker.class);

    Stream<TargetInfo> s = tt.stream(predSource, predTarget);
    Stream<AisPacket[]> sPackets = s.map(e -> e.getPackets()).filter(o -> o != null);

    final ConcurrentLinkedDeque<AisPacket> packets = new ConcurrentLinkedDeque<AisPacket>();
    sPackets.sequential().forEach(e -> {
        for (int i = 0; i < e.length; i++) {
            packets.add(e[i]);
        }
    });

    return packets.stream();
}
 
开发者ID:dma-ais,项目名称:AisView,代码行数:24,代码来源:AbstractTrackerResource.java


示例8: getTenMinuteCount

import dk.dma.ais.packet.AisPacket; //导入依赖的package包/类
/**
 * Get the count of messages from packets received with timestamp in the
 * closest full 10 minutes time block.
 * 
 * @return
 */
private AtomicLong getTenMinuteCount() {
    // get the latest guaranteed full block
    long startBlock = (long) ((double) DateTime.now().getMillis() / 10.0 / 60.0 / 1000.0) - 1;
    long endBlock = startBlock + 1;

    long start = startBlock * 10 * 60 * 1000;
    long end = endBlock * 10 * 60 * 1000;

    AisStoreQueryBuilder b = AisStoreQueryBuilder.forTime().setInterval(
            start, end);
    AisStoreQueryResult query = cassandraConnection().execute(b);
    Iterable<AisPacket> q = query;

    final AtomicLong l = new AtomicLong();
    q = Iterables.counting(q, l);
    for (Iterator<AisPacket> iterator = q.iterator(); iterator.hasNext();) {
        iterator.next();
    }

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


示例9: getPastTrack

import dk.dma.ais.packet.AisPacket; //导入依赖的package包/类
/**
 * getPastTrack will only work with position messages
 * 
 * @param info
 * @param mmsi
 * @return
 */
private Iterable<AisPacket> getPastTrack(@Context UriInfo info, int... mmsi) {
    QueryParameterHelper p = new QueryParameterHelper(info);

    // Execute the query
    AisStoreQueryBuilder b = AisStoreQueryBuilder.forMmsi(mmsi);
    b.setInterval(p.getInterval());

    // Create the query
    Iterable<AisPacket> query = cassandraConnection().execute(b);

    // Apply filters from the user
    query = Iterables.filter(query, AisPacketFilters
            .filterOnMessageType(IVesselPositionMessage.class));
    query = p.applyPacketFilter(query);
    query = p.applyPositionSampler(query); // WARNING: Must be the second
                                           // last filter
    query = p.applyLimitFilter(query); // WARNING: Must be the last filter
                                       // (if other filters reject packets)
    return query;
}
 
开发者ID:dma-ais,项目名称:AisView,代码行数:28,代码来源:AisStoreResource.java


示例10: getHistory

import dk.dma.ais.packet.AisPacket; //导入依赖的package包/类
/**
 * getHistory takes all ais data with mmsis using stateful filters
 * 
 * @param info
 * @param mmsi
 * @return
 */
private Iterable<AisPacket> getHistory(@Context UriInfo info, int... mmsi) {
    QueryParameterHelper p = new QueryParameterHelper(info);

    // Execute the query
    AisStoreQueryBuilder b = AisStoreQueryBuilder.forMmsi(mmsi);
    b.setInterval(p.getInterval());

    // Create the query
    Iterable<AisPacket> query = cassandraConnection().execute(b);

    final AisPacketFiltersStateful state = new AisPacketFiltersStateful();

    // Apply filters from the user
    query = p.applyPacketFilter(query); // first because this potentially
                                        // filters a lot of packets
    query = p.applyTargetFilterArea(query, state);
    query = p.applyLimitFilter(query); // WARNING: Must be the last filter
                                       // (if other filters reject packets)
    return query;
}
 
开发者ID:dma-ais,项目名称:AisView,代码行数:28,代码来源:AisStoreResource.java


示例11: provideShipNameFilter

import dk.dma.ais.packet.AisPacket; //导入依赖的package包/类
@Provides
@Named("shipNameFilter")
Predicate<AisPacket> provideShipNameFilter() {
    Configuration configuration = getConfiguration();
    String[] shipNames = configuration.getStringArray(CONFKEY_FILTER_SHIPNAME_SKIP);
    Predicate<AisPacket> filter = null;
    if (shipNames != null && shipNames.length > 0 && !(shipNames.length == 1 && shipNames[0].trim().length() == 0)) {
        String filterExpression = "";
        for (int i = 0; i < shipNames.length; i++) {
            filterExpression += "t.name ~ " + shipNames[i];
            if (i != shipNames.length - 1) {
                filterExpression += " | ";
            }
        }
        LOG.debug("filterExpression: " + filterExpression);
        filter = parseExpressionFilter(filterExpression);
        LOG.info("Created ship name filter: " + filterExpression);
    }
    return filter != null ? filter : aisPacket -> false;
}
 
开发者ID:dma-ais,项目名称:AisAbnormal,代码行数:21,代码来源:AbnormalAnalyzerAppModule.java


示例12: PacketHandlerImpl

import dk.dma.ais.packet.AisPacket; //导入依赖的package包/类
@Inject
public PacketHandlerImpl(
        Configuration configuration,
        Injector injector,
        AppStatisticsService statisticsService,
        EventEmittingTracker tracker,
        Set<IPacketFilter> filters,
        @Named("shipNameFilter") Predicate<AisPacket> shipNameFilter
) {
    this.configuration = configuration;
    this.injector = injector;
    this.statisticsService = statisticsService;
    this.tracker = tracker;
    this.filters = filters;
    this.shipNameFilter = shipNameFilter;
    this.analyses = initAnalyses();

    this.analyses.forEach(analysis -> analysis.start());
}
 
开发者ID:dma-ais,项目名称:AisAbnormal,代码行数:20,代码来源:PacketHandlerImpl.java


示例13: accept

import dk.dma.ais.packet.AisPacket; //导入依赖的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


示例14: filterPacket

import dk.dma.ais.packet.AisPacket; //导入依赖的package包/类
/**
 * Returns true if packet passes all packet filters
 * @param packet
 * @return
 */
private boolean filterPacket(AisPacket packet) {
    final boolean[] rejected = {false}; // TODO Use Groovy or Scala...
    filters.forEach(f -> {
        if (!rejected[0] && f.rejectedByFilter(packet)) {
            rejected[0] = true;
            if (LOG.isDebugEnabled()) {
                LOG.debug("Packet dropped due to " + f.getClass().getSimpleName());
            }
        }
    });

    boolean shipNameFilterPassed = ! shipNameFilter.test(packet);
    if (!shipNameFilterPassed && LOG.isDebugEnabled()) {
        LOG.debug("Packet dropped due to shipNameFilter");
    }

    boolean filterPassed = !rejected[0] && shipNameFilterPassed;

    if (LOG.isDebugEnabled()) {
        LOG.debug("Packet " + (filterPassed ? "passed":"dropped") + ": " + packet.getStringMessage());
    }

    return filterPassed;
}
 
开发者ID:dma-ais,项目名称:AisAbnormal,代码行数:30,代码来源:PacketHandlerImpl.java


示例15: AisCoverage

import dk.dma.ais.packet.AisPacket; //导入依赖的package包/类
private AisCoverage(AisCoverageConfiguration conf) {
    this.conf = conf;

    // Create handler
    handler = new CoverageHandler(conf);

    // Create AisBus
    aisBus = conf.getAisbusConfiguration().getInstance();
    

    // Create web server
    if (conf.getServerConfiguration() != null) {
        webServer = new WebServer(conf.getServerConfiguration());
    } else {
        webServer = null;
    }

    final DistributerConsumer unfilteredConsumer = new DistributerConsumer(true);
    unfilteredConsumer.init();
    // Delegate unfiltered packets to handler
    unfilteredConsumer.getConsumers().add(new Consumer<AisPacket>() {
        @Override
        public void accept(AisPacket packet) {
            handler.receiveUnfiltered(packet);
        }
    });                
    aisBus.registerConsumer(unfilteredConsumer);
}
 
开发者ID:dma-ais,项目名称:AisCoverage,代码行数:29,代码来源:AisCoverage.java


示例16: AisTargetEntry

import dk.dma.ais.packet.AisPacket; //导入依赖的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


示例17: update

import dk.dma.ais.packet.AisPacket; //导入依赖的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


示例18: rateCount

import dk.dma.ais.packet.AisPacket; //导入依赖的package包/类
@GET
@Path("rate/count")
@Produces(MediaType.TEXT_PLAIN)
public Long rateCount(@Context UriInfo uriInfo) {
    TargetTracker tt = Objects.requireNonNull(LegacyResource.this
            .get(TargetTracker.class));

    Stream<TargetInfo> tis = tt.stream();

    final Date d = new Date(new Date().getTime() - 1000);
    final Long dLong = d.getTime();

    // count all packets in the TargetInfo which are after the given
    // timestamp.
    // this is kind of "double work" since we already filtered them above.
    Long r = tis.mapToLong(value -> {

        long r1 = 0L;
        if (value.getPositionTimestamp() > dLong) {
            r1++;
        }

        // eep, this is slow but has to be done
        if (value.getStaticCount() > 1) {
            for (AisPacket p : value.getStaticPackets()) {
                if (p.getBestTimestamp() > dLong) {
                    r1++;
                }
            }
        } else if (value.getStaticTimestamp() > dLong) {
            r1++;
        }

        return r1;
    }).sum();

    return new Double((double) r).longValue();
}
 
开发者ID:dma-ais,项目名称:AisView,代码行数:39,代码来源:LegacyResource.java


示例19: getStatics

import dk.dma.ais.packet.AisPacket; //导入依赖的package包/类
@GET
@Path("/static/")
@Produces(MediaType.TEXT_PLAIN)
public StreamingOutput getStatics(@Context UriInfo info) {
    QueryParameterHelper qh = new QueryParameterHelper(info);

    Predicate<AisPacketSource> predSource = qh.getSourcePredicate();
    predSource = (predSource == null) ? e -> true : predSource;

    Predicate<TargetInfo> predTarget = qh.getTargetPredicate();
    predTarget = (predTarget == null) ? e -> true : predTarget;
    
    predTarget.and(TargetInfoFilters.filterOnHasStatic());
    predTarget = (qh.getArea() != null) ? qh.getTargetAreaFilter() : predTarget;

    TargetTracker tt = get(TargetTracker.class);

    Stream<TargetInfo> s = tt.stream(predSource, predTarget);

    Stream<AisPacket[]> sPackets = s.map(e -> e.getStaticPackets());

    final ConcurrentLinkedDeque<AisPacket> packets = new ConcurrentLinkedDeque<AisPacket>();
    sPackets.forEach(e -> {
        for (int i = 0; i < e.length; i++) {
            packets.add(e[i]);
        }
    });

    Iterable<AisPacket> p = applyFilters(packets.stream(), qh);

    return StreamingUtil.createStreamingOutput(p,
            qh.getOutputSink());
}
 
开发者ID:dma-ais,项目名称:AisView,代码行数:34,代码来源:TrackerResource.java


示例20: getPacketsJson

import dk.dma.ais.packet.AisPacket; //导入依赖的package包/类
@GET
@Path("/packets/json")
@Produces(MediaType.TEXT_PLAIN)
public StreamingOutput getPacketsJson(@Context UriInfo info) {
    QueryParameterHelper qh = new QueryParameterHelper(info);
    Stream<AisPacket> packets = getPacketStream(info, qh);
    return StreamingUtil.createStreamingOutput(
            (Iterable<AisPacket>) packets::iterator,
            AisPacketOutputSinks.jsonMessageSink());
}
 
开发者ID:dma-ais,项目名称:AisView,代码行数:11,代码来源:TrackerResource.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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