dmcwincpp.docx

上传人:b****5 文档编号:6840359 上传时间:2023-01-11 格式:DOCX 页数:25 大小:17.22KB
下载 相关 举报
dmcwincpp.docx_第1页
第1页 / 共25页
dmcwincpp.docx_第2页
第2页 / 共25页
dmcwincpp.docx_第3页
第3页 / 共25页
dmcwincpp.docx_第4页
第4页 / 共25页
dmcwincpp.docx_第5页
第5页 / 共25页
点击查看更多>>
下载资源
资源描述

dmcwincpp.docx

《dmcwincpp.docx》由会员分享,可在线阅读,更多相关《dmcwincpp.docx(25页珍藏版)》请在冰豆网上搜索。

dmcwincpp.docx

dmcwincpp

//IncludethisfileforMicrosoftVisualC++ifyouareusingpre-compiledheaders

#include"stdafx.h"

#include"dmcwin.h"

CDMCWin:

:

CDMCWin()

{

m_usController=0;

m_hWnd=0;

m_lThreadID=0;

m_bConnected=FALSE;

m_hDmc=-1;

m_lLastError=0;

#ifdefDMCMULTIPLETHREADS

InitializeCriticalSection(&m_CritSec);

#endif

}

CDMCWin:

:

CDMCWin(USHORTusController,HWNDhWnd,LONGlThreadID)

{

m_usController=usController;

m_hWnd=hWnd;

m_lThreadID=lThreadID;

m_bConnected=FALSE;

m_hDmc=-1;

m_lLastError=0;

#ifdefDMCMULTIPLETHREADS

InitializeCriticalSection(&m_CritSec);

#endif

if(m_usController>0&&m_usController<17)

{

#ifdefDMCMULTIPLETHREADS

EnterCriticalSection(&m_CritSec);

#endif

if(m_lThreadID)

m_lLastError=DMCOpen2(m_usController,m_lThreadID,&m_hDmc);

else

m_lLastError=DMCOpen(m_usController,m_hWnd,&m_hDmc);

#ifdefDMCMULTIPLETHREADS

LeaveCriticalSection(&m_CritSec);

#endif

if(m_lLastError==0)

m_bConnected=TRUE;

else

m_hDmc=-1;

}

}

CDMCWin:

:

~CDMCWin()

{

if(m_hDmc!

=-1)

Close();

#ifdefDMCMULTIPLETHREADS

DeleteCriticalSection(&m_CritSec);

#endif

}

LONGCDMCWin:

:

Open()

{

m_lLastError=0;

if(m_bConnected)

returnm_lLastError;

if(m_usController>0&&m_usController<17)

{

#ifdefDMCMULTIPLETHREADS

EnterCriticalSection(&m_CritSec);

#endif

if(m_lThreadID)

m_lLastError=DMCOpen2(m_usController,m_lThreadID,&m_hDmc);

else

m_lLastError=DMCOpen(m_usController,m_hWnd,&m_hDmc);

#ifdefDMCMULTIPLETHREADS

LeaveCriticalSection(&m_CritSec);

#endif

if(m_lLastError==0)

m_bConnected=TRUE;

else

m_hDmc=-1;

}

else

m_lLastError=DMCERROR_CONTROLLER;

returnm_lLastError;

}

LONGCDMCWin:

:

Open(USHORTusController,HWNDhWnd,LONGlThreadID)

{

m_usController=usController;

m_hWnd=hWnd;

m_lThreadID=lThreadID;

returnOpen();

}

HANDLEDMCCDMCWin:

:

GetHandle()

{

if(m_hDmc!

=-1)

returnm_hDmc;

if(m_usController>0&&m_usController<17)

{

#ifdefDMCMULTIPLETHREADS

EnterCriticalSection(&m_CritSec);

#endif

m_lLastError=DMCGetHandle(m_usController,&m_hDmc);

#ifdefDMCMULTIPLETHREADS

LeaveCriticalSection(&m_CritSec);

#endif

if(m_lLastError==0)

returnm_hDmc;

}

return-1;

}

voidCDMCWin:

:

SethWnd(HWNDhWnd)

{

m_hWnd=hWnd;

if(m_bConnected)

{

#ifdefDMCMULTIPLETHREADS

EnterCriticalSection(&m_CritSec);

#endif

m_lLastError=DMCChangeInterruptNotification(m_hDmc,(long)hWnd);

#ifdefDMCMULTIPLETHREADS

LeaveCriticalSection(&m_CritSec);

#endif

}

};

voidCDMCWin:

:

SetThreadID(LONGlThreadID)

{

m_lThreadID=lThreadID;

if(m_bConnected)

{

#ifdefDMCMULTIPLETHREADS

EnterCriticalSection(&m_CritSec);

#endif

m_lLastError=DMCChangeInterruptNotification(m_hDmc,(long)lThreadID);

#ifdefDMCMULTIPLETHREADS

LeaveCriticalSection(&m_CritSec);

#endif

}

};

LONGCDMCWin:

:

Close()

