Search in sources :

Example 1 with NMEAService

use of org.vesalainen.parsers.nmea.NMEAService in project NMEAParser by tvesalainen.

the class AISServiceT method test1.

@Test
public void test1() throws IOException, InterruptedException {
    CachedScheduledThreadPool executor = new CachedScheduledThreadPool();
    NMEAService nmeaService = new NMEAService("224.0.0.3", 10110, executor);
    Path dir = Paths.get("c:\\temp");
    AISService aisService = AISService.getInstance(nmeaService, dir, 10, 1024 * 1024, executor);
    nmeaService.start();
    while (true) {
        Thread.sleep(10000);
        System.err.println();
        Collection<AISTarget> liveList = aisService.getLiveList();
        liveList.forEach((t) -> testAISTarget(t));
    }
// aisService.addObserver((s, m, t)->System.err.println(s+" "+m));
// Thread.sleep(100000000);
}
Also used : Path(java.nio.file.Path) CachedScheduledThreadPool(org.vesalainen.util.concurrent.CachedScheduledThreadPool) NMEAService(org.vesalainen.parsers.nmea.NMEAService) Test(org.junit.Test)

Example 2 with NMEAService

use of org.vesalainen.parsers.nmea.NMEAService in project NMEAParser by tvesalainen.

the class NMEASamplerT method test1.

@Test
public void test1() {
    try {
        NMEAService service = new NMEAService("224.0.0.3", 10110);
        // service.setLiveClock(false);
        service.start();
        Stream<NMEASample> stream = service.stream("latitude", "longitude");
        stream.forEach((s) -> System.err.println(s));
    } catch (IOException ex) {
        Logger.getLogger(NMEASamplerT.class.getName()).log(Level.SEVERE, null, ex);
    }
}
Also used : NMEAService(org.vesalainen.parsers.nmea.NMEAService) IOException(java.io.IOException) Test(org.junit.Test)

Example 3 with NMEAService

use of org.vesalainen.parsers.nmea.NMEAService in project NMEAParser by tvesalainen.

the class CommandLine method start.

private void start() throws IOException, InterruptedException, JAXBException, Exception {
    config("starting NMEA Server");
    Path configfile = getArgument("configuration file");
    Config config = new Config(configfile);
    String address = config.getNmeaMulticastAddress();
    int nmeaPort = config.getNmeaMulticastPort();
    int httpPort = config.getHttpPort();
    config("NMEA Multicast Address=%s", address);
    config("NMEA Multicast Port=%s", nmeaPort);
    config("HTTP Port=%s", httpPort);
    CachedScheduledThreadPool executor = new CachedScheduledThreadPool(64);
    config("ThreadPool started %s", executor);
    NMEAService nmeaService = new NMEAService(address, nmeaPort, executor);
    PropertyServer propertyServer = new PropertyServer(Clock.systemDefaultZone(), config, executor);
    nmeaService.addNMEAObserver(propertyServer);
    nmeaService.start();
    config("NMEA Service started");
    JavaUtilLog log = new JavaUtilLog();
    // make jetty use java.util.logger
    Log.setLog(log);
    Server server = new Server(httpPort);
    HandlerList handlers = new HandlerList();
    ServletContextHandler context = new ServletContextHandler();
    context.addServlet(ResourceServlet.class, "/");
    ServletHolder holder = new ServletHolder(SseServlet.class);
    holder.setAsyncSupported(true);
    context.addServlet(holder, "/sse");
    context.addServlet(ResourceServlet.class, "*.js");
    context.addServlet(ResourceServlet.class, "*.css");
    context.addServlet(ResourceServlet.class, "*.gif");
    context.addServlet(ResourceServlet.class, "*.png");
    context.addServlet(ResourceServlet.class, "*.ico");
    context.addServlet(PrefsServlet.class, "/prefs");
    context.addServlet(I18nServlet.class, "/i18n");
    SessionHandler sessionHandler = new SessionHandler();
    context.setSessionHandler(sessionHandler);
    handlers.addHandler(context);
    server.setHandler(handlers);
    server.setSessionIdManager(new DefaultSessionIdManager(server));
    ServletContext servletContext = context.getServletContext().getContext("/sse");
    servletContext.setAttribute(PropertyServer.class.getName(), propertyServer);
    server.start();
    executor.awaitTermination(Long.MAX_VALUE, TimeUnit.MILLISECONDS);
}
Also used : Path(java.nio.file.Path) HandlerList(org.eclipse.jetty.server.handler.HandlerList) SessionHandler(org.eclipse.jetty.server.session.SessionHandler) DefaultSessionIdManager(org.eclipse.jetty.server.session.DefaultSessionIdManager) Server(org.eclipse.jetty.server.Server) ServletHolder(org.eclipse.jetty.servlet.ServletHolder) CachedScheduledThreadPool(org.vesalainen.util.concurrent.CachedScheduledThreadPool) JavaUtilLog(org.eclipse.jetty.util.log.JavaUtilLog) ServletContext(javax.servlet.ServletContext) NMEAService(org.vesalainen.parsers.nmea.NMEAService) ServletContextHandler(org.eclipse.jetty.servlet.ServletContextHandler)

Example 4 with NMEAService

use of org.vesalainen.parsers.nmea.NMEAService in project NMEAParser by tvesalainen.

the class ViewerService method openNMEAService.

private void openNMEAService() {
    try {
        if (nmeaService != null) {
            nmeaService.stop();
            nmeaService = null;
        }
        nmeaService = new NMEAService(hostBinding.getValue(), portBinding.getValue(), executor);
        nmeaService.addNMEAObserver(propertyStore);
        nmeaService.start();
        isInvalid = false;
    } catch (Exception ex) {
        Logger.getLogger(ViewerService.class.getName()).log(Level.SEVERE, null, ex);
    }
}
Also used : NMEAService(org.vesalainen.parsers.nmea.NMEAService)

Aggregations

NMEAService (org.vesalainen.parsers.nmea.NMEAService)4 Path (java.nio.file.Path)2 Test (org.junit.Test)2 CachedScheduledThreadPool (org.vesalainen.util.concurrent.CachedScheduledThreadPool)2 IOException (java.io.IOException)1 ServletContext (javax.servlet.ServletContext)1 Server (org.eclipse.jetty.server.Server)1 HandlerList (org.eclipse.jetty.server.handler.HandlerList)1 DefaultSessionIdManager (org.eclipse.jetty.server.session.DefaultSessionIdManager)1 SessionHandler (org.eclipse.jetty.server.session.SessionHandler)1 ServletContextHandler (org.eclipse.jetty.servlet.ServletContextHandler)1 ServletHolder (org.eclipse.jetty.servlet.ServletHolder)1 JavaUtilLog (org.eclipse.jetty.util.log.JavaUtilLog)1