Class: Device::Printer
- Inherits:
-
Object
- Object
- Device::Printer
- Defined in:
- lib/device/printer.rb
Constant Summary collapse
- RET_OK =
0- ERR_PRN_BUSY =
Printer busy
-3701 # Printer busy
- ERR_PRN_PAPEROUT =
Out of paper
-3702 # Out of paper
- ERR_PRN_WRONG_PACKAGE =
The format of print data packet error
-3703 # The format of print data packet error
- ERR_PRN_OVERHEAT =
Printer over heating
-3704 # Printer over heating
- ERR_PRN_OUTOFMEMORY =
The print data is too large, and exceeds the buffer length.
-3705 # The print data is too large, and exceeds the buffer length.
- ERR_PRN_OVERVOLTAGE =
Voltage is too high.
-3706 # Voltage is too high.
- ERR_INVALID_PARAM =
Invalid parameter.
-1003 # Invalid parameter.
- ERR_DEV_NOT_EXIST =
Device does not exist.
-1004 # Device does not exist.
- ERR_DEV_BUSY =
Device is busy.
-1005 # Device is busy.
- ERR_FONT_NOT_EXIST =
Font does not exist.
-1008 # Font does not exist.
- DEFAULT_SINGLE_WIDTH =
12- DEFAULT_SINGLE_HEIGHT =
24- DEFAULT_MULTI_WIDTH =
24- DEFAULT_MULTI_HEIGHT =
24
Class Method Summary collapse
- .adapter ⇒ Object
-
.check ⇒ Fixnum
Check printer status, useful for paper check.
-
.close ⇒ NilClass
Closes the printer.
-
.font=(path) ⇒ Fixnum
Selects print font.
-
.level=(value) ⇒ NilClass
Sets printing gray level.
-
.open ⇒ Fixnum
Check printer status, useful for paper check.
-
.paper? ⇒ TrueClass, FalseClass
Check if printer has paper.
-
.paperfeed ⇒ NilClass
Feeds printing paper.
-
.print(string) ⇒ NilClass
Write text on print buffer.
-
.print_big(string) ⇒ NilClass
Write text on print buffer changing the size only for this print.
-
.print_bmp(path) ⇒ NilClass
Print bmp file.
-
.puts(string) ⇒ NilClass
Write text on print buffer.
-
.reset ⇒ NilClass
Restore the printer default settings and clear the print buffer data.
-
.size(singlecode_width = DEFAULT_SINGLE_WIDTH, singlecode_height = DEFAULT_SINGLE_HEIGHT, multicode_width = DEFAULT_MULTI_WIDTH, multicode_height = DEFAULT_MULTI_HEIGHT) ⇒ NilClass
Define size, in pixel, of printing.
-
.start(singlecode_width = DEFAULT_SINGLE_WIDTH, singlecode_height = DEFAULT_SINGLE_HEIGHT, multicode_width = DEFAULT_MULTI_WIDTH, multicode_height = DEFAULT_MULTI_HEIGHT) ⇒ Fixnum
Initialize Printer device.
Class Method Details
.adapter ⇒ Object
21 22 23 |
# File 'lib/device/printer.rb', line 21 def self.adapter Device.adapter::Printer end |
.check ⇒ Fixnum
Check printer status, useful for paper check.
182 183 184 |
# File 'lib/device/printer.rb', line 182 def self.check self._check end |
.close ⇒ NilClass
Closes the printer.
70 71 72 |
# File 'lib/device/printer.rb', line 70 def self.close self.adapter.close end |
.font=(path) ⇒ Fixnum
Selects print font.
81 82 83 |
# File 'lib/device/printer.rb', line 81 def self.font=(path) self.adapter.font = path end |
.level=(value) ⇒ NilClass
Sets printing gray level.
Level =0, reserved, Level =1, default level, normal print slip, Level =2, reserved, Level =3, two-layer thermal printing, Level =4, two-layer thermal printing, higher gray level than 3, The default level is 1. The illegal value does not change current settings.
98 99 100 |
# File 'lib/device/printer.rb', line 98 def self.level=(value) self.adapter.level = value end |
.open ⇒ Fixnum
Check printer status, useful for paper check.
56 57 58 |
# File 'lib/device/printer.rb', line 56 def self.open self.adapter.open end |
.paper? ⇒ TrueClass, FalseClass
Check if printer has paper
190 191 192 193 194 195 196 |
# File 'lib/device/printer.rb', line 190 def self.paper? if self.check == ERR_PRN_PAPEROUT false else true end end |
.paperfeed ⇒ NilClass
Feeds printing paper.
125 126 127 |
# File 'lib/device/printer.rb', line 125 def self.paperfeed self.adapter.feed end |
.print(string) ⇒ NilClass
Write text on print buffer.
134 135 136 |
# File 'lib/device/printer.rb', line 134 def self.print(string) self.adapter.print(string) end |
.print_big(string) ⇒ NilClass
Write text on print buffer changing the size only for this print.
Big size is (24, 64, 64, 64)
153 154 155 156 157 |
# File 'lib/device/printer.rb', line 153 def self.print_big(string) size(24, 48, 48, 48) self.adapter.print(string) size end |
.print_bmp(path) ⇒ NilClass
Print bmp file.
Details: Bitmap data is generated as monochromatic, bmp format. Printing bitmap size limit up to 384 pixels in width, spocket with 180 pixels and the height is unlimited. If the bitmap width is larger than the limit of the printer, then it will be sliced on the right side. If the data packet is too long, then this function will remove the LOGO message.
170 171 172 |
# File 'lib/device/printer.rb', line 170 def self.print_bmp(path) self.adapter.print_bmp(path) end |
.puts(string) ⇒ NilClass
Write text on print buffer.
143 144 145 |
# File 'lib/device/printer.rb', line 143 def self.puts(string) self.adapter.puts(string) end |
.reset ⇒ NilClass
Restore the printer default settings and clear the print buffer data.
63 64 65 |
# File 'lib/device/printer.rb', line 63 def self.reset self.adapter.reset end |
.size(singlecode_width = DEFAULT_SINGLE_WIDTH, singlecode_height = DEFAULT_SINGLE_HEIGHT, multicode_width = DEFAULT_MULTI_WIDTH, multicode_height = DEFAULT_MULTI_HEIGHT) ⇒ NilClass
Define size, in pixel, of printing
(For non-monospaced font, width of each character may not meet the settings).
The value ranges from 8 to 64.
115 116 117 118 119 120 |
# File 'lib/device/printer.rb', line 115 def self.size(singlecode_width=DEFAULT_SINGLE_WIDTH, singlecode_height=DEFAULT_SINGLE_HEIGHT, multicode_width=DEFAULT_MULTI_WIDTH, multicode_height=DEFAULT_MULTI_HEIGHT) self.adapter.size(singlecode_width, singlecode_height, multicode_width, multicode_height) end |
.start(singlecode_width = DEFAULT_SINGLE_WIDTH, singlecode_height = DEFAULT_SINGLE_HEIGHT, multicode_width = DEFAULT_MULTI_WIDTH, multicode_height = DEFAULT_MULTI_HEIGHT) ⇒ Fixnum
Initialize Printer device.
42 43 44 45 46 47 |
# File 'lib/device/printer.rb', line 42 def self.start(singlecode_width=DEFAULT_SINGLE_WIDTH, singlecode_height=DEFAULT_SINGLE_HEIGHT, multicode_width=DEFAULT_MULTI_WIDTH, multicode_height=DEFAULT_MULTI_HEIGHT) self.adapter.start(singlecode_width, singlecode_height, multicode_width, multicode_height) end |