📄 dj9xx.cpp
字号:
}} //MandatoryPaperSizeDISPLAY_STATUS DJ9xx::ParseError(BYTE status_reg){ DBG1("DJ9XX, parsing error info\n"); DRIVER_ERROR err = NO_ERROR; BYTE DevIDBuffer[DevIDBuffSize]; char *pStr; if(IOMode.bDevID) { // If a bi-di cable was plugged in and everything was OK, let's see if it's still // plugged in and everything is OK err = pSS->GetDeviceID (DevIDBuffer, DevIDBuffSize, TRUE); if(err != NO_ERROR) { // job was bi-di but now something's messed up, probably cable unplugged return DISPLAY_COMM_PROBLEM; } if ( (pStr=(char *)strstr((const char*)DevIDBuffer+2,"VSTATUS:")) == NULL ) { return DISPLAY_COMM_PROBLEM; } pStr+=8; // skip "VSTATUS:" // Paper Jam or Paper Stall if (strstr((char*)pStr,"PAJM") || strstr((char*)pStr,"PAPS")) { return DISPLAY_PAPER_JAMMED; } // Carriage Stall if (strstr((char*)pStr,"CARS")) { return DISPLAY_ERROR_TRAP; } if (strstr((char*)pStr,"OOPA")) // OOP state { DBG1("Out of Paper [from Encoded DevID]\n"); return DISPLAY_OUT_OF_PAPER; } // Job Cancelled (AIO printer turn idle after job canceled) if (strstr((char*)pStr,"CNCL")) // CNCL state { DBG1("Printing Canceled [from Encoded DevID]\n"); return DISPLAY_PRINTING_CANCELED; } if ( TopCoverOpen(status_reg) ) { DBG1("Top Cover Open\n"); return DISPLAY_TOP_COVER_OPEN; } // VerifyPenInfo will handle prompting the user // if this is a problem err = VerifyPenInfo(); if(err != NO_ERROR) // VerifyPenInfo returned an error, which can only happen when ToDevice // or GetDeviceID returns an error. Either way, it's BAD_DEVICE_ID or // IO_ERROR, both unrecoverable. This is probably due to the printer // being turned off during printing, resulting in us not being able to // power it back on in VerifyPenInfo, since the buffer still has a // partial raster in it and we can't send the power-on command. return DISPLAY_COMM_PROBLEM; } // check for errors we can detect from the status reg if (IOMode.bStatus) { if ( DEVICE_IS_OOP(status_reg) ) { DBG1("Out Of Paper\n"); return DISPLAY_OUT_OF_PAPER; } if (DEVICE_PAPER_JAMMED(status_reg)) { DBG1("Paper Jammed\n"); return DISPLAY_PAPER_JAMMED; } if (DEVICE_IO_TRAP(status_reg)) { DBG1("IO trap\n"); return DISPLAY_ERROR_TRAP; } } // don't know what the problem is- // Is the PrinterAlive? if (pSS->PrinterIsAlive()) { iTotal_SLOW_POLL_Count += iMax_SLOW_POLL_Count;#if defined(DEBUG) && (DBG_MASK & DBG_LVL1) printf("iTotal_SLOW_POLL_Count = %d\n",iTotal_SLOW_POLL_Count);#endif // -Note that iTotal_SLOW_POLL_Count is a multiple of // iMax_SLOW_POLL_Count allowing us to check this // on an absolute time limit - not relative to the number // of times we happen to have entered ParseError. // -Also note that we have different thresholds for uni-di & bi-di. if( ((IOMode.bDevID == FALSE) && (iTotal_SLOW_POLL_Count >= 60)) || ((IOMode.bDevID == TRUE) && (iTotal_SLOW_POLL_Count >= 120)) ) return DISPLAY_BUSY; else return DISPLAY_PRINTING; } else return DISPLAY_COMM_PROBLEM;}DRIVER_ERROR DJ9xx::VerifyPenInfo(){ DRIVER_ERROR err=NO_ERROR; if(IOMode.bDevID == FALSE) return err; err = ParsePenInfo(ePen); if(err == UNSUPPORTED_PEN) // probably Power Off - pens couldn't be read { DBG1("DJ9xx::Need to do a POWER ON to get penIDs\n"); // have to delay for DJ9xx or the POWER ON will be ignored if (pSS->BusyWait((DWORD)2000) == JOB_CANCELED) return JOB_CANCELED; DWORD length=sizeof(Venice_Power_On); err = pSS->ToDevice(Venice_Power_On,&length); ERRCHECK; err = pSS->FlushIO(); ERRCHECK; // give the printer some time to power up if (pSS->BusyWait ((DWORD) 2500) == JOB_CANCELED) return JOB_CANCELED; err = ParsePenInfo(ePen); } ERRCHECK; // check for the normal case if (ePen == BOTH_PENS) return NO_ERROR; while ( ePen != BOTH_PENS ) { switch (ePen) { case BLACK_PEN: // black pen installed, need to install color pen pSS->DisplayPrinterStatus(DISPLAY_NO_COLOR_PEN); break; case COLOR_PEN: // color pen installed, need to install black pen pSS->DisplayPrinterStatus(DISPLAY_NO_BLACK_PEN); break; case NO_PEN: // neither pen installed default: pSS->DisplayPrinterStatus(DISPLAY_NO_PENS); break; } if (pSS->BusyWait(500) == JOB_CANCELED) return JOB_CANCELED; err = ParsePenInfo(ePen); ERRCHECK; } pSS->DisplayPrinterStatus(DISPLAY_PRINTING); return NO_ERROR;}DRIVER_ERROR DJ9xx::ParsePenInfo(PEN_TYPE& ePen, BOOL QueryPrinter){ char *str; DRIVER_ERROR err = SetPenInfo (str, QueryPrinter); ERRCHECK; if (*str != '$') { //Escher+ is having Aladdin style devid string. int num_pens = 0; PEN_TYPE temp_pen1 = NO_PEN; BYTE penInfoBits[4]; int iNumMissingPens = 0; // the first byte indicates how many pens are supported if ((str[0] >= '0') && (str[0] <= '9')) { num_pens = str[0] - '0'; } else if ((str[0] >= 'A') && (str[0] <= 'F')) { num_pens = 10 + (str[0] - 'A'); } else { return BAD_DEVICE_ID; } if ((int) strlen (str) < (num_pens * 8)) { return BAD_DEVICE_ID; } // Aladdin style DevID if (pSS->GetVIPVersion () == 1) { if (num_pens < 2) { return UNSUPPORTED_PEN; } // parse pen1 (should be black) AsciiHexToBinary(penInfoBits, str+1, 4); penInfoBits[1] &= 0xf8; // mask off ink level trigger bits if ((penInfoBits[0] == 0xc1) && (penInfoBits[1] == 0x10)) { // Hobbes temp_pen1 = BLACK_PEN; } else if (penInfoBits[0] == 0xc0) { // missing pen temp_pen1 = NO_PEN; iNumMissingPens = 1; } else { return UNSUPPORTED_PEN; } // now check pen2 (should be color) AsciiHexToBinary(penInfoBits, str+9, 4); penInfoBits[1] &= 0xf8; // mask off ink level trigger bits if ((penInfoBits[0] == 0xc2) && (penInfoBits[1] == 0x08)) { // Chinook if (temp_pen1 == BLACK_PEN) { ePen = BOTH_PENS; } else { ePen = COLOR_PEN; } } else if (penInfoBits[0] == 0xc0) { // missing pen ePen = temp_pen1; iNumMissingPens = 1; } else { return UNSUPPORTED_PEN; } return NO_ERROR; } // Check for missing pens if (*(str - 1) == '1' && *(str - 2) == '1') { return UNSUPPORTED_PEN; } char *p = str + 1; BYTE penColor; ePen = NO_PEN; for (int i = 0; i < num_pens; i++, p += 8) { AsciiHexToBinary (penInfoBits, p, 8); if ((penInfoBits[1] & 0xf8) == 0xf8) { // The high 5 bits in the 3rd and 4th nibble (second byte) identify the // installed pen. If all 5 bits are on, user has installed an incompatible pen. return UNSUPPORTED_PEN; } if ((penInfoBits[0] & 0x80) != 0x80) // if Bit 31 is 0, this is not a pen { continue; } penColor = penInfoBits[0] & 0x3F; switch (penColor) { case 0: { iNumMissingPens++; break; } case 1: ePen = BLACK_PEN; break; case 2: { if (ePen == BLACK_PEN) { ePen = BOTH_PENS; } else { ePen = COLOR_PEN; } break; } case 4: // cyan pen case 5: // magenta pen case 6: // yellow pen case 7: // low dye load cyan pen case 8: // low dye load magenta pen case 9: // low dye load yellow pen if (ePen == BLACK_PEN || ePen == BOTH_PENS) { ePen = BOTH_PENS; } else { ePen = COLOR_PEN; } break; default: ePen = UNKNOWN_PEN; } } return NO_ERROR; } // parse penID PEN_TYPE temp_pen1; // check pen1, assume it is black, pen2 is color switch (str[1]) { case 'H': // Hobbes case 'L': // Linus case 'Z': // Zorro temp_pen1 = BLACK_PEN; break; case 'X': return UNSUPPORTED_PEN; default: temp_pen1 = NO_PEN; break; } // now check pen2 int i = 2; while ((i < DevIDBuffSize) && str[i]!='$') i++; // handles variable length penIDs if (i == DevIDBuffSize) { return BAD_DEVICE_ID; } i++; // need to be more forgiving of the color pen type because of // the unknown chinookID for broadway // we can't guarantee the (F)lash color pen, but we can make sure // the pen is not (X)Undefined, (A)Missing or (M)onet if(str[i]!='X' && str[i]!='A' && str[i]!='M') // check what pen1 was { if (temp_pen1 == BLACK_PEN) ePen = BOTH_PENS; else { ePen = COLOR_PEN; } } else // no color pen, just set what pen1 was ePen = temp_pen1; return NO_ERROR;}#if defined(APDK_FONTS_NEEDED)Font* DJ9xx::RealizeFont(const int index,const BYTE bSize, const TEXTCOLOR eColor, const BOOL bBold,const BOOL bItalic, const BOOL bUnderline){ return Printer::RealizeFont(index,bSize,eColor,bBold,bItalic,bUnderline);}#endifDRIVER_ERROR DJ9xx::CleanPen(){ const BYTE Broadway_User_Output_Page[] = {ESC, '%','P','u','i','f','p','.', 'm','u','l','t','i','_','b','u','t','t','o','n','_','p','u','s','h',' ','3',';', 'u','d','w','.','q','u','i','t',';',ESC,'%','-','1','2','3','4','5','X' }; DWORD length = sizeof(PEN_CLEAN_PML); DRIVER_ERROR err = pSS->ToDevice(PEN_CLEAN_PML, &length); ERRCHECK; // send this page so that the user sees some output. If you don't send this, the // pens get serviced but nothing prints out. length = sizeof(Broadway_User_Output_Page); return pSS->ToDevice(Broadway_User_Output_Page, &length);}APDK_END_NAMESPACE#endif // APDK_DJ9xx
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -