123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- #pragma once
- #include "dt.h"
- #include "IIO.h"
- #include "CHardware.h"
- #include <string>
- #include <memory>
- #include "CMessageBox.h"
- #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;
- CMessageBox* m_pMessageBox = nullptr;
- private:
- void PopWarn(AlarmID iId, std::string strDescribe, std::string otherInfo = "",
- LogStream::LogLevel iLevel = LogStream::LogLevel::Error, BUTTON_TYPE eViewButton = BUTTON_TYPE::CLOSE_BUTTON, std::string strTip = "", std::string strHelp = "");
- public:
- CIO();
- LONG Init(ns_db::IO_CONFIG_STRUCT stIoConfig, void* pIO);
- string GetUtility();
- string GetName();
- string GetModuleType();
- ns_db::IO_TYPE GetIoType();
- 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);
- };
|