ASP NET, NET Framework, MONO, SQL, Visual Studio | Professional Programs | Программист Еремин В.В.
(Terminal) Terminal (2010)

OpenSource драйвер терминального принтера Custom VKP80 для Windows и Linux

Мой драйвер дает низкоуровневую обвязку 87 функций чекового терминального принтера Custom VKP80. При этом в этой версии мне были не нужны и остались нереализованными в связи со сжатыми сроками разработки всего пять операций принтера.

Драйвер позволяет работать с термопринтером VKP80 в основном не обращаясь к документации на принтер, а пользуясь непосредственно Intellisense-подсказкой Visual Studio.Это переносимый код, пригодный для использования в Windows и Linux по технологии MONO.

На этом уровне не реализована также подробная обработка статусов принтера - байты статуса вам придется обработать самостоятельно в вышестоящем классе, наследующем эту низкоуровневую обвязку примерно так:


   1:   Public Class VKP80_Status
   2:          Inherits VKP80_CMD
   3:   
   4:   Public Enum VKP80_Status
   5:          PaperEnd = &H10
   6:          ....
   7:      End Enum
   8:   
   9:      Dim Stat1() As Byte = VKP80_CMD.CMDstatus_Transmit_status(1)
  10:      If Stat1(0) Xor VKP80_Status.PaperEnd Then
  11:          ....

