package nomadgui;

import nomadgui.state.*;

class armTestThread extends Thread {
  RSPFrame rframe;

  armTestThread(RSPFrame r) {
    rframe = r;
  }

  public void run() {
    for(float x=0; x<=((float)Math.PI*2/3); x+=.02f) {  // Theta from 0 -> 120 degrees
      rframe.setTheta(x);
      try { Thread.sleep(10); } catch(InterruptedException ie) {}
    }
    rframe.setTheta((float)Math.PI*2/3);
    
    for(float x=0; x<=(float)Math.PI; x+=.02f) {      // Phi from 0 -> 180 degrees
      rframe.setPhi(x);
      try { Thread.sleep(10); } catch(InterruptedException ie) {}
    }
    rframe.setPhi((float)Math.PI);
    
    for(float x=((float)Math.PI*1/18); x<=((float)Math.PI*17/18); x+=.02f) {
      // Alpha from 10 -> 170 degrees
      rframe.setAlpha(x);
      try { Thread.sleep(10); } catch(InterruptedException ie) {}
    }
    rframe.setAlpha((float)Math.PI*17/18);

    // back to starting position
    
    for(float x=(float)Math.PI; x>=0; x-=.02f) {      // Phi from 180 -> 0 degrees
      rframe.setPhi(x);
      try { Thread.sleep(10); } catch(InterruptedException ie) {}
    }
    rframe.setPhi(0);
    
    for(float x=((float)Math.PI*2/3); x>=0; x-=.02f) {  // Theta from 120 -> 0 degrees
      rframe.setTheta(x);
      try { Thread.sleep(10); } catch(InterruptedException ie) {}
    }
    rframe.setTheta(0);
    
    for(float x=((float)Math.PI*17/18); x>=((float)Math.PI*1/18); x-=.02f) {
      // Alpha from 170 -> 10 degrees
      rframe.setAlpha(x);
      try { Thread.sleep(10); } catch(InterruptedException ie) {}
    }
    rframe.setAlpha((float)Math.PI*1/18);
  }
}