{

m_lLastError=0;

if(m_hDmc!

=-1)

{

#ifdefDMCMULTIPLETHREADS

EnterCriticalSection(&m_CritSec);

#endif

m_lLastError=DMCClose(m_hDmc);

#ifdefDMCMULTIPLETHREADS

LeaveCriticalSection(&m_CritSec);

#endif

}

m_hDmc=-1;

m_bConnected=FALSE;

returnm_lLastError;

}

LONGCDMCWin:

:

Command(constPSZpszCommand,PCHARpchResponse,ULONGcbResponse)

{

if(m_bConnected)

{

#ifdefDMCMULTIPLETHREADS

EnterCriticalSection(&m_CritSec);

#endif

m_lLastError=DMCCommand(m_hDmc,(PSZ)pszCommand,pchResponse,cbResponse);

#ifdefDMCMULTIPLETHREADS

LeaveCriticalSection(&m_CritSec);

#endif

}

else

m_lLastError=DMCERROR_HANDLE;

returnm_lLastError;

}

LONGCDMCWin:

:

FastCommand(constPSZpszCommand)

{

if(m_bConnected)

{

#ifdefDMCMULTIPLETHREADS

EnterCriticalSection(&m_CritSec);

#endif

m_lLastError=DMCFastCommand(m_hDmc,(PSZ)pszCommand);

#ifdefDMCMULTIPLETHREADS

LeaveCriticalSection(&m_CritSec);

#endif

}

else

m_lLastError=DMCERROR_HANDLE;

returnm_lLastError;

}

LONGCDMCWin:

:

BinaryCommand(PBYTEpbCommand,ULONGulCommandLength,PCHARpchResponse,ULONGcbResponse)

{

if(m_bConnected)

{

#ifdefDMCMULTIPLETHREADS

EnterCriticalSection(&m_CritSec);

#endif

m_lLastError=DMCBinaryCommand(m_hDmc,pbCommand,ulCommandLength,pchResponse,cbResponse);

#ifdefDMCMULTIPLETHREADS

LeaveCriticalSection(&m_CritSec);

#endif

}

else

m_lLastError=DMCERROR_HANDLE;

returnm_lLastError;

}

LONGCDMCWin:

:

GetUnsolicitedResponse(PCHARpchResponse,ULONGcbResponse)

{

if(m_bConnected)

{

#ifdefDMCMULTIPLETHREADS

EnterCriticalSection(&m_CritSec);

#endif

m_lLastError=DMCGetUnsolicitedResponse(m_hDmc,pchResponse,cbResponse);

#ifdefDMCMULTIPLETHREADS

LeaveCriticalSection(&m_CritSec);

#endif

}

else

m_lLastError=DMCERROR_HANDLE;

returnm_lLastError;

}

LONGCDMCWin:

:

GetAdditionalResponseLen()

{

LONGlLength;

if(m_bConnected)

{

#ifdefDMCMULTIPLETHREADS

EnterCriticalSection(&m_CritSec);

#endif

m_lLastError=DMCGetAdditionalResponseLen(m_hDmc,(PULONG)&lLength);

#ifdefDMCMULTIPLETHREADS

LeaveCriticalSection(&m_CritSec);

#endif

}

else

m_lLastError=DMCERROR_HANDLE;

if(m_lLastError!

=0)

lLength=0;

returnlLength;

}

LONGCDMCWin:

:

GetAdditionalResponse(PCHARpchResponse,ULONGcbResponse)

{

if(m_bConnected)

{

#ifdefDMCMULTIPLETHREADS

EnterCriticalSection(&m_CritSec);

#endif

m_lLastError=DMCGetAdditionalResponse(m_hDmc,pchResponse,cbResponse);

#ifdefDMCMULTIPLETHREADS

LeaveCriticalSection(&m_CritSec);

#endif

}

else

m_lLastError=DMCERROR_HANDLE;

returnm_lLastError;

}

LONGCDMCWin:

:

GetErrorText(LONGlError,PCHARpchMessage,ULONGcbMessage)

{

#ifdefDMCMULTIPLETHREADS

EnterCriticalSection(&m_CritSec);

#endif

m_lLastError=DMCError(m_hDmc,lError,pchMessage,cbMessage);

#ifdefDMCMULTIPLETHREADS

LeaveCriticalSection(&m_CritSec);

#endif

returnm_lLastError;

}

LONGCDMCWin:

:

Clear()

{

if(m_bConnected)

{

#ifdefDMCMULTIPLETHREADS

EnterCriticalSection(&m_CritSec);

#endif

m_lLastError=DMCClear(m_hDmc);

#ifdefDMCMULTIPLETHREADS

LeaveCriticalSection(&m_CritSec);

#endif

}

returnm_lLastError;

}

LONGCDMCWin:

:

Reset()

{

if(m_bConnected)

{

#ifdefDMCMULTIPLETHREADS

EnterCriticalSection(&m_CritSec);

#endif

m_lLastError=DMCReset(m_hDmc);

#ifdefDMCMULTIPLETHREADS

LeaveCriticalSection(&m_CritSec);

#endif

}

returnm_lLastError;

}

