private void tracksRun() throws IOException { while (running) { try { if (tracksMsgReady) { p("ready to send Tracks"); tracksMsgReady = !(sendTracks()); Thread.sleep(TRACKS_DELAY); } else { int[][] targets = {{1, 1}, {100, 100}, {100, 10}}; int[][] lasers = {{22, 54}}; tracksMsgReady = setTracks( System.currentTimeMillis(), this.sysStatus.OPERATIONAL, targets, lasers, true); // setup tracks message } } catch (InterruptedException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } // end while loop } // End tracksRun method
private void imageRun() { while (running) { try { if (imageMsgReady) { imageMsgReady = !(sendImage()); Thread.sleep(IMAGE_DELAY); } else { byte[] serialImage = new byte[(channels * sizeX * sizeY)]; Random generator = new Random(); int index = 0; for (int i = 0; i < channels; i++) { for (int j = 0; j < sizeY; j++) { for (int k = 0; k < sizeX; k++) { serialImage[index++] = (byte) generator.nextInt(128); // Generate random number 0-127 MAX_SIZE for byte } } } imageMsgReady = setImage( System.currentTimeMillis(), channels, sizeX, sizeY, com.google.protobuf.ByteString.copyFrom(serialImage)); // setup status message } } catch (InterruptedException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } // end while loop } // End tracksRun method
public void run() { p("Run()"); try { switch (type) { case 0: // STATUS netStat.serverInit(); // try { // Thread.sleep( 1000 ); // // } // catch ( InterruptedException e) { // e.printStackTrace(); // } statusRun(); netStat.close(); break; case 1: // TRACKS netTracks.serverInit(); // try { // Thread.sleep( 900 ); // // } // catch ( InterruptedException e) { // e.printStackTrace(); // } tracksRun(); netTracks.close(); break; case 2: // IMAGE netImage.serverInit(); // try { // Thread.sleep( 300 ); // // } // catch ( InterruptedException e) { // e.printStackTrace(); // } imageRun(); netImage.close(); break; default: p("Didn't match any cases in constructor"); break; } } catch (IOException e) { e.printStackTrace(); } finally { p("Done"); } return; }
private void statusRun() throws IOException { p("in StatusRun()"); while (running) { try { if (statusMsgReady) { statusMsgReady = !(sendStatus()); p("send Status"); Thread.sleep(STATUS_DELAY); } else { statusMsgReady = setStatus( System.currentTimeMillis(), this.sysStatus.OPERATIONAL, false, "TEST-STRING"); // setup status message p("setStatus"); } } catch (InterruptedException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } // end while loop } // End statusRun method