MACHINE_DPC.cpp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669
  1. #include "stdafx.h"
  2. #include <map>
  3. #include "All.h"
  4. #include "MACHINE_DPC.h"
  5. #include "MACHINE_Logical.h"
  6. #include "MACHINE_MammoLogic.h"
  7. #include "MACHINE_StitchLogic.h"
  8. #include "PacketAnalizer.h"
  9. #include "common_api.h"
  10. #ifdef CMD_ANSYNC
  11. #include "RingBuffer.h"
  12. #endif
  13. #define MACHINERY_TID "DetectorToTableDistance"
  14. #define MACHINERY_SID "DistanceSourcetoDetector"
  15. #define MACHINERY_ENTRANCE "DistanceSourcetoEntrance"
  16. #define MACHINERY_GEOMETRY "GeometryKeyword"
  17. #define MACHINERY_PROJECTIONNUM "ProjectionNum"
  18. #define MACHINERY_MAXANGLE "ProjectionMaxAngle"
  19. #define MACHINERY_DIRECTION "ProjectionDirection"
  20. int FormatCMD(char * pCmd, int nSize)
  21. {
  22. pCmd[nSize] = 0x0d;
  23. nSize++;
  24. pCmd[nSize] = 0x0a;
  25. nSize++;
  26. pCmd[nSize] = 0;
  27. return nSize;
  28. }
  29. /////////////////////////////////////////////////////////////////////////
  30. /////////////////////////////////////////////////////////////////////////
  31. #define FUNNAME_CREATE_SCF TEXT("GetSCF")
  32. #define FUNNAME_RELEASE_SCF TEXT("ReleseSCF")
  33. #define OFFSET_CLASSNAME_DOSE 14
  34. #define OFFSET_CLASSNAME_DOSE_SP 22
  35. #define OFFSET_CLASSNAME_LOGIC 17
  36. #define OFFSET_CLASSNAME_LOGIC_SP 25
  37. #define CMD_LEN_MAX 128
  38. #define TIMEOUTVALUE 1000
  39. CMACHINE_DPC::CMACHINE_DPC()
  40. {
  41. m_pWorkpath = new std::string();
  42. m_pNotify = NULL;
  43. m_hConnectFinish = CreateEvent(NULL, true, false, NULL);
  44. m_hBeginConnect = CreateEvent(NULL, true, false, NULL);
  45. m_hConnection = CreateEvent(NULL, true, false, NULL);
  46. m_hMechReady = CreateEvent(NULL, false, false, NULL);
  47. m_hMechGetPostionFinished = CreateEvent(NULL, false, false, NULL);
  48. m_DetectorToTableDistance.add(MACHINERY_TID, (FLOAT)0.0);
  49. m_DistanceSourcetoDetector.add(MACHINERY_SID, (FLOAT)1.0);
  50. m_DistanceSourcetoEntrance.add(MACHINERY_ENTRANCE, (FLOAT)15.0);
  51. m_GEOMETRY.add(MACHINERY_GEOMETRY, "liner");
  52. m_ProjectionNum.add(MACHINERY_PROJECTIONNUM, (INT)15);
  53. m_ProjectionMaxAngle.add(MACHINERY_MAXANGLE, (FLOAT)15.0);
  54. m_ProjectionDirection.add(MACHINERY_DIRECTION, (INT)-1);
  55. m_pGenVender = new ConfigInfo("Vender");
  56. m_pGenModel = new ConfigInfo("Model");
  57. m_pGenSyncType = new ConfigInfo(DiosSyncType);
  58. m_pGenSCFType = new ConfigInfo(DiosSCFType);
  59. m_pGenSCFPort = new ConfigInfo(DiosSCFPort);
  60. m_pTID = new ConfigInfo(MACHINERY_TID);
  61. m_pSID = new ConfigInfo(MACHINERY_SID);
  62. m_pENTRANCE = new ConfigInfo(MACHINERY_ENTRANCE);
  63. m_pGEOMETRY = new ConfigInfo(MACHINERY_GEOMETRY);
  64. }
  65. CMACHINE_DPC::~CMACHINE_DPC()
  66. {
  67. delete m_pWorkpath;
  68. delete m_pGenVender;
  69. delete m_pGenModel;
  70. delete m_pGenSyncType;
  71. delete m_pGenSCFType;
  72. delete m_pGenSCFPort;
  73. delete m_pTID;
  74. delete m_pSID;
  75. delete m_pENTRANCE;
  76. delete m_pGEOMETRY;
  77. }
  78. //bool CMACHINE_DPC::DpcEntry(ResDataObject &Configuration)
  79. //{
  80. // try
  81. // {
  82. // m_DeviceConfig = Configuration;
  83. // }
  84. // catch (...)
  85. // {
  86. // PRINTA_INFO(m_pLog, "Can't get the Configuration for Device");
  87. // }
  88. // PRINTA_INFO(m_pLog, "DpcEntry Configuration");
  89. //
  90. // return true;
  91. //}
  92. //
  93. //ResDataObject CMACHINE_DPC::GetConnectionType()
  94. //{
  95. // return ResDataObject();
  96. //}
  97. //
  98. //bool CMACHINE_DPC::Connect(ResDataObject &Connection)
  99. //{
  100. // m_pSCFServer = m_fpGetSCF();
  101. //
  102. // int Result = m_pSCFServer->Connect(Connection, &CMACHINE_DPC::PackageProcess, SCF_PACKET_TRANSFER);
  103. // if (Result != SCF_SUCCEED)
  104. // {
  105. // return false;
  106. // }
  107. //
  108. // return true;
  109. //}
  110. //
  111. //bool CMACHINE_DPC::Probe(ResDataObject &HardwareInfo)
  112. //{
  113. //#ifdef ENV_DIOS
  114. // HardwareInfo.add("MajorID", "Generator");
  115. // HardwareInfo.add("MinorID", "DR");
  116. // HardwareInfo.add("VendorID", "CPI");
  117. // HardwareInfo.add("ProductID", "SHF");
  118. // HardwareInfo.add("SerialID", "1234");
  119. //#endif
  120. // return true;
  121. //}
  122. //
  123. //bool CMACHINE_DPC::SetWorkPath(const char *pWorkPath)
  124. //{
  125. // m_strWorkPath = pWorkPath;
  126. // return true;
  127. //}
  128. //
  129. //PVOID CMACHINE_DPC::LoadLogicDevices()
  130. //{
  131. // DevTree *pTree = new DevTree();
  132. // LogicDevice * pLD = NULL;
  133. //
  134. // //Load DOSE Logic unit
  135. // m_pGenDose = new CMACHINE_Dose();
  136. // m_pGenDose->DPCPoint(this);
  137. // pLD = (LogicDevice *)m_pGenDose;
  138. // pTree->Add((PVOID)pLD, TYPE_DEVICE);
  139. //
  140. // //Load SyncGen
  141. // m_pGenLogical = new CMACHINE_Logical();
  142. // m_pGenLogical->DPCPoint(this);
  143. // pLD = (LogicDevice *)m_pGenLogical;
  144. // pTree->Add((PVOID)pLD, TYPE_DEVICE);
  145. //
  146. //#if 0
  147. // try{
  148. // m_pGenDose->m_DeviceConfig.nTable = (int)(m_DeviceConfig["Table"]);
  149. // m_pGenDose->m_DeviceConfig.nWall = (int)(m_DeviceConfig["Wall"]);
  150. // m_pGenDose->m_DeviceConfig.nFree = (int)(m_DeviceConfig["Free"]);
  151. // m_pGenDose->m_DeviceConfig.nTomo = (int)(m_DeviceConfig["Tomo"]);
  152. // m_pGenDose->m_DeviceConfig.nConventional = (int)(m_DeviceConfig["Conventional"]);
  153. // }
  154. // catch (...)
  155. // {
  156. // printf("Get Gen config item Crash.\n");
  157. // }
  158. //#endif
  159. // return (PVOID)pTree;
  160. //}
  161. //
  162. //void CMACHINE_DPC::UnloadLogicDevices(/*LogicDevice*/PVOID p)
  163. //{
  164. //#ifdef ENV_DIOS
  165. // DevTree *pTree = (DevTree*)p;
  166. // size_t Size = pTree->size();
  167. // for (size_t i = 0; i < Size; i++)
  168. // {
  169. // DevTreeNode node = (*pTree)[i];
  170. // if (node.m_NodeType == TYPE_DEVICE)
  171. // {
  172. // LogicDevice *pdev = (LogicDevice*)node.m_pObject;
  173. // delete pdev;
  174. // }
  175. // else
  176. // {
  177. // //tree dev
  178. // //do not copy this!!!!
  179. // UnloadLogicDevices(node.m_pObject);
  180. // }
  181. // }
  182. //
  183. // delete pTree;
  184. //#endif
  185. //}
  186. //
  187. //bool CMACHINE_DPC::DisConnect()
  188. //{
  189. // m_pSCFServer->Disconnect();
  190. // m_fpReleaseSCF(m_pSCFServer);
  191. // return true;
  192. //}
  193. //
  194. //bool CMACHINE_DPC::OnNotify(HANDLE ExitNotify)
  195. //{
  196. // Work();
  197. // return true;
  198. //}
  199. bool CMACHINE_DPC::DriverEntry(ResDataObject &Configuration)
  200. {
  201. try
  202. {
  203. m_DeviceConfig = Configuration;
  204. }
  205. catch (...)
  206. {
  207. PRINTA_INFO(m_pLog, "Can't get the Configuration for Device");
  208. }
  209. PRINTA_INFO(m_pLog, "DpcEntry Configuration");
  210. return LogicDriver::DriverEntry(Configuration);
  211. }
  212. bool CMACHINE_DPC::Driver_Probe(ResDataObject &HardwareInfo)
  213. {
  214. ResDataObject Config;
  215. GetConfiguration(&Config);
  216. HardwareInfo.add("MajorID", (const char*)Config["MajorID"]);
  217. HardwareInfo.add("MinorID", (const char*)Config["MinorID"]);
  218. HardwareInfo.add("VendorID", (const char*)Config["VendorID"]);
  219. HardwareInfo.add("ProductID", (const char*)Config["ProductID"]);
  220. HardwareInfo.add("SerialID", (const char*)Config["SerialID"]);
  221. return true;
  222. }
  223. bool SYSTEM_CALL CMACHINE_DPC::SetDriverWorkPath(const char * PARAM_IN pWorkPath)
  224. {
  225. return true;
  226. }
  227. PVOID SYSTEM_CALL CMACHINE_DPC::LoadDriver()
  228. {
  229. return NULL;
  230. }
  231. void SYSTEM_CALL CMACHINE_DPC::UnloadDriver()
  232. {
  233. }
  234. bool CMACHINE_DPC::Connect()
  235. {
  236. LogicDriver::Connect();
  237. return true;
  238. }
  239. bool CMACHINE_DPC::Device_Probe(ResDataObject &HardwareInfo)
  240. {
  241. ResDataObject Config;
  242. GetConfiguration(&Config);
  243. HardwareInfo.add("MajorID", (const char*)Config["MajorID"]);
  244. HardwareInfo.add("MinorID", (const char*)Config["MinorID"]);
  245. HardwareInfo.add("VendorID", (const char*)Config["VendorID"]);
  246. HardwareInfo.add("ProductID", (const char*)Config["ProductID"]);
  247. HardwareInfo.add("SerialID", "1234");
  248. return true;
  249. }
  250. bool CMACHINE_DPC::SetDeviceWorkPath(const char *pWorkPath)
  251. {
  252. (*m_pWorkpath) = pWorkPath;
  253. //要把读取单一硬件属性的过程放到此处
  254. return true;
  255. }
  256. PVOID CMACHINE_DPC::LoadLogicDevices()
  257. {
  258. DevTree *pTree = (DevTree *)GetDeviceTree();
  259. if ((string)m_DeviceConfig["MechType"] == "0")
  260. {
  261. m_pGenLogical = new CMACHINE_Logical();
  262. m_pGenLogical->DPCPoint(this);
  263. LogicDevice *pret = (LogicDevice *)m_pGenLogical;
  264. pTree->Add((PVOID)pret, TYPE_DEVICE);
  265. m_pGenLogical->NotifyMachineryReadyState(true);
  266. }
  267. else if ((string)m_DeviceConfig["MechType"] == "1")
  268. {
  269. CMACHINE_StitchLogic *pGenLogical = new CMACHINE_StitchLogic();
  270. pGenLogical->DPCPoint(this);
  271. LogicDevice *pret = (LogicDevice *)pGenLogical;
  272. pTree->Add((PVOID)pret, TYPE_DEVICE);
  273. }
  274. else
  275. {
  276. CMACHINE_MammoLogic *pGenLogical = new CMACHINE_MammoLogic();
  277. pGenLogical->DPCPoint(this);
  278. LogicDevice *pret = (LogicDevice *)pGenLogical;
  279. pTree->Add((PVOID)pret, TYPE_DEVICE);
  280. }
  281. return (PVOID)pTree;
  282. }
  283. void CMACHINE_DPC::UnloadLogicDevices()
  284. {
  285. DevTree *pTree = (DevTree *)GetDeviceTree();
  286. size_t Size = pTree->size();
  287. for (size_t i = 0; i < Size; i++)
  288. {
  289. DevTreeNode node = (*pTree)[i];
  290. if (node.m_NodeType == TYPE_DEVICE)
  291. {
  292. LogicDevice *pdev = (LogicDevice*)node.m_pObject;
  293. delete pdev;
  294. }
  295. else
  296. {
  297. //tree dev
  298. //do not copy this!!!!
  299. //UnloadLogicDevices(node.m_pObject);
  300. }
  301. }
  302. pTree->clear();
  303. PRINTA_INFO(m_pLog, "UnLoad Over");
  304. }
  305. void CMACHINE_DPC::DisConnect()
  306. {
  307. LogicDriver::DisConnect();
  308. }
  309. bool SYSTEM_CALL CMACHINE_DPC::OnHeartBeat()
  310. {
  311. return true;
  312. }
  313. void MakeComList(int TotalIdx, string &Result)
  314. {
  315. Result = "";
  316. ResDataObject Res;
  317. for (int i = 0; i < TotalIdx; i++)
  318. {
  319. string key = FormatstdString("%d", i);
  320. string Context = FormatstdString("COM%d", i + 1);
  321. Res.add(key.c_str(), Context.c_str());
  322. }
  323. Result = Res.encode();
  324. }
  325. RET_STATUS SYSTEM_CALL CMACHINE_DPC::GetDeviceResource(ResDataObject PARAM_OUT *pDeviceResource)
  326. {
  327. RET_STATUS rs = LogicDriver::GetDeviceResource(pDeviceResource);
  328. bool ret = true;
  329. ResDataObject val = (*pDeviceResource)["Attribute"];
  330. //val.add(MACHINERY_READY, m_MachineryReady[MACHINERY_READY]);
  331. val.add(MACHINERY_TID, m_DetectorToTableDistance[MACHINERY_TID]);
  332. val.add(MACHINERY_SID, m_DistanceSourcetoDetector[MACHINERY_SID]);
  333. val.add(MACHINERY_ENTRANCE, m_DistanceSourcetoEntrance[MACHINERY_ENTRANCE]);
  334. val.add(MACHINERY_GEOMETRY, m_GEOMETRY[MACHINERY_GEOMETRY]);
  335. val.add(MACHINERY_PROJECTIONNUM, m_ProjectionNum[MACHINERY_PROJECTIONNUM]);
  336. val.add(MACHINERY_MAXANGLE, m_ProjectionMaxAngle[MACHINERY_MAXANGLE]);
  337. val.add(MACHINERY_DIRECTION, m_ProjectionDirection[MACHINERY_DIRECTION]);
  338. string ComList;
  339. ResDataObject DeviceConfig;
  340. m_pGenVender->SetCurrentValue("ECOM");
  341. m_pGenVender->SetType("string");
  342. m_pGenVender->SetAccessReadOnly();
  343. m_pGenVender->SetRequired(true);
  344. m_pGenModel->SetCurrentValue("MACHINE");
  345. m_pGenModel->SetType("string");
  346. m_pGenModel->SetAccessReadOnly();
  347. m_pGenModel->SetRequired(true);
  348. m_pGenSCFType->SetCurrentValue("COM");
  349. m_pGenSCFType->SetType("string");
  350. m_pGenSCFType->SetAccessReadOnly();
  351. m_pGenSCFType->SetRequired(true);
  352. m_pGenSCFPort->SetCurrentValue("");
  353. m_pGenSCFPort->SetType("string");
  354. m_pGenSCFPort->SetAccessReadWrite();
  355. MakeComList(12, ComList);
  356. m_pGenSCFPort->SetList(ComList.c_str());
  357. //m_pGenSCFPort->SetList("COM1;COM2;COM3;COM4;COM5;COM6;COM7;COM8;COM9;COM10;COM11;COM12");
  358. m_pGenSCFPort->SetRequired(true);
  359. m_pTID->SetCurrentValue("20");
  360. m_pTID->SetType("int");
  361. m_pTID->SetAccessReadWrite();
  362. m_pTID->SetRequired(true);
  363. m_pSID->SetCurrentValue("1000");
  364. m_pSID->SetType("int");
  365. m_pSID->SetAccessReadWrite();
  366. m_pSID->SetRequired(true);
  367. m_pENTRANCE->SetCurrentValue("1000");
  368. m_pENTRANCE->SetType("int");
  369. m_pENTRANCE->SetAccessReadWrite();
  370. m_pENTRANCE->SetRequired(true);
  371. m_pGEOMETRY->SetCurrentValue("liner");
  372. m_pGEOMETRY->SetType("string");
  373. m_pGEOMETRY->SetAccessReadWrite();
  374. ResDataObject resList;
  375. resList.add("0", "liner");
  376. resList.add("1", "arc");
  377. m_pGEOMETRY->SetList(resList.encode());
  378. m_pGEOMETRY->SetRequired(true);
  379. GetDeviceConfig(&DeviceConfig);
  380. val.add(DeviceConfig.GetKey(0), DeviceConfig[0]);
  381. ret &= pDeviceResource->update("Attribute", val);
  382. PRINTA_INFO(m_pLog, pDeviceResource->encode());
  383. if (ret)
  384. {
  385. return RET_SUCCEED;
  386. }
  387. return RET_FAILED;
  388. }
  389. /////////////////////////////////////////////////////////////////////////
  390. int CMACHINE_DPC::CMDSet(const char *pKey, int len)
  391. {
  392. return 1;
  393. }
  394. RET_STATUS SYSTEM_CALL CMACHINE_DPC::GetDriverDictionary(ResDataObject& PARAM_OUT DriverInfo)
  395. {
  396. DriverInfo.add("DriverType", "PositionMachine");
  397. DriverInfo.add("DeviceName", "SiemensTOMO");
  398. DriverInfo.add("DateOfManufacture", "2019.4.12");
  399. DriverInfo.add("SoftwareVersion", "Alpha1.0");
  400. DriverInfo.add("HardwareVersion", "Alpha1.0");
  401. DriverInfo.add("Description", "None");
  402. DriverInfo.add("Properties", "None");
  403. return RET_SUCCEED;
  404. }
  405. bool CMACHINE_DPC::SendDate(void)
  406. {
  407. return true;
  408. }
  409. bool CMACHINE_DPC::SendTomoExam(void)
  410. {
  411. return true;
  412. }
  413. bool CMACHINE_DPC::StartMove(bool state)
  414. {
  415. return true;
  416. }
  417. bool CMACHINE_DPC::ClearMoveState()
  418. {
  419. return true;
  420. }
  421. bool CMACHINE_DPC::SendIXRAY(void)
  422. {
  423. return true;
  424. }
  425. bool CMACHINE_DPC::MechMoveReady()
  426. {
  427. return true;
  428. }
  429. bool CMACHINE_DPC::SetPositionNum(const char* code)
  430. {
  431. return true;
  432. }
  433. void OEM_IF CMACHINE_DPC::NotifyTomoParams(FLOAT fSID, FLOAT fTID, FLOAT fMaxAngle, int nDirection, int nProjectionNumber)
  434. {
  435. //距离单位为mm
  436. m_DetectorToTableDistance[MACHINERY_TID] = fTID;
  437. m_DistanceSourcetoDetector[MACHINERY_SID] = fSID;
  438. m_ProjectionMaxAngle[MACHINERY_MAXANGLE] = fMaxAngle;
  439. m_ProjectionNum[MACHINERY_PROJECTIONNUM] = nProjectionNumber;
  440. m_ProjectionDirection[MACHINERY_DIRECTION] = nDirection;
  441. ResDataObject NotifyData;
  442. PacketAnalizer::MakeNotify(NotifyData, PACKET_CMD_UPDATE, MACHINERY_TID, (const char *)m_DetectorToTableDistance[MACHINERY_TID]);
  443. CmdFromLogicDev(&NotifyData);
  444. PacketAnalizer::MakeNotify(NotifyData, PACKET_CMD_UPDATE, MACHINERY_SID, (const char *)m_DistanceSourcetoDetector[MACHINERY_SID]);
  445. CmdFromLogicDev(&NotifyData);
  446. PacketAnalizer::MakeNotify(NotifyData, PACKET_CMD_UPDATE, MACHINERY_MAXANGLE, (const char *)m_ProjectionMaxAngle[MACHINERY_MAXANGLE]);
  447. CmdFromLogicDev(&NotifyData);
  448. PacketAnalizer::MakeNotify(NotifyData, PACKET_CMD_UPDATE, MACHINERY_PROJECTIONNUM, (const char *)m_ProjectionNum[MACHINERY_PROJECTIONNUM]);
  449. CmdFromLogicDev(&NotifyData);
  450. PacketAnalizer::MakeNotify(NotifyData, PACKET_CMD_UPDATE, MACHINERY_DIRECTION, (const char *)m_ProjectionDirection[MACHINERY_DIRECTION]);
  451. CmdFromLogicDev(&NotifyData);
  452. }
  453. bool CMACHINE_DPC::MechGetPosReady()
  454. {
  455. return true;
  456. }
  457. bool CMACHINE_DPC::GetPosition(ResDataObject &resangle, ResDataObject &resheight)
  458. {
  459. resangle = m_MechAngle;
  460. resheight = m_MechHeight;
  461. return true;
  462. }
  463. RET_STATUS CMACHINE_DPC::SetDeviceConfig(ResDataObject PARAM_IN *DeviceConfig)
  464. {
  465. string strKey;
  466. printf("\n SetDeviceConfig before : %s\n", DeviceConfig->encode());
  467. ResDataObject &ConfigContext = (*DeviceConfig)[0][0];
  468. for (int i = 0; i < ConfigContext.size(); i++)
  469. {
  470. strKey = ConfigContext.GetKey(i);
  471. printf("\n Key : %s, Value : %s\n", strKey.c_str(), ((string)(ConfigContext)[i]).c_str());
  472. if (strKey == (string)m_pGenSCFPort->GetKey(0))
  473. {
  474. m_DeviceConfig["connections"][0][DiosSCFPort] = (ConfigContext)[i];
  475. m_pGenSCFPort->SetCurrentValue((ConfigContext)[i]);
  476. }
  477. else if (strKey == MACHINERY_TID)
  478. {
  479. m_DetectorToTableDistance[MACHINERY_TID] = (ConfigContext)[i];
  480. m_DeviceConfig.update(MACHINERY_TID, (ConfigContext)[i]);
  481. m_pTID->SetCurrentValue(((string)ConfigContext[i]).c_str());
  482. }
  483. else if (strKey == MACHINERY_SID)
  484. {
  485. m_DistanceSourcetoDetector[MACHINERY_SID] = (ConfigContext)[i];
  486. m_DeviceConfig.update(MACHINERY_SID, (ConfigContext)[i]);
  487. m_pSID->SetCurrentValue(((string)ConfigContext[i]).c_str());
  488. }
  489. else if (strKey == MACHINERY_ENTRANCE)
  490. {
  491. m_DistanceSourcetoEntrance[MACHINERY_ENTRANCE] = (ConfigContext)[i];
  492. m_DeviceConfig.update(MACHINERY_ENTRANCE, (ConfigContext)[i]);
  493. m_pENTRANCE->SetCurrentValue(((string)ConfigContext[i]).c_str());
  494. }
  495. else if (strKey == MACHINERY_GEOMETRY)
  496. {
  497. m_GEOMETRY[MACHINERY_GEOMETRY] = (ConfigContext)[i];
  498. m_DeviceConfig.update(MACHINERY_GEOMETRY, (ConfigContext)[i]);
  499. m_pGEOMETRY->SetCurrentValue(((string)ConfigContext[i]).c_str());
  500. }
  501. }
  502. printf("\n m_DeviceConfig after : %s\n", m_DeviceConfig.encode());
  503. ResDataObject config, writecontent;
  504. LogicDriver::GetConfiguration(&config);
  505. string configpath = GetDriverConfigFilePath();
  506. writecontent.add("CONFIGURATION", m_DeviceConfig);
  507. writecontent.SaveFile(configpath.c_str());
  508. LogicDriver::SetDeviceConfig(&ConfigContext);
  509. return RET_SUCCEED;
  510. }
  511. RET_STATUS CMACHINE_DPC::GetDeviceConfig(ResDataObject PARAM_OUT *pDeviceConfig)
  512. {
  513. if (m_DeviceConfig.size() > 0)
  514. {
  515. printf("\n m_DeviceConfig: %s \n", m_DeviceConfig.encode());
  516. m_pGenSCFType->SetCurrentValue(((string)m_DeviceConfig["connections"][0]["type"]).c_str());
  517. m_pGenSCFPort->SetCurrentValue(((string)m_DeviceConfig["connections"][0][DiosSCFPort]).c_str());
  518. for (int i = 0; i < m_DeviceConfig.size(); i++)
  519. {
  520. if ((string)m_DeviceConfig.GetKey(i) == MACHINERY_TID)
  521. {
  522. m_pTID->SetCurrentValue(((string)m_DeviceConfig[i]).c_str());
  523. }
  524. else if ((string)m_DeviceConfig.GetKey(i) == MACHINERY_SID)
  525. {
  526. m_pSID->SetCurrentValue(((string)m_DeviceConfig[i]).c_str());
  527. }
  528. else if ((string)m_DeviceConfig.GetKey(i) == MACHINERY_ENTRANCE)
  529. {
  530. m_pENTRANCE->SetCurrentValue(((string)m_DeviceConfig[i]).c_str());
  531. }
  532. else if ((string)m_DeviceConfig.GetKey(i) == MACHINERY_GEOMETRY)
  533. {
  534. m_pGEOMETRY->SetCurrentValue(((string)m_DeviceConfig[i]).c_str());
  535. }
  536. }
  537. }
  538. ResDataObject temp, DeviceConfig;
  539. temp.add(m_pGenVender->GetKey(0), m_pGenVender->GetCurrentValue());
  540. temp.add(m_pGenModel->GetKey(0), m_pGenModel->GetCurrentValue());
  541. temp.add(m_pGenSCFType->GetKey(0), m_pGenSCFType->GetCurrentValue());
  542. temp.add(m_pGenSCFPort->GetKey(0), m_pGenSCFPort->GetCurrentValue());
  543. temp.add(m_pTID->GetKey(0), m_pTID->GetCurrentValue());
  544. temp.add(m_pSID->GetKey(0), m_pSID->GetCurrentValue());
  545. temp.add(m_pENTRANCE->GetKey(0), m_pENTRANCE->GetCurrentValue());
  546. temp.add(m_pGEOMETRY->GetKey(0), m_pGEOMETRY->GetCurrentValue());
  547. DeviceConfig.update("Attribute", temp);
  548. ResDataObject resdescription;
  549. resdescription += *m_pGenVender;
  550. resdescription += *m_pGenModel;
  551. resdescription += *m_pGenSCFType;
  552. resdescription += *m_pGenSCFPort;
  553. resdescription += *m_pTID;
  554. resdescription += *m_pSID;
  555. resdescription += *m_pENTRANCE;
  556. resdescription += *m_pGEOMETRY;
  557. DeviceConfig.update("Description", resdescription);
  558. pDeviceConfig->add("DeviceConfig", DeviceConfig);
  559. //(*pDeviceConfig) = DeviceConfig;
  560. LogicDriver::GetDeviceConfig(pDeviceConfig);
  561. return RET_SUCCEED;
  562. }