Exemple #1
0
 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
Exemple #2
0
  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
Exemple #3
0
 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
Exemple #4
0
  public static void main(String... aArgs) throws IOException {
    if (aArgs.length > 0) {
      SendMsg msg = new SendMsg();
    } else {
      SendMsg mStatus = new SendMsg(0); // Create object instance
      SendMsg mTracks = new SendMsg(1);
      SendMsg mImage = new SendMsg(2);

      Thread tStatus = new Thread(mStatus);
      Thread tTracks = new Thread(mTracks);
      Thread tImage = new Thread(mImage);

      tStatus.start();
      System.out.println("tStatus Started");

      tTracks.start();
      System.out.println("tTracks Started");

      tImage.start();
      System.out.println("tImage Started");
    }
    long time = System.currentTimeMillis();
    long duration = MAIN_RUNTIME;
    while (System.currentTimeMillis() < time + duration) {
      // Do Nothing - everything in threads
      try {
        Thread.sleep(MAIN_RUNTIME);
      } catch (InterruptedException e) {
        e.printStackTrace();
      }
    }
    running = false; // stop threads
    //
    //		for (int n=0; n<10; n++) {
    //
    //
    //
    //
    //		statusMsgReady =
    // msg.setStatus(System.currentTimeMillis(),msg.sysStatus.OPERATIONAL,false,"TEST-STRING");	//
    // setup status message
    //		tracksMsgReady =
    // msg.setTracks(System.currentTimeMillis(),msg.sysStatus.OPERATIONAL,targets,lasers,true);	//
    // setup tracks message
    ////		imageMsgReady =
    // msg.setImage(System.currentTimeMillis(),image.length,image[0].length,image[0][0].length,com.google.protobuf.ByteString.copyFrom(serialImage));	// setup status message
    //		imageMsgReady =
    // msg.setImage(System.currentTimeMillis(),channels,sizeX,sizeY,com.google.protobuf.ByteString.copyFrom(serialImage));	// setup status message
    //
    //		statusMsgReady = !(msg.sendStatus());
    //		System.out.println("Send Status");
    //
    //		tracksMsgReady = !(msg.sendTracks(netTracks));
    //			System.out.println("Send Tracks");
    //
    //		imageMsgReady = !(msg.sendImage(netImage));
    //			System.out.println("Send Image");

    //		} // End For Loop
    // Close Network interfaces
    //		netImage.close();
    //		netTracks.close();
    //		netStat.close();

    // netImage.close();
  } // End Main Function