Возможно, я в будущем опубликую версию с оставшимися пятью командами и обработкой состояния сенсоров принтера и статусов принтера.

   1:  Public Class VKP80_CMD
   2:      Inherits Port
   3:   
   4:      ''' <summary>
   5:      ''' Печать строки с русскими буквами на принтере с русской прошивкой
   6:      ''' </summary>
   7:      Public Shared Sub WriteString(ByVal Str1 As String)
   8:          Dim Buf(Str1.Length) As Byte
   9:          Dim ASCII As New Text.ASCIIEncoding
  10:          For i = 0 To Str1.Length - 1
  11:              Select Case Str1.Substring(i, 1)
  12:                  Case "А" : Buf(i) = &H80
  13:                  Case "Б" : Buf(i) = &H81
  14:                  Case "В" : Buf(i) = &H82
  15:                  Case "Г" : Buf(i) = &H83
  16:                  Case "Д" : Buf(i) = &H84
  17:                  Case "Е" : Buf(i) = &H85
  18:                  Case "Ж" : Buf(i) = &H86
  19:                  Case "З" : Buf(i) = &H87
  20:                  Case "И" : Buf(i) = &H88
  21:                  Case "Й" : Buf(i) = &H89
  22:                  Case "К" : Buf(i) = &H8A
  23:                  Case "Л" : Buf(i) = &H8B
  24:                  Case "М" : Buf(i) = &H8C
  25:                  Case "Н" : Buf(i) = &H8D
  26:                  Case "О" : Buf(i) = &H8E
  27:                  Case "П" : Buf(i) = &H8F
  28:                  Case "Р" : Buf(i) = &H90
  29:                  Case "С" : Buf(i) = &H91
  30:                  Case "Т" : Buf(i) = &H92
  31:                  Case "У" : Buf(i) = &H93
  32:                  Case "Ф" : Buf(i) = &H94
  33:                  Case "Х" : Buf(i) = &H95
  34:                  Case "Ц" : Buf(i) = &H96
  35:                  Case "Ч" : Buf(i) = &H97
  36:                  Case "Ш" : Buf(i) = &H98
  37:                  Case "Щ" : Buf(i) = &H99
  38:                  Case "Ъ" : Buf(i) = &H9A
  39:                  Case "Ы" : Buf(i) = &H9B
  40:                  Case "Ь" : Buf(i) = &H9C
  41:                  Case "Э" : Buf(i) = &H9D
  42:                  Case "Ю" : Buf(i) = &H9E
  43:                  Case "Я" : Buf(i) = &H9F
  44:                  Case "а" : Buf(i) = &HA0
  45:                  Case "б" : Buf(i) = &HA1
  46:                  Case "в" : Buf(i) = &HA2
  47:                  Case "г" : Buf(i) = &HA3
  48:                  Case "д" : Buf(i) = &HA4
  49:                  Case "е" : Buf(i) = &HA5
  50:                  Case "ж" : Buf(i) = &HA6
  51:                  Case "з" : Buf(i) = &HA7
  52:                  Case "и" : Buf(i) = &HA8
  53:                  Case "й" : Buf(i) = &HA9
  54:                  Case "к" : Buf(i) = &HAA
  55:                  Case "л" : Buf(i) = &HAB
  56:                  Case "м" : Buf(i) = &HAC
  57:                  Case "н" : Buf(i) = &HAD
  58:                  Case "о" : Buf(i) = &HAE
  59:                  Case "п" : Buf(i) = &HAF
  60:                  Case "р" : Buf(i) = &HE0
  61:                  Case "с" : Buf(i) = &HE1
  62:                  Case "т" : Buf(i) = &HE2
  63:                  Case "у" : Buf(i) = &HE3
  64:                  Case "ф" : Buf(i) = &HE4
  65:                  Case "х" : Buf(i) = &HE5
  66:                  Case "ц" : Buf(i) = &HE6
  67:                  Case "ч" : Buf(i) = &HE7
  68:                  Case "ш" : Buf(i) = &HE8
  69:                  Case "щ" : Buf(i) = &HE9
  70:                  Case "ъ" : Buf(i) = &HEA
  71:                  Case "ы" : Buf(i) = &HEB
  72:                  Case "ь" : Buf(i) = &HEC
  73:                  Case "э" : Buf(i) = &HED
  74:                  Case "ю" : Buf(i) = &HEE
  75:                  Case "я" : Buf(i) = &HEF
  76:                  Case "Ё" : Buf(i) = &HF0
  77:                  Case "ё" : Buf(i) = &HF1
  78:                  Case Else
  79:                      Buf(i) = ASCII.GetBytes(Str1.Substring(i))(0)
  80:              End Select
  81:          Next
  82:          Port.Write(Buf)
  83:      End Sub
  84:   
  85:      Private Shared Function ReadStatus() As Byte()
  86:          Dim I As Integer
  87:          Dim Y() As Byte = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
  88:          For i = 0 To Y.Length - 1
  89:              Y(i) = 0
  90:          Next
  91:          For I = 0 To Y.Length - 1
  92:              'ключевое местечко - время задержки подобрано опытным путем
  93:              System.Threading.Thread.Sleep(100)
  94:              If ComPort.BytesToRead > 0 Then
  95:                  Y(I) = CByte(ComPort.ReadByte)
  96:              Else
  97:                  Exit For
  98:              End If
  99:          Next
 100:          ReDim Preserve Y(I - 1)
 101:          Return Y
 102:      End Function
 103:   
 104:      Public Shared Function GetPrinterStatus() As String
 105:          Dim Str1 As New Text.StringBuilder
 106:          Str1.AppendLine("VKP80II State  :")
 107:          Str1.AppendLine("----------------------------------------")
 108:          Str1.AppendLine("FullStatus     : " & VKP80_CMD.ByteToString(VKP80_CMD.CMDSTATUS_Realtime_status_transmission(VKP80_CMD.RequestType.FullStatus)))
 109:          Str1.AppendLine("ErrorStatus    : " & VKP80_CMD.ByteToString(VKP80_CMD.CMDSTATUS_Realtime_status_transmission(VKP80_CMD.RequestType.ErrorStatus)))
 110:          Str1.AppendLine("PrinterStatus  : " & VKP80_CMD.ByteToString(VKP80_CMD.CMDSTATUS_Realtime_status_transmission(VKP80_CMD.RequestType.PrinterStatus)))
 111:          Str1.AppendLine("PrintStatus    : " & VKP80_CMD.ByteToString(VKP80_CMD.CMDSTATUS_Realtime_status_transmission(VKP80_CMD.RequestType.PrintStatus)))
 112:          Str1.AppendLine("OfflineStatus  : " & VKP80_CMD.ByteToString(VKP80_CMD.CMDSTATUS_Realtime_status_transmission(VKP80_CMD.RequestType.OfflineStatus)))
 113:          Str1.AppendLine("RollSensor     : " & VKP80_CMD.ByteToString(VKP80_CMD.CMDSTATUS_Realtime_status_transmission(VKP80_CMD.RequestType.PaperRollSensorStatus)))
 114:          Str1.AppendLine("EjectorSensor  : " & VKP80_CMD.ByteToString(VKP80_CMD.CMDSTATUS_Ejector_commands(6)))
 115:          Str1.AppendLine("PaperEndSensor : " & VKP80_CMD.ByteToString(VKP80_CMD.CMDSTATUS_Transmit_status(1)))
 116:          Str1.AppendLine("PrinterID1     : " & VKP80_CMD.ByteToString(VKP80_CMD.CMDSTATUS_Transmit_printer_ID(1)))
 117:          Str1.AppendLine("PrinterID2     : " & VKP80_CMD.ByteToString(VKP80_CMD.CMDSTATUS_Transmit_printer_ID(2)))
 118:          Str1.AppendLine("PrinterID3     : " & VKP80_CMD.ByteToString(VKP80_CMD.CMDSTATUS_Transmit_printer_ID(3)))
 119:          Str1.AppendLine("Cuts           : " & VKP80_CMD.ByteToString(VKP80_CMD.CMDSTATUS_Reading_number_of_cuts_performed_from_the_printer))
 120:          Str1.AppendLine("PowerUp        : " & VKP80_CMD.ByteToString(VKP80_CMD.CMDSTATUS_Reading_number_of_power_up))
 121:          Str1.AppendLine("Retracting     : " & VKP80_CMD.ByteToString(VKP80_CMD.CMDSTATUS_Reading_number_of_retracting))
 122:          Str1.AppendLine("PaperLength1   : " & VKP80_CMD.ByteToString(VKP80_CMD.CMDSTATUS_Reading_of_length_cm_of_printed_paper))
 123:          Str1.AppendLine("PaperLength2   : " & VKP80_CMD.ByteToString(VKP80_CMD.CMDSTATUS_Reading_of_length_paper_cm_available_before_virtual_paper_end))
 124:          Str1.AppendLine("----------------------------------------")
 125:          Return Str1.ToString
 126:      End Function
 127:   
 128:      Public Overloads Shared Function GetPortStatus() As String
 129:          Dim Str1 As New Text.StringBuilder
 130:          Str1.AppendLine(ComPort.PortName & " State  :")
 131:          Str1.AppendLine("----------------------------------------")
 132:          Str1.AppendLine("IsOpen                : " & ComPort.IsOpen)
 133:          Str1.AppendLine("BaudRate              : " & ComPort.BaudRate)
 134:          Str1.AppendLine("Parity                : " & ComPort.Parity)
 135:          Str1.AppendLine("DataBits              : " & ComPort.DataBits)
 136:          Str1.AppendLine("StopBits              : " & ComPort.StopBits)
 137:          Str1.AppendLine("BreakState            : " & ComPort.BreakState)
 138:          Str1.AppendLine("CDHolding             : " & ComPort.CDHolding)
 139:          Str1.AppendLine("CtsHolding            : " & ComPort.CtsHolding)
 140:          Str1.AppendLine("DsrHolding            : " & ComPort.DsrHolding)
 141:          Str1.AppendLine("RtsEnable             : " & ComPort.RtsEnable)
 142:          Str1.AppendLine("Handshake             : " & ComPort.Handshake)
 143:          Str1.AppendLine("BytesToRead           : " & ComPort.BytesToRead)
 144:          Str1.AppendLine("BytesToWrite          : " & ComPort.BytesToWrite)
 145:          Str1.AppendLine("ReadBufferSize        : " & ComPort.ReadBufferSize)
 146:          Str1.AppendLine("WriteBufferSize       : " & ComPort.WriteBufferSize)
 147:          Str1.AppendLine("Encoding              : " & ComPort.Encoding.EncodingName)
 148:          Str1.AppendLine("ReadTimeout           : " & ComPort.ReadTimeout)
 149:          Str1.AppendLine("WriteTimeout          : " & ComPort.WriteTimeout)
 150:          Str1.AppendLine("InfiniteTimeout       : " & IO.Ports.SerialPort.InfiniteTimeout)
 151:          Str1.AppendLine("DiscardNull           : " & ComPort.DiscardNull)
 152:          Str1.AppendLine("ParityReplace         : " & ComPort.ParityReplace)
 153:          Str1.AppendLine("ReceivedBytesThreshold: " & ComPort.ReceivedBytesThreshold)
 154:          Str1.AppendLine("----------------------------------------")
 155:          Return Str1.ToString
 156:      End Function
 157:   
 158:  #Region "Статусы принтера и статистика"
 159:   
 160:      'Printer Sensor:
 161:      '1. Head temperature
 162:      '2. Black mark
 163:      '3. Paper end
 164:      '4. Ticket presence on output
 165:      '5. Opening of printing unit
 166:      '6. Near paper end on roll support is optional
 167:      'Public Overloads Shared Function _CMD_Ejector_commands()
 168:   
 169:      ''' <summary>
 170:      ''' Near paper-end sensor and Paper-end sensor
 171:      ''' </summary>
 172:      Shared Function CMDstatus_Transmit_parer_sensor_status() As Byte()
 173:          Dim X() As Byte = {&H1B, &H76}
 174:          Port.Write(X)
 175:          Return ReadStatus()
 176:      End Function
 177:   
 178:      ''' <summary>
 179:      ''' Near paper-end sensor and Paper-end sensor
 180:      ''' </summary>
 181:      ''' <param name="n">n = 1, 49</param>
 182:      Shared Function CMDstatus_Transmit_status(ByVal n As Integer) As Byte()
 183:          Dim X() As Byte = {&H1D, &H72, CByte(n)}
 184:          Port.Write(X)
 185:          Return ReadStatus()
 186:      End Function
 187:   
 188:      ''' <summary>
 189:      ''' Transmits the printer ID speci?ed by n follows
 190:      ''' </summary>
 191:      ''' <param name="n">1 ? n ? 3, 49 ? n ? 51</param>
 192:      Shared Function CMDstatus_Transmit_printer_ID(ByVal n As Integer) As Byte()
 193:          Dim X() As Byte = {&H1D, &H49, CByte(n)}
 194:          Port.Write(X)
 195:          Return ReadStatus()
 196:      End Function
 197:   
 198:      ''' <summary>
 199:      ''' Transmits the selected printer status speci?ed by n in real time according to the following parameters:
 200:      ''' n = 1 transmit printer status
 201:      ''' n = 2 transmit off-line status
 202:      ''' n = 3 transmit error status
 203:      ''' n = 4 transmit paper roll sensor status
 204:      ''' n = 17 transmit print status
 205:      ''' n = 20 transmit FULL STATUS
 206:      ''' This command is executed when the data buffer is full.
 207:      ''' This status is transmitted whenever data sequence $10 $04 n is received.
 208:      ''' </summary>
 209:      ''' <param name="n">1 ? n ? 4; n=17, n=20</param>
 210:      Public Shared Function CMDstatus_Realtime_status_transmission(ByVal n As Integer) As Byte()
 211:          Dim X() As Byte = {&H10, &H4, CByte(n)}
 212:          Port.Write(X)
 213:          Return ReadStatus()
 214:      End Function
 215:   
 216:      Public Enum RequestType
 217:          PrinterStatus = 1
 218:          OfflineStatus = 2
 219:          ErrorStatus = 3
 220:          PaperRollSensorStatus = 4
 221:          PrintStatus = 17
 222:          FullStatus = 20
 223:      End Enum
 224:   
 225:      Public Shared Function CMDstatus_Realtime_status_transmission(ByVal Request As RequestType) As Byte()
 226:          Return VKP80_CMD.CMDstatus_Realtime_status_transmission(CInt(Request))
 227:      End Function
 228:   
 229:      ''' <summary>
 230:      ''' This command handles tickets ejector:
 231:      ''' n = 1 
 232:      ''' n = 2 Execute a ticket retract (only if Paper retracting is enabled)
 233:      ''' n = 3 Produce a ticket with m steps (1 step = 7.3 mm)
 234:      ''' n = 5 Eject ticket
 235:      ''' n = 6 Transmit the status byte of the ejector
 236:      ''' </summary>
 237:      Shared Function CMDstatus_Ejector_commands(ByVal n As Integer, ByVal m As Integer) As Byte()
 238:          Dim X() As Byte = {&H1D, &H65, CByte(n), CByte(m)}
 239:          Port.Write(X)
 240:          Return ReadStatus()
 241:      End Function
 242:   
 243:      Shared Function CMDstatus_Ejector_commands(ByVal n As Integer) As Byte()
 244:          Dim X() As Byte = {&H1D, &H65, CByte(n)}
 245:          Port.Write(X)
 246:          Return ReadStatus()
 247:      End Function
 248:   
 249:      ''' <summary>
 250:      ''' Reading of length (cm) paper available before virtual paper-end.
 251:      ''' The command return a string pointing out how much paper is available, for example if there are 5.1 m before the paper end, it will be: ‘510cm’
 252:      ''' • The lenght of residual paper reported is just as an indication because tolerances and other factors are not taken into consideration (paper thickness, roll core diameter, roll core thickness). The virtual paper-end limit is set by the command $1D $E6.
 253:      ''' • To set virtual paper-end limit, measure the length of the paper from near paper end to the end of the roll, using several of them.
 254:      ''' </summary>
 255:      Shared Function CMDstatus_Reading_of_length_paper_cm_available_before_virtual_paper_end() As Byte()
 256:          Dim X() As Byte = {&H1D, &HE1}
 257:          Port.Write(X)
 258:          Return ReadStatus()
 259:      End Function
 260:   
 261:      ''' <summary>
 262:      ''' The command return a string that points out how many cuts are performed by the printer, for example if there are performed 2376 cuts, it will be: ‘2376 cuts’
 263:      ''' </summary>
 264:      Shared Function CMDstatus_Reading_number_of_cuts_performed_from_the_printer() As Byte()
 265:          Dim X() As Byte = {&H1D, &HE2}
 266:          Port.Write(X)
 267:          Return ReadStatus()
 268:      End Function
 269:   
 270:      ''' <summary>
 271:      ''' The command return a string pointing out how much paper is printed, for example if the printer has print about 2515,5 m, it will be: ‘251550cm’
 272:      ''' </summary>
 273:      Shared Function CMDstatus_Reading_of_length_cm_of_printed_paper() As Byte()
 274:          Dim X() As Byte = {&H1D, &HE3}
 275:          Port.Write(X)
 276:          Return ReadStatus()
 277:      End Function
 278:   
 279:      ''' <summary>
 280:      ''' • The command return a string pointing out the number of retracting of the printer, for example if the printer has retracted the paper 512 times, it will be: ‘512ret’
 281:      ''' </summary>
 282:      Shared Function CMDstatus_Reading_number_of_retracting() As Byte()
 283:          Dim X() As Byte = {&H1D, &HE4}
 284:          Port.Write(X)
 285:          Return ReadStatus()
 286:      End Function
 287:   
 288:      ''' <summary>
 289:      ''' Reading number of power up of the printer.
 290:      ''' • The command return a string pointing out the number of turning on of the printer, for example if the printer is turned on 512 times, it will be: ‘512on’
 291:      ''' </summary>
 292:      Shared Function CMDstatus_Reading_number_of_power_up() As Byte()
 293:          Dim X() As Byte = {&H1D, &HE5}
 294:          Port.Write(X)
 295:          Return ReadStatus()
 296:      End Function
 297:   
 298:  #End Region
 299:   
 300:  #Region "Simple command"
 301:   
 302:      ''' <summary>
 303:      ''' Moves print position to previous character
 304:      ''' </summary>
 305:      Shared Sub CMDsimple_Back_space()
 306:          Dim X() As Byte = {&H8}
 307:          Port.Write(X)
 308:      End Sub
 309:   
 310:      ''' <summary>
 311:      ''' Ignored unless the next horizontal tab position has been set
 312:      ''' If the command is received when the printing position is at the right margin, 
 313:      ''' the printer executes print buffer full printing and horizontal tab processing from the beginning of the  next line. 
 314:      '''</summary>
 315:      Shared Sub CMDsimple_Horizontal_tab()
 316:          Dim X() As Byte = {&H9}
 317:          Port.Write(X)
 318:      End Sub
 319:   
 320:      ''' <summary>
 321:      ''' Sets the print position to the beginning of the line
 322:      ''' </summary>
 323:      Shared Sub CMDsimple_Print_and_line_feed()
 324:          Dim X() As Byte = {&HA}
 325:          Port.Write(X)
 326:      End Sub
 327:   
 328:      ''' <summary>
 329:      ''' Prints the data in the buffer, cuts the paper and presents the ticket.
 330:      ''' </summary>
 331:      Shared Sub CMDsimple_Form_feed()
 332:          Dim X() As Byte = {&HC}
 333:          Port.Write(X)
 334:      End Sub
 335:   
 336:      ''' <summary>
 337:      ''' Sets the print position to the beginning of the line.  See “Autofeed in setup” parameter.
 338:      ''' When autofeed is “CR enabled”, this command functions in the same way as $0A, otherwise it is disregarded.
 339:      ''' </summary>
 340:      Shared Sub CMDsimple_Print_and_carriage_return()
 341:          Dim X() As Byte = {&HD}
 342:          Port.Write(X)
 343:      End Sub
 344:   
 345:      ''' <summary>
 346:      ''' Deletes current line transmitted.
 347:      ''' Sets the print position to the beginning of the line.
 348:      ''' However, this command does not clear the receive buffer.
 349:      ''' </summary>
 350:      Shared Sub CMDsimple_Cancel_current_line_transmitted()
 351:          Dim X() As Byte = {&H18}
 352:          Port.Write(X)
 353:      End Sub
 354:   
 355:      ''' <summary>
 356:      ''' Prints the data in the print buffer and feeds the paper n rows.
 357:      ''' • Sets the print starting position at the beginning of the line.
 358:      ''' • This command does not affect the line spacing set by $1B $32 or $1B $33.
 359:      ''' • The maximum paper feed amount is 254 rows. Even if a paper feed amount of more than
 360:      '''  254 rows is set, the printer feeds the paper only 254 rows
 361:      ''' </summary>
 362:      ''' <param name="n">0 ? n ? 255</param>
 363:      Shared Sub CMDsimple_Print_and_feed_paper_n_lines(ByVal n As Integer)
 364:          Dim X() As Byte = {&H1B, &H64, CByte(n)}
 365:          Port.Write(X)
 366:      End Sub
 367:   
 368:      ''' <summary>
 369:      ''' Sets line spacing to [ n * (vertical or horizontal motion unit)] inches.
 370:      ''' • The horizontal and vertical motion unit are speci?ed by $1D $50 or $1D $D0. Changing the horizontal or vertical motion unit does not affect the current line spacing.
 371:      ''' • The $1D $50 or $1D $D0 command can change the horizontal (and vertical) motion unit. However, the value cannot be less than the minimum vertical movement amount.
 372:      ''' • In standard mode, the vertical motion unit is used.
 373:      ''' n = 64 (1/6 inch)
 374:      ''' </summary>
 375:      ''' <param name="n">0 ? n ? 255</param>
 376:      Shared Sub CMDsimple_Set_line_spacing(ByVal n As Integer)
 377:          Dim X() As Byte = {&H1B, &H33, CByte(n)}
 378:          Port.Write(X)
 379:      End Sub
 380:   
 381:   
 382:  #End Region
 383:   
 384:  #Region "Printer Init"
 385:      ''' <summary>
 386:      ''' Clears the data in the print buffer and resets the printer mode to that in effect when power was turned on.
 387:      ''' • The data in the receiver buffer is not cleared.
 388:      ''' • The macro de?nitions are not cleared.
 389:      ''' </summary>
 390:      Shared Sub CMDinit_Initialize_printer()
 391:          Dim X() As Byte = {&H1B, &H40}
 392:          Port.Write(X)
 393:      End Sub
 394:   
 395:      ''' <summary>
 396:      ''' Select the device to which the host computer sends data, using n as follows:
 397:      ''' When the printer is disabled, it ignores all transmitted data until the printer is enabled through this command.
 398:      '''• When the Pass-trough function is enabled, all transmitted data are sent on the 2nd serial.
 399:      ''' </summary>
 400:      ''' <param name="n"></param>
 401:      Shared Sub CMDinit_Select_peripheral_device(ByVal n As Integer)
 402:          Dim X() As Byte = {&H1B, &H3D, CByte(n)}
 403:          Port.Write(X)
 404:      End Sub
 405:   
 406:      ''' <param name="n">0 ? n ? 255</param>
 407:      Shared Sub CMDinit_EnableDisable_front_panel_buttons(ByVal n As Integer)
 408:          Dim X() As Byte = {&H1B, &H63, &H35, CByte(n)}
 409:          Port.Write(X)
 410:      End Sub
 411:   
 412:      ''' <summary>
 413:      ''' Sets printing speed. n speci?es the printing speed as follows:
 414:      ''' Printing speed
 415:      ''' 0 - High quality
 416:      ''' 1 - Norma
 417:      ''' 2 - High speed
 418:      ''' • Printing speed reverts to the default value when the printer is reset or turned off.
 419:      ''' </summary>
 420:      ''' <param name="n">0?n?2 , Default 1</param>
 421:      Shared Sub CMDinit_Set_printing_speed(ByVal n As Integer)
 422:          Dim X() As Byte = {&H1D, &HF0, CByte(n)}
 423:          Port.Write(X)
 424:      End Sub
 425:   
 426:      ''' <summary>
 427:      ''' n speci?es the composition of FULL STATUS as follows:
 428:      ''' • Once enable at least one byte of the FULL STATUS, for each change of at least one of the bits which compose the required status, the status sent in automatic from the printer will be so composed as follows:
 429:      ''' 1° byte = $10 (DLE)
 430:      ''' 2° byte = n
 431:      ''' Next byte (depends how many bits are active in n)
 432:      ''' </summary>
 433:      ''' <param name="n">0 ? n ? 255</param>
 434:      ''' <remarks>Доделать определение битов</remarks>
 435:      Shared Sub CMDinit_EnableDisable_automatic_FULL_STATUS_back(ByVal n As Integer)
 436:          Dim X() As Byte = {&H1D, &HE0, CByte(n)}
 437:          Port.Write(X)
 438:      End Sub
 439:   
 440:  #End Region
 441:   
 442:  #Region "Print mode"
 443:   
 444:      ''' <summary>
 445:      ''' Switches from standard mode to page mode.
 446:      ''' • This command is enabled only when processed at the beginning of a line in standard mode.
 447:      ''' • This command has no effect in page mode
 448:      ''' • After printing by $0C is completed or by using $1B $53, the printer returns to standard mode.
 449:      ''' • This command sets the position where data is buffered to the position speci?ed by $1B $54 within the printing area de?ned by $1B $57.
 450:      ''' • This command switches the settings for the following commands (in which the values can be set independently in standard mode and page mode) to those for page mode:
 451:      '''  1) Set right-side character spacing: $1B $20
 452:      '''  2) Select default line spacing: $1B $32, $1B $33
 453:      ''' • Only value settings is possible for the following commands in page mode; these commands are not executed.
 454:      ''' 1) Turn 90° clockwise rotation mode on/off: $1B $56
 455:      ''' 2) Select justi?cation: $1B $61
 456:      ''' 3) Turn upside-down printing mode on/off: $1B $7B
 457:      ''' 4) Set left margin: $1D $4C
 458:      ''' 5) Set printable area width: $1D $57
 459:      ''' • The following command is not available in page mode:
 460:      ''' 1) Print raster bit image: $1D $76 $30
 461:      ''' • The printer returns to standard mode when power is turned on, the printer is reset, or $1B $40 is used.
 462:      ''' </summary>
 463:      Shared Sub CMDmode_Select_page_mode()
 464:          Dim X() As Byte = {&H1B, &H4C}
 465:          Port.Write(X)
 466:      End Sub
 467:   
 468:      ''' <summary>
 469:      ''' Switches from page mode to standard mode.
 470:      ''' • This command is effective only in page mode.
 471:      ''' • Data buffered in page mode are cleared.
 472:      ''' • This command sets the print position to the beginning of the line.
 473:      ''' • The printing area set by $1B $57 are initialized.
 474:      ''' • This command switches the settings for the following commands (in which the values can be set independently in standard mode and page mode) to those for standard mode:
 475:      ''' 1) Set right-side character spacing: $1B $20
 476:      ''' 2) Select default line spacing: $1B $32, $1B $33
 477:      ''' • The following commands are enabled only to set in standard mode.
 478:      ''' 1) Set printing area in page mode: $1B $57
 479:      ''' 2) Select print direction in page mode: $1B $54
 480:      ''' • The following commands are ignored in standard mode.
 481:      ''' 1) Set absolute vertical print position in page mode: $1D $24
 482:      ''' 2) Set relative vertical print position in page mode: $1D $5C
 483:      ''' • Standard mode is selected automatically when power is turned on, the printer is reset, or command $1B $40 is used.
 484:      ''' </summary>
 485:      Shared Sub CMDmode_Select_standard_mode()
 486:          Dim X() As Byte = {&H1B, &H53}
 487:          Port.Write(X)
 488:      End Sub
 489:   
 490:   
 491:      ''' <summary>
 492:      '''• When the LSB of n is 0, white/black reverse printing is turned off.
 493:      '''• When the LSB of n is 1, white/black reverse printing is turned on.
 494:      '''• Only the LSB di n is effective.
 495:      '''• This command is available for both built-in and user-de?ned characters.
 496:      '''• This command does not affect bit image, downloaded bit image, bar code, HRI characters and spacing skipped by $09, $1B $24 and $1B $5C.
 497:      '''• This command does not affect white space between lines.
 498:      '''• White/black reverse mode has a higher priority than underline mode. Even if underline mode is on, it will be disabled (but not cancelled) when white/black reverse mode is selected.
 499:      ''' </summary>
 500:      ''' <param name="n">0 ? n ? 255</param>
 501:      Shared Sub CMDmode_Turn_WhiteBlack_reverse_printing_mode_OnOff(ByVal n As Integer)
 502:          Dim X() As Byte = {&H1D, &H42, CByte(n)}
 503:          Port.Write(X)
 504:      End Sub
 505:   
 506:      ''' <summary>
 507:      '''      direction      Starting position
 508:      ''' 0,48 Left to right Upper left
 509:      ''' 1,49 Bottom to top Lower left
 510:      ''' 2,50 Right to left Lower right
 511:      ''' 3,51 Top to bottom Upper right
 512:      ''' </summary>
 513:      ''' <param name="n">0?n?3,48 ? n ? 51</param>
 514:      Shared Sub CMDmode_Select_print_direction_in_page_mode(ByVal n As Integer)
 515:          Dim X() As Byte = {&H1B, &H54, CByte(n)}
 516:          Port.Write(X)
 517:      End Sub
 518:   
 519:      ''' <summary>
 520:      ''' Turns 90° rotation mode on/off. n is used as follows 
 521:      ''' 0,48 Turns off 90° rotation mode
 522:      ''' 1,49 Turns on 90° rotation mode
 523:      ''' </summary>
 524:      ''' <param name="n">0?n?1,48 ? n ? 49</param>
 525:      Shared Sub CMDmode_Select_print_mode_90_turned(ByVal n As Integer)
 526:          Dim X() As Byte = {&H1B, &H56, CByte(n)}
 527:          Port.Write(X)
 528:      End Sub
 529:   
 530:  #End Region
 531:   
 532:  #Region "Print area"
 533:      ''' <summary>
 534:      ''' • If this command is input in standard mode, the printer executes only internal ?ag operation.
 535:      '''This command does not affect printing in standard mode.
 536:      '''• If the horizontal or vertical starting position is set outside the printable area, the printer stops command processing and processes the following data as normal data.
 537:      '''• If the printing area width or height is set to 0, the printer stops command processing and processes the following data as normal data.
 538:      '''• This command sets the position where data is buffered to the position speci?ed by $1B $54 within the printing area.
 539:      '''• If (horizontal starting position + printing area width) exceeds the printable area, the printing area width is automatically set to (horizontal printable area -horizontal starting position).
 540:      '''• If (vertical starting position + printing area height) exceeds the printable area, the printing area height is automatically set to (vertical printable area - vertical starting position).
 541:      '''• The horizontal and vertical motion unit are speci?ed by $1D $50. Changing the horizontal or vertical motion unit does not affect the current printing area.
 542:      '''• The $1D $50 command can change the horizontal (and vertical) motion unit. However, the value cannot be less than the minimum horizontal movement amount, and it must be in even units of minimum horizontal movement amount.
 543:      '''• Use the horizontal motion unit ( x) for setting the horizontal starting position and printing area width, and use the vertical motion unit ( y) for setting the vertical starting position and printing area height.
 544:      '''• When the horizontal starting position , vertical starting position, printing area width, and printing area height are de?ned as X, Y, Dx, and Dy respectively, the printing area is set.
 545:      ''' The horizontal starting position, vertical starting position, printing area width, and printing area height are de?ned as x0, y0, dx (inch), dy (inch), respectively.
 546:      ''' Each setting for the printing area is calculated as follows:
 547:      ''' x0 = [( xL + xH x 256) x (horizontal motion unit)]
 548:      ''' y0 = [( yL + yH x 256) x (vertical motion unit)]
 549:      ''' dx = [ dxL + dxH x 256) x (horizontal motion unit)]
 550:      ''' dy = [ dyL + dyH x 256) x (vertical motion unit)]
 551:      ''' 0 ? xL, xH, yL, yH, dxL, dxH, dyL, dyHn ? 255 (except dxL= dxH = 0 or dyL = dyHn = 0)
 552:      ''' </summary>
 553:      Shared Sub CMDarea_Set_printing_area_in_page_mode(ByVal xL As Integer, ByVal xH As Integer, ByVal yL As Integer, ByVal yH As Integer, ByVal dxL As Integer, ByVal dxH As Integer, ByVal dyL As Integer, ByVal dyH As Integer)
 554:          Dim X() As Byte = {&H1B, &H57, CByte(xL), CByte(xH), CByte(yL), CByte(yH), CByte(dxL), CByte(dxH), CByte(dyL), CByte(dyH)}
 555:          Port.Write(X)
 556:      End Sub
 557:   
 558:   
 559:      ''' <summary>
 560:      '''Sets the horizontal and vertical motion units to 1/x inch and 1/y inch respectively.
 561:      '''When x is set to 0, the default setting value is used.
 562:      '''When y is set to 0, the default setting value is used.
 563:      '''• The horizontal direction is perpendicular to the paper feed direction.
 564:      '''• In standard mode, the following commands use x or y, regardless of character rotation
 565:      '''(upside-down or 90° clockwise rotation):
 566:      '''         Commands using x : $1D $4C, $1D $57.
 567:      '''         Commands using y : $1B $4A.
 568:      '''• This command does not affect the previously speci?ed values.
 569:      '''• The calculated result from combining this command with others is truncated to the minimum value of the mechanical pitch or an exact multiple of that value.
 570:      ''' </summary>
 571:      ''' <param name="x1">0 ? x, y ? 255</param>
 572:      ''' <param name="y">0 ? x, y ? 255</param>
 573:      Shared Sub CMDarea_Set_horizontal_and_vertical_motion_units_mode_1(ByVal x1 As Integer, ByVal y As Integer)
 574:          Dim X() As Byte = {&H1B, &H50, CByte(x1), CByte(y)}
 575:          Port.Write(X)
 576:      End Sub
 577:   
 578:      ''' <summary>
 579:      '''Sets the horizontal and vertical motion units to 1/((xH * 256) + xL) inch and 1/((yH * 256) + yL) inch respectively.
 580:      '''When x is set to 0, the default setting value is used.
 581:      '''When y is set to 0, the default setting value is used.
 582:      '''• The horizontal direction is perpendicular to the paper feed direction.
 583:      '''• In standard mode, the following commands use x or y, regardless of character rotation
 584:      '''(upside-down or 90° clockwise rotation):
 585:      '''         Commands using x : $1D $4C, $1D 57.
 586:      '''         Commands using y : $1B $4A, $1B $33.
 587:      '''• This command does not affect the previously speci?ed values.
 588:      '''• The calculated result from combining this command with others is truncated to the minimum value of the mechanical pitch or an exact multiple of that value.
 589:      ''' </summary>
 590:      ''' <param name="xH">0 ? ((xH * 256) + xL) ? 2040</param>
 591:      ''' <param name="xL">0 ? ((xH * 256) + xL) ? 2040</param>
 592:      ''' <param name="yH">0 ? ((yH * 256) + yL) ? 4080</param>
 593:      ''' <param name="yL">0 ? ((yH * 256) + yL) ? 4080</param>
 594:      ''' <remarks></remarks>
 595:      Shared Sub CMDarea_Set_horizontal_and_vertical_motion_units_mode_2(ByVal xH As Integer, ByVal xL As Integer, ByVal yH As Integer, ByVal yL As Integer)
 596:          Dim X() As Byte = {&H1D, &HD0, CByte(xH), CByte(xL), CByte(yH), CByte(yL)}
 597:          Port.Write(X)
 598:      End Sub
 599:   
 600:      ''' <summary>
 601:      ''' Sets notch distance in mm from the beginning of the document (see appendix B).
 602:      ''' • This value is expressed as [(nH x 256)+nL]
 603:      ''' • It’s possible to put in the notch distance maximum limit during the setup phase. The notch distance value range goes from 0 to 32 mm.
 604:      ''' The setting are saved in the EEPROM to keep the value when the printer is turned off.
 605:      ''' </summary>
 606:      ''' <param name="nH">0 ? nH ? 255, Default nH = $00 </param>
 607:      ''' <param name="nL">0 ? nL ? 255, Default nL = $00</param>
 608:      Shared Sub CMDarea_Set_notch_distance(ByVal nH As Integer, ByVal nL As Integer)
 609:          Dim X() As Byte = {&H1D, &HE7, CByte(nH), CByte(nL)}
 610:          Port.Write(X)
 611:      End Sub
 612:   
 613:   
 614:      ''' <summary>
 615:      ''' Sets the printing area width to the area speci?ed by nL and nH.
 616:      '''The nMAX value is 576.
 617:      '''• The left margin is set to [(nL + nH * 256) ? (horizontal motion unit)] inches.
 618:      '''• This command is only enabled if set at the beginning of the line.
 619:      '''• If the right margin is greater than the printable area, the printing area width is set at maximum value.
 620:      '''• If the printing area width = 0, it is set at the maximum value.
 621:      '''• The horizontal and vertical motion units are speci?ed by $1D $50 or $1D $D0. Changing the horizontal or vertical motion unit does not affect the current left margin.
 622:      '''• The $1D $50 or $1D $D0 command can change the horizontal (and vertical) motion unit.
 623:      '''• However, the value cannot be less than the minimum horizontal movement amount and it must be in even units of the minimum horizontal movement amount.
 624:      ''' </summary>
 625:      ''' <param name="nL">0 ? nL, nH ? 255</param>
 626:      ''' <param name="nH">0 ? nL + nH x 256) ? nMAX</param>
 627:      Shared Sub CMDarea_Set_printing_area_width(ByVal nL As Integer, ByVal nH As Integer)
 628:          Dim X() As Byte = {&H1D, &H57, CByte(nL), CByte(nH)}
 629:          Port.Write(X)
 630:      End Sub
 631:   
 632:   
 633:  #End Region
 634:   
 635:  #Region "Counters"
 636:      ''' <summary>
 637:      ''' Selects a print mode for the serial number counter.
 638:      '''• n speci?es the number of digits to be printed as follows: 
 639:      '''when n = 0, the printer prints the actual digits indicated by the numeric value.
 640:      '''when n = 1 to 5, the command sets the number of digits to be printed.
 641:      '''• m speci?es the printing position within the entire range of printed digits as follows:
 642:      ''' m   position     Processing of digits less than those speci?ed
 643:      '''0,48 Flush right  Adds spaces to the left
 644:      '''1,49 Flush right  Adds a ‘0’ to the left
 645:      '''2,50 Flush left   Adds spaces to the right
 646:      '''• If n or m is out of the de?ned range, the previously set print mode is not changed.
 647:      '''• If n = 0, m is not applicable.
 648:      ''' </summary>
 649:      ''' <param name="n">0?n?5</param>
 650:      ''' <param name="m">m = 0, 1, 2, 48, 49, 50</param>
 651:      Shared Sub CMDcount_Select_counter_print_mode(ByVal n As Integer, ByVal m As Integer)
 652:          Dim X() As Byte = {&H1D, &H43, &H30, CByte(n), CByte(n)}
 653:          Port.Write(X)
 654:      End Sub
 655:   
 656:      ''' <summary>
 657:      ''' Selects a count mode for the serial number counter.
 658:      '''• aL, aH or bL, bH specify the counter range.
 659:      '''• n indicates the unit amount when counting up or down.
 660:      '''• r indicates the repetition number when the counter value is ?xed.
 661:      '''• Count-up mode is speci?ed when:
 662:      '''[aL + (aH * 256)] %lt; [bL + (bH * 256)] and n ? 0 and r ? 0
 663:      '''• Count-down mode is speci?ed when:
 664:      '''[aL + (aH * 256)] &gt; [bL + (bH * 256)] and n ? 0 and r ? 0
 665:      '''• Counting stops when:
 666:      '''[aL + (aH * 256)] = [bL + (bH * 256)] or n = 0 or r = 0
 667:      '''• Setti ng the count-up mode, the minimum counter value is [aL + (aH * 256)] and the maximum value is [bL + (bH * 256)]. If the counting up reaches a value that exceeds the maximum, it resets to the minimum value.
 668:      '''• Setting the count-down mode, the maximum counter value is [aL + (aH * 256)] and the minimum value is [bL + (bH * 256)]. If the counting down reaches a value less than the minimum, it resets to the maximum value.
 669:      '''• When this command is executed, the internal count that indicates the repetition number speci?ed by r is cleared.
 670:      ''' </summary>
 671:      ''' <param name="aL">0 ? aL, aH ? 255</param>
 672:      ''' <param name="aH">0 ? aL, aH ? 255</param>
 673:      ''' <param name="bL">0 ? bL, bH ? 255</param>
 674:      ''' <param name="bH">0 ? bL, bH ? 255</param>
 675:      ''' <param name="n">0 ? n, r ? 255</param>
 676:      ''' <param name="r">0 ? n, r ? 255</param>
 677:      Shared Sub CMDcount_Select_count_mode_A(ByVal aL As Integer, ByVal aH As Integer, ByVal bL As Integer, ByVal bH As Integer, ByVal n As Integer, ByVal r As Integer)
 678:          Dim X() As Byte = {&H1D, &H43, &H31, CByte(aL), CByte(aH), CByte(bL), CByte(bH), CByte(n), CByte(r)}
 679:          Port.Write(X)
 680:      End Sub
 681:   
 682:      ''' <summary>
 683:      ''' Sets the serial number counter value.
 684:      ''' • nL and nH determine the value of the serial number counter set by [nL + (nH * 256)].
 685:      ''' • In count -up mode, if the counter value speci?ed by this command goes out of the counter operation range speci?ed by $1D $43 $31 or $1D $43 $3B it is forced to convert to the minimum value through $1D $63.
 686:      ''' • In count-down mode, if the counter value speci?ed by this command goes out of the counter operation range speci?ed by $1D $43 $31 or $1D $43 $3B it is forced to convert to the maximum value through $1D $63.
 687:      ''' </summary>
 688:      ''' <param name="aL">0 ? nL, nH ? 255</param>
 689:      ''' <param name="aH">0 ? nL, nH ? 255</param>
 690:      Shared Sub CMDcount_Select_counter(ByVal aL As Integer, ByVal aH As Integer)
 691:          Dim X() As Byte = {&H1D, &H43, &H32, CByte(aL), CByte(aH)}
 692:          Port.Write(X)
 693:      End Sub
 694:   
 695:      ''' <summary>
 696:      ''' These values are all character strings.
 697:      '''Selects a count mode for the serial number counter and speci?es the value of the counter.
 698:      '''• sa, sb, sn, sr and sc are all displayed as ASCII characters using codes from ‘0’ to ‘9’.
 699:      '''• sa and sb specify the counter range.
 700:      '''• sn indicates the unit amount for counting up or down.
 701:      '''• sr indicates the repetition number when the counter value is ?xed.
 702:      '''• sc indicates the counter value.
 703:      '''• Count-up mode is speci?ed when: sa &lt; sb and sn ? 0 and sr ? 0
 704:      '''• Count-down mode is speci?ed when: sa &gt; sb and sn ? 0 and sr ? 0
 705:      '''• Counting stops when: sa = sb or sn = 0 or sr = 0
 706:      '''• In setting count-up mode, the minimum value of the counter is sa and the maximum value is sb. If counting up reaches a value exceeding the maximum, it resets to the minimum value. If the counter value set by sc is outside the counter operation range, the counter value is forced to convert to the minimum value by executing $1D $63.
 707:      ''' • In setting count-down mode, the maximum value of the counter is sa and the minimum value is sb. If counting down reaches a value less than the minimum, it resets to the maximum value. If the counter value set by sc is outside the counter operation range, the counter value is forced to convert to the maximum value by executing $1D $63.
 708:      '''• Parameters sa to sc can be omitted. If omitted, they remain unchanged.
 709:      '''• Parameters sa to sc cannot contain characters other than ‘0’ to ‘9’.
 710:      ''' </summary>
 711:      ''' <param name="sa">0 ? sa, sb, sc ? 65535</param>
 712:      ''' <param name="sb">0 ? sa, sb, sc ? 65535</param>
 713:      ''' <param name="sn">0 ? sn, sr ? 255</param>
 714:      ''' <param name="sr">0 ? sn, sr ? 255</param>
 715:      ''' <param name="sc">0 ? sa, sb, sc ? 65535</param>
 716:      Shared Sub CMDcount_Select_count_mode_B(ByVal sa As Integer, ByVal sb As Integer, ByVal sn As Integer, ByVal sr As Integer, ByVal sc As Integer)
 717:          Dim X() As Byte = {&H1D, &H43, &H3B, CByte(sa), &H3B, CByte(sb), &H3B, CByte(sn), &H3B, CByte(sr), &H3B, CByte(sc), &H3B}
 718:          Port.Write(X)
 719:      End Sub
 720:   
 721:      ''' <summary>
 722:      ''' Sets the serial counter value in the print buffer and increments or decrements the counter   value.
 723:      '''• After setting the current counter value in the print buffer as print data (a character string), the printer counts up or down based on the count mode set. The counter value in the print   buffer is printed when the printer receives a print command or the buffer is full.
 724:      '''• The counter print mode is set using $1D $43 $30.
 725:      '''• The counter mode is set using $1D $43 $31 or $1D $43 $3B.
 726:      '''• In count-up mode, if the counter value set by this command goes out of the counter operation range set by $1D $43 $31 or $1D $43 $3B it is forced to revert to the minimum value.
 727:      '''• In count-down mode, if the counter value set by this command goes out of the counter operation range set by $1D $43 $31 or $1D $43 $3B it is forced to revert to the maximum  value.
 728:      ''' </summary>
 729:      Shared Sub CMDcount_Print_counter()
 730:          Dim X() As Byte = {&H1D, &H63}
 731:          Port.Write(X)
 732:      End Sub
 733:   
 734:  #End Region
 735:   
 736:  #Region "print, cut and feeds the paper"
 737:   
 738:   
 739:      ''' <summary>
 740:      ''' 'This command prints the data in the buffer and enables cutter operation. If there is no cutter, a disabling ?ag is set and any subsequent cut commands will be ignored.
 741:      '''• The printer waits to complete all paper movement commands before it executes a total cut.
 742:      ''' </summary>
 743:      Shared Sub CMDpaper_Total_cut()
 744:          Dim X() As Byte = {&H1B, &H69}
 745:          Port.Write(X)
 746:      End Sub
 747:   
 748:   
 749:      ''' <summary>
 750:      ''' 0, 48 Total cut.
 751:      ''' 65 Form feed (cut position + [ n x vertical motion unit]) and total cut
 752:      ''' • This command is only enabled if set at the beginning of the line.
 753:      ''' </summary>
 754:      ''' <param name="m">m = 65, 0 ? n ? 255</param>
 755:      Shared Sub CMDpaper_Select_cut_mode(ByVal m As Integer)
 756:          Dim X() As Byte = {&H1D, &H56, CByte(m)}
 757:          Port.Write(X)
 758:      End Sub
 759:   
 760:      ''' <summary>
 761:      ''' Prints the data in the print buffer and feeds the paper [ n * (vertical or horizontal motion unit)] inches.
 762:      '''• After printing has been completed, this command sets the print starting position to the beginning of the line.
 763:      '''• The paper feed amount set by this command does not affect the values set by $1B $32 or $1B $33.
 764:      '''• The horizontal and vertical motion units are speci?ed by $1D $50 or $1D $D0.
 765:      '''• $1D $50 or $1D $D0 can change the vertical (and horizontal) motion unit. However, the value cannot be less than the minimum vertical movement amount.
 766:      '''• In standard mode, the vertical motion unit is used.
 767:      ''' </summary>
 768:      ''' <param name="n">0 ? n ? 255</param>
 769:      Shared Sub CMDpaper_Print_and_feed_paper(ByVal n As Integer)
 770:          Dim X() As Byte = {&H1B, &H4A, CByte(n)}
 771:          Port.Write(X)
 772:      End Sub
 773:   
 774:      ''' <summary>
 775:      ''' This command sets the limit after which is pointed out the virtual paper-end.
 776:      '''• The calculation limit of the near paper-end is in centimetres.
 777:      '''• This value is expressed as [(nH x 256)+nL]
 778:      ''' </summary>
 779:      ''' <param name="nH">0 ? nH, nL ? 255, Default nH = $00</param>
 780:      ''' <param name="nL">0 ? nH, nL ? 255, Default nL = $F0</param>
 781:      Shared Sub CMDpaper_Virtual_paper_end_limit(ByVal nH As Integer, ByVal nL As Integer)
 782:          Dim X() As Byte = {&H1D, &HE0, CByte(nH), CByte(nL)}
 783:          Port.Write(X)
 784:      End Sub
 785:   
 786:   
 787:      ''' <summary>
 788:      ''' Set the print head notch alignment. With the $1D $E7 command it’s possible to program the printing start distance from the notch.
 789:      ''' • The distances range goes from 0 to 32 mm.
 790:      ''' </summary>
 791:      Shared Sub CMDpaper_Ticket_align_at_print()
 792:          Dim X() As Byte = {&H1D, &HF6}
 793:          Port.Write(X)
 794:      End Sub
 795:      ''' <summary>
 796:      ''' Set the autocutter notch alignment. With the $1D $E7 command it’s possible to program the paper cut start distance from the notch.
 797:      '''• The distances range goes from 0 to 32 mm.
 798:      ''' </summary>
 799:      Shared Sub CMDpaper_Ticket_align_at_cut()
 800:          Dim X() As Byte = {&H1D, &HF8}
 801:          Port.Write(X)
 802:      End Sub
 803:   
 804:      ''' <summary>
 805:      '''In page mode, prints all buffered data in the printing area collectively.
 806:      '''This command is enabled only in page mode.
 807:      '''After printing, the printer does not clear the buffered data, setting values for $1B $54 and $1B $57, and the position for buffering character data.
 808:      ''' </summary>
 809:      Shared Sub CMDpaper_Print_in_page_mode()
 810:          Dim X() As Byte = {&H1B, &HC}
 811:          Port.Write(X)
 812:      End Sub
 813:   
 814:   
 815:  #End Region
 816:   
 817:  #Region "Font & density"
 818:      ''' <summary>
 819:      ''' The printer can underline all characters, but cannot underline the spaces set by $09, $1B , $24, $1B $5C and 90°/270° rotated characters.
 820:      ''' • When characters are enlarged to different heights on one line, the characters are aligned at the baseline or topline (see $1D $7E).
 821:      ''' • This command resets the left and right margin at default value (see $1D $4C, $1D $57).
 822:      ''' • $1B $45 can also be used to turn the emphasized mode on/off. However, the last-received setting command is the effective one.
 823:      ''' • $1B $2D can also be used to turn the underlining mode on/off. However, the last-received setting command is the effective one.
 824:      ''' • $1B $34 can also be used to turn the italic mode on/off. However, the last-received setting command is the effective one.
 825:      ''' </summary>
 826:      ''' <param name="n">0 ? n ? 255</param>
 827:      Shared Sub CMDfont_Set_print_mode(ByVal n As Integer)
 828:          Dim X() As Byte = {&H1B, &H21, CByte(n)}
 829:          Port.Write(X)
 830:      End Sub
 831:   
 832:      ''' <summary>
 833:      ''' Turns italic mode on or off, based on the following values of n:
 834:      ''' n      Function
 835:      ''' 0,48   Turns off italic mode
 836:      ''' 1,49   Turns on italic mode
 837:      ''' • The printer can print any character in italic mode.
 838:      '''• When italic mode is turned off by setting the value of n to 0 or 48, the data which follows is printed in normal mode.
 839:      ''' • Italic mode can also be turned on or off using $1B $21. Note, however, that the last received command is the effective one.
 840:      ''' </summary>
 841:      ''' <param name="n"></param>
 842:      Shared Sub CMDfont_SetReset_italic_mode(ByVal n As Integer)
 843:          Dim X() As Byte = {&H1B, &H34, CByte(n)}
 844:          Port.Write(X)
 845:      End Sub
 846:   
 847:      ''' <summary>
 848:      '''A=11cpi 0,48 Font 11 cpi (18x24)
 849:      '''B=15cpi 1,49 Font 15 cpi (14x24)
 850:      '''A=15cpi 0,48 Font 15 cpi (14x24)
 851:      '''B=20cpi 1,49 Font 20 cpi (10x24)
 852:      ''' </summary>
 853:      ''' <param name="n">n = 0, 1, 48, 49</param>
 854:      Shared Sub CMDfont_Select_character_font(ByVal n As Integer)
 855:          Dim X() As Byte = {&H1B, &H4D, CByte(n)}
 856:          Port.Write(X)
 857:      End Sub
 858:   
 859:      ''' <summary>
 860:      ''' Sets the character spacing for the right side of the character to [n x horizontal or vertical motion units].
 861:      ''' </summary>
 862:      ''' <param name="n">0 ? n ? 255</param>
 863:      Shared Sub CMDfont_Set_character_RightSide_spacing(ByVal n As Integer)
 864:          Dim X() As Byte = {&H1B, &H20, CByte(n)}
 865:          Port.Write(X)
 866:      End Sub
 867:   
 868:      ''' <summary>
 869:      '''• Bits 0 to 3: to select character height (see table 2).
 870:      '''• Bits 4 to 7: to select character width (see table 1).
 871:      '''Table 1 Select Character Width        
 872:      '''Hex    Decimal    Width
 873:      '''0    0    1 (normal)
 874:      '''10    16    2 (width = 2x)
 875:      '''20    32    3 (width = 3x)
 876:      '''30    48    4 (width = 4x)
 877:      '''40    64    5 (width = 5x)
 878:      '''50    80    6 (width = 6x)
 879:      '''60    96    7 (width = 7x)
 880:      '''70    112    8 (width = 8x)
 881:      '''Table 1 Select Character Height        
 882:      '''Hex    Decimal    Altezza
 883:      '''0    0    1 (normal)
 884:      '''1    1    2 (height = 2x)
 885:      '''2    2    3 (height = 3x)
 886:      '''3    3    4 (height = 4x)
 887:      '''4    4    5 (height = 5x)
 888:      '''5    5    6 (height = 6x)
 889:      '''6    6    7 (height = 7x)
 890:      '''7    7    8 (height = 8x)
 891:      ''' </summary>
 892:      ''' <param name="n">0 ? n ? 255</param>
 893:      Shared Sub CMDfont_Select_character_size(ByVal n As Integer)
 894:          Dim X() As Byte = {&H1D, &H21, CByte(n)}
 895:          Port.Write(X)
 896:      End Sub
 897:   
 898:   
 899:   
 900:      ''' <summary>
 901:      ''' Turns underline mode on or off, based on the following values of n:
 902:      ''' n = 0, 48Turns off underline mode
 903:      ''' n = 1, 49Turns on underline mode (1-dot thick)
 904:      ''' n = 2, 50Turns on underline mode (2-dot thick)
 905:      ''' • The printer can underline all characters, but cannot underline the space set by $09 and right-side character spacing.
 906:      ''' • The printer cannot underline 90°/270° rotated characters and white/black inverted characters.
 907:      ''' • When underline mode is turned off by setting the value of n to 0 or 48, the data which follows is not underlined.
 908:      ''' • Underline mode can also be turned on or off by using $1B $21. Note, however, that the lastreceived command is the effective one.
 909:      ''' </summary>
 910:      ''' <param name="n">0 ? n ? 2, 48 ? n ? 50</param>
 911:      Shared Sub CMDfont_Turn_underline_mode_OnOff(ByVal n As Integer)
 912:          Dim X() As Byte = {&H1B, &H2D, CByte(n)}
 913:          Port.Write(X)
 914:      End Sub
 915:   
 916:      ''' <summary>
 917:      ''' Selects 1/8-inch line spacing
 918:      ''' </summary>
 919:      Shared Sub CMDfont_Select_1_8_inch_line_spacing()
 920:          Dim X() As Byte = {&H1B, &H30}
 921:          Port.Write(X)
 922:      End Sub
 923:   
 924:      ''' <summary>
 925:      ''' Selects 1/6-inch line spacing
 926:      ''' </summary>
 927:      Shared Sub CMDfont_Select_1_6_inch_line_spacing()
 928:          Dim X() As Byte = {&H1B, &H32}
 929:          Port.Write(X)
 930:      End Sub
 931:   
 932:   
 933:      ''' <summary>
 934:      ''' 0 - the emphasized mode is off; 1 - the emphasized mode is on. Default 0
 935:      ''' </summary>
 936:      ''' <param name="n">0 ? n ? 255</param>
 937:      Shared Sub CMDfont_Select_emphasized_mode(ByVal n As Integer)
 938:          Dim X() As Byte = {&H1B, &H45, CByte(n)}
 939:          Port.Write(X)
 940:      End Sub
 941:   
 942:      ''' <summary>
 943:      '''  0 - double-strike mode is off; 1 - the double-strike mode is on. Default 0
 944:      ''' </summary>
 945:      ''' <param name="n">0 ? n ? 255</param>
 946:      Shared Sub CMDfont_Select_doubleStrike_mode(ByVal n As Integer)
 947:          Dim X() As Byte = {&H1B, &H47, CByte(n)}
 948:          Port.Write(X)
 949:      End Sub
 950:   
 951:      ''' <summary>
 952:      ''' n    Printing density
 953:      '''0, 48 - 50%
 954:      '''1, 49 - 37.5%
 955:      '''2, 50 - 25%
 956:      '''3, 51 - 12.5%
 957:      '''4, 52 0%
 958:      '''5, 53 + 12.5%
 959:      '''6, 54 + 25%
 960:      '''7, 55 + 37.5%
 961:      '''8,56 + 50%
 962:      ''' Printing density reverts to the default value when the printer is reset or turned off.
 963:      ''' </summary>
 964:      ''' <param name="n">0 ? n ? 8, 48 ? n ? 56</param>
 965:      Shared Sub CMDfont_Set_printing_density(ByVal n As Integer)
 966:          Dim X() As Byte = {&H1D, &H7C, CByte(n)}
 967:          Port.Write(X)
 968:      End Sub
 969:   
 970:      ''' <summary>
 971:      ''' 0,48 Font A= 11 cpi Font B= 15 cpi
 972:      ''' 1,49 Font A= 15 cpi Font B= 20 cpi
 973:      ''' </summary>
 974:      ''' <param name="n">0 ? n ? 1, 48 ? n ? 49</param>
 975:      Shared Sub CMDfont_SetCancel_cpi_mode(ByVal n As Integer)
 976:          Dim X() As Byte = {&H1B, &HC1, CByte(n)}
 977:          Port.Write(X)
 978:      End Sub
 979:   
 980:      ''' <summary>
 981:      '''Sets superscript or subscript character position. n speci?es the position as follows:
 982:      '''0, 48 Subscript character position
 983:      '''1, 49 Superscript character position
 984:      ''' • This command is executed if there are characters of different height on the same line.
 985:      ''' </summary>
 986:      ''' <param name="n">n = 0, 1, 48, 49</param>
 987:      Shared Sub CMDfont_Set_SuperscriptSubscript(ByVal n As Integer)
 988:          Dim X() As Byte = {&H1D, &H7E, CByte(n)}
 989:          Port.Write(X)
 990:      End Sub
 991:   
 992:  #End Region
 993:   
 994:  #Region "Charset"
 995:   
 996:      ''' <summary>
 997:      ''' Selects or cancels the user-de?ned character set.
 998:      ''' When the Least Signi?cant Bit (LSB) of n is 0, the user-de?ned character set is cancelled.
 999:      ''' When the LSB of n is 1, the user-de?ned character set is selected.
