Skip to content
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

Enhancements for image scanning #29

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scanline Tests/ScanConfigurationTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#import <XCTest/XCTest.h>

#import "ScanConfiguration.h"
#import "../scanline/ScanConfiguration.h"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this should be necessary. If I revert it back to #import "ScanConfiguration.h", I'm able to run the tests. Although I also had to remove the app source files from the test target, which they shouldn't have been in. Maybe that was the issue here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. When I revert the change I get 'ScanConfiguration.h' file not found. Removing the source files from CompileSources of the Test target unfortunately does not fix things for me:
image
image

However I'm not very familiar with XCode nor the Swift build system. Any ideas?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was able to get it to work by doing the following:

  1. Change to #import "ScanConfiguration.h" in ScanConfigurationTests.m
  2. Remove everything except ScanConfigurationTests.m and ScanConfiguration.m from the Compile Sources step
  3. Remove #import "scanline-Swift.h" from ScanConfiguration.m

It's not ideal -- we shouldn't need any of the app source files in the test target -- but I'm not sure what the issue is right now with that.


@interface ScanConfigurationTests : XCTestCase

Expand Down
6 changes: 3 additions & 3 deletions scanline/ScannerController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class ScannerController: NSObject, ICScannerDeviceDelegate {
guard error == nil else {
logger.log("Error received while attempting to open a session with the scanner.")
delegate?.scannerControllerDidFail(self)
return
exit(1)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In a batch scan, would this change the current behavior? Wondering if there's an issue where you're scanning several items in a batch and then one of them fails -- would it exit now instead of bailing on that particular item and continuing on?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point! I haven't thought of that use case. I just found it confusing that the command did not exit when encountering an error. Instead it kept running forever. To be safe I added a fallback to return for the batch scan case now.

}
}

Expand All @@ -76,7 +76,7 @@ class ScannerController: NSObject, ICScannerDeviceDelegate {
// NOTE: Despite the fact that `functionalUnit` is not an optional, it still sometimes comes in as `nil` even when `error` is `nil`
if functionalUnit != nil && functionalUnit.type == self.desiredFunctionalUnitType {
configureScanner()
logger.log("Starting scan...")
logger.verbose("Starting scan...")
scanner.requestScan()
}
}
Expand All @@ -93,7 +93,7 @@ class ScannerController: NSObject, ICScannerDeviceDelegate {
guard error == nil else {
logger.log("ERROR: \(error!.localizedDescription)")
delegate?.scannerControllerDidFail(self)
return
exit(1)
}

if self.configuration.batchScan {
Expand Down
2 changes: 0 additions & 2 deletions scanline/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,3 @@ let appController = ScanlineAppController(arguments: CommandLine.arguments)
appController.go()

CFRunLoopRun()

print("Done")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious why this was removed...

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For my taste this was just too verbose. I would expect a terminal command to just do it's job and exit with 0 exit code when it is done. Exit code != 0 for failures and according error message on stderr when something failed.

Or is there some use case for it that I am missing?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough...