extface 0.1.8 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fc59569d61b550e245d115c0542d9803bc9ded4c
|
4
|
+
data.tar.gz: 16607248a89cc5776e47a9145eed8a4a68389509
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 981cd2238ba9611ea66f5375af2e34d4f33272bdc303109910e8407c979c59946881a17c234150b2275ad878e0b77df4104a6abf52b3ca6a4722870e9af3b700
|
7
|
+
data.tar.gz: a11e17b3b21d4600915fc7181898258a0eb28961da58d5c0bffaeb8b0d571e0819fca358037a90f573e61bbe5e0e03a6d26e3aa3f135dbd578896646e07fd538
|
@@ -21,7 +21,7 @@ module Extface
|
|
21
21
|
ensure
|
22
22
|
response.stream.close
|
23
23
|
end
|
24
|
-
|
24
|
+
|
25
25
|
def push
|
26
26
|
# get request.body.read
|
27
27
|
# if it is push message, process it
|
@@ -35,10 +35,10 @@ module Extface
|
|
35
35
|
end
|
36
36
|
if bytes_porcessed = device.driver.handle(@full_buffer.b)
|
37
37
|
Extface.redis_block do |r|
|
38
|
-
r.set device.uuid,
|
38
|
+
r.set device.uuid, @full_buffer.b[bytes_porcessed..-1]
|
39
39
|
end
|
40
40
|
end
|
41
|
-
stream_job # stream right now :)
|
41
|
+
#stream_job # stream right now :)
|
42
42
|
status = :ok
|
43
43
|
end
|
44
44
|
rescue => e
|
@@ -23,7 +23,7 @@ module Extface
|
|
23
23
|
FISCAL = true #cash registers, fiscal printers
|
24
24
|
REPORT = false #only transmit data that must be parsed by handler, CDR, report devices
|
25
25
|
|
26
|
-
RESPONSE_TIMEOUT =
|
26
|
+
RESPONSE_TIMEOUT = 3 #seconds
|
27
27
|
INVALID_FRAME_RETRIES = 6 #seconds
|
28
28
|
|
29
29
|
TAX_GROUPS_MAP = {
|
@@ -53,7 +53,6 @@ module Extface
|
|
53
53
|
return 0 #no bytes processed
|
54
54
|
end
|
55
55
|
end
|
56
|
-
return buffer.length
|
57
56
|
end
|
58
57
|
|
59
58
|
def autocut(partial = true) # return "P" - success, "F" - failed
|
@@ -70,7 +69,7 @@ module Extface
|
|
70
69
|
s.fsend Sales::PRINT_NON_FISCAL_TEXT, "********************************"
|
71
70
|
s.fsend Printer::MOVE, "1"
|
72
71
|
s.fsend Sales::PRINT_NON_FISCAL_TEXT, "Driver: " + "#{self.class::NAME}".truncate(24)
|
73
|
-
s.fsend
|
72
|
+
s.fsend Sales::END_NON_FISCAL_DOC
|
74
73
|
s.notify "Printing finished"
|
75
74
|
end
|
76
75
|
end
|
@@ -97,7 +96,7 @@ module Extface
|
|
97
96
|
def sale_and_pay_items_session(items = [], operator = "1", password = "1")
|
98
97
|
device.session("Fiscal Doc") do |s|
|
99
98
|
s.notify "Fiscal Doc Start"
|
100
|
-
s.fsend Sales::START_FISCAL_DOC, "#{operator},#{password},00001"
|
99
|
+
s.fsend Sales::START_FISCAL_DOC, "#{operator || "1"},#{password || "1"},00001"
|
101
100
|
items.each do |item|
|
102
101
|
s.fsend Sales::SALE_AND_SHOW, build_sale_data(item[:price], item[:text1], item[:text2], item[:tax_group], item[:qty], item[:percent], item[:neto])
|
103
102
|
end
|
@@ -185,7 +184,7 @@ module Extface
|
|
185
184
|
end
|
186
185
|
end
|
187
186
|
|
188
|
-
|
187
|
+
private
|
189
188
|
def bcc(buffer)
|
190
189
|
sum = 0
|
191
190
|
buffer.each_byte do |byte|
|
@@ -264,15 +263,17 @@ module Extface
|
|
264
263
|
attr_reader :frame, :len, :seq, :cmd, :data, :status, :bcc
|
265
264
|
|
266
265
|
validates_presence_of :frame
|
267
|
-
|
268
|
-
|
266
|
+
validate :bcc_validation
|
267
|
+
validate :len_validation
|
269
268
|
|
270
269
|
def initialize(buffer)
|
271
270
|
# test Extface::Driver::DaisyFx1200::RespFrame.new("\x16\x16\x01\x2c\x20\x2dP\x04SSSSSS\x05\BBBB\x03")
|
272
271
|
# LEN SEQ CMD DATA STATUS BCC
|
273
272
|
if match = buffer.match(/\x01(.{1})(.{1})(.{1})(.*)\x04(.{6})\x05(.{4})\x03/n)
|
274
|
-
@frame = match.
|
273
|
+
@frame = match.to_a.first
|
275
274
|
@len, @seq, @cmd, @data, @status, @bcc = match.captures
|
275
|
+
else
|
276
|
+
#TODO look for NAK
|
276
277
|
end
|
277
278
|
end
|
278
279
|
|
@@ -42,6 +42,16 @@ module Extface
|
|
42
42
|
OPEN_DRAWER_1 = 0x7b
|
43
43
|
OPEN_DRAWER_2 = 0x7c
|
44
44
|
end
|
45
|
+
|
46
|
+
def handle(buffer)
|
47
|
+
bytes_processed = 0
|
48
|
+
if frame_match = buffer.match(/\x02.*\x03.{4}/n)
|
49
|
+
frame_data = frame_match.to_s
|
50
|
+
rpush frame_data
|
51
|
+
bytes_processed = frame_match.pre_match.length + frame_data.length
|
52
|
+
end
|
53
|
+
return bytes_processed
|
54
|
+
end
|
45
55
|
|
46
56
|
def build_packet(cmd, fields = [])
|
47
57
|
String.new.tap() do |frame|
|
@@ -71,6 +81,19 @@ module Extface
|
|
71
81
|
@seq += 1 if increment
|
72
82
|
@seq = 0x20 if @seq == 0x7f
|
73
83
|
@seq
|
74
|
-
end
|
84
|
+
end
|
85
|
+
|
86
|
+
class Frame
|
87
|
+
include ActiveModel::Validations
|
88
|
+
attr_reader :frame, :seq, :cmd, :fields_data, :fields, :bcc
|
89
|
+
|
90
|
+
def initialize(buffer)
|
91
|
+
if match = buffer.match(/\x02([\x20-\x7F])([\x30-\xaf])\x1c(.*)\x03(.{4})/n)
|
92
|
+
@frame = match.to_a.first
|
93
|
+
@seq, @cmd, @fileds_data, @bcc = match.captures
|
94
|
+
@fields = @fields_data.split("\x1c")
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
75
98
|
end
|
76
99
|
end
|
data/lib/extface/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: extface
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Vangelov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-05-
|
11
|
+
date: 2014-05-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|