DIOS.Dev.Collimator.Mould.cpp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664
  1. #include "..\..\..\..\Deliver\include\DIOS.Dev.Collimator.Mould.hpp"
  2. //
  3. #include "stdafx.h"
  4. #include <assert.h>
  5. #include "Helper.JSON.hpp"
  6. #include "DIOS.Dev.Collimator.Mould.hpp"
  7. #include "EasyJSONEncoder.hpp"
  8. #include "DIOSDICOMInfo.h"
  9. using namespace DIOS::Dev::Detail::Collimator;
  10. namespace nsGEN = DIOS::Dev::Detail::Collimator;
  11. //template <typename _Container, typename T>
  12. //inline _Container& operator << (_Container& ar, const T& t)
  13. //{
  14. // ar.push_back(t);
  15. // return ar;
  16. //}
  17. string nsGEN::GetProcessDirectory()
  18. {
  19. string ret = "";
  20. char szFilename[MAX_PATH] = { 0 };
  21. DWORD res = GetModuleFileNameA(0, szFilename, MAX_PATH);
  22. if (res == 0)
  23. {
  24. return ret;
  25. }
  26. string fullpath = szFilename;
  27. string::size_type firstHit = fullpath.find_last_of('\\');
  28. if (firstHit == string::npos || firstHit == 0)
  29. {
  30. return ret;
  31. }
  32. ret = fullpath.substr(0, firstHit);//kick last \
  33. return ret;
  34. }
  35. //获取配置文件中指定模块的版本号
  36. bool nsGEN::GetVersion(string& version, HMODULE hMyModule)
  37. {
  38. try {
  39. char filename[MAX_PATH + 1] = { 0 };
  40. if (GetModuleFileName(hMyModule, filename, MAX_PATH) == 0)
  41. {
  42. printf("dll HMODULEis null\n");
  43. //mLog::Error("dll HMODULEis null\n");
  44. return false;
  45. }
  46. printf("get Generator path:{$}\n", filename);
  47. //mLog::Info("get Generator path:{$}\n", filename);
  48. DWORD dummy;
  49. DWORD size = GetFileVersionInfoSize(filename, &dummy);
  50. if (size == 0)
  51. {
  52. return false;
  53. }
  54. auto data = make_unique<BYTE[]>(size);
  55. if (!GetFileVersionInfo(filename, 0, size, &data[0]))
  56. {
  57. return false;
  58. }
  59. UINT32 len = 0;
  60. VS_FIXEDFILEINFO* fixed_file_info = 0;
  61. if (!VerQueryValue(&data[0], TEXT("\\"), reinterpret_cast<void**>(&fixed_file_info), &len))
  62. {
  63. return false;
  64. }
  65. // version 为版本号
  66. UINT32 vBitNumber = 0;
  67. vBitNumber = HIWORD(fixed_file_info->dwProductVersionMS);
  68. version += to_string(vBitNumber);
  69. version += ".";
  70. vBitNumber = LOWORD(fixed_file_info->dwProductVersionMS);
  71. version += to_string(vBitNumber);
  72. version += ".";
  73. vBitNumber = HIWORD(fixed_file_info->dwProductVersionLS);
  74. version += to_string(vBitNumber);
  75. version += ".";
  76. vBitNumber = LOWORD(fixed_file_info->dwProductVersionLS);
  77. version += to_string(vBitNumber);
  78. return true;
  79. }
  80. catch (...)
  81. {
  82. printf("get Generator Mould version failed");
  83. //mLog::Error("get Generator Mould version failed\n");
  84. }
  85. return false;
  86. }
  87. bool nsGEN::GetVersion(string& version, ResDataObject& config)
  88. {
  89. try {
  90. string procdir = "";
  91. char filename[MAX_PATH + 1] = { 0 };
  92. procdir = nsGEN::GetProcessDirectory();
  93. if (procdir.empty())
  94. {
  95. if (GetModuleFileName(nullptr, filename, MAX_PATH) == 0)
  96. {
  97. return false;
  98. }
  99. }
  100. else
  101. {
  102. string oemdrvpath = (const char*)config["oemdriver"];
  103. {
  104. string keystr = "%ROOT%";
  105. string::size_type pos = 0;
  106. string::size_type keylen = keystr.size();
  107. string::size_type replen = procdir.size();
  108. while ((pos = oemdrvpath.find(keystr, pos)) != string::npos)
  109. {
  110. oemdrvpath.replace(pos, keylen, procdir);
  111. pos += replen;
  112. }
  113. }
  114. strncpy_s(filename, oemdrvpath.c_str(), MAX_PATH);
  115. }
  116. printf("get Generator path:{$}\n", filename);
  117. //mLog::Info("get Generator path:{$}\n", filename);
  118. DWORD dummy;
  119. DWORD size = GetFileVersionInfoSize(filename, &dummy);
  120. if (size == 0)
  121. {
  122. return false;
  123. }
  124. auto data = make_unique<BYTE[]>(size);
  125. if (!GetFileVersionInfo(filename, 0, size, &data[0]))
  126. {
  127. return false;
  128. }
  129. UINT32 len = 0;
  130. VS_FIXEDFILEINFO* fixed_file_info = 0;
  131. if (!VerQueryValue(&data[0], TEXT("\\"), reinterpret_cast<void**>(&fixed_file_info), &len))
  132. {
  133. return false;
  134. }
  135. // version 为版本号
  136. UINT32 vBitNumber = 0;
  137. vBitNumber = HIWORD(fixed_file_info->dwProductVersionMS);
  138. version += to_string(vBitNumber);
  139. version += ".";
  140. vBitNumber = LOWORD(fixed_file_info->dwProductVersionMS);
  141. version += to_string(vBitNumber);
  142. version += ".";
  143. vBitNumber = HIWORD(fixed_file_info->dwProductVersionLS);
  144. version += to_string(vBitNumber);
  145. version += ".";
  146. vBitNumber = LOWORD(fixed_file_info->dwProductVersionLS);
  147. version += to_string(vBitNumber);
  148. return true;
  149. }
  150. catch (...)
  151. {
  152. printf("get Generator Mould version failed");
  153. //mLog::Error("get Generator Mould version failed\n");
  154. }
  155. return false;
  156. }
  157. bool nsGEN::GetVersion(string& version)
  158. {
  159. try {
  160. char filename[MAX_PATH + 1] = { 0 };
  161. if (GetModuleFileName(nullptr, filename, MAX_PATH) == 0)
  162. {
  163. return false;
  164. }
  165. printf("get Generator path:{$}\n", filename);
  166. //mLog::Info("get Generator path:{$}\n", filename);
  167. DWORD dummy;
  168. DWORD size = GetFileVersionInfoSize(filename, &dummy);
  169. if (size == 0)
  170. {
  171. return false;
  172. }
  173. auto data = make_unique<BYTE[]>(size);
  174. if (!GetFileVersionInfo(filename, 0, size, &data[0]))
  175. {
  176. return false;
  177. }
  178. UINT32 len = 0;
  179. VS_FIXEDFILEINFO* fixed_file_info = 0;
  180. if (!VerQueryValue(&data[0], TEXT("\\"), reinterpret_cast<void**>(&fixed_file_info), &len))
  181. {
  182. return false;
  183. }
  184. // version 为版本号
  185. UINT32 vBitNumber = 0;
  186. vBitNumber = HIWORD(fixed_file_info->dwProductVersionMS);
  187. version += to_string(vBitNumber);
  188. version += ".";
  189. vBitNumber = LOWORD(fixed_file_info->dwProductVersionMS);
  190. version += to_string(vBitNumber);
  191. version += ".";
  192. vBitNumber = HIWORD(fixed_file_info->dwProductVersionLS);
  193. version += to_string(vBitNumber);
  194. version += ".";
  195. vBitNumber = LOWORD(fixed_file_info->dwProductVersionLS);
  196. version += to_string(vBitNumber);
  197. return true;
  198. }
  199. catch (...)
  200. {
  201. printf("get Generator Mould version failed");
  202. //mLog::Error("get Generator Mould version failed\n");
  203. }
  204. return false;
  205. }
  206. //-----------------------------------------------------------------------------
  207. // nsGEN::ColliamtorMould
  208. //-----------------------------------------------------------------------------
  209. nsGEN::ColliamtorMould::ColliamtorMould()
  210. {
  211. }
  212. nsGEN::ColliamtorMould::~ColliamtorMould()
  213. {
  214. }
  215. void nsGEN::ColliamtorMould::Register (Dispatch* Dispatch)
  216. {
  217. Dispatch->Get.Push(AttrKey::XSIZE, this, &ColliamtorMould::JSGetCollimatorXSize);
  218. Dispatch->Get.Push(AttrKey::YSIZE, this, &ColliamtorMould::JSGetCollimatorYSize);
  219. Dispatch->Get.Push(AttrKey::XRatio, this, &ColliamtorMould::JSGetCollimatorXRatio);
  220. Dispatch->Get.Push(AttrKey::YRatio, this, &ColliamtorMould::JSGetCollimatorYRatio);
  221. Dispatch->Get.Push(AttrKey::MaxWidth, this, &ColliamtorMould::JSGetCollimatorMaxWidth);
  222. Dispatch->Get.Push(AttrKey::MaxHigh, this, &ColliamtorMould::JSGetCollimatorMaxHigh);
  223. Dispatch->Get.Push(AttrKey::ThresholdValue, this, &ColliamtorMould::JSGetCollimatorThresholdValue);
  224. Dispatch->Get.Push(AttrKey::SID, this, &ColliamtorMould::JSGetCollimatorSID);
  225. Dispatch->Get.Push(AttrKey::FILTER, this, &ColliamtorMould::JSGetCollimatorFilter);
  226. Dispatch->Get.Push(AttrKey::ANGLE, this, &ColliamtorMould::JSGetCollimatorAngle);
  227. Dispatch->Get.Push(AttrKey::MODE, this, &ColliamtorMould::JSGetCollimatorMode);
  228. Dispatch->Get.Push(AttrKey::LIGHT, this, &ColliamtorMould::JSGetCollimatorLight);
  229. Dispatch->Action.Push(ActionKey::SetCollimatorSize, this, &ColliamtorMould::JSSetCollimatorSize);
  230. Dispatch->Action.Push(ActionKey::SetCollimatorRatio, this, &ColliamtorMould::JSSetCollimatorRatio);
  231. Dispatch->Action.Push(ActionKey::SetCollimatorSID, this, &ColliamtorMould::JSSetCollimatorSID);
  232. Dispatch->Action.Push(ActionKey::SetCollimatorFilter, this, &ColliamtorMould::JSSetCollimatorFilter);
  233. Dispatch->Action.Push(ActionKey::SetCollimatorAngle, this, &ColliamtorMould::JSSetCollimatorAngle);
  234. Dispatch->Action.Push(ActionKey::SetCollimatorMode, this, &ColliamtorMould::JSSetCollimatorMode);
  235. Dispatch->Action.Push(ActionKey::SetTechParamsInfo, this, &ColliamtorMould::JSSetTechParamsInfo);
  236. Dispatch->Action.Push(ActionKey::SetCollimatorLight, this, &ColliamtorMould::JSSetCollimatorLight);
  237. Dispatch->Action.Push(ActionKey::SetHCollimatorOpen, this, &ColliamtorMould::JSSetHCollimatorOpen);
  238. Dispatch->Action.Push(ActionKey::SetHCollimatorClose, this, &ColliamtorMould::JSSetHCollimatorClose);
  239. Dispatch->Action.Push(ActionKey::SetVCollimatorOpen, this, &ColliamtorMould::JSSetVCollimatorOpen);
  240. Dispatch->Action.Push(ActionKey::SetVCollimatorClose, this, &ColliamtorMould::JSSetVCollimatorClose);
  241. Dispatch->Action.Push(ActionKey::Reset, this, &ColliamtorMould::JSReset);
  242. }
  243. //-----------------------------------------------------------------------------
  244. // 所有的消息响应函数
  245. //-----------------------------------------------------------------------------
  246. RET_STATUS nsGEN::ColliamtorMould::JSSetCollimatorSize(std::string in, std::string& out)
  247. {
  248. ResDataObject json;
  249. json.decode(in.c_str());
  250. int xvalue = atoi(((string)json[0]).c_str());
  251. int yvalue = atoi(((string)json[1]).c_str());
  252. return SetCollimatorSize(xvalue, yvalue);
  253. }
  254. RET_STATUS nsGEN::ColliamtorMould::JSSetCollimatorRatio(std::string in, std::string& out)
  255. {
  256. ResDataObject json;
  257. json.decode(in.c_str());
  258. float xvalue = atof(((string)json[0]).c_str());
  259. float yvalue = atof(((string)json[1]).c_str());
  260. return SetCollimatorRatio(xvalue, yvalue);
  261. }
  262. RET_STATUS nsGEN::ColliamtorMould::JSSetCollimatorSID(std::string in, std::string& out)
  263. {
  264. auto value = JSONTo <int>(in);
  265. return SetCollimatorSID(value);
  266. }
  267. RET_STATUS nsGEN::ColliamtorMould::JSSetCollimatorFilter(std::string in, std::string& out)
  268. {
  269. auto value = JSONTo <int>(in);
  270. return SetCollimatorFilter(value);
  271. }
  272. RET_STATUS nsGEN::ColliamtorMould::JSSetCollimatorAngle(std::string in, std::string& out)
  273. {
  274. auto value = JSONTo <float>(in);
  275. return SetCollimatorAngle(value);
  276. }
  277. RET_STATUS nsGEN::ColliamtorMould::JSSetCollimatorMode(std::string in, std::string& out)
  278. {
  279. auto value = JSONTo <int>(in);
  280. return SetCollimatorMode(value);
  281. }
  282. RET_STATUS nsGEN::ColliamtorMould::JSSetCollimatorLight(std::string in, std::string& out)
  283. {
  284. auto value = JSONTo <int>(in);
  285. return SetCollimatorLight(value);
  286. }
  287. RET_STATUS nsGEN::ColliamtorMould::JSSetHCollimatorOpen(std::string in, std::string& out)
  288. {
  289. auto value = JSONTo <int>(in);
  290. return SetHCollimatorOpen(value);
  291. }
  292. RET_STATUS nsGEN::ColliamtorMould::JSSetHCollimatorClose(std::string in, std::string& out)
  293. {
  294. auto value = JSONTo <int>(in);
  295. return SetHCollimatorClose(value);
  296. }
  297. RET_STATUS nsGEN::ColliamtorMould::JSSetVCollimatorOpen(std::string in, std::string& out)
  298. {
  299. auto value = JSONTo <int>(in);
  300. return SetVCollimatorOpen(value);
  301. }
  302. RET_STATUS nsGEN::ColliamtorMould::JSSetVCollimatorClose(std::string in, std::string& out)
  303. {
  304. auto value = JSONTo <int>(in);
  305. return SetVCollimatorClose(value);
  306. }
  307. RET_STATUS nsGEN::ColliamtorMould::JSSetTechParamsInfo(std::string in, std::string& out)
  308. {
  309. ResDataObject json;
  310. json.decode(in.c_str());
  311. TECHPARAM_INFO info;
  312. info.SetVal(json[0].encode());
  313. string strcollimatorwidth = info.m_CollimatorWidth;
  314. string strcollimatorheight = info.m_CollimatorHeight;
  315. string strcollimatorfilter = info.m_CollimatorFilter;
  316. string strSID = info.m_SID;
  317. DWORD Width = 0;
  318. DWORD Height = 0;
  319. DWORD dwFilter = 0;
  320. DWORD dwSID = 0;
  321. dwSID = (DWORD)atoi(strSID.c_str());
  322. if (dwSID >= 0)
  323. {
  324. SetCollimatorSID(dwSID);
  325. }
  326. if (strcollimatorwidth.find("IN") != string::npos)
  327. {
  328. Width = (DWORD)(atof(strcollimatorwidth.substr(0, strcollimatorwidth.size() - 2).c_str()) * 2.54);
  329. }
  330. else
  331. {
  332. Width = (DWORD)(atoi(strcollimatorwidth.substr(0, strcollimatorwidth.size() - 2).c_str()));
  333. }
  334. if (strcollimatorheight.find("IN") != string::npos)
  335. {
  336. Height = (DWORD)(atof(strcollimatorheight.substr(0, strcollimatorheight.size() - 2).c_str()) * 2.54);
  337. }
  338. else
  339. {
  340. Height = (DWORD)(atoi(strcollimatorheight.substr(0, strcollimatorheight.size() - 2).c_str()));
  341. }
  342. if (Width != 0 && Height != 0)
  343. {
  344. SetCollimatorSize(Width, Height);
  345. }
  346. dwFilter = (DWORD)atoi(strcollimatorfilter.c_str());
  347. if (dwFilter >= 0)
  348. {
  349. SetCollimatorFilter(dwFilter);
  350. }
  351. return RET_STATUS::RET_SUCCEED;
  352. }
  353. RET_STATUS nsGEN::ColliamtorMould::JSGetCollimatorXSize(std::string& out)
  354. {
  355. auto value = GetXSize();
  356. out= ToJSON(value);
  357. return RET_STATUS::RET_SUCCEED;
  358. }
  359. RET_STATUS nsGEN::ColliamtorMould::JSGetCollimatorYSize(std::string& out)
  360. {
  361. auto value = GetYSize();
  362. out = ToJSON(value);
  363. return RET_STATUS::RET_SUCCEED;
  364. }
  365. RET_STATUS nsGEN::ColliamtorMould::JSGetCollimatorXRatio(std::string& out)
  366. {
  367. auto value = GetXRatio();
  368. out = ToJSON(value);
  369. return RET_STATUS::RET_SUCCEED;
  370. }
  371. RET_STATUS nsGEN::ColliamtorMould::JSGetCollimatorYRatio(std::string& out)
  372. {
  373. auto value = GetYRatio();
  374. out = ToJSON(value);
  375. return RET_STATUS::RET_SUCCEED;
  376. }
  377. RET_STATUS nsGEN::ColliamtorMould::JSGetCollimatorMaxWidth(std::string& out)
  378. {
  379. auto value = m_fMaxWidth;
  380. out = ToJSON(value);
  381. return RET_STATUS::RET_SUCCEED;
  382. }
  383. RET_STATUS nsGEN::ColliamtorMould::JSGetCollimatorMaxHigh(std::string& out)
  384. {
  385. auto value = m_fMaxHigh;
  386. out = ToJSON(value);
  387. return RET_STATUS::RET_SUCCEED;
  388. }
  389. RET_STATUS nsGEN::ColliamtorMould::JSGetCollimatorThresholdValue(std::string& out)
  390. {
  391. auto value = m_fThresholdValue;
  392. out = ToJSON(value);
  393. return RET_STATUS();
  394. }
  395. RET_STATUS nsGEN::ColliamtorMould::JSGetCollimatorSID(std::string& out)
  396. {
  397. auto value = GetSID();
  398. out = ToJSON(value);
  399. return RET_STATUS::RET_SUCCEED;
  400. }
  401. RET_STATUS nsGEN::ColliamtorMould::JSGetCollimatorFilter(std::string& out)
  402. {
  403. auto value = GetFilter();
  404. out = ToJSON(value);
  405. return RET_STATUS::RET_SUCCEED;
  406. }
  407. RET_STATUS nsGEN::ColliamtorMould::JSGetCollimatorAngle(std::string& out)
  408. {
  409. auto value = GetAngle();
  410. out = ToJSON(value);
  411. return RET_STATUS::RET_SUCCEED;
  412. }
  413. RET_STATUS nsGEN::ColliamtorMould::JSGetCollimatorMode(std::string& out)
  414. {
  415. auto value = GetMode();
  416. out = ToJSON(value);
  417. return RET_STATUS::RET_SUCCEED;
  418. }
  419. RET_STATUS nsGEN::ColliamtorMould::JSGetCollimatorLight(std::string& out)
  420. {
  421. auto value = GetCollimatorLight();
  422. out = ToJSON(value);
  423. return RET_STATUS::RET_SUCCEED;
  424. }
  425. RET_STATUS nsGEN::ColliamtorMould::JSReset(std::string in, std::string& out)
  426. {
  427. return Reset();
  428. }
  429. RET_STATUS nsGEN::ColliamtorMould::Reset()
  430. {
  431. return RET_STATUS::RET_SUCCEED;
  432. }
  433. //-----------------------------------------------------------------------------
  434. // 所有的 GetXX 函数
  435. //-----------------------------------------------------------------------------
  436. int nsGEN::ColliamtorMould::GetXSize() { return m_CollimatorUnit.m_XRatio->Get(); }
  437. int nsGEN::ColliamtorMould::GetYSize() { return m_CollimatorUnit.m_YRatio->Get(); }
  438. int nsGEN::ColliamtorMould::GetXRatio() { return m_CollimatorUnit.m_XSize->Get(); }
  439. int nsGEN::ColliamtorMould::GetYRatio() { return m_CollimatorUnit.m_YSize->Get(); }
  440. RET_STATUS nsGEN::ColliamtorMould::SetCollimatorRatio(float xproportion, float yproportion)
  441. {
  442. return RET_STATUS::RET_SUCCEED;
  443. }
  444. //int nsGEN::ColliamtorMould::GetMaxWidth(){ return m_CollimatorUnit.m_MaxWidth->Get();}
  445. //int nsGEN::ColliamtorMould::GetMaxHigh(){ return m_CollimatorUnit.m_MaxHigh->Get();}
  446. int nsGEN::ColliamtorMould::GetSID() { return m_CollimatorUnit.m_SID->Get(); }
  447. int nsGEN::ColliamtorMould::GetFilter() { return m_CollimatorUnit.m_Filter->Get(); }
  448. int nsGEN::ColliamtorMould::GetAngle() { return m_CollimatorUnit.m_Angle->Get(); }
  449. int nsGEN::ColliamtorMould::GetMode() { return m_CollimatorUnit.m_Mode->Get(); }
  450. int nsGEN::ColliamtorMould::GetCollimatorLight() { return m_CollimatorUnit.m_Light->Get(); }
  451. RET_STATUS nsGEN::ColliamtorMould::SetHCollimatorOpen(bool bStatus)
  452. {
  453. return RET_STATUS::RET_SUCCEED;
  454. }
  455. RET_STATUS nsGEN::ColliamtorMould::SetHCollimatorClose(bool bStatus)
  456. {
  457. return RET_STATUS::RET_SUCCEED;
  458. }
  459. RET_STATUS nsGEN::ColliamtorMould::SetVCollimatorOpen(bool bStatus)
  460. {
  461. return RET_STATUS::RET_SUCCEED;
  462. }
  463. RET_STATUS nsGEN::ColliamtorMould::SetVCollimatorClose(bool bStatus)
  464. {
  465. return RET_STATUS::RET_SUCCEED;
  466. }
  467. //-----------------------------------------------------------------------------
  468. // nsGEN::DriverMould
  469. //-----------------------------------------------------------------------------
  470. nsGEN::DriverMould::DriverMould ()
  471. {
  472. ConfigInfo Vender (ConfKey::DiosType, "string", "R", "TRUE", "");
  473. m_ConfigInfo.push_back(Vender);
  474. ConfigInfo Model (ConfKey::DiosModel, "string", "R", "TRUE", "");
  475. m_ConfigInfo.push_back(Model);
  476. EasyJSONEncoder synList;
  477. synList.Set ("0", "1");
  478. synList.Set ("1", "2");
  479. ConfigInfo GenIsConnect (ConfKey::DiosIsConnect, "int", "RW", "FALSE", "");
  480. GenIsConnect.SetList (synList.ToString ().c_str ());
  481. m_ConfigInfo.push_back(GenIsConnect);
  482. ConfigInfo SCFType (ConfKey::DiosSCFType, "string", "R", "TRUE", "");
  483. m_ConfigInfo.push_back(SCFType);
  484. EasyJSONEncoder COMList;
  485. COMList.Set ("0", "COM1");
  486. COMList.Set ("1", "COM2");
  487. COMList.Set ("2", "COM3");
  488. COMList.Set ("3", "COM4");
  489. COMList.Set ("4", "COM5");
  490. COMList.Set ("5", "COM6");
  491. COMList.Set ("6", "COM7");
  492. COMList.Set ("7", "COM8");
  493. COMList.Set ("8", "COM9");
  494. COMList.Set ("9", "COM10");
  495. COMList.Set ("10", "COM11");
  496. COMList.Set ("11", "COM12");
  497. ConfigInfo SCFPort (ConfKey::DiosSCFPort, "string", "RW", "TRUE", "");
  498. SCFPort.SetList (COMList.ToString ().c_str ());
  499. m_ConfigInfo.push_back(SCFPort);
  500. ConfigInfo SCFBaudrate (ConfKey::DiosSCFBaudrate, "int", "R", "FALSE", "");
  501. m_ConfigInfo.push_back(SCFBaudrate);
  502. ConfigInfo SCFBytesize (ConfKey::DiosSCFBytesize, "int", "R", "FALSE", "");
  503. m_ConfigInfo.push_back(SCFBytesize);
  504. ConfigInfo SCFParity (ConfKey::DiosSCFParity, "int", "R", "FALSE", "");
  505. m_ConfigInfo.push_back(SCFParity);
  506. ConfigInfo SCFStopbits (ConfKey::DiosSCFStopbits, "int", "R", "FALSE", "");
  507. m_ConfigInfo.push_back(SCFStopbits);
  508. }
  509. nsGEN::DriverMould::~DriverMould ()
  510. {
  511. }
  512. #ifdef _WIN64
  513. #ifdef _DEBUG
  514. static const auto COM_SCFDllName = "Dios.Dev.SerialSCFX64D.dll";
  515. static const auto TCP_SCFDllName = "Dios.Dev.TcpipSCFX64D.dll";
  516. #else
  517. static const auto COM_SCFDllName = "Dios.Dev.SerialSCFX64.dll";
  518. static const auto TCP_SCFDllName = "Dios.Dev.TcpipSCFX64.dll";
  519. #endif
  520. #endif
  521. std::string nsGEN::DriverMould::GetGUID () const
  522. {
  523. return DeviceDriverType;
  524. }
  525. string nsGEN::DriverMould::GetConnectDLL(string& ConfigFileName)
  526. {
  527. string ConnectDLL = COM_SCFDllName;
  528. ResDataObject r_config, Connection;
  529. if (!r_config.loadFile(ConfigFileName.c_str()))
  530. return ConnectDLL;
  531. if (r_config["CONFIGURATION"]["connections"].GetKeyCount("Value") > 0)
  532. {
  533. Connection = r_config["CONFIGURATION"]["connections"]["Value"];
  534. }
  535. else
  536. {
  537. Connection = r_config["CONFIGURATION"]["connections"][0];
  538. }
  539. if ((string)Connection["type"] == "COM")
  540. ConnectDLL = COM_SCFDllName;
  541. else
  542. ConnectDLL = TCP_SCFDllName;
  543. return ConnectDLL;
  544. }
  545. ResDataObject nsGEN::DriverMould::GetConnectParam(string& ConfigFileName)
  546. {
  547. ResDataObject r_config, Connection;
  548. if (!r_config.loadFile(ConfigFileName.c_str()))
  549. return Connection;
  550. if (r_config["CONFIGURATION"]["connections"].GetKeyCount("Value") > 0)
  551. {
  552. Connection = r_config["CONFIGURATION"]["connections"]["Value"];
  553. }
  554. else
  555. {
  556. Connection = r_config["CONFIGURATION"]["connections"][0];
  557. }
  558. return Connection;
  559. }
  560. void DIOS::Dev::Detail::Collimator::TransJsonText(ResDataObject& config)
  561. {
  562. for (int x = 0; x < config.size(); x++)
  563. {
  564. //如果有Value
  565. if (config[x].GetKeyCount("Value") > 0)
  566. {
  567. //mLog::FINFO("TRY COVERT [{$}] VALUE {$}", config.GetKey(x), config[x]["Value"].size() > 0 ? config[x]["Value"].encode() : (const char*)config[x]["Value"]);
  568. if (config[x]["Value"].size() <= 0)
  569. {
  570. string va = (const char*)config[x]["Value"];
  571. config[x] = va.c_str();
  572. }
  573. else
  574. {
  575. ResDataObject rest = config[x]["Value"];
  576. config[x] = rest;
  577. //mLog::FINFO("convert object [{$}], object {$}", config.GetKey(x), rest.encode());
  578. }
  579. }
  580. //mLog::FINFO("After Convert {$}", config.encode());
  581. }
  582. }