| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413 |
- // CanModelDPC.cpp : 定义 DLL 应用程序的导出函数。
- //
- #include "stdafx.h"
- #include "CanModelDPC.h"
- #include "DevTree.h"
- #include "CanModelDevice.h"
- #include "common_api.h"
- #include <iostream>
- #include <sstream>
- #include "localConfig.h"
- #include "ModuleConfig.h"
- #include <iostream>
- #include <filesystem>
- #include <system_error>
- CANMODELDPC_C_API DriverDPC* GetDriverDPC()
- {
- return (DriverDPC*)(new CanModelDPC());
- }
- CANMODELDPC_C_API void ReleaseDriverDPC(DriverDPC *p)
- {
- CanModelDPC *org = (CanModelDPC*)p;
- delete org;
- }
- typedef nsDEV::IODriver* (*GetDriverMgrAPI)();
- typedef VirtualDevice* (*CreateVirtuaDeviceAPI)();
- typedef void (*FreeVirtualDeviceAPI)(VirtualDevice*);
- Log4CPP::Logger* gLogger = nullptr;
- HANDLE g_hExit = INVALID_HANDLE_VALUE;
- CanModelDPC::CanModelDPC(void)
- {
- m_pWorkpath = new std::string();
- m_MainHostDevice = nullptr;
- //m_pMidObject = 0;
- //m_pMidObject.reset(new eDEV::Mediator());
- if (gLogger == nullptr)
- {
- string strLogPath = GetProcessDirectory() + R"(\Conf\Log4CPP.Config.xml)";
- string LogHost = ((string)getLogRootpath()).c_str();
- Log4CPP::ThreadContext::Map::Set(ECOM::Utility::Hash("LogFileName"), "Platform");
- //Log4CPP::GlobalContext::Map::Set("LogHost", LogHost.c_str());
- Log4CPP::ThreadContext::Map::Set(ECOM::Utility::Hash("LogHost"), LogHost.c_str() + 1);
- auto rc = Log4CPP::LogManager::LoadConfigFile(strLogPath.c_str());
- gLogger = Log4CPP::LogManager::GetLogger("Platform");
- FINFO("Code Build datetime [{$} {$}]", __DATE__, __TIME__);
- }
- g_hExit = CreateEvent(NULL, TRUE, FALSE, NULL);
- }
- CanModelDPC::~CanModelDPC(void)
- {
- delete m_pWorkpath;
- SetEvent(g_hExit);
- }
- bool CanModelDPC::LoadVirtualDevice(const char* pDevicePath, bool isImgDevice, bool bAddToList, string devPath, string devSrvPath)
- {
- string devDeriverPath = GetProcessDirectory() + "\\VirtualDevices\\" + pDevicePath;
- string FilePath = GetFileDirectory(devDeriverPath);
- AddEnvPath(FilePath.c_str());
- auto hModle = LoadLibrary(devDeriverPath.c_str());
- //m_arrImgeFunc = nullptr;
- if (hModle)
- {
- VirtualDevice* pDevice = nullptr;
- FINFO("Load Driver ok.. {$}", devDeriverPath);
- CreateVirtuaDeviceAPI callfunc = (CreateVirtuaDeviceAPI)GetProcAddress(hModle, "CreateVirtualDevice");
- if (callfunc)
- {
- pDevice = callfunc();
- if (pDevice)
- {
- int nIndex = -1;
- if (isImgDevice)
- {
- if (bAddToList)
- {
- //"ImageProcessIndex":
- // "DescKey":"ImageProcessIndex",
- // "Value" : "2"
- /*ResDataObject resPri;
- if (RET_SUCCEED == pDevice->DevGet("", "ImageProcessIndex", resPri))
- {
- string strPri = (const char*)resPri;
- if (strPri.length() > 0)
- {
- resPri = "";
- int nPri = atoi(strPri.c_str());
- for (int x = 0; x < m_arrImgeProcessDevices.size(); x++)
- {
- if (m_arrImgeProcessDevices[x]->DevGet("", "ImageProcessIndex", resPri) == RET_SUCCEED)
- {
- strPri = (const char*)resPri;
- if (atoi(strPri.c_str()) < nPri)
- {
- nIndex = x;
- continue;
- }
- else
- break;
- }
- }
- }
- }*/
- ImageProcessAPI func = (ImageProcessAPI)GetProcAddress(hModle, "DeviceImgProcess");
- if (nIndex >= 0)
- {
- FINFO("Inesrt {$} at [{$}] ImageProcess Array", pDevice->GetCcosRootPath(), nIndex);
- m_arrImgeProcessDevices.insert(m_arrImgeProcessDevices.begin()+nIndex, pDevice);
- m_arrImgeFunc.insert(m_arrImgeFunc.begin()+nIndex, func);
- }
- else
- {
- FINFO("Append {$} ImageProcess Array at [{$}] ", pDevice->GetCcosRootPath(), m_arrImgeFunc.size());
- m_arrImgeProcessDevices.push_back(pDevice);
- m_arrImgeFunc.push_back(func);
- }
- }
- m_hImgeDeviceHandle = hModle;
- }
- else
- {
- if (bAddToList)
- {
- m_arrMessageProcessDevices.push_back( pDevice);
- m_hMessageDeviceHandle = hModle;
- }
- }
- if (!bAddToList)
- {
- FINFO("Only Init Module from Template ");
- FreeVirtualDeviceAPI freeFunc = (FreeVirtualDeviceAPI)GetProcAddress(hModle, "ReleaseVirtualDevice");
- if (freeFunc && pDevice)
- {
- //创建对象,只是模型文件操作
- FINFO(" SetDeviceInfo {$} devSrvPath: {$} ",devPath, devSrvPath);
- pDevice->SetDeviceInfo(devPath, devSrvPath);
- FINFO("First Install Test and check Module Begin ");
- pDevice->SetClientRootID("", devSrvPath.c_str());
- FINFO("Test and check Module End ");
- freeFunc(pDevice);
- }
- }
- //m_NewDevManager.reset(pDriver);
- //succeed
- return true;
- }
- else
- {
- DWORD errNo = GetLastError();
- FERROR("lib:{$} no Object returned.ErrNo:{$}\n", devDeriverPath, errNo);
- }
- }
- else
- {
- DWORD errNo = GetLastError();
- FERROR("lib:{$} no CreateIODriver entry.ErrNo:{$}\n", devDeriverPath, errNo);
- }
- }
- else
- {
- DWORD errNo = GetLastError();
- FERROR("Load lib:{$} failed.ErrNo:{$}\n", devDeriverPath, errNo);
- }
- return false;
- }
- const int MAX_IMG_THREAD = 4;
- //using imgFuncThreadParams = std::tuple<ImageProcessAPI, int, char*, char*, char*, DWORD, LogicDevice*, LogicDevice*>;
- using imgFuncThreadParams = std::tuple<int, ImageProcessAPI*, int, char*, char*, char*, DWORD, LogicDevice*, LogicDevice**>;
- imgFuncThreadParams g_paramImgThread[MAX_IMG_THREAD];
- HANDLE g_hImgThread[MAX_IMG_THREAD];
- HANDLE g_hIdleEvent[MAX_IMG_THREAD+1];
- HANDLE g_hDataReaded[MAX_IMG_THREAD];
- HANDLE g_hDataReadyEvent[MAX_IMG_THREAD+1];
- DWORD WINAPI ImgeProcessThread(LPVOID pPara);
- bool CanModelDPC::InitDeviceMgr(const char *pDriverpath)
- {
- m_Module = LoadLibrary(pDriverpath);
- if (m_Module)
- {
- FINFO("Load Driver ok.. {$}", pDriverpath);
- GetDriverMgrAPI callfunc = (GetDriverMgrAPI)GetProcAddress(m_Module, "CreateIODriver");
- if (callfunc)
- {
- auto pDriver = reinterpret_cast <nsDEV::IODriver*> (callfunc());
- if (pDriver)
- {
- m_NewDevManager.reset(pDriver);
- //succeed
- SECURITY_ATTRIBUTES sa = { 0 };
- sa.bInheritHandle = TRUE;
- sa.nLength = sizeof(SECURITY_ATTRIBUTES);
- DWORD threadID;
- for (int x = 0; x < MAX_IMG_THREAD; x++)
- {
- g_hDataReadyEvent[x] = CreateEvent(NULL, FALSE, FALSE, NULL);
- g_hIdleEvent[x] = CreateEvent(NULL, FALSE, TRUE, NULL);
- g_hDataReaded[x] = CreateEvent(NULL, FALSE, FALSE, NULL);
- g_hImgThread[x] = CreateThread(&sa, 0, ImgeProcessThread, (void*)x, 0, &threadID);
- FINFO("Create ImageProcessThread ID={$}", threadID);
- }
- g_hDataReadyEvent[MAX_IMG_THREAD] = g_hExit;
- g_hIdleEvent[MAX_IMG_THREAD] = g_hExit;
- ///初始化 图像处理线程需要的数据
- return true;
- }
- else
- {
- DWORD errNo = GetLastError();
- FERROR("lib:{$} no Object returned.ErrNo:{$}\n", pDriverpath, errNo);
- }
- }
- else
- {
- DWORD errNo = GetLastError();
- FERROR("lib:{$} no CreateIODriver entry.ErrNo:{$}\n", pDriverpath, errNo);
- }
- }
- else
- {
- DWORD errNo = GetLastError();
- FERROR("Load lib:{$} failed.ErrNo:{$}\n", pDriverpath, errNo);
- }
- return false;
- }
- static void TrimeSDKPath(string& sdkPath)
- {
- if (sdkPath.length() > 0)
- {
- if (sdkPath[0] == '\\' || sdkPath[0] == '/')
- sdkPath = sdkPath.substr(1);
- if (sdkPath.length() > 0)
- {
- if (sdkPath[sdkPath.length() - 1] == '\\' || sdkPath[sdkPath.length() - 1] == '/')
- {
- sdkPath = sdkPath.substr(0, sdkPath.length() - 1);
- }
- }
- }
- }
- namespace fs = std::filesystem;
- void copy_directory(const fs::path& src, const fs::path& dst) {
- if (!fs::exists(dst)) {
- fs::create_directory(dst);
- }
- for (auto& dir_entry : fs::recursive_directory_iterator(src)) {
- const auto& path = dir_entry.path();
- auto relative_path = path.lexically_relative(src);
- fs::path dest_path = dst / relative_path;
- if (fs::is_directory(path)) {
- fs::create_directories(dest_path);
- }
- else if (fs::is_regular_file(path)) {
- fs::copy(path, dest_path, fs::copy_options::update_existing);
- }
- else {
- std::cerr << "Unhandled path: " << path << std::endl;
- }
- }
- }
- bool CanModelDPC::DriverEntry(ResDataObject &Configuration)
- {
- const char *pDriverpath = Configuration["oemdriver"];
- if (pDriverpath == 0 || strlen(pDriverpath) == 0)
- {
- FERROR("context of oemdriver is empty");
- return false;
- }
- m_resHardwareInfo.update("MajorID", (const char*)Configuration["MajorID"]);
- m_resHardwareInfo.update("MinorID", (const char*)Configuration["MinorID"]);
- m_resHardwareInfo.update("VendorID", (const char*)Configuration["VendorID"]);
- m_resHardwareInfo.update("ProductID", (const char*)Configuration["ProductID"]);
- m_resHardwareInfo.update("SerialID", (const char*)Configuration["SerialID"]);
- string sdkPath,realSdkPath;
- m_nServerIdx = -1;
- if (Configuration.GetKeyCount("ServerID") > 0)
- {
- //有ServerID配置
- m_nServerIdx = (int)Configuration["ServerID"];
- if (m_nServerIdx > 0)
- {
- FINFO("Need clone SDK path from 0");
- if (Configuration.GetKeyCount("SDKPath") > 0)
- {
- sdkPath = (const char*)Configuration["SDKPath"];
- realSdkPath = sdkPath;
- TrimeSDKPath(realSdkPath);
- realSdkPath = GetProcessDirectory() + "\\" + realSdkPath;
- string newSdkPath = realSdkPath + to_string(m_nServerIdx);
- FINFO("Try Copy Directory from {$} to {$}", realSdkPath, newSdkPath);
- try {
- copy_directory(realSdkPath, newSdkPath);
- }
- catch (...)
- {
- FWARN("Copy Directory from {$} to {$} Error maybe exists.", realSdkPath, newSdkPath);
- }
- if (sdkPath.length() > 0)
- {
- if (sdkPath[sdkPath.length() - 1] == '\\' )
- {
- sdkPath = sdkPath.substr(0, sdkPath.length() - 1) + to_string(m_nServerIdx) + "\\";
- }
- else if (sdkPath[sdkPath.length() - 1] == '/')
- {
- sdkPath = sdkPath.substr(0, sdkPath.length() - 1) + to_string(m_nServerIdx) + "/";
- }
- else
- {
- sdkPath = sdkPath + to_string(m_nServerIdx);
- }
- Configuration.update("SDKPath", sdkPath.c_str());
- }
- }
- }
- }
- if (InitDeviceMgr(pDriverpath) == false)
- {
- FERROR("CreateIODriver Failed.{$}",pDriverpath);
- return false;
- }
- bool ret = ModuleDriver::DriverEntry(Configuration);
- string moduleConfig = GetModuleConfigrateFilePath(m_resHardwareInfo);
- string filepath;
- try {
- ResDataObject moduleConf;
- moduleConf.loadFile(moduleConfig.c_str());
- filepath = moduleConfig;
- FINFO("Load Configration from Mudle Config [{$}]", moduleConfig);
- }
- catch (...)
- {
- FERROR("Failed to Load Configration from Driver Config [{$}]", moduleConfig);
- filepath = GetDriverConfigFilePath();
- FERROR("Try Load Configration from Driver Config [{$}]", moduleConfig);
- }
- //这里修改SDKPath和ServerID
- if (m_nServerIdx > 0 && sdkPath.length() > 0)
- {
- FINFO("Change SDKPath and ServerID {$}", m_nServerIdx);
- ResDataObject resCtx;
- try
- {
- resCtx.loadFile(filepath.c_str());
- if (resCtx.GetKeyCount("CONFIGURATION") > 0)
- {
- if (resCtx["CONFIGURATION"].GetKeyCount("SDKPath") > 0 )
- {
- resCtx["CONFIGURATION"]["SDKPath"].update("Value", sdkPath.c_str());
- }
- else
- {
- ResDataObject resObj;
- resObj.add("Value", sdkPath.c_str());
- resCtx["CONFIGURATION"].add("SDKPath", resObj);
- }
- if (resCtx["CONFIGURATION"].GetKeyCount("ServerID") > 0)
- {
- resCtx["CONFIGURATION"]["ServerID"].update("Value", m_nServerIdx);
- }
- else
- {
- ResDataObject resObj;
- resObj.add("Value", m_nServerIdx);
- resCtx["CONFIGURATION"].add("ServerID", resObj);
- }
- if (resCtx["CONFIGURATION"].GetKeyCount("ComServerID") > 0)
- {
- resCtx["CONFIGURATION"]["ComServerID"].update("Value", m_nServerIdx);
- }
-
- resCtx.SaveFile(filepath.c_str());
- }
- }
- catch (...)
- {
- FERROR("Read config file error {$}", filepath);
- }
- }
- if (ret)
- {
- //这里检查模型对象的配置项是否存在,如果是走模型配置,在安装的时候,会自动创建一份修改后的配置文件
- //这里可以直接检查到
- FINFO("m_NewDevManager->DriverEntry {$}", filepath);
- ret = m_NewDevManager->DriverEntry(filepath);
- FINFO("m_NewDevManager->Prepare ");
- m_NewDevManager->Prepare();
- }
- else
- {
- FERROR("LogicDriver::DriverEntry Failed.{$}", filepath.c_str());
- }
- return ret;
- }
- DWORD SYSTEM_CALL CanModelDPC::OnNotify(HANDLE evtList[], DWORD count)
- {
- DWORD dwResult = WaitForMultipleObjects(count, evtList, FALSE, 2500);
- if ((dwResult >= WAIT_OBJECT_0) && (dwResult < WAIT_OBJECT_0 + count - 1))
- {
- FINFO("OnNotify Platform");
- return dwResult - WAIT_OBJECT_0;
- }
- else
- {
- if (NULL != m_NewDevManager)
- {
- if (!m_NewDevManager->isConnected())
- {
- FWARN("CONNECTED is false");
- if (*m_pConnectionStatus)
- {
- FWARN("Notify disCONNECTED ");
- LogicDriver::DisConnect();
- }
- if (!*m_pConnectionStatus)
- {
- FINFO("Try CONNECT");
- if (m_NewDevManager->Connect())
- {
- FINFO("try CONNECTED is ok");
- LogicDriver::Connect();
-
- FINFO("Notify CONNECTED is ok");
- }
- else
- {
- FWARN("Notify disCONNECTED ");
- LogicDriver::DisConnect();
- FWARN("Try CONNECT failed. ");
- }
- }
-
- }
- else
- {
- if (!*m_pConnectionStatus)
- {
- FINFO("Auto CONNECTED is ok");
- LogicDriver::Connect();
- FINFO("Notify CONNECTED is ok");
- }
- }
- //此处从程序启动后会一直打印,重复调用work函数
- FINFO("ImageSaveDev->work()");
- //((ImageSaveDev*)m_pImgSaveDev)->Work();
- }
- }
- return 1;
- }
- RET_STATUS CanModelDPC::OnAction(const char* pszActionName, const char* pszParams, ResDataObject& resResponse)
- {
- RET_STATUS ret = ModuleDriver::OnAction(pszActionName, pszParams, resResponse);
- if (ret != RET_NOSUPPORT)
- {
- //成功或者失败,
- return ret;
- }
- string action = pszActionName;
- if (action == "InstallVirutalDevice")
- {
- //安装虚拟设备
- /// "ABS": {
- // "InstalHost":"Detector",
- // "ImgeProcessDevice" : "ABS\\ABSX64.dll"
- // },
- // "DAP": {
- // "MessageProcessDevice": "DAP\\DAPX64.dll"
- // }
- //
- //找到配置项,检查文件
- //ResDataObject resTest,resdll;
- //resdll.add("ImgeProcessDevice", "ABS\\ABSX64.dll");
- //resTest.add("ABS", resdll);
- ResDataObject resConf;
- string fileName = GetDriverConfigFilePath();
- FINFO("Try Load xml Config file {$} ", fileName);
- resConf.loadFile(fileName.c_str());
- //string test = resTest.encode();
- if (resConf.GetKeyCount("CONFIGURATION") <= 0)
- {
- FERROR("config file {$} content error", fileName);
- ret = RET_FAILED;
- return ret;
- }
- //resConf = resConf["CONFIGURATION"];
- ResDataObject resVirtual;
- resVirtual.decode(pszParams);
- bool changed = false;
- string strServDevPath;
- for (int vdIdx = 0; vdIdx < resVirtual.size(); vdIdx++)
- {
- bool got = false;
- string vdModuleName;
- //DTS/ABS/...
- if (strcmp(resVirtual.GetKey(vdIdx), "RespTopic") == 0)
- continue;
- if (resVirtual[vdIdx].GetKeyCount("ServDevPath") > 0)
- strServDevPath = (const char*)resVirtual[vdIdx]["ServDevPath"];
- else
- strServDevPath = "";
- for (int cfIdx = 0; cfIdx < resVirtual[vdIdx].size(); cfIdx++)
- {
- string va = (const char*)resVirtual[vdIdx][cfIdx];
- if (va.length() > 4 && va.substr(va.length() - 4, 4) == ".dll")
- {
- string type = resVirtual[vdIdx].GetKey(cfIdx);
- vdModuleName = va;
- int idx = resConf["CONFIGURATION"].GetFirstOf(type.c_str());
- while (idx != -1)
- {
- string confV = resConf["CONFIGURATION"][idx];
- if (confV == va)
- {
- got = true;
- break;
- }
- idx = resConf["CONFIGURATION"].GetNextOf(type.c_str(), idx);
- }
- if (!got)
- {
- resConf["CONFIGURATION"].add(type.c_str(), va.c_str());
- changed = true;
- break;
- }
- }
- }
- if (resVirtual[vdIdx].GetKeyCount("ServDevPath") > 0)
- {
- }
- if (got || changed)
- {
- //新装
- string newdev = "CCOS/DEVICE/" + string(resVirtual.GetKey(vdIdx));
- string devPath = newdev;
- devPath += "/" + string((const char*)m_resHardwareInfo["VendorID"]);// , (const char*)Configuration["VendorID"]);
- devPath += "/" + string((const char*)m_resHardwareInfo["ProductID"]);//, (const char*)Configuration["ProductID"]);
- devPath += "/" + string((const char*)m_resHardwareInfo["SerialID"]);//, (const char*)Configuration["SerialID"]);
- FINFO("New Virtual Device Path {$}", devPath);
- resResponse.add(strServDevPath.c_str(), "");
- if (strServDevPath.length() <= 0)
- strServDevPath = devPath;
- if (!got)
- {
- FINFO("New install VD {$]", strServDevPath);
- //之前没有配置,则需要测试,并设置
- LoadVirtualDevice(vdModuleName.c_str(), false, false, devPath, strServDevPath);
- }
- else
- {
- FINFO("VD had installed aready {$]", strServDevPath);
- for(int x=0;x<m_arrImgeProcessDevices.size();x++)
- if (m_arrImgeProcessDevices[x]->GetCcosRootPath() == strServDevPath)
- {
- //
- FINFO("VD {$} had installed aready type ImageProcessDevices with idx {$]", strServDevPath, x);
- resResponse.update(strServDevPath.c_str(), "ON");
- }
- for (int x = 0; x < m_arrMessageProcessDevices.size(); x++)
- if (m_arrMessageProcessDevices[x]->GetCcosRootPath() == strServDevPath)
- {
- //
- FINFO("VD {$} had installed aready type MessageProcessDevices with idx {$]", strServDevPath, x);
- resResponse.update(strServDevPath.c_str(), "ON");
- }
- if(strlen(resResponse[strServDevPath.c_str()]) == 0)
- resResponse.update(strServDevPath.c_str(), "OFF");
- }
- }
- }
- if (changed)
- {
- //ResDataObject save;
- //save.add("CONFIGURATION", resConf);
- resConf.SaveFile(fileName.c_str());
-
- }
- ret = RET_SUCCEED;
- //resResponse = "Install ok.";
- }
- else if (action == "restart")
- {
- resResponse = "reStart ok.";
- ret = RET_SUCCEED;
- exit(1);
- }
- return ret;
- }
- bool CanModelDPC::GetDeviceType(GUID &DevType)
- {
- string DriverType = m_NewDevManager->GetGUID();
- if (DriverType.size() == 0)
- {
- FERROR("GetDeviceType Failed");
- return false;
- }
- //if (m_pNewDevManager->GetDriverType(DriverType) == false)
- //{
- // return false;
- //}
- return string_2_guid(DriverType.c_str(), DevType);
- }
- string DEVICE_ID = "";
- string TOPIC_PREFIX = "";
- bool SYSTEM_CALL CanModelDPC::Driver_Probe(ResDataObject& PARAM_OUT HardwareInfo)
- {
- //string DriverInfo = m_NewDevManager->DriverProbe();
- FINFO("Driver : DriverInfo {$}", m_resHardwareInfo.encode());
- //if (m_pNewDevManager->Driver_Probe(DriverInfo))
- {
- ResDataObject Config = m_resHardwareInfo;
- HardwareInfo = m_resHardwareInfo;
- //if (Config.decode(DriverInfo.c_str()))
- {
- //HardwareInfo.add("MajorID", (const char*)Config["MajorID"]);
- //HardwareInfo.add("MinorID", (const char*)Config["MinorID"]);
- //HardwareInfo.add("VendorID", (const char*)Config["VendorID"]);
- //HardwareInfo.add("ProductID", (const char*)Config["ProductID"]);
- //HardwareInfo.add("SerialID", (const char*)Config["SerialID"]);
- ostringstream os,os2;
- os << (const char*)Config["VendorID"] << "_" << (const char*)Config["ProductID"] << "_" << (const char*)Config["SerialID"];
- DEVICE_ID = os.str();
-
- os2 << "" << (const char*)Config["MajorID"] ;//<< "/" << (const char*)Config["VendorID"] << "/" << (const char*)Config["ProductID"];
- os2 << "/" << (const char*)Config["SerialID"] << "/";
- TOPIC_PREFIX = os2.str();
- return true;
- }
- //else
- //{
- // FERROR("Driver_Probe Failed");
- //}
- }
- return false;
- }
- RET_STATUS CanModelDPC::GetDeviceResource(ResDataObject *pDeviceResource)
- {
- RET_STATUS ret = RET_FAILED;
- ResDataObject BaseLayerConfig;
- if ((*m_config).GetPropties().size() > 0)
- {
- ModuleDriver::GetDeviceResource(pDeviceResource);
- FINFO("ModuleDriver : GetDeviceResource {$}", pDeviceResource->encode());
- //BaseLayerConfig = *pDeviceResource;
- }
- string ResInfo;// = m_NewDevManager->GetResource();
- FINFO("IO Driver : GetDeviceResource {$}", ResInfo);
- //if (m_pNewDevManager->GetDriverResource(ResInfo))
- {
- //low layerInfo
- ResDataObject LowLayerConfig;
- if ((*m_config).GetPropties().size() <= 0)
- {
- ResInfo = m_NewDevManager->GetResource();
- if (LowLayerConfig.decode(ResInfo.c_str()) == false)
- {
- FERROR("GetDriverResource Failed");
- return ret;
- }
- ResDataObject BaseLayerConfig;
- ret = LogicDriver::GetDeviceResource(&BaseLayerConfig);
- if (ret < RET_SUCCEED)
- {
- return ret;
- }
- }
- //base LogicDriverinfo
- if (BaseLayerConfig.size() <= 0)
- {
- ret = LogicDriver::GetDeviceResource(&BaseLayerConfig);
- FINFO("LogicDriver : GetDeviceResource {$}", BaseLayerConfig.encode());
- if (ret < RET_SUCCEED)
- {
- return ret;
- }
- }
- if (LowLayerConfig.GetFirstOf("Attribute") >= 0)
- {
- //loop Low Layer Attribute
- for (size_t i = 0; i < LowLayerConfig["Attribute"].size(); i++)
- {
- const char *pKey = LowLayerConfig["Attribute"].GetKey(i);
- if (pKey)
- {
- int BaseIdx = BaseLayerConfig["Attribute"].GetFirstOf(pKey);
- if (BaseIdx >= 0)
- {
- //exist then overwrite
- BaseLayerConfig["Attribute"][BaseIdx] = LowLayerConfig["Attribute"][i];
- }
- else
- {
- //not exist then add
- BaseLayerConfig["Attribute"].add(pKey, LowLayerConfig["Attribute"][i]);
- }
- }
- }
- }
- if (LowLayerConfig.GetFirstOf("Action") >= 0)
- {
- //loop Low Layer Action
- for (size_t i = 0; i < LowLayerConfig["Action"].size(); i++)
- {
- const char *pKey = LowLayerConfig["Action"].GetKey(i);
- if (pKey)
- {
- int BaseIdx = BaseLayerConfig["Action"].GetFirstOf(pKey);
- if (BaseIdx >= 0)
- {
- //exist then overwrite
- BaseLayerConfig["Action"][BaseIdx] = LowLayerConfig["Action"][i];
- }
- else
- {
- //not exist then add
- BaseLayerConfig["Action"].add(pKey, LowLayerConfig["Action"][i]);
- }
- }
- }
- }
- (*pDeviceResource) = BaseLayerConfig;
- FINFO("GetDeviceResource Result {$}", BaseLayerConfig.encode());
- return RET_SUCCEED;
- }
- return ret;
- }
- /*
- void CanModelDPC::SubscribeSelf() {
- //这里订阅topic
- }*/
- bool CanModelDPC::Device_Probe(ResDataObject &HardwareInfo)
- {
- //string DeviceInfo = m_NewDevManager->DeviceProbe();
- FINFO("Driver : Device_Probe {$}", m_resHardwareInfo.encode());
- //if (m_pNewDevManager->Device_Probe(DeviceInfo))
- {
- //ResDataObject Config;
- //if (Config.decode(DeviceInfo.c_str()))
- {
- //HardwareInfo.add("MajorID", (const char*)Config["MajorID"]);
- //HardwareInfo.add("MinorID", (const char*)Config["MinorID"]);
- //HardwareInfo.add("VendorID", (const char*)Config["VendorID"]);
- //HardwareInfo.add("ProductID", (const char*)Config["ProductID"]);
- //HardwareInfo.add("SerialID", (const char*)Config["SerialID"]);
- HardwareInfo = m_resHardwareInfo;
- return true;
- }
- //else
- //{
- // FERROR("Device_Probe Failed");
- //}
- }
- return false;
- }
- bool CanModelDPC::SetDeviceWorkPath(const char *pWorkPath)
- {
- return true;
- }
- bool CanModelDPC::SetDriverWorkPath(const char *pWorkPath)
- {
- (*m_pWorkpath) = pWorkPath;
- //要把读取单一硬件属性的过程放到此处
- return true;
- }
- bool CanModelDPC::Connect()
- {
- bool bret = m_NewDevManager->Connect();
- if (bret)
- {
- LogicDriver::Connect();//make sure it's connected
- FINFO("Connect Succeed");
- return true;
- }
- else
- {
- FERROR("Connect Failed");
- }
- return false;
- }
- bool SYSTEM_CALL CanModelDPC::GetConnectionStatus()
- {
- return m_NewDevManager->isConnected();
- }
- void CanModelDPC::DisConnect()
- {
- m_NewDevManager->Disconnect();
- LogicDriver::DisConnect();//make sure it's Disconnected
- FINFO("DisConnect Succeed");
- }
- bool SYSTEM_CALL CanModelDPC::OnHeartBeat()
- {
- return m_NewDevManager->OnHeartBeat();
- }
- DWORD WINAPI ImgeProcessThread(LPVOID pPara)
- {
- int nIndex = (int)pPara;
- imgFuncThreadParams* pParam = g_paramImgThread + nIndex;
- HANDLE hWait[2];
- hWait[0] = g_hDataReadyEvent[nIndex];
- hWait[1] = g_hExit;
- while (true)
- {
- DWORD dwWait = WaitForMultipleObjects(2, hWait, FALSE, 1000);
- if (dwWait == WAIT_OBJECT_0)
- {
- //有图像
- int nNum = std::get<0>(*pParam);
- ImageProcessAPI* func = std::get<1>(*pParam);
- LogicDevice** pDev = std::get<8>(*pParam);
- string Head = std::get<3>(*pParam);
- string context = std::get<4>(*pParam);
- SetEvent(g_hDataReaded[nIndex]);
- if (func != nullptr)
- {
- //string temp = std::get<3>(*pParam);
- for (int x = 0; x < nNum; x++)
- {
- if (func[x] == nullptr)
- {
- FERROR("Thread[{$}] ImageProcessFunc is null with devpath= {$}", nIndex, pDev[x]->GetCcosRootPath());
- continue;
- }
- FINFO("Thread[{$}] start ImageProcess {$} from {$} with devpath= {$}", nIndex, Head, std::get<7>(*pParam)->GetCcosRootPath(), pDev[x]->GetCcosRootPath());
- func[x](std::get<2>(*pParam), Head, (char*)context.c_str(), std::get<5>(*pParam), std::get<6>(*pParam),std::get<7>(*pParam), pDev[x]);
- FINFO("Thread[{$}] ImageProcessFunc Over with devpath= {$}", nIndex, pDev[x]->GetCcosRootPath());
- }
- }
- else
- {
- FERROR("Thread[{$}] ImageProcessFunc arrpoint is null ", nIndex);
- }
- SetEvent(g_hIdleEvent[nIndex]);
- }
- else if(dwWait == WAIT_OBJECT_0 + 1)
- {
- FINFO("ImageThread {$} Got exit", nIndex);
- }
- }
- //delete pParam;
- //std::get<1>(*pParam) = Type;
- //std::get<2>(*pParam) = (char*)imageHead.c_str();
- //std::get<3>(*pParam) = (char*)resContext.encode();
- //std::get<4>(*pParam) = pFrameBuff;
- //std::get<5>(*pParam) = FrameSize;
- //std::get<6>(*pParam) = pDeviceFrom;
- //std::get<7>(*pParam) = m_arrImgeProcessDevices[x];
- return 0;
- }
- /// <summary>
- ///
- /// </summary>
- /// <param name="Type"></param>
- /// <param name="imageHead"></param>
- /// <param name="pFrameBuff"></param>
- /// <param name="FrameSize"></param>
- /// <param name="pDeviceFrom"></param>
- /// <returns></returns>
- int CanModelDPC::ImageRrocess(int Type, string& imageHead, ResDataObject& resContext, char* pFrameBuff, DWORD FrameSize, CanModelDevice* pDeviceFrom)
- {
- FINFO("Begin");
- //std::vector<HANDLE> threads;
- if (m_arrImgeFunc.size() <= 0)
- return 0;
- char* context = (char*)resContext.encode();
- char* header = (char*)imageHead.c_str();
- HANDLE thread = INVALID_HANDLE_VALUE;
- //for (int x = 0; x < m_arrImgeFunc.size(); x++)
- {
- DWORD dwWait = WaitForMultipleObjects(MAX_IMG_THREAD + 1, g_hIdleEvent, FALSE, INFINITE);
- FINFO("Wait for ImageProcessThrad Idle return {$}", dwWait);
- if (dwWait != WAIT_TIMEOUT && dwWait >= WAIT_OBJECT_0 && dwWait < WAIT_OBJECT_0 + MAX_IMG_THREAD)
- {
- imgFuncThreadParams* pParam = g_paramImgThread + (dwWait - WAIT_OBJECT_0);
- std::get<0>(*pParam) = m_arrImgeFunc.size();
- std::get<1>(*pParam) = m_arrImgeFunc.data();
- std::get<2>(*pParam) = Type;
- std::get<3>(*pParam) = header;
- std::get<4>(*pParam) = context;
- std::get<5>(*pParam) = pFrameBuff;
- std::get<6>(*pParam) = FrameSize;
- std::get<7>(*pParam) = pDeviceFrom;
- std::get<8>(*pParam) = (LogicDevice**)m_arrImgeProcessDevices.data();
- FINFO("Notify ImageProcessThread [{$}] work ", dwWait - WAIT_OBJECT_0);
- SetEvent(g_hDataReadyEvent[dwWait - WAIT_OBJECT_0]);
- //等待线程 读取完数据 ,就可以下一个
- FINFO("Start Wait {$} Thread to Read Data.", m_arrImgeFunc.size());
- DWORD dwRet = WaitForSingleObject(g_hDataReaded[dwWait - WAIT_OBJECT_0], 4000);
- if (dwRet == WAIT_OBJECT_0)
- FINFO("Over Succeded with ret {$}", dwRet);
- else
- FERROR("Over Timeout with ret {$}", dwRet);
- }
- else
- {
- FERROR("No Process this Iamge with ret {$}", dwWait);
- }
- }
- //if (m_arrImgeFunc != nullptr)
- // return m_arrImgeFunc(Type, imageHead, (char*)resContext.encode(), pFrameBuff, FrameSize, pDeviceFrom, m_arrImgeProcessDevices);
- return m_arrImgeFunc.size();
- }
- /// <summary>
- ///
- /// </summary>
- /// <param name="resNotify"></param>
- /// <param name="pDeviceFrom"></param>
- /// <returns></returns>
- int CanModelDPC::NotifyMessageProcess(ResDataObject& resNotify, CanModelDevice* pDeviceFrom)
- {
- FINFO("Begin");
- ResDataObject resResp;
- RET_STATUS ret = RET_FAILED;
- //if (m_arrMessageProcessDevices != nullptr)
- for(int x=0;x< m_arrMessageProcessDevices.size();x++)
- {
- ret = m_arrMessageProcessDevices[x]->Request(&resNotify, &resResp);
- }
- //if (m_arrImgeProcessDevices != nullptr)
- for(int x=0;x< m_arrImgeProcessDevices.size();x++)
- {
- ret = m_arrImgeProcessDevices[x]->Request(&resNotify, &resResp);
- }
- FINFO("End");
- return ret ;
- }
- void InitLogicDevice(LogicDevice* p, string guidname)
- {
- }
- PVOID CanModelDPC::LoadLogicDevices()
- {
- // std::cout << "**************** CanModelDPC :: LoadLogicDevices" << std::endl;
- FINFO( "Load Logic Devices");
- int nDeviceNumber = 1;
- string filepath = GetDriverConfigFilePath();
- ResDataObject Config;
- string imgLogicDevice, noImgLogicDevice;
- // std::cout << "**************** CanModelDPC Load Config " << filepath << std::endl;
- if (Config.loadFile(filepath.c_str()))
- {
- int nHaveDeviceNumber = (int)Config["CONFIGURATION"].GetKeyCount("DeviceNumber");
- if (nHaveDeviceNumber > 0)
- {
- nDeviceNumber = Config["CONFIGURATION"]["DeviceNumber"];
- FINFO("Have {$} Devices", nDeviceNumber);
- }
- else
- {
- FWARN("Have no DeviceNumber Attribute");
- }
- int nHaveImgLogicDevice = (int)Config["CONFIGURATION"].GetKeyCount("ImgeProcessDevice");
- if (nHaveImgLogicDevice > 0)
- {
- int first = Config["CONFIGURATION"].GetFirstOf("ImgeProcessDevice");
- while (first != -1)
- {
- imgLogicDevice = (const char*)Config["CONFIGURATION"][first];
- if (imgLogicDevice.length() > 0)
- {
- //图像处理逻辑设备
- LoadVirtualDevice(imgLogicDevice.c_str(), true);
- }
- first = Config["CONFIGURATION"].GetNextOf("ImgeProcessDevice", first);
- }
-
- }
- int nHaveNoneImgLogicDevice = (int)Config["CONFIGURATION"].GetKeyCount("MessageProcessDevice");
- if (nHaveNoneImgLogicDevice > 0)
- {
- int first = Config["CONFIGURATION"].GetFirstOf("MessageProcessDevice");
- while (first != -1)
- {
- imgLogicDevice = (const char*)Config["CONFIGURATION"][first];
- if (imgLogicDevice.length() > 0)
- {
- //图像处理逻辑设备
- LoadVirtualDevice(imgLogicDevice.c_str(), false);
- }
- first = Config["CONFIGURATION"].GetNextOf("MessageProcessDevice", first);
- }
- //noImgLogicDevice = (const char*)Config["CONFIGURATION"]["MessageProcessDevice"];
- }
- }
- else
- {
- FERROR("Load config file failed {$}",filepath.c_str());
- }
-
- DevTree *pTree = (DevTree *)GetDeviceTree();
- //imgLogicDevice "VirtualDevice/ABS/ABSX64.dll"
- //m_arrImgeProcessDevices = nullptr;
- //if (imgLogicDevice.length() > 0)
- //{
- // //图像处理逻辑设备
- // LoadVirtualDevice(imgLogicDevice.c_str(), true);
- //}
- //noImgLogicDevice "VirtualDevice/AGD/AGDX64.dll"
- //m_arrMessageProcessDevices = nullptr;
- //if (noImgLogicDevice.length() > 0)
- //{
- // //非图像处理设备
- // LoadVirtualDevice(noImgLogicDevice.c_str());
- //}
- for (int i = 0; i < nDeviceNumber; i++)
- {
- CanModelDevice *p = new CanModelDevice();
- // std::cout << " ****************CanModelDPC Try new Device " << i << " of " << nDeviceNumber << std::endl;
- auto pIoDevice = m_NewDevManager->CreateDevice(i);
- if (pIoDevice)
- {
- GUID guid2;
- string guidname;
- //((LogicDevice*)pChild)->GetDeviceType(guid);
- //bool bget = pIoDevice->GetDeviceType(guid2);
- guidname = pIoDevice->GetGUID();
- //guid_2_string(guid2, guidname);
- ResDataObject subpath;
- subpath = (guidname).c_str();
- ResDataObject probe,conn_usless;
- Device_Probe(probe);
- //此时知道宿主设备是谁,如果Generator/Detector
- //
- string hostName;
- bool isMain = false;
- if (probe.GetKeyCount("MajorID") > 0)
- {
- //找到宿主
- hostName = "CCOS/DEVICE/" + string((const char* )probe["MajorID"]);
- }
- string fullpath = MakeDevicePath(probe, conn_usless, subpath);
- string ccospath = MakeCcosPath(probe, conn_usless, subpath, false);
- if (hostName.length() > 0)
- {
- if (ccospath.substr(0, hostName.length()) == hostName)
- {
- //宿主设备
- isMain = true;
- FINFO("Got MainHost {$} of {$}", hostName, ccospath);
- }
- }
- if (isMain && m_MainHostDevice == nullptr)
- {
- m_MainHostDevice = p;
- FINFO("Add ImageProcess Deivce : {$} ", m_arrImgeProcessDevices.size());
- //嵌入式设备加载
- for (int x = 0; x < m_arrImgeProcessDevices.size(); x++)
- {
- GUID guid2;
- string guidname;
- m_arrImgeProcessDevices[x]->GetDeviceType(guid2);
- guid_2_string(guid2, guidname);
- ResDataObject subpath;
- subpath = (guidname).c_str();
- ResDataObject probe, conn_usless;
- Device_Probe(probe);
- string fullpatht = MakeDevicePath(probe, conn_usless, subpath);
- string ccospatht = MakeCcosPath(probe, conn_usless, subpath, false);
- m_arrImgeProcessDevices[x]->SetClientRootID(fullpatht.c_str(), ccospatht.c_str());
- m_arrImgeProcessDevices[x]->CompleteInit();
- pTree->Add((PVOID)(m_arrImgeProcessDevices[x]), TYPE_DEVICE);
- FINFO("Try add ccos child {$} ", ccospatht);
- m_MainHostDevice->AddCcosChildren(m_arrImgeProcessDevices[x], ccospatht.c_str());
- }
- FINFO("Add MessageProcess Deivce : {$} ", m_arrImgeProcessDevices.size());
- //if (m_arrMessageProcessDevices != nullptr)
- for (int x = 0; x < m_arrMessageProcessDevices.size(); x++)
- {
- GUID guid2;
- string guidname;
- m_arrMessageProcessDevices[x]->GetDeviceType(guid2);
- guid_2_string(guid2, guidname);
- ResDataObject subpath;
- subpath = (guidname).c_str();
- ResDataObject probe, conn_usless;
- Device_Probe(probe);
- string fullpatht = MakeDevicePath(probe, conn_usless, subpath);
- string ccospatht = MakeCcosPath(probe, conn_usless, subpath, false);
- m_arrMessageProcessDevices[x]->SetClientRootID(fullpatht.c_str(), ccospatht.c_str());
- m_arrMessageProcessDevices[x]->CompleteInit();
- pTree->Add((PVOID)(m_arrMessageProcessDevices[x]), TYPE_DEVICE);
- FINFO("Try add ccos child {$} ", ccospatht);
- m_MainHostDevice->AddCcosChildren(m_arrMessageProcessDevices[x], ccospatht.c_str());
- }
- }
- //pDevice->SetEbusRoot(fullpath.c_str());
- p->SetClientRootID(fullpath.c_str(), ccospath.c_str());
- FINFO(" SetClientRootID ", ccospath);
- //p->SetClientRootID();
- FINFO("Get IoDevice Succeed");
- p->SetDrvDPC(this);
- HANDLE DisconnectEvt = GetPassiveDisConnectEvtHandle();
- //p->ConnectMQTTServer();
- p->Init(std::move(pIoDevice), DisconnectEvt);
- //p->SubscribeAction();
- FINFO("Create IoDevice Succeed");
- }
- else
- {
- FERROR("Create IoDevice Failed");
-
- delete p;
- return NULL;
- }
- //*/
- ResDataObject resPri;
- string strPri;
- for (int x = 1; x < m_arrImgeProcessDevices.size(); x++)
- {
- for (int y = 0; y < x; y++)
- {
- unsigned int xPri, yPri;
- xPri = yPri = -1;
- if (m_arrImgeProcessDevices[x]->DevGet("", "ImageProcessIndex", resPri) == RET_SUCCEED)
- {
- strPri = (const char*)resPri;
- if (strPri.length() > 0)
- xPri = atoi(strPri.c_str());
- FINFO("Vd {$} ImageProcessIdex=[{$}]", m_arrImgeProcessDevices[x]->GetCcosRootPath(), strPri);
- }
- if (m_arrImgeProcessDevices[y]->DevGet("", "ImageProcessIndex", resPri) == RET_SUCCEED)
- {
- strPri = (const char*)resPri;
- if (strPri.length() > 0)
- xPri = atoi(strPri.c_str());
- FINFO("Vd {$} ImageProcessIdex=[{$}]", m_arrImgeProcessDevices[y]->GetCcosRootPath(), strPri);
- }
- if (xPri < yPri)
- {
- auto* pTemp = m_arrImgeProcessDevices[x];
- auto fTemp = m_arrImgeFunc[x];
- m_arrImgeProcessDevices[x] = m_arrImgeProcessDevices[y];
- m_arrImgeProcessDevices[y] = pTemp;
- m_arrImgeFunc[x] = m_arrImgeFunc[y];
- m_arrImgeFunc[y] = fTemp;
- FINFO("Exchange Vd [{$}] <=> [{$}]", x, y);
- }
- }
- }
- //*/
- LogicDevice *pret = (LogicDevice *)p;
- pTree->Add((PVOID)pret, TYPE_DEVICE);
- LogicDevice::AddEbusChildren(p, "");
- }
- return (PVOID)pTree;
- }
- void CanModelDPC::UnloadLogicDevices()
- {
- FINFO( "UnLoad Logic Devices");
- DevTree *pTree = (DevTree *)GetDeviceTree();
- size_t Size = pTree->size();
- for (size_t i = 0; i < Size; i++)
- {
- DevTreeNode node = (*pTree)[i];
- if (node.m_NodeType == TYPE_DEVICE)
- {
- CanModelDevice *pdev = (CanModelDevice*)node.m_pObject;
- delete pdev;
- }
- else
- {
- //tree dev
- //do not copy this!!!!
- //UnloadLogicDevices(node.m_pObject);
- }
- }
- pTree->clear();
- FINFO( "UnLoad Over");
- }
- RET_STATUS DATA_ACTION CanModelDPC::GetDeviceConfig(ResDataObject PARAM_OUT* pDeviceConfig)
- {
- if ((*m_config).GetPropties().size() > 0)
- {
- FERROR("GetDeviceConfig has module config do not return anything.");
- return RET_FAILED;
- }
- FINFO( "GetDeviceConfig start");
- std::string strDeviceConfig;
- if (m_NewDevManager->GetDeviceConfig(strDeviceConfig))
- {
- pDeviceConfig->decode(strDeviceConfig.c_str());
- FINFO( "GetDeviceConfig ok {$}", strDeviceConfig);
- }
- else
- {
- FERROR( "GetDeviceConfig failed");
- return RET_FAILED;
- }
- FINFO( "GetDeviceConfig Over");
- return RET_SUCCEED;
- }
- RET_STATUS DATA_ACTION CanModelDPC::SetDeviceConfig(ResDataObject PARAM_IN* DeviceConfig)
- {
- if ((*m_config).GetPropties().size() > 0)
- {
- return RET_FAILED;
- }
- FINFO( "SetDeviceConfig start");
- std::string strDeviceConfig = DeviceConfig->encode();
- if (m_NewDevManager->SetDeviceConfig(strDeviceConfig))
- {
- }
- else
- {
- return RET_FAILED;
- }
- FINFO( "SetDeviceConfig Over");
- return RET_SUCCEED;
|