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);
}
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);
}
}
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);
}
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);
}
}
Aggregations