001package edu.wpi.first.wpilibj.networktables2.connection; 002 003import java.io.*; 004 005import edu.wpi.first.wpilibj.networktables2.*; 006import edu.wpi.first.wpilibj.networktables2.thread.*; 007 008 009/** 010 * A periodic thread that repeatedly reads from a connection 011 * @author Mitchell 012 * 013 */ 014public class ConnectionMonitorThread implements PeriodicRunnable{ 015 private final ConnectionAdapter adapter; 016 private final NetworkTableConnection connection; 017 018 /** 019 * create a new monitor thread 020 * @param adapter 021 * @param connection 022 */ 023 public ConnectionMonitorThread(final ConnectionAdapter adapter, final NetworkTableConnection connection) { 024 this.adapter = adapter; 025 this.connection = connection; 026 } 027 028 public void run() throws InterruptedException { 029 try{ 030 connection.read(adapter); 031 } catch(BadMessageException e){ 032 adapter.badMessage(e); 033 } catch(IOException e){ 034 adapter.ioException(e); 035 } 036 } 037}