LogicDriver.cpp 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737
  1. // LogicDriver.cpp : 定义 DLL 应用程序的导出函数。
  2. //
  3. //#include "Logger.h"
  4. #include "LogicDriver.h"
  5. #include "common_api.h"
  6. #include "PacketAnalizer.h"
  7. #include <iostream>
  8. #define Driver_DeviceID "{66888A95-CDBE-6CA6-B53F-86185E4B9C88}"
  9. LogicDriver::LogicDriver()
  10. {
  11. m_pConfigFile = new ResDataObject();
  12. m_pSubDeviceList = new SubDeviceDescriptList();
  13. m_pConnectionStatus = new BaseJsonDataObject<bool>();
  14. m_pConnectionStatus->SetKey("ConnectionStatus");
  15. (*m_pConnectionStatus) = false;
  16. m_pReConnectFlag = new BaseJsonDataObject<bool>();
  17. m_pReConnectFlag->SetKey("ReConnectFlag");
  18. (*m_pReConnectFlag) = false;
  19. m_pReConnectTimePeriod = new BaseJsonDataObject<DWORD>();
  20. m_pReConnectTimePeriod->SetKey("ReConnectTimePeriod");
  21. (*m_pReConnectTimePeriod) = 10*1000;
  22. m_pHeartBeatTimePeriod = new BaseJsonDataObject<DWORD>();
  23. m_pHeartBeatTimePeriod->SetKey("HeartBeatTimePeriod");
  24. (*m_pHeartBeatTimePeriod) = 60 * 1000;
  25. m_pSelfTestResult = new BaseJsonDataObject<DWORD>();
  26. m_pSelfTestResult->SetKey("SelfTest");
  27. (*m_pSelfTestResult) = 0;
  28. m_pConnections = new ResDataObject();
  29. m_pConnections->add("connections", "");
  30. m_DisConnectionStatusEvt = LinuxEvent::CreateEvent(LinuxEvent::MANUAL_RESET,false);//manual,disconnect evt = false
  31. m_ReConnectLastTryTime = GetTickCount();
  32. bool ret = true;
  33. ret &= m_Actions.add("SelfTest", "");
  34. ret &= m_Actions.add("Connect", "");
  35. ret &= m_Actions.add("DisConnect", "");
  36. ret &= m_Actions.add("SetReConnectOption", "");
  37. ret &= m_Actions.add("SetConnectionParam", "");
  38. ret &= m_Actions.add("SetHeartBeatTimePeriod", "");
  39. ret &= m_Actions.add("GetDriverDictionary", "");
  40. ret &= m_Actions.add("GetDeviceConfig", "");
  41. ret &= m_Actions.add("SetDeviceConfig", "");
  42. return;
  43. }
  44. LogicDriver::~LogicDriver()
  45. {
  46. delete m_pConfigFile;
  47. delete m_pSubDeviceList;
  48. delete m_pConnectionStatus;
  49. delete m_pReConnectFlag;
  50. delete m_pSelfTestResult;
  51. delete m_pReConnectTimePeriod;
  52. delete m_pHeartBeatTimePeriod;
  53. delete m_pConnections;
  54. m_pConfigFile = NULL;
  55. m_pSubDeviceList = NULL;
  56. m_pConnectionStatus = NULL;
  57. m_pReConnectFlag = NULL;
  58. m_pReConnectTimePeriod = NULL;
  59. m_pHeartBeatTimePeriod = NULL;
  60. m_pConnections = NULL;
  61. m_pSelfTestResult = NULL;
  62. m_DisConnectionStatusEvt = NULL;
  63. return;
  64. }
  65. std::shared_ptr<LinuxEvent> LogicDriver::GetPassiveDisConnectEvtHandle()
  66. {
  67. return m_DisConnectionStatusEvt;
  68. }
  69. void LogicDriver::ReSetPassiveDisConnect(bool DisConnect)
  70. {
  71. if (DisConnect)
  72. {
  73. m_DisConnectionStatusEvt->SetEvent();
  74. }
  75. else
  76. {
  77. m_DisConnectionStatusEvt->ResetEvent();
  78. }
  79. }
  80. void TryReadConnections(ResDataObject &config, ResDataObject &connection)
  81. {
  82. try
  83. {
  84. ResDataObject Context;
  85. if (config.GetFirstOf("connections") >= 0)
  86. {
  87. const char* pEncode = config["connections"].encode();//cut off \n\r \'\"
  88. Context.decode(pEncode);
  89. connection.update("connections", Context);
  90. }
  91. }
  92. catch (...)
  93. {
  94. connection["connections"] = "";
  95. }
  96. }
  97. bool SYSTEM_CALL LogicDriver::DriverEntry(ResDataObject& PARAM_IN Configuration)
  98. {
  99. try
  100. {
  101. ResDataObject Temp;
  102. (*m_pConfigFile) = Configuration;
  103. if (TryGetValue(Configuration, "ReConnect", Temp))
  104. {
  105. (*m_pReConnectFlag) = (bool)Temp;
  106. }
  107. Temp.clear();
  108. if (TryGetValue(Configuration, "ReConnectTimePeriod", Temp))
  109. {
  110. (*m_pReConnectTimePeriod) = ((DWORD)Temp)*1000;
  111. }
  112. if (TryGetValue(Configuration, "HeartBeatTimePeriod", Temp))
  113. {
  114. (*m_pHeartBeatTimePeriod) = ((DWORD)Temp) * 1000;
  115. }
  116. //try read connections
  117. TryReadConnections(Configuration, *m_pConnections);
  118. }
  119. catch (...)
  120. {
  121. return false;
  122. }
  123. return true;
  124. }
  125. //get device type
  126. bool LogicDriver::GetDeviceType(GUID &DevType)
  127. {
  128. return string_2_guid(Driver_DeviceID, DevType);
  129. }
  130. //get device resource
  131. RET_STATUS LogicDriver::GetDeviceResource(ResDataObject *pDeviceResource)
  132. {
  133. bool ret = true;
  134. //PRINTA_INFO( "GetDeviceResource");
  135. //make device type
  136. ret &= pDeviceResource->add("ClientType", DPC_DriverClient);
  137. GUID DrvType;
  138. string guidstr;
  139. GetDeviceType(DrvType);
  140. guid_2_string(DrvType, guidstr);
  141. ret &= pDeviceResource->add("DeviceType", guidstr.c_str());
  142. //make attributes
  143. ResDataObject val;
  144. ResDataObject Actions;
  145. val.add(m_pConnectionStatus->GetKey(), m_pConnectionStatus->GetVal());
  146. ResDataObject temp;
  147. temp = m_pSubDeviceList->GetResVal();
  148. val.add(m_pSubDeviceList->GetKey(), temp);
  149. //change val
  150. val.add(m_pSelfTestResult->GetKey(), m_pSelfTestResult->GetVal());
  151. val.add(m_pReConnectFlag->GetKey(), m_pReConnectFlag->GetVal());
  152. val.add(m_pReConnectTimePeriod->GetKey(), m_pReConnectTimePeriod->GetVal());
  153. val.add(m_pHeartBeatTimePeriod->GetKey(), m_pHeartBeatTimePeriod->GetVal());
  154. val.add(m_pConnections->GetKey(0), (*m_pConnections)[0]);
  155. ResDataObject Diction;
  156. if (GetDriverDictionary(Diction) >= RET_SUCCEED)
  157. {
  158. val.add("DriverDictionary", Diction);
  159. }
  160. else
  161. {
  162. val.add("DriverDictionary", "");
  163. }
  164. ret &= pDeviceResource->add("Attribute", val);
  165. /*
  166. ret &= Actions.add("SelfTest", "");
  167. ret &= Actions.add("Connect", "");
  168. ret &= Actions.add("DisConnect", "");
  169. ret &= Actions.add("SetReConnectOption", "");
  170. ret &= Actions.add("SetConnectionParam", "");
  171. ret &= Actions.add("SetHeartBeatTimePeriod", "");
  172. ret &= Actions.add("GetDriverDictionary", "");
  173. ret &= Actions.add("GetDeviceConfig", "");
  174. ret &= Actions.add("SetDeviceConfig", "");*/
  175. if (ret)
  176. {
  177. pDeviceResource->add("Action", m_Actions);
  178. return RET_SUCCEED;
  179. }
  180. return RET_FAILED;
  181. }
  182. void SYSTEM_CALL LogicDriver::SetDpcsIdentifyKey(const char *pszIdentifykey)
  183. {
  184. m_SerialNo = pszIdentifykey;
  185. }
  186. const char* SYSTEM_CALL LogicDriver::GetDpcsSerialNo()
  187. {
  188. return (const char *)m_SerialNo;
  189. }
  190. RET_STATUS LogicDriver::GetSEQResource(ResDataObject PARAM_OUT *pDeviceResource)
  191. {
  192. ResDataObject Events;
  193. Events.add(m_pConnectionStatus->GetKey(), INFINITE);
  194. pDeviceResource->update("Event", Events);
  195. return RET_SUCCEED;
  196. }
  197. RET_STATUS DATA_ACTION LogicDriver::SelfTest()
  198. {
  199. RET_STATUS ret = RET_SUCCEED;
  200. if ((*m_pSelfTestResult) != 1)
  201. {
  202. //发通知
  203. ResDataObject NotifyData;
  204. (*m_pSelfTestResult) = 1;
  205. PacketAnalizer::MakeNotify(NotifyData, PACKET_CMD_UPDATE, m_pSelfTestResult->GetKey(), m_pSelfTestResult->GetVal());
  206. //CmdFromLogicDev(&NotifyData);
  207. PublishAction(&NotifyData, (m_strEBusRoot + "/Notify").c_str(), m_pMqttConntion);
  208. }
  209. return ret;
  210. }
  211. //ResourceCommand Request In and Response Out
  212. RET_STATUS LogicDriver::Request(ResDataObject *pRequest, ResDataObject *pResponse)
  213. {
  214. ResDataObject res;
  215. RET_STATUS ret = RET_NOSUPPORT;
  216. //1. analize request
  217. PACKET_CMD cmd = PacketAnalizer::GetPacketCmd(pRequest);
  218. //cmd:get,set,add,del,exe,
  219. //ignore open/close
  220. //Action和Attr应该做成一个MAP,经过MAP访问这些资源,不应该是switch case
  221. //为了快速做一版,先保留switch case!!!
  222. string keystr = PacketAnalizer::GetPacketKey(pRequest);
  223. //PRINTA_INFO(m_pLogger, "Request is %s", keystr.c_str());
  224. ACTION_SYNC_MODE syncmode = PacketAnalizer::GetPacketSyncMode(pRequest);
  225. switch (cmd){
  226. case PACKET_CMD_GET:
  227. {
  228. if (keystr.size() == 0)
  229. {
  230. //get resource
  231. ret = GetDeviceResource(&res);
  232. pResponse->update("CONTEXT", res);
  233. }
  234. else
  235. {
  236. //it must be attribute get
  237. //Action和Attr应该做成一个MAP,经过MAP访问这些资源
  238. //重新考虑了一遍,这个GET意义不大.因为值的变化总是以Data Notify形式进行同步.
  239. assert(0);//NOT FINISHED YET
  240. //这点需要应用层的确认,如果应用层没有获取,就没人调用进来
  241. //if(keystr == m_Status.GetKey())
  242. //{
  243. // //yes they want it
  244. // //CMD的关键字是否要改成SET???
  245. // pResponse->update("CONTEXT",m_Status.GetVal());
  246. // ret = RET_SUCCEED;
  247. // PacketAnalizer::MakeRetCode(ret,pResponse);
  248. //}
  249. }
  250. }
  251. break;
  252. case PACKET_CMD_EXE:
  253. {
  254. if (keystr == "Connect")
  255. {
  256. if (Connect())
  257. {
  258. ret = RET_SUCCEED;
  259. }
  260. else
  261. {
  262. ret = RET_FAILED;
  263. }
  264. }
  265. else if (keystr == "SelfTest")
  266. {
  267. ret = SelfTest();
  268. }
  269. else if (keystr == "GetDriverDictionary")
  270. {
  271. ResDataObject obj;
  272. obj.add("DriverDictionary", "");
  273. ret = GetDriverDictionary(obj["DriverDictionary"]);
  274. if (ret >= RET_SUCCEED)
  275. {
  276. res.add("P0", obj);
  277. //3. 打包
  278. pResponse->update("CONTEXT", res);
  279. }
  280. }
  281. else if (keystr == "DisConnect")
  282. {
  283. DisConnect();
  284. ret = RET_SUCCEED;
  285. }
  286. else if (keystr == "SetReConnectOption")
  287. {
  288. bool result = true;
  289. ResDataObject obj1, obj2;
  290. result &= PacketAnalizer::GetParam(pRequest, 0, obj1);
  291. result &= PacketAnalizer::GetParam(pRequest, 1, obj2);
  292. if (result)
  293. {
  294. ret = SetReConnectOption(obj1, obj2);
  295. }
  296. }
  297. else if (keystr == "SetConnectionParam")
  298. {
  299. bool result = true;
  300. ResDataObject obj1, obj2;
  301. result &= PacketAnalizer::GetParam(pRequest, 0, obj1);
  302. result &= PacketAnalizer::GetParam(pRequest, 1, obj2);
  303. if (result)
  304. {
  305. ret = SetConnectionParam((const char*)obj1, obj2);
  306. }
  307. }
  308. else if (keystr == "SetHeartBeatTimePeriod")
  309. {
  310. bool result = true;
  311. ResDataObject obj1;
  312. result &= PacketAnalizer::GetParam(pRequest, 0, obj1);
  313. if (result)
  314. {
  315. ret = SetHeartBeatTimePeriod((DWORD)obj1);
  316. }
  317. }
  318. else if (keystr == "GetDeviceConfig")
  319. {
  320. ret = (RET_STATUS)GetDeviceConfig(&res);
  321. pResponse->update("CONTEXT", res);
  322. }
  323. else if (keystr == "SetDeviceConfig")
  324. {
  325. bool result = true;
  326. ResDataObject obj1;
  327. result &= PacketAnalizer::GetParam(pRequest, 0, obj1);
  328. if (result)
  329. {
  330. ret = (RET_STATUS)SetDeviceConfig(&obj1);
  331. }
  332. }
  333. }
  334. break;
  335. default:
  336. //对当前设备来讲,其他都是浮云
  337. break;
  338. }
  339. //return status
  340. PacketAnalizer::MakeRetCode(ret, pResponse);
  341. return ret;
  342. }
  343. //notify to lower layer
  344. RET_STATUS LogicDriver::CmdToLogicDev(ResDataObject *pCmd)
  345. {
  346. //这个命令只有一种情况下发生(作为客户端存在的时候)
  347. //1.设备的Notify消息
  348. //发往当前客户端的Notify
  349. //Data&Action notify!!!
  350. //Data Notify分两种
  351. //一种是本数据对象的更新,直接更新
  352. //一种是数据传递给上层,比如图像数据,探测器的剂量需求数据
  353. //Action Notify是发给Owner的
  354. //通知事件,让Owner知道,另外ActionNotify先保留下来
  355. //保留到哪里???
  356. //2.Response
  357. //命令Request发出后的反馈
  358. //1. analize request
  359. //2. call api
  360. //3. check results
  361. //put error log here
  362. assert(0);//not happening
  363. return RET_FAILED;
  364. }
  365. RET_STATUS LogicDriver::SetHeartBeatTimePeriod(DWORD TimePeriod)
  366. {
  367. RET_STATUS ret = RET_SUCCEED;
  368. if ((*m_pHeartBeatTimePeriod) != TimePeriod)
  369. {
  370. //发通知
  371. ResDataObject NotifyData;
  372. (*m_pHeartBeatTimePeriod) = TimePeriod;
  373. PacketAnalizer::MakeNotify(NotifyData, PACKET_CMD_UPDATE, m_pHeartBeatTimePeriod->GetKey(), m_pHeartBeatTimePeriod->GetVal());
  374. CmdFromLogicDev(&NotifyData);
  375. //PublishAction(&NotifyData, (m_strEBusRoot + "/Notify").c_str(), m_pMqttConntion);
  376. }
  377. return ret;
  378. }
  379. bool LogicDriver::AddDevice(const char *pPath)
  380. {
  381. //添加设备
  382. if (m_pSubDeviceList->AddDevice(pPath))
  383. {
  384. //发通知
  385. ResDataObject NotifyData;
  386. ResDataObject theContext;
  387. theContext = (pPath);
  388. PacketAnalizer::MakeNotify(NotifyData, PACKET_CMD_ADD, m_pSubDeviceList->GetKey(), theContext);
  389. CmdFromLogicDev(&NotifyData);
  390. //PublishAction(&NotifyData, (m_strEBusRoot + "/Notify").c_str(), m_pMqttConntion);
  391. return true;
  392. }
  393. return false;
  394. }
  395. bool LogicDriver::DelDevice(const char *pPath)
  396. {
  397. //删除设备
  398. if (m_pSubDeviceList->DelDevice(pPath))
  399. {
  400. //发通知
  401. ResDataObject NotifyData;
  402. ResDataObject theContext;
  403. theContext = (pPath);
  404. PacketAnalizer::MakeNotify(NotifyData, PACKET_CMD_DEL, m_pSubDeviceList->GetKey(), theContext);
  405. CmdFromLogicDev(&NotifyData);
  406. //PublishAction(&NotifyData, (m_strEBusRoot + "/Notify").c_str(), m_pMqttConntion);
  407. return true;
  408. }
  409. return false;
  410. }
  411. void SYSTEM_CALL LogicDriver::GetDeviceList(ResDataObject &Object)
  412. {
  413. Object = (*m_pSubDeviceList).GetResVal();
  414. }
  415. void LogicDriver::SetLastDisconnectTime(DWORD LastTick)
  416. {
  417. if ((*m_pConnectionStatus) == false)
  418. {
  419. m_ReConnectLastTryTime = LastTick;
  420. }
  421. }
  422. DWORD LogicDriver::GetLastDisconnectTime()
  423. {
  424. if ((*m_pConnectionStatus) == false)
  425. {
  426. DWORD ret = m_ReConnectLastTryTime;
  427. return ret;
  428. }
  429. return 0;
  430. }
  431. RET_STATUS LogicDriver::GetHeartBeatTimePeriod(DWORD &TimePeriod)
  432. {
  433. TimePeriod = (*m_pHeartBeatTimePeriod);
  434. return RET_SUCCEED;
  435. }
  436. RET_STATUS LogicDriver::GetReConnectOption(bool &Flag, DWORD &TimePeriod)
  437. {
  438. Flag = (*m_pReConnectFlag);
  439. TimePeriod = (*m_pReConnectTimePeriod);
  440. return RET_SUCCEED;
  441. }
  442. bool LogicDriver::GetConnectionStatus()
  443. {
  444. return (*m_pConnectionStatus);
  445. }
  446. void LogicDriver::OnSetClientID()
  447. {
  448. //
  449. std::cout << "LogicDriver " << endl;
  450. }
  451. void LogicDriver::SubscribeSelf() //所有子类必须使用 SubscribeTopic 订阅自身topic及资源topic,如果不知道需要DPC代订阅
  452. {
  453. LogicDevice::SubscribeSelf();
  454. if (m_strEBusRoot.length() > 0)
  455. SubscribeTopic(m_pMqttConntion, m_strEBusRoot.c_str());
  456. SubscribeActions();
  457. std::cout << "LogicDriver " << endl;
  458. //SubscribeTopic(m_pMqttConntion)
  459. }
  460. RET_STATUS LogicDriver::SetReConnectOption(bool Flag, DWORD TimePeriod)
  461. {
  462. RET_STATUS ret = RET_SUCCEED;
  463. if ((*m_pReConnectFlag) != Flag)
  464. {
  465. //发通知
  466. ResDataObject NotifyData;
  467. (*m_pReConnectFlag) = Flag;
  468. PacketAnalizer::MakeNotify(NotifyData, PACKET_CMD_UPDATE, m_pReConnectFlag->GetKey(), m_pReConnectFlag->GetVal());
  469. CmdFromLogicDev(&NotifyData);
  470. //PublishAction(&NotifyData, (m_strEBusRoot + "/Notify").c_str(), m_pMqttConntion);
  471. }
  472. if ((*m_pReConnectTimePeriod) != TimePeriod)
  473. {
  474. //发通知
  475. ResDataObject NotifyData;
  476. (*m_pReConnectTimePeriod) = TimePeriod;
  477. PacketAnalizer::MakeNotify(NotifyData, PACKET_CMD_UPDATE, m_pReConnectTimePeriod->GetKey(), m_pReConnectTimePeriod->GetVal());
  478. CmdFromLogicDev(&NotifyData);
  479. //PublishAction(&NotifyData, (m_strEBusRoot + "/Notify").c_str(), m_pMqttConntion);
  480. }
  481. return ret;
  482. }
  483. bool SYSTEM_CALL LogicDriver::Driver_Probe(ResDataObject& PARAM_OUT DriverInfo)
  484. {
  485. ResDataObject Config;
  486. GetConfiguration(&Config);
  487. DriverInfo.add("MajorID", (const char*)Config["MajorID"]);
  488. DriverInfo.add("MinorID", (const char*)Config["MinorID"]);
  489. DriverInfo.add("VendorID", (const char*)Config["VendorID"]);
  490. DriverInfo.add("ProductID", (const char*)Config["ProductID"]);
  491. DriverInfo.add("SerialID", (const char*)Config["SerialID"]);
  492. return true;
  493. }
  494. void SYSTEM_CALL LogicDriver::GetConfiguration(ResDataObject *pConfig)
  495. {
  496. (*pConfig) = (*m_pConfigFile);
  497. }
  498. ResDataObject& LogicDriver::GetConnectionParam()
  499. {
  500. return (*m_pConnections)["connections"];
  501. }
  502. RET_STATUS LogicDriver::SetConnectionParam(const char *pTitle, ResDataObject &ConnectionContext)
  503. {
  504. RET_STATUS ret = RET_SUCCEED;
  505. try
  506. {
  507. int idx = (*m_pConnections)[0].GetFirstOf(pTitle);
  508. if (idx >= 0)
  509. {
  510. //update it
  511. //check it before set
  512. (*m_pConnections)[0][idx] = ConnectionContext;
  513. //notify it
  514. ResDataObject Context;
  515. ResDataObject NotifyData;
  516. Context.add(pTitle, ConnectionContext);
  517. PacketAnalizer::MakeNotify(NotifyData, PACKET_CMD_UPDATE, m_pConnections->GetKey(0), Context);
  518. CmdFromLogicDev(&NotifyData);
  519. //PublishAction(&NotifyData, (m_strEBusRoot + "/Notify").c_str(), m_pMqttConntion);
  520. }
  521. }
  522. catch (...)
  523. {
  524. ret = RET_FAILED;
  525. }
  526. return ret;
  527. }
  528. bool DATA_ACTION LogicDriver::Connect()
  529. {
  530. if ((*m_pConnectionStatus) == false)
  531. {
  532. //发通知
  533. ResDataObject NotifyData;
  534. (*m_pConnectionStatus) = true;
  535. m_DisConnectionStatusEvt->ResetEvent();
  536. PacketAnalizer::MakeNotify(NotifyData, PACKET_CMD_UPDATE, m_pConnectionStatus->GetKey(), m_pConnectionStatus->GetVal());
  537. CmdFromLogicDev(&NotifyData);
  538. //PublishAction(&NotifyData, (m_strEBusRoot + "/Notify").c_str(), m_pMqttConntion);
  539. return true;
  540. }
  541. return false;
  542. }
  543. void DATA_ACTION LogicDriver::DisConnect()
  544. {
  545. //if ((*m_pConnectionStatus) == true)
  546. {
  547. //发通知
  548. ResDataObject NotifyData;
  549. (*m_pConnectionStatus) = false;
  550. m_DisConnectionStatusEvt->SetEvent();
  551. PacketAnalizer::MakeNotify(NotifyData, PACKET_CMD_UPDATE, m_pConnectionStatus->GetKey(), m_pConnectionStatus->GetVal());
  552. //PublishAction(&NotifyData, (m_strEBusRoot + "/Notify").c_str(), m_pMqttConntion);
  553. CmdFromLogicDev(&NotifyData);
  554. }
  555. //发删除设备通知
  556. //for (size_t i = 0; i < m_pSubDeviceList->m_DeviceList.size(); i++)
  557. //{
  558. // string DevPath = m_pSubDeviceList->m_DeviceList[i];
  559. // ResDataObject NotifyData;
  560. // ResDataObject theContext;
  561. // theContext = DevPath.c_str();
  562. // PacketAnalizer::MakeNotify(NotifyData, PACKET_CMD_DEL, m_pSubDeviceList->GetKey(), theContext);
  563. // CmdFromLogicDev(&NotifyData);
  564. // //PublishAction(&NotifyData, (m_strEBusRoot + "/Notify").c_str(), m_pMqttConntion);
  565. //}
  566. ////清除设备列表
  567. //m_pSubDeviceList->m_DeviceList.clear();
  568. //设置时间
  569. SetLastDisconnectTime(GetTickCount());
  570. }
  571. bool SYSTEM_CALL LogicDriver::OnHeartBeat()
  572. {
  573. return true;
  574. }
  575. RET_STATUS DATA_ACTION LogicDriver::SetDeviceConfig(ResDataObject PARAM_IN *DeviceConfig)
  576. {
  577. return RET_SUCCEED;
  578. }
  579. RET_STATUS DATA_ACTION LogicDriver::GetDeviceConfig(ResDataObject PARAM_OUT *pDeviceConfig)
  580. {
  581. return RET_SUCCEED;
  582. }