RobotCasserole1736 / RobotCasserole2020

Software for Robot Casserole's 2020 FIRST Infinite Recharge competition season
MIT License
1 stars 0 forks source link

Implement OverrunTracker class #92

Closed gerth2 closed 4 years ago

gerth2 commented 4 years ago

TBD Details

gerth2 commented 4 years ago

Create a class which will track how long it takes to execute some method call.

Ideally, use java lambda's to specify to the class which function to call. I think this guide may be of help, but this is admittedly java territory I have not traversed yet.

Here's the basic thought process I had:

class OverrunTracker(){
    int numOverrun = 0;

    OverrunTracker(double limit_sec, string Name){
        //Store limit_sec & name
    }

    public void reset(){
        numOverrun = 0;
    }

   public void runTracked( <method to be timed??>){
       double startTime = Timer.getFPGATimestamp();
       // <Run the method to be timed>
       double endTime = Timer.getFPGATimestamp();

       if(endTime - startTime > lim_sec){
            numOverrun++;
        }
    }

    public void report(){
        CrashTracker.logMessage(Name + " overran its execution time limit " + Integer.toString(numOverrun) + " times.");
        reset();
    }

}
gerth2 commented 4 years ago

Done - needs test on robot, but seems reasonable.