⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 printer.cpp

📁 HP喷墨打印机驱动代码 HP内部资料! 珍贵 珍贵 珍贵
💻 CPP
📖 第 1 页 / 共 3 页
字号:
                    {                        DBG1("Send: JOB_CANCELED\n");                        JobCanceled = TRUE;                        pSS->DisplayPrinterStatus(DISPLAY_PRINTING_CANCELED);                    }                    break;                case DISPLAY_OUT_OF_PAPER:				case DISPLAY_PHOTOTRAY_MISMATCH:				{					DISPLAY_STATUS	tmpStatus = eDisplayStatus;                    pSS->DisplayPrinterStatus(eDisplayStatus);                    // wait for the user to add paper and                    // press resume                    while ( eDisplayStatus == tmpStatus)                    {                        if (pSS->BusyWait((DWORD)500) == JOB_CANCELED)                        // although we'll leave an incomplete job in the printer,                        // we really need to bail for proper CANCEL response.                        {                            ErrorTerminationState = TRUE;                            return JOB_CANCELED;                        }                        if (m_bStatusByPJL)                        {                            status_reg = (BYTE) eDisplayStatus;                        }                        else                        {                            if (IOMode.bStatus)                            {                                pSS->GetStatusInfo(&status_reg);                            }                        }                        eDisplayStatus = ParseError(status_reg);                    }                    pSS->DisplayPrinterStatus(DISPLAY_PRINTING);                    break;				}                case DISPLAY_BUSY:                    if (pSS->BusyWait((DWORD)5000) == JOB_CANCELED)                    {                        ErrorTerminationState = TRUE;                        return JOB_CANCELED;                    }                    pSS->DisplayPrinterStatus(DISPLAY_BUSY);                    break;                // other cases need no special handling, display                // the error and try to continue                default:                    pSS->DisplayPrinterStatus(eDisplayStatus);                    break;            }// switch        } // if        // give printer time to digest the data and check for 'cancel' before        // the next iteration of the loop        if (pSS->BusyWait((DWORD)100) == JOB_CANCELED)        {            DBG1("Send: JOB_CANCELED\n");            JobCanceled = TRUE;            pSS->DisplayPrinterStatus(DISPLAY_PRINTING_CANCELED);        }    }   // while (residual > 0)    // The above BusyWait's will not be checked if residual gets sent the first time, every time    // because we 'break' at that point for efficiency.  However, we want to make sure we check    // at least once for a CANCEL event for timely job-cancel response.    if (pSS->BusyWait((DWORD)0) == JOB_CANCELED)    {        JobCanceled = TRUE;        pSS->DisplayPrinterStatus(DISPLAY_PRINTING_CANCELED);    }#ifdef APDK_BUFFER_SEND    // Our buffer is now empty: reset the size so concurrent writes start at the beginning        iCurrBuffSize = 0;    } while (BytesToWrite > 0);#endif    // restore my JOB_CANCELED error    if (JobCanceled == TRUE)    {        DBG1("Send: Clean return w/ JOB_CANCELED\n");        // ensure that display still says we're cancelling        pSS->DisplayPrinterStatus(DISPLAY_PRINTING_CANCELED);        return JOB_CANCELED;    }    else    {        // ensure any error message has been cleared        pSS->DisplayPrinterStatus(DISPLAY_PRINTING);        if (bCheckForCancelButton)        {            ulBytesSentSinceCancelCheck += dwWriteCount;        }        return NO_ERROR;    }} //SendBOOL Printer::TopCoverOpen(    BYTE /*status_reg*/){    char * pStr;    BYTE bDevIDBuff[DevIDBuffSize];    if(IOMode.bDevID == FALSE)    {        return FALSE;    }    DRIVER_ERROR err = pSS->GetDeviceID(bDevIDBuff, DevIDBuffSize, TRUE);    if (err != NO_ERROR)    {        return FALSE;    }    if( (pStr=strstr((char*)bDevIDBuff+2,"VSTATUS:")) ) //  find the VSTATUS area    {        pStr+=8;        // now parse VSTATUS parameters        // looking for UP for open, DN for closed        if (strstr((char*)pStr,"UP"))        {            return TRUE;        }        if (strstr((char*)pStr,"DN"))        {            return FALSE;        }        DBG1("didn't find UP or DN!!\n");        return FALSE;    }    else    if (( pStr = strstr ((char*) bDevIDBuff+2, ";S")))    {        if ( (*(pStr+5) == '9') )        {            return TRUE;        }        else        {            return FALSE;        }    }    else    {        return FALSE;  // if we can't find VSTATUS or binary status field, assume top is not open    }} //TopCoverOpenDRIVER_ERROR Printer::CleanPen(){    DBG1("Printer::ClearPen() called\n");    DWORD length=sizeof(PEN_CLEAN_PML);    return pSS->ToDevice(PEN_CLEAN_PML,&length);} //CleanPenPrintMode* Printer::GetMode(    unsigned int index){    if (index >= ModeCount)    {        return NULL;    }    return pMode[index];} //GetModePrintMode::PrintMode(    uint32_t *map1,    uint32_t *map2){    pmQuality = QUALITY_NORMAL;    pmMediaType = MEDIA_PLAIN;    pmColor = COLOR;    int iCount;    cmap.ulMap1 = map1;    cmap.ulMap2 = map2;    BaseResX = BaseResY = TextRes = 300;    MixedRes= FALSE;    // default setting    for (iCount = 0; iCount < MAXCOLORPLANES; iCount++)    {        ResolutionX[iCount] = BaseResX;        ResolutionY[iCount] = BaseResY;        ColorDepth[iCount] = 1;    }    medium = mediaPlain;    theQuality = qualityNormal;    dyeCount=4;    Config.bResSynth = TRUE;#if defined(APDK_VIP_COLORFILTERING)    Config.bErnie = FALSE;#endif    Config.bPixelReplicate = TRUE;    Config.bColorImage = TRUE;    Config.bCompress = TRUE;    Config.eHT = FED;    BlackFEDTable = GetHTBinary();    ColorFEDTable = GetHTBinary();    // set for most common cases    bFontCapable = TRUE;    CompatiblePens[0] = BOTH_PENS;    for(iCount = 1; iCount < MAX_COMPATIBLE_PENS; iCount++)    {        CompatiblePens[iCount] = DUMMY_PEN;    }#ifdef APDK_AUTODUPLEX    bDuplexCapable = FALSE;    DuplexMode = DUPLEXMODE_NONE;#endif} //PrintModeGrayMode::GrayMode(    uint32_t *map) :    PrintMode(map)// grayscale uses econo, 300, 1 bit{    ColorDepth[K] = 1;    dyeCount = 1;    CompatiblePens[1] = BLACK_PEN;  // accept either black or both    pmColor = GREY_K;} //GrayModeCMYGrayMode::CMYGrayMode(    uint32_t *map) :    GrayMode(map){    CompatiblePens[1] = COLOR_PEN;  // accept either color or both    dyeCount = 3;    pmColor = GREY_CMY;} //CMYGrayModeKCMYGrayMode::KCMYGrayMode(    uint32_t *map) :    GrayMode(map){    dyeCount = 4;    pmColor = GREY_CMY;} //KCMYGrayModeDRIVER_ERROR Printer::SetPenInfo(    char*& pStr,    BOOL QueryPrinter){    DRIVER_ERROR err;    if (QueryPrinter)    {        // read the DevID into the stored strDevID        err = pSS->GetDeviceID(pSS->strDevID, DevIDBuffSize, TRUE);        ERRCHECK;        // update the static values of the pens        err = pSS->DR->ParseDevIDString((const char*)(pSS->strDevID),pSS->strModel,&(pSS->VIPVersion),pSS->strPens);        ERRCHECK;        if ((pStr = strstr((char*)pSS->strDevID,"VSTATUS:")))   //  find the VSTATUS area        {            pStr += 8;        }        else if ((pStr = strstr((char*)pSS->strDevID, ";S:00")))  // binary encoded device ID status (version 0)        {            pStr += 19;     // get to the number of pens field - 12 byte feature field        }        else if ((pStr = strstr ((char *) pSS->strDevID, ";S:01")))        {            pStr += 19;     // same as version 00        }        else if ((pStr = strstr((char*)pSS->strDevID, ";S:02")))  // binary encoded device ID status (version 2)        {            pStr += 21;     // get to the number of pens field - 14 byte feature field        }        else if ((pStr = strstr((char*)pSS->strDevID, ";S:03")))  // binary encoded device ID status (version 3)        {            pStr += 21;     // get to the number of pens field - 14 byte feature field        }        else if ((pStr = strstr((char*)pSS->strDevID, ";S:04")))  // binary encoded device ID status (version 3)        {            pStr += 25;     // get to the number of pens field - 18 byte feature field        }        else if ((pSS->GetVIPVersion ()) > 5)        {            return NO_ERROR;        }        else        {            TRACE("Printer::SetPenInfo - Unsupported DeviceID %s.\n", pSS->strDevID);            ASSERT (0);  // you must have a printer with a new version that is not supported yet!            return BAD_DEVICE_ID;  // - code should never reach this point        }    }    else    {        pStr = pSS->strPens;    }    return NO_ERROR;} //SetPenInfoBOOL PrintMode::Compatible(    PEN_TYPE pens){    BOOL res = FALSE;    for (int i=0; i < MAX_COMPATIBLE_PENS; i++)    {        if (CompatiblePens[i] == pens)        {            res = TRUE;        }    }    return res;} //CompatibleDRIVER_ERROR Printer::SetPens(    PEN_TYPE eNewPen){    ASSERT(eNewPen <= MAX_PEN_TYPE);    // We are (probably)in unidi.  We have to trust they know what pens are    // in the printer.  We'll let them set any pen set (even if this printer    // doesn't support it.  We'll find out during SelectPrintMode    if (eNewPen <= MAX_PEN_TYPE)    {        ePen = eNewPen;        return NO_ERROR;    }    else    {        return UNSUPPORTED_PEN;    }} //SetPensvoid PrintMode::GetValues(    QUALITY_MODE& eQuality,    MEDIATYPE& eMedia,    COLORMODE& eColor,    BOOL& bDeviceText){    if (&eQuality != NULL)    {        eQuality = pmQuality;    }    if (&eMedia != NULL)    {        eMedia = pmMediaType;    }    if (&eColor != NULL)    {        eColor = pmColor;    }    if (&bDeviceText != NULL)    {        bDeviceText = bFontCapable;    }} //GetValuesvoid Printer::SetPMIndices(){    for (unsigned int i=0; i < ModeCount; i++)    {        pMode[i]->myIndex = i;    }} //SetPMIndicesAPDK_END_NAMESPACE

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -