-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add new logger system #27
base: master
Are you sure you want to change the base?
Changes from 2 commits
66e5a0a
314ee21
29ec846
2918f29
0d0bb64
ab7bc1a
903661e
4b2ccdc
5019e88
7b09772
5bdd854
e0eb9fe
4d90feb
a5412f1
4c3cfc4
86578d9
44cc623
d39f525
6c7522e
754c848
f1439e3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,18 +4,21 @@ | |
|
||
package frc.robot; | ||
|
||
import edu.wpi.first.wpilibj.Notifier; | ||
import edu.wpi.first.wpilibj.PneumaticsModuleType; | ||
import edu.wpi.first.wpilibj.PowerDistribution.ModuleType; | ||
import edu.wpi.first.wpilibj.Solenoid; | ||
import edu.wpi.first.wpilibj.TimedRobot; | ||
import frc.robot.Climber.MotorStates; | ||
import frc.robot.logging.LoggableCompressor; | ||
import frc.robot.logging.LoggableController; | ||
import frc.robot.logging.LoggableGyro; | ||
// import frc.robot.logging.LoggableGyro; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This block of commented-out lines of code should be removed. |
||
import frc.robot.logging.LoggablePowerDistribution; | ||
import frc.robot.logging.LoggableTimer; | ||
import frc.robot.logging.Logger; | ||
|
||
import java.io.IOException; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Extra separation in import group before 'java.io.IOException' |
||
|
||
/** | ||
* The VM is configured to automatically run this class, and to call the functions corresponding to | ||
* each mode, as described in the TimedRobot documentation. If you change the name of this class or | ||
|
@@ -24,6 +27,9 @@ | |
*/ | ||
public class Robot extends TimedRobot { | ||
|
||
Notifier notif; | ||
Runnable runnable; | ||
|
||
Logger logger; | ||
LoggableTimer timer; | ||
|
||
|
@@ -62,11 +68,28 @@ public double deadband(double in) { | |
@Override | ||
public void robotInit() { | ||
logger = new Logger(); | ||
runnable = new Runnable() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Make this anonymous inner class a lambda (sonar.java.source not set. Assuming 8 or greater.) |
||
@Override | ||
public void run() { | ||
logger.logAll(); | ||
} | ||
}; | ||
|
||
notif = new Notifier(runnable); | ||
|
||
timer = new LoggableTimer(); | ||
logger.addLoggable(timer); | ||
// gyro = new LoggableGyro(); | ||
|
||
pdp = new LoggablePowerDistribution(1, ModuleType.kRev); | ||
logger.addLoggable(pdp); | ||
|
||
try { | ||
logger.createLog(); | ||
} catch (IOException e) { | ||
// TODO Auto-generated catch block | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TODO found |
||
e.printStackTrace(); | ||
} | ||
|
||
driver = new LoggableController("Driver", 0); | ||
operator = new LoggableController("Operator", 1); | ||
|
@@ -112,6 +135,10 @@ public void robotInit() { | |
logger.addLoggable(driver); | ||
logger.addLoggable(operator); | ||
logger.addLoggable(compressor); | ||
|
||
logger.logAllHeaders(); | ||
|
||
notif.startPeriodic(1/30); | ||
} | ||
|
||
@Override | ||
|
@@ -129,8 +156,6 @@ public void autonomousInit() { | |
@Override | ||
public void autonomousPeriodic() { | ||
// Robot code goes here | ||
logger.log(); | ||
logger.writeLine(); | ||
} | ||
|
||
@Override | ||
|
@@ -179,21 +204,17 @@ public void teleopPeriodic() { | |
} | ||
// TODO: Enable this when we're ready to test the climber | ||
} | ||
|
||
logger.log(); | ||
logger.writeLine(); | ||
} | ||
|
||
@Override | ||
public void disabledInit() { | ||
logger.close(); | ||
timer.stop(); | ||
notif.stop(); | ||
} | ||
|
||
@Override | ||
public void disabledPeriodic() { | ||
// Robot code goes here | ||
// logger.log(); | ||
} | ||
|
||
@Override | ||
|
@@ -209,16 +230,12 @@ public void testPeriodic() { | |
// climber.setPower(operator.getRightY()); // Deadband | ||
// climber.checkClimbingState(); | ||
// } | ||
|
||
logger.log(); | ||
logger.writeLine(); | ||
} | ||
|
||
private void resetLogging() { | ||
logger.open(); | ||
logger.setup(); | ||
|
||
timer.reset(); | ||
timer.start(); | ||
|
||
logger.logAllHeaders(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,13 @@ | ||
package frc.robot.logging; | ||
|
||
/** A class for a loggable subsystem. */ | ||
public interface Loggable { | ||
/** | ||
* Sets up all the keys in the given Logger object. | ||
* | ||
* @param logger Logger class to setup keys in | ||
*/ | ||
public abstract void setupLogging(Logger logger); | ||
/** | ||
* Logs all the headers provided by the Loggable object. | ||
*/ | ||
public abstract void logHeaders(Logger logger); | ||
|
||
/** | ||
* Logs data in the given Logger object. | ||
* | ||
* @param logger Logger class to log data to | ||
*/ | ||
public abstract void log(Logger logger); | ||
} | ||
/** | ||
* Logs all the data provided by the Loggable object. | ||
*/ | ||
public abstract void logData(Logger logger); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This block of commented-out lines of code should be removed.