vision_mate 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/vision_mate/configuration.rb +2 -1
- data/lib/vision_mate/telnet.rb +17 -5
- data/lib/vision_mate/version.rb +1 -1
- data/spec/scanner_integeration_spec.rb +1 -0
- data/spec/vision_mate/telnet_spec.rb +2 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8862e4a3e6fc5d74ed601f4cd4a084b4d49bd684
|
4
|
+
data.tar.gz: be967aa4c5c8319bdfd85a1e91c9533579ee8fa8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1044d370cdaf50827df903e04a806e4e0b4e6a6542534adf73780e06a56704cea10770cf54302a5b53a666364a6a5e8e0f1fd52663c5fe9466c04d4a1bf33492
|
7
|
+
data.tar.gz: e790bffc421236831a23a8508997e3461df7580056fa5200fbc0d191f944f8959adaaa6fe02cc6d4d50e96e96236033db3e98d02a51c5a85991ecb68688854cb
|
data/lib/vision_mate/telnet.rb
CHANGED
@@ -11,7 +11,10 @@ module VisionMate
|
|
11
11
|
class Net::OpenTimeout; end
|
12
12
|
|
13
13
|
def self.connect(host, port, telnet_class = Net::Telnet)
|
14
|
-
|
14
|
+
@telnet_connection ||= telnet_class.new(
|
15
|
+
"Host" => host, "Port" => port, "Timeout" => Configuration.timeout
|
16
|
+
)
|
17
|
+
new(@telnet_connection)
|
15
18
|
rescue Net::OpenTimeout, Timeout::Error
|
16
19
|
raise CouldNotConnect, "Failed to connect to #{host}:#{port}"
|
17
20
|
rescue SocketError
|
@@ -31,19 +34,28 @@ module VisionMate
|
|
31
34
|
end
|
32
35
|
|
33
36
|
def initiate_scan
|
34
|
-
|
37
|
+
telnet_command("S")
|
35
38
|
wait_for_data
|
36
39
|
end
|
37
40
|
|
38
41
|
private
|
39
42
|
|
43
|
+
def telnet_command(string)
|
44
|
+
telnet_connection.cmd("String" => string, "Match" => /OK/)
|
45
|
+
rescue Net::ReadTimeout, Timeout::Error
|
46
|
+
retries ||= 0
|
47
|
+
raise CouldNotConnect, "Telnet command timed out: #{string}" if retries == 5
|
48
|
+
retries += 1
|
49
|
+
retry
|
50
|
+
end
|
51
|
+
|
40
52
|
def wait_for_data
|
41
53
|
sleep 0.1 while scanner_status["finished_scan"]
|
42
54
|
sleep 0.1 until scanner_status["data_ready"]
|
43
55
|
end
|
44
56
|
|
45
57
|
def scanner_status
|
46
|
-
result =
|
58
|
+
result = telnet_command "L"
|
47
59
|
status = strip_prefix(result)
|
48
60
|
status_names = %w{initializing scanning finished_scan data_ready
|
49
61
|
data_sent rack96 empty error}
|
@@ -63,11 +75,11 @@ module VisionMate
|
|
63
75
|
end
|
64
76
|
|
65
77
|
def retrieve_data
|
66
|
-
|
78
|
+
telnet_command "D"
|
67
79
|
end
|
68
80
|
|
69
81
|
def set_scanner_to_manual
|
70
|
-
|
82
|
+
telnet_command "M0"
|
71
83
|
end
|
72
84
|
|
73
85
|
def strip_prefix(string)
|
data/lib/vision_mate/version.rb
CHANGED
@@ -14,6 +14,7 @@ describe "Integrating With a Scanner" do
|
|
14
14
|
.and_return one_tube_string
|
15
15
|
telnet.stub(:cmd).with(hash_including("String" => "L")).and_return("OK37")
|
16
16
|
Net::Telnet.stub new: telnet
|
17
|
+
VisionMate::Telnet.instance_variable_set(:@telnet_connection, nil)
|
17
18
|
end
|
18
19
|
|
19
20
|
it "scans a rack of tubes" do
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require_relative "../../lib/vision_mate/telnet"
|
2
|
+
require_relative "../../lib/vision_mate/configuration"
|
2
3
|
|
3
4
|
class MockTelnet; end
|
4
5
|
|
@@ -6,6 +7,7 @@ describe VisionMate::Telnet do
|
|
6
7
|
subject { VisionMate::Telnet.new(telnet_connection) }
|
7
8
|
let(:uri) { double("uri", host: "192.168.3.132", port: "8000") }
|
8
9
|
let(:telnet_connection) { double "telnet_connection" }
|
10
|
+
before { VisionMate::Telnet.instance_variable_set(:@telnet_connection, nil) }
|
9
11
|
|
10
12
|
describe ".connect" do
|
11
13
|
it "connects to telnet using a host and port" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vision_mate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joe Jackson
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-01-
|
12
|
+
date: 2014-01-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|