Skip to content

Commit

Permalink
Allow for customizing WPILOGWriter flush period
Browse files Browse the repository at this point in the history
  • Loading branch information
mjansen4857 authored and jwbonner committed Nov 8, 2023
1 parent 768261e commit 88c5c78
Showing 1 changed file with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@

/** Records log values to a WPILOG file. */
public class WPILOGWriter implements LogDataReceiver {
private static final double writePeriodSecs = 0.1;
private static final double timestampUpdateDelay = 8.0; // Wait several seconds after DS attached to ensure
// timestamp/timezone is updated

private String folder;
private String filename;
private final String randomIdentifier;
private final double writePeriodSecs;

private boolean autoRename;
private Date logDate;
Expand All @@ -57,8 +57,11 @@ public class WPILOGWriter implements LogDataReceiver {
* @param path Path to log file or folder. If only a folder is provided, the
* filename will be generated based on the current time and match
* number (if applicable).
* @param writePeriodSecs Time between automatic flushes to the disk, in seconds
*/
public WPILOGWriter(String path) {
public WPILOGWriter(String path, double writePeriod) {
writePeriodSecs = writePeriod;

// Create random identifier
Random random = new Random();
StringBuilder randomIdentifierBuilder = new StringBuilder();
Expand All @@ -80,6 +83,17 @@ public WPILOGWriter(String path) {
}
}

/**
* Create a new WPILOGWriter for writing to a ".wpilog" file.
*
* @param path Path to log file or folder. If only a folder is provided, the
* filename will be generated based on the current time and match
* number (if applicable).
*/
public WPILOGWriter(String path){
this(path, 0.1);
}

public void start() {
// Create folder if necessary
File logFolder = new File(folder);
Expand Down

0 comments on commit 88c5c78

Please sign in to comment.