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

📄 rangerexception.cpp

📁 支票扫描仪协议Ranger的应用.使用vc7.1
💻 CPP
字号:
#include "stdafx.h"
#include "RangerConstants.h"

#include "RangerException.h"

// helper routine
//-------------------------------------------------------------------------------------------------------------------------------------
struct __MAP_EXCEPTION_TYPE_DESC
{
	CRangerException::RangerExceptionType		nType;
	CString										strTypeDesc;
} g_MapExcceptionTypeDesc[] = {
	{CRangerException::RangerExceptionType_Unknown,"An unexpected error occurred"},
	{CRangerException::RangerExceptionType_None,"No exception was detected"},
	{CRangerException::RangerExceptionType_Jam,"One or more items jammed in the track"},
	{CRangerException::RangerExceptionType_LatePocket,"The application took too much time to make a pocket decision"},
	{CRangerException::RangerExceptionType_InternalSoftwareError,"The transport API encountered an internal error"},
	{CRangerException::RangerExceptionType_PocketFull,"A pocket is full"},
	{CRangerException::RangerExceptionType_TransportOffLine,"The transport is not ready to feed items"},
	{CRangerException::RangerExceptionType_ImageSubsystemDead,"The image subsystem is not functioning properly"},
	{CRangerException::RangerExceptionType_InitializationError,"The transport’s power up sequence failed"},
	{CRangerException::RangerExceptionType_ItemsInTrack,"There are one or more items in the track"},
	{CRangerException::RangerExceptionType_DeviceError,"A hardware device is malfunctioning"},
	{CRangerException::RangerExceptionType_FeedError,"Error feeding an item"},
	{CRangerException::RangerExceptionType_PrinterError,"A printer error was encountered"},
	{CRangerException::RangerExceptionType_FeedButtonPressed,"The transport’s physical feed button was pressed"},
	{CRangerException::RangerExceptionType_WaitingForFeedButton,"The transport is waiting for its physical feed button to be pressed"},
	{CRangerException::RangerExceptionType_EndOfMicrofilm,"The end of the microfilm reel was detected"},
	{CRangerException::RangerExceptionType_Misfeed,"An item was fed improperly"},
	{CRangerException::RangerExceptionType_DogEar,"A dog-eared item was detected"},
	{CRangerException::RangerExceptionType_MediaEmpty,"The replaceable media is exhausted for a particular device"},

	{CRangerException::RangerExceptionType_End,""},

	};

CString __CRangerException_FindExceptionTypeDesc(CRangerException::RangerExceptionType type)
{
	int index = 0;
	while (g_MapExcceptionTypeDesc[index].nType != CRangerException::RangerExceptionType_End )
	{
		if (g_MapExcceptionTypeDesc[index].nType == type) 
			return g_MapExcceptionTypeDesc[index].strTypeDesc;
		
		index++;
	} 

	return g_MapExcceptionTypeDesc[0].strTypeDesc;
}

struct __MAP_EXCEPTION_DEVICE_DESC
{
	CRangerException::RangerExceptionDevice		nDevice;
	CString										strDeviceDesc;
} g_MapExcceptionDeviceDesc[] = {
	{CRangerException::RangerExceptionDevice_Unknown,"The device is not known"},
	{CRangerException::RangerExceptionDevice_None,"No exception was caused by any device"},
	{CRangerException::RangerExceptionDevice_Transport,"An exception occurred that is not related to a specific device"},
	{CRangerException::RangerExceptionDevice_MainHopper,"A feeding exception occurred at the main hopper "},
	{CRangerException::RangerExceptionDevice_MergeHopper,"A feeding exception occurred at the merge hopper"},
	{CRangerException::RangerExceptionDevice_ManualDrop,"A feeding exception occurred during manual drop"},
	{CRangerException::RangerExceptionDevice_MICRReader,"An exception occurred at the MICR reader"},
	{CRangerException::RangerExceptionDevice_OCRReader,"An exception occurred at the OCR reader"},
	{CRangerException::RangerExceptionDevice_ICRReader,"An exception occurred at the ICR reader"},
	{CRangerException::RangerExceptionDevice_ViewWindow,"An exception occurred at the view window unit"},
	{CRangerException::RangerExceptionDevice_MICREncoder,"An exception occurred at the MICR encoder"},
	{CRangerException::RangerExceptionDevice_MICRVerifier,"TAn exception occurred at the MICR verifier"},
	{CRangerException::RangerExceptionDevice_FrontEndorser,"An exception occurred at the front endorser"},
	{CRangerException::RangerExceptionDevice_RearEndorser,"An exception occurred at the rear endorser"},
	{CRangerException::RangerExceptionDevice_FrontStamp,"An exception occurred at the front stamping unit"},
	{CRangerException::RangerExceptionDevice_RearStamp,"An exception occurred at the rear stamping unit"},
	{CRangerException::RangerExceptionDevice_MicroFilmer,"An exception occurred at the micro filmer"},
	{CRangerException::RangerExceptionDevice_FronImageCamera,"An exception occurred while capturing the front image "},
	{CRangerException::RangerExceptionDevice_RearImageCamera,"An exception occurred while capturing the rear image "},
	{CRangerException::RangerExceptionDevice_JournalPrinter,"An exception occurred at the journal printer"},
	{CRangerException::RangerExceptionDevice_PocketPrinter,"Printing failed due to requesting unsupported printing options, attempting to print excessively long text, and so forth"},
	{CRangerException::RangerExceptionDevice_ImageFileSet,"An exception occurred during image capture which prevents the creation of the image file sets"},
	{CRangerException::RangerExceptionDevice_ImageCameraController,"An exception occurred during the retrieval of the image from the transport"},
	{CRangerException::RangerExceptionDevice_Pocket,"Exceptions associated with pockets could indicate that the pocket is full, a pocket decision failed, and so forth"},

	{CRangerException::RangerExceptionDevice_End,""},

};

