📄 dj3320.cpp
字号:
break; case DISPLAY_ERROR_TRAP: case DISPLAY_COMM_PROBLEM: // These are unrecoverable cases. Don't let any more of this job be sent // to the printer. We can't even eject the page at the end of the job ErrorTerminationState = TRUE; pSS->DisplayPrinterStatus (eDisplayStatus); // Wait for user to cancel the job, otherwise they might miss the // error message while (pSS->BusyWait ((DWORD) 500) != JOB_CANCELED) { // nothing.... ; } return IO_ERROR; case DISPLAY_TOP_COVER_OPEN: pSS->DisplayPrinterStatus(DISPLAY_TOP_COVER_OPEN); err = NO_ERROR; // Wait for top cover to close or user to cancel while(eDisplayStatus == DISPLAY_TOP_COVER_OPEN && !err) { err = pSS->BusyWait((DWORD)500); if(err == JOB_CANCELED) { ErrorTerminationState = TRUE; } if(!err) { bUpdateState = pLDLEncap->UpdateState(FALSE); if(bUpdateState) { eDisplayStatus = ParseError(byStatusReg); // Need to check for cancel here, because we could miss it if the // user presses cancel button then lifts lid or something if(eDisplayStatus == DISPLAY_PRINTING_CANCELED) { ErrorTerminationState = TRUE; bPrinterCancelButton = TRUE; } } } } // while(eDisplayStatus == DISPLAY_TOP_COVER_OPEN && !err) if(!err && !bPrinterCancelButton) { pSS->DisplayPrinterStatus(DISPLAY_PRINTING); // Give the printer some time to come back online if(pSS->BusyWait((DWORD)1000) == JOB_CANCELED) { ErrorTerminationState = TRUE; } } break; case DISPLAY_OUT_OF_PAPER_NEED_CONTINUE: pSS->DisplayPrinterStatus (DISPLAY_OUT_OF_PAPER_NEED_CONTINUE); err = NO_ERROR; // Wait for user to add more paper and press resume button on printer or // select CONTINUE button from host's error dialog while(eDisplayStatus == DISPLAY_OUT_OF_PAPER_NEED_CONTINUE && !err) { err = pSS->BusyWait((DWORD)500); if (err == JOB_CANCELED) { ErrorTerminationState = TRUE; } else if(err == CONTINUE_FROM_BLOCK) { // Setup CONTINUE command pWriteBuff = byContinue; dwWriteCount = sizeof(byContinue); BytesToWrite = sizeof(byContinue); byCommandNumber = COMMAND_CONTINUE; bOriginalRequest = FALSE; bCreditForCommand = FALSE; byCreditWaitCountOriginal = byCreditWaitCount; byCreditWaitCount = 0; } else { bUpdateState = pLDLEncap->UpdateState(FALSE); if(bUpdateState) { eDisplayStatus = ParseError(byStatusReg); // Need to check for cancel here, because we could miss it if the // user presses cancel button then lifts lid or something if(eDisplayStatus == DISPLAY_PRINTING_CANCELED) { ErrorTerminationState = TRUE; bPrinterCancelButton = TRUE; } } } } // while(eDisplayStatus == DISPLAY_OUT_OF_PAPER_NEED_CONTINUE && !err) if(!err && !bPrinterCancelButton) { pSS->DisplayPrinterStatus(DISPLAY_PRINTING); } break; case DISPLAY_BUSY: pSS->DisplayPrinterStatus(DISPLAY_BUSY); if (pSS->BusyWait ((DWORD) 5000) == JOB_CANCELED) { ErrorTerminationState = TRUE; } break; // Other cases need no special handling, display the error and try to continue default: pSS->DisplayPrinterStatus (eDisplayStatus); if (pSS->BusyWait ((DWORD) 500) == JOB_CANCELED) { ErrorTerminationState = TRUE; } break; } // switch(eDisplayStatus) } // else(iCurrBuffSize) } // if(byCreditWaitCount >= CREDIT_WAIT) } // else(bCreditForCommand || bFlush) if (pSS->BusyWait ((DWORD)0) == JOB_CANCELED || bPrinterCancelButton) { pSS->DisplayPrinterStatus(DISPLAY_PRINTING_CANCELED); // If there is anything waiting in the buffer, send it. I/O may have had a full buffer and // may not have been able to buffer the full request for which we had credit, so if there // are still BytesToWrite and we have credit for the current command, we have to buffer // those and send them if we didn't terminate in an error condition. // Another possibility is that we don't have credit for the current command. In that case // we don't want to wait for BytesToWrite to be 0 or we'll be in a deadlock. We'll never // get credit for the command and thus BytesToWrite will never be 0. // We can only terminate in an error condition if we didn't have credit for the original // command, so in that case we only have to flush what's in the buffer and not worry about // the remaining BytesToWrite. // After we check for these conditions we can send the Prepare to Cancel and Cancel // Job commands if( (iCurrBuffSize || (BytesToWrite && bCreditForCommand && !ErrorTerminationState) ) && !(bCanceling || bCanceled) ) { bFlush = TRUE; } else if(!bCanceling) { pWriteBuff = byPrepareToCancel; dwWriteCount = sizeof(byPrepareToCancel); BytesToWrite = sizeof(byPrepareToCancel); byCommandNumber = COMMAND_PREPARE_TO_CANCEL; bOriginalRequest = FALSE; bCreditForCommand = FALSE; byCreditWaitCount = 0; bCanceling = TRUE; } else if(!bCanceled) { // pWriteBuff will only be equal to byPrepareToCancel when we've setup the Prepare to // Cancel command but haven't yet sent it to the printer if(pWriteBuff != byPrepareToCancel) { pWriteBuff = pLDLEncap->pbyCancel; dwWriteCount = sizeof(pLDLEncap->pbyCancel); BytesToWrite = sizeof(pLDLEncap->pbyCancel); byCommandNumber = COMMAND_CANCEL; bOriginalRequest = FALSE; bCreditForCommand = FALSE; byCreditWaitCount = 0; bCanceled = TRUE; } } } } while (BytesToWrite > 0); if (bCanceled) { // Ensure that display still says we're cancelling pSS->DisplayPrinterStatus(DISPLAY_PRINTING_CANCELED); ErrorTerminationState = TRUE; return JOB_CANCELED; } else { // Ensure any error message has been cleared pSS->DisplayPrinterStatus (DISPLAY_PRINTING); if (bCheckForCancelButton) { ulBytesSentSinceCancelCheck += dwWriteCount; } return NO_ERROR; }}DRIVER_ERROR DJ3320::ParsePenInfo (PEN_TYPE& ePen, BOOL QueryPrinter){ char *str; int num_pens = 0; DRIVER_ERROR err = SetPenInfo (str, QueryPrinter); ERRCHECK; // 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; } char *p = str + 1; BYTE penInfoBits[4];/* * Pen Type Info * Bit 31 (1 bit) 1 if these fields describe a print head 0 otherwise Bit 30 (1 bit) 1 if these fields describe an ink supply 0 otherwise Bits 29 .. 24 (6 bits) describes the pen/supply type: 0 = none 1 = black 2 = CMY 3 = KCM 4 = Cyan 5 = Meganta 6 = Yellow 7 = Cyan - low dye load 8 = Magenta - low dye load 9 = Yellow - low dye load (may never be used, but reserve space anyway) [def added Jun 3, 2002] 10 = gGK - two shades of grey plus black; g=light grey, G=medium Grey, K=black [added Sep 12, 02] 11 .. 62 = reserved for future use 63=Unknown */ 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; } BYTE penColor = penInfoBits[0] & 0x3F; switch (penColor) { case 0: { break; } case 1: ePen = BLACK_PEN; break; case 2: { if (ePen == BLACK_PEN) { ePen = BOTH_PENS; } else if (ePen == MDL_PEN) { ePen = MDL_BOTH; } else { ePen = COLOR_PEN; } break; } case 3: if (ePen == BLACK_PEN) { ePen = MDL_AND_BLACK_PENS; } else if (ePen == COLOR_PEN) { ePen = MDL_BOTH; } else if (ePen == BOTH_PENS) { ePen = MDL_BLACK_AND_COLOR_PENS; } else { ePen = MDL_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;}DRIVER_ERROR DJ3320::VerifyPenInfo(){ DRIVER_ERROR err = NO_ERROR; if(IOMode.bDevID == FALSE) return err; ePen = NO_PEN; err = ParsePenInfo(ePen); ERRCHECK; while (ePen == NO_PEN) { err = ParsePenInfo (ePen); ERRCHECK; if (ePen == NO_PEN) { pSS->DisplayPrinterStatus (DISPLAY_NO_PENS); if (pSS->BusyWait (500) == JOB_CANCELED) return JOB_CANCELED; } } pSS->DisplayPrinterStatus (DISPLAY_PRINTING); return NO_ERROR;}DRIVER_ERROR DJ3320::CheckInkLevel(){ DRIVER_ERROR err; char* pStr; BYTE bDevIDBuff[DevIDBuffSize]; if (!IOMode.bDevID) { return NO_ERROR; } err = pSS->GetDeviceID(bDevIDBuff, DevIDBuffSize, TRUE); if (err!=NO_ERROR) { return err; } if ( (pStr=(char *)strstr((const char*)bDevIDBuff+2,";S:")) == NULL ) { return SYSTEM_ERROR; } pStr += 21; int numPens = 0; if (*pStr > '0' && *pStr < '9') { numPens = *pStr - '0'; } else if (*pStr > 'A' && *pStr < 'F') { numPens = *pStr - 'A'; } else if (*pStr > 'a' && *pStr < 'f') { numPens = *pStr - 'a'; } pStr++;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -