DIOS.Dev.MECH.Mould.cpp 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017
  1. //
  2. #include "stdafx.h"
  3. #include <assert.h>
  4. #include "ResDataObject.h"
  5. #include "Helper.JSON.hpp"
  6. #include "DIOS.Dev.MECH.Mould.hpp"
  7. #include "EasyJSONEncoder.hpp"
  8. using namespace DIOS::Dev::Detail::MECH;
  9. namespace nsMECH = DIOS::Dev::Detail::MECH;
  10. string nsMECH::GetProcessDirectory()
  11. {
  12. string ret = "";
  13. char szFilename[MAX_PATH] = { 0 };
  14. DWORD res = GetModuleFileNameA(0, szFilename, MAX_PATH);
  15. if (res == 0)
  16. {
  17. return ret;
  18. }
  19. string fullpath = szFilename;
  20. string::size_type firstHit = fullpath.find_last_of('\\');
  21. if (firstHit == string::npos || firstHit == 0)
  22. {
  23. return ret;
  24. }
  25. ret = fullpath.substr(0, firstHit);//kick last \
  26. return ret;
  27. }
  28. //获取配置文件中指定模块的版本号
  29. bool nsMECH::GetVersion(string& version, HMODULE hMyModule)
  30. {
  31. try {
  32. char filename[MAX_PATH + 1] = { 0 };
  33. if (GetModuleFileName(hMyModule, filename, MAX_PATH) == 0)
  34. {
  35. printf("dll HMODULEis null\n");
  36. //mLog::Error("dll HMODULEis null\n");
  37. return false;
  38. }
  39. printf("get Generator path:%s\n", filename);
  40. //mLog::Info("get Generator path:{$}\n", filename);
  41. DWORD dummy;
  42. DWORD size = GetFileVersionInfoSize(filename, &dummy);
  43. if (size == 0)
  44. {
  45. return false;
  46. }
  47. auto data = make_unique<BYTE[]>(size);
  48. if (!GetFileVersionInfo(filename, 0, size, &data[0]))
  49. {
  50. return false;
  51. }
  52. UINT32 len = 0;
  53. VS_FIXEDFILEINFO* fixed_file_info = 0;
  54. if (!VerQueryValue(&data[0], TEXT("\\"), reinterpret_cast<void**>(&fixed_file_info), &len))
  55. {
  56. return false;
  57. }
  58. // version 为版本号
  59. UINT32 vBitNumber = 0;
  60. vBitNumber = HIWORD(fixed_file_info->dwProductVersionMS);
  61. version += to_string(vBitNumber);
  62. version += ".";
  63. vBitNumber = LOWORD(fixed_file_info->dwProductVersionMS);
  64. version += to_string(vBitNumber);
  65. version += ".";
  66. vBitNumber = HIWORD(fixed_file_info->dwProductVersionLS);
  67. version += to_string(vBitNumber);
  68. version += ".";
  69. vBitNumber = LOWORD(fixed_file_info->dwProductVersionLS);
  70. version += to_string(vBitNumber);
  71. return true;
  72. }
  73. catch (...)
  74. {
  75. printf("get Generator Mould version failed");
  76. //mLog::Error("get Generator Mould version failed\n");
  77. }
  78. return false;
  79. }
  80. bool nsMECH::GetVersion(string& version, ResDataObject& config)
  81. {
  82. try {
  83. string procdir = "";
  84. char filename[MAX_PATH + 1] = { 0 };
  85. procdir = nsMECH::GetProcessDirectory();
  86. if (procdir.empty())
  87. {
  88. if (GetModuleFileName(nullptr, filename, MAX_PATH) == 0)
  89. {
  90. return false;
  91. }
  92. }
  93. else
  94. {
  95. string oemdrvpath = (const char*)config["oemdriver"];
  96. {
  97. string keystr = "%ROOT%";
  98. string::size_type pos = 0;
  99. string::size_type keylen = keystr.size();
  100. string::size_type replen = procdir.size();
  101. while ((pos = oemdrvpath.find(keystr, pos)) != string::npos)
  102. {
  103. oemdrvpath.replace(pos, keylen, procdir);
  104. pos += replen;
  105. }
  106. }
  107. strncpy_s(filename, oemdrvpath.c_str(), MAX_PATH);
  108. }
  109. printf("get Generator path:%s\n", filename);
  110. //mLog::Info("get Generator path:{$}\n", filename);
  111. DWORD dummy;
  112. DWORD size = GetFileVersionInfoSize(filename, &dummy);
  113. if (size == 0)
  114. {
  115. return false;
  116. }
  117. auto data = make_unique<BYTE[]>(size);
  118. if (!GetFileVersionInfo(filename, 0, size, &data[0]))
  119. {
  120. return false;
  121. }
  122. UINT32 len = 0;
  123. VS_FIXEDFILEINFO* fixed_file_info = 0;
  124. if (!VerQueryValue(&data[0], TEXT("\\"), reinterpret_cast<void**>(&fixed_file_info), &len))
  125. {
  126. return false;
  127. }
  128. // version 为版本号
  129. UINT32 vBitNumber = 0;
  130. vBitNumber = HIWORD(fixed_file_info->dwProductVersionMS);
  131. version += to_string(vBitNumber);
  132. version += ".";
  133. vBitNumber = LOWORD(fixed_file_info->dwProductVersionMS);
  134. version += to_string(vBitNumber);
  135. version += ".";
  136. vBitNumber = HIWORD(fixed_file_info->dwProductVersionLS);
  137. version += to_string(vBitNumber);
  138. version += ".";
  139. vBitNumber = LOWORD(fixed_file_info->dwProductVersionLS);
  140. version += to_string(vBitNumber);
  141. return true;
  142. }
  143. catch (...)
  144. {
  145. printf("get Generator Mould version failed");
  146. //mLog::Error("get Generator Mould version failed\n");
  147. }
  148. return false;
  149. }
  150. bool nsMECH::GetVersion(string& version)
  151. {
  152. try {
  153. char filename[MAX_PATH + 1] = { 0 };
  154. if (GetModuleFileName(nullptr, filename, MAX_PATH) == 0)
  155. {
  156. return false;
  157. }
  158. printf("get Generator path:%s \n", filename);
  159. //mLog::Info("get Generator path:{$}\n", filename);
  160. DWORD dummy;
  161. DWORD size = GetFileVersionInfoSize(filename, &dummy);
  162. if (size == 0)
  163. {
  164. return false;
  165. }
  166. auto data = make_unique<BYTE[]>(size);
  167. if (!GetFileVersionInfo(filename, 0, size, &data[0]))
  168. {
  169. return false;
  170. }
  171. UINT32 len = 0;
  172. VS_FIXEDFILEINFO* fixed_file_info = 0;
  173. if (!VerQueryValue(&data[0], TEXT("\\"), reinterpret_cast<void**>(&fixed_file_info), &len))
  174. {
  175. return false;
  176. }
  177. // version 为版本号
  178. UINT32 vBitNumber = 0;
  179. vBitNumber = HIWORD(fixed_file_info->dwProductVersionMS);
  180. version += to_string(vBitNumber);
  181. version += ".";
  182. vBitNumber = LOWORD(fixed_file_info->dwProductVersionMS);
  183. version += to_string(vBitNumber);
  184. version += ".";
  185. vBitNumber = HIWORD(fixed_file_info->dwProductVersionLS);
  186. version += to_string(vBitNumber);
  187. version += ".";
  188. vBitNumber = LOWORD(fixed_file_info->dwProductVersionLS);
  189. version += to_string(vBitNumber);
  190. return true;
  191. }
  192. catch (...)
  193. {
  194. printf("get Generator Mould version failed");
  195. //mLog::Error("get Generator Mould version failed\n");
  196. }
  197. return false;
  198. }
  199. void nsMECH::TransJsonText(ResDataObject& config)
  200. {
  201. for (int x = 0; x < config.size(); x++)
  202. {
  203. //如果有Value
  204. if (config[x].GetKeyCount("Value") > 0)
  205. {
  206. //mLog::FINFO("TRY COVERT [{$}] VALUE {$}", config.GetKey(x), config[x]["Value"].size() > 0 ? config[x]["Value"].encode() : (const char*)config[x]["Value"]);
  207. if (config[x]["Value"].size() <= 0)
  208. {
  209. string va = (const char*)config[x]["Value"];
  210. config[x] = va.c_str();
  211. }
  212. else
  213. {
  214. ResDataObject rest = config[x]["Value"];
  215. config[x] = rest;
  216. //mLog::FINFO("convert object [{$}], object {$}", config.GetKey(x), rest.encode());
  217. }
  218. }
  219. //mLog::FINFO("After Convert {$}", config.encode());
  220. }
  221. }
  222. //-----------------------------------------------------------------------------
  223. // nsGEN::MECHMould
  224. //-----------------------------------------------------------------------------
  225. nsMECH::MECHMould::MECHMould()
  226. {
  227. //基础信息
  228. //m_MECHUnit.m_SID.reset(new SIDMould(1, 0, 99, 1));
  229. //其它的信息按需在子类模块自行定义
  230. }
  231. nsMECH::MECHMould::~MECHMould()
  232. {
  233. }
  234. void nsMECH::MECHMould::RegisterExamInfo(Dispatch* Dispatch)
  235. {
  236. Dispatch->Get.Push(AttrKey::PATIENTSIZE, [this](std::string& out) {
  237. if (m_MECHUnit.m_PatientSize)
  238. out = m_MECHUnit.m_PatientSize->JSGet();
  239. return RET_STATUS::RET_SUCCEED; });
  240. Dispatch->Get.Push(AttrKey::VIEWID, [this](std::string& out) {
  241. if (m_MECHUnit.m_ViewID)
  242. out = m_MECHUnit.m_ViewID->JSGet();
  243. return RET_STATUS::RET_SUCCEED; });
  244. Dispatch->Action.Push(ActionKey::SetStudyInfo, [this](std::string in, std::string& out) {
  245. ResDataObject json;
  246. json.decode(in.c_str());
  247. return SetStudyInfo(json); });
  248. Dispatch->Action.Push(ActionKey::SetViewInfo, [this](std::string in, std::string& out) {
  249. ResDataObject json;
  250. json.decode(in.c_str());
  251. return SetViewInfo(json); });
  252. Dispatch->Action.Push(ActionKey::SetPatientInfo, [this](std::string in, std::string& out) {
  253. ResDataObject json;
  254. json.decode(in.c_str());
  255. auto& R0 = json[0];
  256. return SetPatientInfo(R0); });
  257. }
  258. void nsMECH::MECHMould::RegisterNormalControl(Dispatch* Dispatch)
  259. {
  260. //重置
  261. Dispatch->Action.Push(ActionKey::Reset, [this](std::string in, std::string& out) {
  262. return Reset(); });
  263. //同步模式
  264. Dispatch->Action.Push(ActionKey::ActiveSyncMode, [this](std::string in, std::string& out) {
  265. ResDataObject json;
  266. json.decode(in.c_str());
  267. _tSyncModeArgs t{ };
  268. if (json.size() >= 3)
  269. {
  270. t.strWS = (string)json[0];
  271. t.strSyncMode = (string)json[1];
  272. t.strSyncValue = (string)json[2];
  273. return ActiveSyncMode(t);
  274. }
  275. else
  276. {
  277. return RET_STATUS::RET_FAILED;
  278. }});
  279. Dispatch->Action.Push(ActionKey::SetAutoTracking, [this](std::string in, std::string& out) {
  280. auto value = JSONTo<int>(in);
  281. return SetAutoTracking(value); });
  282. Dispatch->Get.Push(AttrKey::MACHSTATE, [this](std::string& out) {
  283. if(m_MECHUnit.m_MechState)
  284. out = m_MECHUnit.m_MechState->JSGet();
  285. return RET_STATUS::RET_SUCCEED; });
  286. Dispatch->Action.Push(ActionKey::SetTechParamsInfo, [this](std::string in, std::string& out) {
  287. ResDataObject json;
  288. json.decode(in.c_str());
  289. TECHPARAM_INFO info;
  290. info.SetVal(json[0].encode());
  291. auto value = atof(info.m_SID.GetVal());
  292. SetSID((float)value);
  293. auto pn = atoi(info.m_PositionNumber.GetVal());
  294. SetPositionNumber(pn);
  295. return RET_STATUS::RET_SUCCEED; });
  296. Dispatch->Get.Push(AttrKey::TUBEANGLE, [this](std::string& out) {
  297. if (m_MECHUnit.m_TubeAngle)
  298. out = m_MECHUnit.m_TubeAngle->JSGet();
  299. return RET_STATUS::RET_SUCCEED; });
  300. Dispatch->Get.Push(AttrKey::TUBEHEIGHT, [this](std::string& out) {
  301. if (m_MECHUnit.m_TubeHeight)
  302. out = m_MECHUnit.m_TubeHeight->JSGet();
  303. return RET_STATUS::RET_SUCCEED; });
  304. Dispatch->Get.Push(AttrKey::POSITIONNUMBER, [this](std::string& out) {
  305. if (m_MECHUnit.m_PostionNumber)
  306. out = m_MECHUnit.m_PostionNumber->JSGet();
  307. return RET_STATUS::RET_SUCCEED; });
  308. Dispatch->Set.Push(AttrKey::POSITIONNUMBER, [this](std::string in) {
  309. auto value = JSONTo<int>(in);
  310. return SetPositionNumber(value); });
  311. Dispatch->Action.Push(ActionKey::SetPositionNumber, [this](std::string in, std::string& out) {
  312. auto value = JSONTo<int>(in);
  313. return SetPositionNumber(value); });
  314. Dispatch->Get.Push(AttrKey::TID, [this](std::string& out) {
  315. if (m_MECHUnit.m_TID)
  316. out = m_MECHUnit.m_TID->JSGet();
  317. return RET_STATUS::RET_SUCCEED; });
  318. Dispatch->Get.Push(AttrKey::SID, [this](std::string& out) {
  319. if (m_MECHUnit.m_SID)
  320. out = m_MECHUnit.m_SID->JSGet();
  321. return RET_STATUS::RET_SUCCEED; });
  322. Dispatch->Set.Push(AttrKey::SID, [this](std::string in) {
  323. auto value = JSONTo<int>(in);
  324. return SetSID(value); });
  325. Dispatch->Action.Push(ActionKey::SetSID, [this](std::string in, std::string& out) {
  326. auto value = JSONTo<int>(in);
  327. return SetSID(value); });
  328. Dispatch->Get.Push(AttrKey::SOD, [this](std::string& out) {
  329. if (m_MECHUnit.m_SOD)
  330. out = m_MECHUnit.m_SOD->JSGet();
  331. return RET_STATUS::RET_SUCCEED; });
  332. Dispatch->Set.Push(AttrKey::SOD, [this](std::string in) {
  333. auto value = JSONTo<int>(in);
  334. return SetSOD(value); });
  335. Dispatch->Action.Push(ActionKey::SetSOD, [this](std::string in, std::string& out) {
  336. auto value = JSONTo<int>(in);
  337. return SetSOD(value); });
  338. Dispatch->Get.Push(AttrKey::SED, [this](std::string& out) {
  339. if (m_MECHUnit.m_SED)
  340. out = m_MECHUnit.m_SED->JSGet();
  341. return RET_STATUS::RET_SUCCEED; });
  342. Dispatch->Get.Push(AttrKey::FID, [this](std::string& out) {
  343. if (m_MECHUnit.m_FID)
  344. out = m_MECHUnit.m_FID->JSGet();
  345. return RET_STATUS::RET_SUCCEED; });
  346. Dispatch->Get.Push(AttrKey::GRIDSTATE, [this](std::string& out) {
  347. if (m_MECHUnit.m_GridState)
  348. out = m_MECHUnit.m_GridState->JSGet();
  349. return RET_STATUS::RET_SUCCEED; });
  350. Dispatch->Set.Push(AttrKey::GRIDSTATE, [this](std::string in) {
  351. AttrKey::MECH_GRIDSTATE value = (AttrKey::MECH_GRIDSTATE)JSONTo<int>(in);
  352. return SetGrid(value); });
  353. Dispatch->Action.Push(ActionKey::SetGrid, [this](std::string in, std::string& out) {
  354. AttrKey::MECH_GRIDSTATE value = (AttrKey::MECH_GRIDSTATE)JSONTo<int>(in);
  355. return SetGrid(value); });
  356. Dispatch->Action.Push(ActionKey::MoveToHome, [this](std::string in, std::string& out) {
  357. return MoveToHome(in); });
  358. Dispatch->Action.Push(ActionKey::MoveMech, [this](std::string in, std::string& out) {
  359. return MoveMech(in); });
  360. Dispatch->Action.Push(ActionKey::StopMech, [this](std::string in, std::string& out) {
  361. return StopMech(in); });
  362. Dispatch->Get.Push(AttrKey::UNITINFO, [this](std::string& out) {
  363. out = m_MECHUnit.m_strInfo;
  364. return RET_STATUS::RET_SUCCEED;
  365. });
  366. }
  367. void nsMECH::MECHMould::RegisterCollimatorControl(Dispatch* Dispatch)
  368. {
  369. Dispatch->Set.Push(AttrKey::CollimatorSize, [this](std::string in) {
  370. ResDataObject json;
  371. json.decode(in.c_str());
  372. auto& R0 = json[0];
  373. ECOM_COLLIMATOR_INFO curCollimator;
  374. curCollimator.fWidth = atoi(((string)R0["Width"]).c_str());
  375. curCollimator.fHeight = atoi(((string)R0["Height"]).c_str());
  376. return SetCollimator(curCollimator); });
  377. Dispatch->Action.Push(ActionKey::SetCollimator, [this](std::string in, std::string& out) {
  378. ResDataObject json;
  379. json.decode(in.c_str());
  380. auto& R0 = json[0];
  381. ECOM_COLLIMATOR_INFO curCollimator;
  382. curCollimator.fWidth = atoi(((string)R0["Width"]).c_str());
  383. curCollimator.fHeight = atoi(((string)R0["Height"]).c_str());
  384. return SetCollimator(curCollimator); });
  385. Dispatch->Get.Push(AttrKey::FILTER, [this](std::string& out) {
  386. if (m_MECHUnit.m_Filter)
  387. out = m_MECHUnit.m_Filter->JSGet();
  388. return RET_STATUS::RET_SUCCEED; });
  389. Dispatch->Set.Push(AttrKey::FILTER, [this](std::string in) {
  390. auto value = JSONTo <int>(in);
  391. return SetFilter(value); });
  392. Dispatch->Action.Push(ActionKey::SetFilter, [this](std::string in, std::string& out) {
  393. auto value = JSONTo <int>(in);
  394. return SetFilter(value); });
  395. }
  396. void nsMECH::MECHMould::RegisterExtraScreenControl(Dispatch* Dispatch)
  397. {
  398. Dispatch->Action.Push(ActionKey::SetExpEnable, [this](std::string in, std::string& out) {
  399. auto value = JSONTo <int>(in);
  400. return SetExpEnable(value); });
  401. Dispatch->Set.Push(AttrKey::WORKSTATION, [this](std::string in) {
  402. auto value = JSONTo <int>(in);
  403. return SetWS(value); });
  404. Dispatch->Action.Push(ActionKey::SetWS, [this](std::string in, std::string& out) {
  405. auto value = JSONTo <int>(in);
  406. return SetWS(value); });
  407. Dispatch->Set.Push(AttrKey::KV, [this](std::string in) {
  408. auto value = JSONTo <int>(in);
  409. return SetKV(value); });
  410. Dispatch->Action.Push(ActionKey::SetKV, [this](std::string in, std::string& out) {
  411. auto value = JSONTo <int>(in);
  412. return SetKV(value); });
  413. Dispatch->Set.Push(AttrKey::MA, [this](std::string in) {
  414. auto value = JSONTo <float>(in);
  415. return SetMA(value); });
  416. Dispatch->Action.Push(ActionKey::SetMA, [this](std::string in, std::string& out) {
  417. auto value = JSONTo <float>(in);
  418. return SetMA(value); });
  419. Dispatch->Set.Push(AttrKey::MS, [this](std::string in) {
  420. auto value = JSONTo <int>(in);
  421. return SetMS(value); });
  422. Dispatch->Action.Push(ActionKey::SetMS, [this](std::string in, std::string& out) {
  423. auto value = JSONTo <int>(in);
  424. return SetMS(value); });
  425. Dispatch->Set.Push(AttrKey::MAS, [this](std::string in) {
  426. auto value = JSONTo <float>(in);
  427. return SetMAS(value); });
  428. Dispatch->Action.Push(ActionKey::SetMAS, [this](std::string in, std::string& out) {
  429. auto value = JSONTo <float>(in);
  430. return SetMAS(value); });
  431. Dispatch->Set.Push(AttrKey::FOCUS, [this](std::string in) {
  432. auto value = JSONTo <int>(in);
  433. return SetFO(value); });
  434. Dispatch->Action.Push(ActionKey::SetFocus, [this](std::string in, std::string& out) {
  435. auto value = JSONTo <int>(in);
  436. return SetFO(value); });
  437. Dispatch->Set.Push(AttrKey::TECHMODE, [this](std::string in) {
  438. auto value = JSONTo <int>(in);
  439. return SetTechMode(value); });
  440. Dispatch->Action.Push(ActionKey::SetTechMode, [this](std::string in, std::string& out) {
  441. auto value = JSONTo <int>(in);
  442. return SetTechMode(value); });
  443. Dispatch->Set.Push(AttrKey::AECFIELD, [this](std::string in) {
  444. auto value = JSONTo <int>(in);
  445. return SetAECField(value); });
  446. Dispatch->Action.Push(ActionKey::SetAECField, [this](std::string in, std::string& out) {
  447. auto value = JSONTo <int>(in);
  448. return SetAECField(value); });
  449. Dispatch->Set.Push(AttrKey::AECDENSITY, [this](std::string in) {
  450. auto value = JSONTo <int>(in);
  451. return SetDensity(value); });
  452. Dispatch->Action.Push(ActionKey::SetDensity, [this](std::string in, std::string& out) {
  453. auto value = JSONTo <int>(in);
  454. return SetDensity(value); });
  455. Dispatch->Action.Push(ActionKey::SetBodySize, [this](std::string in, std::string& out) {
  456. ResDataObject json;
  457. json.decode(in.c_str());
  458. auto value = (string)json[0];
  459. return SetBodySize(value); });
  460. }
  461. void nsMECH::MECHMould::RegisterMammoControl(Dispatch* Dispatch)
  462. {
  463. Dispatch->Get.Push(AttrKey::MAMMO_AE, [this](std::string& out) { if (m_MECHUnit.m_Mammo_AE) out = m_MECHUnit.m_Mammo_AE->JSGet(); return RET_STATUS::RET_SUCCEED; });
  464. Dispatch->Get.Push(AttrKey::MAMMO_AGD, [this](std::string& out) { if (m_MECHUnit.m_Mammo_AGD) out = m_MECHUnit.m_Mammo_AGD->JSGet(); return RET_STATUS::RET_SUCCEED; });
  465. Dispatch->Get.Push(AttrKey::MAMMO_CompPressureDEC, [this](std::string& out) { if (m_MECHUnit.m_Mammo_CompPressureDEC) out = m_MECHUnit.m_Mammo_CompPressureDEC->JSGet(); return RET_STATUS::RET_SUCCEED; });
  466. Dispatch->Get.Push(AttrKey::MAMMO_DEPRESS, [this](std::string& out) { if (m_MECHUnit.m_Mammo_Depress) out = m_MECHUnit.m_Mammo_Depress->JSGet(); return RET_STATUS::RET_SUCCEED; });
  467. Dispatch->Get.Push(AttrKey::MAMMO_MAG, [this](std::string& out) { if (m_MECHUnit.m_Mammo_MAG) out = m_MECHUnit.m_Mammo_MAG->JSGet(); return RET_STATUS::RET_SUCCEED; });
  468. Dispatch->Get.Push(AttrKey::MAMMO_PRESSVAL, [this](std::string& out) { if (m_MECHUnit.m_Mammo_PressureValue) out = m_MECHUnit.m_Mammo_PressureValue->JSGet(); return RET_STATUS::RET_SUCCEED; });
  469. Dispatch->Get.Push(AttrKey::MAMMO_THICKNESS, [this](std::string& out) { if (m_MECHUnit.m_Mammo_Thickness) out = m_MECHUnit.m_Mammo_Thickness->JSGet(); return RET_STATUS::RET_SUCCEED; });
  470. }
  471. void nsMECH::MECHMould::RegisterTOMOControl(Dispatch* Dispatch)
  472. {
  473. Dispatch->Action.Push(ActionKey::SetTomoEnable, [this](std::string in, std::string& out) {
  474. auto value = JSONTo<int>(in);
  475. return SetTomoEnable(value); });
  476. Dispatch->Action.Push(ActionKey::SetTomoExpMode, [this](std::string in, std::string& out) {
  477. return SetTomoExpMode(in); });
  478. Dispatch->Action.Push(ActionKey::SetTomoTechnical, [this](std::string in, std::string& out) {
  479. return SetTomoTechnical(in); });
  480. Dispatch->Action.Push(ActionKey::GetTomoResults, [this](std::string in, std::string& out) {
  481. return GetTomoResults(out); });
  482. }
  483. void nsMECH::MECHMould::RegisterStitchingControl(Dispatch* Dispatch)
  484. {
  485. Dispatch->Get.Push(AttrKey::STITCHINGSTATE, [this](std::string& out) {
  486. if (m_MECHUnit.m_StitchingState)
  487. out = m_MECHUnit.m_StitchingState->JSGet();
  488. return RET_STATUS::RET_SUCCEED; });
  489. Dispatch->Get.Push(AttrKey::STITCHHEIGHT, [this](std::string& out) {
  490. if (m_MECHUnit.m_StitchHeight)
  491. out = m_MECHUnit.m_StitchHeight->JSGet();
  492. return RET_STATUS::RET_SUCCEED; });
  493. Dispatch->Get.Push(AttrKey::STITCHLENGTH, [this](std::string& out) {
  494. if (m_MECHUnit.m_StitchLength)
  495. out = m_MECHUnit.m_StitchLength->JSGet();
  496. return RET_STATUS::RET_SUCCEED; });;
  497. Dispatch->Get.Push(AttrKey::STITCHOVERLAP, [this](std::string& out) {
  498. if (m_MECHUnit.m_StitchOverLap)
  499. out = m_MECHUnit.m_StitchOverLap->JSGet();
  500. return RET_STATUS::RET_SUCCEED; });
  501. Dispatch->Get.Push(AttrKey::STITCHPID, [this](std::string& out) {
  502. if (m_MECHUnit.m_StitchPID)
  503. out = m_MECHUnit.m_StitchPID->JSGet();
  504. return RET_STATUS::RET_SUCCEED; });
  505. Dispatch->Get.Push(AttrKey::STITCHDIRECTION, [this](std::string& out) {
  506. if (m_MECHUnit.m_StitchDirection)
  507. out = m_MECHUnit.m_StitchDirection->JSGet();
  508. return RET_STATUS::RET_SUCCEED; });
  509. Dispatch->Get.Push(AttrKey::STITCHTYPE, [this](std::string& out) {
  510. if (m_MECHUnit.m_StitchType)
  511. out = m_MECHUnit.m_StitchType->JSGet();
  512. return RET_STATUS::RET_SUCCEED; });
  513. Dispatch->Get.Push(AttrKey::STITCHSTEPLENGTH, [this](std::string& out) {
  514. if (m_MECHUnit.m_StitchStepLength)
  515. out = m_MECHUnit.m_StitchStepLength->JSGet();
  516. return RET_STATUS::RET_SUCCEED; });
  517. Dispatch->Get.Push(AttrKey::FPDPOSITION, [this](std::string& out) {
  518. if (m_MECHUnit.m_FPDPosition)
  519. out = m_MECHUnit.m_FPDPosition->JSGet();
  520. return RET_STATUS::RET_SUCCEED; });
  521. Dispatch->Get.Push(AttrKey::TOTALIMAGECOUNT, [this](std::string& out) {
  522. if (m_MECHUnit.m_TotalImageCount)
  523. out = m_MECHUnit.m_TotalImageCount->JSGet();
  524. return RET_STATUS::RET_SUCCEED; });
  525. Dispatch->Get.Push(AttrKey::CURRENTIMAGENUMBER, [this](std::string& out) {
  526. if (m_MECHUnit.m_CurrentImageNumber)
  527. out = m_MECHUnit.m_CurrentImageNumber->JSGet();
  528. return RET_STATUS::RET_SUCCEED; });
  529. Dispatch->Action.Push(ActionKey::BeginStitching, [this](std::string in, std::string& out) {
  530. return BeginStitching(); });
  531. Dispatch->Action.Push(ActionKey::InitStitching, [this](std::string in, std::string& out) {
  532. return InitStitching(); });
  533. Dispatch->Action.Push(ActionKey::EndStitching, [this](std::string in, std::string& out) {
  534. return EndStitching(); });
  535. Dispatch->Action.Push(ActionKey::SetupStitching, [this](std::string in, std::string& out) {
  536. return SetupStitching(in); });
  537. Dispatch->Action.Push(ActionKey::AcceptStitchingImage, [this](std::string in, std::string& out) {
  538. return AcceptStitchingImage(); });
  539. Dispatch->Action.Push(ActionKey::RejectStitchingImage, [this](std::string in, std::string& out) {
  540. return RejectStitchingImage(); });
  541. Dispatch->Action.Push(ActionKey::CancelStitching, [this](std::string in, std::string& out) {
  542. return CancelStitching(); });
  543. Dispatch->Action.Push(ActionKey::CompleteStitching, [this](std::string in, std::string& out) {
  544. return CompleteStitching(); });
  545. Dispatch->Action.Push(ActionKey::NewExtraView, [this](std::string in, std::string& out) {
  546. return NewExtraView(); });
  547. Dispatch->Action.Push(ActionKey::RepeatStitching, [this](std::string in, std::string& out) {
  548. return RepeatStitching(); });
  549. Dispatch->Action.Push(ActionKey::SetAutoPosiitonNo, [this](std::string in, std::string& out) {
  550. auto value = JSONTo <int>(in);
  551. return SetAutoPosiitonNo(value); });
  552. }
  553. //-----------------------------------------------------------------------------
  554. // 所有的 检查 函数
  555. //-----------------------------------------------------------------------------
  556. RET_STATUS nsMECH::MECHMould::SetStudyInfo(ResDataObject& pParam)
  557. {
  558. STUDAY_INFO info;
  559. info.SetVal(pParam[0].encode());
  560. return RET_STATUS::RET_SUCCEED;
  561. }
  562. RET_STATUS nsMECH::MECHMould::SetViewInfo(ResDataObject& pParam) //假设2个体位View
  563. {
  564. vector<ECOM_PROCEDURE_VIEW> tempProcedureViewList;
  565. for (int i = 0; i < pParam.size(); i++)
  566. {
  567. auto& itrm = pParam[i];
  568. ECOM_PROCEDURE_VIEW viewInfo;
  569. viewInfo.strViewDescription = (string)itrm["ViewDescription"];
  570. viewInfo.strSOPInstanceUID = (string)itrm["SOPInstanceUID"];
  571. viewInfo.strSOPInstanceUID = (string)itrm["SOPInstanceUID"];
  572. tempProcedureViewList.push_back(viewInfo);
  573. }
  574. return RET_STATUS::RET_SUCCEED;
  575. }
  576. RET_STATUS nsMECH::MECHMould::SetPatientInfo(ResDataObject& pParam) //注册完病人信息后调用
  577. {
  578. ECOM_PATIENT PatientInfo;
  579. PatientInfo.strPatientName = (string)pParam["PatientName"];
  580. PatientInfo.strSex = (string)pParam["Sex"];
  581. PatientInfo.strAge = (string)pParam["Age"];
  582. PatientInfo.strPatientID = (string)pParam["PatientID"];
  583. PatientInfo.strPatientSize = (string)pParam["PatientSize"];
  584. PatientInfo.strStudyDescription = (string)pParam["StudyDescription"];
  585. return RET_STATUS::RET_SUCCEED;
  586. }
  587. //-----------------------------------------------------------------------------
  588. // 所有的 通用 函数
  589. //-----------------------------------------------------------------------------
  590. RET_STATUS nsMECH::MECHMould::SetTechParamsInfo(ResDataObject& pParam)
  591. {
  592. TECHPARAM_INFO info;
  593. info.SetVal(pParam.encode());
  594. string strcollimatorwidth = info.m_CollimatorWidth;
  595. string strcollimatorheight = info.m_CollimatorHeight;
  596. string strcollimatorfilter = info.m_CollimatorFilter;
  597. DWORD Width = 0;
  598. DWORD Height = 0;
  599. DWORD dwFilter = 0;
  600. if (strcollimatorwidth.find("IN") != string::npos)
  601. {
  602. Width = (DWORD)(atof(strcollimatorwidth.substr(0, strcollimatorwidth.size() - 2).c_str()) * 2.54);
  603. }
  604. else
  605. {
  606. Width = (DWORD)(atoi(strcollimatorwidth.substr(0, strcollimatorwidth.size() - 2).c_str()));
  607. }
  608. if (strcollimatorheight.find("IN") != string::npos)
  609. {
  610. Height = (DWORD)(atof(strcollimatorheight.substr(0, strcollimatorheight.size() - 2).c_str()) * 2.54);
  611. }
  612. else
  613. {
  614. Height = (DWORD)(atoi(strcollimatorheight.substr(0, strcollimatorheight.size() - 2).c_str()));
  615. }
  616. if (Width != 0 && Height != 0)
  617. {
  618. SetCollimatorSize(Width, Height);
  619. }
  620. dwFilter = (DWORD)atoi(strcollimatorfilter.c_str());
  621. if (dwFilter >= 0)
  622. {
  623. SetCollimatorFilter(dwFilter);
  624. }
  625. return RET_STATUS::RET_SUCCEED;
  626. }
  627. RET_STATUS nsMECH::MECHMould::SetPositionNumber(int pn)
  628. {
  629. return RET_STATUS::RET_SUCCEED;
  630. }
  631. RET_STATUS nsMECH::MECHMould::SetSID(float value)
  632. {
  633. return RET_STATUS::RET_SUCCEED;
  634. }
  635. RET_STATUS nsMECH::MECHMould::SetSOD(float value)
  636. {
  637. return RET_STATUS::RET_SUCCEED;
  638. }
  639. RET_STATUS nsMECH::MECHMould::MoveToHome(string& value)
  640. {
  641. return RET_STATUS::RET_SUCCEED;
  642. }
  643. RET_STATUS nsMECH::MECHMould::MoveMech(string& value)
  644. {
  645. return RET_STATUS::RET_SUCCEED;
  646. }
  647. RET_STATUS nsMECH::MECHMould::StopMech(string& value)
  648. {
  649. return RET_STATUS::RET_SUCCEED;
  650. }
  651. RET_STATUS nsMECH::MECHMould::SetGrid(AttrKey::MECH_GRIDSTATE GridState)
  652. {
  653. return RET_STATUS::RET_SUCCEED;
  654. }
  655. RET_STATUS nsMECH::MECHMould::SetAutoTracking(int nAutoTracking)
  656. {
  657. return RET_STATUS::RET_SUCCEED;
  658. }
  659. //-----------------------------------------------------------------------------
  660. // 所有的 乳腺 函数
  661. //-----------------------------------------------------------------------------
  662. RET_STATUS nsMECH::MECHMould::SetCollimatorSize(int xsize, int ysize)
  663. {
  664. return RET_STATUS::RET_SUCCEED;
  665. }
  666. RET_STATUS nsMECH::MECHMould::SetCollimatorSID(int sid)
  667. {
  668. return RET_STATUS::RET_SUCCEED;
  669. }
  670. RET_STATUS nsMECH::MECHMould::SetCollimatorFilter(int pParams)
  671. {
  672. return RET_STATUS::RET_SUCCEED;
  673. }
  674. RET_STATUS nsMECH::MECHMould::SetCollimatorAngle(int pParams)
  675. {
  676. return RET_STATUS::RET_SUCCEED;
  677. }
  678. RET_STATUS nsMECH::MECHMould::SetCollimatorLight(int Param)
  679. {
  680. return RET_STATUS::RET_SUCCEED;
  681. }
  682. //-----------------------------------------------------------------------------
  683. // 所有的 TOMO 函数
  684. //-----------------------------------------------------------------------------
  685. RET_STATUS nsMECH::MECHMould::SetTomoEnable(bool state)
  686. {
  687. return RET_STATUS::RET_SUCCEED;
  688. }
  689. RET_STATUS nsMECH::MECHMould::SetTomoExpMode(string& vakue)
  690. {
  691. return RET_STATUS::RET_SUCCEED;
  692. }
  693. RET_STATUS nsMECH::MECHMould::SetTomoTechnical(string& value)
  694. {
  695. return RET_STATUS::RET_SUCCEED;
  696. }
  697. RET_STATUS nsMECH::MECHMould::GetTomoResults(std::string& result)
  698. {
  699. return RET_STATUS::RET_SUCCEED;
  700. }
  701. //-----------------------------------------------------------------------------
  702. // 所有的 遮光器 函数
  703. //-----------------------------------------------------------------------------
  704. RET_STATUS nsMECH::MECHMould::SetCollimator(ECOM_COLLIMATOR_INFO& curCollimator)
  705. {
  706. return RET_STATUS::RET_SUCCEED;
  707. }
  708. RET_STATUS nsMECH::MECHMould::SetFilter(int nFilter)
  709. {
  710. return RET_STATUS::RET_SUCCEED;
  711. }
  712. //-----------------------------------------------------------------------------
  713. // 所有的 拼接 函数
  714. //-----------------------------------------------------------------------------
  715. RET_STATUS nsMECH::MECHMould::BeginStitching()
  716. {
  717. return RET_STATUS::RET_SUCCEED;
  718. }
  719. RET_STATUS nsMECH::MECHMould::InitStitching()
  720. {
  721. return RET_STATUS::RET_SUCCEED;
  722. }
  723. RET_STATUS nsMECH::MECHMould::EndStitching()
  724. {
  725. return RET_STATUS::RET_SUCCEED;
  726. }
  727. RET_STATUS nsMECH::MECHMould::SetupStitching(string& value)
  728. {
  729. return RET_STATUS::RET_SUCCEED;
  730. }
  731. //notice the URS that the last acquired image is accepted by host. Move to the next stitching target position.
  732. RET_STATUS nsMECH::MECHMould::AcceptStitchingImage()
  733. {
  734. return RET_STATUS::RET_SUCCEED;
  735. }
  736. //notice the URS that the last acquired image is rejected by host. Keep current position.
  737. RET_STATUS nsMECH::MECHMould::RejectStitchingImage()
  738. {
  739. return RET_STATUS::RET_SUCCEED;
  740. }
  741. //Cancel stitching procedure.
  742. RET_STATUS nsMECH::MECHMould::CancelStitching()
  743. {
  744. return RET_STATUS::RET_SUCCEED;
  745. }
  746. //Note the URS that stitching is finished.
  747. RET_STATUS nsMECH::MECHMould::CompleteStitching()
  748. {
  749. return RET_STATUS::RET_SUCCEED;
  750. }
  751. //New extra view, request the positioner to move to a position to take an extra image.
  752. RET_STATUS nsMECH::MECHMould::NewExtraView()
  753. {
  754. return RET_STATUS::RET_SUCCEED;
  755. }
  756. RET_STATUS nsMECH::MECHMould::RepeatStitching()
  757. {
  758. return RET_STATUS::RET_SUCCEED;
  759. }
  760. RET_STATUS nsMECH::MECHMould::SetAutoPosiitonNo(int nPN)
  761. {
  762. return RET_STATUS::RET_SUCCEED;
  763. }
  764. //-----------------------------------------------------------------------------
  765. // 所有的 牛头 函数
  766. //-----------------------------------------------------------------------------
  767. RET_STATUS nsMECH::MECHMould::SetExpEnable(bool nExpEnabled)
  768. {
  769. return RET_STATUS::RET_SUCCEED;
  770. }
  771. RET_STATUS nsMECH::MECHMould::SetKV(int nKV)
  772. {
  773. return RET_STATUS::RET_SUCCEED;
  774. }
  775. RET_STATUS nsMECH::MECHMould::SetMA(float fMA)
  776. {
  777. return RET_STATUS::RET_SUCCEED;
  778. }
  779. RET_STATUS nsMECH::MECHMould::SetMS(float fMS)
  780. {
  781. return RET_STATUS::RET_SUCCEED;
  782. }
  783. RET_STATUS nsMECH::MECHMould::SetMAS(float fMAS)
  784. {
  785. return RET_STATUS::RET_SUCCEED;
  786. }
  787. RET_STATUS nsMECH::MECHMould::SetWS(int nWS)
  788. {
  789. return RET_STATUS::RET_SUCCEED;
  790. }
  791. RET_STATUS nsMECH::MECHMould::SetFO(int nFO)
  792. {
  793. return RET_STATUS::RET_SUCCEED;
  794. }
  795. RET_STATUS nsMECH::MECHMould::SetTechMode(int nET)
  796. {
  797. return RET_STATUS::RET_SUCCEED;
  798. }
  799. RET_STATUS nsMECH::MECHMould::SetAECField(int nAECFieldSel)
  800. {
  801. return RET_STATUS::RET_SUCCEED;
  802. }
  803. RET_STATUS nsMECH::MECHMould::SetDensity(float fAECDensity)
  804. {
  805. return RET_STATUS::RET_SUCCEED;
  806. }
  807. RET_STATUS nsMECH::MECHMould::SetBodySize(string strSize)
  808. {
  809. return RET_STATUS::RET_SUCCEED;
  810. }
  811. //-----------------------------------------------------------------------------
  812. // nsGEN::DriverMould
  813. //-----------------------------------------------------------------------------
  814. nsMECH::DriverMould::DriverMould ()
  815. {
  816. ConfigInfo Vender (ConfKey::DiosType, "string", "R", "TRUE", "");
  817. m_ConfigInfo.push_back(Vender);
  818. ConfigInfo Model (ConfKey::DiosModel, "string", "R", "TRUE", "");
  819. m_ConfigInfo.push_back(Model);
  820. EasyJSONEncoder synList;
  821. synList.Set ("0", "1");
  822. synList.Set ("1", "2");
  823. ConfigInfo GenIsConnect (ConfKey::DiosIsConnect, "int", "RW", "FALSE", "");
  824. GenIsConnect.SetList (synList.ToString ().c_str ());
  825. m_ConfigInfo.push_back(GenIsConnect);
  826. ConfigInfo SCFType (ConfKey::DiosSCFType, "string", "R", "TRUE", "");
  827. m_ConfigInfo.push_back(SCFType);
  828. EasyJSONEncoder COMList;
  829. COMList.Set ("0", "COM1");
  830. COMList.Set ("1", "COM2");
  831. COMList.Set ("2", "COM3");
  832. COMList.Set ("3", "COM4");
  833. COMList.Set ("4", "COM5");
  834. COMList.Set ("5", "COM6");
  835. COMList.Set ("6", "COM7");
  836. COMList.Set ("7", "COM8");
  837. COMList.Set ("8", "COM9");
  838. COMList.Set ("9", "COM10");
  839. COMList.Set ("10", "COM11");
  840. COMList.Set ("11", "COM12");
  841. ConfigInfo SCFPort (ConfKey::DiosSCFPort, "string", "RW", "TRUE", "");
  842. SCFPort.SetList (COMList.ToString ().c_str ());
  843. m_ConfigInfo.push_back(SCFPort);
  844. ConfigInfo SCFBaudrate (ConfKey::DiosSCFBaudrate, "int", "R", "FALSE", "");
  845. m_ConfigInfo.push_back(SCFBaudrate);
  846. ConfigInfo SCFBytesize (ConfKey::DiosSCFBytesize, "int", "R", "FALSE", "");
  847. m_ConfigInfo.push_back(SCFBytesize);
  848. ConfigInfo SCFParity (ConfKey::DiosSCFParity, "int", "R", "FALSE", "");
  849. m_ConfigInfo.push_back(SCFParity);
  850. ConfigInfo SCFStopbits (ConfKey::DiosSCFStopbits, "int", "R", "FALSE", "");
  851. m_ConfigInfo.push_back(SCFStopbits);
  852. }
  853. nsMECH::DriverMould::~DriverMould ()
  854. {
  855. }
  856. std::string nsMECH::DriverMould::GetGUID () const
  857. {
  858. return MechDriverType;
  859. }
  860. #ifdef _WIN64
  861. #ifdef _DEBUG
  862. static const auto COM_SCFDllName = "Dios.Dev.SerialSCFX64D.dll";
  863. static const auto TCP_SCFDllName = "Dios.Dev.TcpipSCFX64D.dll";
  864. #else
  865. static const auto COM_SCFDllName = "Dios.Dev.SerialSCFX64.dll";
  866. static const auto TCP_SCFDllName = "Dios.Dev.TcpipSCFX64.dll";
  867. #endif
  868. #endif
  869. string nsMECH::DriverMould::GetConnectDLL(string& ConfigFileName)
  870. {
  871. string ConnectDLL = COM_SCFDllName;
  872. ResDataObject r_config, Connection;
  873. if (!r_config.loadFile(ConfigFileName.c_str()))
  874. return ConnectDLL;
  875. if (r_config["CONFIGURATION"]["connections"].GetKeyCount("Value") > 0)
  876. {
  877. Connection = r_config["CONFIGURATION"]["connections"]["Value"];
  878. }
  879. else
  880. {
  881. Connection = r_config["CONFIGURATION"]["connections"][0];
  882. }
  883. if ((string)Connection["type"] == "COM")
  884. ConnectDLL = COM_SCFDllName;
  885. else
  886. ConnectDLL = TCP_SCFDllName;
  887. return ConnectDLL;
  888. }
  889. ResDataObject nsMECH::DriverMould::GetConnectParam(string& ConfigFileName)
  890. {
  891. ResDataObject r_config, Connection;
  892. if (!r_config.loadFile(ConfigFileName.c_str()))
  893. return Connection;
  894. if (r_config["CONFIGURATION"]["connections"].GetKeyCount("Value") > 0)
  895. {
  896. Connection = r_config["CONFIGURATION"]["connections"]["Value"];
  897. }
  898. else
  899. {
  900. Connection = r_config["CONFIGURATION"]["connections"][0];
  901. }
  902. return Connection;
  903. }