CCOS.Dev.Generator.Demo.cpp 72 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282
  1. #include <assert.h>
  2. #include "Helper.JSON.hpp"
  3. #include "CCOS.Dev.Generator.Demo.hpp"
  4. //#include "logger.temp.h"
  5. using namespace CCOS::Dev::Detail::Generator;
  6. namespace nsGEN = CCOS::Dev::Detail::Generator;
  7. #pragma warning (disable:4305)
  8. #define DEMO_DAEC_Flag 1
  9. //-----------------------------------------------------------------------------
  10. // DemoDevice
  11. //-----------------------------------------------------------------------------
  12. float g_MA_List[] = { 8, 10, 12.5, 16, 20, 25, 32, 40, 50, 64, 80, 100, 125, 160, 200, 250, 320, 400, 500, 640 };
  13. float g_MAS_List[] = { 1, 1.25, 1.6, 2, 2.5, 3.2, 4, 5, 6.4, 8, 10, 12.5, 16, 20, 25, 32, 40, 50, 64, 80, 100, 125, 160, 200, 250, 320, 400, 500, 640, 800, 1000 };
  14. float g_MS_List[] = { 1, 2, 3, 4, 5, 6, 8, 10, 12, 16, 20, 25, 32, 40, 50, 64, 80, 100, 125, 160, 200, 250, 320, 400, 500, 640, 800, 1000, 1250, 1600, 2000, 2500, 3200, 4000, 5000, 6400, 8000, 10000 };
  15. float g_KV_List[] = { 400, 405, 410, 415, 420, 430, 440, 450, 460, 470, 480, 490, 500, 510, 520, 535, 550, 560, 570, 585, 600, 615, 630, 645, 660, 680, 700, 715, 730, 750, 770, 790, 810, 830, 850, 875, 900, 930, 960, 1000, 1020, 1050, 1090, 1130, 1170, 1210, 1250, 1290, 1330, 1370, 1410, 1450, 1500 };//<!--KV * 10-->
  16. int g_AECFIELD_List[] = { 1, 10, 100, 11, 101, 110, 111 };
  17. std::vector <float> gf_MA_List = { 8, 10, 12.5, 16, 20, 25, 32, 40, 50, 64, 80, 100, 125, 160, 200, 250, 320, 400, 500, 640 };
  18. std::unique_ptr<OemCollimator> nsGEN::DemoDevice::m_pCollDev = nullptr; //遮光器逻辑实体指针
  19. std::unique_ptr<OemMechanical> nsGEN::DemoDevice::m_pMechDev = nullptr; //机架逻辑实体指针
  20. template<typename T>
  21. int FindPositon(T* pList, int nListSize, T& value)
  22. {
  23. if (pList == NULL || nListSize == 0) return -1;
  24. if (value <= pList[0])
  25. {
  26. value = pList[0];
  27. return 0;
  28. }
  29. if (value >= pList[nListSize - 1])
  30. {
  31. value = pList[nListSize - 1];
  32. return nListSize - 1;
  33. }
  34. for (int i = 0; i < nListSize - 1; i++)
  35. {
  36. if (value >= pList[i] && value <= pList[i + 1])
  37. {
  38. int npos = 0;
  39. if (abs(value - pList[i]) >= abs(value - pList[i + 1]))
  40. {
  41. value = pList[i + 1];
  42. npos = i + 1;
  43. }
  44. else
  45. {
  46. value = pList[i];
  47. npos = i;
  48. }
  49. return npos;
  50. }
  51. }
  52. return -1;
  53. }
  54. nsGEN::DemoDevice::DemoDevice(std::shared_ptr <IOEventCenter> center, string configfile) : super(center), superGen()
  55. {
  56. ////mLog::Info("DEMO ver 3.0.0.1");
  57. if (!configfile.empty())
  58. {
  59. ResDataObject Conftemp;
  60. Conftemp.loadFile(configfile.c_str());
  61. m_GenConfig = Conftemp["CONFIGURATION"];
  62. TransJsonText(m_GenConfig);
  63. string version;
  64. void* hMyModule;
  65. if (GetVersion(version, hMyModule))
  66. //mLog::Info("\n===============log begin : DEMO version:{$} ===================\n", version.c_str());
  67. ///else
  68. //mLog::Info("\n===============log begin : DEMO version:0.0.0.0 ===================\n");
  69. m_iStateChangeInterval = (int)m_GenConfig["StateChangeInterval"];
  70. m_iAutoExpActWaitTime = (int)m_GenConfig["AutoExpActWaitTime"];
  71. m_bIsDemo = ((int)m_GenConfig["IsDemo"]);
  72. //mLog::Info("Config:StateChangeInterval[{$}],AutoExpActWaitTime[{$}],IsDemo[{$}]",
  73. //m_iStateChangeInterval, m_iAutoExpActWaitTime, m_bIsDemo);
  74. }
  75. else
  76. {
  77. //mLog::Info("\n===============log begin : DEMO version:3.0.0.1 ===================\n");
  78. m_iStateChangeInterval = 500;
  79. m_iAutoExpActWaitTime = 5;
  80. m_bIsDemo = true;
  81. //mLog::Info("default:StateChangeInterval[{$}],AutoExpActWaitTime[{$}],IsDemo[{$}]",
  82. // m_iStateChangeInterval, m_iAutoExpActWaitTime, m_bIsDemo);
  83. }
  84. //通用
  85. m_DoseUnit.m_GenSynState.reset(new GENSYNSTATEMould(AttrKey::GENERATOR_RAD_OFF, AttrKey::GENERATOR_RAD_OFF, AttrKey::GENERATOR_RAD_XRAYOFF, 1));
  86. m_DoseUnit.m_GenState.reset(new GENSTATEMould(4, AttrKey::GENERATOR_STATUS_SHUTDOWN, AttrKey::GENERATOR_STATUS_MAX, 1));
  87. m_DoseUnit.m_GenTotalExpNumber.reset(new TOTALEXPNUMMould(0, 0, 9999, 1));
  88. m_DoseUnit.m_GenTotalAcqTimes.reset(new TOTALACQTIMESMould(0, 0, 9999, 1));
  89. m_DoseUnit.m_GenTubeCoolWaitTimes.reset(new TUBECOOLTIMEMould(0, 0, 9999, 1));
  90. m_DoseUnit.m_GenTubeOverLoadNumber.reset(new TUBEOVERLOADNUMMould(0, 0, 9999, 1));
  91. m_DoseUnit.m_GenCurrentExpNumber.reset(new CUREXPNUMMould(0, 0, 9999, 1));
  92. m_DoseUnit.m_ExpMode.reset(new EXPMODEMould(AttrKey::EXPMODE_TYPE::Single));
  93. m_DoseUnit.m_WS.reset(new WORKSTATIONMould(1, 0, 5, 1));
  94. m_DoseUnit.m_HE.reset(new TUBEHEATMould(0, 0, 100, 1));
  95. m_DoseUnit.m_TubeTargetMaterial.reset(new TUBETARGETMATERIALMould(AttrKey::TUBETARGETMATERIAL_TYPE::MO));
  96. m_DoseUnit.m_TubeAngle.reset(new TUBEANGLEMould(0, 0, 360, 1));
  97. //点片
  98. m_DoseUnit.m_KV.reset(new KVMould(0.0, 0.0, 150.0, 1.0));
  99. m_DoseUnit.m_MA.reset(new MAMould(0.0, 0.0, 1000.0, 0.1));
  100. m_DoseUnit.m_MS.reset(new MSMould(0.0, 0.0, 10000.0, 0.01));
  101. m_DoseUnit.m_MAS.reset(new MASMould(0.0, 0.0, 1000.0, 0.01));
  102. m_DoseUnit.m_Techmode.reset(new TECHMODEMould(AttrKey::TECHMODE_TYPE::TECHMODE_NOAEC_2P, AttrKey::TECHMODE_NOAEC_3P, AttrKey::TECHMODE_AEC_2P, 1));
  103. m_DoseUnit.m_Focus.reset(new FOCUSMould(AttrKey::FOCUS_TYPE::FOCUS_LARGE, AttrKey::FOCUS_SMALL, AttrKey::FOCUS_LARGE, 1));
  104. m_DoseUnit.m_AECField.reset(new AECFIELDMould(0, 0, 111, 1));
  105. m_DoseUnit.m_AECFilm.reset(new AECFILMMould(0, 0, 2, 1));
  106. m_DoseUnit.m_AECDensity.reset(new AECDENSITYMould(0, -4, 4, 1));
  107. m_DoseUnit.m_PostKV.reset(new POSTKVMould(0.0, 0.0, 150.0, 1.0));
  108. m_DoseUnit.m_PostMA.reset(new POSTMAMould(0.0, 0.0, 1000.0, 0.1));
  109. m_DoseUnit.m_PostMS.reset(new POSTMSMould(0.0, 0.0, 10000.0, 0.01));
  110. m_DoseUnit.m_PostMAS.reset(new POSTMASMould(0.0, 0.0, 1000.0, 0.01));
  111. //透视
  112. m_DoseUnit.m_FLKV.reset(new FLUKVMould(0.0, 40.0, 150.0, 1));
  113. m_DoseUnit.m_FLMA.reset(new FLUMAMould(0.0, 0.5, 800.0, 0.1));
  114. m_DoseUnit.m_FLMS.reset(new FLUMSMould(0.0, 1.0, 10000.0, 0.01));
  115. m_DoseUnit.m_FLAccTime.reset(new FLAccTimeMould(0.0, 0.0, 300.0, 1));
  116. m_DoseUnit.m_FLIntTime.reset(new FLUIntTimeMould(0.0, 0.0, 1000.0, 1));
  117. m_DoseUnit.m_PPS.reset(new PPSMould(0.0, 0.0, 60.0, 1));
  118. m_DoseUnit.m_FLMode.reset(new FLUModeMould(AttrKey::GENERATOR_FLUMode::GENERATOR_FLMODE_NOTFLU));
  119. m_DoseUnit.m_ABSStatus.reset(new FLUABSStatusMould(AttrKey::GENERATOR_ABSStatus::GENERATOR_ABS_OFF));
  120. m_DoseUnit.m_MagSize.reset(new FLUMagMould(0, 0, 3, 1));
  121. m_DoseUnit.m_DoseLevel.reset(new FLUDoseLevelMould(AttrKey::GENERATOR_DoseLevel::GENERATOR_DOSE_LOW));
  122. m_DoseUnit.m_Curve.reset(new FLUCurveMould(0, 1, 3, 1));
  123. //other
  124. m_MSGUnit.reset(new nsDetail::MSGUnit(center, GeneratorUnitType));
  125. OnRegister();
  126. GetConfData();
  127. //add by wxx:for 品臻3025ZF测试
  128. m_iAutoExpFlag = 0;
  129. m_pHardwareStatusThread = 0;
  130. StartHardwareStatusThread();
  131. }
  132. nsGEN::DemoDevice::~DemoDevice()
  133. {
  134. //mLog::Info("\n===============log end ===================\n");
  135. if (m_pHardwareStatusThread != 0) {
  136. pthread_cancel(m_pHardwareStatusThread); // 请求取消线程
  137. pthread_join(m_pHardwareStatusThread, nullptr); // 等待线程结束
  138. m_pHardwareStatusThread = 0;
  139. }
  140. m_pCollDev.release();
  141. m_pCollDev = nullptr;
  142. m_pMechDev.release();
  143. m_pMechDev = nullptr;
  144. }
  145. void nsGEN::DemoDevice::OnRegister()
  146. {
  147. auto Disp = m_Dispatch.Lock().As();
  148. superGen::Register(Disp);
  149. superGen::RegisterRAD(Disp);
  150. superGen::RegisterAEC(Disp);
  151. superGen::RegisterExpEnable(Disp);
  152. superGen::RegisterGeneratortoSyncStatus(Disp);
  153. superGen::RegisterFluoro(Disp);
  154. Disp->Get.Push(m_MSGUnit->GetKey().c_str(), [this](std::string& out) { out = m_MSGUnit->JSGet(); return RET_STATUS::RET_SUCCEED; });
  155. auto fun_StartMove = [this](auto in, auto& out)
  156. {
  157. return StartMove();
  158. };
  159. Disp->Action.Push("StartMove", fun_StartMove);
  160. auto fun_EndMove = [this](auto in, auto& out)
  161. {
  162. return EndMove();
  163. };
  164. Disp->Action.Push("EndMove", fun_EndMove);
  165. auto fun_DirectlyNotify = [this](auto in, auto& out)
  166. {
  167. return DirectlyNotify(in);
  168. };
  169. Disp->Action.Push("DirectlyNotify", fun_DirectlyNotify);
  170. auto fun_DirectlyCMD = [this](auto in, auto& out)
  171. {
  172. return DirectlyCMD(in);
  173. };
  174. Disp->Action.Push("DirectlyCMD", fun_DirectlyCMD);
  175. }
  176. //设备方法
  177. std::string nsGEN::DemoDevice::GetGUID() const
  178. {
  179. printf("\n===============GetGUID : %s ===================\n", GeneratorUnitType);
  180. return GeneratorUnitType;
  181. }
  182. RET_STATUS nsGEN::DemoDevice::SetWS(std::string value)
  183. {
  184. //mLog::Debug("Enter SetWS:[{$}]", value.c_str());
  185. int tempws = 1;
  186. string strWS = "";
  187. cfgWorkStationKey trWS = cfgWorkStationKey(value.c_str());
  188. if (m_arrWSMap.find(trWS) != m_arrWSMap.end())
  189. {
  190. m_strCurrentWSName = trWS;
  191. tempws = m_arrWSMap[m_strCurrentWSName].nWSNamber;
  192. strWS = m_arrWSMap[m_strCurrentWSName].strWSNAme;
  193. //mLog::Debug("Set WS number [{$}][{$}]", strWS.c_str(), tempws);
  194. }
  195. else
  196. {
  197. //mLog::Debug("Set WS number default 1");
  198. m_strCurrentWSName = cfgWorkStationKey(1);
  199. }
  200. m_DoseUnit.m_WS->Update(atoi(value.c_str()));
  201. FireNotify(m_DoseUnit.m_WS->GetKey(), m_DoseUnit.m_WS->JSGet());
  202. return RET_STATUS::RET_SUCCEED;
  203. }
  204. RET_STATUS nsGEN::DemoDevice::QueryHE(int& value)
  205. {
  206. return RET_STATUS::RET_SUCCEED;
  207. }
  208. RET_STATUS nsGEN::DemoDevice::StartMove() //发生器无此设置
  209. {
  210. return RET_STATUS::RET_SUCCEED;
  211. }
  212. RET_STATUS nsGEN::DemoDevice::EndMove() //发生器无此设置
  213. {
  214. return RET_STATUS::RET_SUCCEED;
  215. }
  216. RET_STATUS nsGEN::DemoDevice::DirectlyNotify(string& value)
  217. {
  218. ResDataObject json;
  219. json.decode(value.c_str());
  220. //mLog::Debug("Enter DirectlyNotify:[{$}]", json.encode());
  221. string strKey = (string)json["NotifyKey"];
  222. string strValue = (string)json["NotifyValue"];
  223. FireNotify(strKey, strValue);
  224. return RET_STATUS::RET_SUCCEED;
  225. }
  226. RET_STATUS nsGEN::DemoDevice::DirectlyCMD(string& value)
  227. {
  228. ResDataObject json;
  229. json.decode(value.c_str());
  230. //mLog::Debug("Enter DirectlyCMD:[{$}]", json.encode());
  231. string strCMD = (string)json["CMDText"];
  232. return RET_STATUS::RET_SUCCEED;
  233. }
  234. RET_STATUS nsGEN::DemoDevice::SetGenSynState(int value)
  235. {
  236. //mLog::Debug("Enter SetGenSynState:[{$}]", value);
  237. switch (value)
  238. {
  239. case AttrKey::GENERATOR_RAD_OFF:
  240. {
  241. }break;
  242. case AttrKey::GENERATOR_RAD_PREPARE:
  243. {
  244. }break;
  245. case AttrKey::GENERATOR_RAD_READY:
  246. {
  247. }break;
  248. case AttrKey::GENERATOR_RAD_XRAYON:
  249. {
  250. if (m_DoseUnit.m_ExpMode->JSGet() == AttrKey::EXPMODE_TYPE::Stitch)
  251. {
  252. if (!m_APRarray.empty())
  253. {
  254. int aprnum = m_DoseUnit.m_GenCurrentExpNumber->Get();
  255. SetAPR(m_APRarray[aprnum]);
  256. m_DoseUnit.m_GenCurrentExpNumber->Update(++aprnum);
  257. //mLog::Debug("SetAPRArray:[totalEXP:{$}, currentEXP:{$}]", m_DoseUnit.m_GenTotalExpNumber->Get(), m_DoseUnit.m_GenCurrentExpNumber->Get());
  258. }
  259. else
  260. {
  261. //mLog::Warn("APRarray is empty");
  262. }
  263. }
  264. else if (m_DoseUnit.m_ExpMode->JSGet() == AttrKey::EXPMODE_TYPE::PulseSerial ||
  265. m_DoseUnit.m_ExpMode->JSGet() == AttrKey::EXPMODE_TYPE::CoutineSerial)
  266. {
  267. value = AttrKey::GENERATOR_FLU_XRAYON;
  268. }
  269. }break;
  270. case AttrKey::GENERATOR_RAD_XRAYOFF:
  271. {
  272. //mLog::Info("SetGenSynState:4 exp Status value:POSTKV[{$}],POSTMA[{$}],POSTMS[{$}],POSTMAS[{$}]",
  273. // m_DoseUnit.m_PostKV->Get(), m_DoseUnit.m_PostMA->Get(), m_DoseUnit.m_PostMS->Get(), m_DoseUnit.m_PostMAS->Get());
  274. std::cout << "SetGenSynState:4 exp Status value:POSTKV["
  275. << m_DoseUnit.m_PostKV->Get()
  276. << "],POSTMA[" << m_DoseUnit.m_PostMA->Get()
  277. << "],POSTMS[" << m_DoseUnit.m_PostMS->Get()
  278. << "],POSTMAS[" << m_DoseUnit.m_PostMAS->Get()
  279. << "]" << std::endl;
  280. FireNotify(AttrKey::POSTKV, m_DoseUnit.m_PostKV->JSGet());
  281. FireNotify(AttrKey::POSTMA, m_DoseUnit.m_PostMA->JSGet());
  282. #if DEMO_DAEC_Flag
  283. int temp = m_DoseUnit.m_PostMS->Get();
  284. if (m_DoseUnit.m_Techmode->Get() == AttrKey::TECHMODE_TYPE::TECHMODE_AEC_3P ||
  285. m_DoseUnit.m_Techmode->Get() == AttrKey::TECHMODE_TYPE::TECHMODE_AEC_2P ||
  286. m_DoseUnit.m_Techmode->Get() == AttrKey::TECHMODE_TYPE::TECHMODE_AEC_1P)
  287. {
  288. temp /= 2;
  289. }
  290. FireNotify(AttrKey::POSTMS, temp);
  291. #else
  292. FireNotify(AttrKey::POSTMS, m_DoseUnit.m_PostMS->JSGet());
  293. #endif // DEMO_DAEC_Flag
  294. FireNotify(AttrKey::POSTMAS, m_DoseUnit.m_PostMAS->JSGet());
  295. if (m_DoseUnit.m_ExpMode->JSGet() == AttrKey::EXPMODE_TYPE::PulseSerial ||
  296. m_DoseUnit.m_ExpMode->JSGet() == AttrKey::EXPMODE_TYPE::CoutineSerial)
  297. {
  298. value = AttrKey::GENERATOR_FLU_XRAYOFF;
  299. }
  300. }break;
  301. case AttrKey::GENERATOR_FLU_READY:
  302. {
  303. }break;
  304. case AttrKey::GENERATOR_FLU_XRAYON:
  305. {
  306. }break;
  307. case AttrKey::GENERATOR_FLU_XRAYOFF:
  308. {
  309. }break;
  310. default:
  311. break;
  312. }
  313. m_DoseUnit.m_GenSynState->Update(value);
  314. FireNotify(m_DoseUnit.m_GenSynState->GetKey(), value);
  315. return RET_STATUS::RET_SUCCEED;
  316. }
  317. RET_STATUS nsGEN::DemoDevice::SetGenState(int value)
  318. {
  319. //mLog::Debug("Enter SetGenState:[{$}]", value);
  320. return RET_STATUS::RET_SUCCEED;
  321. }
  322. RET_STATUS nsGEN::DemoDevice::SetExpEnable()
  323. {
  324. //mLog::Debug("Enter SetExpEnable");
  325. //mLog::Info("Request Fault Status:GENSTATE STATUS_SHUTDOWN -> STATUS_STANDBY");
  326. m_DoseUnit.m_GenState->Update(nsGEN::AttrKey::GENERATOR_STATUS_STANDBY);
  327. FireNotify(AttrKey::GENSTATE, m_DoseUnit.m_GenState->JSGet());
  328. FireNotify(m_DoseUnit.m_KVList->GetKey(), m_DoseUnit.m_KVList->JSGet());
  329. return RET_STATUS::RET_SUCCEED;
  330. }
  331. RET_STATUS nsGEN::DemoDevice::SetExpDisable()
  332. {
  333. //mLog::Debug("Enter SetExpDisable");
  334. return RET_STATUS::RET_SUCCEED;
  335. }
  336. RET_STATUS CCOS::Dev::Detail::Generator::DemoDevice::PrepareAcquisition()
  337. {
  338. m_DoseUnit.m_GenState->Update(nsGEN::AttrKey::GENERATOR_STATUS_STANDBY);
  339. FireNotify(AttrKey::GENSTATE, m_DoseUnit.m_GenState->JSGet());
  340. return RET_STATUS::RET_SUCCEED;
  341. }
  342. RET_STATUS nsGEN::DemoDevice::Reset()
  343. {
  344. //mLog::Debug("Enter Reset");
  345. //FireErrorMessage(false, 0, "clear all Gen error");
  346. return RET_STATUS::RET_SUCCEED;
  347. }
  348. RET_STATUS nsGEN::DemoDevice::SetExpMode(std::string value)
  349. {
  350. //add for dcm img hard
  351. //mLog::Debug("Enter SetExpMode:[{$}]", value.c_str());
  352. if (m_DoseUnit.m_ExpMode->Update(value))
  353. {
  354. FireNotify(AttrKey::EXPMODE, m_DoseUnit.m_ExpMode->JSGet());
  355. }
  356. FireNotify(AttrKey::GENSTATE, m_DoseUnit.m_GenState->JSGet());
  357. m_DoseUnit.m_GenTotalExpNumber->Update(0);
  358. m_DoseUnit.m_GenCurrentExpNumber->Update(0);
  359. //add for dcm img hard
  360. FireNotify(m_DoseUnit.m_TubeTargetMaterial->GetKey(), m_DoseUnit.m_TubeTargetMaterial->JSGet());
  361. FireNotify(m_DoseUnit.m_TubeAngle->GetKey(), m_DoseUnit.m_TubeAngle->JSGet());
  362. if (m_pCollDev != nullptr)
  363. {
  364. //mLog::Info("act CollDev ReportMessageToDicom");
  365. m_pCollDev->ReportMessageToDicom();
  366. }
  367. if (m_pMechDev != nullptr)
  368. {
  369. //mLog::Info("act MechDev ReportMessageToDicom");
  370. m_pMechDev->ReportMessageToDicom();
  371. }
  372. return RET_STATUS::RET_SUCCEED;
  373. }
  374. RET_STATUS nsGEN::DemoDevice::SetEXAMMode(std::string value)
  375. {
  376. //mLog::Debug("Enter SetEXAMMode:[{$}]", value.c_str());
  377. return RET_STATUS::RET_SUCCEED;
  378. }
  379. RET_STATUS nsGEN::DemoDevice::ActiveSyncMode(_tSyncModeArgs value)
  380. {
  381. //mLog::Debug("Enter ActiveSyncMode:Sync[{$},{$}],WS[{$}]", value.strSyncMode.c_str(), value.strSyncValue.c_str(), value.strWS.c_str());
  382. return RET_STATUS::RET_SUCCEED;
  383. }
  384. //点片
  385. RET_STATUS nsGEN::DemoDevice::IncKV()
  386. {
  387. //mLog::Debug("Enter IncKV");
  388. if (m_bIsDemo)
  389. {
  390. if (!m_DoseUnit.m_KV->CanInc()) return RET_STATUS::RET_SUCCEED;
  391. m_DoseUnit.m_KV->Inc();
  392. FireNotify(m_DoseUnit.m_KV->GetKey(), m_DoseUnit.m_KV->JSGet());
  393. m_DoseUnit.m_PostKV->Update(m_DoseUnit.m_KV->Get());
  394. }
  395. return RET_STATUS::RET_SUCCEED;
  396. }
  397. RET_STATUS nsGEN::DemoDevice::DecKV()
  398. {
  399. //mLog::Debug("Enter DecKV");
  400. if (m_bIsDemo)
  401. {
  402. if (!m_DoseUnit.m_KV->CanDec()) return RET_STATUS::RET_SUCCEED;
  403. m_DoseUnit.m_KV->Dec();
  404. m_DoseUnit.m_PostKV->Update(m_DoseUnit.m_KV->Get());
  405. FireNotify(m_DoseUnit.m_KV->GetKey(), m_DoseUnit.m_KV->JSGet());
  406. }
  407. return RET_STATUS::RET_SUCCEED;
  408. }
  409. RET_STATUS nsGEN::DemoDevice::SetKV(float value)
  410. {
  411. //mLog::Debug("Enter SetKV:[{$}]", value);
  412. if (m_bIsDemo)
  413. {
  414. m_DoseUnit.m_KV->Update(value);
  415. m_DoseUnit.m_PostKV->Update(value);
  416. FireNotify(m_DoseUnit.m_KV->GetKey(), m_DoseUnit.m_KV->JSGet());
  417. }
  418. return RET_STATUS::RET_SUCCEED;
  419. }
  420. RET_STATUS nsGEN::DemoDevice::IncKVL()
  421. {
  422. //mLog::Debug("Enter IncKVL");
  423. if (m_bIsDemo)
  424. {
  425. float tempKV = m_DoseUnit.m_KV->Get();
  426. tempKV += 4;
  427. if (m_DoseUnit.m_KV->Update(tempKV))
  428. {
  429. //mLog::Debug("IncKVL:[{$}] ok", tempKV);
  430. FireNotify(m_DoseUnit.m_KV->GetKey(), m_DoseUnit.m_KV->JSGet());
  431. return RET_STATUS::RET_SUCCEED;
  432. }
  433. else
  434. {
  435. //mLog::Debug("IncKVL:[{$}] failed,Exceeding limit", tempKV);
  436. return RET_STATUS::RET_FAILED;
  437. }
  438. }
  439. return RET_STATUS::RET_SUCCEED;
  440. }
  441. RET_STATUS nsGEN::DemoDevice::DecKVL()
  442. {
  443. //mLog::Debug("Enter DecKVL");
  444. if (m_bIsDemo)
  445. {
  446. float tempKV = m_DoseUnit.m_KV->Get();
  447. tempKV -= 4;
  448. if (m_DoseUnit.m_KV->Update(tempKV))
  449. {
  450. //mLog::Debug("DecKVL:[{$}] ok", tempKV);
  451. FireNotify(m_DoseUnit.m_KV->GetKey(), m_DoseUnit.m_KV->JSGet());
  452. return RET_STATUS::RET_SUCCEED;
  453. }
  454. else
  455. {
  456. //mLog::Debug("DecKVL:[{$}] failed,Exceeding limit", tempKV);
  457. return RET_STATUS::RET_FAILED;
  458. }
  459. }
  460. return RET_STATUS::RET_SUCCEED;
  461. }
  462. RET_STATUS nsGEN::DemoDevice::IncMA()
  463. {
  464. //mLog::Debug("Enter IncMA");
  465. if (m_bIsDemo)
  466. {
  467. if (m_DoseUnit.m_Techmode->Get() != AttrKey::TECHMODE_TYPE::TECHMODE_NOAEC_3P &&
  468. m_DoseUnit.m_Techmode->Get() != AttrKey::TECHMODE_TYPE::TECHMODE_AEC_3P)
  469. {
  470. //mLog::Warn("Techmode is not 3P, can't IncMA");
  471. return RET_STATUS::RET_SUCCEED;
  472. }
  473. float value = m_DoseUnit.m_MA->Get();
  474. int npos = FindPositon(g_MA_List, sizeof(g_MA_List) / sizeof(float), value);
  475. if (npos < 0)
  476. {
  477. return RET_STATUS::RET_FAILED;
  478. }
  479. else if (npos == sizeof(g_MA_List) / sizeof(float) - 1)
  480. {
  481. return RET_STATUS::RET_SUCCEED;
  482. }
  483. npos += 1;
  484. float temp = g_MA_List[npos];
  485. m_DoseUnit.m_MA->Update(temp);
  486. m_DoseUnit.m_PostMA->Update(temp);
  487. FireNotify(m_DoseUnit.m_MA->GetKey(), m_DoseUnit.m_MA->JSGet());
  488. ComputeMAS();
  489. }
  490. return RET_STATUS::RET_SUCCEED;
  491. }
  492. RET_STATUS nsGEN::DemoDevice::DecMA()
  493. {
  494. //mLog::Debug("Enter DecMA");
  495. if (m_bIsDemo)
  496. {
  497. if (m_DoseUnit.m_Techmode->Get() != AttrKey::TECHMODE_TYPE::TECHMODE_NOAEC_3P &&
  498. m_DoseUnit.m_Techmode->Get() != AttrKey::TECHMODE_TYPE::TECHMODE_AEC_3P)
  499. {
  500. //mLog::Warn("Techmode is not 3P, can't DecMA");
  501. return RET_STATUS::RET_FAILED;
  502. }
  503. float value = m_DoseUnit.m_MA->Get();
  504. int npos = FindPositon(g_MA_List, sizeof(g_MA_List) / sizeof(float), value);
  505. if (npos < 0)
  506. {
  507. return RET_STATUS::RET_FAILED;
  508. }
  509. else if (npos == 0)
  510. {
  511. return RET_STATUS::RET_SUCCEED;
  512. }
  513. npos -= 1;
  514. float temp = g_MA_List[npos];
  515. m_DoseUnit.m_MA->Update(temp);
  516. m_DoseUnit.m_PostMA->Update(temp);
  517. FireNotify(m_DoseUnit.m_MA->GetKey(), m_DoseUnit.m_MA->JSGet());
  518. ComputeMAS();
  519. }
  520. return RET_STATUS::RET_SUCCEED;
  521. }
  522. RET_STATUS nsGEN::DemoDevice::SetMA(float value)
  523. {
  524. //mLog::Debug("Enter SetMA:[{$}]", value);
  525. if (m_bIsDemo)
  526. {
  527. //if (m_DoseUnit.m_Techmode->Get() != AttrKey::TECHMODE_TYPE::TECHMODE_NOAEC_3P &&
  528. // m_DoseUnit.m_Techmode->Get() != AttrKey::TECHMODE_TYPE::TECHMODE_AEC_3P)
  529. //{
  530. // //mLog::Warn("Techmode is not 3P, can't SetMA");
  531. // return RET_STATUS::RET_FAILED;
  532. //}
  533. int npos = FindPositon(g_MA_List, sizeof(g_MA_List) / sizeof(float), value);
  534. if (npos < 0)
  535. {
  536. return RET_STATUS::RET_FAILED;
  537. }
  538. float temp = g_MA_List[npos];
  539. m_DoseUnit.m_MA->Update(temp);
  540. m_DoseUnit.m_PostMA->Update(temp);
  541. FireNotify(m_DoseUnit.m_MA->GetKey(), m_DoseUnit.m_MA->JSGet());
  542. }
  543. return RET_STATUS::RET_SUCCEED;
  544. }
  545. RET_STATUS nsGEN::DemoDevice::IncMS()
  546. {
  547. //mLog::Debug("Enter IncMS");
  548. if (m_bIsDemo)
  549. {
  550. if (m_DoseUnit.m_Techmode->Get() != AttrKey::TECHMODE_TYPE::TECHMODE_NOAEC_3P &&
  551. m_DoseUnit.m_Techmode->Get() != AttrKey::TECHMODE_TYPE::TECHMODE_AEC_3P)
  552. {
  553. //mLog::Warn("Techmode is not 3P, can't IncMAS");
  554. return RET_STATUS::RET_FAILED;
  555. }
  556. float value = m_DoseUnit.m_MS->Get();
  557. int npos = FindPositon(g_MS_List, sizeof(g_MS_List) / sizeof(float), value);
  558. if (npos < 0)
  559. {
  560. return RET_STATUS::RET_FAILED;
  561. }
  562. else if (npos == sizeof(g_MS_List) / sizeof(float) - 1)
  563. {
  564. return RET_STATUS::RET_SUCCEED;
  565. }
  566. npos += 1;
  567. float temp = g_MS_List[npos];
  568. m_DoseUnit.m_MS->Update(temp);
  569. m_DoseUnit.m_PostMS->Update(temp);
  570. FireNotify(m_DoseUnit.m_MS->GetKey(), m_DoseUnit.m_MS->JSGet());
  571. ComputeMAS();
  572. }
  573. return RET_STATUS::RET_SUCCEED;
  574. }
  575. RET_STATUS nsGEN::DemoDevice::DecMS()
  576. {
  577. //mLog::Debug("Enter DecMS");
  578. if (m_bIsDemo)
  579. {
  580. if (m_DoseUnit.m_Techmode->Get() != AttrKey::TECHMODE_TYPE::TECHMODE_NOAEC_3P &&
  581. m_DoseUnit.m_Techmode->Get() != AttrKey::TECHMODE_TYPE::TECHMODE_AEC_3P)
  582. {
  583. //mLog::Warn("Techmode is not 3P, can't DecMS");
  584. return RET_STATUS::RET_FAILED;
  585. }
  586. float value = m_DoseUnit.m_MS->Get();
  587. int npos = FindPositon(g_MS_List, sizeof(g_MS_List) / sizeof(float), value);
  588. if (npos < 0)
  589. {
  590. return RET_STATUS::RET_FAILED;
  591. }
  592. else if (npos == 0)
  593. {
  594. return RET_STATUS::RET_SUCCEED;
  595. }
  596. npos -= 1;
  597. float temp = g_MS_List[npos];
  598. m_DoseUnit.m_MS->Update(temp);
  599. m_DoseUnit.m_PostMS->Update(temp);
  600. FireNotify(m_DoseUnit.m_MS->GetKey(), m_DoseUnit.m_MS->JSGet());
  601. ComputeMAS();
  602. }
  603. return RET_STATUS::RET_SUCCEED;
  604. }
  605. RET_STATUS nsGEN::DemoDevice::SetMS(float value)
  606. {
  607. //mLog::Debug("Enter SetMS:[{$}]", value);
  608. if (m_bIsDemo)
  609. {
  610. //if (m_DoseUnit.m_Techmode->Get() != AttrKey::TECHMODE_TYPE::TECHMODE_NOAEC_3P &&
  611. // m_DoseUnit.m_Techmode->Get() != AttrKey::TECHMODE_TYPE::TECHMODE_AEC_3P)
  612. //{
  613. // //mLog::Warn("Techmode is not 3P, can't SetMS");
  614. // return RET_STATUS::RET_FAILED;
  615. //}
  616. int npos = FindPositon(g_MS_List, sizeof(g_MS_List) / sizeof(float), value);
  617. if (npos < 0)
  618. {
  619. return RET_STATUS::RET_FAILED;
  620. }
  621. float temp = g_MS_List[npos];
  622. m_DoseUnit.m_MS->Update(temp);
  623. m_DoseUnit.m_PostMS->Update(temp);
  624. FireNotify(m_DoseUnit.m_MS->GetKey(), m_DoseUnit.m_MS->JSGet());
  625. }
  626. return RET_STATUS::RET_SUCCEED;
  627. }
  628. RET_STATUS nsGEN::DemoDevice::IncMAS()
  629. {
  630. //mLog::Debug("Enter IncMAS");
  631. if (m_bIsDemo)
  632. {
  633. if (m_DoseUnit.m_Techmode->Get() != AttrKey::TECHMODE_TYPE::TECHMODE_NOAEC_2P &&
  634. m_DoseUnit.m_Techmode->Get() != AttrKey::TECHMODE_TYPE::TECHMODE_AEC_2P)
  635. {
  636. //mLog::Warn("Techmode is not 2P, can't IncMAS");
  637. return RET_STATUS::RET_NOSUPPORT;
  638. }
  639. float value = m_DoseUnit.m_MAS->Get();
  640. int npos = FindPositon(g_MAS_List, sizeof(g_MAS_List) / sizeof(float), value);
  641. if (npos < 0)
  642. {
  643. return RET_STATUS::RET_SUCCEED;
  644. }
  645. else if (npos == sizeof(g_MAS_List) / sizeof(float) - 1)
  646. {
  647. return RET_STATUS::RET_SUCCEED;
  648. }
  649. npos += 1;
  650. float temp = g_MAS_List[npos];
  651. m_DoseUnit.m_MAS->Update(temp);
  652. m_DoseUnit.m_PostMAS->Update(temp);
  653. FireNotify(m_DoseUnit.m_MAS->GetKey(), m_DoseUnit.m_MAS->JSGet());
  654. }
  655. return RET_STATUS::RET_SUCCEED;
  656. }
  657. RET_STATUS nsGEN::DemoDevice::DecMAS()
  658. {
  659. //mLog::Debug("Enter DecMAS");
  660. if (m_bIsDemo)
  661. {
  662. if (m_DoseUnit.m_Techmode->Get() != AttrKey::TECHMODE_TYPE::TECHMODE_NOAEC_2P &&
  663. m_DoseUnit.m_Techmode->Get() != AttrKey::TECHMODE_TYPE::TECHMODE_AEC_2P)
  664. {
  665. //mLog::Warn("Techmode is not 2P, can't DecMAS");
  666. return RET_STATUS::RET_NOSUPPORT;
  667. }
  668. float value = m_DoseUnit.m_MAS->Get();
  669. int npos = FindPositon(g_MAS_List, sizeof(g_MAS_List) / sizeof(float), value);
  670. if (npos < 0)
  671. {
  672. return RET_STATUS::RET_FAILED;
  673. }
  674. else if (npos == 0)
  675. {
  676. return RET_STATUS::RET_SUCCEED;
  677. }
  678. npos -= 1;
  679. float temp = g_MAS_List[npos];
  680. m_DoseUnit.m_MAS->Update(temp);
  681. m_DoseUnit.m_PostMAS->Update(temp);
  682. FireNotify(m_DoseUnit.m_MAS->GetKey(), m_DoseUnit.m_MAS->JSGet());
  683. }
  684. return RET_STATUS::RET_SUCCEED;
  685. }
  686. RET_STATUS nsGEN::DemoDevice::SetMAS(float value)
  687. {
  688. //mLog::Debug("Enter SetMAS:[{$}]", value);
  689. if (m_bIsDemo)
  690. {
  691. //if (m_DoseUnit.m_Techmode->Get() != AttrKey::TECHMODE_TYPE::TECHMODE_NOAEC_2P &&
  692. // m_DoseUnit.m_Techmode->Get() != AttrKey::TECHMODE_TYPE::TECHMODE_AEC_2P)
  693. //{
  694. // //mLog::Warn("Techmode is not 2P, can't SetMAS");
  695. // return RET_STATUS::RET_NOSUPPORT;
  696. //}
  697. int npos = FindPositon(g_MAS_List, sizeof(g_MAS_List) / sizeof(float), value);
  698. if (npos < 0)
  699. {
  700. return RET_STATUS::RET_FAILED;
  701. }
  702. float temp = g_MAS_List[npos];
  703. m_DoseUnit.m_MAS->Update(temp);
  704. m_DoseUnit.m_PostMAS->Update(temp);
  705. FireNotify(m_DoseUnit.m_MAS->GetKey(), m_DoseUnit.m_MAS->JSGet());
  706. }
  707. return RET_STATUS::RET_SUCCEED;
  708. }
  709. RET_STATUS nsGEN::DemoDevice::IncMASL()
  710. {
  711. //mLog::Debug("Enter IncMASL");
  712. if (m_bIsDemo)
  713. {
  714. if (m_DoseUnit.m_Techmode->Get() != AttrKey::TECHMODE_TYPE::TECHMODE_NOAEC_2P &&
  715. m_DoseUnit.m_Techmode->Get() != AttrKey::TECHMODE_TYPE::TECHMODE_AEC_2P)
  716. {
  717. //mLog::Warn("Techmode is not 2P, can't IncMASL");
  718. return RET_STATUS::RET_NOSUPPORT;
  719. }
  720. float tempMAS = m_DoseUnit.m_MAS->Get();
  721. tempMAS += 4;
  722. if (m_DoseUnit.m_MAS->Update(tempMAS))
  723. {
  724. //mLog::Debug("IncMASL:[{$}] ok", tempMAS);
  725. FireNotify(m_DoseUnit.m_MAS->GetKey(), m_DoseUnit.m_MAS->JSGet());
  726. return RET_STATUS::RET_SUCCEED;
  727. }
  728. else
  729. {
  730. //mLog::Debug("IncMASL:[{$}] failed,Exceeding limit", tempMAS);
  731. return RET_STATUS::RET_FAILED;
  732. }
  733. }
  734. return RET_STATUS::RET_SUCCEED;
  735. }
  736. RET_STATUS nsGEN::DemoDevice::DecMASL()
  737. {
  738. //mLog::Debug("Enter DecMASL");
  739. if (m_bIsDemo)
  740. {
  741. if (m_DoseUnit.m_Techmode->Get() != AttrKey::TECHMODE_TYPE::TECHMODE_NOAEC_2P &&
  742. m_DoseUnit.m_Techmode->Get() != AttrKey::TECHMODE_TYPE::TECHMODE_AEC_2P)
  743. {
  744. //mLog::Warn("Techmode is not 2P, can't DecMASL");
  745. return RET_STATUS::RET_NOSUPPORT;
  746. }
  747. float tempMAS = m_DoseUnit.m_MAS->Get();
  748. tempMAS -= 4;
  749. if (m_DoseUnit.m_MAS->Update(tempMAS))
  750. {
  751. //mLog::Debug("DecMASL:[{$}] ok", tempMAS);
  752. FireNotify(m_DoseUnit.m_MAS->GetKey(), m_DoseUnit.m_MAS->JSGet());
  753. return RET_STATUS::RET_SUCCEED;
  754. }
  755. else
  756. {
  757. //mLog::Debug("DecMASL:[{$}] failed,Exceeding limit", tempMAS);
  758. return RET_STATUS::RET_FAILED;
  759. }
  760. }
  761. return RET_STATUS::RET_SUCCEED;
  762. }
  763. void nsGEN::DemoDevice::ComputeMAS()
  764. {
  765. float tempMa = m_DoseUnit.m_MA->Get();
  766. float tempMs = m_DoseUnit.m_MS->Get();
  767. float tempMAS = tempMa * tempMs / 1000.0f;
  768. //m_DoseUnit.m_MAS->Update(tempMAS);
  769. m_DoseUnit.m_PostMAS->Update(tempMAS);
  770. //mLog::Debug("ComputeMAS:MA[{$}] MS[{$}] tempMAS[{$}] MAS[{$}] postMAS[{$}]",
  771. //tempMa, tempMs,tempMAS,m_DoseUnit.m_MAS->Get(), m_DoseUnit.m_PostMAS->Get());
  772. FireNotify(m_DoseUnit.m_MAS->GetKey(), tempMAS);
  773. }
  774. RET_STATUS nsGEN::DemoDevice::SetTechmode(int value)
  775. {
  776. //mLog::Debug("Enter SetTechmode:[{$}]", value);
  777. if (m_bIsDemo)
  778. {
  779. if (!m_DoseUnit.m_Techmode->Verify(value)) return RET_STATUS::RET_SUCCEED;
  780. m_DoseUnit.m_Techmode->Update(value);
  781. FireNotify(m_DoseUnit.m_Techmode->GetKey(), m_DoseUnit.m_Techmode->JSGet());
  782. switch (value)
  783. {
  784. case AttrKey::TECHMODE_TYPE::TECHMODE_NOAEC_3P:
  785. {
  786. FireNotify(m_DoseUnit.m_MA->GetKey(), m_DoseUnit.m_MA->JSGet());
  787. FireNotify(m_DoseUnit.m_MS->GetKey(), m_DoseUnit.m_MS->JSGet());
  788. ComputeMAS();
  789. }
  790. break;
  791. case AttrKey::TECHMODE_TYPE::TECHMODE_NOAEC_2P:
  792. {
  793. FireNotify(m_DoseUnit.m_MA->GetKey(), "0");
  794. FireNotify(m_DoseUnit.m_MS->GetKey(), "0");
  795. FireNotify(m_DoseUnit.m_MAS->GetKey(), m_DoseUnit.m_MAS->JSGet());
  796. }
  797. break;
  798. case AttrKey::TECHMODE_TYPE::TECHMODE_AEC_3P:
  799. {
  800. FireNotify(m_DoseUnit.m_MA->GetKey(), m_DoseUnit.m_MA->JSGet());
  801. FireNotify(m_DoseUnit.m_MS->GetKey(), m_DoseUnit.m_MS->JSGet());
  802. ComputeMAS();
  803. }
  804. break;
  805. case AttrKey::TECHMODE_TYPE::TECHMODE_AEC_2P:
  806. {
  807. FireNotify(m_DoseUnit.m_MA->GetKey(), "0");
  808. FireNotify(m_DoseUnit.m_MS->GetKey(), "0");
  809. FireNotify(m_DoseUnit.m_MAS->GetKey(), m_DoseUnit.m_MAS->JSGet());
  810. }
  811. break;
  812. }
  813. }
  814. return RET_STATUS::RET_SUCCEED;
  815. }
  816. RET_STATUS nsGEN::DemoDevice::SetFocus(int value)
  817. {
  818. //mLog::Debug("Enter SetFocus:[{$}]", value);
  819. if (m_bIsDemo)
  820. {
  821. if (!m_DoseUnit.m_Focus->Verify(value)) return RET_STATUS::RET_SUCCEED;
  822. m_DoseUnit.m_Focus->Update(value);
  823. FireNotify(m_DoseUnit.m_Focus->GetKey(), m_DoseUnit.m_Focus->JSGet());
  824. if (m_DoseUnit.m_Focus->Get() == AttrKey::FOCUS_SMALL)
  825. FireNotify(AttrKey::FOCUSSIZE, m_DoseUnit.m_FocusSmall);
  826. else
  827. FireNotify(AttrKey::FOCUSSIZE, m_DoseUnit.m_FocusLarge);
  828. }
  829. return RET_STATUS::RET_SUCCEED;
  830. }
  831. RET_STATUS nsGEN::DemoDevice::SetAECDensity(int value)
  832. {
  833. //mLog::Debug("Enter SetAECDensity:[{$}]", value);
  834. if (m_bIsDemo)
  835. {
  836. if (m_DoseUnit.m_Techmode->Get() != AttrKey::TECHMODE_TYPE::TECHMODE_AEC_1P &&
  837. m_DoseUnit.m_Techmode->Get() != AttrKey::TECHMODE_TYPE::TECHMODE_AEC_2P &&
  838. m_DoseUnit.m_Techmode->Get() != AttrKey::TECHMODE_TYPE::TECHMODE_AEC_3P)
  839. {
  840. printf("\n Techmode is not AEC, can't SetAECDensity");
  841. return RET_STATUS::RET_NOSUPPORT;
  842. }
  843. if (!m_DoseUnit.m_AECDensity->Verify(value)) return RET_STATUS::RET_FAILED;
  844. m_DoseUnit.m_AECDensity->Update(value);
  845. FireNotify(m_DoseUnit.m_AECDensity->GetKey(), m_DoseUnit.m_AECDensity->JSGet());
  846. }
  847. return RET_STATUS::RET_SUCCEED;
  848. }
  849. RET_STATUS nsGEN::DemoDevice::IncAECDensity()
  850. {
  851. //mLog::Debug("Enter IncAECDensity");
  852. if (m_bIsDemo)
  853. {
  854. //mLog::Debug("Enter IncAECDensity");
  855. if (m_DoseUnit.m_Techmode->Get() != AttrKey::TECHMODE_TYPE::TECHMODE_AEC_1P &&
  856. m_DoseUnit.m_Techmode->Get() != AttrKey::TECHMODE_TYPE::TECHMODE_AEC_2P &&
  857. m_DoseUnit.m_Techmode->Get() != AttrKey::TECHMODE_TYPE::TECHMODE_AEC_3P)
  858. {
  859. //mLog::Warn("Techmode is not AEC, can't IncAECDensity");
  860. return RET_STATUS::RET_NOSUPPORT;
  861. }
  862. if (m_DoseUnit.m_AECDensity->CanInc())
  863. {
  864. m_DoseUnit.m_AECDensity->Inc();
  865. FireNotify(m_DoseUnit.m_AECDensity->GetKey(), m_DoseUnit.m_AECDensity->JSGet());
  866. }
  867. }
  868. return RET_STATUS::RET_SUCCEED;
  869. }
  870. RET_STATUS nsGEN::DemoDevice::DecAECDensity()
  871. {
  872. //mLog::Debug("Enter DecAECDensity");
  873. if (m_bIsDemo)
  874. {
  875. //mLog::Debug("Enter DecAECDensity");
  876. if (m_DoseUnit.m_Techmode->Get() != AttrKey::TECHMODE_TYPE::TECHMODE_AEC_1P &&
  877. m_DoseUnit.m_Techmode->Get() != AttrKey::TECHMODE_TYPE::TECHMODE_AEC_2P &&
  878. m_DoseUnit.m_Techmode->Get() != AttrKey::TECHMODE_TYPE::TECHMODE_AEC_3P)
  879. {
  880. //mLog::Warn("Techmode is not AEC, can't DecAECDensity");
  881. return RET_STATUS::RET_NOSUPPORT;
  882. }
  883. if (m_DoseUnit.m_AECDensity->CanDec())
  884. {
  885. m_DoseUnit.m_AECDensity->Dec();
  886. FireNotify(m_DoseUnit.m_AECDensity->GetKey(), m_DoseUnit.m_AECDensity->JSGet());
  887. }
  888. }
  889. return RET_STATUS::RET_SUCCEED;
  890. }
  891. RET_STATUS nsGEN::DemoDevice::SetAECField(int value)
  892. {
  893. //mLog::Debug("Enter SetAECField:[{$}]", value);
  894. if (m_bIsDemo)
  895. {
  896. if (m_DoseUnit.m_Techmode->Get() != AttrKey::TECHMODE_V2TYPE::ET_AEC)
  897. {
  898. printf("\n Techmode is not AEC, can't set AEC");
  899. return RET_STATUS::RET_FAILED;
  900. }
  901. if (!m_DoseUnit.m_AECField->Verify(value)) return RET_STATUS::RET_SUCCEED;
  902. int npos = FindPositon(g_AECFIELD_List, sizeof(g_AECFIELD_List) / sizeof(int), value);
  903. if (npos < 0)
  904. {
  905. return RET_STATUS::RET_FAILED;
  906. }
  907. int temp = value;
  908. m_DoseUnit.m_AECField->Update(temp);
  909. FireNotify(m_DoseUnit.m_AECField->GetKey(), m_DoseUnit.m_AECField->JSGet());
  910. }
  911. return RET_STATUS::RET_SUCCEED;
  912. }
  913. RET_STATUS nsGEN::DemoDevice::SetAECFilm(int value)
  914. {
  915. //mLog::Debug("Enter SetAECFilm:[{$}]", value);
  916. if (m_bIsDemo)
  917. {
  918. if (m_DoseUnit.m_Techmode->Get() != AttrKey::TECHMODE_V2TYPE::ET_AEC)
  919. {
  920. printf("\n Techmode is not AEC, can't set AEC");
  921. return RET_STATUS::RET_FAILED;
  922. }
  923. if (!m_DoseUnit.m_AECFilm->Verify(value)) return RET_STATUS::RET_SUCCEED;
  924. m_DoseUnit.m_AECFilm->Update(value);
  925. FireNotify(m_DoseUnit.m_AECFilm->GetKey(), m_DoseUnit.m_AECFilm->JSGet());
  926. }
  927. return RET_STATUS::RET_SUCCEED;
  928. }
  929. RET_STATUS nsGEN::DemoDevice::SetAPR(const _tAPRArgs& t)
  930. {
  931. //mLog::Debug("SetAPR:KV={$},MA={$},MS={$},MAS={$},Focus={$},Techmode={$},WS={$},AECDensity={$},AECField={$},AECFilm={$}",
  932. //t.fKV, t.fMA, t.fMS, t.fMAS, t.nFocus, t.nTechmode, t.nWS, t.nAECDensity, t.nAECField, t.nAECFilm);
  933. if (m_bIsDemo)
  934. {
  935. //note:缺少WS
  936. SetTechmode(t.nTechmode);
  937. SetKV(t.fKV);
  938. SetMA(t.fMA);
  939. SetMS(t.fMS);
  940. SetMAS(t.fMAS);
  941. SetFocus(t.nFocus);
  942. SetAECDensity(t.nAECDensity);
  943. SetAECField(t.nAECField);
  944. SetAECFilm(t.nAECFilm);
  945. if (m_DoseUnit.m_Techmode->Get() == AttrKey::TECHMODE_TYPE::TECHMODE_NOAEC_3P ||
  946. m_DoseUnit.m_Techmode->Get() == AttrKey::TECHMODE_TYPE::TECHMODE_AEC_3P)
  947. {
  948. ComputeMAS();
  949. }
  950. m_DoseUnit.m_HE->Update(50);
  951. FireNotify(m_DoseUnit.m_HE->GetKey(), m_DoseUnit.m_HE->JSGet());
  952. }
  953. else
  954. {
  955. FireNotify(m_DoseUnit.m_Techmode->GetKey(), t.nTechmode);
  956. FireNotify(m_DoseUnit.m_KV->GetKey(), t.fKV);
  957. FireNotify(m_DoseUnit.m_MA->GetKey(), t.fMA);
  958. FireNotify(m_DoseUnit.m_MS->GetKey(), t.fMS);
  959. FireNotify(m_DoseUnit.m_MAS->GetKey(), t.fMAS);
  960. FireNotify(m_DoseUnit.m_Focus->GetKey(), t.nFocus);
  961. FireNotify(m_DoseUnit.m_AECDensity->GetKey(), t.nAECDensity);
  962. FireNotify(m_DoseUnit.m_AECField->GetKey(), t.nAECField);
  963. FireNotify(m_DoseUnit.m_AECFilm->GetKey(), t.nAECFilm);
  964. }
  965. return RET_STATUS::RET_SUCCEED;
  966. }
  967. RET_STATUS nsGEN::DemoDevice::SetAPRArray(vector<_tAPRArgs>& APRarray)
  968. {
  969. //mLog::Debug("SetAPRArray:[size:{$}]", APRarray.size());
  970. if (m_bIsDemo)
  971. {
  972. m_APRarray = APRarray;
  973. for (int i = 0; i < m_APRarray.size(); i++)
  974. {
  975. //mLog::Debug("APRArray[{$}]:WS={$},Techmode={$},Focus={$},KV={$},MA={$},MS={$},MAS={$},AECDensity={$},AECField={$},AECFilm={$}",
  976. //i, m_APRarray[i].nWS, m_APRarray[i].nTechmode, m_APRarray[i].nFocus,
  977. //m_APRarray[i].fKV, m_APRarray[i].fMA, m_APRarray[i].fMS, m_APRarray[i].fMAS,
  978. //m_APRarray[i].nAECDensity, m_APRarray[i].nAECField, m_APRarray[i].nAECFilm);
  979. }
  980. if (!m_APRarray.empty())
  981. {
  982. SetAPR(m_APRarray[0]);
  983. m_DoseUnit.m_GenTotalExpNumber->Update(m_APRarray.size());
  984. m_DoseUnit.m_GenCurrentExpNumber->Update(1);
  985. //mLog::Debug("SetAPRArray:[totalEXP:{$}, currentEXP:{$}]", m_DoseUnit.m_GenTotalExpNumber->Get(), m_DoseUnit.m_GenCurrentExpNumber->Get());
  986. }
  987. }
  988. return RET_STATUS::RET_SUCCEED;
  989. }
  990. RET_STATUS nsGEN::DemoDevice::QueryPostKV(float& value)
  991. {
  992. value = m_DoseUnit.m_KV->Get();
  993. return RET_STATUS::RET_SUCCEED;
  994. }
  995. RET_STATUS nsGEN::DemoDevice::QueryPostMA(float& value)
  996. {
  997. value = m_DoseUnit.m_MA->Get();
  998. return RET_STATUS::RET_SUCCEED;
  999. }
  1000. RET_STATUS nsGEN::DemoDevice::QueryPostMS(float& value)
  1001. {
  1002. value = m_DoseUnit.m_MS->Get();
  1003. return RET_STATUS::RET_SUCCEED;
  1004. }
  1005. RET_STATUS nsGEN::DemoDevice::QueryPostMAS(float& value)
  1006. {
  1007. value = m_DoseUnit.m_MAS->Get();
  1008. return RET_STATUS::RET_SUCCEED;
  1009. }
  1010. RET_STATUS nsGEN::DemoDevice::SetFrameRate(float frameRate)
  1011. {
  1012. //mLog::Debug("Enter SetFrameRate:[{$}]", frameRate);
  1013. return RET_STATUS::RET_SUCCEED;
  1014. }
  1015. RET_STATUS nsGEN::DemoDevice::SetCollimatorDev(OemCollimator* dev)
  1016. {
  1017. //mLog::Debug("Enter SetCollimatorDev");
  1018. if (dev)
  1019. m_pCollDev.reset(dev);
  1020. return RET_STATUS::RET_SUCCEED;
  1021. }
  1022. RET_STATUS nsGEN::DemoDevice::SetMechDev(OemMechanical* dev)
  1023. {
  1024. //mLog::Debug("Enter SetMechDev");
  1025. if (dev)
  1026. m_pMechDev.reset(dev);
  1027. return RET_STATUS::RET_SUCCEED;
  1028. }
  1029. RET_STATUS nsGEN::DemoDevice::SetCollimatorSize(int xsize, int ysize)
  1030. {
  1031. //mLog::Debug("Enter SetCollimatorSize:[x:{$}, y:{$}]", xsize, ysize);
  1032. if (m_pCollDev)
  1033. {
  1034. m_pCollDev->UpdateCollimatorXSize(xsize);
  1035. m_pCollDev->UpdateCollimatorYSize(ysize);
  1036. }
  1037. return RET_STATUS::RET_SUCCEED;
  1038. }
  1039. RET_STATUS nsGEN::DemoDevice::SetCollimatorLight(unsigned short pParams)
  1040. {
  1041. //mLog::Debug("Enter SetCollimatorLight:[{$}]", (int)pParams);
  1042. //此处应该发送指令给GEN,并且该指令可以控制 coll 的LED
  1043. return RET_STATUS::RET_SUCCEED;
  1044. }
  1045. RET_STATUS nsGEN::DemoDevice::SetAutoTracking(int nAutoTracking)
  1046. {
  1047. //mLog::Debug("Enter SetAutoTracking:[{$}]", nAutoTracking);
  1048. if (m_pMechDev)
  1049. m_pMechDev->UpdateMammo_Depress(nAutoTracking);
  1050. return RET_STATUS::RET_SUCCEED;
  1051. }
  1052. RET_STATUS nsGEN::DemoDevice::SetFilter(int nFilterType)
  1053. {
  1054. //mLog::Debug("Enter SetFilter:[{$}]", nFilterType);
  1055. if (m_pMechDev)
  1056. {
  1057. m_pMechDev->UpdateMammo_FT(nFilterType);
  1058. }
  1059. if (m_pCollDev)
  1060. {
  1061. m_pCollDev->UpdateCollimatorFilter(nFilterType);
  1062. }
  1063. return RET_STATUS::RET_SUCCEED;
  1064. }
  1065. RET_STATUS nsGEN::DemoDevice::SetGrid(int nGridType)
  1066. {
  1067. //mLog::Debug("Enter SetGrid:[{$}]", nGridType);
  1068. if (m_pMechDev)
  1069. m_pMechDev->UpdateGrid(nGridType);
  1070. return RET_STATUS::RET_SUCCEED;
  1071. }
  1072. RET_STATUS nsGEN::DemoDevice::GetTomoResults(ResDataObject& resultAngle, ResDataObject& resultHeight)
  1073. {
  1074. RET_STATUS ret = RET_STATUS::RET_SUCCEED;
  1075. if (resultAngle.size() == 1 && resultHeight.size() == 1)
  1076. {
  1077. m_resultAngle.update(resultAngle.GetKey(0), (float)resultAngle[0]);
  1078. //mLog::Info("GetTomoResults insert, key={$},value={$}", resultAngle.GetKey(0), (float)resultAngle[0]);
  1079. }
  1080. else
  1081. {
  1082. //mLog::Info("GetTomoResults size={$}", m_resultAngle.size());
  1083. for (int i = 0; i < m_resultAngle.size(); i++)
  1084. {
  1085. resultAngle.update(m_resultAngle.GetKey(i), (float)m_resultAngle[i]);
  1086. //mLog::Info("GetTomoResults ket={$} ,resule={$}", m_resultAngle.GetKey(i), (float)m_resultAngle[i]);
  1087. }
  1088. resultHeight.update("0", 63.71);
  1089. resultHeight.update("1", 63.97);
  1090. resultHeight.update("2", 64.21);
  1091. resultHeight.update("3", 64.41);
  1092. resultHeight.update("4", 64.59);
  1093. resultHeight.update("5", 64.73);
  1094. resultHeight.update("6", 64.84);
  1095. resultHeight.update("7", 64.92);
  1096. resultHeight.update("8", 64.97);
  1097. resultHeight.update("9", 64.99);
  1098. resultHeight.update("10", 64.98);
  1099. resultHeight.update("11", 64.94);
  1100. resultHeight.update("12", 64.87);
  1101. resultHeight.update("13", 64.72);
  1102. resultHeight.update("14", 64.63);
  1103. resultHeight.update("15", 64.47);
  1104. resultHeight.update("16", 64.28);
  1105. resultHeight.update("17", 64.05);
  1106. m_resultAngle.clear();
  1107. }
  1108. return ret;
  1109. }
  1110. //透视
  1111. RET_STATUS nsGEN::DemoDevice::IncFluKV()
  1112. {
  1113. //mLog::Debug("Enter IncFluKV");
  1114. float KV = m_DoseUnit.m_FLKV->Get()+1;
  1115. if (m_DoseUnit.m_FLKV->Update(KV))
  1116. {
  1117. FireNotify(m_DoseUnit.m_FLKV->GetKey(), m_DoseUnit.m_FLKV->JSGet());
  1118. }
  1119. return RET_STATUS::RET_SUCCEED;
  1120. }
  1121. RET_STATUS nsGEN::DemoDevice::DecFluKV()
  1122. {
  1123. //mLog::Debug("Enter DecFluKV");
  1124. float KV = m_DoseUnit.m_FLKV->Get() - 1;
  1125. if (m_DoseUnit.m_FLKV->Update(KV))
  1126. {
  1127. FireNotify(m_DoseUnit.m_FLKV->GetKey(), m_DoseUnit.m_FLKV->JSGet());
  1128. }
  1129. return RET_STATUS::RET_SUCCEED;
  1130. }
  1131. RET_STATUS nsGEN::DemoDevice::SetFluKV(float value)
  1132. {
  1133. //mLog::Debug("Enter SetFluKV:[{$}]", value);
  1134. if (m_DoseUnit.m_FLKV->Update(value))
  1135. {
  1136. FireNotify(m_DoseUnit.m_FLKV->GetKey(), m_DoseUnit.m_FLKV->JSGet());
  1137. }
  1138. return RET_STATUS::RET_SUCCEED;
  1139. }
  1140. RET_STATUS nsGEN::DemoDevice::IncFluMA()
  1141. {
  1142. //mLog::Debug("Enter IncFluKV");
  1143. float MA = m_DoseUnit.m_FLMA->Get()+1;
  1144. if (m_DoseUnit.m_FLMA->Update(MA))
  1145. {
  1146. FireNotify(m_DoseUnit.m_FLMA->GetKey(), m_DoseUnit.m_FLMA->JSGet());
  1147. }
  1148. return RET_STATUS::RET_SUCCEED;
  1149. }
  1150. RET_STATUS nsGEN::DemoDevice::DecFluMA()
  1151. {
  1152. //mLog::Debug("Enter DecFluKV");
  1153. float MA = m_DoseUnit.m_FLMA->Get() - 1;
  1154. if (m_DoseUnit.m_FLMA->Update(MA))
  1155. {
  1156. FireNotify(m_DoseUnit.m_FLMA->GetKey(), m_DoseUnit.m_FLMA->JSGet());
  1157. }
  1158. return RET_STATUS::RET_SUCCEED;
  1159. }
  1160. RET_STATUS nsGEN::DemoDevice::SetFluMA(float value)
  1161. {
  1162. //mLog::Debug("Enter SetFluMA:[{$}]", value);
  1163. if (m_DoseUnit.m_FLMA->Update(value))
  1164. {
  1165. FireNotify(m_DoseUnit.m_FLMA->GetKey(), m_DoseUnit.m_FLMA->JSGet());
  1166. }
  1167. return RET_STATUS::RET_SUCCEED;
  1168. }
  1169. RET_STATUS nsGEN::DemoDevice::IncFluMS()
  1170. {
  1171. return RET_STATUS::RET_SUCCEED;
  1172. }
  1173. RET_STATUS nsGEN::DemoDevice::DecFluMS()
  1174. {
  1175. return RET_STATUS::RET_SUCCEED;
  1176. }
  1177. RET_STATUS nsGEN::DemoDevice::SetFluMS(float value)
  1178. {
  1179. return RET_STATUS::RET_SUCCEED;
  1180. }
  1181. RET_STATUS nsGEN::DemoDevice::SetPPS(float frameRate)
  1182. {
  1183. //mLog::Debug("Enter SetPPS:[{$}]", frameRate);
  1184. if (m_DoseUnit.m_PPS->Update(frameRate))
  1185. {
  1186. FireNotify(AttrKey::FLUPPS, m_DoseUnit.m_PPS->JSGet());
  1187. }
  1188. return RET_STATUS::RET_SUCCEED;
  1189. }
  1190. RET_STATUS nsGEN::DemoDevice::INCPPS()
  1191. {
  1192. //mLog::Debug("Enter INCPPS");
  1193. float PPS = m_DoseUnit.m_PPS->Get()+1;
  1194. if (m_DoseUnit.m_PPS->Update(PPS))
  1195. {
  1196. FireNotify(AttrKey::FLUPPS, m_DoseUnit.m_PPS->JSGet());
  1197. }
  1198. return RET_STATUS::RET_SUCCEED;
  1199. }
  1200. RET_STATUS nsGEN::DemoDevice::DECPPS()
  1201. {
  1202. //mLog::Debug("Enter DECPPS");
  1203. float PPS = m_DoseUnit.m_PPS->Get() - 1;
  1204. if (m_DoseUnit.m_PPS->Update(PPS))
  1205. {
  1206. FireNotify(AttrKey::FLUPPS, m_DoseUnit.m_PPS->JSGet());
  1207. }
  1208. return RET_STATUS::RET_SUCCEED;
  1209. }
  1210. RET_STATUS nsGEN::DemoDevice::SetPluseWidth(float fplusewidth)
  1211. {
  1212. return RET_STATUS::RET_SUCCEED;
  1213. }
  1214. RET_STATUS nsGEN::DemoDevice::SetABSMode(int nMode)
  1215. {
  1216. //mLog::Debug("Enter SetABSMode:[{$}]", nMode);
  1217. if (m_DoseUnit.m_ABSStatus->Update(nMode))
  1218. {
  1219. FireNotify(m_DoseUnit.m_ABSStatus->GetKey(), m_DoseUnit.m_ABSStatus->JSGet());
  1220. }
  1221. return RET_STATUS::RET_SUCCEED;
  1222. }
  1223. RET_STATUS nsGEN::DemoDevice::SetABSCurve(int curveNum)
  1224. {
  1225. return RET_STATUS::RET_SUCCEED;
  1226. }
  1227. RET_STATUS nsGEN::DemoDevice::IncABSCurve()
  1228. {
  1229. return RET_STATUS::RET_SUCCEED;
  1230. }
  1231. RET_STATUS nsGEN::DemoDevice::DecABSCurve()
  1232. {
  1233. return RET_STATUS::RET_SUCCEED;
  1234. }
  1235. RET_STATUS nsGEN::DemoDevice::SetABSValue(float fABSValue)
  1236. {
  1237. return RET_STATUS::RET_SUCCEED;
  1238. }
  1239. RET_STATUS nsGEN::DemoDevice::SetABSTargetEXI(float fEXIValue)
  1240. {
  1241. return RET_STATUS::RET_SUCCEED;
  1242. }
  1243. float nsGEN::DemoDevice::GetFluIntTimer()
  1244. {
  1245. return RET_STATUS::RET_SUCCEED;
  1246. }
  1247. float nsGEN::DemoDevice::GetFluAccTimer()
  1248. {
  1249. return RET_STATUS::RET_SUCCEED;
  1250. }
  1251. RET_STATUS nsGEN::DemoDevice::ResetFluTimer(int ntype)
  1252. {
  1253. //mLog::Debug("ReSetFluAccTimer:[{$}]", ntype);
  1254. return RET_STATUS::RET_SUCCEED;
  1255. }
  1256. RET_STATUS nsGEN::DemoDevice::SetFluPre(int bPrepare)
  1257. {
  1258. return RET_STATUS::RET_SUCCEED;
  1259. }
  1260. RET_STATUS nsGEN::DemoDevice::SetFluEXP(int bPrepare)
  1261. {
  1262. return RET_STATUS::RET_SUCCEED;
  1263. }
  1264. RET_STATUS nsGEN::DemoDevice::SetFLFMode(std::string value)
  1265. {
  1266. //mLog::Debug("Enter SetFLFMode:[{$}]", value.c_str());
  1267. if (value == "CF")
  1268. {
  1269. m_DoseUnit.m_FLMode->Update(AttrKey::GENERATOR_FLMODE_CF);
  1270. SetExpMode(AttrKey::EXPMODE_TYPE::CoutineSerial);
  1271. }
  1272. else if (value == "PF")
  1273. {
  1274. m_DoseUnit.m_FLMode->Update(AttrKey::GENERATOR_FLMODE_PF);
  1275. SetExpMode(AttrKey::EXPMODE_TYPE::PulseSerial);
  1276. }
  1277. FireNotify(AttrKey::FLUMode, m_DoseUnit.m_FLMode->JSGet());
  1278. return RET_STATUS::RET_SUCCEED;
  1279. }
  1280. RET_STATUS nsGEN::DemoDevice::SetFluMAG(int nsize)
  1281. {
  1282. return RET_STATUS::RET_SUCCEED;
  1283. }
  1284. RET_STATUS nsGEN::DemoDevice::DisableMAG()
  1285. {
  1286. return RET_STATUS::RET_SUCCEED;
  1287. }
  1288. RET_STATUS nsGEN::DemoDevice::SetFluDoseLever(int nlever)
  1289. {
  1290. //mLog::Debug("Enter SetFluDoseLever:[{$}]", nlever);
  1291. if (m_DoseUnit.m_DoseLevel->Update(nlever))
  1292. {
  1293. FireNotify(AttrKey::FLUDoseLevel, m_DoseUnit.m_DoseLevel->JSGet());
  1294. }
  1295. return RET_STATUS::RET_SUCCEED;
  1296. }
  1297. RET_STATUS nsGEN::DemoDevice::SetHalfDose(int nlever)
  1298. {
  1299. return RET_STATUS::RET_SUCCEED;
  1300. }
  1301. RET_STATUS nsGEN::DemoDevice::TransferRadCurve(int ncurve)
  1302. {
  1303. return RET_STATUS::RET_SUCCEED;
  1304. }
  1305. RET_STATUS nsGEN::DemoDevice::SetAPF(const _tAPFArgs& t)
  1306. {
  1307. //mLog::Debug("SetAPF: nWS={$}, Flu mode={$}, ABS mode={$}, DoseLever={$}, nFlkv={$}, FlMA={$}",
  1308. //t.nWS, t.nFluMode, t.nABSMode, t.nDoseLever, t.nFLKV, t.fFLMA, t.nPPS);
  1309. if (m_DoseUnit.m_FLKV->Update(t.nFLKV))
  1310. {
  1311. FireNotify(m_DoseUnit.m_FLKV->GetKey(), m_DoseUnit.m_FLKV->JSGet());
  1312. }
  1313. if (m_DoseUnit.m_FLMA->Update(t.fFLMA))
  1314. {
  1315. FireNotify(m_DoseUnit.m_FLMA->GetKey(), m_DoseUnit.m_FLMA->JSGet());
  1316. }
  1317. if (m_DoseUnit.m_PPS->Update(t.nPPS))
  1318. {
  1319. FireNotify(AttrKey::FLUPPS, m_DoseUnit.m_PPS->JSGet());
  1320. }
  1321. if (m_DoseUnit.m_DoseLevel->Update(t.nDoseLever))
  1322. {
  1323. FireNotify(AttrKey::FLUDoseLevel, m_DoseUnit.m_DoseLevel->JSGet());
  1324. }
  1325. if (m_DoseUnit.m_FLMode->Update(t.nFluMode))
  1326. {
  1327. FireNotify(AttrKey::FLUMode, m_DoseUnit.m_FLMode->JSGet());
  1328. }
  1329. if (m_DoseUnit.m_ABSStatus->Update(t.nABSMode))
  1330. {
  1331. FireNotify(m_DoseUnit.m_ABSStatus->GetKey(), m_DoseUnit.m_ABSStatus->JSGet());
  1332. }
  1333. return RET_STATUS::RET_SUCCEED;
  1334. }
  1335. //额外
  1336. void nsGEN::DemoDevice::FireNotify(string key, int context)
  1337. {
  1338. //std::unique_lock<std::mutex> uqeLock(m_MSGLock);
  1339. char szInfo[64] = { 0 };
  1340. sprintf(szInfo, "%d", context);
  1341. std::string str = szInfo;
  1342. EventCenter->OnNotify(1, key, str);//(int)ATTRACTION_SET 2
  1343. }
  1344. void nsGEN::DemoDevice::FireNotify(std::string key, float context)
  1345. {
  1346. //std::unique_lock<std::mutex> uqeLock(m_MSGLock);
  1347. char szInfo[64] = { 0 };
  1348. sprintf(szInfo, "%.2f", context);
  1349. std::string str = szInfo;
  1350. EventCenter->OnNotify(1, key, str);//(int)ATTRACTION_SET 2
  1351. }
  1352. void nsGEN::DemoDevice::FireNotify(std::string key, std::string context)
  1353. {
  1354. //std::unique_lock<std::mutex> uqeLock(m_MSGLock);
  1355. EventCenter->OnNotify(1, key, context);
  1356. }
  1357. int nsGEN::DemoDevice::GetConfData()
  1358. {
  1359. //灯丝大小
  1360. if (m_GenConfig.GetKeyCount(ConfKey::CcosTubeInfo) > 0)
  1361. {
  1362. string tempValue = m_GenConfig[ConfKey::CcosTubeInfo].encode();
  1363. m_DoseUnit.m_TubeInfo.reset(new TUBEINFOMould(tempValue));
  1364. }
  1365. if (m_GenConfig.GetKeyCount(ConfKey::CcosFocusSmall) > 0)
  1366. {
  1367. float tempValue = (float)m_GenConfig[ConfKey::CcosFocusSmall];
  1368. m_DoseUnit.m_FocusSmall = tempValue;
  1369. }
  1370. if (m_GenConfig.GetKeyCount(ConfKey::CcosFocusLarge) > 0)
  1371. {
  1372. float tempValue = (float)m_GenConfig[ConfKey::CcosFocusLarge];
  1373. m_DoseUnit.m_FocusLarge = tempValue;
  1374. }
  1375. //同步模式
  1376. if (m_GenConfig.GetKeyCount("WSTable") > 0)
  1377. {
  1378. int WSNamber = (int)m_GenConfig["WSTable"];
  1379. EnSYNMode WSSYN = (EnSYNMode)((int)m_GenConfig["SYNTable"]);
  1380. m_arrWSMap[cfgWorkStationKey("Table", AttrKey::TABLE)] = cfgWorkStationData("Table", WSNamber, WSSYN);
  1381. //mLog::Debug("cfg Table WS[{$}],SYN[{$}]", WSNamber, (int)WSSYN);
  1382. }
  1383. if (m_GenConfig.GetKeyCount("WSWall") > 0)
  1384. {
  1385. int WSNamber = (int)m_GenConfig["WSWall"];
  1386. EnSYNMode WSSYN = (EnSYNMode)((int)m_GenConfig["SYNWall"]);
  1387. m_arrWSMap[cfgWorkStationKey("Wall", AttrKey::WALL)] = cfgWorkStationData("Wall", WSNamber, WSSYN);
  1388. //mLog::Debug("cfg Wall WS[{$}],SYN[{$}]", WSNamber, (int)WSSYN);
  1389. }
  1390. if (m_GenConfig.GetKeyCount("WSFree") > 0)
  1391. {
  1392. int WSNamber = (int)m_GenConfig["WSFree"];
  1393. EnSYNMode WSSYN = (EnSYNMode)((int)m_GenConfig["SYNFree"]);
  1394. m_arrWSMap[cfgWorkStationKey("Free", AttrKey::MOBILE)] = cfgWorkStationData("Free", WSNamber, WSSYN);
  1395. //mLog::Debug("cfg Free WS[{$}],SYN[{$}]", WSNamber, (int)WSSYN);
  1396. }
  1397. if (m_GenConfig.GetKeyCount("WSTomo") > 0)
  1398. {
  1399. int WSNamber = (int)m_GenConfig["WSTomo"];
  1400. EnSYNMode WSSYN = (EnSYNMode)((int)m_GenConfig["SYNTomo"]);
  1401. m_arrWSMap[cfgWorkStationKey("Tomo", AttrKey::TOMO)] = cfgWorkStationData("Tomo", WSNamber, WSSYN);
  1402. //mLog::Debug("cfg Tomo WS[{$}],SYN[{$}]", WSNamber, (int)WSSYN);
  1403. }
  1404. if (m_GenConfig.GetKeyCount("WSConventional") > 0)
  1405. {
  1406. int WSNamber = (int)m_GenConfig["WSConventional"];
  1407. EnSYNMode WSSYN = (EnSYNMode)((int)m_GenConfig["SYNConventional"]);
  1408. m_arrWSMap[cfgWorkStationKey("Direct", AttrKey::CONVENTIONAL)] = cfgWorkStationData("Direct", WSNamber, WSSYN);
  1409. //mLog::Debug("cfg Conventional WS[{$}],SYN[{$}]", WSNamber, (int)WSSYN);
  1410. }
  1411. //参数初始化
  1412. ResDataObject temp;
  1413. temp.update("Max", 150);
  1414. temp.update("Min", 40);
  1415. temp.update("List", "");
  1416. for (int i = 0; i < sizeof(g_KV_List) / sizeof(g_KV_List[0]); i++)
  1417. {
  1418. char chindex[4] = { 0 };
  1419. sprintf(chindex, "%d", i);
  1420. temp["List"].add(chindex, g_KV_List[i] / 10.0f);
  1421. }
  1422. m_DoseUnit.m_KVList.reset(new KVLISTMould(temp.encode()));
  1423. temp.clear();
  1424. temp.update("Max", 1000);
  1425. temp.update("Min", 8);
  1426. temp.update("List", "");
  1427. for (int i = 0; i < sizeof(g_MAS_List) / sizeof(g_MAS_List[0]); i++)
  1428. {
  1429. char chindex[4] = { 0 };
  1430. sprintf(chindex, "%d", i);
  1431. temp["List"].add(chindex, g_MAS_List[i]);
  1432. }
  1433. m_DoseUnit.m_mAsList.reset(new MASLISTMould(temp.encode()));
  1434. //add by wxx for delworks:解决前端提出KV值太少的问题 20230913
  1435. FireNotify(m_DoseUnit.m_KVList->GetKey(), m_DoseUnit.m_KVList->JSGet());
  1436. return true;
  1437. }
  1438. void nsGEN::DemoDevice::FireErrorMessage(const bool Act, const int Code, const char* ResInfo)
  1439. {
  1440. string ErrorCode("Demo_ERR_");
  1441. ErrorCode += std::to_string(Code);
  1442. int level = Demo_REGULATION_LEVEL::REG_ERRO;
  1443. if (Act)
  1444. {
  1445. //mLog::Error("add {$}:{$}", ErrorCode.c_str(), ResInfo);
  1446. m_MSGUnit->AddErrorMessage(ErrorCode.c_str(), level, ResInfo);
  1447. }
  1448. else
  1449. {
  1450. //mLog::Error("del {$}:{$}", ErrorCode.c_str(), ResInfo);
  1451. if (Code == 0)
  1452. m_MSGUnit->DelErrorMessage("0", level, ResInfo);
  1453. else
  1454. m_MSGUnit->DelErrorMessage(ErrorCode.c_str(), level, ResInfo);
  1455. }
  1456. }
  1457. void nsGEN::DemoDevice::FireWarnMessage(const bool Act, const int Code, const char* ResInfo)
  1458. {
  1459. string ErrorCode("Demo_WAR_");
  1460. ErrorCode += std::to_string(Code);
  1461. int level = Demo_REGULATION_LEVEL::REG_WARN;
  1462. if (Act)
  1463. {
  1464. //mLog::Error("add {$}:{$}", ErrorCode.c_str(), ResInfo);
  1465. m_MSGUnit->AddWarnMessage(ErrorCode.c_str(), level, ResInfo);
  1466. }
  1467. else
  1468. {
  1469. //mLog::Error("del {$}:{$}", ErrorCode.c_str(), ResInfo);
  1470. m_MSGUnit->DelWarnMessage(ErrorCode.c_str(), level, ResInfo);
  1471. }
  1472. }
  1473. bool nsGEN::DemoDevice::StartHardwareStatusThread()
  1474. {
  1475. //mLog::Info("enter Start HardwareStatus Thread ");
  1476. if (m_pHardwareStatusThread == 0) // Linux使用0表示无效线程ID
  1477. {
  1478. // 创建线程属性对象(可选)
  1479. pthread_attr_t attr;
  1480. pthread_attr_init(&attr);
  1481. pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
  1482. // 创建线程
  1483. int ret = pthread_create(&m_pHardwareStatusThread,
  1484. &attr,
  1485. HardwareStatusThread,
  1486. this);
  1487. pthread_attr_destroy(&attr); // 销毁属性对象
  1488. if (ret != 0)
  1489. {
  1490. //mLog::Error("Start HardwareStatus Thread Failed");
  1491. return false;
  1492. }
  1493. }
  1494. return true;
  1495. }
  1496. void* nsGEN::DemoDevice::HardwareStatusThread(void* pParam)
  1497. {
  1498. DemoDevice* pCurGen = (DemoDevice*)pParam;
  1499. if (pCurGen == NULL)
  1500. {
  1501. return NULL;
  1502. }
  1503. usleep(1500000);
  1504. //mLog::Info("HardwareStatusThread start");
  1505. bool bActExpFlag = false;
  1506. //mLog::Info("m_iStateChangeInterval = {$},m_iAutoExpActWaitTime = {$}", pCurGen->m_iStateChangeInterval, pCurGen->m_iAutoExpActWaitTime);;
  1507. //mLog::Info("Request Fault Status:GENSTATE STATUS_SHUTDOWN -> STATUS_STANDBY");
  1508. pCurGen->m_DoseUnit.m_GenState->Update(nsGEN::AttrKey::GENERATOR_STATUS_STANDBY);
  1509. pCurGen->FireNotify(AttrKey::GENSTATE, pCurGen->m_DoseUnit.m_GenState->JSGet());
  1510. while (true)
  1511. {
  1512. while (!bActExpFlag)
  1513. {
  1514. ////mLog::Info("loopAction: begin \n");
  1515. if (pCurGen->m_iAutoExpFlag > 0)
  1516. {
  1517. pCurGen->m_iAutoExpFlag = 0;
  1518. usleep(pCurGen->m_iAutoExpActWaitTime*1000);
  1519. if (pCurGen->m_iAutoExpFlag == 0)
  1520. {
  1521. //mLog::Info("loopAction: start Exp Workflow \n");
  1522. bActExpFlag = true;
  1523. break;
  1524. }
  1525. else
  1526. {
  1527. //mLog::Info("loopAction: Exp param changed restart wait \n");
  1528. continue;
  1529. }
  1530. }
  1531. usleep(pCurGen->m_iAutoExpActWaitTime*1000);
  1532. }
  1533. while (bActExpFlag)
  1534. {
  1535. //mLog::Info("loopAction: act exp Workflow \n");
  1536. switch (pCurGen->m_DoseUnit.m_GenSynState->Get())
  1537. {
  1538. case nsGEN::AttrKey::GENERATOR_RAD_OFF:
  1539. {
  1540. //mLog::Info("exp Status change:RAD_OFF -> PREPARE(PR1)", pCurGen->m_DoseUnit.m_GenSynState->Get());
  1541. pCurGen->m_DoseUnit.m_GenSynState->Update(nsGEN::AttrKey::GENERATOR_RAD_PREPARE);
  1542. }break;
  1543. case nsGEN::AttrKey::GENERATOR_RAD_PREPARE:
  1544. {
  1545. //mLog::Info("exp Status change:PREPARE(PR1) -> RAD_READY(PR2)", pCurGen->m_DoseUnit.m_GenSynState->Get());
  1546. pCurGen->m_DoseUnit.m_GenSynState->Update(nsGEN::AttrKey::GENERATOR_RAD_READY);
  1547. }break;
  1548. case nsGEN::AttrKey::GENERATOR_RAD_READY:
  1549. {
  1550. //mLog::Info("exp Status change:RAD_READY(PR2) -> XRAYON(XR1)", pCurGen->m_DoseUnit.m_GenSynState->Get());
  1551. pCurGen->m_DoseUnit.m_GenSynState->Update(nsGEN::AttrKey::GENERATOR_RAD_XRAYON);
  1552. }break;
  1553. case nsGEN::AttrKey::GENERATOR_RAD_XRAYON:
  1554. {
  1555. //mLog::Info("exp Status change:XRAYON(XR1) -> XRAYOFF(XR0)", pCurGen->m_DoseUnit.m_GenSynState->Get());
  1556. pCurGen->m_DoseUnit.m_GenSynState->Update(nsGEN::AttrKey::GENERATOR_RAD_XRAYOFF);
  1557. //mLog::Debug("Request Fault Status:GENSTATE STATUS_STANDBY -> STATUS_EXP");
  1558. pCurGen->m_DoseUnit.m_GenState->Update(nsGEN::AttrKey::GENERATOR_STATUS_EXP);
  1559. pCurGen->FireNotify(AttrKey::GENSTATE, pCurGen->m_DoseUnit.m_GenState->JSGet());
  1560. //mLog::Info("exp Status value:POSTKV[{$}],POSTMA[{$}],POSTMS[{$}],POSTMAS[{$}]",
  1561. // pCurGen->m_DoseUnit.m_PostKV->Get(), pCurGen->m_DoseUnit.m_PostMA->Get(), pCurGen->m_DoseUnit.m_PostMS->Get(), pCurGen->m_DoseUnit.m_PostMAS->Get());
  1562. pCurGen->FireNotify(AttrKey::POSTKV, pCurGen->m_DoseUnit.m_PostKV->JSGet());
  1563. pCurGen->FireNotify(AttrKey::POSTMA, pCurGen->m_DoseUnit.m_PostMA->JSGet());
  1564. #if DEMO_DAEC_Flag
  1565. int temp = pCurGen->m_DoseUnit.m_PostMS->Get();
  1566. if (pCurGen->m_DoseUnit.m_Techmode->Get() == AttrKey::TECHMODE_TYPE::TECHMODE_AEC_3P ||
  1567. pCurGen->m_DoseUnit.m_Techmode->Get() == AttrKey::TECHMODE_TYPE::TECHMODE_AEC_2P ||
  1568. pCurGen->m_DoseUnit.m_Techmode->Get() == AttrKey::TECHMODE_TYPE::TECHMODE_AEC_1P)
  1569. {
  1570. temp /= 2;
  1571. }
  1572. pCurGen->FireNotify(AttrKey::POSTMS, temp);
  1573. #else
  1574. pCurGen->FireNotify(AttrKey::POSTMS, pCurGen->m_DoseUnit.m_PostMS->JSGet());
  1575. #endif // DEMO_DAEC_Flag
  1576. pCurGen->FireNotify(AttrKey::POSTMAS, pCurGen->m_DoseUnit.m_PostMAS->JSGet());
  1577. }break;
  1578. case nsGEN::AttrKey::GENERATOR_RAD_XRAYOFF:
  1579. {
  1580. //mLog::Info("exp Status change:XRAYOFF(XR0) -> RAD_OFF", pCurGen->m_DoseUnit.m_GenSynState->Get());
  1581. pCurGen->m_DoseUnit.m_GenSynState->Update(nsGEN::AttrKey::GENERATOR_RAD_OFF);
  1582. //mLog::Debug("Request Fault Status:GENSTATE STATUS_EXP -> STATUS_STANDBY");
  1583. pCurGen->m_DoseUnit.m_GenState->Update(nsGEN::AttrKey::GENERATOR_STATUS_STANDBY);
  1584. pCurGen->FireNotify(AttrKey::GENSTATE, pCurGen->m_DoseUnit.m_GenState->JSGet());
  1585. }
  1586. default:
  1587. {
  1588. bActExpFlag = false;
  1589. }
  1590. }
  1591. pCurGen->FireNotify(pCurGen->m_DoseUnit.m_GenSynState->GetKey(), pCurGen->m_DoseUnit.m_GenSynState->JSGet());
  1592. usleep(pCurGen->m_iStateChangeInterval*1000);
  1593. }
  1594. }
  1595. //mLog::Info("HardwareStatusThread stop");
  1596. return NULL;
  1597. }
  1598. //驱动
  1599. nsGEN::DemoDriver::DemoDriver()
  1600. {
  1601. m_bDemoMode = false;
  1602. m_bDemoConnected = false;
  1603. m_bDemoInitDataFlag = false;
  1604. m_pDriGenDev = nullptr;
  1605. //m_pDriCollDev = nullptr;
  1606. //m_pDriMechDev = nullptr;
  1607. m_pAttribute.reset(new ResDataObject());
  1608. m_pDescription.reset(new ResDataObject());
  1609. }
  1610. nsGEN::DemoDriver::~DemoDriver()
  1611. {
  1612. //if (m_pDriGenDev)
  1613. //{
  1614. // delete m_pDriGenDev;
  1615. // m_pDriGenDev = nullptr;
  1616. //}
  1617. //if (m_pDriCollDev)
  1618. //{
  1619. // delete m_pDriCollDev;
  1620. // m_pDriCollDev = nullptr;
  1621. //}
  1622. //if (m_pDriMechDev)
  1623. //{
  1624. // delete m_pDriMechDev;
  1625. // m_pDriMechDev = nullptr;
  1626. //}
  1627. //mLog::Close();
  1628. //mLog::gLogger = nullptr;
  1629. }
  1630. auto nsGEN::DemoDriver::CreateDevice(int index) -> std::unique_ptr <IODevice>
  1631. {
  1632. std::cout << "Enter CreateDevice, index=" << index<< std::endl;
  1633. //mLog::Info("Enter CreateDevice, index={$}", index);
  1634. if (index == 0)
  1635. {
  1636. m_pDriGenDev = new DemoDevice(EventCenter, m_ConfigFileName);
  1637. auto dev = std::unique_ptr<IODevice>(new IODevice(m_pDriGenDev));
  1638. return dev;
  1639. }
  1640. else if (index == 1)
  1641. {
  1642. std::cout << "Enter CreateDevice COLL" << std::endl;
  1643. //mLog::Info("Enter CreateDevice COLL");
  1644. if (m_bDemoInitDataFlag)
  1645. {
  1646. int nXSize = (atoi)(((string)m_InitDataFile["CONFIGURATION"]["XSize"]).c_str());
  1647. int nYSize = (atoi)(((string)m_InitDataFile["CONFIGURATION"]["YSize"]).c_str());
  1648. int nFilter = (atoi)(((string)m_InitDataFile["CONFIGURATION"]["Filter"]).c_str());
  1649. int nSID = (atoi)(((string)m_InitDataFile["CONFIGURATION"]["SID"]).c_str());
  1650. int nAngle = (atoi)(((string)m_InitDataFile["CONFIGURATION"]["Angle"]).c_str());
  1651. int nMode = (atoi)(((string)m_InitDataFile["CONFIGURATION"]["Mode"]).c_str());
  1652. m_pDriCollDev = new OemCollimator(std::shared_ptr<IOEventCenter>(new IOEventCenter()), nXSize, nYSize, nFilter, nSID, nAngle, nMode);
  1653. }
  1654. else
  1655. m_pDriCollDev = new OemCollimator(std::shared_ptr<IOEventCenter>(new IOEventCenter()));
  1656. auto dev = std::unique_ptr <IODevice>(new IODevice(m_pDriCollDev));
  1657. m_pDriCollDev->SetCtrlDev(m_pDriGenDev);
  1658. m_pDriGenDev->SetCollimatorDev(m_pDriCollDev);
  1659. //mLog::Info("Leave CreateDevice COLL");
  1660. return dev;
  1661. }
  1662. else if (index == 2)
  1663. {
  1664. std::cout << "Enter CreateDevice Mech" << std::endl;
  1665. //mLog::Info("Enter CreateDevice Mech");
  1666. if (m_bDemoInitDataFlag)
  1667. {
  1668. int nGrid = (atoi)(((string)m_InitDataFile["CONFIGURATION"]["Grid"]).c_str());
  1669. int nAE = (atoi)(((string)m_InitDataFile["CONFIGURATION"]["AE"]).c_str());
  1670. int nFT = (atoi)(((string)m_InitDataFile["CONFIGURATION"]["FT"]).c_str());
  1671. int nPressureState = (atoi)(((string)m_InitDataFile["CONFIGURATION"]["PressureState"]).c_str());
  1672. int nCompPressureDEC = (atoi)(((string)m_InitDataFile["CONFIGURATION"]["CompPressureDEC"]).c_str());
  1673. int nDepress = (atoi)(((string)m_InitDataFile["CONFIGURATION"]["Depress"]).c_str());
  1674. float fMechAngle = (atof)(((string)m_InitDataFile["CONFIGURATION"]["MechAngle"]).c_str());
  1675. float fMechHeight = (atof)(((string)m_InitDataFile["CONFIGURATION"]["MechHeight"]).c_str());
  1676. float fPressureValue = (atof)(((string)m_InitDataFile["CONFIGURATION"]["PressureValue"]).c_str());
  1677. float fAGD = (atof)(((string)m_InitDataFile["CONFIGURATION"]["AGD"]).c_str());
  1678. float fMAG = (atof)(((string)m_InitDataFile["CONFIGURATION"]["MAG"]).c_str());
  1679. m_pDriMechDev = new OemMechanical(std::shared_ptr<IOEventCenter>(new IOEventCenter()), nGrid, nAE, nFT, nPressureState, nCompPressureDEC, nDepress, fMechAngle, fMechHeight, fPressureValue, fAGD, fMAG);
  1680. }
  1681. else
  1682. m_pDriMechDev = new OemMechanical(std::shared_ptr<IOEventCenter>(new IOEventCenter()));
  1683. auto dev = std::unique_ptr <IODevice>(new IODevice(m_pDriMechDev));
  1684. m_pDriMechDev->SetCtrlDev(m_pDriGenDev);
  1685. m_pDriGenDev->SetMechDev(m_pDriMechDev);
  1686. //mLog::Info("Leave CreateDevice Mech");
  1687. return dev;
  1688. }
  1689. std::cout << "unknown index" << std::endl;
  1690. //mLog::Error("unknown index");
  1691. unique_ptr <IODevice> dev;
  1692. return dev;
  1693. }
  1694. void nsGEN::DemoDriver::FireNotify(int code, std::string key, std::string content)
  1695. {
  1696. EventCenter->OnNotify(code, key, content);
  1697. }
  1698. //Log4CPP::Logger* mLog::gLogger = nullptr;
  1699. void nsGEN::DemoDriver::Prepare()
  1700. {
  1701. //string strLogPath = GetProcessDirectory() + R"(\OEMDrivers\Generator\Conf\Log4CPP.Config.GEN.xml)";
  1702. //Log4CPP::GlobalContext::Map::Set(ECOM::Utility::Hash("LogFileName"), "GEN.Demo");
  1703. //auto rc = Log4CPP::LogManager::LoadConfigFile(strLogPath.c_str());
  1704. ////mLog::gLogger = Log4CPP::LogManager::GetLogger("GEN.Demo");
  1705. ResDataObject r_config;
  1706. if (r_config.loadFile(m_ConfigFileName.c_str()))
  1707. {
  1708. if(r_config["CONFIGURATION"].GetKeyCount("IsDemo")>0)
  1709. {
  1710. m_bDemoMode = (atoi)(((string)r_config["CONFIGURATION"]["IsDemo"]).c_str());
  1711. }
  1712. }
  1713. string strDataPath = GetProcessDirectory() + R"(\OEMDrivers\Generator\Demo\InitData.xml)";
  1714. try {
  1715. if (m_InitDataFile.loadFile(strDataPath.c_str()))
  1716. {
  1717. m_bDemoInitDataFlag = true;
  1718. //mLog::Info("exist InitData");
  1719. }
  1720. //else
  1721. //mLog::Info("can not open InitData[{$}]", strDataPath.c_str());
  1722. }
  1723. catch (const ResDataObjectExption&)
  1724. {
  1725. //mLog::Error("open InitData failed");
  1726. }
  1727. }
  1728. bool nsGEN::DemoDriver::Connect()
  1729. {
  1730. m_bDemoConnected = true;
  1731. return true; //return SCF_ERR::SCF_SUCCEED;
  1732. }
  1733. void nsGEN::DemoDriver::Disconnect()
  1734. {
  1735. //super::Disconnect();
  1736. //m_SCF.Disconnect();
  1737. m_bDemoConnected = false;
  1738. }
  1739. bool nsGEN::DemoDriver::isConnected() const
  1740. {
  1741. return m_bDemoConnected;
  1742. }
  1743. std::string nsGEN::DemoDriver::DriverProbe()
  1744. {
  1745. printf("line= %d,%s %s\n", __LINE__, __FUNCTION__, m_ConfigFileName.c_str());
  1746. ResDataObject r_config, HardwareInfo;
  1747. if (r_config.loadFile(m_ConfigFileName.c_str()))
  1748. {
  1749. HardwareInfo.add("MajorID", r_config["CONFIGURATION"]["MajorID"]);
  1750. HardwareInfo.add("MinorID", r_config["CONFIGURATION"]["MinorID"]);
  1751. HardwareInfo.add("VendorID", r_config["CONFIGURATION"]["VendorID"]);
  1752. HardwareInfo.add("ProductID", r_config["CONFIGURATION"]["ProductID"]);
  1753. HardwareInfo.add("SerialID", r_config["CONFIGURATION"]["SerialID"]);
  1754. }
  1755. else
  1756. {
  1757. HardwareInfo.add("MajorID", "Generator");
  1758. HardwareInfo.add("MinorID", "Dr");
  1759. HardwareInfo.add("VendorID", "DEMO");
  1760. HardwareInfo.add("ProductID", "HF");
  1761. HardwareInfo.add("SerialID", "1234");
  1762. }
  1763. string ret = HardwareInfo.encode();
  1764. printf("line= %d,%s %s\n", __LINE__, __FUNCTION__, m_ConfigFileName.c_str());
  1765. return ret;
  1766. }
  1767. bool nsGEN::DemoDriver::GetDeviceConfig(std::string& Cfg)
  1768. {
  1769. //printf("line= %d,%s\n", __LINE__, __FUNCTION__);
  1770. //Cfg = m_GenConfig.encode();
  1771. //return true;
  1772. Cfg = m_DeviceConfigSend.encode();
  1773. printf("GetDeviceConfig over , %s", Cfg.c_str());
  1774. return true;
  1775. }
  1776. bool nsGEN::DemoDriver::SetDeviceConfig(std::string Cfg)
  1777. {
  1778. //mLog::Info("--Func-- SetDeviceConfig {$}\n", Cfg.c_str());
  1779. printf("\n--Func-- SetDeviceConfig %s\n", Cfg.c_str());
  1780. ResDataObject DeviceConfig;
  1781. DeviceConfig.decode(Cfg.c_str());
  1782. ResDataObject DescriptionTempEx;
  1783. DescriptionTempEx = DeviceConfig["DeviceConfig"]["Attribute"];
  1784. //mLog::Debug("Attribute:{$}", DescriptionTempEx.encode());
  1785. bool bSaveFile = false; //true:重新保存配置文件
  1786. string strAccess = "";
  1787. for (int i = 0; i < DescriptionTempEx.size(); i++)
  1788. {
  1789. string strKey = DescriptionTempEx.GetKey(i);
  1790. //mLog::Info("{$}", strKey.c_str());
  1791. printf("%s\n", strKey.c_str());
  1792. try
  1793. {
  1794. if (m_pAttribute->GetFirstOf(strKey.c_str()) >= 0)
  1795. {
  1796. strAccess = (string)(*m_pDescription)[strKey.c_str()]["Access"];
  1797. if ("RW" == strAccess)
  1798. {
  1799. //修改对应配置,在其他单元的配置项要同时调用其修改函数修改真实值
  1800. //1. 修改内存中的值,用于给上层发消息
  1801. (*m_pAttribute)[strKey.c_str()] = DescriptionTempEx[i];
  1802. //2. 拿到Innerkey
  1803. int nConfigInfoCount = (int)m_Configurations["ConfigToolInfo"].GetKeyCount("AttributeInfo");
  1804. //mLog::Info("nConfigInfoCount {$}", nConfigInfoCount);
  1805. string strTemp = ""; //存储AttributeKey
  1806. for (int nInfoIndex = 0; nInfoIndex < nConfigInfoCount; nInfoIndex++)
  1807. {
  1808. strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeKey"];
  1809. if (strTemp == strKey)
  1810. {
  1811. strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["InnerKey"];
  1812. break;
  1813. }
  1814. }
  1815. //3. 修改配置文件中的值
  1816. if (SetDeviceConfigValue(m_Configurations, strTemp.c_str(), 1, DescriptionTempEx[i]))
  1817. {
  1818. //mLog::Debug("SetDeviceConfigValue over");
  1819. bSaveFile = true;
  1820. }
  1821. }
  1822. else
  1823. {
  1824. //mLog::Info("{$} is not a RW configuration item", strKey.c_str());
  1825. }
  1826. }
  1827. else
  1828. {
  1829. //mLog::Info("without this attribute {$}", strKey.c_str());
  1830. }
  1831. }
  1832. catch (ResDataObjectExption& e)
  1833. {
  1834. printf("\nSetDriverConfig crashed: %s\n", e.what());
  1835. //mLog::Error("SetDriverConfig crashed: {$}", e.what());
  1836. return false;
  1837. }
  1838. }
  1839. if (bSaveFile)
  1840. {
  1841. //3. 重新保存配置文件
  1842. SaveConfigFile(true);
  1843. }
  1844. return true;
  1845. }
  1846. bool nsGEN::DemoDriver::SaveConfigFile(bool bSendNotify)
  1847. {
  1848. m_ConfigAll["CONFIGURATION"] = m_Configurations;
  1849. bool bRt = m_ConfigAll.SaveFile(m_ConfigFileName.c_str());
  1850. //mLog::Info("SaveConfigFile over {$}", bRt);
  1851. return true;
  1852. }
  1853. bool nsGEN::DemoDriver::GetDeviceConfigValue(ResDataObject config, const char* pInnerKey, int nPathID, string& strValue)
  1854. {
  1855. strValue = "";
  1856. string strTemp = pInnerKey;
  1857. if (1 == nPathID) //从DriverConfig路径下每个DPC自己的配置文件读取
  1858. {
  1859. int pos = 0;
  1860. ResDataObject resTemp = config;
  1861. while ((pos = strTemp.find_first_of(',')) != string::npos)
  1862. {
  1863. string Key = strTemp.substr(0, pos);
  1864. string TempValue = resTemp[Key.c_str()].encode();
  1865. // printf("-TempValue=== %s", TempValue.c_str());
  1866. resTemp.clear();
  1867. resTemp.decode(TempValue.c_str());
  1868. strTemp = strTemp.substr(pos + 1, strTemp.length() - pos - 1);
  1869. //printf("-************--%s", strTemp.c_str());
  1870. }
  1871. if (strTemp != "")
  1872. {
  1873. strValue = (string)resTemp[strTemp.c_str()];
  1874. }
  1875. else
  1876. {
  1877. strValue = (string)resTemp;
  1878. }
  1879. }
  1880. //printf("------------%s", strValue.c_str());
  1881. return true;
  1882. }
  1883. bool nsGEN::DemoDriver::SetDeviceConfigValue(ResDataObject& config, const char* pInnerKey, int nPathID, const char* szValue)
  1884. {
  1885. string strTemp = pInnerKey;
  1886. //mLog::Debug("Begin to change {$} item value to {$}", pInnerKey, szValue);
  1887. printf("\n Begin to change {%s} item value to {%s}\n", pInnerKey, szValue);
  1888. if (1 == nPathID) //从DriverConfig路径下每个DPC自己的配置文件读取
  1889. {
  1890. try {
  1891. int pos = 0;
  1892. ResDataObject* resTemp = &config;
  1893. while ((pos = strTemp.find_first_of(',')) != string::npos)
  1894. {
  1895. string Key = strTemp.substr(0, pos);
  1896. resTemp = &(*resTemp)[Key.c_str()];
  1897. strTemp = strTemp.substr(pos + 1, strTemp.length() - pos - 1);
  1898. }
  1899. if (strTemp != "")
  1900. {
  1901. //if ((strTemp.compare("WSTable") == 0) ||
  1902. // (strTemp.compare("WSWall") == 0) ||
  1903. // (strTemp.compare("WSFree") == 0) ||
  1904. // (strTemp.compare("WSTomo") == 0) ||
  1905. // (strTemp.compare("WSConventional") == 0)
  1906. // )
  1907. //{
  1908. // int sum = (*szValue) + 1;
  1909. // (*resTemp)[strTemp.c_str()] = (char*)(&sum);
  1910. //}
  1911. //else
  1912. // (*resTemp)[strTemp.c_str()] = szValue;
  1913. (*resTemp)[strTemp.c_str()] = szValue;
  1914. }
  1915. else
  1916. {
  1917. *resTemp = szValue;
  1918. }
  1919. }
  1920. catch (ResDataObjectExption& e)
  1921. {
  1922. //mLog::Error("SetDriverConfigvalue crashed: {$}", e.what());
  1923. return false;
  1924. }
  1925. }
  1926. return true;
  1927. }
  1928. std::string nsGEN::DemoDriver::GetResource()
  1929. {
  1930. ResDataObject r_config, temp;
  1931. if (!temp.loadFile(m_ConfigFileName.c_str()))
  1932. {
  1933. return "";
  1934. }
  1935. m_ConfigAll = temp;
  1936. r_config = temp["CONFIGURATION"];
  1937. m_Configurations = r_config;
  1938. ResDataObject DescriptionTemp;
  1939. ResDataObject DescriptionSend;
  1940. ResDataObject m_DescriptionSend;
  1941. ResDataObject ListTemp;
  1942. string strTemp = ""; //用于读取字符串配置信息
  1943. string strIndex = ""; //用于读取配置信息中的List项
  1944. int nTemp = -1; //用于读取整型配置信息
  1945. char sstream[10] = { 0 }; //用于转换值
  1946. string strValue = ""; //用于存储配置的值
  1947. string strType = ""; //用于存储配置的类型 int/float/string...
  1948. /***
  1949. * 1. 通过循环,将所有配置项写到pDeviceConfig
  1950. * 2. 记录配置项的内部key以及配置类型,类型对应了不同配置文件路径,用于读写真实值
  1951. ***/
  1952. try
  1953. {
  1954. //便利ConfigToolInfo 中 所有的AttributeInfo 属性段
  1955. int nConfigInfoCount = (int)m_Configurations["ConfigToolInfo"].GetKeyCount("AttributeInfo");
  1956. m_pAttribute->clear();
  1957. m_pDescription->clear();
  1958. for (int nInfoIndex = 0; nInfoIndex < nConfigInfoCount; nInfoIndex++)
  1959. {
  1960. DescriptionTemp.clear();
  1961. DescriptionSend.clear();
  1962. ListTemp.clear();
  1963. //AttributeType
  1964. strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["Type"];
  1965. DescriptionTemp.add(ConfKey::CcosType, strTemp.c_str());//CcosGeneratorAttribute
  1966. DescriptionSend.add(ConfKey::CcosType, strTemp.c_str());//CcosGeneratorAttribute
  1967. strType = strTemp; //记录配置项的类型
  1968. //AttributeKey
  1969. //1. 根据AttributeType,内部key和配置路径,拿到当前的真实值
  1970. strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["InnerKey"];
  1971. nTemp = (int)m_Configurations["ConfigToolInfo"][nInfoIndex]["PathID"];
  1972. GetDeviceConfigValue(r_config, strTemp.c_str(), nTemp, strValue); //得到strValue的值
  1973. //printf("********************************innerkey=%s --strValue = %s\n", strTemp.c_str(), strValue.c_str());
  1974. //2. 赋值
  1975. strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeKey"];
  1976. if ("int" == strType)
  1977. {
  1978. (*m_pAttribute).add(strTemp.c_str(), atoi(strValue.c_str()));
  1979. }
  1980. else if ("float" == strType)
  1981. {
  1982. (*m_pAttribute).add(strTemp.c_str(), atoi(strValue.c_str()));
  1983. }
  1984. else //其它先按string类型处理
  1985. {
  1986. (*m_pAttribute).add(strTemp.c_str(), strValue.c_str());
  1987. }
  1988. //printf("********************************outkey =%s --strValue = %s\n", strTemp.c_str(), strValue.c_str());
  1989. //AttributeAccess
  1990. strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["Access"];
  1991. DescriptionTemp.add(ConfKey::CcosAccess, strTemp.c_str());
  1992. DescriptionSend.add(ConfKey::CcosAccess, strTemp.c_str());
  1993. /*
  1994. //AttributeRangeMin
  1995. strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["RangeMin"];
  1996. if (strTemp != "") //不需要的配置项为空
  1997. {
  1998. DescriptionTemp.add(ConfKey::CcosRangeMin, strTemp.c_str());
  1999. }
  2000. //AttributeRangeMax
  2001. strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["RangeMax"];
  2002. if (strTemp != "") //不需要的配置项为空
  2003. {
  2004. DescriptionTemp.add(ConfKey::CcosRangeMax, strTemp.c_str());
  2005. }
  2006. */
  2007. //AttributeList
  2008. nTemp = m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["ListNum"];
  2009. if (nTemp > 0) //ListNum不大于0时说明不需要list配置
  2010. {
  2011. for (int nListIndex = 0; nListIndex < nTemp; nListIndex++)
  2012. {
  2013. strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["ListInfo"][nListIndex];
  2014. auto temKey = std::to_string(nListIndex);
  2015. ListTemp.add(temKey.c_str(), strTemp.c_str());
  2016. }
  2017. DescriptionTemp.add(ConfKey::CcosList, ListTemp);
  2018. DescriptionSend.add(ConfKey::CcosList, ListTemp.encode());
  2019. }
  2020. //AttributeRequired
  2021. strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["Required"];
  2022. DescriptionTemp.add(ConfKey::CcosRequired, strTemp.c_str());
  2023. DescriptionSend.add(ConfKey::CcosRequired, strTemp.c_str());
  2024. //AttributeDefaultValue
  2025. strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["DefaultValue"];
  2026. if (strTemp != "") //不需要的配置项为空
  2027. {
  2028. DescriptionTemp.add(ConfKey::CcosDefaultValue, strTemp.c_str());
  2029. DescriptionSend.add(ConfKey::CcosDefaultValue, strTemp.c_str());
  2030. }
  2031. strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeKey"];
  2032. (*m_pDescription).add(strTemp.c_str(), DescriptionTemp);
  2033. m_DescriptionSend.add(strTemp.c_str(), DescriptionSend.encode());
  2034. }
  2035. }
  2036. catch (ResDataObjectExption& e)
  2037. {
  2038. //mLog::Error("Get config error: {$}", e.what());
  2039. return "";
  2040. }
  2041. ResDataObject resDeviceResource;
  2042. resDeviceResource.add(ConfKey::CcosGeneratorAttribute, (*m_pAttribute));
  2043. resDeviceResource.add(ConfKey::CcosGeneratorDescription, (*m_pDescription));
  2044. ResDataObject DescriptionTempEx;
  2045. DescriptionTempEx.add(ConfKey::CcosGeneratorConfig, resDeviceResource);
  2046. m_DeviceConfig.clear();
  2047. m_DeviceConfig = DescriptionTempEx;
  2048. ////mLog::Debug("local ************* get resource over {$}", DescriptionTempEx.encode());
  2049. //printf("local ************* get resource over %s \n", DescriptionTempEx.encode());
  2050. resDeviceResource.clear();
  2051. resDeviceResource.add(ConfKey::CcosGeneratorAttribute, (*m_pAttribute));
  2052. resDeviceResource.add(ConfKey::CcosGeneratorDescription, m_DescriptionSend);
  2053. DescriptionTempEx.clear();
  2054. DescriptionTempEx.add(ConfKey::CcosGeneratorConfig, resDeviceResource);
  2055. m_DeviceConfigSend.clear();
  2056. m_DeviceConfigSend = DescriptionTempEx;
  2057. string res = m_DeviceConfigSend.encode();
  2058. //printf("%s", res.c_str());
  2059. ////mLog::Debug("get resource over {$}", DescriptionTempEx.encode());
  2060. //printf("************* get resource over %s \n", DescriptionTempEx.encode());
  2061. return res;
  2062. }
  2063. std::string nsGEN::DemoDriver::DeviceProbe()
  2064. {
  2065. printf("line= %d,%s\n", __LINE__, __FUNCTION__);
  2066. ResDataObject r_config, HardwareInfo;
  2067. if (r_config.loadFile(m_ConfigFileName.c_str()))
  2068. {
  2069. HardwareInfo.add("MajorID", r_config["CONFIGURATION"]["MajorID"]);
  2070. HardwareInfo.add("MinorID", r_config["CONFIGURATION"]["MinorID"]);
  2071. HardwareInfo.add("VendorID", r_config["CONFIGURATION"]["VendorID"]);
  2072. HardwareInfo.add("ProductID", r_config["CONFIGURATION"]["ProductID"]);
  2073. HardwareInfo.add("SerialID", r_config["CONFIGURATION"]["SerialID"]);
  2074. }
  2075. else
  2076. {
  2077. HardwareInfo.add("MajorID", "Generator");
  2078. HardwareInfo.add("MinorID", "Dr");
  2079. HardwareInfo.add("VendorID", "DEMO");
  2080. HardwareInfo.add("ProductID", "HF");
  2081. HardwareInfo.add("SerialID", "1234");
  2082. }
  2083. string ret = HardwareInfo.encode();
  2084. return ret;
  2085. }
  2086. void nsGEN::DemoDriver::Dequeue(const char* Packet, DWORD Length)
  2087. {
  2088. //DecodeFrame(Packet, Length); //无真实数据,此处直接空.
  2089. }
  2090. //In Demo mode ,will not enter here
  2091. int nsGEN::DemoDriver::callbackPackageProcess(const char* RecData, DWORD nLength, DWORD& PacketLength)
  2092. {
  2093. return 0;
  2094. }
  2095. //-----------------------------------------------------------------------------
  2096. // GetIODriver & CreateIODriver
  2097. //-----------------------------------------------------------------------------
  2098. static nsGEN::DemoDriver gIODriver;
  2099. extern "C" CCOS::Dev::IODriver * GetIODriver() // 返回静态对象的引用, 调用者不能删除 !
  2100. {
  2101. return &gIODriver;
  2102. }
  2103. extern "C" CCOS::Dev::IODriver * CreateIODriver() // 返回新对象, 调用者必须自行删除此对象 !
  2104. {
  2105. return new nsGEN::DemoDriver();
  2106. }