smartware 0.1.30 → 0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/smartware +10 -3
- data/config/smartware.yml.sample +10 -0
- data/lib/smartware.rb +19 -0
- data/lib/smartware/clients/printer.rb +8 -2
- data/lib/smartware/clients/watchdog.rb +36 -0
- data/lib/smartware/connection_monitor.rb +25 -0
- data/lib/smartware/drivers/cash_acceptor/ccnet.rb +28 -24
- data/lib/smartware/drivers/cash_acceptor/dummy.rb +3 -3
- data/lib/smartware/drivers/modem/dummy.rb +2 -2
- data/lib/smartware/drivers/modem/standard.rb +3 -3
- data/lib/smartware/drivers/printer/dummy.rb +16 -5
- data/lib/smartware/drivers/printer/esc_pos.rb +272 -0
- data/lib/smartware/drivers/watchdog/dummy.rb +29 -0
- data/lib/smartware/drivers/watchdog/watchdog_daemon.rb +40 -0
- data/lib/smartware/interfaces/cash_acceptor.rb +154 -109
- data/lib/smartware/interfaces/interface.rb +47 -0
- data/lib/smartware/interfaces/modem.rb +29 -58
- data/lib/smartware/interfaces/printer.rb +78 -60
- data/lib/smartware/interfaces/watchdog.rb +26 -0
- data/lib/smartware/process_manager.rb +40 -0
- data/lib/smartware/service.rb +26 -70
- data/lib/smartware/version.rb +1 -1
- data/smartware.gemspec +3 -1
- metadata +44 -4
- data/lib/smartware/drivers/printer/tg24xx.rb +0 -64
@@ -1,64 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
#
|
3
|
-
# Custom tg2480h printer functions
|
4
|
-
#
|
5
|
-
|
6
|
-
require 'serialport'
|
7
|
-
|
8
|
-
module Smartware
|
9
|
-
module Driver
|
10
|
-
module Printer
|
11
|
-
|
12
|
-
class TG24XX
|
13
|
-
|
14
|
-
def initialize(port)
|
15
|
-
@sp = SerialPort.new(port, 115200, 8, 1, SerialPort::NONE)
|
16
|
-
@sp.read_timeout = 100
|
17
|
-
end
|
18
|
-
|
19
|
-
def error
|
20
|
-
res = send "\x1Dr1"
|
21
|
-
return "1" unless res # No answer
|
22
|
-
return "" if res == "0" # No error
|
23
|
-
return "2" if res == "f" # Paper not present
|
24
|
-
return "3" if res == "3" # Paper near end
|
25
|
-
rescue
|
26
|
-
-1
|
27
|
-
end
|
28
|
-
|
29
|
-
def model
|
30
|
-
model_code = send "\x1DI1"
|
31
|
-
model_name = case model_code
|
32
|
-
when "a7" then 'Custom TG2460H'
|
33
|
-
when "a8" then 'Custom TG2480H'
|
34
|
-
when "ac" then 'Custom TL80'
|
35
|
-
when "ad" then 'Custom TL60'
|
36
|
-
else 'Unknown printer'
|
37
|
-
end
|
38
|
-
model_name
|
39
|
-
rescue
|
40
|
-
-1
|
41
|
-
end
|
42
|
-
|
43
|
-
def version
|
44
|
-
send "\x1DI3", false
|
45
|
-
end
|
46
|
-
|
47
|
-
private
|
48
|
-
def send(message, parse_answer = true)
|
49
|
-
@sp.write message
|
50
|
-
ans = @sp.gets
|
51
|
-
if ans
|
52
|
-
parse_answer ? res = ans.unpack("C*").map{|e| e.to_s(16) } : res = ans
|
53
|
-
else
|
54
|
-
res = nil
|
55
|
-
end
|
56
|
-
res.is_a?(Array) ? res[0] : res
|
57
|
-
end
|
58
|
-
|
59
|
-
end
|
60
|
-
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|