View Single Post
  #13   Spotlight this post!  
Unread 08-06-2012, 16:17
daniel_dsouza daniel_dsouza is offline
does what needs to be done.
FRC #2449 (Out of Orbit Robotics)
Team Role: Alumni
 
Join Date: May 2011
Rookie Year: 2011
Location: Chandler, AZ
Posts: 231
daniel_dsouza has a spectacular aura aboutdaniel_dsouza has a spectacular aura about
Re: Multitasking in Java

The "PIDcontroller" class creates a thread to run its calculations.
It's code looks like this (extra stuff removed so that the thread code remains):
Code:
java.util.Timer controlLoop;
...
private class PIDTask extends TimerTask {
     ...
     public void run() {
           m_controller.calculate();
     }
}

public PIDController(double Kp, double Ki, double Kd, PIDSource source, PIDOutput[] output, double iperiod) {
     controlLoop = new java.util.Timer();
      ...
     controlLoop.schedule(new PIDController.PIDTask(this), 0L, (long) (period * 1000)); //starts thread
}
I haven't examined the process in depth, but this is what is written.
Reply With Quote