LONGCDMCWin:

:

MasterReset()

{

if(m_bConnected)

{

#ifdefDMCMULTIPLETHREADS

EnterCriticalSection(&m_CritSec);

#endif

m_lLastError=DMCMasterReset(m_hDmc);

#ifdefDMCMULTIPLETHREADS

LeaveCriticalSection(&m_CritSec);

#endif

}

returnm_lLastError;

}

LONGCDMCWin:

:

GetVersion(PCHARpchVersion,ULONGcbVersion)

{

if(m_bConnected)

{

#ifdefDMCMULTIPLETHREADS

EnterCriticalSection(&m_CritSec);

#endif

m_lLastError=DMCVersion(m_hDmc,pchVersion,cbVersion);

#ifdefDMCMULTIPLETHREADS

LeaveCriticalSection(&m_CritSec);

#endif

}

returnm_lLastError;

}

LONGCDMCWin:

:

DownloadFile(constPSZpszFileName,constPSZpszLabel)

{

if(m_bConnected)

{

#ifdefDMCMULTIPLETHREADS

EnterCriticalSection(&m_CritSec);

#endif

m_lLastError=DMCDownloadFile(m_hDmc,(PSZ)pszFileName,(PSZ)pszLabel);

#ifdefDMCMULTIPLETHREADS

LeaveCriticalSection(&m_CritSec);

#endif

}

returnm_lLastError;

}

LONGCDMCWin:

:

DownloadFromBuffer(constPSZpszBuffer,constPSZpszLabel)

{

if(m_bConnected)

{

#ifdefDMCMULTIPLETHREADS

EnterCriticalSection(&m_CritSec);

#endif

m_lLastError=DMCDownloadFromBuffer(m_hDmc,(PSZ)pszBuffer,(PSZ)pszLabel);

#ifdefDMCMULTIPLETHREADS

LeaveCriticalSection(&m_CritSec);

#endif

}

returnm_lLastError;

}

LONGCDMCWin:

:

UploadFile(constPSZpszFileName)

{

if(m_bConnected)

{

#ifdefDMCMULTIPLETHREADS

EnterCriticalSection(&m_CritSec);

#endif

m_lLastError=DMCUploadFile(m_hDmc,(PSZ)pszFileName);

#ifdefDMCMULTIPLETHREADS

LeaveCriticalSection(&m_CritSec);

#endif

}

returnm_lLastError;

}

LONGCDMCWin:

:

UploadToBuffer(PCHARpchBuffer,ULONGcbBuffer)

{

if(m_bConnected)

{

#ifdefDMCMULTIPLETHREADS

EnterCriticalSection(&m_CritSec);

#endif

m_lLastError=DMCUploadToBuffer(m_hDmc,pchBuffer,cbBuffer);

#ifdefDMCMULTIPLETHREADS

LeaveCriticalSection(&m_CritSec);

#endif

}

returnm_lLastError;

}

LONGCDMCWin:

:

SendFile(constPSZpszFileName)

{

if(m_bConnected)

{

#ifdefDMCMULTIPLETHREADS

EnterCriticalSection(&m_CritSec);

#endif

m_lLastError=DMCSendFile(m_hDmc,(PSZ)pszFileName);

#ifdefDMCMULTIPLETHREADS

LeaveCriticalSection(&m_CritSec);

#endif

}

returnm_lLastError;

}

LONGCDMCWin:

:

SendBinaryFile(constPSZpszFileName)

{

if(m_bConnected)

{

#ifdefDMCMULTIPLETHREADS

EnterCriticalSection(&m_CritSec);

#endif

m_lLastError=DMCSendBinaryFile(m_hDmc,(PSZ)pszFileName);

#ifdefDMCMULTIPLETHREADS

LeaveCriticalSection(&m_CritSec);

#endif

}

returnm_lLastError;

}

LONGCDMCWin:

:

AsciiCommandToBinaryCommand(PSZpszAsciiCommand,ULONGulAsciiCommandLength,PBYTEpbBinaryResult,ULONGcbBinaryResult,ULONGFAR*pulBinaryResultLength)

{

m_lLastError=DMCCommand_AsciiToBinary(m_hDmc,pszAsciiCommand,ulAsciiCommandLength,pbBinaryResult,cbBinaryResult,pulBinaryResultLength);

returnm_lLastError;

}

LONGCDMCWin:

:

BinaryCommandToAsciiCommand(PBYTEpbBinaryCommand,ULONGulBinaryCommandLength,PSZpszAsciiResult,ULONGcbAsciiResult,ULONGFAR*pulAsciiResultLength)

{

m_lLastError=DMCCommand_BinaryToAscii(m_hDmc,pbBinaryCommand,ulBinaryCommandLength,pszAsciiResult,cbAsciiResult,pulAsciiResultLength);

returnm_lLastError;

}

LONGCDMCWin:

:

AsciiFileToBinaryFile(constPSZpszInputFileName,constPSZpszOutputFileName)

{

m_lLastError=DMCFil

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 法律文书 > 调解书

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1