12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- #pragma once
- #include "dt.h"
- #include "IIO.h"
- #include "CHardware.h"
- #include <string>
- #include <memory>
- #ifdef C_IO_EXPORTS
- #define C_IO_DLL_API __declspec(dllexport)
- #else
- #define C_IO_DLL_API //__declspec(dllimport)
- #endif
- class C_IO_DLL_API CIO
- {
- public:
- typedef struct
- {
- CIO* pClass;
- HANDLE hEvent;
- ns_db::DIGIT_IO_LEVEL level;
- ULONG lDleay;
- bool bRestore;
- } THREAD_CONFIG_STRUCT;
- private:
- ns_db::IO_CONFIG_STRUCT m_stIoConfig;
- bool m_bEnable = false;
- bool m_bIsInitSuccess = false;
- HANDLE m_hEvent = NULL;
- CDigitInput* m_pDi = nullptr;
- CDigitOutput* m_pDo = nullptr;
- CDigitInputS* m_pDis = nullptr;
- CDigitOutputS* m_pDos = nullptr;
- CAnalogOutput* m_pAo = nullptr;
- CAnalogInput* m_pAi = nullptr;
- public:
- CIO();
- LONG Init(ns_db::IO_CONFIG_STRUCT stIoConfig, void* pIO);
- string GetUtility();
- string GetName();
- string GetModuleType();
- LONG GetIo(ns_db::DIGIT_IO_LEVEL& nOutput);
- LONG GetIo(short & nOutput);
- LONG SetIo(ns_db::DIGIT_IO_LEVEL nOutput);
- LONG SetIo(short nOutput);
- //设置IO为高电平,如果lDelay>0时,将延时lDelay毫秒后自动恢复为设置前状态。
- //bRestore时间到后是否恢复,如果lDelay<=0,bRestore无意义
- LONG SetIo2LevelHigh(LONG lDelay,bool bRestore = false);
- //设置IO为高电平,如果lDelay>0时,将延时lDelay毫秒后自动恢复为设置前状态。
- //bRestore时间到后是否恢复,如果lDelay<=0,bRestore无意义
- LONG SetIo2LevelLow(LONG lDelay, bool bRestore = false);
- //等待设置Io线程完成
- LONG WaitSetIoThreadDone();
- static VOID CALLBACK threadSetIo(PTP_CALLBACK_INSTANCE Instance, PVOID Parameter, PTP_WORK Work);
- };
|