CString __CRangerException_FindExceptionDeviceDesc(CRangerException::RangerExceptionDevice device)
{
	int index = 0;
	while (g_MapExcceptionDeviceDesc[index].nDevice != CRangerException::RangerExceptionDevice_End )
	{
		if (g_MapExcceptionDeviceDesc[index].nDevice == device) 
			return g_MapExcceptionDeviceDesc[index].strDeviceDesc;

		index++;
	} 

	return g_MapExcceptionDeviceDesc[0].strDeviceDesc;
}

// CRangerException
//====================================================================================================================================
CRangerException::CRangerException()
	:	m_nExceptionTypeID(RangerExceptionType_Unknown),
		m_strExceptionTypeString(g_MapExcceptionTypeDesc[0].strTypeDesc),
		m_nExceptionDeviceID(RangerExceptionDevice_Unknown),
		m_strExceptionDeviceString(g_MapExcceptionDeviceDesc[0].strDeviceDesc)

{

}

CRangerException::CRangerException(int nExceptionType,int nExceptionDevice)
{
	if (nExceptionType < RangerExceptionType_Unknown || nExceptionType >= RangerExceptionType_End)
		m_nExceptionTypeID = RangerExceptionType_Unknown;
	else
		m_nExceptionTypeID =(RangerExceptionType) nExceptionType;
	 
	m_strExceptionTypeString = __CRangerException_FindExceptionTypeDesc(m_nExceptionTypeID);

	if (nExceptionDevice < RangerExceptionDevice_Unknown || nExceptionDevice >= RangerExceptionDevice_End)
		m_nExceptionDeviceID = RangerExceptionDevice_Unknown;
	else
		m_nExceptionDeviceID =(RangerExceptionDevice)  nExceptionDevice;

	m_strExceptionDeviceString = __CRangerException_FindExceptionDeviceDesc(m_nExceptionDeviceID);

}

CRangerException::CRangerException(const CRangerException& other)
{
	m_nExceptionDeviceID = other.m_nExceptionDeviceID;
	m_strExceptionDeviceString = other.m_strExceptionDeviceString;

	m_nExceptionTypeID = other.m_nExceptionTypeID;;
	m_strExceptionTypeString = other.m_strExceptionTypeString;
}

CRangerException& CRangerException::operator=(const CRangerException other)
{
	if (&other != this)
	{
		m_nExceptionDeviceID = other.m_nExceptionDeviceID;
		m_strExceptionDeviceString = other.m_strExceptionDeviceString;

		m_nExceptionTypeID = other.m_nExceptionTypeID;;
		m_strExceptionTypeString = other.m_strExceptionTypeString;
	}
	return *this;
}

CRangerException::RangerExceptionType CRangerException::GetExceptionTypeID()  const
{
	return m_nExceptionTypeID;
}

CString CRangerException::GetExceptionTypeString()  const
{
	return m_strExceptionTypeString;
}

CRangerException::RangerExceptionDevice CRangerException::GetExceptionDeviceID()  const
{
	return m_nExceptionDeviceID;
}

CString CRangerException::GetExceptionDeviceString()  const
{
	return m_strExceptionDeviceString;

}

⌨️ 快捷键说明

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