📄 dj9xxvip.cpp
字号:
FullbleedType fbType; if (thePrintContext->bDoFullBleed && thePrinter->FullBleedCapable (thePrintContext->thePaperSize, &fbType, &fXOverSpray, &fYOverSpray, &fLeftOverSpray, &fTopOverSpray)) {/* * To get the printer to do fullbleed printing, send the top and * left overspray commands. Overspray is needed to take care of * skew during paper pick. These values may be mech dependent. * Currently, supported only on PhotoSmart 100. Malibu supports * fullbleed printing also. The current values for overspray are * 0.059 inch for top, bottom and left edges and 0.079 for right edge. */ BYTE cBuf[4]; BYTE TopOverSpraySeq[] = {0x1b, 0x2A, 0x6F, 0x35, 0x57, 0x0E, 0x02, 0x00}; // "Esc*o5W 0E 02 00 00 00" Top edge overspray for full-bleed printing BYTE LeftOverSpraySeq[] = {0x1b, 0x2A, 0x6F, 0x35, 0x57, 0x0E, 0x01, 0x00}; // "Esc*o5W 0E 01 00 00 00" Left edge overspray for full-bleed printing short topspray = (short)(fTopOverSpray * thePrintContext->EffectiveResolutionY() + 0.5); cBuf[1] = topspray & 0xFF; cBuf[0] = topspray >> 8; err = thePrinter->Send ((const BYTE *) TopOverSpraySeq, sizeof (TopOverSpraySeq)); err = thePrinter->Send ((const BYTE *) cBuf, 2); // set the left overspray value based on resolution and global constant for horizontal overspray short leftspray = (short)(fLeftOverSpray * thePrintContext->EffectiveResolutionX() + 0.5); cBuf[1] = leftspray & 0xFF; cBuf[0] = leftspray >> 8; err = thePrinter->Send ((const BYTE *) LeftOverSpraySeq, sizeof (LeftOverSpraySeq)); err = thePrinter->Send ((const BYTE *) cBuf, 2); } // no need for compression command, it's in the CRD err = thePrinter->Send((const BYTE*)grafStart, sizeof(grafStart) ); ERRCHECK; if (!thePrinter->UseGUIMode (thePrintContext->CurrentMode) && (thePrintContext->PhysicalPageSizeX ()) < 8.0) { BYTE blankRow[40]; memset (blankRow, 0xFF, 40); strcpy ((char *) blankRow, "\033*p0Y\033*b23W"); blankRow[11] = 18; // ce, 7f blankRow[30] = 0xCE; blankRow[31] = 0x7F; err = thePrinter->Send ((const BYTE *) blankRow, 34); } return err;} //SendDRIVER_ERROR HeaderAladdin::StartSend(){ DRIVER_ERROR err; err = thePrinter->Send((const BYTE*)Reset,sizeof(Reset)); ERRCHECK; err = thePrinter->Send((const BYTE*)UEL,sizeof(UEL)); ERRCHECK; err = thePrinter->Send((const BYTE*)EnterLanguage,sizeof(EnterLanguage)); ERRCHECK; if (!thePrinter->UseGUIMode(thePrintContext->CurrentMode)) { err = thePrinter->Send((const BYTE*)PCL3,sizeof(PCL3)); } else { err = thePrinter->Send((const BYTE*)PCLGUI,sizeof(PCLGUI)); } ERRCHECK; err = thePrinter->Send((const BYTE*)&LF,1); ERRCHECK; err = Modes (); // Set media source, type, size and quality modes. ERRCHECK;// Now send media pre-load command err = thePrinter->Send ((const BYTE *) "\033&l-2H", 6); // Moved from Modes(), des 3/11/03 ERRCHECK; if (!thePrinter->UseGUIMode(thePrintContext->CurrentMode)) { err = Margins(); // set margins }// special GUI mode top margin set else if ((thePrintContext->PrintableStartY ()) > 0.0) { CAPy = thePrintContext->GUITopMargin(); } return err;} //StartSend/* This could replace Header::SetMediaSource in header.cpp. des 8/5/02 */void HeaderAladdin::SetMediaSource(MediaSource msource)// Sets value of PCL::mediasource and associated counter msrccount{ msrccount=EscAmplCopy((BYTE*)mediasource,msource,'H');}DRIVER_ERROR DJ9xxVIP::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("DJ9xxVIP::Need to do a POWER ON to get penIDs\n"); // have to delay for Broadway 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 || ePen == MDL_BLACK_AND_COLOR_PENS) { return NO_ERROR; }// Should we return NO_ERROR for MDL_BOTH also - malibu?? while ( ePen != BOTH_PENS && pSS->GetVIPVersion () == 1 ) { 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;} //VerifyPenInfoDRIVER_ERROR DJ9xxVIP::ParsePenInfo(PEN_TYPE& ePen, BOOL QueryPrinter){ char* str; int num_pens = 0; PEN_TYPE temp_pen1 = NO_PEN; BYTE penInfoBits[4];/* * First check if this printer's firmware version is one I know about. Currently * I know upto S:04. I can't guess if the pen info nibbles have shifted in the * new version. Can't tell the user about missing pens. */ if ((pSS->GetVIPVersion ()) > 5) { ePen = BOTH_PENS; return NO_ERROR; } DRIVER_ERROR err = SetPenInfo (str, QueryPrinter); ERRCHECK; 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;/* * 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 Bits 23 .. 19 (5 bits) describes the pen/supply id: 0 = none 1 = Chinook (Formerly N) 2 = Hobbes (Formerly H) 3 = Flash (Formerly F) 4 = Robinhood (Formerly R -- only 6xx family) 5 = Candide (Formerly C -- only 6xx family) 6 = Little John (Formerly M -- only for 6xx family) 7 = Cyclone (Jupiter Pen) 8 = Europa (Jupiter Ink) 9 = Wax (pen/ink combo; k) 10 = Pele (pen/ink combo; cmy) 11 = Iris (pen/ink combo; kcm) 12 = Zorro (pen/ink combo; k) [def added Jun 27, 2002] 13 = Linus (k) [def added Jun 27, 2002] 14 = Ash pen/ink combo; gGK) [added Sep 12, 02] 15 .. 30 = reserved for future use [def added Jun 27, 2002] 31 = Other/Unknown [def added Jun 27, 2002] */ 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 if (ePen == MDL_PEN) { ePen = MDL_BOTH; } else if (ePen == GREY_PEN) { ePen = GREY_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 if (ePen == GREY_PEN) { ePen = MDL_AND_GREY_PENS; } else if (ePen == GREY_BOTH) { ePen = MDL_GREY_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; case 10: ePen = GREY_PEN; break; default: ePen = UNKNOWN_PEN; } } return NO_ERROR;} //ParsePenInfoBOOL DJ9xxVIP::IsPCL3DriverwareAvailable(){ BOOL pcl3driverware = TRUE; // default to TRUE since this is the case for all but some early units BOOL inAJob = FALSE; char *pStr; char *pEnd; BYTE devIDBuff[DevIDBuffSize]; int maxWaitTries; int i; // if don't have bidi can't check so assume driverware is ok since only certain // 990s don't handle driverware in PCL3 mode if (!IOMode.bDevID) { return TRUE; } if (pSS->GetDeviceID(devIDBuff, DevIDBuffSize, TRUE) != NO_ERROR) { goto cleanup; } // if printer does not have firmware based on the first 990 release // don't bother checking, can assume driverware commands are OK if (!strstr((const char*)devIDBuff+2,"MDL:DESKJET 990C") && !strstr((const char*)devIDBuff+2,"MDL:PHOTOSMART 1215") && !strstr((const char*)devIDBuff+2,"MDL:PHOTOSMART 1218") ) { return TRUE; } // high-level process to check if driverware is available in PCL3 mode: // 1. set JobName through the normal PJL command to some string X // 2. poll DeviceID until see this JobName (syncs host with printer in case // printer is still printing an earlier job etc.) // 3. go into PCL3 mode // 4. send driverware command to set JobName // 5. get the DeviceID and look at the JobName, if it is not "NEWDRIVERWARE" (what // the firmware driverware command sets it to) conclude that driverware is // not available in PCL3 mode; if the JobName is "NEWDRIVERWARE" then conclude // that driverware is available in PCL3 mode // 6. exit this "job" (send a UEL) // set the JobName via PJL if (Flush() != NO_ERROR) goto cleanup; if (Send((const BYTE*)UEL,sizeof(UEL)) != NO_ERROR) goto cleanup; inAJob = TRUE; if (Send((const BYTE*)JobName,sizeof(JobName)) != NO_ERROR) goto cleanup; if (Send((const BYTE*)&Quote,1) != NO_ERROR) goto cleanup; if (Send((const BYTE*)OUR_PJL_JOBNAME,strlen(OUR_PJL_JOBNAME)) != NO_ERROR) goto cleanup; if (Send((const BYTE*)&Quote,1) != NO_ERROR) goto cleanup; if (Send((const BYTE*)&LF,1) != NO_ERROR) goto cleanup; if (Flush() != NO_ERROR) goto cleanup; // we flush our ::Send buffer if (pSS->FlushIO() != NO_ERROR) goto cleanup; // we flush any external I/O buffer // wait for printer to see this and set JobName in the DeviceID // we know printer will respond, it is just a matter of time so wait // a while until see it since it may take a few seconds // for it to sync up with us if it is busy printing or picking // // this is a pretty long timeout but if the printer is finishing up // a preceding job we need to give it time to finish it since it won't // set the new jobname until the last job is complete // one possible enhancement would be to look at the flags in the DeviceID // to see if a job is active on more than one i/o connection maxWaitTries = 120; // wait max of 60sec for (i=0; i<maxWaitTries; i++) { if (pSS->GetDeviceID(devIDBuff, DevIDBuffSize, TRUE) != NO_ERROR) goto cleanup; if ( (pStr=(char *)strstr((const char*)devIDBuff+2,";J:")) ) { pStr += 3; if ( (pEnd=(char *)strstr((const char*)pStr,";")) ) { *pEnd = '\0';
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -