innerken-gmbh / InnerKen-Weekly

这周我们又做了哪些事情呢?
0 stars 0 forks source link

5-17 工作流重大更新,尚未完工的InnerKenDataEntity以及全新的打印机适配 #1

Open juhaodong opened 4 years ago

juhaodong commented 4 years ago

1.更新了InnerKen Utils 1.5版本 npm install innerken-utils

加入了ModelFactory方法,用以重新注册Model。 仿照JPA协议提供了默认的几个接口 原API中需要传入的重复的getList等部分已经被移除 TODO: 使用Entitiy名字自动生成CRUD命令,以及可配置的标准字段名写法

2.为我们的Kasse适配了所有基于ESC/POS类型的打印机,并开放了以下接口 __construct(PrintConnector $connector, CapabilityProfile $profile) Construct new print object.

Parameters:

PrintConnector $connector: The PrintConnector to send data to. CapabilityProfile $profile Supported features of this printer. If not set, the "default" CapabilityProfile will be used, which is suitable for Epson printers. See example/interface/ for ways to open connections for different platforms and interfaces.

barcode($content, $type) Print a barcode.

Parameters:

string $content: The information to encode. int $type: The barcode standard to output. If not specified, Printer::BARCODE_CODE39 will be used. Currently supported barcode standards are (depending on your printer):

BARCODE_UPCA BARCODE_UPCE BARCODE_JAN13 BARCODE_JAN8 BARCODE_CODE39 BARCODE_ITF BARCODE_CODABAR Note that some barcode standards can only encode numbers, so attempting to print non-numeric codes with them may result in strange behaviour.

bitImage(EscposImage $image, $size) See graphics() below.

cut($mode, $lines) Cut the paper.

Parameters:

int $mode: Cut mode, either Printer::CUT_FULL or Printer::CUT_PARTIAL. If not specified, Printer::CUT_FULL will be used. int $lines: Number of lines to feed before cutting. If not specified, 3 will be used. feed($lines) Print and feed line / Print and feed n lines.

Parameters:

int $lines: Number of lines to feed feedForm() Some printers require a form feed to release the paper. On most printers, this command is only useful in page mode, which is not implemented in this driver.

feedReverse($lines) Print and reverse feed n lines.

Parameters:

int $lines: number of lines to feed. If not specified, 1 line will be fed. graphics(EscposImage $image, $size) Print an image to the printer.

Parameters:

EscposImage $img: The image to print. int $size: Output size modifier for the image. Size modifiers are:

IMG_DEFAULT (leave image at original size) IMG_DOUBLE_WIDTH IMG_DOUBLE_HEIGHT A minimal example:

<?php $img = EscposImage::load("logo.png"); $printer -> graphics($img); See the example/ folder for detailed examples.

The function bitImage() takes the same parameters, and can be used if your printer doesn't support the newer graphics commands. As an additional fallback, the bitImageColumnFormat() function is also provided.

initialize() Initialize printer. This resets formatting back to the defaults.

pdf417Code($content, $width, $heightMultiplier, $dataColumnCount, $ec, $options) Print a two-dimensional data code using the PDF417 standard.

Parameters:

string $content: Text or numbers to store in the code number $width: Width of a module (pixel) in the printed code. Default is 3 dots. number $heightMultiplier: Multiplier for height of a module. Default is 3 times the width. number $dataColumnCount: Number of data columns to use. 0 (default) is to auto-calculate. Smaller numbers will result in a narrower code, making larger pixel sizes possible. Larger numbers require smaller pixel sizes. real $ec: Error correction ratio, from 0.01 to 4.00. Default is 0.10 (10%). number $options: Standard code Printer::PDF417_STANDARD with start/end bars, or truncated code Printer::PDF417_TRUNCATED with start bars only. pulse($pin, $on_ms, $off_ms) Generate a pulse, for opening a cash drawer if one is connected. The default settings (0, 120, 240) should open an Epson drawer.