1000:      ''' • Only the LSB of n is applicable.
1001:      ''' • When the user-de?ned character set is cancelled, the internal character set is automatically selected.
1002:      ''' n=0
1003:      ''' </summary>
1004:      ''' <param name="n">0 ? n ? 255</param>
1005:      Shared Sub CMDcharset_SelectCancel_user_de?ned_character_set(ByVal n As Integer)
1006:          Dim X() As Byte = {&H1B, &H25, CByte(n)}
1007:          Port.Write(X)
1008:      End Sub
1009:   
1010:      ''' <summary>
1011:      ''' Cancels user-de?ned characters.
1012:      ''' • This command cancels the pattern de?ned for the character code speci?ed by n. After the user-de?ned character is cancelled, the corresponding pattern for the internal character is printed.
1013:      ''' • This command deletes the pattern de?ned for the speci?ed character code in the font selected by $1B $21.
1014:      '''  • If the user-de?ned character has not been de?ned for the speci?ed character code, the printer ignores this command.
1015:      ''' </summary>
1016:      ''' <param name="n">32 ? n ? 126</param>
1017:      Shared Sub CMDcharset_Cancel_UserDde?ned_characters(ByVal n As Integer)
1018:          Dim X() As Byte = {&H1B, &H3F, CByte(n)}
1019:          Port.Write(X)
1020:      End Sub
1021:   
1022:      ''' <summary>
1023:      ''' Selects the international character 
1024:      ''' </summary>
1025:      ''' <param name="n">0 ? n ? 10</param>
1026:      Shared Sub CMDcharset_Select_international_character_set(ByVal n As Integer)
1027:          Dim X() As Byte = {&H1B, &H52, CByte(n)}
1028:          Port.Write(X)
1029:      End Sub
1030:   
1031:      ''' <summary>
1032:      '''0 0 (PC437 [U.S.A., Standard Europe])
1033:      '''2 2 (PC850 [Multilingual])
1034:      '''3 3 (PC860 [Portuguesel])
1035:      '''4 4 (PC863 [Canadian-French])
1036:      '''5 5 (PC865 [Nordic])
1037:      '''19 19 (PC858 for Euro symbol at position 213))
1038:      '''255 Space page
1039:      ''' </summary>
1040:      ''' <param name="n">n = 0, 2, 3, 4, 5, 19, 255</param>
1041:      Shared Sub CMDcharset_Select_character_code_table(ByVal n As Integer)
1042:          Dim X() As Byte = {&H1B, &H74, CByte(n)}
1043:          Port.Write(X)
1044:      End Sub
1045:   
1046:      Shared Sub CMDcharset_SetCancel_UpsideDown_character_printing(ByVal n As Integer)
1047:          Dim X() As Byte = {&H1B, &H7E, CByte(n)}
1048:          Port.Write(X)
1049:      End Sub
1050:   
1051:  #End Region
1052:   
1053:  #Region "Position"
1054:      ''' <summary>
1055:      ''' Sets the distance from the beginning of the line to the position at which subsequent characters are to be printed.
1056:      ''' The distance from the beginning of the line to the print position is [(nL + nH ? 256) ? (vertical or horizontal motion unit)] inches.
1057:      ''' • Settings outside the speci?ed printable area are ignored.
1058:      ''' • The horizontal and vertical motion unit are speci?ed by $1D $50 or $1D $D0.
1059:      ''' • $1D $50 or $1D $D0 can change the horizontal (and vertical) motion unit.
1060:      ''' However, the value cannot be less than the minimum horizontal movement amount.
1061:      ''' • In standard mode, the horizontal motion unit (x) is used.
1062:      ''' • If the setting is outside the printing area width, it sets the absolute print position, but the left or right margin is set at default value.
1063:      ''' </summary>
1064:      ''' <param name="nL">0 ? nL ? 255</param>
1065:      ''' <param name="nH">0 ? nH ? 255</param>
1066:      Shared Sub CMDposition_Set_absolute_position(ByVal nL As Integer, ByVal nH As Integer)
1067:          Dim X() As Byte = {&H1B, &H24, CByte(nL), CByte(nH)}
1068:          Port.Write(X)
1069:      End Sub
1070:   
1071:      ''' <summary>
1072:      ''' • n speci?es the column number for setting a horizontal tab position calculated from the beginning of the line.
1073:      ''' k indicates the total number of horizontal tab positions to be set.
1074:      ''' $1B $44 $00 cancels all horizontal tab positions.
1075:      '''      </summary>
1076:      ''' <param name="n">1 ? n ? 255, 0 ? k ? 32</param>
1077:      Shared Sub CMDposition_Set_horizontal_tab_positions(ByVal ParamArray n() As Integer)
1078:          Dim X0() As Byte = {&H1B, &H44}
1079:          Dim X1(UBound(n, 1)) As Byte
1080:          Dim X2() As Byte = {&H0}
1081:          For i As Integer = 0 To UBound(n, 1)
1082:              X1(1) = CByte(n(i))
1083:          Next
1084:          Port.Write(X0)
1085:          Port.Write(X1)
1086:          Port.Write(X2)
1087:      End Sub
1088:   
1089:      ''' <summary>
1090:      ''' Sets the print starting position based on the current position by using the horizontal or vertical motion unit.
1091:      ''' Sets the distance from the current position to [(nL+ nH ? 256) ? (horizontal or vertical motion unit)].
1092:      ''' • Any setting that exceeds the printable area is ignored.
1093:      '''• When the starting position is speci?ed by n motion units to the right:
1094:      '''nL + nH * 256 = n
1095:      '''When the starting position is speci?ed by n motion units to the left (negative direction), use the complement of 65536:
1096:      '''nL + nH * 256 = 65536 – n
1097:      '''• If setting exceeds the printing area width, the left or right margin is set to the default value.
1098:      '''• The horizontal and vertical motion unit are speci?ed by $1D $50 or $1D $D0.
1099:      '''• $1D $50 or $1D $D0 can change the horizontal (and vertical) motion units. However, the value cannot be less than the minimum horizontal movement amount.
1100:      '''• In standard mode, the horizontal motion unit is used.
1101:      ''' </summary>
1102:      ''' <param name="nL">0 ? nL ? 255</param>
1103:      ''' <param name="nH">0 ? nH ? 255</param>
1104:      Shared Sub CMDposition_Set_relative_print_position_2(ByVal nL As Integer, ByVal nH As Integer)
1105:          Dim X() As Byte = {&H1B, &H5C, CByte(nL), CByte(nH)}
1106:          Port.Write(X)
1107:      End Sub
1108:   
1109:      ''' <summary>
1110:      ''' Aligns all data in one line to the speci?ed position. n selects the type of justi?cation as follows:
1111:      '''     n Justi?cation
1112:      '''     0, 48Flush left
1113:      '''     1, 49Centered
1114:      '''     2, 50Flush right
1115:      '''• This command is only enabled when inserted at the beginning of a line.
1116:      '''• Lines are justi?ed within the speci?ed printing area.
1117:      '''• Spaces set by HT, ESC $ and ESC \ will be justi?ed according to the previously-entered mode.
1118:      ''' </summary>
1119:      ''' <param name="n">0 ? n ? 2, 48 ? n ? 50</param>
1120:      Shared Sub CMDposition_Select_justi?cation(ByVal n As Integer)
1121:          Dim X() As Byte = {&H1B, &H61, CByte(n)}
1122:          Port.Write(X)
1123:      End Sub
1124:   
1125:      ''' <summary>
1126:      ''' • Set the absolute vertical print starting position for buffer character data in page mode.
1127:      '''• This command sets the absolute print position to [( nL + nH x 256) x (vertical or horizontal motion unit)] inches.
1128:      '''• This command is effective only in page mode.
1129:      '''• If the [( nL + nH x 256) x (vertical or horizontal motion unit)] exceeds the speci?ed printing area, this command is ignored.
1130:      '''• The horizontal starting buffer position does not move.
1131:      '''• The reference starting position is that speci?ed by $1B $54.
1132:      '''• This command operates as follows, depending on the starting position of the printing area speci?ed by $1B $54:
1133:      '''1) When the starting position is set to the upper left or lower right, this command sets the absolute position in the vertical direction.
1134:      ''' 2) When the starting position is set to the upper right or lower left, this command sets the absolute position in the horizontal direction.
1135:      '''• The horizontal and vertical motion unit are speci?ed by $1D $50.
1136:      '''• The $1D $50 command can change the horizontal and vertical motion unit. However, the value cannot be less than the minimum horizontal movement amount, and it must be in even units of the minimum horizontal movement amount.
1137:      ''' </summary>
1138:      ''' <param name="nL">0 ? nL ? 255, 0 ? nH ? 255</param>
1139:      ''' <param name="nH">0 ? nL ? 255, 0 ? nH ? 255</param>
1140:      Shared Sub CMDposition_Set_absolute_vertical_print_position_in_page_mode(ByVal nL As Integer, ByVal nH As Integer)
1141:          Dim X() As Byte = {&H1D, &H21, CByte(nL), CByte(nH)}
1142:          Port.Write(X)
1143:      End Sub
1144:   
1145:      ''' <summary>
1146:      ''' Sets the left margin.
1147:      ''' • The left margin is set to [(nL + nH * 256) * (horizontal motion unit)] inches.
1148:      ''' • This command is enabled only if set at the beginning of the line.
1149:      '''• If the setting exceeds the printable area, the maximum value of the printable area is used.
1150:      '''• If the left margin + printing area width is greater than the printable area, the printing area width is set at maximum value.
1151:      '''• The horizontal and vertical motion unit are speci?ed by $1D $50 or $1D $D0. Changing the horizontal or vertical motion unit does not affect the current left margin.
1152:      '''• The $1D $50 or $1D $D0 command can change the horizontal (and vertical) motion unit.
1153:      '''• However, the value cannot be less than the minimum horizontal movement amount and it must be in even units of the minimum horizontal movement amount.
1154:      ''' </summary>
1155:      ''' <param name="aL">0 ? nL, nH ? 255</param>
1156:      ''' <param name="aH">0 ? nL, nH ? 255</param>
1157:      Shared Sub CMDposition_Set_left_margin(ByVal aL As Integer, ByVal aH As Integer)
1158:          Dim X() As Byte = {&H1D, &H4C, CByte(aL), CByte(aH)}
1159:          Port.Write(X)
1160:      End Sub
1161:   
1162:      ''' <summary>
1163:      ''' • Sets the relative vertical print starting position from the current position in page mode.
1164:      '''• This command sets the distance from the current position to [(nL + nH x 256) x vertical or horizontal motion unit] inches.
1165:      '''• This command is ignored unless page mode is selected.
1166:      '''• When N is speci?ed to the movement downward:
1167:      '''nL + nH x 256 = N
1168:      '''• When N is speci?ed to the movement upward (the negative direction), use the complement of 65536.
1169:      '''• When N is speci?ed to the movement upward:
1170:      '''nL + nH x 256 = 65536 - N
1171:      '''• Any setting that exceeds the speci?ed printing area is ignored.
1172:      '''• This command function as follows, depending on the print starting position set by $1B $54:
1173:      '''1) When the starting position is set to the upper left or lower right of the printing, the vertical motion unit (y) is used.
1174:      '''2) When the starting position is set to the upper right or lower left of the printing area, the horizontal motion unit (x) is used.
1175:      '''• The horizontal and vertical motion unit are speci?ed by $1D $50.
1176:      '''• The $1D $50 command can change the horizontal (and vertical) motion unit. However, the value cannot be less than the minimum horizontal movement amount, and it must be in even units of the minimum horizontal movement amount.
1177:      ''' </summary>
1178:      ''' <param name="nL">0 ? nL ? 255, 0 ? nH ? 255</param>
1179:      ''' <param name="nH">0 ? nL ? 255, 0 ? nH ? 255</param>
1180:      Shared Sub CMDposition_Set_relative_print_position(ByVal nL As Integer, ByVal nH As Integer)
1181:          Dim X() As Byte = {&H1D, &H5C, CByte(nL), CByte(nH)}
1182:          Port.Write(X)
1183:      End Sub
1184:   
1185:  #End Region
1186:   
1187:  #Region "BarCode"
1188:   
1189:      ''' <summary>
1190:      ''' Selects the printing position of HRI characters when printing bar codes. n selects the printing positions as follows:
1191:      ''' 0,48 Not printed
1192:      ''' 1,49 Above the bar code
1193:      ''' 2,50 Below the bar code
1194:      ''' 3,51 Both above the below the bar code
1195:      ''' • HRI characters are printed using the font speci?ed by $1D $66.
1196:      ''' </summary>
1197:      ''' <param name="n">0 ? n ? 3, 48 ? n ? 51</param>
1198:      Shared Sub CMDbarcode_Select_printing_position_of_HRI_characters(ByVal n As Integer)
1199:          Dim X() As Byte = {&H1D, &H48, CByte(n)}
1200:          Port.Write(X)
1201:      End Sub
1202:   
1203:      ''' <summary>
1204:      ''' Selects a font for the HRI characters used when printing a bar code. n selects a font from the following table:
1205:      '''0, 48 Font(A)
1206:      '''1,49  Font(B)
1207:      '''HRI characters are printed at the position speci?ed by $1D $48.
1208:      ''' </summary>
1209:      ''' <param name="n">n = 0, 1, 48, 49</param>
1210:      Shared Sub CMDbarcode_Select_font_for_HRI_characters(ByVal n As Integer)
1211:          Dim X() As Byte = {&H1D, &H66, CByte(n)}
1212:          Port.Write(X)
1213:      End Sub
1214:   
1215:      ''' <summary>
1216:      ''' Sets the height of the bar code. n speci?es the number of vertical dots.
1217:      ''' </summary>
1218:      ''' <param name="n">1 ? n ? 255, n = 162 ( 20.25 mm )</param>
1219:      Shared Sub CMDbarcode_Select_height_of_bar_code(ByVal n As Integer)
1220:          Dim X() As Byte = {&H1D, &H68, CByte(n)}
1221:          Port.Write(X)
1222:      End Sub
1223:   
1224:      ''' <summary>
1225:      ''' Sets the horizontal size of the bar code. n speci?es the bar code width as follows:
1226:      '''n Module width ( mm )
1227:      '''1 0.125
1228:      '''2 0.25
1229:      '''3 0.375
1230:      '''4 0.5
1231:      '''5 0.625
1232:      '''6 0.75
1233:      ''' </summary>
1234:      ''' <param name="n">1?n?6</param>
1235:      Shared Sub CMDbarcode_Set_bar_code_width(ByVal n As Integer)
1236:          Dim X() As Byte = {&H1D, &H77, CByte(n)}
1237:          Port.Write(X)
1238:      End Sub
1239:   
1240:   
1241:  #End Region
1242:   
1243:  #Region "Macro"
1244:   
1245:      ''' <summary>
1246:      ''' Starts or ends macro de?nition.
1247:      '''• Macro de?nition starts when this command is received during normal operation.
1248:      '''• When $1D $5E is received during macro de?nition, the printer ends macro de?nition and clears all de?nitions.
1249:      '''• Macros are not de?ned when power is turned on to the machine.
1250:      '''• Macro content is not cancelled by the $1B $40 command. Therefore, $1B $40 may be included in the content of macro de?nitions.
1251:      '''• If the printer receives $1D $3A a second time after previously receiving $1D $3A, the printer remains in macro unde?ned status.
1252:      ''' • The contents of the macro can be de?ned up to 1024 bytes. If the macro de?nition exceeds 1024 bytes, excess data is not stored.
1253:      ''' </summary>
1254:      Shared Sub CMDmacro_Set_StartEnd_of_macro_de?nition()
1255:          Dim X() As Byte = {&H1D, &H3A}
1256:          Port.Write(X)
1257:      End Sub
1258:   
1259:      ''' <summary>
1260:      ''' Executes a macro.
1261:      '''• r speci?es the number of times to execute the macro.
1262:      '''• t speci?es the waiting time for executing the macro.
1263:      '''The waiting time is t * 100 msec. for each macro execution.
1264:      '''• m speci?es macro executing mode:
1265:      '''When the LSB of m = 0, the macro is executed r times continuously at the interval speci?ed by t.
1266:      '''When the LSB of m = 1, after waiting for the period speci?ed by t, the LED indicator blinks and the printer waits for the FEED button to be pressed. After the button is pressed, the printer executes the macro once. The printer repeats the operation r times.
1267:      '''[Notes] • This command has an interval of (t * 100 msec.) after a macro is executed by t.
1268:      '''• If this command is received while a macro is being de?ned, the macro de?nition is aborted and the de?nition is cleared.
1269:      '''• If the macro is not de?ned or if r is 0, nothing is executed.
1270:      '''• When the macro is executed by pressing the FEED button (m=1), the paper cannot be fedusing the FEED button.
1271:      ''' </summary>
1272:      ''' <param name="r">0 ? r, t ? 255</param>
1273:      ''' <param name="t">0 ? r, t ? 255</param>
1274:      ''' <param name="m">0?m?1</param>
1275:      Shared Sub CMDmacro_Execute_macro(ByVal r As Integer, ByVal t As Integer, ByVal m As Integer)
1276:          Dim X() As Byte = {&H1D, &H5E, CByte(r), CByte(t), CByte(m)}
1277:          Port.Write(X)
1278:      End Sub
1279:  #End Region
1280:   
1281:  #Region "Image"
1282:   
1283:      ''' <summary>
1284:      ''' Print graphic bank (608 x 862 dots).
1285:      ''' 1 Print logo 1 from ?ash bank
1286:      ''' 2 Print logo 2 from ?ash bank
1287:      ''' xL + xH * 256 speci?es the starting dotline ( 1 ? 862).
1288:      ''' yL + yH * 256 speci?es the number of lines to print.
1289:      ''' • If (xL + (xH * 256)) > 862 the printer does not execute the command.
1290:      ''' • If ( xL + ( xH * 256 ) + yL +( yH * 256 ))> 862 the printer prints only 862 - xL + ( xH * 256 ) +1 dotline.
1291:      ''' • If the logo has been previously saved in the ?ash bank it will be printed correctly. If not a “NAK” ($15) will be returned.
1292:      ''' </summary>
1293:      ''' <param name="n">1?n?2</param>
1294:      ''' <param name="xH">0 ? xH, xL, yH, yL ? 255</param>
1295:      ''' <param name="xL">0 ? xH, xL, yH, yL ? 255</param>
1296:      ''' <param name="yH">0 ? xH, xL, yH, yL ? 255</param>
1297:      ''' <param name="yL">0 ? xH, xL, yH, yL ? 255</param>
1298:      Shared Sub CMDimage_Print_graphic(ByVal n As Integer, ByVal xH As Integer, ByVal xL As Integer, ByVal yH As Integer, ByVal yL As Integer)
1299:          Dim X() As Byte = {&H1B, &HFA, CByte(n), CByte(xH), CByte(xL), CByte(yH), CByte(yL)}
1300:          Port.Write(X)
1301:      End Sub
1302:   
1303:      ''' <summary>
1304:      '''ONLY_FOR_SERIAL_For_this_command_set_the_comunication__protocol_as_“”Hardware””
1305:      ''' Riceive [nL + (nH * 256)] word from the comunication port and save them in the ?ash bank speci?ed by n as shown in the following table:
1306:      ''' 1 Save logo in the ?ash bank 1
1307:      ''' 2 Save logo in the ?ash bank 2
1308:      ''' • Set the comunication protocol on “Hardware” for this command.
1309:      ''' • The number of received data bytes is [nL + (nH * 256)] * 2.
1310:      ''' • Every word is received ?rst as MSByte and then as LSByte.
1311:      ''' • If [nL + (nH * 256)] is more than 32756, the following data are processed as normal data.
1312:      ''' • In the horizontal dotline there are 38 words.
1313:      ''' • The ?ash bank for graphic print dimensions are: 608 horizontal dots (76 bytes/line) * 862 vertical dots (65512 bytes).
1314:      ''' </summary>
1315:      ''' <param name="n"> 1?n?2</param>
1316:      ''' <param name="nH">0 ? nL, nH ? 255</param>
1317:      ''' <param name="nL">0 ? nL, nH ? 255</param>
1318:      Shared Sub CMDimage_Receive_graphic_page_from_communication_port(ByVal n As Integer, ByVal nL As Integer, ByVal nH As Integer)
1319:          Dim X() As Byte = {&H1B, &HFF, CByte(n), CByte(nL), CByte(nH)}
1320:          Port.Write(X)
1321:      End Sub
1322:   
1323:      ''' <summary>
1324:      ''' Prints graphic logo in the graphic page
1325:      ''' Allow graphic logo parts selection and coordinates of the graphic page point input for the graphic logo part printing.
1326:      '''(xl,yl) = graphic logo point coordinates;
1327:      '''xl = xlL + (xlH * 256) ; yl = ylL + (ylH * 256)
1328:      '''dx = horizontal dimension of the graphic logo part which must be printed:
1329:      '''dx = dxL + (dxH * 256)
1330:      '''dy = vertical dimension of the graphic logo part which must be printed:
1331:      '''dy = dyL + (dyH * 256)
1332:      '''(x,y) = coordinates of the graphic page point where must be printed the graphic logo part:
1333:      '''x = xL + (xH * 256) ; y = yL + (yH * 256)
1334:      '''num = parameter for the graphic logo selection between the two logos available.
1335:      '''dx + xl ? 608
1336:      '''dx + x ? 608
1337:      '''dy + yl ? 862
1338:      ''' </summary>
1339:      ''' <param name="num">0 ? num ? 1</param>
1340:      Shared Sub CMDimage_Select_logo_share_and_print_it_in_any_graphic_page_point(ByVal xH As Integer, ByVal xL As Integer, ByVal yH As Integer, ByVal yL As Integer, ByVal dxH As Integer, ByVal dxL As Integer, _
1341:     ByVal dyH As Integer, ByVal dyL As Integer, ByVal xLH As Integer, ByVal xLL As Integer, ByVal yLH As Integer, ByVal yLL As Integer, ByVal num As Integer)
1342:          Dim X() As Byte = {&H1C, &HC0, CByte(xH), CByte(xL), CByte(yH), CByte(yL), CByte(dxH), CByte(dxL), CByte(dyH), CByte(dyL), CByte(xLH), CByte(xLL), CByte(yLH), CByte(yLL), CByte(num)}
1343:          Port.Write(X)
1344:      End Sub
1345:   
1346:      ''' <summary>
1347:      '''0,48 Normal
1348:      '''1,49 Double-width
1349:      '''2,50 Double-height
1350:      '''3,51 Quadruple
1351:      ''' • This command is ignored if a downloaded bit image has not been de?ned.
1352:      '''• In standard mode, this command is effective only when there is no data in the print buffer.
1353:      '''• This command has no effect in the print modes (emphasized, underline, character size, or white/black reverse printing), except for upside-down printing mode.
1354:      '''• If the downloaded bit-image to be printed exceeds the printable area, the excess data is not printed
1355:      '''• If the printing area width set by $1D $4C and $1D $57 is less than one line in vertical, the following processing is performed only on the line in question:
1356:      '''1) The printing area width is extended to the right up to one line in vertical. In this case, printing does not exceed the printable area.
1357:      '''2) If the printing area width cannot be extended by one line in vertical, the left margin isreduced to accommodate one line in vertical.
1358:      ''' </summary>
1359:      Shared Sub CMDimage_Print_downloaded_bit_image(ByVal n As Integer)
1360:          Dim X() As Byte = {&H1D, &H2F, CByte(n)}
1361:          Port.Write(X)
1362:      End Sub
1363:   
1364:  #End Region
1365:   
1366:  #Region "Unsupported command"
1367:      ''' <summary>
1368:      ''' De?nes a downloaded bit image using the number of dots speci?ed by x and y.
1369:      ''' • x speci?es the number of dots in the horizontal direction.
1370:      ''' • y speci?es the number of dots in the vertical direction.
1371:      ''' • The number of dots in the horizontal direction is x x 8, in the vertical direction it is y x 8.
1372:      ''' • If x x y is out of the speci?ed range, this command is disabled.
1373:      ''' • The d indicates bit-image data. Data ( d) speci?es a bit printed to 1 and not printed to 0.
1374:      ''' • The downloaded bit image de?nition is cleared when:
1375:      ''' 1) $1B $40 is executed.
1376:      ''' 2) $1B $26 is executed.
1377:      ''' Printer is reset or the power is turned off.
1378:      ''' • The following ?gure shows the relationship between the downloaded bit image and the printed data.
1379:      ''' </summary>
1380:      Shared Sub _CMDimage_De?ne_downloaded_bit_image()
1381:          '&H1D &H2A x y d1...d(x x y x 8)
1382:   
1383:      End Sub
1384:   
1385:      ''' <summary>
1386:      ''' unsupported
1387:      ''' </summary>
1388:      Shared Sub _CMDimage_Print_raster_image()
1389:          '&H1D &H76 &H30 m xL xH yL yH d1...dk
1390:   
1391:      End Sub
1392:   
1393:      ''' <summary>
1394:      ''' m = 0, 1, 32, 33
1395:      ''' 0 ? nL ? 255
1396:      ''' 0 ? d ? 255
1397:      ''' Selects a bit image mode using m for the number of dots speci?ed by nL and nH, as follows:
1398:      ''' </summary>
1399:      Shared Sub _CMDimage_Select_image_print_mode()
1400:          '&H1B &H2A m nL nH d1...dk
1401:      End Sub
1402:   
1403:      ''' <summary>
1404:      ''' y=3
1405:      ''' 32 ? c1 ? c2 ? 126
1406:      ''' 0 ? x ? 16 (Font ( 18 * 24))
1407:      ''' 0 ? x ? 13 (Font 14 * 24)
1408:      ''' 0 ? x ? 10 (Font 10 * 24)
1409:      ''' 0 ? d1 … d (y * xk) ? 255
1410:      ''' k = c2 – c1 + 1
1411:      ''' De?nes user-de?ned characters.
1412:      ''' Y speci?es the number of bytes in the vertical direction.
1413:      ''' C1 speci?es the beginning character code for the de?nition, and C2 speci?es the ?nal code.
1414:      ''' X speci?es the number of dots in the horizontal direction.
1415:      ''' • The allowable character code range is from ASCII $20 (32) to $7E (126) (95 characters).
1416:      ''' • It is possible to de?ne multiple characters for consecutive character codes. If only one cha racter is desired, use c1 = c2.
1417:      ''' </summary>
1418:      ''' <remarks></remarks>
1419:      Shared Sub _CMDcharset_De?ne_UserDe?ned_characters()
1420:          '&H1B &H26 y c1 c2
1421:      End Sub
1422:   
1423:   
1424:      ''' <summary>
1425:      ''' look to documentation
1426:      ''' </summary>
1427:      ''' <param name="m">0 ? m ? 20, 65 ? m ? 90</param>
1428:      Shared Sub _CMDbarcode_Print_bar_code(ByVal m As Integer)
1429:          '$1D $6B m [d1...dk] $00 $1D $6B m [d1...dn]
1430:      End Sub
1431:   
1432:  #End Region
1433:   
1434:  End Class

Этот класс наследует мою низкоуровневую обвязку Port для работы с COM-портом, опубликованную мною тут - ComDetector - утилита поиска COM-оборудования.

В бинарном виде мой драйвер вы можете сгрузить отсюда.



Комментарии к этой страничке ( )
ссылка на эту страничку: http://www.vb-net.ru/Custom_VKP80/index.htm
<На главную>  <В раздел ASP>  <В раздел NET>  <В раздел SQL>  <В раздел Разное>  <Написать автору>  < Поблагодарить>