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