12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- //
- #pragma once
- #include <thread>
- #include <chrono>
- using namespace std::chrono_literals;
- #include "SyncEvent.hpp"
- #include "DIOS.Dev.IODevice.Detail.hpp"
- #include "SCF.hpp"
- namespace nsSCF = DIOS::Dev::Communication;
- //-----------------------------------------------------------------------------
- // IODeviceWithSCF
- //-----------------------------------------------------------------------------
- namespace DIOS::Dev::Detail
- {
- template <typename T>
- class IODeviceWithSCF : public T
- {
- using super = typename T;
- protected:
- nsSCF::SCF m_SCF;
- public:
- IODeviceWithSCF (std::shared_ptr <IOEventCenter> center, nsSCF::SCF SCF) : super (center)
- {
- m_SCF = SCF;
- }
- };
- }
- //-----------------------------------------------------------------------------
- // IODeviceWithSCF
- //-----------------------------------------------------------------------------
- namespace DIOS::Dev::Detail
- {
- template <typename T>
- class IODriverWithSCF : public T
- {
- using super = typename T;
- public:
- IODriverWithSCF ()
- {
- m_msWaitSCFTimeOut = 200; // 如果子类不重新设置, 默认就是 0.2 秒
- }
- ~IODriverWithSCF ()
- {
- std::this_thread::sleep_for (100ms);
- Disconnect ();
- }
- public:
- virtual void Prepare () override;
- virtual int Connect () override;
- virtual void Disconnect () override;
- virtual bool isConnected () const override;
- virtual void FireNotify (int Code, std::string Key, std::string Content) = 0;
-
- protected:
- virtual void Dequeue (const char * Packet, DWORD Length) = 0;
- protected:
- nsSCF::SCF m_SCF;
- SyncEvent::Auto OnNewPacket;
- std::thread::id m_TID;
- std::string m_SCFDllName;
- int m_msWaitSCFTimeOut; //
- static const int CMD_LEN_MAX = 1024;
- };
- }
|