123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208 |
- // 下列 ifdef 块是创建使从 DLL 导出更简单的
- // 宏的标准方法。此 DLL 中的所有文件都是用命令行上定义的 SDCDOSEDPC_EXPORTS
- // 符号编译的。在使用此 DLL 的
- // 任何其他项目上不应定义此符号。这样,源文件中包含此文件的任何其他项目都会将
- // SDCDOSEDPC_API 函数视为是从 DLL 导入的,而此 DLL 则将用此宏定义的
- // 符号视为是被导出的。
- #pragma once
- #ifndef SDCDOSEDPC_EXPORTS
- #ifdef _WIN64
- #ifdef _DEBUG
- #pragma comment(lib, "SDCDoseDPCX64D.lib")
- #else
- #pragma comment(lib, "SDCDoseDPCX64.lib")
- #endif
- #else
- #ifdef _DEBUG
- #pragma comment(lib, "SDCDoseDPCD.lib")
- #else
- #pragma comment(lib, "SDCDoseDPC.lib")
- #endif
- #endif
- #endif
- #define PARAM_IN_TYPE
- #ifdef SDCDOSEDPC_EXPORTS
- #define GENDPC_API __declspec(dllexport)
- #else
- #define GENDPC_API __declspec(dllimport)
- #endif
- #include "LogicDriver.h"
- #include "SerialSCF.h"
- #include "DoseOemDevice.h"
- #include "common_api.h"
- #include "SyncGenOEM.h"
- #include "diosthread.h"
- //#include "afxmt.h"
- //extern "C" GENDPC_API DPC* GetDPC();
- //extern "C" GENDPC_API void ReleaseDPC(DPC *p);
- extern "C" GENDPC_API DriverDPC* GetDriverDPC();
- extern "C" GENDPC_API void ReleaseDriverDPC(DriverDPC *p);
- // 此类是从 SDCDoseDPC.dll 导出的
- class GENDPC_API SDCDoseDPC : public LogicDriver
- {
- std::string *m_pWorkpath;
- public:
- SDCDoseDPC(void);
- virtual ~SDCDoseDPC(void);
- //virtual bool DpcEntry(ResDataObject &Configuration);
- //virtual ResDataObject GetConnectionType();
- //virtual bool Connect(ResDataObject &Connection);
- //virtual bool Probe(ResDataObject &HardwareInfo);
- //virtual bool SetWorkPath(const char *pWorkPath);
- ////virtual LogicDevice* LoadLogicDevices();
- //virtual PVOID LoadLogicDevices();
- //virtual void UnloadLogicDevices(/*LogicDevice*/PVOID p);
- //virtual bool DisConnect();
- //virtual bool OnNotify(HANDLE ExitNotify);
- ///////////////////////////////////////////////////////
- virtual bool DriverEntry(ResDataObject &Configuration);
- virtual bool Driver_Probe(ResDataObject &HardwareInfo);
- virtual bool SYSTEM_CALL SetDriverWorkPath(const char * PARAM_IN pWorkPath);
- virtual PVOID SYSTEM_CALL LoadDriver();//无根节点
- virtual void SYSTEM_CALL UnloadDriver();
- //virtual bool OnNotify(HANDLE ExitNotify);
- virtual DWORD SYSTEM_CALL OnNotify(HANDLE evtList[], DWORD count);
- virtual bool Connect();
- virtual void DisConnect();
- //给硬件驱动设置Unique工作路径
- //如果是同一设备同一连接情况下,硬件多次接入,系统会保证工作路径是一样的.
- //连接后,单一硬件相关的数据要保存在此.
- virtual bool SYSTEM_CALL SetDeviceWorkPath(const char * PARAM_IN pWorkPath);
- //逻辑设备树的加载和卸载
- virtual PVOID SYSTEM_CALL LoadLogicDevices();
- virtual void SYSTEM_CALL UnloadLogicDevices();
- virtual bool SYSTEM_CALL OnHeartBeat();
- virtual bool Device_Probe(ResDataObject &HardwareInfo);
- /////////////////////////////////
- int SendCommand(char* strCommand, int nTimeOut = TIMEOUTVALUE); //对指令名称进行打包封装
- //Device Function
- bool ProcessCommand(char* strCommand, int nType = 0);
- //int SendCommand(string strcommand, bool bWaitACK, DWORD nWaitingTime);
- int SendCommand(string strcommand, bool bWaitACK = true, DWORD nWaitingTime = 350);
- bool WaitforAK(DWORD nWaitingTime = 500);
- bool WaitforRX1(DWORD nWaitingTime = 500);
- bool WaitforSA(DWORD nWaitingTime = 3000);
- bool WaitforRX0(DWORD nWaitingTime = 500);
- bool WaitforCP(DWORD nWaitingTime = 500);
- bool WaitforXR1(DWORD nWaitingTime = 40);
- bool ReProcessCommand(string strCommand);
- UINT SedecalSendingCommandsThread(HANDLE hExitFlag);
-
- void* m_pSendCommandThread;
- struct tagCommandStruct
- {
- string strCommand;
- //0, common commmand, not wait for ack command,
- //1 commmand, wait for vck command.,
- //2 APR command,
- //3, FO command
- int nCommmandType;
- };
- CRITICAL_SECTION g_cs;
- HANDLE m_hGenACKEvent;
- HANDLE m_hGenCPEvent;
-
- HANDLE m_hGenRX0Event;
- HANDLE m_hGenSAEvent;
- HANDLE m_hGenRX1Event;
- HANDLE m_hGenXR1Event;
- string m_strCurrentCommand;
- bool m_bReceiveRX1;
- bool m_bReceiveRX0;
- bool m_bReceiveXR1;
- bool m_bWaitforXR1;
- bool m_bWaitforRX1;
- bool m_bWaitforRX0;
- bool m_bSendXR1Failed;
- bool m_bInExposurePeriod;
- bool m_bIsNAK;
- bool m_bWaitAK;
- bool m_bStatusFlag;
- bool m_bResetting;
- bool m_bAPRProcessing;
- int m_nCurrentRsubmit;
- int m_nAKRsubmit;
- int m_nTotalRsubmit;
- int m_nTimeoutCounter;
- vector <tagCommandStruct> m_strCommondvector;
- tagCommandStruct m_SDCCommand;
- private:
- static PACKET_RET callbackPackageProcess(const char * RecData, DWORD nLength, DWORD& PacketLength);
- size_t OnCallback(const char * strPackage, size_t nLength);
- string LoadErrorContext(const char* strCode);
- ResDataObject m_DeviceConfig; //设备属性
- HMODULE m_SCFDllFileHandle;
- HMODULE m_LoggerDllFileHandle;
- Dose_OemDevice *m_pOEM; //Dose OEM
- SyncGen_OemDevice *m_pSyncGenOEM; //SynGen
- SyncSwitch_OemDevice *m_pSyncSwitchOEM; //SynSwitch
-
- SCF* m_pSCFServer;
- typedef SCF* (*GetSCF)();
- GetSCF getSCF;
- typedef void(*ReleaseSCF)(SCF *p);
- ReleaseSCF releaseSCF;
- SCFPacket *m_pSendPacket;
- SCFPacket *m_pReceivePacket;
- DWORD m_wReceiveTime;
- };
- class SendCommandThread :public Thread_Base
- {
- public:
- SendCommandThread(class SDCDoseDPC *pSDCDoseDPC);
- ~SendCommandThread();
- protected:
- bool Exec(void);
- SDCDoseDPC * m_pSDCDoseDPC;
- };
|