Parameters:

int $pin: 0 or 1, for pin 2 or pin 5 kick-out connector respectively. int $on_ms: pulse ON time, in milliseconds. int $off_ms: pulse OFF time, in milliseconds. qrCode($content, $ec, $size, $model) Print the given data as a QR code on the printer.

string $content: The content of the code. Numeric data will be more efficiently compacted. int $ec Error-correction level to use. One of Printer::QR_ECLEVEL_L (default), Printer::QR_ECLEVEL_M, Printer::QR_ECLEVEL_Q or Printer::QR_ECLEVEL_H. Higher error correction results in a less compact code. int $size: Pixel size to use. Must be 1-16 (default 3) int $model: QR code model to use. Must be one of Printer::QR_MODEL_1, Printer::QR_MODEL_2 (default) or Printer::QR_MICRO (not supported by all printers). selectPrintMode($mode) Select print mode(s).

Parameters:

int $mode: The mode to use. Default is Printer::MODE_FONTA, with no special formatting. This has a similar effect to running initialize(). Several MODE* constants can be OR'd together passed to this function's $mode argument. The valid modes are:

MODE_FONT_A MODE_FONT_B MODE_EMPHASIZED MODE_DOUBLE_HEIGHT MODE_DOUBLE_WIDTH MODE_UNDERLINE setBarcodeHeight($height) Set barcode height.

Parameters:

int $height: Height in dots. If not specified, 8 will be used. setBarcodeWidth($width) Set barcode bar width.

Parameters:

int $width: Bar width in dots. If not specified, 3 will be used. Values above 6 appear to have no effect. setColor($color) Select print color - on printers that support multiple colors.

Parameters:

int $color: Color to use. Must be either Printer::COLOR_1 (default), or Printer::COLOR_2 setDoubleStrike($on) Turn double-strike mode on/off.

Parameters:

boolean $on: true for double strike, false for no double strike. setEmphasis($on) Turn emphasized mode on/off.

Parameters:

boolean $on: true for emphasis, false for no emphasis. setFont($font) Select font. Most printers have two fonts (Fonts A and B), and some have a third (Font C).

Parameters:

int $font: The font to use. Must be either Printer::FONT_A, Printer::FONT_B, or Printer::FONT_C. setJustification($justification) Select justification.

Parameters:

int $justification: One of Printer::JUSTIFY_LEFT, Printer::JUSTIFY_CENTER, or Printer::JUSTIFY_RIGHT. setLineSpacing($height) Set the height of the line.

Some printers will allow you to overlap lines with a smaller line feed.

Parameters:

int $height: The height of each line, in dots. If not set, the printer will reset to its default line spacing. setPrintLeftMargin($margin) Set print area left margin. Reset to default with Printer::initialize().

Parameters:

int $margin: The left margin to set on to the print area, in dots. setPrintWidth($width) Set print area width. This can be used to add a right margin to the print area. Reset to default with Printer::initialize().

Parameters:

int $width: The width of the page print area, in dots. setReverseColors($on) Set black/white reverse mode on or off. In this mode, text is printed white on a black background.

Parameters:

boolean $on: True to enable, false to disable. setTextSize($widthMultiplier, $heightMultiplier) Set the size of text, as a multiple of the normal size.

Parameters:

int $widthMultiplier: Multiple of the regular height to use (range 1 - 8). int $heightMultiplier: Multiple of the regular height to use (range 1 - 8). setUnderline($underline) Set underline for printed text.

Parameters:

int $underline: Either true/false, or one of Printer::UNDERLINE_NONE, Printer::UNDERLINE_SINGLE or Printer::UNDERLINE_DOUBLE. Defaults to Printer::UNDERLINE_SINGLE. text($str) Add text to the buffer. Text should either be followed by a line-break, or feed() should be called after this.

Parameters:

string $str: The string to print.