Technical Paper: Cassette Printer Driver Integration

Technical Paper: Cassette Printer Driver Integration
PRIMERA HEALTHCARE TECHNICAL DOCUMENT LIS Integration using Signature Cassette Printer Windows Printer Driver Version 1.1 October 28, 2014 INTRODUCTION This document will focus on connecting the printer to your LIS via the Signature Cassette Printer Windows Printer Driver. To see other ways to integrate the Signature printer into your LIS download Primera’s Cassette Printer Integration white paper at http://www.primerahealthcare.com/LISIntegration.html/ LIS Integration using Signature Cassette Printer Windows Printer Driver •
LIS software can use the cassette printer as a standard Windows raster‐based printer by utilizing the included Windows XP/Vista/7/8 printer driver. This printer driver is included at no extra charge with every Signature Cassette Printer. •
Cassette images generated by the LIS are sent via standard Windows APIs to the printer. 2 SENDING A CASSETTE LABEL TO THE PRINTER Description: The windows print driver is a raster based print driver. LIS systems that already print to raster based print drivers can print to the Signature Cassette Printer. There may be a few changes required to the current template in order for the printing to work. Below is a list of requirement to print via the printer driver. Printing Requirements: •
Colors supported: black •
Printable area 4 Page Sizes: o
Size 1 = .236” x 1.01” o
Size 2 = .236” x 0.880” o
Size 3 = .293” x 1.01” o
Size 4 = .293” x 0.880” •
Page size can be changed via a SetPrinter call with appropriate changes made to the PRINTER_INFO_2 structure. The DEVMODE dmPaperSize should be updated for the correct page size requested. •
DPI: the rasterized DPI of the image should be 300 dpi; any higher resolution is not required and will only result in longer raster times. Printing Requirements (Cassette Printer with Autoloader): All of the previous requirements with the following changes • Cassette Source: o Manual – requires a cassette to be placed into the printer manually o Hopper #1 o Hopper #2 o Hopper #3 o Hopper #4 3 • Cassette Source can be changed via a SetPrinter call with appropriate changes made to the PRINTER_INFO_2 structure. The DEVMODE dmDefaultSource value should be changed for the Cassette Source requested. NOTE: Selecting a hopper that has the same cassette type as another hopper will not guarantee the autoloader will pick from that location. The driver sends down the cassette type to pick internally for improved performance and to continue printing if a hopper goes empty. To guarantee the autoloader will only pick from the desired hopper the cassette type should be different for each hopper location. OTHER COMMUNICATION Description: The Signature Cassette Printer will provide status and configuration values via the printer driver. An application can query this information using standard windows API calls. Communication Details: •
Current printer status such as error conditions, cover status, and firmware versions can be queried. •
Detailed supply status including ribbon and slide types and levels can be queried. 4 •
Example Code: public bool ReadBytesFromPrinter(string szPrinterName, Byte[] bytes, Int32 dwCount, ref Int32 dwBytes, string sKey) { bool bSuccess; // Assume failure unless you specifically succeed. Int32 type = 3; byte[] bData = new byte[2]; string sValue = sKey; const int numBytes = 1; const int setType = 3; bData[0] = 0; bData[1] = 0; int nRetries = 2; while (true) { // Open the printer. UInt32[] printDefaults = new UInt32[3]; printDefaults[2] = 0x04; IntPtr hPrinter; if (OpenPrinter(szPrinterName, out hPrinter, ref printDefaults[0])) { if (SetPrinterData(hPrinter, sValue, setType, ref bData[0], numBytes) == 0) { dwBytes = 0; if (GetPrinterData(hPrinter, sValue, ref type, ref bytes[0], dwCount, ref dwBytes) == 0)
{ bSuccess = true; ClosePrinter(hPrinter); break; } } Thread.Sleep(500); ClosePrinter(hPrinter); } Thread.Sleep(500); if (nRetries‐‐ <= 0) { bSuccess = false; break; } } return bSuccess; } Complete Status Structure The structure of the data returned from the printer is detailed in the table below. Status Structure Byte Offset Length Description ('' denotes ASCII Character) 0 1 Start Character (Value is always 0x1b)
1 1 Command Character (Value is always 0x04)
2 1 Number of bytes in message including this byte and checksum 3 1 Message Type (0x01 is a status message)
4 1 Product ID (Value is always 'O')
5 1 Record Number (Will increment with each request)
6 1 Model # 7 1 PGA Version Number
5 8 24 28 30 31 32 33 34 35 36 39 43 44 45 46 54 55 57 58 59 60 61 69 71 73 74 75 88 89 91 95 99 100 101 117 121 122 140 156 157 159 160 161 162 163 164 165 166 167 168 16 4 2 1 1 1 1 1 1 3 4 1 1 1 8 1 2 1 1 1 1 8 2 2 1 1 13 1 2 4 4 1 1 16 4 1 18 16 1 2 1 1 1 1 1 1 1 1 1 39 Firmware Version and Date Code
Firmware Checksum
System Error Value (See Table Below for possible values)
Head Lifter Status (Down = 0x81, Up = 0x80)
Media Sensor Value
OEM Number Print Status (Idle = 0x00, Cassette is IN = 0x01, Cassette Printed On = 0x20, Busy = 0x80)
Cover flag ('C' = Closed, 'O' = Open)
Setup Values (Internal Use Only)
USB Serial Number
Total # Cassettes printed
Ribbon color sensor value
Top of form offset
Horizontal offset
Setup Values (Internal Use Only)
System Busy Flag (Idle ='I', Busy = 'B, Powered Off = 'X')
Setup Values (Internal Use Only)
Printer Control Mode ( 1 = Preload Cassette, 0 = No Preload Cassette) Media Type (Invalid = 0x00, Cassette Type = 0x20, Not Installed = 0xFF) Ribbon Type ( Invalid = 0x00, Mono = 0x01, 4 Color = 0x04, Not Installed = 0xFF)
Print Speed Ribbon Serial Number
# of panels left on ribbon
Setup Values (Internal Use Only)
Black Print Heat Value
Color Print Heat Value
Setup Values (Internal Use Only)
Door Status (‘O’ = Open, ‘C’ = Closed, ‘X’ = In Error)
Setup Values (Internal Use Only)
Number of Mono Ribbons Used
Number of Color Ribbons Used
Cassette Load Mode ( 1 = Auto, 0 = Manual)
Cassette Load Mode Timer (.02 second interval)
Robot Firmware Version Number and Date
Robot Checksum of Firmware
Robot PGA Version
Robot Flipper Version
LCD Display Version
Robot Arm Status (Bits 0 – 2 = number of hopper cassette loaded from 1‐4, 0 = Idle, 0x80 = Busy)
Robot Errors (See Table Below for possible values)
Robot Cover Status (0 = Closed, 1 = Open)
Number of Cassettes in Hopper # 1 (0x80 = Hopper removed) Cassette Type String Position
Number of Cassettes in Hopper # 2 (0x80 = Hopper removed) Cassette Type String Position
Number of Cassettes in Hopper # 3 (0x80 = Hopper removed) Cassette Type String Position
Number of Cassettes in Hopper # 4 (0x80 = Hopper removed) Cassette Type String Position
Unused Space 6 207 Bit 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 Bit 0 1 2 3 4 5 6 7 8 9 10 11 12 1 Checksum of the command includes Bytes 0 (0x1b) and 1 (0x04) of the returned status
System Error Bit Field (Bytes 28 and 29) Description (More than 1 bit can be set) Head Lifter Error Invalid Ribbon Ribbon Advance Error Carrier Movement Error Paper Out Error Cassette Lost Error Robot Communication Error Tilt Table Movement Error Out of Ribbon Ribbon Break Detected Model Number Error Ribbon Contact Error Ribbon Jam Error Door Movement Error Head Loading Error Robot Error Bit Field (Bytes 157 and 158) Description (More than 1 bit can be set) Arm Flipper Error Arm Vertical Movement Error Arm Rotate Error Pick Error Arm Stall Cover Open Error Dropped Cassette Error Requested Cassette Type Is Out Cassette Type Not Installed Unknown Cassette Type Mismatch Cassette Hopper Not Installed Cassette Lost Error Commands The list of commands that can be sent to the printer and the corresponding command bytes are detailed in the table below. Commands can be sent to the printer in the following way: 7 public bool SendBytesToPrinter(string szPrinterName, IntPtr pBytes, Int32 dwCount)
{ IntPtr hPrinter; DOCINFOA di = new DOCINFOA(); bool bSuccess = false; // Assume failure unless you specifically succeed. di.pDocName = "Driver"; di.pDataType = "RAW"; // Open the printer. UInt32[] printDefaults = new UInt32[3]; printDefaults[2] = 0x04; if (OpenPrinter(szPrinterName, out hPrinter, ref printDefaults[0])) { // Start a document. if (StartDocPrinter(hPrinter, 1, di)) { // Start a page. if (StartPagePrinter(hPrinter)) { // Write your bytes. Int32 dwWritten; bSuccess = WritePrinter(hPrinter, pBytes, dwCount, out dwWritten); EndPagePrinter(hPrinter); } EndDocPrinter(hPrinter); } ClosePrinter(hPrinter); } // If you did not succeed, GetLastError may give more information // about why not. if (bSuccess == false) { Marshal.GetLastWin32Error(); } return bSuccess; } Raw Commands (Cassette Printer) Description Command Bytes (K = Checksum of command) Reset System 0x1b, 0x04, 0x05,0x00, 0x00, 0x00, 0x00,K Cassette Load and Eject Cycle 0x1b, 0x04, 0x0F, 0x00, 0x00, 0x00, 0x00,K Restore Factory Defaults 0x1b, 0x04, 0x15, 0x00, 0x00, 0x00, 0x00,K Firmware Update (Followed by Firmware File) 0x1b, 0x04, 0x07, 0x00, 0x00, 0x00, 0x00,K Toggle Head Lifter 0x1b, 0x04, 0x0A, 0x00, 0x00, 0x00, 0x00,K Ribbon Calibration 0x1b, 0x04, 0x10, 0x01, 0x00, 0x00, 0x00,K Raw Commands (Cassette Printer) Description Command Bytes (K = Checksum of command) Raw Commands (Cassette Printer Autoloader) Reset System 0x1b, 0x05, 0x05,0x00, 0x00, 0x00, 0x00,K Firmware Update (Followed by Firmware File) 0x1b, 0x05, 0x07, 0x00, 0x00, 0x00, 0x00,K Restore Factory Defaults 0x1b, 0x05, 0x15, 0x00, 0x00, 0x00, 0x00,K Set Hopper Cassette Type 0x1b, 0x05, 0x09, H1, H2, H3, H4, K H1 = Hopper 1 Cassette Type (1 – 16) H2 = Hopper 2 Cassette Type (1 – 16) H3 = Hopper 3 Cassette Type (1 – 16) H4 = Hopper 4 Cassette Type (1 – 16) 8 CASSETTE TYPE DESCRIPTIONS (AUTOLOADER) NOTE: Pages 2 & 3 are the only pages in the cassette printer flash that should be addressed when storing or requesting stored data. Trying to store data in other pages than defined below could cause unexpected and possibly unrecoverable results. ** DO NOT ADDRESS OTHER PAGES AS THEY ARE FOR INTERNAL SYSTEM USE ONLY. ** Description: The cassette type descriptions are stored inside the cassette printer’s flash memory in pages 2 & 3. The descriptions are stored starting with the cassette type 1 description followed by 2 and so on up to cassette type 16. Each cassette type description has a max of 20 characters followed by a ‘$’ character and a carriage return line feed (CRLF) ending. If the cassette type descriptions contain more characters than will fit in the flash page 2 data space you will have to manage flash page 3 in addition to page 2. Store Flash Page Data Command: 0x1b, 0x04, 0x11, p, 0x00, 0x00, 0x00, K, <FlashData> See Flash Memory Page Format Below p = Page address should be 2 or 3 only k = checksum of the command <FlashData> FLASH MEMORY PAGE FORMAT: 0 0x01 1 Start character. START OF DATA BLOCK: 1 nn 2 # of bytes in message including this one and checksum. 3 C 1 Record Type: C 4 P 1 Page # being sent. 5‐260 256 Page of data from FLASH memory. END OF DATA BLOCK 261 ck 1 Checksum of the data block. 262 0x04 1 End character: Here is an example of cassette types 1 – 10 that we would like to store in the printer. “Type WHITE” is cassette type 1 and “STRING 10” is cassette type 10. Again each description is followed by a ‘$’ character and a carriage return line feed (CRLF) ending. Type WHITE$ Type RED$ Type GREEN$ Type YELLOW$ STRING 5$ STRING 6$ STRING 7$ STRING 8$ STRING 9$ STRING 10$ 9 The following bytes would be generated and sent to store the above type descriptions in flash page 2 on the cassette printer: Request Flash Page Data Command: 0x1b, 0x04, 0x12, p, 0x00, 0x00, 0x00, K p 1 Page address 2 or 3. K 1 Checksum of command. <FLASH DATA> See Flash Memory Page Format Above (returned by an immediate read from printer) NOTE: Pages 2 & 3 are the only pages in the cassette printer flash that should be addressed when storing or requesting stored data. Trying to store data in other pages than defined above could cause unexpected and possibly unrecoverable results. ** DO NOT ADDRESS OTHER PAGES AS THEY ARE FOR INTERNAL SYSTEM USE ONLY. ** 10 
Was this manual useful for you? yes no
Thank you for your participation!

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Download PDF

advertisement