123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- #include "stdafx.h"
- #include "SCFLoader.h"
- using namespace DIOS::Dev::Detail::MachineryECOM;
- #ifdef _WIN64
- #ifdef _DEBUG
- const string SCFFile = "SerialSCFX64D.dll";
- #else
- const string SCFFile = "SerialSCFX64.dll";
- #endif
- #else
- #ifdef _DEBUG
- const string SCFFile = "SerialSCFD.dll";
- #else
- const string SCFFile = "SerialSCF.dll";
- #endif
- #endif
- using namespace nsSCF;
- SCFLoader *SCFLoader::m_instance = nullptr;
- SCFLoader::SCFLoader() :m_DllFileHandle(0), m_SCFInstance(nullptr)
- {
- }
- SCFLoader::~SCFLoader()
- {
- //if (m_DllFileHandle)
- //{
- // typedef void(*ReleaseSCF)(SCF *p);
- // ReleaseSCF dpcfunc = (ReleaseSCF)GetProcAddress(m_DllFileHandle, "ReleseSCF");
- // if (dpcfunc)
- // {
- // dpcfunc(m_SCFInstance);
- // }
- //}
- }
- SCFLoader *SCFLoader::Instance()
- {
- if (m_instance == nullptr)
- {
- m_instance = new SCFLoader();
- //m_instance->Initialize();
- }
- return m_instance;
- }
- void SCFLoader::Initialize(nsSCF::SCF* pSCF)
- {
- //m_DllFileHandle = LoadLibrary(SCFFile.c_str());
- //if (!m_DllFileHandle)
- //{
- // if(gdriverLog) gdriverLog->Error("DIOSBoardController Initialize Load library %s Failed.ErrorNo:%d", SCFFile.c_str(), GetLastError());
- //}
- //typedef SCF* (*GetSCF)();
- //GetSCF getSCF;
- //getSCF = (GetSCF)GetProcAddress(m_DllFileHandle, "GetSCF");
- //m_SCFInstance = getSCF();
- m_SCFInstance = pSCF;
- if (!m_SCFInstance)
- {
- if(gdriverLog) gdriverLog->Error("Load library {$}::GetSCF Action Failed", SCFFile.c_str());
- }
- }
- SCF* SCFLoader::GetSCFInstance()
- {
- //if (!m_SCFInstance)
- //{
- // Initialize();
- //}
- return m_SCFInstance;
- }
- SCFPacket *SCFLoader::CreateSingletonSCFPacket(const std::string &name)
- {
- if (m_scfPackets.find(name) == m_scfPackets.end())
- {
- auto packet = (SCFPacket *)MallocSCFPacket();
- m_scfPackets[name] = packet;
- }
-
- return m_scfPackets[name];
- }
- void SCFLoader::ReleaseSCFPacket(const std::string &name)
- {
- if (m_scfPackets.find(name) != m_scfPackets.end())
- {
- ::ReleaseSCFPacket(m_scfPackets[name]);
- m_scfPackets.erase(name);
- }
- }
|