package ch.spherICIT.communication; import com.fazecast.jSerialComm.SerialPort; import javax.swing.SwingWorker; public class StatusLoopWorker extends SwingWorker { private SerialPort serialPort; public StatusLoopWorker(SerialPort serialPort) { this.serialPort = serialPort; } @Override protected Void doInBackground() throws Exception { long counter = 0; while (counter < 4) { if (isCancelled()) { break; } if (counter == 0) { SerialCommHandler.sendRelaisStatusCommand(this.serialPort); } else if (counter == 1) { SerialCommHandler.sendCamStatusCommand(this.serialPort); } else if (counter == 2) { SerialCommHandler.sendCamVelocityStatusCommand(this.serialPort); } else { SerialCommHandler.sendActualAzimutCommand(this.serialPort); } counter++; Thread.sleep(3000); } return null; } }