DIOS.Dev.Generator.SINOmini.cpp 76 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505
  1. // CCOS.Dev.GEN.SINOmini.cpp : 定义 DLL 应用程序的导出函数。
  2. //
  3. #include "stdafx.h"
  4. #include <assert.h>
  5. #include <functional>
  6. using namespace std::placeholders;
  7. //#include "logger.temp.h"
  8. #include "CCOS.Dev.Generator.SINOmini.h"
  9. #include "Helper.JSON.hpp"
  10. using namespace CCOS::Dev::Detail::Generator;
  11. namespace nsGEN = CCOS::Dev::Detail::Generator;
  12. //关闭无关警告
  13. #pragma warning (disable:4244) // warning C4244: “初始化”: 从“double”转换到“float”,可能丢失数据
  14. #pragma warning (disable:4305) // warning C4305: “参数”: 从“double”到“float”截断
  15. #pragma warning (disable:4267) // warning C4267 : “初始化”: 从“size_t”转换到“int”,可能丢失数据
  16. #pragma warning (disable:4805) // warning C4805: “!=”: 在操作中将类型“bool”与类型“int”混合不安全
  17. //设置对应通信接口库
  18. #ifdef _WIN64
  19. #ifdef _DEBUG
  20. static const auto COM_SCFDllName = "Ccos.Dev.SerialSCFX64D.dll";
  21. #else
  22. static const auto COM_SCFDllName = "Ccos.Dev.SerialSCFX64.dll";
  23. #endif
  24. #endif
  25. #ifdef _WIN64
  26. #ifdef _DEBUG
  27. static const auto TCP_SCFDllName = "Ccos.Dev.TcpipSCFX64D.dll";
  28. #else
  29. static const auto TCP_SCFDllName = "Ccos.Dev.TcpipSCFX64.dll";
  30. #endif
  31. #endif
  32. /*
  33. #数据命令格式
  34. 字节编号 数据 数据含义 备注
  35. 1 STX 帧头 WS(程序)的帧头为:0xA5,MU(设备)的帧头为:0xCF
  36. 2 TYPE 数据类型 0x00: 主动发出的数据,0x01: 反馈数据,表示收到命令并反馈数据
  37. 3 ID 命令ID(CMD)
  38. 4 LEN 数据总长度(LEN)
  39. 5~n DATA… 参数数据
  40. n+1 CRC 异或取反校验(CRC)
  41. n+2 ETX 帧尾 WS的帧尾为:0x5A,MU的帧尾为:0xFC
  42. #应答命令格式
  43. 字节编号 数据 数据含义 备注
  44. 1 STX 帧头 WS的帧头为:0xA5,MU的帧头为:0xCF
  45. 2 TYPE 数据类型 0x02: 应答命令
  46. 3 ID 命令ID(CMD)
  47. 4 LEN 数据总长度(LEN)
  48. 5 Stauts 状态 0x00: 数据成功接收并设置, 0x01: 数据不正确,未成功设置
  49. 6 CRC 异或取反校验(CRC)
  50. 7 ETX 帧尾 WS的帧尾为:0x5A, MU的帧尾为:0xFC
  51. */
  52. //设置相关常量
  53. static const int msTimeOut_Lock = 500;
  54. Log4CPP::Logger* gLogger = nullptr;
  55. //指令操作关联结构
  56. struct tFrameMapping
  57. {
  58. static const int MaxLen = 5; //前缀不能超超过5个字符
  59. using cbFun = std::function <void(char*, int)>;
  60. char strHead[MaxLen];
  61. int NbOfCharOfHead;
  62. cbFun fun;
  63. tFrameMapping(char* str, int len, cbFun f)
  64. {
  65. assert(len < MaxLen); //len最大只能是4
  66. for (int i = 0; i < len; i++) //给strHead赋值
  67. strHead[i] = str[i];
  68. NbOfCharOfHead = len + 1;
  69. fun = f;
  70. }
  71. tFrameMapping(char str, cbFun f)
  72. {
  73. strHead[0] = str;
  74. NbOfCharOfHead = 1;
  75. fun = f;
  76. }
  77. };
  78. //响应操作对照表
  79. static std::list <tFrameMapping> arFrame;
  80. //生成命令校验和:多项式POLY 0x31,初始值INIT 0x00,结果亦或值XOROU 0x00,输入数据反转REFIN YES,输出数据反转REFOUT YES
  81. char crc8_MAXIM(char* data, int len)
  82. {
  83. uint8_t crc, i;
  84. crc = 0x00;
  85. while (len--)
  86. {
  87. crc ^= *data++;
  88. for (i = 0; i < 8; i++)
  89. {
  90. if (crc & 0x01)
  91. {
  92. crc = (crc >> 1) ^ 0x8c;
  93. }
  94. else crc >>= 1;
  95. }
  96. }
  97. return crc;
  98. }
  99. //查找响应操作对照表执行对应操作
  100. static bool DecodeFrame(const char* strFrame, int length)
  101. {
  102. auto pr = [strFrame, length](const tFrameMapping& Item)
  103. {
  104. FDEBUG("DecodeFrame[{$}][{$}]", (UINT8)strFrame[2], (UINT8)Item.strHead[0]);
  105. for (int i = 0; i < Item.NbOfCharOfHead; i++)
  106. {
  107. if ((UINT8)strFrame[i+1] != (UINT8)Item.strHead[i])
  108. {
  109. return false;
  110. }
  111. }
  112. return true;
  113. };
  114. auto found = std::find_if(arFrame.begin(), arFrame.end(), pr);//此处pr用来在arFrame中找到对于的包头
  115. if (found == arFrame.end())
  116. {
  117. return false;
  118. }
  119. const auto& Item = *found;
  120. auto pc = strFrame;
  121. char data[SINOmini_Com_NormalLen] = { 0 };
  122. //memcpy(data, strFrame + Item.NbOfCharOfHead + 3, length - Item.NbOfCharOfHead - 3);
  123. memcpy(data, strFrame, length);
  124. Item.fun(data, length - Item.NbOfCharOfHead);//第二个参数 不重要
  125. return true;
  126. }
  127. //-----------------------------------------------------------------------------
  128. // SINOminiDevice
  129. //-----------------------------------------------------------------------------
  130. int nsGEN::SINOminiDevice::m_iLoopTime = 1000;
  131. nsGEN::SINOminiDevice::SINOminiDevice(std::shared_ptr <IOEventCenter> center, nsSCF::SCF SCF, string configfile) : super(center, SCF)
  132. {
  133. assert(EventCenter);
  134. //其余属性初始化
  135. ResDataObject temp;
  136. temp.loadFile(configfile.c_str());
  137. m_GenConfig = temp["CONFIGURATION"];
  138. TransJsonText(m_GenConfig);
  139. m_pHardwareStatusThread = NULL;
  140. m_pAECProcessThread = NULL;
  141. m_AECFlag = false;
  142. m_bExpEnable = false;
  143. m_iHeartBeats = 0;
  144. m_bConnectFlag = true;
  145. m_pMechDev = nullptr;
  146. m_pCollDev = nullptr;
  147. string version;
  148. if(GetVersion(version,m_GenConfig))
  149. FINFO("\n===============log begin : version:{$} ===================\n", version.c_str());
  150. else
  151. FINFO("\n===============log begin : version:0.0.0.0 ===================\n");
  152. //设置发生器属性集合各个值的范围及精度
  153. m_DoseUnit.m_KV.reset(new KVMould(0.0, 20.0, 36, 1.0));
  154. m_DoseUnit.m_MA.reset(new MAMould(0, 0.0, 200.0, 0.1));
  155. m_DoseUnit.m_MS.reset(new MSMould(0, 20.0, 12000.0, 0.01));
  156. m_DoseUnit.m_MAS.reset(new MASMould(0.0, 0.0, 630.0, 1.0));
  157. m_DoseUnit.m_Techmode.reset(new TECHMODEMould(AttrKey::TECHMODE_TYPE::TECHMODE_NOAEC_2P, AttrKey::TECHMODE_NOAEC_3P, AttrKey::TECHMODE_AEC_2P, 1));
  158. m_DoseUnit.m_WS.reset(new WORKSTATIONMould(1, 0, 5, 1));
  159. m_DoseUnit.m_Focus.reset(new FOCUSMould(AttrKey::FOCUS_TYPE::FOCUS_SMALL, AttrKey::FOCUS_SMALL, AttrKey::FOCUS_LARGE, 1));
  160. m_DoseUnit.m_AECField.reset(new AECFIELDMould(0, 0, 111, 1));
  161. m_DoseUnit.m_AECFilm.reset(new AECFILMMould(0, 0, 2, 1));
  162. m_DoseUnit.m_AECDensity.reset(new AECDENSITYMould(7, -10, 10, 1));
  163. m_DoseUnit.m_HE.reset(new TUBEHEATMould(0, 0, 100, 1));
  164. m_DoseUnit.m_GenSynState.reset(new GENSYNSTATEMould(AttrKey::GENERATOR_RAD_OFF, AttrKey::GENERATOR_SYNC_ERR, AttrKey::GENERATOR_SYNC_MAX, 1));
  165. m_DoseUnit.m_GenState.reset(new GENSTATEMould(0, AttrKey::GENERATOR_STATUS_SHUTDOWN, AttrKey::GENERATOR_STATUS_MAX, 1));
  166. m_DoseUnit.m_GenTotalExpNumber.reset(new TOTALEXPNUMMould(0, 0, 9999, 1));
  167. m_DoseUnit.m_GenTotalAcqTimes.reset(new TOTALACQTIMESMould(0, 0, 9999, 1));
  168. m_DoseUnit.m_GenTubeCoolWaitTimes.reset(new TUBECOOLTIMEMould(0, 0, 9999, 1));
  169. m_DoseUnit.m_GenTubeOverLoadNumber.reset(new TUBEOVERLOADNUMMould(0, 0, 9999, 1));
  170. m_DoseUnit.m_GenCurrentExpNumber.reset(new CUREXPNUMMould(0, 0, 9999, 1));
  171. m_DoseUnit.m_ExpMode.reset(new EXPMODEMould(AttrKey::EXPMODE_TYPE::Single));
  172. m_DoseUnit.m_FrameRate.reset(new FRAMERATEMould(0, 0, 16, 1));
  173. m_DoseUnit.m_FLMode.reset(new FLUModeMould(AttrKey::GENERATOR_FLUMode::GENERATOR_FLMODE_NOTFLU));
  174. m_DoseUnit.m_BatteryChargeState.reset(new BATTERYCHARGSTATEMould(0, 0, 1, 1));
  175. //m_DoseUnit.m_EXAMMode.reset(new EXAMMODEMould(EXAMMODE_TYPE::MANUAL));
  176. //实际曝光参数值
  177. m_DoseUnit.m_PostKV.reset(new POSTKVMould(0.0, 0.0, 40.0, 1.0));
  178. m_DoseUnit.m_PostMA.reset(new POSTMAMould(0.0, 0.0, 200.0, 0.1));
  179. m_DoseUnit.m_PostMS.reset(new POSTMSMould(0.0, 20.0, 12000.0, 0.01));
  180. m_DoseUnit.m_PostMAS.reset(new POSTMASMould(0.0, 0.0, 600.0, 0.01));
  181. //发生器告警及错误消息
  182. m_MSGUnit.reset(new nsDetail::MSGUnit(center, nsGEN::GeneratorUnitType));
  183. //配置响应操作对照表 供发生器回传的数据触发相应的操作
  184. OnCallBack();
  185. //将发生器可以对外提供的指令注册集进行补充
  186. Register();
  187. //重置发生器
  188. Reset();
  189. Sleep(500);
  190. //以下进行默认设置,需要注意默认值是否正确
  191. //刷新数据
  192. RefreshData();
  193. //启动硬件转状态查询进程
  194. StartHardwareStatusThread();
  195. }
  196. nsGEN::SINOminiDevice::~SINOminiDevice()
  197. {
  198. FINFO("\n===============log end ===================\n");
  199. //ReleaseLogger();
  200. if (m_pHardwareStatusThread != NULL)
  201. {
  202. DWORD dwExitCode = 0;
  203. GetExitCodeThread(m_pHardwareStatusThread, &dwExitCode);
  204. if (STILL_ACTIVE != dwExitCode)
  205. {
  206. TerminateThread(m_pHardwareStatusThread, 0);
  207. }
  208. m_pHardwareStatusThread = NULL;
  209. }
  210. }
  211. std::string nsGEN::SINOminiDevice::GetGUID() const
  212. {
  213. FINFO("===============GetGUID : {$} ===================\n", GeneratorUnitType);
  214. return GeneratorUnitType;
  215. }
  216. void nsGEN::SINOminiDevice::Register()
  217. {
  218. auto Disp = &Dispatch;
  219. superGen::Register(Disp);
  220. superGen::RegisterRAD(Disp);
  221. superGen::RegisterAEC(Disp);
  222. superGen::RegisterExpEnable(Disp);
  223. superGen::RegisterGeneratortoSyncStatus(Disp);
  224. Disp->Get.Push(m_MSGUnit->GetKey().c_str(), [this](std::string& out) { out = m_MSGUnit->JSGet(); return RET_STATUS::RET_SUCCEED; });
  225. auto fun_Clear_DAP = [this](auto a, auto&)
  226. {
  227. return Clear_DAP();
  228. };
  229. Disp->Action.Push("Clear_DAP", fun_Clear_DAP);
  230. auto fun_GetValue_DAP = [this](auto a, auto& b)
  231. {
  232. float value = 0;
  233. RET_STATUS ret = GetValue_DAP(value);
  234. b = ToJSON(value);
  235. return ret;
  236. };
  237. Disp->Action.Push("GetValue_DAP", fun_GetValue_DAP);
  238. #if 0
  239. auto fun_StartMove = [this](auto a,auto& b)
  240. {
  241. return StartMove();
  242. };
  243. Disp->Action.Push("StartMove", fun_StartMove);
  244. auto fun_EndMove = [this](auto a, auto& b)
  245. {
  246. return EndMove();
  247. };
  248. Disp->Action.Push("EndMove", fun_EndMove);
  249. #endif // 0
  250. }
  251. RET_STATUS nsGEN::SINOminiDevice::SetAPRMaMmo(int nKV, float fMAS, int nFO, int nET, int nDensity, int nThickness, int nPress, int nFilter, int nSensor, int nGrid)
  252. {
  253. FDEBUG("SetAPRMaMmo:nKV[{$}],MAS[{$}],FO[{$}],ET[{$}],Density[{$}],Thickness[{$}],Press[{$}],Filter[{$}],Sensor[{$}],Grid[{$}] ", nKV, fMAS, nFO, nET, nDensity, nThickness, nPress, nFilter, nSensor, nGrid);
  254. SINOminiCommand strCmd(SINOmini_Parameter, EM_Param000);
  255. strCmd.SetAt(4, fMAS);
  256. strCmd.SetAt(5, nKV);
  257. strCmd.SetAt(6, nDensity);
  258. if (-1 == nThickness) //压迫厚度
  259. {
  260. if (m_pMechDev)
  261. {
  262. nThickness = m_pMechDev->GetMammo_Thickness();
  263. }
  264. else
  265. nThickness = 0;
  266. }
  267. strCmd.SetAt(8, nThickness);
  268. if (-1 == nPress) //压力值
  269. {
  270. if (m_pMechDev)
  271. {
  272. nPress = m_pMechDev->GetMammo_PressureValue();
  273. }
  274. else
  275. nPress = 0;
  276. }
  277. strCmd.SetAt(9, nPress);
  278. char cData10 = 0;
  279. cData10 = ((nSensor / 0x11) & 0x0F) << 4;
  280. if (nET == AttrKey::TECHMODE_TYPE::TECHMODE_NOAEC_3P ||
  281. nET == AttrKey::TECHMODE_TYPE::TECHMODE_AEC_3P) //曝光模式
  282. {
  283. FERROR("SetAPRMaMmo:can not set TECHMODE[{$}] \n", nET);
  284. }
  285. else
  286. {
  287. if (nET == AttrKey::TECHMODE_TYPE::TECHMODE_AEC_1P)
  288. {
  289. cData10 += (1) << 2;
  290. }
  291. else if (nET == AttrKey::TECHMODE_TYPE::TECHMODE_NOAEC_2P)
  292. {
  293. cData10 += (0) << 2;
  294. }
  295. else if (nET == AttrKey::TECHMODE_TYPE::TECHMODE_AEC_2P)
  296. {
  297. cData10 += (2) << 2;//应该是2,暂时改1
  298. }
  299. }
  300. if (-1 == nFilter) //滤线器
  301. {
  302. if (m_pMechDev)
  303. {
  304. nFilter = m_pMechDev->GetMammo_FT();
  305. }
  306. else
  307. nFilter = 0;
  308. }
  309. cData10 += (nFilter & 0x01) << 1;
  310. cData10 += nFO & 0x01;
  311. strCmd.SetAt(10, cData10);
  312. return HWSend(strCmd);
  313. }
  314. RET_STATUS nsGEN::SINOminiDevice::IncKV()
  315. {
  316. if (!m_DoseUnit.m_KV->CanInc()) return RET_STATUS::RET_SUCCEED;
  317. float oldKV= m_DoseUnit.m_KV->Get();
  318. oldKV++;
  319. FINFO("IncKV call SetAPRMaMmo \n");
  320. return SetAPRMaMmo(oldKV, m_DoseUnit.m_MAS->Get(), m_DoseUnit.m_Focus->Get(), m_DoseUnit.m_Techmode->Get(), m_DoseUnit.m_AECDensity->Get());
  321. }
  322. RET_STATUS nsGEN::SINOminiDevice::DecKV()
  323. {
  324. if (!m_DoseUnit.m_KV->CanDec()) return RET_STATUS::RET_SUCCEED;
  325. float oldKV = m_DoseUnit.m_KV->Get();
  326. oldKV--;
  327. FINFO("DecKV call SetAPRMaMmo \n");
  328. return SetAPRMaMmo(oldKV, m_DoseUnit.m_MAS->Get(), m_DoseUnit.m_Focus->Get(), m_DoseUnit.m_Techmode->Get(), m_DoseUnit.m_AECDensity->Get());
  329. }
  330. RET_STATUS nsGEN::SINOminiDevice::SetKV(float value)
  331. {
  332. if (!m_DoseUnit.m_KV->Verify(value)) return RET_STATUS::RET_SUCCEED;
  333. FINFO("SetKV call SetAPRMaMmo \n");
  334. return SetAPRMaMmo(value, m_DoseUnit.m_MAS->Get(), m_DoseUnit.m_Focus->Get(), m_DoseUnit.m_Techmode->Get(), m_DoseUnit.m_AECDensity->Get());
  335. }
  336. RET_STATUS nsGEN::SINOminiDevice::IncMAS()
  337. {
  338. if (!m_DoseUnit.m_MAS->CanInc()) return RET_STATUS::RET_SUCCEED;
  339. float oldMAS = m_DoseUnit.m_MAS->Get();
  340. oldMAS++;
  341. FINFO("IncMAS call SetAPRMaMmo \n");
  342. return SetAPRMaMmo(m_DoseUnit.m_KV->Get(), oldMAS, m_DoseUnit.m_Focus->Get(), m_DoseUnit.m_Techmode->Get(), m_DoseUnit.m_AECDensity->Get());
  343. }
  344. RET_STATUS nsGEN::SINOminiDevice::DecMAS()
  345. {
  346. if (!m_DoseUnit.m_MAS->CanDec()) return RET_STATUS::RET_SUCCEED;
  347. float oldMAS = m_DoseUnit.m_MAS->Get();
  348. oldMAS--;
  349. FINFO("DecMAS call SetAPRMaMmo \n");
  350. return SetAPRMaMmo(m_DoseUnit.m_KV->Get(), oldMAS, m_DoseUnit.m_Focus->Get(), m_DoseUnit.m_Techmode->Get(), m_DoseUnit.m_AECDensity->Get());
  351. }
  352. RET_STATUS nsGEN::SINOminiDevice::SetMAS(float value)
  353. {
  354. if (!m_DoseUnit.m_MAS->Verify(value))
  355. {
  356. if (m_DoseUnit.m_GenState->Get() == nsGEN::AttrKey::GENERATOR_STATUS_EXP)
  357. {
  358. value = 11;
  359. FDEBUG("SetMAS in AEC MAS is too small, use 11 \n");
  360. }
  361. else
  362. {
  363. FDEBUG("SetMAS in AEC MAS is too small \n");
  364. return RET_STATUS::RET_SUCCEED;
  365. }
  366. }
  367. FINFO("SetMAS call SetAPRMaMmo \n");
  368. #if 0 //wxx test for SINO AEC
  369. return SetAPRMaMmo(m_DoseUnit.m_KV->Get(), value, m_DoseUnit.m_Focus->Get(), m_DoseUnit.m_Techmode->Get(), m_DoseUnit.m_AECDensity->Get());
  370. #else
  371. if (m_DoseUnit.m_GenState->Get() == nsGEN::AttrKey::GENERATOR_STATUS_EXP)
  372. {
  373. char tempCMD[12] = { 0xf0,0x07,0x00,0x00,0x00,0x00,0x01,0x28,0x00,0x00,0xC6 };
  374. SINOminiCommand strCmd(tempCMD, 11);
  375. HWSend(strCmd);
  376. }
  377. else
  378. {
  379. return SetAPRMaMmo(m_DoseUnit.m_KV->Get(), value, m_DoseUnit.m_Focus->Get(), m_DoseUnit.m_Techmode->Get(), m_DoseUnit.m_AECDensity->Get());
  380. }
  381. #endif // 0
  382. }
  383. RET_STATUS nsGEN::SINOminiDevice::SetTechmode(int value)
  384. {
  385. if (!m_DoseUnit.m_Techmode->Verify(value)) return RET_STATUS::RET_SUCCEED;
  386. FINFO("SetTechmode [{$}] \n", value);
  387. if (value == AttrKey::TECHMODE_TYPE::TECHMODE_NOAEC_2P ||
  388. value == AttrKey::TECHMODE_TYPE::TECHMODE_AEC_2P ||
  389. value == AttrKey::TECHMODE_TYPE::TECHMODE_AEC_1P)
  390. {
  391. FINFO("SetTechmode call SetAPRMaMmo \n");
  392. return SetAPRMaMmo(m_DoseUnit.m_KV->Get(), m_DoseUnit.m_MAS->Get(), m_DoseUnit.m_Focus->Get(), value, m_DoseUnit.m_AECDensity->Get());
  393. }
  394. else
  395. {
  396. FERROR("SetTechmode:unknown mode[{$}] \n", value);
  397. }
  398. return RET_STATUS::RET_SUCCEED;
  399. }
  400. RET_STATUS nsGEN::SINOminiDevice::SetEXAMMode(std::string value)
  401. {
  402. //上层给我设置exam mode。(manual semi atuo)对应(NoAEC2Point AEC2Point AEC2Point)
  403. FINFO("Enter setexammode func value = {$}\n", value);
  404. if (value == AttrKey::EXAMMODE_TYPE::MANUAL)
  405. {
  406. if (m_DoseUnit.m_Techmode->Get() != AttrKey::TECHMODE_TYPE::TECHMODE_NOAEC_2P)
  407. {
  408. SetTechmode(1);
  409. }
  410. }
  411. else if (value == AttrKey::EXAMMODE_TYPE::SEMIAUTO)
  412. {
  413. if (m_DoseUnit.m_Techmode->Get() != AttrKey::TECHMODE_TYPE::TECHMODE_AEC_2P)
  414. {
  415. SetTechmode(3);
  416. }
  417. }
  418. else if (value == AttrKey::EXAMMODE_TYPE::AUTOMATIC)
  419. {
  420. if (m_DoseUnit.m_Techmode->Get() != AttrKey::TECHMODE_TYPE::TECHMODE_AEC_2P)
  421. {
  422. SetTechmode(3);
  423. }
  424. }
  425. return RET_STATUS::RET_SUCCEED;
  426. }
  427. RET_STATUS nsGEN::SINOminiDevice::SetFocus(int value)
  428. {
  429. if (!m_DoseUnit.m_Focus->Verify(value)) return RET_STATUS::RET_SUCCEED;
  430. FINFO("SetFocus call SetAPRMaMmo \n");
  431. return SetAPRMaMmo(m_DoseUnit.m_KV->Get(), m_DoseUnit.m_MAS->Get(), value, m_DoseUnit.m_Techmode->Get(), m_DoseUnit.m_AECDensity->Get());
  432. }
  433. RET_STATUS nsGEN::SINOminiDevice::SetAECDensity(int value)
  434. {
  435. if (!m_DoseUnit.m_AECDensity->Verify(value)) return RET_STATUS::RET_SUCCEED;
  436. #if 0
  437. if (m_DoseUnit.m_Techmode->Get() == AttrKey::TECHMODE_TYPE::TECHMODE_NOAEC_3P ||
  438. m_DoseUnit.m_Techmode->Get() == AttrKey::TECHMODE_TYPE::TECHMODE_NOAEC_2P)
  439. {
  440. FINFO("Techmode is not AEC, Cannot set Density \n");
  441. return RET_STATUS::RET_FAILED;
  442. }
  443. #endif // 0
  444. FINFO("SetAECDensity call SetAPRMaMmo \n");
  445. return SetAPRMaMmo(m_DoseUnit.m_KV->Get(), m_DoseUnit.m_MAS->Get(), m_DoseUnit.m_Focus->Get(), m_DoseUnit.m_Techmode->Get(), value);
  446. }
  447. RET_STATUS nsGEN::SINOminiDevice::SetAECField(int value) //发生器无此设置
  448. {
  449. if (!m_DoseUnit.m_AECField->Verify(value)) return RET_STATUS::RET_SUCCEED;
  450. #if 0
  451. if (m_DoseUnit.m_Techmode->Get() == AttrKey::TECHMODE_TYPE::TECHMODE_NOAEC_3P ||
  452. m_DoseUnit.m_Techmode->Get() == AttrKey::TECHMODE_TYPE::TECHMODE_NOAEC_2P)
  453. {
  454. FINFO("Techmode is not AEC, Cannot set Field \n");
  455. return RET_STATUS::RET_FAILED;
  456. }
  457. #endif // 0
  458. m_DoseUnit.m_AECField->Update(value);
  459. return RET_STATUS::RET_SUCCEED;
  460. }
  461. RET_STATUS nsGEN::SINOminiDevice::SetAECFilm(int value) //发生器无此设置
  462. {
  463. if (!m_DoseUnit.m_AECFilm->Verify(value)) return RET_STATUS::RET_SUCCEED;
  464. #if 0
  465. if (m_DoseUnit.m_Techmode->Get() == AttrKey::TECHMODE_TYPE::TECHMODE_NOAEC_3P ||
  466. m_DoseUnit.m_Techmode->Get() == AttrKey::TECHMODE_TYPE::TECHMODE_NOAEC_2P)
  467. {
  468. FINFO("Techmode is not AEC, Cannot set Film \n");
  469. return RET_STATUS::RET_FAILED;
  470. }
  471. #endif // 0
  472. m_DoseUnit.m_AECFilm->Update(value);
  473. return RET_STATUS::RET_SUCCEED;
  474. }
  475. RET_STATUS nsGEN::SINOminiDevice::SetWS(const string value) //发生器无此设置
  476. {
  477. FINFO("Enter SetWS {$}", value);
  478. int tempws = 0;
  479. if (value == "Table") tempws = (int)m_GenConfig["WSTable"];
  480. else if (value == "Wall") tempws = (int)m_GenConfig["WSWall"];
  481. else if (value == "Direct") tempws = (int)m_GenConfig["WSConventional"];
  482. else if (value == "Free") tempws = (int)m_GenConfig["WSFree"];
  483. else if (value == "Tomo") tempws = (int)m_GenConfig["WSTomo"];
  484. m_DoseUnit.m_WS->Update(tempws);
  485. return RET_STATUS::RET_SUCCEED;
  486. }
  487. RET_STATUS nsGEN::SINOminiDevice::SetAPR(const _tAPRArgs& t)
  488. {
  489. FINFO("APR:KV={$},MA={$},MS={$},MAS={$},Focus={$},Techmode={$},WS={$},AECDensity={$},AECField={$},AECFilm={$}",t.fKV, t.fMA, t.fMS, t.fMAS, t.nFocus, t.nTechmode, t.nWS, t.nAECDensity, t.nAECField, t.nAECFilm);
  490. if (!m_DoseUnit.m_KV->Verify(t.fKV))
  491. {
  492. FERROR("SetAPR:KV Out of bounds[{$}] \n", t.fKV);
  493. }
  494. else if (!m_DoseUnit.m_MA->Verify(t.fMA) && (m_DoseUnit.m_Techmode->Get() == AttrKey::TECHMODE_TYPE::TECHMODE_NOAEC_3P ||
  495. m_DoseUnit.m_Techmode->Get() == AttrKey::TECHMODE_TYPE::TECHMODE_AEC_3P))
  496. {
  497. FERROR("SetAPR:MA Out of bounds[{$}] \n", t.fMA);
  498. }
  499. else if (!m_DoseUnit.m_MS->Verify(t.fMS) && (m_DoseUnit.m_Techmode->Get() == AttrKey::TECHMODE_TYPE::TECHMODE_NOAEC_3P ||
  500. m_DoseUnit.m_Techmode->Get() == AttrKey::TECHMODE_TYPE::TECHMODE_AEC_3P))
  501. {
  502. FERROR("SetAPR:MS Out of bounds[{$}] \n", t.fMS);
  503. }
  504. else if (!m_DoseUnit.m_MAS->Verify(t.fMAS) && (m_DoseUnit.m_Techmode->Get() == AttrKey::TECHMODE_TYPE::TECHMODE_NOAEC_2P ||
  505. m_DoseUnit.m_Techmode->Get() == AttrKey::TECHMODE_TYPE::TECHMODE_AEC_2P))
  506. {
  507. FERROR("SetAPR:MAS Out of bounds[{$}] \n", t.fMAS);
  508. }
  509. else if (!m_DoseUnit.m_Focus->Verify(t.nFocus))
  510. {
  511. FERROR("SetAPR:Focus Out of bounds[{$}] \n", t.nFocus);
  512. }
  513. else
  514. {
  515. if (m_DoseUnit.m_Techmode->Get() == AttrKey::TECHMODE_TYPE::TECHMODE_AEC_2P || m_DoseUnit.m_Techmode->Get() == AttrKey::TECHMODE_TYPE::TECHMODE_AEC_1P)//wxx test for SINO AEC
  516. {
  517. #if 1
  518. if (m_DoseUnit.m_GenState->Get() == nsGEN::AttrKey::GENERATOR_STATUS_EXP)
  519. {
  520. FDEBUG("SetAPR call AEC Mean [296] \n");
  521. char tempCMD1[12] = { 0xf0,0x07,0x00,0x00,0x00,0x00,0x01,0x28,0x00,0x00,0xC6 };
  522. SINOminiCommand strCmd1(tempCMD1, 11);
  523. HWSend(strCmd1);
  524. FDEBUG("SetAPR call SyncTimestamp \n");
  525. char tempCMD2[12] = { 0xf0,0x04,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x8b };
  526. SINOminiCommand strCmd2(tempCMD2, 11);
  527. HWSend(strCmd2);
  528. FDEBUG("SetAPR call PlateAutoRelease Enable \n");
  529. char tempCMD3[12] = { 0xf0,0x2a,0x2e,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x81 };
  530. SINOminiCommand strCmd3(tempCMD3, 11);
  531. HWSend(strCmd3);
  532. }
  533. else
  534. #endif // 0
  535. {
  536. FDEBUG("SetAPR call fixed SetAPRMaMmo \n");
  537. char tempCMD[12] = { 0xf0,0x01,0x00,0x00,0x1c,0x0a,0x00,0x27,0x00,0xf8,0x00 };
  538. SINOminiCommand strCmd(tempCMD, 11);
  539. HWSend(strCmd);
  540. }
  541. }
  542. else
  543. {
  544. FINFO("SetAPR call SetAPRMaMmo \n");
  545. int nBreastThickness = 0;
  546. if (m_pMechDev)
  547. nBreastThickness = m_pMechDev->GetMammo_Thickness();
  548. float fPressure = 0;
  549. if (m_pMechDev)
  550. fPressure = m_pMechDev->GetMammo_PressureValue();
  551. SetAPRMaMmo(t.fKV, t.fMAS, t.nFocus, m_DoseUnit.m_Techmode->Get(), t.nAECDensity, nBreastThickness, fPressure);
  552. }
  553. }
  554. m_DoseUnit.m_WS->Update(t.nWS);
  555. SetAECField(t.nAECField);
  556. SetAECFilm(t.nAECFilm);
  557. return RET_STATUS::RET_SUCCEED;
  558. }
  559. RET_STATUS nsGEN::SINOminiDevice::QueryHE(int& value) //实际为主动上报
  560. {
  561. //value = m_DoseUnit.m_HE->Get();
  562. return RET_STATUS::RET_SUCCEED;
  563. }
  564. RET_STATUS nsGEN::SINOminiDevice::RefreshData()
  565. {
  566. FDEBUG("RefreshData: set System [init status] \n");
  567. SINOminiCommand strCmd(SINOmini_DevStatus, EM_DevStatus001);
  568. HWSend(strCmd);
  569. FDEBUG("RefreshData: set System [work mode] \n");
  570. SINOminiCommand strCmd2(SINOmini_WorkMode, 0x00);
  571. strCmd2.SetAt(3, 0x01);//PhotoMode
  572. strCmd2.SetAt(4, 0x01);//ImagingMode
  573. strCmd2.SetAt(5, 0x03);//AecMode
  574. strCmd2.SetAt(6, 0x01);//3dScanRange
  575. strCmd2.SetAt(7, 0x01);//3dSameAngle
  576. strCmd2.SetAt(8, 0x01);//FrameFrequency
  577. HWSend(strCmd2);
  578. return RET_STATUS::RET_SUCCEED;
  579. }
  580. RET_STATUS nsGEN::SINOminiDevice::SetExpEnable()
  581. {
  582. SINOminiCommand strCmd(SINOmini_DevStatus, EM_DevStatus003);
  583. HWSend(strCmd);
  584. SINOminiCommand strCmd2(SINOmini_RackAct, EM_RackACT055);
  585. strCmd.SetAt(10, 0x01);
  586. HWSend(strCmd2);
  587. return RET_STATUS::RET_SUCCEED;
  588. }
  589. RET_STATUS nsGEN::SINOminiDevice::SetExpDisable()
  590. {
  591. SINOminiCommand strCmd(SINOmini_DevStatus, EM_DevStatus004);
  592. HWSend(strCmd);
  593. SINOminiCommand strCmd2(SINOmini_RackAct, EM_RackACT055);
  594. strCmd.SetAt(10, 0x01);
  595. HWSend(strCmd2);
  596. return RET_STATUS::RET_SUCCEED;
  597. }
  598. RET_STATUS nsGEN::SINOminiDevice::QueryPostKV(float& value) //实际为主动上报
  599. {
  600. if (m_DoseUnit.m_PostKV->Get() > 0)
  601. {
  602. value = m_DoseUnit.m_PostKV->Get();
  603. }
  604. return RET_STATUS::RET_SUCCEED;
  605. }
  606. RET_STATUS nsGEN::SINOminiDevice::QueryPostMA(float& value) //实际为主动上报
  607. {
  608. if (m_DoseUnit.m_PostMA->Get() > 0)
  609. {
  610. value = m_DoseUnit.m_PostMA->Get();
  611. }
  612. return RET_STATUS::RET_SUCCEED;
  613. }
  614. RET_STATUS nsGEN::SINOminiDevice::QueryPostMS(float& value) //实际为主动上报
  615. {
  616. if (m_DoseUnit.m_PostMS->Get() > 0)
  617. {
  618. value = m_DoseUnit.m_PostMS->Get();
  619. }
  620. return RET_STATUS::RET_SUCCEED;
  621. }
  622. RET_STATUS nsGEN::SINOminiDevice::QueryPostMAS(float& value) //实际为主动上报
  623. {
  624. if (m_DoseUnit.m_PostMAS->Get() > 0)
  625. {
  626. value = m_DoseUnit.m_PostMAS->Get();
  627. }
  628. return RET_STATUS::RET_SUCCEED;
  629. }
  630. RET_STATUS nsGEN::SINOminiDevice::IncMA()
  631. {
  632. return RET_STATUS::RET_SUCCEED;
  633. }
  634. RET_STATUS nsGEN::SINOminiDevice::DecMA()
  635. {
  636. return RET_STATUS::RET_SUCCEED;
  637. }
  638. RET_STATUS nsGEN::SINOminiDevice::SetMA(float value)
  639. {
  640. return RET_STATUS::RET_SUCCEED;
  641. }
  642. RET_STATUS nsGEN::SINOminiDevice::IncMS()
  643. {
  644. return RET_STATUS::RET_SUCCEED;
  645. }
  646. RET_STATUS nsGEN::SINOminiDevice::DecMS()
  647. {
  648. return RET_STATUS::RET_SUCCEED;
  649. }
  650. RET_STATUS nsGEN::SINOminiDevice::SetMS(float value)
  651. {
  652. return RET_STATUS::RET_SUCCEED;
  653. }
  654. RET_STATUS nsGEN::SINOminiDevice::Clear_DAP() //发生器无此设置
  655. {
  656. return RET_STATUS::RET_SUCCEED;
  657. }
  658. RET_STATUS nsGEN::SINOminiDevice::GetValue_DAP(float& value) //发生器无此设置
  659. {
  660. //value = m_DAP->Get();
  661. return RET_STATUS::RET_SUCCEED;
  662. }
  663. RET_STATUS nsGEN::SINOminiDevice::StartMove() //发生器无此设置
  664. {
  665. return RET_STATUS::RET_SUCCEED;
  666. }
  667. RET_STATUS nsGEN::SINOminiDevice::EndMove() //发生器无此设置
  668. {
  669. return RET_STATUS::RET_SUCCEED;
  670. }
  671. RET_STATUS nsGEN::SINOminiDevice::SetGenSynState(int value) //在圣诺中用作AEC第二次曝光流程控制
  672. {
  673. FINFO("Enter SetGenSynState");
  674. if (m_AECFlag)
  675. {
  676. m_AECFlag = false;
  677. FINFO("SetGenSynState:Resolve AEC process too quickly");
  678. if (m_pAECProcessThread == NULL)
  679. {
  680. TerminateThread(m_pAECProcessThread, 0);
  681. m_pAECProcessThread = NULL;
  682. }
  683. DWORD m_HardwareStatusID;
  684. m_pAECProcessThread = CreateThread(0, 0, AECProcessThread, this, 0, &m_HardwareStatusID);
  685. if (m_pAECProcessThread == NULL)
  686. {
  687. FERROR("Start AECProcessThread Thread Failed");
  688. return RET_STATUS::RET_SUCCEED;;
  689. }
  690. }
  691. else
  692. {
  693. FINFO("SetGenSynState:RAD process do nothing");
  694. }
  695. return RET_STATUS::RET_SUCCEED;
  696. }
  697. DWORD nsGEN::SINOminiDevice::AECProcessThread(LPVOID pParam)
  698. {
  699. SINOminiDevice* pCurGen = (SINOminiDevice*)pParam;
  700. if (pCurGen == NULL)
  701. {
  702. return false;
  703. }
  704. FINFO("AECProcessThread start");
  705. FINFO("AECProcessThread send PR2");
  706. pCurGen->FireNotify(AttrKey::GENSYNSTATE, "2"); //PR2
  707. Sleep(2000);
  708. FINFO("AECProcessThread send XR1");
  709. pCurGen->FireNotify(AttrKey::GENSYNSTATE, "3"); //XR1Sleep(1000);
  710. Sleep(1000);
  711. FINFO("AECProcessThread send XR0");
  712. pCurGen->FireNotify(AttrKey::GENSYNSTATE, "4"); //XR0
  713. Sleep(1000);
  714. FINFO("AECProcessThread send PR0");
  715. pCurGen->FireNotify(AttrKey::GENSYNSTATE, "0"); //PR0
  716. FINFO("HardwareStatusThread stop");
  717. pCurGen->m_pAECProcessThread = NULL;
  718. return true;
  719. }
  720. RET_STATUS nsGEN::SINOminiDevice::SetGenState(int value) //发生器无此设置
  721. {
  722. return RET_STATUS::RET_SUCCEED;
  723. }
  724. RET_STATUS nsGEN::SINOminiDevice::SetExpMode(std::string value) //发生器无此设置
  725. {
  726. FINFO("Enter SetExpMode...{$} \n",value);
  727. m_DoseUnit.m_ExpMode->Update(value);
  728. return RET_STATUS::RET_SUCCEED;
  729. }
  730. RET_STATUS nsGEN::SINOminiDevice::SetFLFMode(std::string value) //发生器无此设置
  731. {
  732. return RET_STATUS::RET_SUCCEED;
  733. }
  734. RET_STATUS nsGEN::SINOminiDevice::SetFrameRate(FLOAT frameRate) //发生器无此设置
  735. {
  736. m_DoseUnit.m_FrameRate->Update(frameRate);
  737. return RET_STATUS::RET_SUCCEED;
  738. }
  739. RET_STATUS nsGEN::SINOminiDevice::SetRPS(int rps) //发生器无此设置
  740. {
  741. return RET_STATUS::RET_SUCCEED;
  742. }
  743. //为了将gen和其他设备关联,能相互调用接口
  744. RET_STATUS nsGEN::SINOminiDevice::SetGrid(int nGridType)
  745. {
  746. FDEBUG("Enter SetGrid[{$}]", nGridType);
  747. if (m_pMechDev)
  748. m_pMechDev->UpdateGrid(nGridType);
  749. return RET_STATUS::RET_SUCCEED;
  750. }
  751. RET_STATUS nsGEN::SINOminiDevice::SetFilter(int nFilterType)
  752. {
  753. /*if (m_pMechDev)
  754. {
  755. m_pMechDev->UpdateMammo_FT(nFilterType);
  756. }
  757. if (m_pCollDev)
  758. {
  759. m_pCollDev->UpdateCollimatorFilter(nFilterType);
  760. }*/
  761. #if 0
  762. FINFO("SetFilter call SetAPRMaMmo \n");
  763. return SetAPRMaMmo(m_DoseUnit.m_KV->Get(), m_DoseUnit.m_MAS->Get(), m_DoseUnit.m_Focus->Get(), m_DoseUnit.m_Techmode->Get()
  764. , m_DoseUnit.m_AECDensity->Get(), -1, -1, nFilterType);
  765. #else
  766. SINOminiCommand strCmd(SINOmini_RackAct, EM_RackACT050);
  767. strCmd.SetAt(5, nFilterType);
  768. strCmd.SetAt(10, 0x01);
  769. return HWSend(strCmd);
  770. #endif
  771. }
  772. RET_STATUS nsGEN::SINOminiDevice::SetAutoTracking(int nAutoTracking)
  773. {
  774. FDEBUG("Enter SetAutoTracking[{$}]", nAutoTracking);
  775. /*if (m_pMechDev)
  776. m_pMechDev->UpdateMammo_Depress(nAutoTracking);*/
  777. SINOminiCommand strCmd(SINOmini_RackAct, EM_RackACT046);
  778. strCmd.SetAt(5, nAutoTracking);
  779. strCmd.SetAt(10, 0x01);
  780. return HWSend(strCmd);
  781. }
  782. RET_STATUS nsGEN::SINOminiDevice::GetTomoResults(ResDataObject& resultAngle, ResDataObject& resultHeight)
  783. {
  784. FDEBUG("Enter GetTomoResults");
  785. return RET_STATUS::RET_SUCCEED;
  786. }
  787. RET_STATUS nsGEN::SINOminiDevice::SetMechDev(OemMechanical* dev)
  788. {
  789. if (dev)
  790. m_pMechDev.reset(dev);
  791. return RET_STATUS::RET_SUCCEED;
  792. }
  793. RET_STATUS nsGEN::SINOminiDevice::SetCollimatorDev(OemCollimator* dev)
  794. {
  795. if (dev)
  796. m_pCollDev.reset(dev);
  797. return RET_STATUS::RET_SUCCEED;
  798. }
  799. RET_STATUS nsGEN::SINOminiDevice::SetCollimatorSize(int xsize, int ysize)
  800. {
  801. if (m_pCollDev)
  802. {
  803. m_pCollDev->UpdateCollimatorXSize(xsize);
  804. m_pCollDev->UpdateCollimatorYSize(ysize);
  805. }
  806. return RET_STATUS::RET_SUCCEED;
  807. }
  808. RET_STATUS nsGEN::SINOminiDevice::SetCollimatorLight(WORD pParams)
  809. {
  810. //此处应该发送指令给GEN,并且该指令可以控制 coll 的LED
  811. return RET_STATUS::RET_SUCCEED;
  812. }
  813. RET_STATUS nsGEN::SINOminiDevice::Reset()
  814. {
  815. FDEBUG("clear all errors \n");
  816. int level = 0;
  817. m_MSGUnit->DelErrorMessage("0", level, "begin Rack homing");
  818. SINOminiCommand strCmd(SINOmini_RackAct, EM_RackACT045);
  819. strCmd.SetAt(5, 0x01);//AecMode
  820. strCmd.SetAt(10, 0x01);//3dScanRange
  821. HWSend(strCmd);
  822. SINOminiCommand strCmd2(SINOmini_DevStatus, EM_DevStatus003);
  823. return HWSend(strCmd2);
  824. }
  825. RET_STATUS nsGEN::SINOminiDevice::HWSend(SINOminiCommand& strCommand, int nTimeOut)
  826. {
  827. std::unique_lock<std::mutex> uqeConnectFlag(mtxConnectFlag);
  828. if (!m_bConnectFlag)
  829. {
  830. FERROR("==OUT==: not Connect,[{$}] send failed \n", strCommand.Get_Hex_Log());
  831. uqeConnectFlag.unlock();
  832. return RET_STATUS::RET_FAILED;
  833. }
  834. uqeConnectFlag.unlock();
  835. if (!m_SCF) return RET_STATUS::RET_FAILED;
  836. strCommand.SetCRC(crc8_MAXIM);
  837. FINFO("==OUT==: [{$}] \n", strCommand.Get_Hex_Log());
  838. int retLength;
  839. m_SCF.Lock(msTimeOut_Lock)
  840. .SendPacket(strCommand, SINOmini_Com_NormalLen-1, nTimeOut, retLength);
  841. Sleep(nTimeOut);
  842. return RET_STATUS::RET_SUCCEED;
  843. }
  844. //-----------------------------------------------------------------------------
  845. // ProcessCmd
  846. //-----------------------------------------------------------------------------
  847. void nsGEN::SINOminiDevice::FireNotify(std::string key, std::string content)
  848. {
  849. EventCenter->OnNotify(1, key, content);
  850. }
  851. void nsGEN::SINOminiDevice::FireErrorMessage(const bool Act, const int Code, const char* ResInfo)
  852. {
  853. char ErrorCode[20] = {0};
  854. sprintf_s(ErrorCode, "SINOmini_ERR_%03d", Code);
  855. int level = SINOmini_REGULATION_LEVEL::REG_ERRO;
  856. if (Act)
  857. {
  858. FERROR("add {$}:{$}", ErrorCode, ResInfo);
  859. m_MSGUnit->AddErrorMessage(ErrorCode, level, ResInfo);
  860. }
  861. else
  862. {
  863. FERROR("del {$}:{$}", ErrorCode, ResInfo);
  864. m_MSGUnit->DelErrorMessage(ErrorCode, level, ResInfo);
  865. }
  866. }
  867. void nsGEN::SINOminiDevice::FireWarnMessage(const bool Act, const int Code, const char* ResInfo)
  868. {
  869. char ErrorCode[20] = { 0 };
  870. sprintf_s(ErrorCode, "SINOmini_WAR_%03d", Code);
  871. int level = SINOmini_REGULATION_LEVEL::REG_WARN;
  872. if (Act)
  873. {
  874. FERROR("add {$}:{$}", ErrorCode, ResInfo);
  875. m_MSGUnit->AddWarnMessage(ErrorCode, level, ResInfo);
  876. }
  877. else
  878. {
  879. FERROR("del {$}:{$}", ErrorCode, ResInfo);
  880. m_MSGUnit->DelWarnMessage(ErrorCode, level, ResInfo);
  881. }
  882. }
  883. void nsGEN::SINOminiDevice::OnCallBack()
  884. {
  885. //无 操作
  886. auto HWNotProcess = [this](const char* value, int length) -> void
  887. {
  888. FINFO("\n This commands didn't need to process!");
  889. };
  890. //响应操作
  891. auto CallbackACK = [this](const char* value, int length) -> void
  892. {
  893. //根据现场圣诺系统日志,理应有个ACK
  894. };
  895. //命令模式:用于正常操作
  896. auto CallbackParameter = [this](const char* value, int length) -> void
  897. {
  898. if (m_DoseUnit.m_GenState->Get() != nsGEN::AttrKey::GENERATOR_STATUS_STANDBY)
  899. {
  900. FDEBUG("Request Status_1:GENSTATE {$} -> STATUS_STANDBY", m_DoseUnit.m_GenState->JSGet());
  901. m_DoseUnit.m_GenState->Update(nsGEN::AttrKey::GENERATOR_STATUS_STANDBY);
  902. FireNotify(AttrKey::GENSTATE, m_DoseUnit.m_GenState->JSGet());
  903. }
  904. int type = value[2];
  905. switch ((UINT8)type)
  906. {
  907. case EM_Param000:
  908. {
  909. SINOminiCommand ExposureParam(value, SINOmini_Com_NormalLen-1);
  910. //KV
  911. int nKV = ExposureParam.GetAt(5);
  912. FDEBUG("get CurrtSetKV [{$}]", nKV);
  913. m_DoseUnit.m_KV->Update(nKV);
  914. FireNotify(AttrKey::KV, m_DoseUnit.m_KV->JSGet());
  915. //MAS
  916. float fMAS = ExposureParam.GetAt(4);
  917. FDEBUG("get CurrtSetMAS [{$}]", fMAS);
  918. m_DoseUnit.m_MAS->Update(fMAS);
  919. FireNotify(AttrKey::MAS, m_DoseUnit.m_MAS->JSGet());
  920. //Focus
  921. int nFO = (ExposureParam.GetAt(10) & 0x01);
  922. FDEBUG("get CurrtSetFocus [{$}]", nFO);
  923. if (m_DoseUnit.m_Focus->Update(nFO))
  924. FireNotify(AttrKey::FOCUS, m_DoseUnit.m_Focus->JSGet());
  925. //Techmode
  926. int nET = (ExposureParam.GetAt(10) & 0x0C) >> 2;
  927. switch (nET)
  928. {
  929. case 0:
  930. FDEBUG("get CurrtSetTechmode [TECHMODE_NOAEC_2P]");
  931. nET = AttrKey::TECHMODE_TYPE::TECHMODE_NOAEC_2P;
  932. if (m_DoseUnit.m_Techmode->Update(AttrKey::TECHMODE_TYPE::TECHMODE_NOAEC_2P))
  933. FireNotify(AttrKey::TECHMODE, m_DoseUnit.m_Techmode->JSGet());
  934. break;
  935. case 1:
  936. FDEBUG("get CurrtSetTechmode [TECHMODE_AEC_1P]");
  937. nET = AttrKey::TECHMODE_TYPE::TECHMODE_AEC_1P;
  938. if (m_DoseUnit.m_Techmode->Update(AttrKey::TECHMODE_TYPE::TECHMODE_AEC_1P))
  939. FireNotify(AttrKey::TECHMODE, m_DoseUnit.m_Techmode->JSGet());
  940. break;
  941. case 2:
  942. {
  943. FDEBUG("get CurrtSetTechmode [TECHMODE_AEC_2P]");
  944. nET = AttrKey::TECHMODE_TYPE::TECHMODE_AEC_2P;
  945. if (m_DoseUnit.m_Techmode->Update(AttrKey::TECHMODE_TYPE::TECHMODE_AEC_2P))
  946. FireNotify(AttrKey::TECHMODE, m_DoseUnit.m_Techmode->JSGet());
  947. }
  948. break;
  949. default:
  950. FERROR("==CallbackParameter==: Get other Techmode value!");
  951. break;
  952. }
  953. //AECDensity
  954. int nDensity = ExposureParam.GetAt(6);
  955. FDEBUG("get CurrtSetDensity [{$}]", nDensity);
  956. if (m_DoseUnit.m_AECDensity->Update(nDensity))
  957. FireNotify(AttrKey::AECDENSITY, m_DoseUnit.m_AECDensity->JSGet());
  958. #if 0
  959. //BreastThickness
  960. int nBreastThickness = ExposureParam.GetAt(8);
  961. if (m_pMechDev)
  962. m_pMechDev->UpdateMammo_Thickness(nBreastThickness);
  963. //pressure
  964. float fPressure = ExposureParam.GetAt(9);
  965. if (m_pMechDev)
  966. m_pMechDev->UpdateMammo_PressureValue(fPressure);
  967. #else
  968. int nBreastThickness = 0;
  969. float fPressure = 0;
  970. #endif
  971. //Filter
  972. int nFilter = (ExposureParam.GetAt(10) & 0x0C) >> 1;
  973. if (m_pMechDev)
  974. m_pMechDev->UpdateMammo_FT(nFilter);
  975. //AGD
  976. #if 1
  977. float fAGD = 1;
  978. #else
  979. float fAGD = ExposureParam.GetAt();
  980. if (m_pMechDev)
  981. {
  982. m_pMechDev->UpdateMammo_AGD(fAGD);
  983. }
  984. #endif // 0
  985. FDEBUG("==CallbackParameter==: KV:[{$}],MAS:[{$}],FO:[{$}],Techmode:[{$}],AGD:[{$}],Filter:[{$}],Thickness:[{$}],Pressure:[{$}]",
  986. nKV, fMAS, nFO, nET, fAGD, nFilter, nBreastThickness, fPressure);
  987. break;
  988. }
  989. case EM_Param001:
  990. {
  991. FDEBUG("can not deal with Param001");
  992. break;
  993. }
  994. case EM_Param002:
  995. {
  996. FDEBUG("can not deal with Param002");
  997. break;
  998. }
  999. default:
  1000. FERROR("==CallbackParameter==: unknown Param type value!");
  1001. break;
  1002. }
  1003. };
  1004. auto CallbackWarningInfo = [this](const char* value, int length) -> void
  1005. {
  1006. SINOminiCommand SystemWarn(value, SINOmini_Com_NormalLen - 1);
  1007. UINT8 nCode = SystemWarn.GetAt(3);
  1008. FDEBUG("==CallbackWarningInfo==: Gen system Wraning: [{$:x}]", nCode);
  1009. switch ((UINT8)nCode)
  1010. {
  1011. case (UINT8)EM_Warn001: //开机高压错误
  1012. {
  1013. FireErrorMessage(true, nCode, "Power on high voltage error");
  1014. break;
  1015. }
  1016. case (UINT8)EM_Warn002: //曝光控制板运行时高压错误
  1017. {
  1018. FireErrorMessage(true, nCode, "High voltage error during of exp_ctrl board");
  1019. break;
  1020. }
  1021. case (UINT8)EM_Warn003: //开机时灯丝错误
  1022. {
  1023. FireErrorMessage(true, nCode, "Filament error during startup");
  1024. break;
  1025. }
  1026. case (UINT8)EM_Warn004: //曝光时灯丝错误
  1027. {
  1028. FireErrorMessage(true, nCode, "Filament error during exposure");
  1029. break;
  1030. }
  1031. case (UINT8)EM_Warn005: //曝光板读存储器错误
  1032. {
  1033. FireErrorMessage(true, nCode, "Exposure board read memory error");
  1034. break;
  1035. }
  1036. case (UINT8)EM_Warn006: //球管过温保护错误
  1037. {
  1038. FireWarnMessage(true, nCode, "Ball tube over temperature protection error");
  1039. break;
  1040. }
  1041. case (UINT8)EM_Warn007: //球管运行绕阻线断开错误
  1042. {
  1043. FireErrorMessage(true, nCode, "Error in the winding wire during tube operation");
  1044. break;
  1045. }
  1046. case (UINT8)EM_Warn008: //阳极启动信号异常
  1047. {
  1048. FireErrorMessage(true, nCode, "Anode start signal abnormality");
  1049. break;
  1050. }
  1051. case (UINT8)EM_Warn011: //曝光时高压电源未产生高压
  1052. {
  1053. FireWarnMessage(true, nCode, "The high-voltage power not supply during exp");
  1054. break;
  1055. }
  1056. case (UINT8)EM_Warn228:
  1057. {
  1058. FireWarnMessage(false, EM_Warn011, "del EM_Warn011");
  1059. break;
  1060. }
  1061. case (UINT8)EM_Warn013: //球管打火计数错误
  1062. {
  1063. FireErrorMessage(true, nCode, "Ball tube firing count error");
  1064. break;
  1065. }
  1066. case (UINT8)EM_Warn014: //手闸激活没有及时释放
  1067. {
  1068. FireWarnMessage(true, nCode, "The handswitch was not released in a timely manner");
  1069. break;
  1070. }
  1071. case (UINT8)EM_Warn233:
  1072. {
  1073. FireWarnMessage(false, EM_Warn014, "del EM_Warn014");
  1074. break;
  1075. }
  1076. case (UINT8)EM_Warn015: //曝光时提前松开手闸错误
  1077. {
  1078. FireWarnMessage(true, nCode, "Error releasing handswitch during exposure");
  1079. break;
  1080. }
  1081. case (UINT8)EM_Warn234:
  1082. {
  1083. FireWarnMessage(false, EM_Warn015, "del EM_Warn015");
  1084. break;
  1085. }
  1086. case (UINT8)EM_Warn016: //自动测试模式时,没有插短接头错误
  1087. {
  1088. FireWarnMessage(true, nCode, "there is no short When in automatic testing mode");
  1089. break;
  1090. }
  1091. case (UINT8)EM_Warn227:
  1092. {
  1093. FireWarnMessage(false, EM_Warn016, "del EM_Warn016");
  1094. break;
  1095. }
  1096. case (UINT8)EM_Warn017: //曝光时管电流过高错误
  1097. {
  1098. FireErrorMessage(true, nCode, "Tube current too high during exposure error");
  1099. break;
  1100. }
  1101. case (UINT8)EM_Warn018: //曝光时管电流过低错误
  1102. {
  1103. FireErrorMessage(true, nCode, "Low tube current error during exposure");
  1104. break;
  1105. }
  1106. case (UINT8)EM_Warn019: //灯丝板输入功率不正常
  1107. {
  1108. FireErrorMessage(true, nCode, "Abnormal input power of filament board");
  1109. break;
  1110. }
  1111. case (UINT8)EM_Warn020: //探测器反馈错误
  1112. {
  1113. FireErrorMessage(true, nCode, "Detector feedback error");
  1114. break;
  1115. }
  1116. case (UINT8)EM_Warn021: //曝光时滤线栅抖动错误
  1117. {
  1118. FireErrorMessage(true, nCode, "Filter grid jitter error during exposure");
  1119. break;
  1120. }
  1121. case (UINT8)EM_Warn025: //急停开关按下
  1122. {
  1123. FireWarnMessage(true, nCode, "Emergency stop switch pressed");
  1124. break;
  1125. }
  1126. case (UINT8)EM_Warn024:
  1127. {
  1128. FireWarnMessage(false, EM_Warn025, "del EM_Warn025");
  1129. break;
  1130. }
  1131. case (UINT8)EM_Warn027: //二次限位开关按下
  1132. {
  1133. FireWarnMessage(true, nCode, "Secondary limit switch pressed");
  1134. break;
  1135. }
  1136. case (UINT8)EM_Warn026:
  1137. {
  1138. FireWarnMessage(false, EM_Warn027, "del EM_Warn027");
  1139. break;
  1140. }
  1141. case (UINT8)EM_Warn029: //在AEC模式下,压迫器压力小于30N不可以曝光
  1142. {
  1143. FireWarnMessage(true, nCode, "In AEC mode, the comp_pressure is less than 30N");
  1144. break;
  1145. }
  1146. case (UINT8)EM_Warn028:
  1147. {
  1148. FireWarnMessage(false, EM_Warn029, "del EM_Warn029");
  1149. break;
  1150. }
  1151. case (UINT8)EM_Warn031: //系统在运动中
  1152. {
  1153. FireWarnMessage(true, nCode, "The system is in motion");
  1154. FireWarnMessage(false, EM_Warn006, "del EM_Warn006");
  1155. break;
  1156. }
  1157. case (UINT8)EM_Warn030:
  1158. {
  1159. FireWarnMessage(false, EM_Warn031, "del EM_Warn031");
  1160. break;
  1161. }
  1162. case (UINT8)EM_Warn033: //屏蔽门打开
  1163. {
  1164. FireWarnMessage(true, nCode, "Platform screen door open");
  1165. break;
  1166. }
  1167. case (UINT8)EM_Warn032:
  1168. {
  1169. FireWarnMessage(false, EM_Warn033, "del EM_Warn033");
  1170. SINOminiCommand strCmd2(SINOmini_DevStatus, EM_DevStatus003);
  1171. HWSend(strCmd2);
  1172. break;
  1173. }
  1174. case (UINT8)EM_Warn035: //校准开关已打开
  1175. {
  1176. FireWarnMessage(true, nCode, "Calibration switch turned on");
  1177. break;
  1178. }
  1179. case (UINT8)EM_Warn034:
  1180. {
  1181. FireWarnMessage(false, EM_Warn035, "del EM_Warn035");
  1182. break;
  1183. }
  1184. case (UINT8)EM_Warn037: //压迫器释放按钮在开机时按下错误
  1185. {
  1186. FireWarnMessage(true, nCode, "Compressor release button during startup");
  1187. break;
  1188. }
  1189. case (UINT8)EM_Warn036:
  1190. {
  1191. FireWarnMessage(false, EM_Warn037, "del EM_Warn037");
  1192. break;
  1193. }
  1194. case (UINT8)EM_Warn048: //C臂旋转方向控制引脚失效
  1195. {
  1196. FireErrorMessage(true, nCode, "C-arm rotation direction control pin failure");
  1197. break;
  1198. }
  1199. case (UINT8)EM_Warn049: //压迫器升降方向控制引脚失效
  1200. {
  1201. FireErrorMessage(true, nCode, "Compressor lifting direction control pin failure");
  1202. break;
  1203. }
  1204. case (UINT8)EM_Warn050: //系统自检未完成时脚踏开关被踩下
  1205. {
  1206. FireWarnMessage(true, nCode, "The foot switch is down when system self-test");
  1207. break;
  1208. }
  1209. case (UINT8)EM_Warn237:
  1210. {
  1211. FireWarnMessage(false, EM_Warn050, "del EM_Warn050");
  1212. break;
  1213. }
  1214. case (UINT8)EM_Warn051: //系统自检未完成时C臂旋转或升降按键被按下
  1215. {
  1216. FireWarnMessage(true, nCode, "The C-arm rotation is pressed when system self-test");
  1217. break;
  1218. }
  1219. case (UINT8)EM_Warn238:
  1220. {
  1221. FireWarnMessage(false, EM_Warn051, "del EM_Warn051");
  1222. break;
  1223. }
  1224. case (UINT8)EM_Warn052: //运动控制板自检未通过错误
  1225. {
  1226. FireErrorMessage(true, nCode, "Motion control board self test failed error");
  1227. break;
  1228. }
  1229. case (UINT8)EM_Warn053: //滤线栅控制电路错误
  1230. {
  1231. FireErrorMessage(true, nCode, "Filter grid control circuit error");
  1232. break;
  1233. }
  1234. case (UINT8)EM_Warn054: //急停开关按下时运动控制键被按下
  1235. {
  1236. FireWarnMessage(true, nCode, "The move_Control pressed when emergency stop switch is pressed");
  1237. break;
  1238. }
  1239. case (UINT8)EM_Warn241:
  1240. {
  1241. FireWarnMessage(false, EM_Warn054, "del EM_Warn054");
  1242. break;
  1243. }
  1244. case (UINT8)EM_Warn055: //滤片切换超时错误
  1245. {
  1246. FireErrorMessage(true, nCode, "Filter switching timeout error");
  1247. break;
  1248. }
  1249. case (UINT8)EM_Warn056: //运动板SysTick时钟初始化不通过错误
  1250. {
  1251. FireErrorMessage(true, nCode, "Sports board SysTick clock initialization failed error");
  1252. break;
  1253. }
  1254. case (UINT8)EM_Warn057: //运动板存储器读取错误
  1255. {
  1256. FireErrorMessage(true, nCode, "Motion board memory read error");
  1257. break;
  1258. }
  1259. case (UINT8)EM_Warn058: //运动板存储器写数据失败错误
  1260. {
  1261. FireErrorMessage(true, nCode, "Motion board memory write data failure error");
  1262. break;
  1263. }
  1264. case (UINT8)EM_Warn059: //C臂电机驱动器错误
  1265. {
  1266. FireErrorMessage(true, nCode, "C-arm motor driver error");
  1267. break;
  1268. }
  1269. case (UINT8)EM_Warn060: //压力传感器故障
  1270. {
  1271. FireErrorMessage(true, nCode, "PRESSURE SENSOR FAILURE");
  1272. break;
  1273. }
  1274. case (UINT8)EM_Warn061: //压迫器电机位置超差错误
  1275. {
  1276. FireErrorMessage(true, nCode, "Compressor motor position out of tolerance error");
  1277. break;
  1278. }
  1279. case (UINT8)EM_Warn062: //C臂电机位置超差错误
  1280. {
  1281. FireErrorMessage(true, nCode, "C-arm motor position out of tolerance error");
  1282. break;
  1283. }
  1284. case (UINT8)EM_Warn063: //推杆电机位置超差错误
  1285. {
  1286. FireErrorMessage(true, nCode, "Pushrod motor position out of tolerance error");
  1287. break;
  1288. }
  1289. case (UINT8)EM_Warn064: //压迫器高度过低时插入放大架错误
  1290. {
  1291. FireWarnMessage(true, nCode, "Inserting the amplifier frame when compressor height too low");
  1292. break;
  1293. }
  1294. case (UINT8)EM_Warn246:
  1295. {
  1296. FireWarnMessage(false, EM_Warn064, "del EM_Warn064");
  1297. break;
  1298. }
  1299. case (UINT8)EM_Warn065: //压迫器电机驱动器错误
  1300. {
  1301. FireErrorMessage(true, nCode, "Compressor motor driver error");
  1302. break;
  1303. }
  1304. case (UINT8)EM_Warn066: //推杆电机驱动器错误
  1305. {
  1306. FireErrorMessage(true, nCode, "Pushrod motor driver error");
  1307. break;
  1308. }
  1309. case (UINT8)EM_Warn067: //角度校准板失效错误
  1310. {
  1311. FireErrorMessage(true, nCode, "Angle calibration board failure error");
  1312. break;
  1313. }
  1314. case (UINT8)EM_Warn069: //开机检测到压力报错
  1315. {
  1316. FireWarnMessage(true, nCode, "Pressure error detected during startup");
  1317. break;
  1318. }
  1319. case (UINT8)EM_Warn249:
  1320. {
  1321. FireWarnMessage(false, EM_Warn069, "del EM_Warn069");
  1322. break;
  1323. }
  1324. case (UINT8)EM_Warn070: //AEC主曝光MAS小于最小值
  1325. {
  1326. FireWarnMessage(true, nCode, "AEC main exposure MAS is less than the minimum value");
  1327. break;
  1328. }
  1329. case (UINT8)EM_Warn071: //AEC主曝光MAS大于最大值
  1330. {
  1331. FireWarnMessage(true, nCode, "AEC main exposure MAS greater than maximum value");
  1332. break;
  1333. }
  1334. case (UINT8)EM_Warn072:
  1335. {
  1336. FireWarnMessage(false, EM_Warn070, "del EM_Warn070");
  1337. FireWarnMessage(false, EM_Warn071, "del EM_Warn071");
  1338. break;
  1339. }
  1340. case (UINT8)EM_Warn073: //滤线栅自检不通过
  1341. {
  1342. FireWarnMessage(true, nCode, "Filter grid self check failed");
  1343. break;
  1344. }
  1345. case (UINT8)EM_Warn080:
  1346. {
  1347. FireWarnMessage(false, EM_Warn073, "del EM_Warn073");
  1348. break;
  1349. }
  1350. case (UINT8)EM_Warn081: //滤过挡片自检不通过
  1351. {
  1352. FireErrorMessage(true, nCode, "Filter filter self check failed");
  1353. break;
  1354. }
  1355. case (UINT8)EM_Warn082: //热容量已满,停止曝光
  1356. {
  1357. FireWarnMessage(true, nCode, "Heat capacity is full, stop exposure");
  1358. break;
  1359. }
  1360. case (UINT8)EM_Warn083:
  1361. {
  1362. FireWarnMessage(false, EM_Warn082, "del EM_Warn082");
  1363. break;
  1364. }
  1365. case (UINT8)EM_Warn128: //运动板问询通信异常
  1366. {
  1367. FireErrorMessage(true, nCode, "Abnormal communication in sports board inquiry");
  1368. break;
  1369. }
  1370. case (UINT8)EM_Warn129: //曝光板问询通信异常
  1371. {
  1372. FireErrorMessage(true, nCode, "Abnormal communication during exposure board inquiry");
  1373. break;
  1374. }
  1375. case (UINT8)EM_Warn130: //压力采集板问询通信异常
  1376. {
  1377. FireErrorMessage(true, nCode, "Pressure collection board inquiry communication abnormality");
  1378. break;
  1379. }
  1380. case (UINT8)EM_Warn131: //X光剂量检测板问询通信异常
  1381. {
  1382. FireErrorMessage(true, nCode, "Abnormal communication during X-ray dose detection board inquiry");
  1383. break;
  1384. }
  1385. case (UINT8)EM_Warn132: //阳极控制板问询通信异常
  1386. {
  1387. FireErrorMessage(true, nCode, "Anode control board inquiry communication abnormality");
  1388. break;
  1389. }
  1390. case (UINT8)EM_Warn133: //显示板通信异常
  1391. {
  1392. FireErrorMessage(true, nCode, "Abnormal communication on the display board");
  1393. break;
  1394. }
  1395. default:
  1396. FERROR("==CallbackSystemWarn==: unKnown Wraning: [{$}]", nCode);
  1397. }
  1398. };
  1399. auto CallbackExpStatus = [this](const char* value, int length) -> void
  1400. {
  1401. SINOminiCommand SystemStatus(value, SINOmini_Com_NormalLen - 1);
  1402. int nStatus = SystemStatus.GetAt(3);
  1403. FDEBUG("==CallbackExpStatus==: Gen system Status: [{$:x}]", nStatus);
  1404. switch ((UINT8)nStatus)
  1405. {
  1406. case (UINT8)EM_ExpStatus001: //进入曝光状态
  1407. {
  1408. FDEBUG("PR1 : Exposure handbrake pressed");
  1409. FDEBUG("Request Status_4:RAD_OFF(PR0) -> RAD_PREPARE(PR1)");
  1410. if (m_DoseUnit.m_GenSynState->Update(nsGEN::AttrKey::GENERATOR_RAD_PREPARE))
  1411. FireNotify(m_DoseUnit.m_GenSynState->GetKey(), m_DoseUnit.m_GenSynState->JSGet());
  1412. break;
  1413. }
  1414. case (UINT8)EM_ExpStatus002: //系统曝光预热状态
  1415. {
  1416. FDEBUG("PR2 : System exposure preheating status");
  1417. FDEBUG("Request Status_13:PREPARE or XRAYOFF(PR1 or XR0) -> RAD_READY(PR2)");
  1418. if (m_DoseUnit.m_GenSynState->Update(nsGEN::AttrKey::GENERATOR_RAD_READY))
  1419. FireNotify(m_DoseUnit.m_GenSynState->GetKey(), m_DoseUnit.m_GenSynState->JSGet());
  1420. break;
  1421. }
  1422. case (UINT8)EM_ExpStatus003: //AEC模式开启高压预曝光
  1423. {
  1424. FDEBUG("Pre - XR1 : AEC mode high-pressure pre exposure begin");
  1425. FDEBUG("Request Status_1:RAD_READY(PR2) -> X-Ray On(XR1)");
  1426. if (m_DoseUnit.m_GenSynState->Update(nsGEN::AttrKey::GENERATOR_RAD_XRAYON))
  1427. FireNotify(m_DoseUnit.m_GenSynState->GetKey(), m_DoseUnit.m_GenSynState->JSGet());
  1428. FDEBUG("Request Status_1:GENSTATE {$} -> STATUS_EXP", m_DoseUnit.m_GenState->JSGet());
  1429. m_DoseUnit.m_GenState->Update(nsGEN::AttrKey::GENERATOR_STATUS_EXP);
  1430. FireNotify(AttrKey::GENSTATE, m_DoseUnit.m_GenState->JSGet());
  1431. break;
  1432. }
  1433. case (UINT8)EM_ExpStatus004: //AEC模式高压预曝光结束
  1434. {
  1435. FDEBUG("Pre - XR0 : AEC mode enables high-pressure pre exposure end");
  1436. FDEBUG("Request Status_1:X-Ray On(XR1) -> Off(XR0)");
  1437. if (m_DoseUnit.m_GenSynState->Update(nsGEN::AttrKey::GENERATOR_RAD_XRAYOFF))
  1438. FireNotify(m_DoseUnit.m_GenSynState->GetKey(), m_DoseUnit.m_GenSynState->JSGet());
  1439. FDEBUG("Request Status_1:GENSTATE {$} -> STATUS_STANDBY", m_DoseUnit.m_GenState->JSGet());
  1440. //m_DoseUnit.m_GenState->Update(nsGEN::AttrKey::GENERATOR_STATUS_STANDBY);
  1441. //FireNotify(AttrKey::GENSTATE, m_DoseUnit.m_GenState->JSGet());
  1442. Sleep(50);
  1443. if (m_DoseUnit.m_GenSynState->Update(nsGEN::AttrKey::GENERATOR_RAD_READY))
  1444. FireNotify(m_DoseUnit.m_GenSynState->GetKey(), m_DoseUnit.m_GenSynState->JSGet());
  1445. //wxx test for SINO AEC
  1446. m_DoseUnit.m_PostKV->Update(28);
  1447. FireNotify(AttrKey::POSTKV, m_DoseUnit.m_PostKV->JSGet());
  1448. m_DoseUnit.m_PostMAS->Update(11);
  1449. FireNotify(AttrKey::POSTMAS, m_DoseUnit.m_PostMAS->JSGet());
  1450. //m_AECFlag = true;
  1451. #if 1 //wxx test for SINO AEC
  1452. {
  1453. FDEBUG("SetAPR call AEC Mean [296] \n");
  1454. char tempCMD1[12] = { 0xf0,0x07,0x00,0x00,0x00,0x00,0x01,0x28,0x00,0x00,0xC6 };
  1455. SINOminiCommand strCmd1(tempCMD1, 11);
  1456. HWSend(strCmd1);
  1457. FDEBUG("SetAPR call SyncTimestamp \n");
  1458. char tempCMD2[12] = { 0xf0,0x04,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x8b };
  1459. SINOminiCommand strCmd2(tempCMD2, 11);
  1460. HWSend(strCmd2);
  1461. FDEBUG("SetAPR call PlateAutoRelease Enable \n");
  1462. char tempCMD3[12] = { 0xf0,0x2a,0x2e,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x81 };
  1463. SINOminiCommand strCmd3(tempCMD3, 11);
  1464. HWSend(strCmd3);
  1465. }
  1466. #endif // 0
  1467. break;
  1468. }
  1469. case (UINT8)EM_ExpStatus005: //开启高压,系统开始正常曝光
  1470. {
  1471. FDEBUG("XR1 : the system starts normal exposure");
  1472. FDEBUG("Request Status_1:RAD_READY(PR2) -> X-Ray On(XR1)");
  1473. if (m_DoseUnit.m_GenSynState->Update(nsGEN::AttrKey::GENERATOR_RAD_XRAYON))
  1474. FireNotify(m_DoseUnit.m_GenSynState->GetKey(), m_DoseUnit.m_GenSynState->JSGet());
  1475. FDEBUG("Request Status_1:GENSTATE {$} -> STATUS_EXP", m_DoseUnit.m_GenState->JSGet());
  1476. m_DoseUnit.m_GenState->Update(nsGEN::AttrKey::GENERATOR_STATUS_EXP);
  1477. FireNotify(AttrKey::GENSTATE, m_DoseUnit.m_GenState->JSGet());
  1478. break;
  1479. }
  1480. case (UINT8)EM_ExpStatus006: //曝光结束
  1481. {
  1482. FDEBUG("XR0 : Exposure process over");
  1483. FDEBUG("Request Status_1:X-Ray On(XR1) -> Off(XR0)");
  1484. if (m_DoseUnit.m_GenSynState->Update(nsGEN::AttrKey::GENERATOR_RAD_XRAYOFF))
  1485. FireNotify(m_DoseUnit.m_GenSynState->GetKey(), m_DoseUnit.m_GenSynState->JSGet());
  1486. FDEBUG("Request Status_1:GENSTATE {$} -> STATUS_STANDBY", m_DoseUnit.m_GenState->JSGet());
  1487. m_DoseUnit.m_GenState->Update(nsGEN::AttrKey::GENERATOR_STATUS_STANDBY);
  1488. FireNotify(AttrKey::GENSTATE, m_DoseUnit.m_GenState->JSGet());
  1489. //wxx test for SINO AEC
  1490. int tempKV = m_DoseUnit.m_KV->Get();
  1491. float tempMAS = m_DoseUnit.m_MAS->Get();
  1492. FDEBUG("get CurrtPOSTKV[{$}], CurrtPOSTMAS[{$}]", tempKV, tempMAS);
  1493. m_DoseUnit.m_PostKV->Update(tempKV);
  1494. FireNotify(AttrKey::POSTKV, m_DoseUnit.m_PostKV->JSGet());
  1495. if (m_DoseUnit.m_PostMAS->Update(tempMAS))
  1496. FireNotify(AttrKey::POSTMAS, m_DoseUnit.m_PostMAS->JSGet());
  1497. break;
  1498. }
  1499. case (UINT8)EM_ExpStatus238: //曝光完成开始冷却
  1500. {
  1501. FDEBUG("PR0 : Start cooling after exposure is completed");
  1502. FDEBUG("Request Status_4:GEN is not in Prep state(PR0)");
  1503. if (m_DoseUnit.m_GenSynState->Update(nsGEN::AttrKey::GENERATOR_RAD_OFF))
  1504. FireNotify(m_DoseUnit.m_GenSynState->GetKey(), m_DoseUnit.m_GenSynState->JSGet());
  1505. FDEBUG("Request Fault Status:GENSTATE {$} -> STATUS_SLEEP", m_DoseUnit.m_GenState->JSGet());
  1506. m_DoseUnit.m_GenState->Update(nsGEN::AttrKey::GENERATOR_STATUS_SLEEP);
  1507. FireNotify(AttrKey::GENSTATE, m_DoseUnit.m_GenState->JSGet());
  1508. break;
  1509. }
  1510. case (UINT8)EM_ExpStatus239: //系统冷却完成
  1511. {
  1512. FDEBUG("System cooling completed");
  1513. FDEBUG("Request Status_1:GENSTATE {$} -> STATUS_STANDBY", m_DoseUnit.m_GenState->JSGet());
  1514. m_DoseUnit.m_GenState->Update(nsGEN::AttrKey::GENERATOR_STATUS_STANDBY);
  1515. FireNotify(AttrKey::GENSTATE, m_DoseUnit.m_GenState->JSGet());
  1516. FireWarnMessage(false, 101, "del warn 101");
  1517. break;
  1518. }
  1519. case (UINT8)EM_ExpStatus254: //正在曝光或曝光条件不充足
  1520. {
  1521. FDEBUG("In Exposure or not OK to enter exposure");
  1522. if (m_DoseUnit.m_GenSynState->Get() == nsGEN::AttrKey::GENERATOR_RAD_OFF)
  1523. {
  1524. FireWarnMessage(true, 100, "Not OK to enter exposure,Please pressurize");
  1525. FireWarnMessage(false, 101, "del warn 101");
  1526. }
  1527. break;
  1528. }
  1529. case (UINT8)EM_ExpStatus255: //系统曝光条件充足
  1530. {
  1531. FDEBUG("OK to enter exposure");
  1532. FireWarnMessage(false, 100, "del warn 100");
  1533. FireWarnMessage(true, 101, "OK to enter exposure");
  1534. break;
  1535. }
  1536. default:
  1537. FERROR("==CallbackExpStatus==: unKnown status: [{$}]", nStatus);
  1538. }
  1539. };
  1540. auto CallbackDevStatus = [this](const char* value, int length) -> void
  1541. {
  1542. //未在现场圣诺系统日志中发现这个日志的响应
  1543. };
  1544. auto CallbackcArmAngle = [this](const char* value, int length) -> void
  1545. {
  1546. SINOminiCommand cArmAngle(value, SINOmini_Com_NormalLen - 1);
  1547. //Angle
  1548. float fAngle = cArmAngle.GetAt(4);
  1549. if (m_pMechDev)
  1550. m_pMechDev->UpdateMammo_MechAngle(fAngle);
  1551. FDEBUG("==CallbackcArmAngle==: Angle:[{$}]", fAngle);
  1552. };
  1553. auto CallbackHu = [this](const char* value, int length) -> void
  1554. {
  1555. SINOminiCommand HU(value, SINOmini_Com_NormalLen - 1);
  1556. //TubeHeat status
  1557. int nHUStatus = HU.GetAt(3);
  1558. m_DoseUnit.m_HE->Update(nHUStatus);
  1559. FireNotify(m_DoseUnit.m_HE->GetKey(), m_DoseUnit.m_HE->JSGet());
  1560. FDEBUG("==CallbackHu==: HUStatus: SINOmini_HU: [{$}]", nHUStatus);
  1561. };
  1562. auto CallbackGenAGD = [this](const char* value, int length) -> void
  1563. {
  1564. #if 1
  1565. SINOminiCommand GenAGD(value, SINOmini_Com_NormalLen - 1);
  1566. //AGD
  1567. float fAGD = GenAGD.GetAt(4);
  1568. if (m_pMechDev)
  1569. {
  1570. m_pMechDev->UpdateMammo_AGD(fAGD);
  1571. }
  1572. #endif
  1573. };
  1574. auto CallbackWorkMode = [this](const char* value, int length) -> void
  1575. {
  1576. //未在现场圣诺系统日志中发现这个日志的响应
  1577. };
  1578. auto CallbackRackAct = [this](const char* value, int length) -> void
  1579. {
  1580. SINOminiCommand RackAct(value, SINOmini_Com_NormalLen - 1);
  1581. UINT8 nCode = RackAct.GetAt(3);
  1582. FDEBUG("==CallbackRackAct==: act code: [{$:x}]", nCode);
  1583. switch ((UINT8)nCode)
  1584. {
  1585. case (UINT8)EM_RackACT045: //一键归零
  1586. {
  1587. FINFO("Rack homing finish");
  1588. break;
  1589. }
  1590. case (UINT8)EM_RackACT046: //压迫板自动释放
  1591. {
  1592. int nAutoTracking = RackAct.GetAt(5);
  1593. nAutoTracking--;
  1594. FINFO("==CallbackRackAct==: AutoTracking[{$}]", nAutoTracking);
  1595. if (m_pMechDev)
  1596. m_pMechDev->UpdateMammo_Depress(nAutoTracking);
  1597. break;
  1598. }
  1599. case (UINT8)EM_RackACT049: //在 Get generator warning info, type = 0x22 之后出现
  1600. {
  1601. FINFO("==CallbackRackAct==: receive after warning 0x22");
  1602. break;
  1603. }
  1604. case (UINT8)EM_RackACT050: //Filter
  1605. {
  1606. int nFilterType = RackAct.GetAt(5);
  1607. if (m_pMechDev)
  1608. {
  1609. m_pMechDev->UpdateMammo_FT(nFilterType);
  1610. }
  1611. if (m_pCollDev)
  1612. {
  1613. m_pCollDev->UpdateCollimatorFilter(nFilterType);
  1614. }
  1615. break;
  1616. }
  1617. case (UINT8)EM_RackACT053: //?
  1618. {
  1619. FINFO("==CallbackRackAct==: unknown 0x35");
  1620. break;
  1621. }
  1622. case (UINT8)EM_RackACT054: //SendUnixTime
  1623. {
  1624. string tempUnixTime(value + 3, 4);
  1625. UINT8 UnixTime = atoi(tempUnixTime.c_str());
  1626. FINFO("==CallbackRackAct==: UnixTime[{$}]", UnixTime);
  1627. break;
  1628. }
  1629. case (UINT8)EM_RackACT055: //ENTER_STUDY_QUERY
  1630. {
  1631. FINFO("==CallbackRackAct==: 0x37 should not get res");
  1632. break;
  1633. }
  1634. default:
  1635. FERROR("==CallbackRackAct==: unKnown RackAct: [{$}]", nCode);
  1636. }
  1637. };
  1638. auto CheckHeartBeat = [this](const char* value, int length) -> void
  1639. {
  1640. std::unique_lock<std::mutex> uqeHeartBeat(mtxHeartBeats); //心跳包统计清空
  1641. m_iHeartBeats = 0;
  1642. uqeHeartBeat.unlock();
  1643. FDEBUG("==CheckHeartBeat==: status[{$}]", 1);
  1644. };
  1645. //服务模式:用于修改并读取非通用值, 不是正常操作的一部分.仅用于系统测试和设备维修
  1646. //暂不使用
  1647. arFrame.clear();
  1648. //命令模式:用于正常操作
  1649. //arFrame.push_back(tFrameMapping("ACK",3, CallbackACK));
  1650. arFrame.push_back(tFrameMapping(SINOmini_Parameter, CallbackParameter));
  1651. arFrame.push_back(tFrameMapping(SINOmini_WarningInfo,CallbackWarningInfo));
  1652. arFrame.push_back(tFrameMapping(SINOmini_ExpStatus, CallbackExpStatus));
  1653. arFrame.push_back(tFrameMapping(SINOmini_DevStatus, CallbackDevStatus));
  1654. arFrame.push_back(tFrameMapping(SINOmini_cArmAngle, CallbackcArmAngle));
  1655. arFrame.push_back(tFrameMapping(SINOmini_GenAGD, CallbackGenAGD));
  1656. arFrame.push_back(tFrameMapping(SINOmini_WorkMode, CallbackWorkMode));
  1657. arFrame.push_back(tFrameMapping(SINOmini_TubeHeat, CallbackHu));
  1658. arFrame.push_back(tFrameMapping(SINOmini_RackAct, CallbackRackAct));
  1659. }
  1660. void nsGEN::SINOminiDevice::ReConnect()
  1661. {
  1662. FINFO("enter reconnect");
  1663. m_SCF.Disconnect();
  1664. ResDataObject Connection = m_GenConfig["connections"][0];
  1665. FINFO("Reconnections:{$} \n", Connection.encode());
  1666. auto erCode = m_SCF.Connect(Connection.encode(), &nsGEN::SINOminiDriver::callbackPackageProcess, SCF_PACKET_TRANSFER, 3000);
  1667. if (erCode == SCF_ERR::SCF_SUCCEED)
  1668. {
  1669. FireErrorMessage(false, 1, "lost Connect");
  1670. std::unique_lock<std::mutex> uqeConnectFlag(mtxConnectFlag);
  1671. m_bConnectFlag = true;
  1672. uqeConnectFlag.unlock();
  1673. FINFO("reconnect success");
  1674. }
  1675. else
  1676. {
  1677. FINFO("reconnect failed");
  1678. }
  1679. }
  1680. bool nsGEN::SINOminiDevice::StartHardwareStatusThread()
  1681. {
  1682. FINFO("enter Start HardwareStatus Thread ");
  1683. if (m_pHardwareStatusThread == NULL)
  1684. {
  1685. DWORD m_HardwareStatusID;
  1686. m_pHardwareStatusThread = CreateThread(0, 0, HardwareStatusThread, this, 0, &m_HardwareStatusID);
  1687. if (m_pHardwareStatusThread == NULL)
  1688. {
  1689. FERROR("Start HardwareStatus Thread Failed");
  1690. return false;
  1691. }
  1692. }
  1693. return true;
  1694. }
  1695. DWORD nsGEN::SINOminiDevice::HardwareStatusThread(LPVOID pParam)
  1696. {
  1697. SINOminiDevice* pCurGen = (SINOminiDevice*)pParam;
  1698. if (pCurGen == NULL)
  1699. {
  1700. return false;
  1701. }
  1702. FINFO("HardwareStatusThread start");
  1703. int iloopingFlag = 0;
  1704. if ((int)pCurGen->m_GenConfig["loopEnable"] >= 1)
  1705. {
  1706. iloopingFlag = (int)pCurGen->m_GenConfig["loopEnable"];
  1707. }
  1708. if ((int)pCurGen->m_GenConfig["loopTime"] >= 100)
  1709. {
  1710. pCurGen->m_iLoopTime = (int)pCurGen->m_GenConfig["loopTime"];
  1711. }
  1712. FINFO("loopEnable = {$},loopTime = {$}", iloopingFlag, pCurGen->m_iLoopTime);
  1713. int currtTime = pCurGen->m_iLoopTime;
  1714. //暂无心跳查询指令
  1715. /*SINOminiCommand strHBCmd();
  1716. pCurGen->HWSend(strHBCmd);*/
  1717. Sleep(currtTime);
  1718. while (iloopingFlag == 1)
  1719. {
  1720. std::unique_lock<std::mutex> uqeConnectFlag(pCurGen->mtxConnectFlag); //判断是否断连
  1721. if (!(pCurGen->m_bConnectFlag))
  1722. {
  1723. uqeConnectFlag.unlock();
  1724. FINFO("SINOminiGEN: not Connect,try to reconnect \n");
  1725. pCurGen->FireErrorMessage(true, 1, "lost Connect");
  1726. pCurGen->ReConnect();
  1727. Sleep(20000);
  1728. continue;
  1729. }
  1730. uqeConnectFlag.unlock();
  1731. std::unique_lock<std::mutex> uqeTime(pCurGen->mtxTime); //读取循环时间
  1732. FDEBUG("currtloopTime = {$}", pCurGen->m_iLoopTime);
  1733. currtTime = pCurGen->m_iLoopTime;
  1734. uqeTime.unlock();
  1735. Sleep(currtTime);
  1736. //pCurGen->HWSend(strHBCmd); //轮询发生器相关数据信息
  1737. std::unique_lock<std::mutex> uqeHeartBeat(pCurGen->mtxHeartBeats); //心跳包统计加1
  1738. pCurGen->m_iHeartBeats++;
  1739. int tempHeartBeat = pCurGen->m_iHeartBeats;
  1740. uqeHeartBeat.unlock();
  1741. if (tempHeartBeat > 10) //无返回信息认为连接断开
  1742. {
  1743. uqeHeartBeat.lock();
  1744. pCurGen->m_iHeartBeats = 0;
  1745. uqeHeartBeat.unlock();
  1746. FINFO("SINOminiGEN: lost Connect \n");
  1747. uqeConnectFlag.lock();
  1748. pCurGen->m_bConnectFlag = false;
  1749. uqeConnectFlag.unlock();
  1750. }
  1751. }
  1752. FINFO("HardwareStatusThread stop");
  1753. return true;
  1754. }
  1755. //-----------------------------------------------------------------------------
  1756. // SINOminiDriver
  1757. //-----------------------------------------------------------------------------
  1758. nsGEN::SINOminiDriver::SINOminiDriver()
  1759. {
  1760. m_bDemoConnected = false;
  1761. m_pAttribute.reset(new ResDataObject());
  1762. m_pDescription.reset(new ResDataObject());
  1763. m_pDriGenDev = nullptr;
  1764. m_pDriMechDev = nullptr;
  1765. m_pDriCollDev = nullptr;
  1766. }
  1767. nsGEN::SINOminiDriver::~SINOminiDriver()
  1768. {
  1769. Close();
  1770. gLogger = nullptr;
  1771. if (m_pDriGenDev)
  1772. {
  1773. delete m_pDriGenDev;
  1774. m_pDriGenDev = nullptr;
  1775. }
  1776. if (m_pDriMechDev)
  1777. {
  1778. delete m_pDriMechDev;
  1779. m_pDriMechDev = nullptr;
  1780. }
  1781. if (m_pDriCollDev)
  1782. {
  1783. delete m_pDriCollDev;
  1784. m_pDriCollDev = nullptr;
  1785. }
  1786. }
  1787. void nsGEN::SINOminiDriver::Prepare()
  1788. {
  1789. string strLogPath = GetProcessDirectory() + R"(\OEMDrivers\Generator\Conf\Log4CPP.Config.GEN.xml)";
  1790. //Log4CPP::ThreadContext::Map::Set("LogFileName", "GEN.SINOmini");
  1791. Log4CPP::GlobalContext::Map::Set(ECOM::Utility::Hash("LogFileName"), "GEN.SINOmini");
  1792. auto rc = Log4CPP::LogManager::LoadConfigFile(strLogPath.c_str());
  1793. gLogger = Log4CPP::LogManager::GetLogger("GEN.SINOmini");
  1794. m_SCFDllName = GetConnectDLL(m_ConfigFileName);
  1795. super::Prepare();
  1796. }
  1797. std::string nsGEN::SINOminiDriver::DriverProbe()
  1798. {
  1799. ResDataObject r_config, HardwareInfo;
  1800. if (r_config.loadFile(m_ConfigFileName.c_str()))
  1801. {
  1802. HardwareInfo.add("MajorID", r_config["CONFIGURATION"]["MajorID"]);
  1803. HardwareInfo.add("MinorID", r_config["CONFIGURATION"]["MinorID"]);
  1804. HardwareInfo.add("VendorID", r_config["CONFIGURATION"]["VendorID"]);
  1805. HardwareInfo.add("ProductID", r_config["CONFIGURATION"]["ProductID"]);
  1806. HardwareInfo.add("SerialID", r_config["CONFIGURATION"]["SerialID"]);
  1807. }
  1808. else
  1809. {
  1810. HardwareInfo.add("MajorID", "Generator");
  1811. HardwareInfo.add("MinorID", "Dr");
  1812. HardwareInfo.add("VendorID", "SINOmini");
  1813. HardwareInfo.add("ProductID", "HF");
  1814. HardwareInfo.add("SerialID", "Drv");
  1815. }
  1816. string ret = HardwareInfo.encode();
  1817. return ret;
  1818. }
  1819. bool DATA_ACTION nsGEN::SINOminiDriver::Connect()
  1820. {
  1821. ResDataObject Connection = GetConnectParam(m_ConfigFileName);
  1822. FINFO("connections:{$} \n", Connection.encode());
  1823. auto erCode = m_SCF.Connect(Connection.encode(), &nsGEN::SINOminiDriver::callbackPackageProcess, SCF_PACKET_TRANSFER, 3000);
  1824. if (erCode != SCF_ERR::SCF_SUCCEED)
  1825. return false;
  1826. auto rc = super::Connect();
  1827. if (!rc)
  1828. return false;
  1829. //return (erCode == SCF_ERR::SCF_SUCCEED);
  1830. return true;
  1831. }
  1832. auto nsGEN::SINOminiDriver::CreateDevice(int index) -> std::unique_ptr <IODevice>
  1833. {
  1834. FINFO("Enter CreateDevice, index={$}", index);
  1835. if (!m_SCF.isConnected())
  1836. {
  1837. FWARN("CreateDevice:not Connected");
  1838. return nullptr;
  1839. }
  1840. if (index == 0)
  1841. {
  1842. m_pDriGenDev = new SINOminiDevice(EventCenter, m_SCF, m_ConfigFileName);
  1843. auto dev = std::unique_ptr<IODevice>(new IODevice(m_pDriGenDev));
  1844. return dev;
  1845. }
  1846. else if (index == 1)
  1847. {
  1848. FINFO("Enter CreateDevice Mechanical");
  1849. m_pDriMechDev = new OemMechanical(std::shared_ptr<IOEventCenter>(new IOEventCenter()), 0, 1, 2, 31, 32, 33, 0, 35, 36, 4, 1);
  1850. auto dev = std::unique_ptr <IODevice>(new IODevice(m_pDriMechDev));
  1851. m_pDriMechDev->SetCtrlDev(m_pDriGenDev);
  1852. m_pDriGenDev->SetMechDev(m_pDriMechDev);
  1853. FINFO("Leave CreateDevice Mechanical");
  1854. return dev;
  1855. }
  1856. else if (index == 2)
  1857. {
  1858. FINFO("Enter CreateDevice Collimator");
  1859. m_pDriCollDev = new OemCollimator(std::shared_ptr<IOEventCenter>(new IOEventCenter()), 40, 50, 6, 7, 8, 1);
  1860. auto dev = std::unique_ptr <IODevice>(new IODevice(m_pDriCollDev));
  1861. m_pDriCollDev->SetCtrlDev(m_pDriGenDev);
  1862. m_pDriGenDev->SetCollimatorDev(m_pDriCollDev);
  1863. FINFO("Leave CreateDevice Collimator");
  1864. return dev;
  1865. }
  1866. }
  1867. void nsGEN::SINOminiDriver::FireNotify(int code, std::string key, std::string content)
  1868. {
  1869. EventCenter->OnNotify(code, key, content);
  1870. }
  1871. bool nsGEN::SINOminiDriver::isConnected() const
  1872. {
  1873. return super::isConnected();
  1874. }
  1875. std::string nsGEN::SINOminiDriver::GetResource()
  1876. {
  1877. ResDataObject r_config, temp;
  1878. if (!temp.loadFile(m_ConfigFileName.c_str()))
  1879. {
  1880. return "";
  1881. }
  1882. m_ConfigAll = temp;
  1883. r_config = temp["CONFIGURATION"];
  1884. m_Configurations = r_config;
  1885. ResDataObject DescriptionTemp;
  1886. ResDataObject DescriptionSend;
  1887. ResDataObject m_DescriptionSend;
  1888. ResDataObject ListTemp;
  1889. string strTemp = ""; //用于读取字符串配置信息
  1890. string strIndex = ""; //用于读取配置信息中的List项
  1891. int nTemp = -1; //用于读取整型配置信息
  1892. char sstream[10] = { 0 }; //用于转换值
  1893. string strValue = ""; //用于存储配置的值
  1894. string strType = ""; //用于存储配置的类型 int/float/string...
  1895. /***
  1896. * 1. 通过循环,将所有配置项写到pDeviceConfig
  1897. * 2. 记录配置项的内部key以及配置类型,类型对应了不同配置文件路径,用于读写真实值
  1898. ***/
  1899. try
  1900. {
  1901. //便利ConfigToolInfo 中 所有的AttributeInfo 属性段
  1902. int nConfigInfoCount = (int)m_Configurations["ConfigToolInfo"].GetKeyCount("AttributeInfo");
  1903. m_pAttribute->clear();
  1904. m_pDescription->clear();
  1905. for (int nInfoIndex = 0; nInfoIndex < nConfigInfoCount; nInfoIndex++)
  1906. {
  1907. DescriptionTemp.clear();
  1908. DescriptionSend.clear();
  1909. ListTemp.clear();
  1910. //AttributeType
  1911. strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["Type"];
  1912. DescriptionTemp.add(ConfKey::CcosType, strTemp.c_str());//CcosGeneratorAttribute
  1913. DescriptionSend.add(ConfKey::CcosType, strTemp.c_str());//CcosGeneratorAttribute
  1914. strType = strTemp; //记录配置项的类型
  1915. //AttributeKey
  1916. //1. 根据AttributeType,内部key和配置路径,拿到当前的真实值
  1917. strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["InnerKey"];
  1918. nTemp = (int)m_Configurations["ConfigToolInfo"][nInfoIndex]["PathID"];
  1919. GetDeviceConfigValue(r_config, strTemp.c_str(), nTemp, strValue); //得到strValue的值
  1920. //printf("********************************innerkey=%s --strValue = %s\n", strTemp.c_str(), strValue.c_str());
  1921. //2. 赋值
  1922. strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeKey"];
  1923. if ("int" == strType)
  1924. {
  1925. (*m_pAttribute).add(strTemp.c_str(), atoi(strValue.c_str()));
  1926. }
  1927. else if ("float" == strType)
  1928. {
  1929. (*m_pAttribute).add(strTemp.c_str(), atoi(strValue.c_str()));
  1930. }
  1931. else //其它先按string类型处理
  1932. {
  1933. (*m_pAttribute).add(strTemp.c_str(), strValue.c_str());
  1934. }
  1935. //printf("********************************outkey =%s --strValue = %s\n", strTemp.c_str(), strValue.c_str());
  1936. //AttributeAccess
  1937. strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["Access"];
  1938. DescriptionTemp.add(ConfKey::CcosAccess, strTemp.c_str());
  1939. DescriptionSend.add(ConfKey::CcosAccess, strTemp.c_str());
  1940. /*
  1941. //AttributeRangeMin
  1942. strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["RangeMin"];
  1943. if (strTemp != "") //不需要的配置项为空
  1944. {
  1945. DescriptionTemp.add(ConfKey::CcosRangeMin, strTemp.c_str());
  1946. }
  1947. //AttributeRangeMax
  1948. strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["RangeMax"];
  1949. if (strTemp != "") //不需要的配置项为空
  1950. {
  1951. DescriptionTemp.add(ConfKey::CcosRangeMax, strTemp.c_str());
  1952. }
  1953. */
  1954. //AttributeList
  1955. nTemp = m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["ListNum"];
  1956. if (nTemp > 0) //ListNum不大于0时说明不需要list配置
  1957. {
  1958. for (int nListIndex = 0; nListIndex < nTemp; nListIndex++)
  1959. {
  1960. strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["ListInfo"][nListIndex];
  1961. auto temKey = std::to_string(nListIndex);
  1962. ListTemp.add(temKey.c_str(), strTemp.c_str());
  1963. }
  1964. DescriptionTemp.add(ConfKey::CcosList, ListTemp);
  1965. DescriptionSend.add(ConfKey::CcosList, ListTemp.encode());
  1966. }
  1967. //AttributeRequired
  1968. strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["Required"];
  1969. DescriptionTemp.add(ConfKey::CcosRequired, strTemp.c_str());
  1970. DescriptionSend.add(ConfKey::CcosRequired, strTemp.c_str());
  1971. //AttributeDefaultValue
  1972. strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["DefaultValue"];
  1973. if (strTemp != "") //不需要的配置项为空
  1974. {
  1975. DescriptionTemp.add(ConfKey::CcosDefaultValue, strTemp.c_str());
  1976. DescriptionSend.add(ConfKey::CcosDefaultValue, strTemp.c_str());
  1977. }
  1978. strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeKey"];
  1979. (*m_pDescription).add(strTemp.c_str(), DescriptionTemp);
  1980. m_DescriptionSend.add(strTemp.c_str(), DescriptionSend.encode());
  1981. }
  1982. }
  1983. catch (ResDataObjectExption& e)
  1984. {
  1985. FERROR("Get config error: {$}", e.what());
  1986. return "";
  1987. }
  1988. ResDataObject resDeviceResource;
  1989. resDeviceResource.add(ConfKey::CcosGeneratorAttribute, (*m_pAttribute));
  1990. resDeviceResource.add(ConfKey::CcosGeneratorDescription, (*m_pDescription));
  1991. ResDataObject DescriptionTempEx;
  1992. DescriptionTempEx.add(ConfKey::CcosGeneratorConfig, resDeviceResource);
  1993. m_DeviceConfig.clear();
  1994. m_DeviceConfig = DescriptionTempEx;
  1995. FDEBUG("local ************* get resource over {$}", DescriptionTempEx.encode());
  1996. //printf("local ************* get resource over %s \n", DescriptionTempEx.encode());
  1997. resDeviceResource.clear();
  1998. resDeviceResource.add(ConfKey::CcosGeneratorAttribute, (*m_pAttribute));
  1999. resDeviceResource.add(ConfKey::CcosGeneratorDescription, m_DescriptionSend);
  2000. DescriptionTempEx.clear();
  2001. DescriptionTempEx.add(ConfKey::CcosGeneratorConfig, resDeviceResource);
  2002. m_DeviceConfigSend.clear();
  2003. m_DeviceConfigSend = DescriptionTempEx;
  2004. string res = m_DeviceConfigSend.encode();
  2005. //printf("%s", res.c_str());
  2006. FDEBUG("get resource over {$}", DescriptionTempEx.encode());
  2007. //printf("************* get resource over %s \n", DescriptionTempEx.encode());
  2008. return res;
  2009. }
  2010. std::string nsGEN::SINOminiDriver::DeviceProbe()
  2011. {
  2012. ResDataObject r_config, HardwareInfo;
  2013. if (r_config.loadFile(m_ConfigFileName.c_str()))
  2014. {
  2015. HardwareInfo.add("MajorID", r_config["CONFIGURATION"]["MajorID"]);
  2016. HardwareInfo.add("MinorID", r_config["CONFIGURATION"]["MinorID"]);
  2017. HardwareInfo.add("VendorID", r_config["CONFIGURATION"]["VendorID"]);
  2018. HardwareInfo.add("ProductID", r_config["CONFIGURATION"]["ProductID"]);
  2019. HardwareInfo.add("SerialID", r_config["CONFIGURATION"]["SerialID"]);
  2020. }
  2021. else
  2022. {
  2023. HardwareInfo.add("MajorID", "Generator");
  2024. HardwareInfo.add("MinorID", "Dr");
  2025. HardwareInfo.add("VendorID", "SINOmini");
  2026. HardwareInfo.add("ProductID", "HF");
  2027. HardwareInfo.add("SerialID", "Dev");
  2028. }
  2029. string ret = HardwareInfo.encode();
  2030. return ret;
  2031. }
  2032. void nsGEN::SINOminiDriver::Disconnect()
  2033. {
  2034. super::Disconnect();
  2035. m_SCF.Disconnect();
  2036. m_bDemoConnected = false;
  2037. Close();
  2038. gLogger = nullptr;
  2039. }
  2040. void nsGEN::SINOminiDriver::Dequeue(const char* Packet, DWORD Length)
  2041. {
  2042. DecodeFrame(Packet, Length);
  2043. }
  2044. PACKET_RET nsGEN::SINOminiDriver::callbackPackageProcess(const char* RecData, DWORD nLength, DWORD& PacketLength)
  2045. {
  2046. #if 0
  2047. if (nLength > 1)
  2048. {
  2049. FERROR("receive data_len[{$}]", nLength);
  2050. for (int i = 0; i < nLength; i++)
  2051. {
  2052. FDEBUG("receive data[{$}][{$:x2}]", i, RecData[i]);
  2053. }
  2054. }
  2055. #endif
  2056. bool bHasHead = false;
  2057. if (nLength < SINOmini_Com_NormalLen - 1)
  2058. {
  2059. PacketLength = 0;
  2060. //printf("nLength too small, nLength==%d \n", nLength);
  2061. FERROR("nLength too small, nLength==[{$}],RecData[{$}]", nLength, RecData);
  2062. return PACKET_NOPACKET;
  2063. }
  2064. for (DWORD i = 0; i < nLength; i++)
  2065. {
  2066. //寻找包头
  2067. if ((UINT8)RecData[i]== SINOmini_STX)
  2068. {
  2069. if (i!=0) //包头之前的数据格式不对,全部扔掉
  2070. {
  2071. if (!bHasHead)
  2072. {
  2073. PacketLength = i;
  2074. SINOminiCommand strtemp(RecData, PacketLength);
  2075. FERROR("==IN unknown format data ==:[{$}],UselessDataLength={$},TotalLength={$} \n", strtemp.Get_Hex_Log(), PacketLength, nLength);
  2076. return PACKET_USELESS;
  2077. }
  2078. }
  2079. else
  2080. {
  2081. bHasHead = true;
  2082. }
  2083. }
  2084. //寻找包尾
  2085. if (i == SINOmini_Com_NormalLen - 2)
  2086. {
  2087. if(bHasHead)
  2088. {
  2089. PacketLength = i + 1; //+1 because ETX
  2090. SINOminiCommand strtemp(RecData, PacketLength); //全部数据
  2091. FINFO("==IN==:[{$}]", strtemp.Get_Hex_Log());
  2092. return PACKET_ISPACKET;
  2093. }
  2094. }
  2095. }
  2096. if (bHasHead && nLength < SINOmini_Com_NormalLen - 1)
  2097. {
  2098. PacketLength = 0;
  2099. }
  2100. if (nLength > SINOmini_Com_NormalLen)
  2101. {
  2102. PacketLength = nLength;
  2103. SINOminiCommand strtemp(RecData, PacketLength);
  2104. FERROR("==IN unknown format data ==:[{$}],nLength{$} too big,", strtemp.Get_Hex_Log(), nLength);
  2105. return PACKET_USELESS;
  2106. }
  2107. return PACKET_NOPACKET;
  2108. }
  2109. bool nsGEN::SINOminiDriver::GetDeviceConfig(std::string& Cfg)
  2110. {
  2111. Cfg = m_DeviceConfigSend.encode();
  2112. printf("GetDeviceConfig over , %s", Cfg.c_str());
  2113. return true;
  2114. }
  2115. bool nsGEN::SINOminiDriver::SetDeviceConfig(std::string Cfg)
  2116. {
  2117. FINFO("--Func-- SetDeviceConfig {$}\n", Cfg.c_str());
  2118. printf("\n--Func-- SetDeviceConfig %s\n", Cfg.c_str());
  2119. ResDataObject DeviceConfig;
  2120. DeviceConfig.decode(Cfg.c_str());
  2121. ResDataObject DescriptionTempEx;
  2122. DescriptionTempEx = DeviceConfig["DeviceConfig"]["Attribute"];
  2123. FDEBUG("Attribute:{$}", DescriptionTempEx.encode());
  2124. bool bSaveFile = false; //true:重新保存配置文件
  2125. string strAccess = "";
  2126. for (int i = 0; i < DescriptionTempEx.size(); i++)
  2127. {
  2128. string strKey = DescriptionTempEx.GetKey(i);
  2129. FINFO("{$}", strKey.c_str());
  2130. printf("%s\n", strKey.c_str());
  2131. try
  2132. {
  2133. if (m_pAttribute->GetFirstOf(strKey.c_str()) >= 0)
  2134. {
  2135. strAccess = (string)(*m_pDescription)[strKey.c_str()]["Access"];
  2136. if ("RW" == strAccess)
  2137. {
  2138. //修改对应配置,在其他单元的配置项要同时调用其修改函数修改真实值
  2139. //1. 修改内存中的值,用于给上层发消息
  2140. (*m_pAttribute)[strKey.c_str()] = DescriptionTempEx[i];
  2141. //2. 拿到Innerkey
  2142. int nConfigInfoCount = (int)m_Configurations["ConfigToolInfo"].GetKeyCount("AttributeInfo");
  2143. FINFO("nConfigInfoCount {$}", nConfigInfoCount);
  2144. string strTemp = ""; //存储AttributeKey
  2145. for (int nInfoIndex = 0; nInfoIndex < nConfigInfoCount; nInfoIndex++)
  2146. {
  2147. strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeKey"];
  2148. if (strTemp == strKey)
  2149. {
  2150. strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["InnerKey"];
  2151. break;
  2152. }
  2153. }
  2154. //3. 修改配置文件中的值
  2155. if (SetDeviceConfigValue(m_Configurations, strTemp.c_str(), 1, DescriptionTempEx[i]))
  2156. {
  2157. FDEBUG("SetDeviceConfigValue over");
  2158. bSaveFile = true;
  2159. }
  2160. }
  2161. else
  2162. {
  2163. FINFO("{$} is not a RW configuration item", strKey.c_str());
  2164. }
  2165. }
  2166. else
  2167. {
  2168. FINFO("without this attribute {$}", strKey.c_str());
  2169. }
  2170. }
  2171. catch (ResDataObjectExption& e)
  2172. {
  2173. printf("\nSetDriverConfig crashed: %s\n", e.what());
  2174. FERROR("SetDriverConfig crashed: {$}", e.what());
  2175. return false;
  2176. }
  2177. }
  2178. if (bSaveFile)
  2179. {
  2180. //3. 重新保存配置文件
  2181. SaveConfigFile(true);
  2182. }
  2183. return true;
  2184. }
  2185. bool nsGEN::SINOminiDriver::SaveConfigFile(bool bSendNotify)
  2186. {
  2187. m_ConfigAll["CONFIGURATION"] = m_Configurations;
  2188. bool bRt = m_ConfigAll.SaveFile(m_ConfigFileName.c_str());
  2189. FINFO("SaveConfigFile over {$}", bRt);
  2190. return true;
  2191. }
  2192. bool nsGEN::SINOminiDriver::GetDeviceConfigValue(ResDataObject config, const char* pInnerKey, int nPathID, string& strValue)
  2193. {
  2194. strValue = "";
  2195. //return true;//暂时不需要
  2196. string strTemp = pInnerKey;
  2197. if (1 == nPathID) //从DriverConfig路径下每个DPC自己的配置文件读取
  2198. {
  2199. int pos = 0;
  2200. ResDataObject resTemp = config;
  2201. while ((pos = strTemp.find_first_of(',')) != string::npos)
  2202. {
  2203. string Key = strTemp.substr(0, pos);
  2204. string TempValue = resTemp[Key.c_str()].encode();
  2205. // printf("-TempValue=== %s", TempValue.c_str());
  2206. resTemp.clear();
  2207. resTemp.decode(TempValue.c_str());
  2208. strTemp = strTemp.substr(pos + 1, strTemp.length() - pos - 1);
  2209. //printf("-************--%s", strTemp.c_str());
  2210. }
  2211. if (strTemp != "")
  2212. {
  2213. strValue = (string)resTemp[strTemp.c_str()];
  2214. }
  2215. else
  2216. {
  2217. strValue = (string)resTemp;
  2218. }
  2219. }
  2220. //printf("------------%s", strValue.c_str());
  2221. return true;
  2222. }
  2223. bool nsGEN::SINOminiDriver::SetDeviceConfigValue(ResDataObject& config, const char* pInnerKey, int nPathID, const char* szValue)
  2224. {
  2225. //return true;//暂时不需要
  2226. string strTemp = pInnerKey;
  2227. FDEBUG("Begin to change {$} item value to {$}", pInnerKey, szValue);
  2228. printf("\nbbbbbbbbbbbbbbBegin to change {%s} item value to {%s}\n", pInnerKey, szValue);
  2229. if (1 == nPathID) //从DriverConfig路径下每个DPC自己的配置文件读取
  2230. {
  2231. try {
  2232. int pos = 0;
  2233. ResDataObject* resTemp = &config;
  2234. while ((pos = strTemp.find_first_of(',')) != string::npos)
  2235. {
  2236. string Key = strTemp.substr(0, pos);
  2237. resTemp = &(*resTemp)[Key.c_str()];
  2238. strTemp = strTemp.substr(pos + 1, strTemp.length() - pos - 1);
  2239. }
  2240. if (strTemp != "")
  2241. {
  2242. //if ((strTemp.compare("WSTable") == 0) ||
  2243. // (strTemp.compare("WSWall") == 0) ||
  2244. // (strTemp.compare("WSFree") == 0) ||
  2245. // (strTemp.compare("WSTomo") == 0) ||
  2246. // (strTemp.compare("WSConventional") == 0)
  2247. // )
  2248. //{
  2249. // int sum = (*szValue) + 1;
  2250. // (*resTemp)[strTemp.c_str()] = (char*)(&sum);
  2251. //}
  2252. //else
  2253. // (*resTemp)[strTemp.c_str()] = szValue;
  2254. (*resTemp)[strTemp.c_str()] = szValue;
  2255. }
  2256. else
  2257. {
  2258. *resTemp = szValue;
  2259. }
  2260. }
  2261. catch (ResDataObjectExption& e)
  2262. {
  2263. FERROR("SetDriverConfigvalue crashed: {$}", e.what());
  2264. return false;
  2265. }
  2266. }
  2267. return true;
  2268. }
  2269. //-----------------------------------------------------------------------------
  2270. // GetIODriver & CreateIODriver
  2271. //-----------------------------------------------------------------------------
  2272. static nsGEN::SINOminiDriver gIODriver;
  2273. extern "C" CCOS::Dev::IODriver * __cdecl GetIODriver() // 返回静态对象的引用, 调用者不能删除 !
  2274. {
  2275. return &gIODriver;
  2276. }
  2277. extern "C" CCOS::Dev::IODriver * __cdecl CreateIODriver() // 返回新对象, 调用者必须自行删除此对象 !
  2278. {
  2279. return new nsGEN::SINOminiDriver();
  2280. }