-
Notifications
You must be signed in to change notification settings - Fork 109
[V2] Add operation to save image snapshots to local disk. #599
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
[V2] Add operation to save image snapshots to local disk. #599
Conversation
The period and path prefix and suffix can be set, and the operation enabled and disabled at will (this is particularly useful in combination with PR WPIRoboticsProjects#572).
|
|
||
| if (!inputSocket.getValue().isPresent()) { | ||
| throw new IllegalArgumentException("Input image must not be empty"); | ||
| } |
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 isn't necessary.
Step does this already.
Current coverage is 58.78%
@@ master #599 diff @@
==========================================
Files 191 194 +3
Lines 5963 6041 +78
Methods 0 0
Messages 0 0
Branches 553 556 +3
==========================================
+ Hits 3508 3551 +43
- Misses 2293 2330 +37
+ Partials 162 160 -2
|
6843281 to
7648094
Compare
7648094 to
aae316c
Compare
| } | ||
|
|
||
| final Handler fileHandler = new FileHandler("%h/GRIP.log");//Log to the file "GRIPlogger.log" | ||
| final Handler fileHandler = new FileHandler("%t/GRIP.log");//Log to the file "GRIPlogger.log" |
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.
Why are you changing the log file directory?
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.
Never actually finished what I was doing... Going to move the log file into the GRIP directory.
| } | ||
|
|
||
| // don't save new image until period expires | ||
| if (stopwatch.elapsed(TimeUnit.NANOSECONDS) < periodSocket.getValue().get().doubleValue()*1000000000L) { |
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.
Why are you using nanoseconds? There's no real point if the file name has only millisecond precision.
c3fbe67 to
c73500b
Compare
c73500b to
b352d9a
Compare
98aa692 to
cfbe494
Compare
|
@SamCarlberg @JLLeitschuh I added the filetype selector. The only issue is that the quality slider does not do anything when png is selected (this is intentional). Do we care that it will not do anything? |
| logger.log(Level.WARNING, ex.getMessage(), ex); | ||
| } | ||
| }; | ||
| new Thread(runnable).start(); |
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.
Make this a daemon thread otherwise it won't die when the application tries to shut down.
This is especially important if the file writing hangs.
586e9cf to
3dbb57c
Compare
|
This PR is ready for review/merge |
|
LGTM |
| activeSocket = operation.getInputSockets().stream().filter( | ||
| o -> o.getSocketHint().getIdentifier().equals("Active") | ||
| && o.getSocketHint().getType().equals(Boolean.class)).findFirst().get(); | ||
| } |
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.
Do you really need dependency injection for this?? There is a MockInputSocketFactory and a MockOutputSocketFactory you can use.
Also, why are you using a real file manager in a test? I really don't want tests writing to the file system.
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.
I don't believe I am using a real FileManager. I will remove the injection
| IMAGE_DIRECTORY.mkdirs(); // If the user deletes the directory | ||
| Files.write(image, file); | ||
| } catch (IOException ex) { | ||
| logger.log(Level.WARNING, ex.getMessage(), ex); |
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.
Why does this not pass the exception up to the caller?
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.
At this point it is in a different thread. How could I handle that?
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.
Oh, I suppose this doesn't make sense.
Closes #573
This PR is a continuation of #573