APlatformDcs.cpp 78 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232
  1. // APlatformDcs.cpp : 定义 DLL 应用程序的导出函数。
  2. //
  3. #include "stdafx.h"
  4. #include "APlatformDcs.h"
  5. #include "cdi.h"
  6. #include "LocalConfig.h"
  7. #include "BusUnitClient.h"
  8. #include "CommonLogicClient.h"
  9. #include <conio.h>
  10. void PrintCurTime()
  11. {
  12. SYSTEMTIME st;
  13. GetLocalTime(&st);
  14. printf("hit At %4d-%2d-%2d %2d:%2d:%2d.%3d\n", st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond, st.wMilliseconds);
  15. }
  16. char *pszPlatformHelpCmds[] = {
  17. "Hello --yeah...",
  18. "Procs --shows all the ccos driver process in this machine.",
  19. "Devs rootpath --shows all the ccos driver process in this process.procpath:[/ccosAlpha]",
  20. "PrintDev Devpath -- show open response context",
  21. "Connect rootpath ipaddr --connect target proc to target machine.ipaddr[192.168.2.77]",
  22. "Disconnect rootpath --disconnect all remote connection",
  23. "RemoteProcs --shows all the ccos driver process in remote machine.",
  24. "RemoteDevs rootpath --shows all the ccos driver process in remote process.procpath:[/ccosAlpha]",
  25. "CT param1[TargetBusId] --close target proc who owns busid",
  26. "Test param1[0:del,1:add] param2[idstr]",
  27. "MechTest param1[1:Move,2:Rotate,3:Stop,4:Reset,5:DrTest,6:TomoTest,7:BlindRotateMech] param2",
  28. "Gen param1[1:SetKV,2:GetKV,3:IncKV,4:DecKV 5:SetMAS,6:GetMAS,7:IncMAS,8:DecMAS 9:SetFocus 10:ExpEnable] param2",
  29. "Dap Param1[0:reset,1:setFilter,2:setSID,3:setColimatorSize,4:setkv,5:setma,6:setms,7:setmas,8:getdap] Param2[num]",
  30. "FDacq Param1[AcqModeIndex] Param2[Xwindow ms]",
  31. "ConfigDriver param1[0:del,1:add,2:ShowAll] param2[driverpath]",
  32. "Action ActionName param1[devpath]",
  33. "Exit -- exit the whole modules.channel and all ccos procs",
  34. "WorkFlowTest param1[1:Acq,2:SetErrStatus,3:EvtPrep,4:EvtExpOn,5:RESET,6:EvtEndPost,7:StopSM,100:OffsetCalibration,101:GainCalibration,200:ErrTest,201:ErrTestAllStates,0:DeactivateSubsystem]",
  35. ""
  36. };
  37. APLATFORMDCS_CAPI CcosConsoleScript* LoadDCS()
  38. {
  39. CcosConsoleScript *pNew = new APlatformDcs();
  40. return pNew;
  41. }
  42. APLATFORMDCS_CAPI void UnLoadDCS(CcosConsoleScript* pDcs)
  43. {
  44. delete (APlatformDcs*)pDcs;
  45. }
  46. APlatformDcs::APlatformDcs(void)
  47. {
  48. MacroRegist(APlatformDcs, Hello);
  49. MacroRegist(APlatformDcs, Procs);
  50. MacroRegist(APlatformDcs, Devs);
  51. MacroRegist(APlatformDcs, PrintDev);
  52. MacroRegist(APlatformDcs, Connect);
  53. MacroRegist(APlatformDcs, Disconnect);
  54. MacroRegist(APlatformDcs, RemoteProcs);
  55. MacroRegist(APlatformDcs, RemoteDevs);
  56. MacroRegist(APlatformDcs, CT);
  57. MacroRegist(APlatformDcs, Test);
  58. MacroRegist(APlatformDcs, Ctrlcpu);
  59. MacroRegist(APlatformDcs, MechTest);
  60. MacroRegist(APlatformDcs, Gen);
  61. MacroRegist(APlatformDcs, Dap);
  62. MacroRegist(APlatformDcs, AddDPC);
  63. MacroRegist(APlatformDcs, DelDPC);
  64. MacroRegist(APlatformDcs, FDacq);
  65. MacroRegist(APlatformDcs, FDcalib);
  66. MacroRegist(APlatformDcs, ConfigDriver);
  67. MacroRegist(APlatformDcs, Action);
  68. MacroRegist(APlatformDcs, Exit);
  69. //MacroRegist(APlatformDcs, WorkFlowTest);
  70. //m_statWFT = new WFTStatus;
  71. }
  72. APlatformDcs::~APlatformDcs()
  73. {
  74. //if (m_statWFT != NULL)
  75. // delete m_statWFT;
  76. }
  77. void APlatformDcs::Help()
  78. {
  79. DWORD i = 0;
  80. while (strlen(pszPlatformHelpCmds[i]) > 0)
  81. {
  82. printf("%s\n", pszPlatformHelpCmds[i]);
  83. ++i;
  84. }
  85. //other script here
  86. }
  87. DCS_RET APlatformDcs::Command(ResDataObject &Req)
  88. {
  89. //return RUNDCS(APlatformDcs,Req);
  90. //get addr ;
  91. //类型转换
  92. //call this.func(Req);
  93. return MacroRun(Req);
  94. //if (gcmds == (const char *)Req[0])
  95. //{
  96. // return Hello(Req);
  97. //}
  98. //return DCS_NOT_SUPPORT;
  99. }
  100. DCS_RET APlatformDcs::Exit(ResDataObject &Req)
  101. {
  102. printf("Enter Exit all procs\n");
  103. string Channel = "/ccosChannel";
  104. BusUnitClient buClient;
  105. buClient.SetRouter(CCOS_PACKET_ROUTE_LOCAL);
  106. if (buClient.Open("/ccosChannel", ALL_ACCESS, 10000) == RET_SUCCEED)
  107. {
  108. ResDataObject req, res;
  109. buClient.Action("ExitDriverProc", req, res);
  110. buClient.Close();
  111. printf("hit exit\n");
  112. }
  113. return DCS_SUCCEED;
  114. }
  115. DCS_RET APlatformDcs::Hello(ResDataObject &Req)
  116. {
  117. printf("Hello You Granpa\n");
  118. string Channel = "/ccosChannel";
  119. BusUnitClient buClient;
  120. buClient.SetRouter(CCOS_PACKET_ROUTE_LOCAL);
  121. if (buClient.Open("/ccosChannel", ALL_ACCESS, 10000) == RET_SUCCEED)
  122. {
  123. ResDataObject req, res;
  124. buClient.Action("ExitDriverProc", req, res);
  125. buClient.Close();
  126. printf("hit exit\n");
  127. }
  128. return DCS_SUCCEED;
  129. }
  130. DCS_RET Procs_Func(ResDataObject &Req,bool Remote)
  131. {
  132. string Channel = "/ccosChannel";
  133. printf("Local Procs\n");
  134. BusUnitClient buClient;
  135. if (Remote)
  136. {
  137. buClient.SetRouter(CCOS_PACKET_ROUTE_ETH);
  138. }
  139. else
  140. {
  141. buClient.SetRouter(CCOS_PACKET_ROUTE_LOCAL);
  142. }
  143. if (buClient.Open("/ccosChannel", ALL_ACCESS, 10000) == RET_SUCCEED)
  144. {
  145. buClient.Close();
  146. DWORD count = buClient.GetDeviceCount();
  147. for (DWORD i = 0; i < count; i++)
  148. {
  149. UINT64 ProcId, Addr;
  150. ResDataObject DevType,devpath, MachineId;
  151. buClient.GetDeviceDescript(i, devpath, DevType, MachineId, ProcId, Addr);
  152. if (Channel == (const char*)devpath)
  153. {
  154. continue;
  155. }
  156. printf("ProcPath[%d]:%s\n DevType:%s Machine:%s\n ProcessId:%I64u\n Addr:%I64u\n", i, (const char*)devpath, (const char *)DevType,(const char*)MachineId, ProcId, Addr);
  157. CommonLogicClient DevClient;
  158. if (Remote)
  159. {
  160. DevClient.SetRouter(CCOS_PACKET_ROUTE_ETH);
  161. }
  162. else
  163. {
  164. DevClient.SetRouter(CCOS_PACKET_ROUTE_LOCAL);
  165. }
  166. if (DevClient.Open((const char*)devpath, ALL_ACCESS, 10000) >= RET_SUCCEED)
  167. {
  168. DevClient.Close();
  169. //printf("Open %s Succeed\n", (const char*)devpath);
  170. }
  171. else
  172. {
  173. printf("Open %s Failed\n", (const char*)devpath);
  174. }
  175. }
  176. }
  177. else
  178. {
  179. printf("Open local ccosChannel Failed\n");
  180. }
  181. return DCS_SUCCEED;
  182. }
  183. DCS_RET Devs_Func(ResDataObject &Req,bool Remote)
  184. {
  185. vector<string> PathList;
  186. vector<string> MachineList;
  187. vector<UINT64> ProcList;
  188. vector<UINT64> AddrList;
  189. string Channel = "/ccosChannel";
  190. //printf("Local Procs\n");
  191. BusUnitClient buClient;
  192. if (Remote)
  193. {
  194. buClient.SetRouter(CCOS_PACKET_ROUTE_ETH);
  195. }
  196. else
  197. {
  198. buClient.SetRouter(CCOS_PACKET_ROUTE_LOCAL);
  199. }
  200. //buClient.SetRouter(CCOS_PACKET_ROUTE_LOCAL);
  201. if (buClient.Open("/ccosChannel", ALL_ACCESS, 2000) == RET_SUCCEED)
  202. {
  203. buClient.UpdateDeviceResource();
  204. buClient.Close();
  205. DWORD count = buClient.GetDeviceCount();
  206. for (DWORD i = 0; i < count; i++)
  207. {
  208. UINT64 ProcId, Addr;
  209. ResDataObject DevType,devpath, MachineId;
  210. buClient.GetDeviceDescript(i, devpath, DevType, MachineId, ProcId, Addr);
  211. if (Channel == (const char*)devpath)
  212. {
  213. continue;
  214. }
  215. CommonLogicClient DevClient;
  216. if (Remote)
  217. {
  218. DevClient.SetRouter(CCOS_PACKET_ROUTE_ETH);
  219. }
  220. else
  221. {
  222. DevClient.SetRouter(CCOS_PACKET_ROUTE_LOCAL);
  223. }
  224. if (DevClient.Open((const char*)devpath, ALL_ACCESS, 2000) >= RET_SUCCEED)
  225. {
  226. DevClient.UpdateDeviceResource();
  227. DevClient.Close();
  228. if (Req.size() > 1)
  229. {
  230. string path = (const char*)Req[1];
  231. if (path == ((const char*)devpath))
  232. {
  233. PathList.push_back((const char*)devpath);
  234. MachineList.push_back((const char*)MachineId);
  235. ProcList.push_back(ProcId);
  236. AddrList.push_back(Addr);
  237. }
  238. }
  239. else
  240. {
  241. PathList.push_back((const char*)devpath);
  242. MachineList.push_back((const char*)MachineId);
  243. ProcList.push_back(ProcId);
  244. AddrList.push_back(Addr);
  245. }
  246. }
  247. }
  248. }
  249. else
  250. {
  251. printf("Open local ccosChannel Failed\n");
  252. return DCS_FAILED;
  253. }
  254. for (size_t ProcIdx = 0; ProcIdx < ProcList.size(); ProcIdx++)
  255. {
  256. BusUnitClient buClient;
  257. if (Remote)
  258. {
  259. buClient.SetRouter(CCOS_PACKET_ROUTE_ETH);
  260. }
  261. else
  262. {
  263. buClient.SetRouter(CCOS_PACKET_ROUTE_LOCAL);
  264. }
  265. //buClient.SetRouter(CCOS_PACKET_ROUTE_LOCAL);
  266. if (buClient.Open(PathList[ProcIdx].c_str(), ALL_ACCESS, 2000) == RET_SUCCEED)
  267. {
  268. buClient.UpdateDeviceResource();
  269. buClient.Close();
  270. printf("ProcPath[%zu]:%s\n Machine:%s\n ProcessId:%I64u\n Addr:%I64u\n", ProcIdx, PathList[ProcIdx].c_str(), MachineList[ProcIdx].c_str(), ProcList[ProcIdx], AddrList[ProcIdx]);
  271. DWORD count = buClient.GetDeviceCount();
  272. for (DWORD i = 0; i < count; i++)
  273. {
  274. UINT64 ProcId, Addr;
  275. ResDataObject DevType,devpath, MachineId;
  276. buClient.GetDeviceDescript(i, devpath, DevType, MachineId, ProcId, Addr);
  277. printf(" devpath[%d]:%s\n devtype:%s\n Addr:%I64u\n", i, (const char*)devpath, (const char*)DevType, Addr);
  278. CommonLogicClient DevClient;
  279. if (Remote)
  280. {
  281. DevClient.SetRouter(CCOS_PACKET_ROUTE_ETH);
  282. }
  283. else
  284. {
  285. DevClient.SetRouter(CCOS_PACKET_ROUTE_LOCAL);
  286. }
  287. if (DevClient.Open((const char*)devpath, ALL_ACCESS, 2000) >= RET_SUCCEED)
  288. {
  289. DevClient.UpdateDeviceResource();
  290. DevClient.Close();
  291. //printf("Open %s Succeed\n", (const char*)devpath);
  292. }
  293. else
  294. {
  295. printf("Open %s Failed\n", (const char*)devpath);
  296. }
  297. }
  298. }
  299. else
  300. {
  301. printf("Open local %s Failed\n", PathList[ProcIdx].c_str());
  302. }
  303. }
  304. return DCS_SUCCEED;
  305. }
  306. bool FindSubString(string org, string keystr)
  307. {
  308. std::string::size_type pos = 0;
  309. std::string::size_type keylen = keystr.size();
  310. if ((pos = org.find(keystr, pos)) != std::string::npos)
  311. {
  312. return true;
  313. }
  314. return false;
  315. }
  316. string Devs_Find(const char *pszKeystr, bool Remote)
  317. {
  318. for (size_t ti = 0; ti < 10; ti++)
  319. {
  320. vector<string> PathList;
  321. vector<string> MachineList;
  322. vector<UINT64> ProcList;
  323. vector<UINT64> AddrList;
  324. string Channel = "/ccosChannel";
  325. //printf("Local Procs\n");
  326. BusUnitClient buClient;
  327. if (Remote)
  328. {
  329. buClient.SetRouter(CCOS_PACKET_ROUTE_ETH);
  330. }
  331. else
  332. {
  333. buClient.SetRouter(CCOS_PACKET_ROUTE_LOCAL);
  334. }
  335. buClient.SetRouter(CCOS_PACKET_ROUTE_LOCAL);
  336. if (buClient.Open("/ccosChannel", ALL_ACCESS, 1000) == RET_SUCCEED)
  337. {
  338. buClient.Close();
  339. DWORD count = buClient.GetDeviceCount();
  340. for (DWORD i = 0; i < count; i++)
  341. {
  342. UINT64 ProcId, Addr;
  343. ResDataObject DevType,devpath, MachineId;
  344. buClient.GetDeviceDescript(i, devpath, DevType, MachineId, ProcId, Addr);
  345. if (Channel == (const char*)devpath)
  346. {
  347. continue;
  348. }
  349. CommonLogicClient DevClient;
  350. if (Remote)
  351. {
  352. DevClient.SetRouter(CCOS_PACKET_ROUTE_ETH);
  353. }
  354. else
  355. {
  356. DevClient.SetRouter(CCOS_PACKET_ROUTE_LOCAL);
  357. }
  358. if (DevClient.Open((const char*)devpath, ALL_ACCESS, 1000) >= RET_SUCCEED)
  359. {
  360. DevClient.Close();
  361. PathList.push_back((const char*)devpath);
  362. MachineList.push_back((const char*)MachineId);
  363. ProcList.push_back(ProcId);
  364. AddrList.push_back(Addr);
  365. }
  366. }
  367. }
  368. else
  369. {
  370. printf("Open local ccosChannel Failed\n");
  371. return "";
  372. }
  373. for (size_t ProcIdx = 0; ProcIdx < ProcList.size(); ProcIdx++)
  374. {
  375. BusUnitClient buClient;
  376. if (Remote)
  377. {
  378. buClient.SetRouter(CCOS_PACKET_ROUTE_ETH);
  379. }
  380. else
  381. {
  382. buClient.SetRouter(CCOS_PACKET_ROUTE_LOCAL);
  383. }
  384. buClient.SetRouter(CCOS_PACKET_ROUTE_LOCAL);
  385. if (buClient.Open(PathList[ProcIdx].c_str(), ALL_ACCESS, 1000) == RET_SUCCEED)
  386. {
  387. buClient.Close();
  388. //printf("ProcPath[%zu]:%s\n Machine:%s\n ProcessId:%I64u\n Addr:%I64u\n", ProcIdx, PathList[ProcIdx].c_str(), MachineList[ProcIdx].c_str(), ProcList[ProcIdx], AddrList[ProcIdx]);
  389. DWORD count = buClient.GetDeviceCount();
  390. for (DWORD i = 0; i < count; i++)
  391. {
  392. UINT64 ProcId, Addr;
  393. ResDataObject DevType,devpath, MachineId;
  394. buClient.GetDeviceDescript(i, devpath, DevType, MachineId, ProcId, Addr);
  395. //printf(" devpath[%d]:%s\n Addr:%I64u\n", i, (const char*)devpath, Addr);
  396. if (FindSubString((const char*)devpath, pszKeystr))
  397. {
  398. return (const char*)devpath;
  399. }
  400. }
  401. }
  402. else
  403. {
  404. printf("Open local %s Failed\n", PathList[ProcIdx].c_str());
  405. }
  406. }
  407. }
  408. return "";
  409. }
  410. DCS_RET APlatformDcs::Procs(ResDataObject &Req)
  411. {
  412. return Procs_Func(Req, false);
  413. }
  414. DCS_RET APlatformDcs::Devs(ResDataObject &Req)
  415. {
  416. return Devs_Func(Req, false);
  417. }
  418. DCS_RET APlatformDcs::PrintDev(ResDataObject &Req)
  419. {
  420. if (Req.size() < 2)
  421. {
  422. printf("lack of params\n");
  423. return DCS_FAILED;
  424. }
  425. string rootname = (const char*)Req[1];
  426. CommonLogicClient buClient;
  427. buClient.SetRouter(CCOS_PACKET_ROUTE_LOCAL);
  428. if (buClient.Open(rootname.c_str(), ALL_ACCESS, 10000) == RET_SUCCEED)
  429. {
  430. ResDataObject DeviceRes;
  431. if (buClient.GetDeviceResource(&DeviceRes) >= RET_SUCCEED)
  432. {
  433. printf("DeviceResource:%s\n", DeviceRes.encode());
  434. }
  435. else
  436. {
  437. printf("Get DeviceResource:Failed\n");
  438. }
  439. buClient.Close();
  440. }
  441. else
  442. {
  443. printf("Open local %s Failed\n", rootname.c_str());
  444. }
  445. return DCS_SUCCEED;
  446. }
  447. DCS_RET APlatformDcs::Connect(ResDataObject &Req)
  448. {
  449. if (Req.size() <= 2)
  450. {
  451. printf("lack of params\n");
  452. return DCS_FAILED;
  453. }
  454. string rootname = (const char*)Req[1];
  455. //ResDataObject busid = getLocalEbusId();
  456. //if (busid == getChannelEbusId())
  457. //{
  458. // printf("This is Channel Proc.can't do the connection\n");
  459. // return DCS_FAILED;
  460. //}
  461. BusUnitClient buClient;
  462. buClient.SetRouter(CCOS_PACKET_ROUTE_LOCAL);
  463. if (buClient.Open(rootname.c_str(), ALL_ACCESS, 10000) == RET_SUCCEED)
  464. {
  465. if (buClient.SetEthBusRouterIp((const char *)(Req[2])) >= RET_SUCCEED && buClient.SetEthBusSwitch(1) >= RET_SUCCEED)
  466. {
  467. printf("Connect %s to %s Succeed.\n", (const char*)Req[1], (const char *)(Req[2]));
  468. }
  469. else
  470. {
  471. printf("Connect %s to %s Failed.\n", (const char*)Req[1], (const char *)(Req[2]));
  472. }
  473. buClient.Close();
  474. }
  475. else
  476. {
  477. printf("Open local %s Failed\n", rootname.c_str());
  478. }
  479. return DCS_SUCCEED;
  480. }
  481. DCS_RET APlatformDcs::Disconnect(ResDataObject &Req)
  482. {
  483. if (Req.size() <= 1)
  484. {
  485. printf("lack of params\n");
  486. return DCS_FAILED;
  487. }
  488. string rootname = (const char*)Req[1];
  489. BusUnitClient buClient;
  490. buClient.SetRouter(CCOS_PACKET_ROUTE_LOCAL);
  491. if (buClient.Open(rootname.c_str(), ALL_ACCESS, 10000) == RET_SUCCEED)
  492. {
  493. if (buClient.SetEthBusSwitch(0) >= RET_SUCCEED)
  494. {
  495. printf("Disconnect %s Succeed.\n", (const char*)Req[1]);
  496. }
  497. else
  498. {
  499. printf("Disconnect %s Failed.\n", (const char*)Req[1]);
  500. }
  501. buClient.Close();
  502. }
  503. else
  504. {
  505. printf("Open local %s Failed\n", rootname.c_str());
  506. }
  507. return DCS_SUCCEED;
  508. }
  509. DCS_RET APlatformDcs::RemoteProcs(ResDataObject &Req)
  510. {
  511. return Procs_Func(Req, true);
  512. }
  513. DCS_RET APlatformDcs::RemoteDevs(ResDataObject &Req)
  514. {
  515. return Devs_Func(Req, true);
  516. }
  517. DCS_RET APlatformDcs::CT(ResDataObject &Req)
  518. {
  519. if (Req.size() < 2)
  520. {
  521. printf("lack of params\n");
  522. return DCS_FAILED;
  523. }
  524. string devpath;
  525. devpath = "/";
  526. devpath += (const char *)Req[1];
  527. ResDataObject request, response;
  528. CommonLogicClient DevClient;
  529. DevClient.SetRouter(CCOS_PACKET_ROUTE_LOCAL);
  530. if (DevClient.Open((const char*)devpath.c_str(), ALL_ACCESS, 10000) >= RET_SUCCEED)
  531. {
  532. DevClient.Action("ExitDriverProc", request, response);
  533. DevClient.Close();
  534. }
  535. return DCS_SUCCEED;
  536. }
  537. DCS_RET APlatformDcs::Test(ResDataObject &Req)
  538. {
  539. //Test del[0] key[str]
  540. //Test add[1] key[str]
  541. ResDataObject NotifyData, ResNotify, ErrorInfo, tempInfo,Obj;
  542. tempInfo.add("CodeID", "");
  543. tempInfo.add("Type", "0");
  544. tempInfo.add("Level", "0");
  545. ErrorInfo.add(" ", tempInfo);
  546. ResNotify.add("{F3C37A69-0EF9-4E95-88AC-662F05D5103B}", ErrorInfo);
  547. Obj.add(CCOS_PACK_CONTEXT, (ResDataObject&)ResNotify);
  548. const char *pOut = (Obj.encode());
  549. printf("TestOutput:%s\n", pOut);
  550. return DCS_SUCCEED;
  551. char szMDPC[] = "MDPC/RF/Ecom/DRSIM/DrvObj/{399B143C-80F1-4D90-81D1-7C5CECC63EE8}";
  552. char szSUBDPC[] = "Generator/DR/ECOM/DEMO";
  553. char szSUBDEV[] = "Generator/DR/ECOM/Device";
  554. string devpath = Devs_Find(szMDPC, false);
  555. if (devpath.size() == 0)
  556. {
  557. printf("Target Mech Device not exist\n");
  558. return DCS_FAILED;
  559. }
  560. string Keystr = "1234";
  561. while(1)
  562. {
  563. CommonLogicClient DevClient;
  564. DevClient.SetRouter(CCOS_PACKET_ROUTE_LOCAL);
  565. if (DevClient.Open((const char*)devpath.c_str(), ALL_ACCESS, 10000) >= RET_SUCCEED)
  566. {
  567. ResDataObject request, response;
  568. for (size_t i = 0; i < 1000000; i++)
  569. {
  570. DevClient.CleanupQueue();
  571. DevClient.UpdateDeviceResource();
  572. //del dpc first
  573. request.add("P0", "{18FDF176-DECE-445F-A52C-A14BDD3AC2C1}");
  574. request.add("P1", Keystr.c_str());
  575. DevClient.Action("DelDPC", request, response);
  576. //add dpc
  577. request.clear(); response.clear();
  578. request.add("P0", "{18FDF176-DECE-445F-A52C-A14BDD3AC2C1}");
  579. request.add("P1", Keystr.c_str());
  580. if (DevClient.Action("AddDPC", request, response) < RET_SUCCEED)
  581. {
  582. printf("Failed AddDPC\n");
  583. break;
  584. }
  585. //confirm MDPC::DPC exist
  586. devpath = Devs_Find(szSUBDPC, false);
  587. if (devpath.size() == 0)
  588. {
  589. printf("Failed find MDPC::DPC\n");
  590. break;
  591. }
  592. //connect
  593. request.clear(); response.clear();
  594. if (DevClient.Action("Connect", request, response) < RET_SUCCEED)
  595. {
  596. printf("Failed Connenct\n");
  597. break;
  598. }
  599. //confirm MDPC::DPC::device exist
  600. devpath = Devs_Find(szSUBDEV, false);
  601. if (devpath.size() == 0)
  602. {
  603. printf("Failed find MDPC::DPC::DEVICE\n");
  604. break;
  605. }
  606. //for test
  607. Sleep(2000);
  608. //print devs
  609. ResDataObject ReqObj;
  610. Devs_Func(ReqObj, false);
  611. //disconnect
  612. request.clear(); response.clear();
  613. if (DevClient.Action("DisConnect", request, response) < RET_SUCCEED)
  614. {
  615. printf("Failed DisConnect\n");
  616. break;
  617. }
  618. //confirm MDPC::DPC::device gone
  619. //del dpc
  620. //request.add("P0", "{18FDF176-DECE-445F-A52C-A14BDD3AC2C1}");
  621. //request.add("P1", Keystr.c_str());
  622. //if (DevClient.Action("DelDPC", request, response) < RET_SUCCEED)
  623. //{
  624. // printf("DelDPC Failed\n");
  625. // break;
  626. //}
  627. //confirm MDPC::DPC gone
  628. //break;
  629. }
  630. DevClient.Close();
  631. }
  632. }
  633. return DCS_SUCCEED;
  634. }
  635. DCS_RET APlatformDcs::Action(ResDataObject &Req)
  636. {
  637. //Action ActionName param1[devpath]
  638. if (Req.size() < 3)
  639. {
  640. printf("lack of params\n");
  641. return DCS_FAILED;
  642. }
  643. CommonLogicClient DevClient;
  644. DevClient.SetRouter(CCOS_PACKET_ROUTE_LOCAL);
  645. ResDataObject request, response;
  646. if (DevClient.Open((const char*)Req[2], ALL_ACCESS, 10000) >= RET_SUCCEED)
  647. {
  648. request.clear();
  649. response.clear();
  650. if (DevClient.Action(Req[1], request, response) < RET_SUCCEED)
  651. {
  652. printf("Failed Action:%s\n", (const char *)Req[1]);
  653. }
  654. else
  655. {
  656. printf("Succeed Action:%s\n", (const char *)Req[1]);
  657. }
  658. DevClient.Close();
  659. return DCS_SUCCEED;
  660. }
  661. printf("can't open device:%s\n", (const char*)Req[1]);
  662. return DCS_FAILED;
  663. }
  664. DCS_RET APlatformDcs::Ctrlcpu(ResDataObject &Req)
  665. {
  666. char szCtrlDev[] = "/ccosAlpha/CtrlBox/Ccos/Ecom/Mech/1234/{7C5949CE-E47C-446C-8E66-F264A451BE78}";
  667. //3 param
  668. //Test CMDIDX ParamContext
  669. if (Req.size() < 3)
  670. {
  671. printf("lack of params\n");
  672. return DCS_FAILED;
  673. }
  674. //CMD
  675. //Ioctrl1:1
  676. //Ioctrl2:2
  677. //GetIO:3
  678. //Write:4
  679. //Read:5
  680. INT CMD = (INT)Req[1];
  681. ResDataObject Resource;
  682. ResDataObject request, response;
  683. CommonLogicClient DevClient;
  684. DevClient.SetRouter(CCOS_PACKET_ROUTE_LOCAL);
  685. if (DevClient.Open((const char*)szCtrlDev, ALL_ACCESS, 10000) >= RET_SUCCEED)
  686. {
  687. request.clear();
  688. response.clear();
  689. switch (CMD){
  690. case 1:
  691. if (Req.size() < 3)
  692. {
  693. printf("lack of params\n");
  694. return DCS_FAILED;
  695. }
  696. request.add("P0", (unsigned char)Req[1]);
  697. request.add("P1", (unsigned char)Req[2]);
  698. DevClient.Action("IOCTRL1", request, response);
  699. break;
  700. case 2:
  701. if (Req.size() < 4)
  702. {
  703. printf("lack of params\n");
  704. return DCS_FAILED;
  705. }
  706. request.add("P0", (unsigned char)Req[1]);
  707. request.add("P1", (unsigned char)Req[2]);
  708. request.add("P2", (unsigned char)Req[3]);
  709. DevClient.Action("IOCTRL2", request, response);
  710. break;
  711. case 3:
  712. if (Req.size() < 2)
  713. {
  714. printf("lack of params\n");
  715. return DCS_FAILED;
  716. }
  717. request.add("P0", (unsigned char)Req[1]);
  718. DevClient.Action("GETIO", request, response);
  719. break;
  720. case 4:
  721. if (Req.size() < 3)
  722. {
  723. printf("lack of params\n");
  724. return DCS_FAILED;
  725. }
  726. request.add("P0", (unsigned char)Req[1]);
  727. request.add("P1", (const char*)Req[2]);
  728. DevClient.Action("WRITE", request, response);
  729. break;
  730. case 5:
  731. if (Req.size() < 2)
  732. {
  733. printf("lack of params\n");
  734. return DCS_FAILED;
  735. }
  736. request.add("P0", (unsigned char)Req[1]);
  737. DevClient.Action("READ", request, response);
  738. break;
  739. default:
  740. printf("no match cmd\n");
  741. DevClient.Close();
  742. return DCS_SUCCEED;
  743. break;
  744. }
  745. DevClient.Close();
  746. }
  747. return DCS_SUCCEED;
  748. }
  749. DCS_RET APlatformDcs::MechTest(ResDataObject &Req)
  750. {
  751. //MechTest param1[1:Move,2:Rotate,3:Stop,4:Reset,5:DrTest,6:TomoTest] param2
  752. //char szCtrlDev[] = "CtrlBox/Ccos/Ecom/Mech/1234/{F868D8BA-9310-4A71-B21F-47DCF8836021}";
  753. //string devpath = Devs_Find(szCtrlDev, false);
  754. //if (devpath.size() == 0)
  755. //{
  756. // printf("Target Mech Device not exist\n");
  757. // return DCS_FAILED;
  758. //}
  759. ////3 param
  760. ////Test CMDIDX ParamContext
  761. //if (Req.size() < 3)
  762. //{
  763. // printf("lack of params\n");
  764. // return DCS_FAILED;
  765. //}
  766. //INT CMD = (INT)Req[1];
  767. //ResDataObject ExamDr;
  768. //ResDataObject ExamTomo;
  769. ////"RF":"Tomo" : "1"
  770. //ResDataObject ExamInfo;
  771. //ExamDr.add("Single", "1");
  772. //ExamTomo.add("TOMO", "1");
  773. //FLOAT Pos = 0;
  774. //ResDataObject Resource;
  775. //ResDataObject request, response;
  776. //CommonLogicClient DevClient;
  777. //DevClient.SetRouter(CCOS_PACKET_ROUTE_LOCAL);
  778. //if (DevClient.Open((const char*)devpath.c_str(), ALL_ACCESS, 10000) >= RET_SUCCEED)
  779. //{
  780. // request.clear();
  781. // response.clear();
  782. // switch (CMD){
  783. // case 1://Move
  784. // Pos = atof((const char*)Req[2]);
  785. // request.add("P0", Pos);
  786. // if (DevClient.Action("MoveMech", request, response,30000) < RET_SUCCEED)
  787. // {
  788. // printf("MoveMech Action Failed\n");
  789. // }
  790. // break;
  791. // case 2://Rotate
  792. // Pos = atof((const char*)Req[2]);
  793. // request.add("P0", Pos);
  794. // if (DevClient.Action("RotateMech", request, response, 30000) < RET_SUCCEED)
  795. // {
  796. // printf("RotateMech Action Failed\n");
  797. // }
  798. // break;
  799. // case 3://Stop
  800. // //request.add("P0", (FLOAT)Req[2]);
  801. // if (DevClient.Action("StopMech", request, response, 30000) < RET_SUCCEED)
  802. // {
  803. // printf("StopMech Action Failed\n");
  804. // }
  805. // break;
  806. // case 4://Reset
  807. // //request.add("P0", (FLOAT)Req[2]);
  808. // if (DevClient.Action("RESET", request, response, 30000) < RET_SUCCEED)
  809. // {
  810. // printf("RESET Action Failed\n");
  811. // }
  812. // break;
  813. // case 5://DrTest
  814. // ExamInfo.add("DX", ExamDr);
  815. // request.add("P0", ExamInfo);
  816. // if (DevClient.Action("SetExamInfo", request, response, 30000) < RET_SUCCEED)
  817. // {
  818. // printf("SetExamInfo Action Failed\n");
  819. // }
  820. // request.clear(); response.clear();
  821. // request.add("P0", "DX");
  822. // if (DevClient.Action("SelectExamMode", request, response, 30000) < RET_SUCCEED)
  823. // {
  824. // printf("SelectExamMode Action Failed\n");
  825. // }
  826. // request.clear(); response.clear();
  827. // if (DevClient.Action("ResetMech", request, response, 30000) < RET_SUCCEED)
  828. // {
  829. // printf("ResetMech Action Failed\n");
  830. // }
  831. // request.clear(); response.clear();
  832. // if (DevClient.Action("FramePrep", request, response, 30000) < RET_SUCCEED)
  833. // {
  834. // printf("FramePrep Action Failed\n");
  835. // }
  836. // request.clear(); response.clear();
  837. // if (DevClient.Action("FrameReady", request, response, 30000) < RET_SUCCEED)
  838. // {
  839. // printf("FramePrep Action Failed\n");
  840. // }
  841. // request.clear(); response.clear();
  842. // if (DevClient.Action("FrameStart", request, response, 30000) < RET_SUCCEED)
  843. // {
  844. // printf("FramePrep Action Failed\n");
  845. // }
  846. // request.clear(); response.clear();
  847. // if (DevClient.Action("FrameEnd", request, response, 30000) < RET_SUCCEED)
  848. // {
  849. // printf("FramePrep Action Failed\n");
  850. // }
  851. // request.clear(); response.clear();
  852. // if (DevClient.Action("FramePost", request, response, 30000) < RET_SUCCEED)
  853. // {
  854. // printf("FramePrep Action Failed\n");
  855. // }
  856. // break;
  857. // case 6://TomoTest
  858. // ExamInfo.add("DX", ExamTomo);
  859. // request.add("P0", ExamInfo);
  860. // if (DevClient.Action("SetExamInfo", request, response, 30000) < RET_SUCCEED)
  861. // {
  862. // printf("SetExamInfo Action Failed\n");
  863. // }
  864. // else
  865. // {
  866. // printf("SetExamInfo Action Succeed\n");
  867. // }
  868. // request.clear(); response.clear();
  869. // if (DevClient.Action("RESET", request, response, 30000) < RET_SUCCEED)
  870. // {
  871. // printf("RESET Action Failed\n");
  872. // }
  873. // else
  874. // {
  875. // printf("RESET Action Succeed\n");
  876. // }
  877. // request.clear(); response.clear();
  878. // request.add("P0", "DX");
  879. // if (DevClient.Action("SelectExamMode", request, response, 30000) < RET_SUCCEED)
  880. // {
  881. // printf("SelectExamMode Action Failed\n");
  882. // }
  883. // else
  884. // {
  885. // printf("SelectExamMode Action Succeed\n");
  886. // }
  887. // request.clear(); response.clear();
  888. // if (DevClient.Action("FramePrep", request, response, 30000) < RET_SUCCEED)
  889. // {
  890. // printf("FramePrep Action Failed\n");
  891. // }
  892. // else
  893. // {
  894. // printf("FramePrep Action Succeed\n");
  895. // }
  896. // request.clear(); response.clear();
  897. // if (DevClient.Action("FrameReady", request, response, 30000) < RET_SUCCEED)
  898. // {
  899. // printf("FrameReady Action Failed\n");
  900. // }
  901. // else
  902. // {
  903. // printf("FrameReady Action Succeed\n");
  904. // }
  905. // printf("Do HSW 1 or 2--------------\n");
  906. // break;
  907. // case 7:
  908. // Pos = atof((const char*)Req[2]);
  909. // request.add("P0", Pos);
  910. // if (DevClient.Action("BlindRotateMech", request, response, 30000) < RET_SUCCEED)
  911. // {
  912. // printf("RotateMech Action Failed\n");
  913. // }
  914. // break;
  915. // default:
  916. // printf("no match cmd\n");
  917. // DevClient.Close();
  918. // return DCS_SUCCEED;
  919. // break;
  920. // }
  921. // DevClient.Close();
  922. //}
  923. //else
  924. //{
  925. // printf("Open Device Failed.\nDev:%s\n", devpath.c_str());
  926. //}
  927. return DCS_SUCCEED;
  928. }
  929. DCS_RET APlatformDcs::Dap(ResDataObject &Req)
  930. {
  931. //Dap Param1[0:reset,1:setFilter,2:setSID,3:setColimatorSize,4:setkv,5:setma,6:setms,7:setmas,8:getdap] Param2[num]
  932. if (Req.size() < 3)
  933. {
  934. printf("lack of params\n");
  935. return DCS_FAILED;
  936. }
  937. //
  938. char szColimator[] = "DAP/DR/Adapter/V2/Device/{566EC9F1-CE5A-4B31-9D2A-E9E80B4CA0CC}";
  939. char szDap[] = "DAP/DR/Adapter/V2/Device/{DFCB1BE5-C0D7-411B-8DF3-57EA097923CB}";
  940. char szDpc[] = "DAP/DR/Adapter/V2/1234/{66888A95-CDBE-6CA6-B53F-86185E4B9C88}";
  941. string devpath = Devs_Find(szDpc, false);
  942. if (devpath.size() == 0)
  943. {
  944. printf("Target Driver not exist\n");
  945. return DCS_FAILED;
  946. }
  947. string dappath = Devs_Find(szDap, false);
  948. string colimatorpath = Devs_Find(szColimator, false);
  949. INT Filter = 0;
  950. FLOAT Pos = 0;
  951. INT CMD = (INT)Req[1];
  952. ResDataObject request, response;
  953. CommonLogicClient DevClient;
  954. CommonLogicClient DapClient;
  955. CommonLogicClient ColimatorClient;
  956. if (
  957. (DevClient.Open((const char*)devpath.c_str(), ALL_ACCESS, 10000) >= RET_SUCCEED) &&
  958. (DapClient.Open((const char*)dappath.c_str(), ALL_ACCESS, 10000) >= RET_SUCCEED) &&
  959. (ColimatorClient.Open((const char*)colimatorpath.c_str(), ALL_ACCESS, 10000) >= RET_SUCCEED)
  960. )
  961. {
  962. request.clear();
  963. response.clear();
  964. switch (CMD){
  965. case 0://ResetDap
  966. if (DapClient.Action("FramePrep", request, response, 30000) < RET_SUCCEED)
  967. {
  968. printf("FramePrep[ResetDap] Action Failed\n");
  969. }
  970. else
  971. {
  972. printf("FramePrep[ResetDap] succeed\n");
  973. }
  974. break;
  975. case 1://SetCollimatorFilter
  976. Filter = atoi((const char*)Req[2]);
  977. request.add("P0", Filter);
  978. if (ColimatorClient.Action("SetCollimatorFilter", request, response, 30000) < RET_SUCCEED)
  979. {
  980. printf("SetCollimatorFilter Action Failed\n");
  981. }
  982. else
  983. {
  984. printf("SetCollimatorFilter:%d succeed\n", Filter);
  985. }
  986. break;
  987. case 2://SetSID
  988. Filter = atoi((const char*)Req[2]);
  989. request.add("P0", Filter);
  990. if (ColimatorClient.Action("SetCollimatorSID", request, response, 30000) < RET_SUCCEED)
  991. {
  992. printf("SetCollimatorSID Action Failed\n");
  993. }
  994. else
  995. {
  996. printf("SetCollimatorSID:%d succeed\n", Filter);
  997. }
  998. break;
  999. case 3://SetCollimatorSize
  1000. Filter = atoi((const char*)Req[2]);
  1001. request.add("P0", Filter);
  1002. request.add("P1", Filter);
  1003. if (ColimatorClient.Action("SetCollimatorSize", request, response, 30000) < RET_SUCCEED)
  1004. {
  1005. printf("SetCollimatorSize Action Failed\n");
  1006. }
  1007. else
  1008. {
  1009. printf("SetCollimatorSize:%d succeed\n", Filter);
  1010. }
  1011. break;
  1012. case 4://SetKV
  1013. Pos = (FLOAT)atof((const char*)Req[2]);
  1014. request.add("P0", Pos);
  1015. if (DapClient.Action("SetValue_KV", request, response, 30000) < RET_SUCCEED)
  1016. {
  1017. printf("SetValue_KV Action Failed\n");
  1018. }
  1019. else
  1020. {
  1021. printf("SetValue_KV:%f succeed\n", Pos);
  1022. }
  1023. break;
  1024. case 5://SetMA
  1025. Pos = (FLOAT)atof((const char*)Req[2]);
  1026. request.add("P0", Pos);
  1027. if (DapClient.Action("SetValue_MA", request, response, 30000) < RET_SUCCEED)
  1028. {
  1029. printf("SetValue_MA Action Failed\n");
  1030. }
  1031. else
  1032. {
  1033. printf("SetValue_MA:%f Succeed.\n", (FLOAT)response["P0"]);
  1034. }
  1035. break;
  1036. case 6://SetMS
  1037. Pos = (FLOAT)atof((const char*)Req[2]);
  1038. request.add("P0", Pos);
  1039. if (DapClient.Action("SetValue_MS", request, response, 30000) < RET_SUCCEED)
  1040. {
  1041. printf("SetValue_MS Action Failed\n");
  1042. }
  1043. else
  1044. {
  1045. printf("SetValue_MS:%f Succeed.\n", (FLOAT)response["P0"]);
  1046. }
  1047. break;
  1048. case 7://SetMAS
  1049. Pos = (FLOAT)atof((const char*)Req[2]);
  1050. request.add("P0", Pos);
  1051. if (DapClient.Action("SetValue_MAS", request, response, 30000) < RET_SUCCEED)
  1052. {
  1053. printf("SetValue_MAS Action Failed\n");
  1054. }
  1055. else
  1056. {
  1057. printf("SetValue_MAS:%f Succeed.\n", (FLOAT)response["P0"]);
  1058. }
  1059. break;
  1060. case 8://GetDap
  1061. if (DapClient.Action("GetValue_DAP", request, response, 30000) < RET_SUCCEED)
  1062. {
  1063. printf("GetValue_DAP Action Failed\n");
  1064. }
  1065. else
  1066. {
  1067. printf("GetValue_DAP[%f] succeed\n", (FLOAT)response["P0"]);
  1068. }
  1069. break;
  1070. default:
  1071. printf("no match cmd\n");
  1072. return DCS_SUCCEED;
  1073. break;
  1074. }
  1075. }
  1076. else
  1077. {
  1078. printf("Open Device Failed.\nDev:%s\n", devpath.c_str());
  1079. }
  1080. return DCS_SUCCEED;
  1081. }
  1082. DCS_RET APlatformDcs::Gen(ResDataObject &Req)
  1083. {
  1084. char szDev[] = "Generator/DR/Adapter/V2/Device/{F5C377E6-5C3F-4A3C-9C5F-31295A0F7104}";
  1085. char szSeqDev[] = "Generator/DR/Adapter/V2/Device/{3BEA33D7-9F86-8F34-C890-F2596546C005}";
  1086. string devpath = Devs_Find(szDev, false);
  1087. string Seqdevpath = Devs_Find(szSeqDev, false);
  1088. if (devpath.size() == 0 || Seqdevpath.size() == 0)
  1089. {
  1090. printf("Target Mech Device not exist\n");
  1091. return DCS_FAILED;
  1092. }
  1093. ////3 param
  1094. ////Test CMDIDX ParamContext
  1095. if (Req.size() < 3)
  1096. {
  1097. printf("lack of params\n");
  1098. return DCS_FAILED;
  1099. }
  1100. INT CMD = (INT)Req[1];
  1101. //ResDataObject ExamDr;
  1102. //ResDataObject ExamTomo;
  1103. ////"RF":"Tomo" : "1"
  1104. //ResDataObject ExamInfo;
  1105. //ExamDr.add("Single", "1");
  1106. //ExamTomo.add("TOMO", "1");
  1107. FLOAT Pos = 0;
  1108. //ResDataObject Resource;
  1109. ResDataObject request, response;
  1110. CommonLogicClient DevClient;
  1111. CommonLogicClient SeqClient;
  1112. DevClient.SetRouter(CCOS_PACKET_ROUTE_LOCAL);
  1113. SeqClient.SetRouter(CCOS_PACKET_ROUTE_LOCAL);
  1114. if (SeqClient.Open((const char*)Seqdevpath.c_str(), ALL_ACCESS, 10000) < RET_SUCCEED)
  1115. {
  1116. printf("Open Device Failed.\nDev:%s\n", Seqdevpath.c_str());
  1117. return DCS_FAILED;
  1118. }
  1119. if (DevClient.Open((const char*)devpath.c_str(), ALL_ACCESS, 10000) >= RET_SUCCEED)
  1120. {
  1121. request.clear();
  1122. response.clear();
  1123. switch (CMD){
  1124. case 1://SetKV
  1125. Pos = (FLOAT)atof((const char*)Req[2]);
  1126. request.add("P0", Pos);
  1127. if (DevClient.Action("SetValue_KV", request, response,30000) < RET_SUCCEED)
  1128. {
  1129. printf("SetValue_KV Action Failed\n");
  1130. }
  1131. else
  1132. {
  1133. printf("SetValue_KV:%f succeed\n", Pos);
  1134. }
  1135. break;
  1136. case 2://GetKV
  1137. if (DevClient.Action("GetValue_KV", request, response, 30000) < RET_SUCCEED)
  1138. {
  1139. printf("GetValue_KV Action Failed\n");
  1140. }
  1141. else
  1142. {
  1143. printf("GetValue_KV:%f Succeed.\n", (FLOAT)response["P0"]);
  1144. }
  1145. break;
  1146. case 3://IncKV
  1147. if (DevClient.Action("IncParam_KV", request, response, 30000) < RET_SUCCEED)
  1148. {
  1149. printf("IncParam_KV Action Failed\n");
  1150. }
  1151. else
  1152. {
  1153. printf("IncParam_KV Action Succeed\n");
  1154. }
  1155. break;
  1156. case 4://DecKV
  1157. if (DevClient.Action("DecParam_KV", request, response, 30000) < RET_SUCCEED)
  1158. {
  1159. printf("DecParam_KV Action Failed\n");
  1160. }
  1161. else
  1162. {
  1163. printf("DecParam_KV Action Succeed\n");
  1164. }
  1165. break;
  1166. case 5://SetMAS
  1167. Pos = (FLOAT)atof((const char*)Req[2]);
  1168. request.add("P0", Pos);
  1169. if (DevClient.Action("SetValue_MAS", request, response, 30000) < RET_SUCCEED)
  1170. {
  1171. printf("SetValue_MAS Action Failed\n");
  1172. }
  1173. else
  1174. {
  1175. printf("SetValue_MAS:%f succeed\n", Pos);
  1176. }
  1177. break;
  1178. case 6://GetMAS
  1179. if (DevClient.Action("GetValue_MAS", request, response, 30000) < RET_SUCCEED)
  1180. {
  1181. printf("GetValue_MAS Action Failed\n");
  1182. }
  1183. else
  1184. {
  1185. printf("GetValue_MAS:%f Succeed.\n", (FLOAT)response["P0"]);
  1186. }
  1187. break;
  1188. case 7://IncMAS
  1189. if (DevClient.Action("IncParam_MAS", request, response, 30000) < RET_SUCCEED)
  1190. {
  1191. printf("IncParam_MAS Action Failed\n");
  1192. }
  1193. else
  1194. {
  1195. printf("IncParam_MAS Action Succeed\n");
  1196. }
  1197. break;
  1198. case 8://DecMAS
  1199. if (DevClient.Action("DecParam_MAS", request, response, 30000) < RET_SUCCEED)
  1200. {
  1201. printf("DecParam_MAS Action Failed\n");
  1202. }
  1203. else
  1204. {
  1205. printf("DecParam_MAS Action Succeed\n");
  1206. }
  1207. break;
  1208. case 9://SetFocus
  1209. request.add("P0", (const char*)Req[2]);
  1210. if (DevClient.Action("SetValue_FOCUS", request, response, 30000) < RET_SUCCEED)
  1211. {
  1212. printf("SetValue_FOCUS Action Failed\n");
  1213. }
  1214. else
  1215. {
  1216. printf("SetValue_FOCUS Action Succeed\n");
  1217. }
  1218. break;
  1219. case 10://exp status
  1220. if ((INT)Req[2] != 0)
  1221. {
  1222. //exp enable
  1223. if (SeqClient.Action("FrameReady", request, response, 30000) < RET_SUCCEED)
  1224. {
  1225. printf("EnableExp Action Failed\n");
  1226. }
  1227. else
  1228. {
  1229. printf("EnableExp Action Succeed\n");
  1230. }
  1231. }
  1232. else
  1233. {
  1234. //exp disable
  1235. if (SeqClient.Action("FrameOut", request, response, 30000) < RET_SUCCEED)
  1236. {
  1237. printf("DisableExp Action Failed\n");
  1238. }
  1239. else
  1240. {
  1241. printf("DisableExp Action Succeed\n");
  1242. }
  1243. }
  1244. break;
  1245. default:
  1246. printf("no match cmd\n");
  1247. DevClient.Close();
  1248. return DCS_SUCCEED;
  1249. break;
  1250. }
  1251. DevClient.Close();
  1252. }
  1253. else
  1254. {
  1255. printf("Open Device Failed.\nDev:%s\n", devpath.c_str());
  1256. }
  1257. SeqClient.Close();
  1258. return DCS_SUCCEED;
  1259. }
  1260. DCS_RET APlatformDcs::FDacq(ResDataObject &Req)
  1261. {
  1262. char szSync[] = "Detector/DRDevice/Trixell/Pixium/3543EZe/{55C509AD-02C8-4E18-8509-B0C6E736936B}";
  1263. char szAcq[] = "Detector/DRDevice/Trixell/Pixium/3543EZe/{65608C98-C66B-4CC4-8C1F-8C616FFE4CC2}";
  1264. string Acqpath = Devs_Find(szAcq, false);
  1265. string Syncpath = Devs_Find(szSync, false);
  1266. if (Acqpath.size() == 0 || Syncpath.size() == 0)
  1267. {
  1268. printf("Target Mech Device not exist\n");
  1269. return DCS_FAILED;
  1270. }
  1271. if (Req.size() < 3)
  1272. {
  1273. printf("lack of params\n");
  1274. return DCS_FAILED;
  1275. }
  1276. INT AcqMode = (INT)Req[1];
  1277. INT Xwindow = (INT)Req[2];
  1278. ResDataObject request, response;
  1279. CommonLogicClient SyncClient;
  1280. CommonLogicClient AcqClient;
  1281. SyncClient.SetRouter(CCOS_PACKET_ROUTE_LOCAL);
  1282. AcqClient.SetRouter(CCOS_PACKET_ROUTE_LOCAL);
  1283. if (AcqClient.Open((const char*)Acqpath.c_str(), ALL_ACCESS, 10000) >= RET_SUCCEED)
  1284. {
  1285. request.add("P0", AcqMode);
  1286. if (AcqClient.Action("SetAcqMode", request, response, 30000) < RET_SUCCEED)
  1287. {
  1288. printf("SetAcqMode Action Failed\n");
  1289. }
  1290. else
  1291. {
  1292. printf("SetAcqMode succeed\n");
  1293. }
  1294. AcqClient.Close();
  1295. }
  1296. else
  1297. {
  1298. printf("Open Device Failed.\nDev:%s\n", Acqpath.c_str());
  1299. }
  1300. if (SyncClient.Open((const char*)Syncpath.c_str(), ALL_ACCESS, 10000) >= RET_SUCCEED)
  1301. {
  1302. if (SyncClient.Action("EnterExam", request, response, 30000) < RET_SUCCEED)
  1303. {
  1304. printf("EnterExam Action Failed\n");
  1305. }
  1306. else
  1307. {
  1308. printf("EnterExam succeed\n");
  1309. }
  1310. request.add("P0", Xwindow);
  1311. if (SyncClient.Action("SetXwindowSize", request, response, 30000) < RET_SUCCEED)
  1312. {
  1313. printf("SetXwindowSize Action Failed\n");
  1314. }
  1315. else
  1316. {
  1317. printf("EnterExam succeed\n");
  1318. }
  1319. if (SyncClient.Action("PrepareAcquisition", request, response, 30000) < RET_SUCCEED)
  1320. {
  1321. printf("PrepareAcquisition Action Failed\n");
  1322. return DCS_FAILED;
  1323. }
  1324. else
  1325. {
  1326. printf("PrepareAcquisition succeed\n");
  1327. }
  1328. if (SyncClient.Action("StartAcquisition", request, response, 30000) < RET_SUCCEED)
  1329. {
  1330. printf("StartAcquisition Action Failed\n");
  1331. return DCS_FAILED;
  1332. }
  1333. else
  1334. {
  1335. printf("StartAcquisition succeed\n");
  1336. }
  1337. if (SyncClient.Action("StopAcquisition", request, response, 30000) < RET_SUCCEED)
  1338. {
  1339. printf("StopAcquisition Action Failed\n");
  1340. return DCS_FAILED;
  1341. }
  1342. else
  1343. {
  1344. printf("StopAcquisition succeed\n");
  1345. }
  1346. if (SyncClient.Action("ExitExam", request, response, 30000) < RET_SUCCEED)
  1347. {
  1348. printf("ExitExam Action Failed\n");
  1349. return DCS_FAILED;
  1350. }
  1351. else
  1352. {
  1353. printf("ExitExam succeed\n");
  1354. }
  1355. SyncClient.Close();
  1356. }
  1357. else
  1358. {
  1359. printf("Open Device Failed.\nDev:%s\n", Syncpath.c_str());
  1360. }
  1361. return DCS_SUCCEED;
  1362. }
  1363. DCS_RET APlatformDcs::FDcalib(ResDataObject &Req)
  1364. {
  1365. char szDev[] = "Detector/DRDevice/Trixell/Pixium/3543EZe/{BE83E2F7-AB62-421C-BC2E-0C40BEEACCFB}";
  1366. string devpath = Devs_Find(szDev, false);
  1367. if (devpath.size() == 0)
  1368. {
  1369. printf("Target Mech Device not exist\n");
  1370. return DCS_FAILED;
  1371. }
  1372. ResDataObject request, response;
  1373. CommonLogicClient DevClient;
  1374. DevClient.SetRouter(CCOS_PACKET_ROUTE_LOCAL);
  1375. if (DevClient.Open((const char*)devpath.c_str(), ALL_ACCESS, 10000) >= RET_SUCCEED)
  1376. {
  1377. request.add("P0", 1);
  1378. if (DevClient.Action("ActiveCalibration", request, response, 30000) < RET_SUCCEED)
  1379. {
  1380. printf("ActiveCalibration Action Failed\n");
  1381. return DCS_FAILED;
  1382. }
  1383. else
  1384. {
  1385. printf("ActiveCalibration succeed\n");
  1386. }
  1387. if (DevClient.Action("GetRequestedDose", request, response, 30000) < RET_SUCCEED)
  1388. {
  1389. printf("GetRequestedDose Action Failed\n");
  1390. return DCS_FAILED;
  1391. }
  1392. else
  1393. {
  1394. printf("GetRequestedDose succeed\n");
  1395. printf("%s", response.encode());
  1396. }
  1397. if (DevClient.Action("PrepareCalibration", request, response, 30000) < RET_SUCCEED)
  1398. {
  1399. printf("PrepareCalibration Action Failed\n");
  1400. return DCS_FAILED;
  1401. }
  1402. else
  1403. {
  1404. printf("PrepareCalibration succeed\n");
  1405. }
  1406. if (DevClient.Action("StartCalibration", request, response, 30000) < RET_SUCCEED)
  1407. {
  1408. printf("StartCalibration Action Failed\n");
  1409. return DCS_FAILED;
  1410. }
  1411. else
  1412. {
  1413. printf("StartCalibration succeed\n");
  1414. }
  1415. if (DevClient.Action("StopCalibration", request, response, 30000) < RET_SUCCEED)
  1416. {
  1417. printf("StopCalibration Action Failed\n");
  1418. return DCS_FAILED;
  1419. }
  1420. else
  1421. {
  1422. printf("StopCalibration succeed\n");
  1423. }
  1424. DevClient.Close();
  1425. }
  1426. else
  1427. {
  1428. printf("Open Device Failed.\nDev:%s\n", devpath.c_str());
  1429. }
  1430. return DCS_SUCCEED;
  1431. }
  1432. DCS_RET APlatformDcs::AddDPC(ResDataObject &Req)
  1433. {
  1434. char szDev[] = "MDPC/RF/Ecom/RFSIM/Demo/{399B143C-80F1-4D90-81D1-7C5CECC63EE8}";
  1435. #define DetectorID ("{18CAB88A-C61C-4BB2-AC28-184FDD4FD160}")
  1436. string devpath = Devs_Find(szDev, false);
  1437. if (devpath.size() == 0)
  1438. {
  1439. printf("Target Mech Device not exist\n");
  1440. return DCS_FAILED;
  1441. }
  1442. ////3 param
  1443. ////Test CMDIDX ParamContext
  1444. if (Req.size() < 3)
  1445. {
  1446. printf("lack of params : %s\n",Req.encode());
  1447. return DCS_FAILED;
  1448. }
  1449. string CMD = (string)Req[1];
  1450. ResDataObject request, response;
  1451. CommonLogicClient DevClient;
  1452. DevClient.SetRouter(CCOS_PACKET_ROUTE_LOCAL);
  1453. if (DevClient.Open((const char*)devpath.c_str(), ALL_ACCESS, 10000) >= RET_SUCCEED)
  1454. {
  1455. request.clear();
  1456. response.clear();
  1457. request.add("P0", DetectorID);
  1458. request.add("P1", CMD.c_str());
  1459. if (DevClient.Action("AddDPC", request, response, 30000) < RET_SUCCEED)
  1460. {
  1461. printf("AddDPC Action Failed\n");
  1462. }
  1463. else
  1464. {
  1465. printf("AddDPC:%s succeed\n", CMD.c_str());
  1466. }
  1467. DevClient.Close();
  1468. }
  1469. else
  1470. {
  1471. printf("Open Device Failed.\nDev:%s\n", devpath.c_str());
  1472. }
  1473. return DCS_SUCCEED;
  1474. }
  1475. DCS_RET APlatformDcs::DelDPC(ResDataObject &Req)
  1476. {
  1477. char szDev[] = "MDPC/RF/Ecom/RFSIM/Demo/{399B143C-80F1-4D90-81D1-7C5CECC63EE8}";
  1478. #define DetectorID ("{18CAB88A-C61C-4BB2-AC28-184FDD4FD160}")
  1479. string devpath = Devs_Find(szDev, false);
  1480. if (devpath.size() == 0)
  1481. {
  1482. printf("Target Mech Device not exist\n");
  1483. return DCS_FAILED;
  1484. }
  1485. ////3 param
  1486. ////Test CMDIDX ParamContext
  1487. if (Req.size() < 3)
  1488. {
  1489. printf("lack of params\n");
  1490. return DCS_FAILED;
  1491. }
  1492. string CMD = (string)Req[1];
  1493. ResDataObject request, response;
  1494. CommonLogicClient DevClient;
  1495. DevClient.SetRouter(CCOS_PACKET_ROUTE_LOCAL);
  1496. if (DevClient.Open((const char*)devpath.c_str(), ALL_ACCESS, 10000) >= RET_SUCCEED)
  1497. {
  1498. request.clear();
  1499. response.clear();
  1500. request.add("P0", DetectorID);
  1501. request.add("P1", CMD.c_str());
  1502. if (DevClient.Action("DelDPC", request, response, 30000) < RET_SUCCEED)
  1503. {
  1504. printf("DelDPC Action Failed\n");
  1505. }
  1506. else
  1507. {
  1508. printf("DelDPC:%s succeed\n", CMD.c_str());
  1509. }
  1510. DevClient.Close();
  1511. }
  1512. else
  1513. {
  1514. printf("Open Device Failed.\nDev:%s\n", devpath.c_str());
  1515. }
  1516. return DCS_SUCCEED;
  1517. }
  1518. DCS_RET APlatformDcs::ConfigDriver(ResDataObject &Req)
  1519. {
  1520. //ConfigDriver param1[0:del,1:add,2:ShowAll] param2[driverpath]
  1521. if (Req.size() < 3)
  1522. {
  1523. printf("lack of params\n");
  1524. return DCS_FAILED;
  1525. }
  1526. ResDataObject req, res;
  1527. INT ActionType = (INT)Req[1];
  1528. string driverpath = (const char*)Req[2];
  1529. if (ActionType == 0)
  1530. {
  1531. //del
  1532. CommonLogicClient Client;
  1533. Client.SetRouter(CCOS_PACKET_ROUTE_LOCAL);
  1534. if (Client.Open("/ccosChannel", ALL_ACCESS, 10000) == RET_SUCCEED)
  1535. {
  1536. req.add("P0", driverpath.c_str());
  1537. if (Client.Action("ConfigRemoveDriver", req, res) >= RET_SUCCEED)
  1538. {
  1539. printf("ConfigRemoveDriver %s Succeed.\n", driverpath.c_str());
  1540. }
  1541. else
  1542. {
  1543. printf("ConfigRemoveDriver %s Failed.\n", driverpath.c_str());
  1544. }
  1545. Client.Close();
  1546. }
  1547. else
  1548. {
  1549. printf("Open local /ccosChannel Failed\n");
  1550. }
  1551. }
  1552. else if (ActionType == 1)
  1553. {
  1554. //add
  1555. CommonLogicClient Client;
  1556. Client.SetRouter(CCOS_PACKET_ROUTE_LOCAL);
  1557. if (Client.Open("/ccosChannel", ALL_ACCESS, 10000) == RET_SUCCEED)
  1558. {
  1559. req.add("P0", driverpath.c_str());
  1560. if (Client.Action("ConfigLoadDriver", req, res) >= RET_SUCCEED)
  1561. {
  1562. printf("ConfigLoadDriver %s Succeed.\n", driverpath.c_str());
  1563. }
  1564. else
  1565. {
  1566. printf("ConfigLoadDriver %s Failed.\n", driverpath.c_str());
  1567. }
  1568. Client.Close();
  1569. }
  1570. else
  1571. {
  1572. printf("Open local /ccosChannel Failed\n");
  1573. }
  1574. }
  1575. else if (ActionType == 2)
  1576. {
  1577. ResDataObject DevResource;
  1578. //showall
  1579. CommonLogicClient Client;
  1580. Client.SetRouter(CCOS_PACKET_ROUTE_LOCAL);
  1581. if (Client.Open("/ccosChannel", ALL_ACCESS, 10000) == RET_SUCCEED)
  1582. {
  1583. Client.GetDeviceResource(&DevResource);
  1584. Client.Close();
  1585. try{
  1586. printf("%s\n", DevResource.encode());
  1587. ResDataObject FulDrvList, ConfigDrvList;
  1588. FulDrvList = DevResource["Attribute"]["FullDriverList"];
  1589. ConfigDrvList = DevResource["Attribute"]["ConfigDriverList"];
  1590. printf("Full Driver List\n");
  1591. for (size_t i = 0; i < FulDrvList.size(); i++)
  1592. {
  1593. printf("FullDriver[%zu]:%s\n", i, (const char *)FulDrvList.GetKey(i));
  1594. }
  1595. printf("\nConfig Driver List\n");
  1596. for (size_t i = 0; i < ConfigDrvList.size(); i++)
  1597. {
  1598. printf("ConfigDriver[%zu]:%s\n", i, (const char *)ConfigDrvList.GetKey(i));
  1599. }
  1600. printf("\n");
  1601. return DCS_SUCCEED;
  1602. }
  1603. catch (...)
  1604. {
  1605. }
  1606. }
  1607. else
  1608. {
  1609. printf("Open local /ccosChannel Failed\n");
  1610. }
  1611. }
  1612. else
  1613. {
  1614. //ignore
  1615. printf("Wrong Type ActionRequest:%d\n", ActionType);
  1616. return DCS_FAILED;
  1617. }
  1618. return DCS_SUCCEED;
  1619. }
  1620. //
  1621. //DCS_RET APlatformDcs::WorkFlowTest(ResDataObject &Req)
  1622. //{
  1623. // CommonLogicClient Client, fpdClient;
  1624. // int nRet;
  1625. // const char* szPathSubsys = "/DevSubSystem/Subsystem/Rf/ecomdemo/demo/1234/{60E2EAAB-0757-4CF3-A547-F0C0A8167359}";
  1626. // const char* szPathRFFpd = "/DevFPD/Detector/RF/ecomdemo/demo/1C70642C/{18CAB88A-C61C-4BB2-AC28-184FDD4FD160}";
  1627. //
  1628. // if (Req.size() < 2)
  1629. // {
  1630. // printf("lack of params\n");
  1631. // return DCS_FAILED;
  1632. // }
  1633. //
  1634. // INT CMD = (INT)Req[1];
  1635. //
  1636. // switch (CMD)
  1637. // {
  1638. // case 1:
  1639. // nRet = Client.Open(szPathSubsys, ALL_ACCESS);
  1640. // printf("Open return %i\n", nRet);
  1641. // if (nRet == RET_SUCCEED)
  1642. // {
  1643. // printf("Open subsystem Device ok\n");
  1644. // ResDataObject Request, Res;
  1645. // nRet = Client.Action("ActivateSubsystem", Request, Res);
  1646. // Request.add("P0", "Table");
  1647. // nRet = Client.Action("SetWorkStation", Request, Res);
  1648. // printf("SetWorkStation return %i\n", nRet);
  1649. // //Sleep(1000);
  1650. // WFTWaitForState(Client, "WorkStation", "");
  1651. // Request.clear();
  1652. // nRet = Client.Action("StartSMMachine", Request, Res);
  1653. // printf("StartSMMachine return %i\n", nRet);
  1654. //
  1655. // //Sleep(1000);
  1656. // WFTWaitForState(Client, "CurrentSMState", "SeqReady");
  1657. // ResDataObject res1, res2, res3, res4, res0, resparam;
  1658. // resparam.clear();
  1659. // resparam.add("P0", 1);
  1660. // res1.add("SetAcqMode", resparam);
  1661. // res2.add("{65608C98-C66B-4CC4-8C1F-8C616FFE4CC2}", res1);
  1662. // //res2.add("", "");
  1663. // res3.add("FramePrep", res2);
  1664. //
  1665. // resparam.clear();
  1666. // res1.clear();
  1667. // res2.clear();
  1668. // resparam.add("P0", "DX");
  1669. // res1.add("SetModality", resparam);
  1670. // res3["FramePrep"].add("{BDDF7891-3C15-4191-98F5-F4A9918B2872}", res1);
  1671. // //res3.add("FramePrep", res2);
  1672. // res0.add("SMOuter", res3);
  1673. //
  1674. //
  1675. // res1.clear();
  1676. // res2.clear();
  1677. // res1.add("StartAcquisition", "");
  1678. // //res2.add("{18CAB88A-C61C-4BB2-AC28-184FDD4FD160}", res1);
  1679. // res2.add("{55C509AD-02C8-4E18-8509-B0C6E736936B}", res1);
  1680. // res4.add("FrameStart", res2);
  1681. //
  1682. // res1.clear();
  1683. // res2.clear();
  1684. // resparam.clear();
  1685. // resparam.add("P0", 3);
  1686. // res1.add("SetGeneratortoSyncStatus", resparam);
  1687. // res2.add("{3BEA33D7-9F86-8F34-C890-F2596546C005}", res1);
  1688. // res4.add("FrameIn", res2);
  1689. //
  1690. // res1.clear();
  1691. // res2.clear();
  1692. // resparam.clear();
  1693. // resparam.add("P0", 4);
  1694. // res1.add("SetGeneratortoSyncStatus", resparam);
  1695. // res2.add("{3BEA33D7-9F86-8F34-C890-F2596546C005}", res1);
  1696. // res4.add("FrameOut", res2);
  1697. //
  1698. // res1.clear();
  1699. // res2.clear();
  1700. // res1.add("StopAcquisition", "");
  1701. // res2.add("{55C509AD-02C8-4E18-8509-B0C6E736936B}", res1);
  1702. // //res2.add("{18CAB88A-C61C-4BB2-AC28-184FDD4FD160}", res1);
  1703. // res4.add("FrameEnd", res2);
  1704. //
  1705. // res0.add("SMFrameAcquiring", res4);
  1706. //
  1707. // Request.clear();
  1708. // Res.clear();
  1709. // Request.add("P0", res0);
  1710. // nRet = Client.Action("SetSEQResourceAction", Request, Res);
  1711. // printf("-----SetSEQResourceAction return %i\n", nRet);
  1712. //
  1713. // // events
  1714. // res0.clear();
  1715. //
  1716. // res1.clear();
  1717. // res2.clear();
  1718. // res3.clear();
  1719. // res3.add("Need", "1");
  1720. // res3.add("ReadFromAttribute", "0");
  1721. // res0.add("EvtFramePrep", res3);
  1722. //
  1723. // res1.clear();
  1724. // res2.clear();
  1725. // res3.clear();
  1726. // res3.add("Need", "1");
  1727. // res3.add("ReadFromAttribute", "0");
  1728. // res1.add("GENERATORSYNCSTATE", "2");
  1729. // res3.add("{3BEA33D7-9F86-8F34-C890-F2596546C005}", res1);
  1730. // res0.add("EvtExpOn", res3);
  1731. //
  1732. // res1.clear();
  1733. // res2.clear();
  1734. // res3.clear();
  1735. // res3.add("Need", "1");
  1736. // res3.add("ReadFromAttribute", "0");
  1737. // res1.add("DETECTORSTATUS", "5");
  1738. // res3.add("{55C509AD-02C8-4E18-8509-B0C6E736936B}", res1);
  1739. // res0.add("EvtFrameAcq", res3);
  1740. //
  1741. // res1.clear();
  1742. // res2.clear();
  1743. // res3.clear();
  1744. // res3.add("Need", "1");
  1745. // res3.add("ReadFromAttribute", "0");
  1746. // res1.add("XWINDOWSTATUS", "1");
  1747. // res3.add("{55C509AD-02C8-4E18-8509-B0C6E736936B}", res1);
  1748. // res0.add("EvtXwinOn", res3);
  1749. //
  1750. // res1.clear();
  1751. // res2.clear();
  1752. // res3.clear();
  1753. // res3.add("Need", "1");
  1754. // res3.add("ReadFromAttribute", "0");
  1755. // res1.add("XWINDOWSTATUS", "0");
  1756. // res3.add("{55C509AD-02C8-4E18-8509-B0C6E736936B}", res1);
  1757. // res0.add("EvtXwinOff", res3);
  1758. //
  1759. // res1.clear();
  1760. // res2.clear();
  1761. // res3.clear();
  1762. // res3.add("Need", "1");
  1763. // res3.add("ReadFromAttribute", "0");
  1764. // res1.add("GENERATORSYNCSTATE", "3");
  1765. // res3.add("{3BEA33D7-9F86-8F34-C890-F2596546C005}", res1);
  1766. // res0.add("EvtXrayOut", res3);
  1767. //
  1768. // res1.clear();
  1769. // res2.clear();
  1770. // res3.clear();
  1771. // res3.add("Need", "1");
  1772. // res3.add("ReadFromAttribute", "0");
  1773. // res1.add("DETECTORSTATUS", "4");
  1774. // res3.add("{55C509AD-02C8-4E18-8509-B0C6E736936B}", res1);
  1775. // res0.add("EvtEndAcq", res3);
  1776. //
  1777. // res1.clear();
  1778. // res2.clear();
  1779. // res3.clear();
  1780. // res3.add("Need", "1");
  1781. // res3.add("ReadFromAttribute", "0");
  1782. // res1.add("GENERATORSYNCSTATE", "0");
  1783. // res3.add("{3BEA33D7-9F86-8F34-C890-F2596546C005}", res1);
  1784. // res0.add("EvtFrameStandby", res3);
  1785. //
  1786. // res1.clear();
  1787. // res2.clear();
  1788. // res3.clear();
  1789. // res3.add("Need", "0");
  1790. // res3.add("ReadFromAttribute", "0");
  1791. // res0.add("EvtEndPost", res3);
  1792. //
  1793. // res1.clear();
  1794. // res2.clear();
  1795. // res3.clear();
  1796. // res3.add("Need", "1");
  1797. // res3.add("ReadFromAttribute", "0");
  1798. // res0.add("EvtFrameError", res3);
  1799. //
  1800. // res1.clear();
  1801. // res2.clear();
  1802. // res3.clear();
  1803. // res3.add("Need", "1");
  1804. // res3.add("ReadFromAttribute", "0");
  1805. // res0.add("EvtFrameRecover", res3);
  1806. //
  1807. // res1.clear();
  1808. // res2.clear();
  1809. // res3.clear();
  1810. // res3.add("Need", "1");
  1811. // res3.add("ReadFromAttribute", "0");
  1812. // res0.add("EvtSeqEnd", res3);
  1813. //
  1814. // Res.clear();
  1815. // Request.clear();
  1816. // Request.add("P0", res0);
  1817. // nRet = Client.Action("SetSEQResourceEvent", Request, Res);
  1818. // printf("-----SetSEQResourceEvent return %i\n", nRet);
  1819. //
  1820. // res1.clear();
  1821. // res2.clear();
  1822. // res3.clear();
  1823. // res1.add("Sensitivity", "Sensitivity");
  1824. // res1.add("DetectorElementPhysicalSize", "PixelSpacing");
  1825. // res1.add("DetectorElementSpacing", "PixelSpacing");
  1826. // res1.add("DetectorActiveShape", "DetectorActiveShape");
  1827. // res1.add("DetectorActiveDimension", "DetectorActiveDimension");
  1828. // res1.add("DetectorActiveOrigin", "DetectorActiveOrigin");
  1829. // res1.add("LossyImageCompression", "LossyImageCompression");
  1830. // res1.add("RescaleType", "RescaleType");
  1831. // res1.add("PixelIntensityRelationship", "PixelIntensityRelationship");
  1832. // res1.add("FPDCoef", "FPDCoef");
  1833. // res2.add("{18CAB88A-C61C-4BB2-AC28-184FDD4FD160}", res1);
  1834. // res3.add("ImgHeader", res2);
  1835. //
  1836. // res1.clear();
  1837. // res2.clear();
  1838. // res1.add("KVP", "KV");
  1839. // res1.add("XRayTubeCurrent", "MA");
  1840. // res1.add("ExposureTime", "MS");
  1841. // res1.add("ExposureTimeinms", "MS");
  1842. // res1.add("Exposure", "DetectorActiveDimension");
  1843. // res1.add("ExposureinmAs", "DetectorActiveOrigin");
  1844. // res1.add("FocusSpot", "LossyImageCompression");
  1845. // res2.add("{F5C377E6-5C3F-4A3C-9C5F-31295A0F7104}", res1);
  1846. // res3.add("FrameHeader", res2);
  1847. //
  1848. // Request.clear();
  1849. // Res.clear();
  1850. // Request.add("P0", res3);
  1851. // Client.Action("SetECMInfo", Request, Res);
  1852. //
  1853. //
  1854. // // TriggerEventSMMachine EvtFramePrep
  1855. // Request.clear();
  1856. // Request.add("P0", "EvtFramePrep");
  1857. // Res.clear();
  1858. // nRet = Client.Action("TriggerEventSMMachine", Request, Res);
  1859. // printf("-----TriggerEventSMMachine return %i\n", nRet);
  1860. //
  1861. // Sleep(500);
  1862. // Client.Close();
  1863. // printf("-- Test step done --\n");
  1864. // return DCS_SUCCEED;
  1865. //
  1866. // }
  1867. //
  1868. // printf("Open subsystem Device failed\n");
  1869. // return DCS_FAILED;
  1870. //
  1871. // break;
  1872. // case 2:
  1873. // {
  1874. // if (Req.size() < 4)
  1875. // {
  1876. // printf("Lack of params\n");
  1877. // return DCS_FAILED;
  1878. // }
  1879. //
  1880. // int nErr = Req[2];
  1881. // string StatePos = (const char *)Req[3];
  1882. //
  1883. // if (WFTSetErrStatus(nErr, StatePos.c_str()))
  1884. // {
  1885. // return DCS_SUCCEED;
  1886. // }
  1887. // break;
  1888. // }
  1889. // case 3:
  1890. // if (WFTTriggerEvtPrep())
  1891. // {
  1892. // return DCS_SUCCEED;
  1893. // }
  1894. // break;
  1895. // case 4:
  1896. // if (!WFTTriggerEvtExpOn())
  1897. // {
  1898. // return DCS_SUCCEED;
  1899. // }
  1900. // break;
  1901. // case 5:
  1902. // if (WFTReset())
  1903. // {
  1904. // return DCS_SUCCEED;
  1905. // }
  1906. // break;
  1907. // case 6:
  1908. // nRet = Client.Open(szPathSubsys, ALL_ACCESS);
  1909. // printf("Open return %i\n", nRet);
  1910. // if (nRet == RET_SUCCEED)
  1911. // {
  1912. // ResDataObject Request, Res;
  1913. // Request.clear();
  1914. // Request.add("P0", "EvtEndPost");
  1915. // nRet = Client.Action("TriggerEventSMMachine", Request, Res);
  1916. // printf("-----TriggerEventSMMachine return %i\n", nRet);
  1917. // Sleep(100);
  1918. // Client.Close();
  1919. // printf("-- Test step done --\n");
  1920. // return DCS_SUCCEED;
  1921. // }
  1922. // break;
  1923. // case 7:
  1924. // nRet = Client.Open(szPathSubsys, ALL_ACCESS);
  1925. // printf("Open return %i\n", nRet);
  1926. // if (nRet == RET_SUCCEED)
  1927. // {
  1928. // ResDataObject Request, Res;
  1929. // Request.clear();
  1930. // nRet = Client.Action("StopSMMachine", Request, Res);
  1931. // printf("-----StopSMMachine return %i\n", nRet);
  1932. // Sleep(100);
  1933. // Client.Close();
  1934. // printf("-- Test step done --\n");
  1935. // return DCS_SUCCEED;
  1936. // }
  1937. // break;
  1938. // case 0:
  1939. // nRet = Client.Open(szPathSubsys, ALL_ACCESS);
  1940. // printf("Open return %i\n", nRet);
  1941. // if (nRet == RET_SUCCEED)
  1942. // {
  1943. // ResDataObject Request, Res;
  1944. // Request.clear();
  1945. // nRet = Client.Action("DeactivateSubsystem", Request, Res);
  1946. // printf("-----DeactivateSubsystem return %i\n", nRet);
  1947. // Sleep(100);
  1948. // Client.Close();
  1949. // printf("-- Test step done --\n");
  1950. // return DCS_SUCCEED;
  1951. // }
  1952. // break;
  1953. // case 100:
  1954. // nRet = Client.Open(szPathSubsys, ALL_ACCESS);
  1955. // printf("Offset calibration, Open return %i\n", nRet);
  1956. // if (nRet == RET_SUCCEED)
  1957. // {
  1958. // Sleep(2000);
  1959. // Client.Close();
  1960. // printf("-- Test step done --\n");
  1961. // return DCS_SUCCEED;
  1962. // }
  1963. // break;
  1964. // case 101:
  1965. // if (WFTCalibrateGain())
  1966. // {
  1967. // return DCS_SUCCEED;
  1968. // }
  1969. // break;
  1970. // case 200:
  1971. // if (WFTActiveAndStartSMForErr())
  1972. // {
  1973. // return DCS_SUCCEED;
  1974. // }
  1975. //
  1976. // break;
  1977. // case 201:
  1978. // {
  1979. // int nErr = 1;
  1980. // if (Req.size() >= 3)
  1981. // nErr = Req[2];
  1982. // if (WFTTestRunAllStates(nErr))
  1983. // {
  1984. // return DCS_SUCCEED;
  1985. // }
  1986. // break;
  1987. // }
  1988. // case 301:
  1989. // {
  1990. // const char* szStateArray[] = { "FrameReady", "FrameStart", "FrameAcq", "FrameIn", "XrayOut", "FrameOut", "FrameEnd", "FramePost", "FramePrep" };
  1991. // bool bRet = true;
  1992. // bRet = WFTActiveAndStartSMForErr();
  1993. // //for (int i = 0; i < ARRAYSIZE(szStateArray); i++)
  1994. // for (int i = 0; i < 5000; i++)
  1995. // {
  1996. // for (int j = 0; bRet && j < 9; j++)
  1997. // {
  1998. // PrintCurTime();
  1999. // printf("Run A round Sub Test:---------------------------------------------------------- [%d]%s\n",i, szStateArray[j]);
  2000. // //for (int erridx = 1; erridx < 4; erridx++)
  2001. // {
  2002. // int erridx = 1;
  2003. // bRet = WFTTestRunOnce(erridx, szStateArray[j]);//errcode:1(ret ng),2(timeout),3(error)
  2004. // erridx = 3;
  2005. // bRet = WFTTestRunOnce(erridx, szStateArray[j]);//errcode:1(ret ng),2(timeout),3(error)
  2006. //
  2007. // }
  2008. // }
  2009. //
  2010. // }
  2011. //
  2012. // if (bRet)
  2013. // {
  2014. // printf("\n\nPressure Test DONE---------------------\n\n");
  2015. // return DCS_SUCCEED;
  2016. // }
  2017. // else
  2018. // {
  2019. // printf("\n\nPressure Test FAILED---------------------\n\n");
  2020. // }
  2021. //
  2022. // }
  2023. // break;
  2024. // default:
  2025. // break;
  2026. // }
  2027. //
  2028. // return DCS_FAILED;
  2029. //}
  2030. //
  2031. //bool APlatformDcs::WFTWaitForState(CommonLogicClient &client, const char* szKey, const char* szState, int nTimeout)
  2032. //{
  2033. // PACKET_CMD cmd;
  2034. // ResDataObject data;
  2035. // ResDataObject context;
  2036. // BaseJsonDataObject<string> key;
  2037. // key.SetKey("CurrentState");
  2038. // string strKey, value;
  2039. // HANDLE notifyhandle = client.GetNotifyHandle();
  2040. // const int nSleep = 10;
  2041. // int nCounter = 0;
  2042. // while (nCounter < nTimeout / nSleep)
  2043. // {
  2044. // while (client.IsDataArrived())
  2045. // {
  2046. // data.clear();
  2047. // cmd = client.ReadCmd(data);
  2048. // int Idx = data.GetFirstOf(CCOS_PACK_KEY);
  2049. // if (Idx >= 0)
  2050. // {
  2051. // strKey = (const char*)data[CCOS_PACK_KEY];
  2052. // }
  2053. // Idx = data.GetFirstOf(CCOS_PACK_CONTEXT);
  2054. // if (Idx >= 0)
  2055. // {
  2056. // context = data[Idx];
  2057. // }
  2058. // value = (string)context;
  2059. // printf("-- cmd:%d ,strKey: %s, value: %s\n", cmd, strKey.c_str(), value.c_str());
  2060. // if (strKey == "CALIBRATIONSTATUS")
  2061. // {
  2062. // m_statWFT->nCalibrationStatus = (int)context;
  2063. // }
  2064. // else if (strKey == "CALIBRATIONPROGRESS")
  2065. // {
  2066. // m_statWFT->nCalibrationProgress = (int)context;
  2067. // }
  2068. // else if (strKey == "CurrentSMState")
  2069. // {
  2070. // if (value == "FrameError")
  2071. // m_statWFT->nSMState = -1;
  2072. // else if (value == "SeqReady")
  2073. // m_statWFT->nSMState = 0;
  2074. // else
  2075. // m_statWFT->nSMState = 1;
  2076. // }
  2077. //
  2078. // if (strlen(szState) > 0)
  2079. // {
  2080. // if (strKey == szKey)
  2081. // {
  2082. // if (strstr(szState, value.c_str()) != NULL)
  2083. // return true;
  2084. // }
  2085. // }
  2086. // else
  2087. // {
  2088. // if (strKey == szKey)
  2089. // return true;
  2090. // }
  2091. //
  2092. // }
  2093. // Sleep(nSleep);
  2094. // nCounter++;
  2095. // }
  2096. //
  2097. // printf("------------WFTWaitForState timedout %s %s\n", szKey, szState);
  2098. // return false;
  2099. //}
  2100. //
  2101. //bool APlatformDcs::WFTActiveAndStartSMForErr()
  2102. //{
  2103. // CommonLogicClient Client, fpdClient;
  2104. // int nRet;
  2105. // const char* szPathSubsys = "/DevSubSystem/Subsystem/Rf/ecomdemo/demo/1234/{60E2EAAB-0757-4CF3-A547-F0C0A8167359}";
  2106. // const char* szPathRFFpd = "/DevFPD/Detector/RF/ecomdemo/demo/1C70642C/{18CAB88A-C61C-4BB2-AC28-184FDD4FD160}";
  2107. // nRet = Client.Open(szPathSubsys, ALL_ACCESS);
  2108. // printf("Test of Exception or Error condition, Open return %i\n", nRet);
  2109. // if (nRet == RET_SUCCEED)
  2110. // {
  2111. // printf("Open subsystem Device ok\n");
  2112. // ResDataObject Request, Res;
  2113. // nRet = Client.Action("ActivateSubsystem", Request, Res);
  2114. // Request.add("P0", "Table");
  2115. // nRet = Client.Action("SetWorkStation", Request, Res);
  2116. // printf("SetWorkStation return %i\n", nRet);
  2117. //
  2118. // WFTWaitForState(Client, "WorkStation", "");
  2119. //
  2120. // Request.clear();
  2121. // nRet = Client.Action("StartSMMachine", Request, Res);
  2122. // printf("StartSMMachine return %i\n", nRet);
  2123. //
  2124. // WFTWaitForState(Client, "CurrentSMState", "SeqReady");
  2125. //
  2126. // ResDataObject res1, res2, res3, res4, res0, resparam;
  2127. // res1.clear();
  2128. // res1.add("SeqReady", "");
  2129. // res2.add("{66888A95-CDBE-6CA6-B53F-86185E4B9C88}", res1); //ErrDisp DPC
  2130. // res3.add("SeqReady", res2);
  2131. // res2.clear();
  2132. //
  2133. // resparam.clear();
  2134. // resparam.add("P0", 1);
  2135. // res1.add("SetAcqMode", resparam);
  2136. // res2.add("{65608C98-C66B-4CC4-8C1F-8C616FFE4CC2}", res1);
  2137. // res1.clear();
  2138. // res1.add("FramePrep", "");
  2139. // res2.add("{66888A95-CDBE-6CA6-B53F-86185E4B9C88}", res1); //ErrDisp DPC
  2140. // res3.add("FramePrep", res2);
  2141. //
  2142. // res1.clear();
  2143. // res1.add("FrameReady", "");
  2144. // res2.clear();
  2145. // res2.add("{66888A95-CDBE-6CA6-B53F-86185E4B9C88}", res1); //ErrDisp DPC
  2146. // res3.add("FrameReady", res2);
  2147. //
  2148. // res1.clear();
  2149. // res1.add("FramePost", "");
  2150. // res2.clear();
  2151. // res2.add("{66888A95-CDBE-6CA6-B53F-86185E4B9C88}", res1); //ErrDisp DPC
  2152. // res3.add("FramePost", res2);
  2153. //
  2154. // resparam.clear();
  2155. // res1.clear();
  2156. // res2.clear();
  2157. // resparam.add("P0", "DX");
  2158. // res1.add("SetModality", resparam);
  2159. // res3["FramePrep"].add("{BDDF7891-3C15-4191-98F5-F4A9918B2872}", res1);
  2160. // //res3.add("FramePrep", res2);
  2161. // res0.add("SMOuter", res3);
  2162. //
  2163. //
  2164. // res1.clear();
  2165. // res2.clear();
  2166. // res1.add("StartAcquisition", "");
  2167. // //res2.add("{18CAB88A-C61C-4BB2-AC28-184FDD4FD160}", res1);
  2168. // res2.add("{55C509AD-02C8-4E18-8509-B0C6E736936B}", res1);
  2169. // res1.clear();
  2170. // res1.add("FrameStart", "");
  2171. // res2.add("{66888A95-CDBE-6CA6-B53F-86185E4B9C88}", res1); //ErrDisp DPC
  2172. // res4.add("FrameStart", res2);
  2173. //
  2174. // res1.clear();
  2175. // res2.clear();
  2176. // resparam.clear();
  2177. // resparam.add("P0", 3);
  2178. // res1.add("SetGeneratortoSyncStatus", resparam);
  2179. // res2.add("{3BEA33D7-9F86-8F34-C890-F2596546C005}", res1);
  2180. // res1.clear();
  2181. // res1.add("FrameIn", "");
  2182. // res2.add("{66888A95-CDBE-6CA6-B53F-86185E4B9C88}", res1); //ErrDisp DPC
  2183. // res4.add("FrameIn", res2);
  2184. //
  2185. // res1.clear();
  2186. // res2.clear();
  2187. // resparam.clear();
  2188. // resparam.add("P0", 4);
  2189. // res1.add("SetGeneratortoSyncStatus", resparam);
  2190. // res2.add("{3BEA33D7-9F86-8F34-C890-F2596546C005}", res1);
  2191. // res1.clear();
  2192. // res1.add("FrameOut", "");
  2193. // res2.add("{66888A95-CDBE-6CA6-B53F-86185E4B9C88}", res1); //ErrDisp DPC
  2194. // res4.add("FrameOut", res2);
  2195. //
  2196. // res1.clear();
  2197. // res2.clear();
  2198. // res1.add("StopAcquisition", "");
  2199. // res2.add("{55C509AD-02C8-4E18-8509-B0C6E736936B}", res1);
  2200. // //res2.add("{18CAB88A-C61C-4BB2-AC28-184FDD4FD160}", res1);
  2201. // res1.clear();
  2202. // res1.add("FrameEnd", "");
  2203. // res2.clear();
  2204. // res2.add("{66888A95-CDBE-6CA6-B53F-86185E4B9C88}", res1); //ErrDisp DPC
  2205. // res4.add("FrameEnd", res2);
  2206. //
  2207. // res1.clear();
  2208. // res1.add("FrameAcq", "");
  2209. // res2.clear();
  2210. // res2.add("{66888A95-CDBE-6CA6-B53F-86185E4B9C88}", res1); //ErrDisp DPC
  2211. // res4.add("FrameAcq", res2);
  2212. //
  2213. // res1.clear();
  2214. // res1.add("XrayOut", "");
  2215. // res2.clear();
  2216. // res2.add("{66888A95-CDBE-6CA6-B53F-86185E4B9C88}", res1); //ErrDisp DPC
  2217. // res4.add("XrayOut", res2);
  2218. //
  2219. // res0.add("SMFrameAcquiring", res4);
  2220. //
  2221. // Request.clear();
  2222. // Res.clear();
  2223. // Request.add("P0", res0);
  2224. // nRet = Client.Action("SetSEQResourceAction", Request, Res);
  2225. // printf("-----SetSEQResourceAction return %i\n", nRet);
  2226. //
  2227. // // events
  2228. // res0.clear();
  2229. //
  2230. // res1.clear();
  2231. // res2.clear();
  2232. // res3.clear();
  2233. // res3.add("Need", "1");
  2234. // res3.add("ReadFromAttribute", "0");
  2235. // res0.add("EvtFramePrep", res3);
  2236. //
  2237. // res1.clear();
  2238. // res2.clear();
  2239. // res3.clear();
  2240. // res3.add("Need", "1");
  2241. // res3.add("ReadFromAttribute", "0");
  2242. // res1.add("GENERATORSYNCSTATE", "2");
  2243. // res3.add("{3BEA33D7-9F86-8F34-C890-F2596546C005}", res1);
  2244. // res0.add("EvtExpOn", res3);
  2245. //
  2246. // res1.clear();
  2247. // res2.clear();
  2248. // res3.clear();
  2249. // res3.add("Need", "1");
  2250. // res3.add("ReadFromAttribute", "1");
  2251. // res1.add("DETECTORSTATUS", "5");
  2252. // res3.add("{55C509AD-02C8-4E18-8509-B0C6E736936B}", res1);
  2253. // res0.add("EvtFrameAcq", res3);
  2254. //
  2255. // res1.clear();
  2256. // res2.clear();
  2257. // res3.clear();
  2258. // res3.add("Need", "1");
  2259. // res3.add("ReadFromAttribute", "0");
  2260. // res1.add("XWINDOWSTATUS", "1");
  2261. // res3.add("{55C509AD-02C8-4E18-8509-B0C6E736936B}", res1);
  2262. // res0.add("EvtXwinOn", res3);
  2263. //
  2264. // res1.clear();
  2265. // res2.clear();
  2266. // res3.clear();
  2267. // res3.add("Need", "1");
  2268. // res3.add("ReadFromAttribute", "0");
  2269. // res1.add("XWINDOWSTATUS", "0");
  2270. // res3.add("{55C509AD-02C8-4E18-8509-B0C6E736936B}", res1);
  2271. // res0.add("EvtXwinOff", res3);
  2272. //
  2273. // res1.clear();
  2274. // res2.clear();
  2275. // res3.clear();
  2276. // res3.add("Need", "1");
  2277. // res3.add("ReadFromAttribute", "0");
  2278. // res1.add("GENERATORSYNCSTATE", "3");
  2279. // res3.add("{3BEA33D7-9F86-8F34-C890-F2596546C005}", res1);
  2280. // res0.add("EvtXrayOut", res3);
  2281. //
  2282. // res1.clear();
  2283. // res2.clear();
  2284. // res3.clear();
  2285. // res3.add("Need", "1");
  2286. // res3.add("ReadFromAttribute", "0");
  2287. // res1.add("DETECTORSTATUS", "4");
  2288. // res3.add("{55C509AD-02C8-4E18-8509-B0C6E736936B}", res1);
  2289. // res0.add("EvtEndAcq", res3);
  2290. //
  2291. // res1.clear();
  2292. // res2.clear();
  2293. // res3.clear();
  2294. // res3.add("Need", "1");
  2295. // res3.add("ReadFromAttribute", "0");
  2296. // res1.add("GENERATORSYNCSTATE", "0");
  2297. // res3.add("{3BEA33D7-9F86-8F34-C890-F2596546C005}", res1);
  2298. // res0.add("EvtFrameStandby", res3);
  2299. //
  2300. // res1.clear();
  2301. // res2.clear();
  2302. // res3.clear();
  2303. // res3.add("Need", "0");
  2304. // res3.add("ReadFromAttribute", "0");
  2305. // res0.add("EvtEndPost", res3);
  2306. //
  2307. // res1.clear();
  2308. // res2.clear();
  2309. // res3.clear();
  2310. // res3.add("Need", "1");
  2311. // res3.add("ReadFromAttribute", "0");
  2312. // res0.add("EvtFrameError", res3);
  2313. //
  2314. // res1.clear();
  2315. // res2.clear();
  2316. // res3.clear();
  2317. // res3.add("Need", "1");
  2318. // res3.add("ReadFromAttribute", "0");
  2319. // res0.add("EvtFrameRecover", res3);
  2320. //
  2321. // res1.clear();
  2322. // res2.clear();
  2323. // res3.clear();
  2324. // res3.add("Need", "1");
  2325. // res3.add("ReadFromAttribute", "0");
  2326. // res0.add("EvtSeqEnd", res3);
  2327. //
  2328. // Res.clear();
  2329. // Request.clear();
  2330. // Request.add("P0", res0);
  2331. // nRet = Client.Action("SetSEQResourceEvent", Request, Res);
  2332. // printf("-----SetSEQResourceEvent return %i\n", nRet);
  2333. //
  2334. // res1.clear();
  2335. // res2.clear();
  2336. // res3.clear();
  2337. // res1.add("Sensitivity", "Sensitivity");
  2338. // res1.add("DetectorElementPhysicalSize", "PixelSpacing");
  2339. // res1.add("DetectorElementSpacing", "PixelSpacing");
  2340. // res1.add("DetectorActiveShape", "DetectorActiveShape");
  2341. // res1.add("DetectorActiveDimension", "DetectorActiveDimension");
  2342. // res1.add("DetectorActiveOrigin", "DetectorActiveOrigin");
  2343. // res1.add("LossyImageCompression", "LossyImageCompression");
  2344. // res1.add("RescaleType", "RescaleType");
  2345. // res1.add("PixelIntensityRelationship", "PixelIntensityRelationship");
  2346. // res1.add("FPDCoef", "FPDCoef");
  2347. // res2.add("{18CAB88A-C61C-4BB2-AC28-184FDD4FD160}", res1);
  2348. // res3.add("ImgHeader", res2);
  2349. //
  2350. // res1.clear();
  2351. // res2.clear();
  2352. // res1.add("KVP", "KV");
  2353. // res1.add("XRayTubeCurrent", "MA");
  2354. // res1.add("ExposureTime", "MS");
  2355. // res1.add("ExposureTimeinms", "MS");
  2356. // res1.add("Exposure", "DetectorActiveDimension");
  2357. // res1.add("ExposureinmAs", "DetectorActiveOrigin");
  2358. // res1.add("FocusSpot", "LossyImageCompression");
  2359. // res2.add("{F5C377E6-5C3F-4A3C-9C5F-31295A0F7104}", res1);
  2360. // res3.add("FrameHeader", res2);
  2361. //
  2362. // Request.clear();
  2363. // Res.clear();
  2364. // Request.add("P0", res3);
  2365. // Client.Action("SetECMInfo", Request, Res);
  2366. //
  2367. //
  2368. //
  2369. // Sleep(500);
  2370. // Client.Close();
  2371. // printf("-- Test step done --\n");
  2372. // return true;
  2373. //
  2374. // }
  2375. //
  2376. // return false;
  2377. //}
  2378. //
  2379. //bool APlatformDcs::WFTTriggerEvtPrep(int nErr)
  2380. //{
  2381. // CommonLogicClient Client;
  2382. // const char* szPathSubsys = "/DevSubSystem/Subsystem/Rf/ecomdemo/demo/1234/{60E2EAAB-0757-4CF3-A547-F0C0A8167359}";
  2383. // const char* szPathRFFpd = "/DevFPD/Detector/RF/ecomdemo/demo/1C70642C/{18CAB88A-C61C-4BB2-AC28-184FDD4FD160}";
  2384. // int nRet = Client.Open(szPathSubsys, ALL_ACCESS);
  2385. // printf("TriggerEvtPrep, Open return %i\n", nRet);
  2386. // if (nRet == RET_SUCCEED)
  2387. // {
  2388. // printf("Open subsystem Device ok\n");
  2389. // ResDataObject Request, Res;
  2390. // // TriggerEventSMMachine EvtFramePrep
  2391. // Request.clear();
  2392. // Request.add("P0", "EvtFramePrep");
  2393. // Res.clear();
  2394. // nRet = Client.Action("TriggerEventSMMachine", Request, Res);
  2395. // printf("-----TriggerEventSMMachine return %i\n", nRet);
  2396. //
  2397. // if (nErr == 0)
  2398. // WFTWaitForState(Client, "CurrentSMState", "FramePrep");
  2399. // else
  2400. // WFTWaitForState(Client, "CurrentSMState", "FrameError");
  2401. //
  2402. // Client.Close();
  2403. // printf("--WFTTriggerEvtPrep Test step done --\n");
  2404. // return true;
  2405. // }
  2406. //
  2407. // printf("Open subsystem Device failed\n");
  2408. // return false;
  2409. //}
  2410. //
  2411. //bool APlatformDcs::WFTTriggerEvtExpOn()
  2412. //{
  2413. // CommonLogicClient Client;
  2414. // const char* szPathSubsys = "/DevSubSystem/Subsystem/Rf/ecomdemo/demo/1234/{60E2EAAB-0757-4CF3-A547-F0C0A8167359}";
  2415. // int nRet = Client.Open(szPathSubsys, ALL_ACCESS);
  2416. // printf("TriggerEvtExpOn, Open return %i\n", nRet);
  2417. // if (nRet == RET_SUCCEED)
  2418. // {
  2419. // printf("Open subsystem Device ok\n");
  2420. // ResDataObject Request, Res;
  2421. // Request.clear();
  2422. // int nImageNumber = 1;
  2423. // Request.add("P0", nImageNumber);
  2424. // nRet = Client.Action("SetExpNumber", Request, Res);
  2425. // printf("-----SetExpNumber %i\n", nImageNumber);
  2426. //
  2427. // Request.clear();
  2428. // Request.add("P0", "EvtExpOn");
  2429. // nRet = Client.Action("TriggerEventSMMachine", Request, Res);
  2430. // printf("-----TriggerEventSMMachine return %i\n", nRet);
  2431. //
  2432. // WFTWaitForState(Client, "CurrentSMState", "SeqReady|FrameError");
  2433. //
  2434. // Client.Close();
  2435. // printf("--WFTTriggerEvtExpOn Test step done --\n");
  2436. // return true;
  2437. // }
  2438. //
  2439. // Sleep(100);
  2440. // printf("Open subsystem Device failed\n");
  2441. // return false;
  2442. //}
  2443. //
  2444. //bool APlatformDcs::WFTSetErrStatus(int nErr, const char* pszState)
  2445. //{
  2446. // const char* szErrDPC = "/DEded1FA3EE2C2/ErrTest/driver/ecom/dispach/1234/{66888A95-CDBE-6CA6-B53F-86185E4B9C88}";
  2447. // CommonLogicClient Client;
  2448. // int nRet = Client.Open(szErrDPC, ALL_ACCESS);
  2449. // printf("Open ErrDPC return %i\n", nRet);
  2450. // if (nRet == RET_SUCCEED)
  2451. // {
  2452. // ResDataObject Request, Res;
  2453. // Request.clear();
  2454. // int nImageNumber = 1;
  2455. // Request.add("P0", nErr);
  2456. // Request.add("P1", pszState);
  2457. // nRet = Client.Action("SetErrStatus", Request, Res);
  2458. // printf("-----SetErrStatus %s err=%i return %i\n", pszState, nErr, nRet);
  2459. // Sleep(50);
  2460. // Client.Close();
  2461. // printf("-- WFTSetErrStatus Test step done --\n");
  2462. // return true;
  2463. // }
  2464. //
  2465. // printf("Open ErrDPC Device failed\n");
  2466. // return false;
  2467. //}
  2468. //
  2469. //bool APlatformDcs::WFTReset(int nErr)
  2470. //{
  2471. // CommonLogicClient Client;
  2472. // const char* szPathSubsys = "/DevSubSystem/Subsystem/Rf/ecomdemo/demo/1234/{60E2EAAB-0757-4CF3-A547-F0C0A8167359}";
  2473. // int nRet = Client.Open(szPathSubsys, ALL_ACCESS);
  2474. // printf("Open return %i\n", nRet);
  2475. // if (nRet == RET_SUCCEED)
  2476. // {
  2477. // ResDataObject Request, Res;
  2478. // Request.clear();
  2479. // nRet = Client.Action("RESET", Request, Res);
  2480. // printf("-----RESET return %i\n", nRet);
  2481. //
  2482. // WFTWaitForState(Client, "CurrentSMState", "FramePrep", 2000);
  2483. //
  2484. // Client.Close();
  2485. // printf("--WFTReset Test step done, state=%i --\n", m_statWFT->nSMState);
  2486. // return true;
  2487. // }
  2488. //
  2489. // printf("WFTReset, Open Device failed\n");
  2490. // return false;
  2491. //}
  2492. //
  2493. //bool APlatformDcs::WFTTestRunAllStates(int nErr)
  2494. //{
  2495. // const char* szStateArray[] = { "FrameReady", "FrameStart", "FrameAcq", "FrameIn", "XrayOut", "FrameOut", "FrameEnd", "FramePost", "FramePrep" };
  2496. // bool bRet;
  2497. // bRet = WFTActiveAndStartSMForErr();
  2498. // //for (int i = 0; i < ARRAYSIZE(szStateArray); i++)
  2499. // for (int i = 0; bRet && i < 9; i++)
  2500. // {
  2501. // bRet = WFTTestRunOnce(nErr, szStateArray[i]);
  2502. // }
  2503. //
  2504. // return bRet;
  2505. //}
  2506. //
  2507. //bool APlatformDcs::WFTTestRunOnce(int nErr, const char* pszState)
  2508. //{
  2509. // bool bRet;
  2510. // bRet = WFTSetErrStatus(nErr, pszState);
  2511. //
  2512. // m_statWFT->nSMState = -1;
  2513. // if (strstr(pszState, "FrameReady") != NULL || strstr(pszState, "FramePrep") != NULL)
  2514. // {
  2515. // bRet = WFTTriggerEvtPrep(nErr);
  2516. // }
  2517. // else
  2518. // {
  2519. // bRet = WFTTriggerEvtPrep();
  2520. // bRet = WFTTriggerEvtExpOn();
  2521. // Sleep(500);
  2522. // }
  2523. //
  2524. // if (nErr != 0)
  2525. // {
  2526. // bRet = WFTReset(nErr);
  2527. // if (m_statWFT->nSMState > 0)
  2528. // bRet = WFTTriggerEvtExpOn();
  2529. // }
  2530. //
  2531. // return bRet;
  2532. //}
  2533. //
  2534. //bool APlatformDcs::WFTCalibrateGain()
  2535. //{
  2536. // bool bRet = WFTCalibrateGainActive();
  2537. //
  2538. // int nCount = 0;
  2539. // while (1)
  2540. // {
  2541. // printf("WFTCalibrateGain %i, press any key...\n", nCount);
  2542. // _getch();
  2543. // bRet = WFTSetAPR();
  2544. //
  2545. // bRet = WFTTriggerEvtPrep();
  2546. //
  2547. // bRet = WFTTriggerEvtExpOn();
  2548. //
  2549. // if (m_statWFT->nCalibrationStatus == 1 || m_statWFT->nCalibrationProgress == 100)
  2550. // {
  2551. // printf("---CALIBRATION Gain done---\n");
  2552. // break;
  2553. // }
  2554. //
  2555. // nCount++;
  2556. // }
  2557. //
  2558. // return bRet;
  2559. //}
  2560. //
  2561. //bool APlatformDcs::WFTCalibrateGainActive()
  2562. //{
  2563. // CommonLogicClient Client;
  2564. // const char* szPathSubsys = "/DevSubSystem/Subsystem/Rf/ecomdemo/demo/1234/{60E2EAAB-0757-4CF3-A547-F0C0A8167359}";
  2565. //
  2566. // m_statWFT->nCalibrationFrame = 0;
  2567. //
  2568. // int nRet = Client.Open(szPathSubsys, ALL_ACCESS);
  2569. // printf("Gain calibration, Open return %i\n", nRet);
  2570. // if (nRet == RET_SUCCEED)
  2571. // {
  2572. // ResDataObject Request, Res;
  2573. // nRet = Client.Action("ActivateSubsystem", Request, Res);
  2574. // Request.add("P0", "Wall");
  2575. // nRet = Client.Action("SetWorkStation", Request, Res);
  2576. // printf("SetWorkStation return %i\n", nRet);
  2577. // //Sleep(1000);
  2578. // WFTWaitForState(Client, "WorkStation", "");
  2579. //
  2580. // // 执行校正单元ActiveCalibration
  2581. // CommonLogicClient fpdClient;
  2582. // string strCalibUnit = Devs_Find("BE83E2F7-AB62-421C-BC2E-0C40BEEACCFB", false);
  2583. // int nRetFpd = fpdClient.Open(strCalibUnit.c_str(), ALL_ACCESS);
  2584. // printf("Open return %i\n", nRetFpd);
  2585. // if (nRetFpd == RET_SUCCEED)
  2586. // {
  2587. // ResDataObject Request, rdoParam, Res;
  2588. // Request.add("P0", 2); // 1:dark, 2:light
  2589. // Res.clear();
  2590. // nRetFpd = fpdClient.Action("ActiveCalibration", Request, Res);
  2591. // printf("ActiveCalibration return %i\n", nRetFpd);
  2592. // fpdClient.Close();
  2593. // }
  2594. //
  2595. //
  2596. //
  2597. // Request.clear();
  2598. // nRet = Client.Action("StartSMMachine", Request, Res);
  2599. // printf("StartSMMachine return %i\n", nRet);
  2600. //
  2601. // //Sleep(1000);
  2602. // WFTWaitForState(Client, "CurrentSMState", "SeqReady");
  2603. // ResDataObject res1, res2, res3, res4, res0, resparam;
  2604. // resparam.clear();
  2605. // resparam.add("P0", 1);
  2606. // res1.add("SetAcqMode", resparam);
  2607. // res2.add("{65608C98-C66B-4CC4-8C1F-8C616FFE4CC2}", res1);
  2608. // //res2.add("", "");
  2609. // res1.clear();
  2610. // res1.add("PrepareCalibration", "");
  2611. // res2.add("{BE83E2F7-AB62-421C-BC2E-0C40BEEACCFB}", res1);
  2612. // res3.add("FramePrep", res2);
  2613. //
  2614. //
  2615. // resparam.clear();
  2616. // res1.clear();
  2617. // res2.clear();
  2618. // resparam.add("P0", "DX");
  2619. // res1.add("SetModality", resparam);
  2620. // res3["FramePrep"].add("{BDDF7891-3C15-4191-98F5-F4A9918B2872}", res1);
  2621. //
  2622. // res1.clear();
  2623. // res2.clear();
  2624. // res1.add("SetExpEnable", "");
  2625. // //res2.add("{18CAB88A-C61C-4BB2-AC28-184FDD4FD160}", res1);
  2626. // res2.add("{18FDF176-DECE-445F-A52C-A14BDD3AC2C1}", res1);
  2627. // res3.add("FrameReady", res2);
  2628. // res0.add("SMOuter", res3);
  2629. //
  2630. // res1.clear();
  2631. // res2.clear();
  2632. // res1.add("StartCalibration", "");
  2633. // //res2.add("{18CAB88A-C61C-4BB2-AC28-184FDD4FD160}", res1);
  2634. // res2.add("{BE83E2F7-AB62-421C-BC2E-0C40BEEACCFB}", res1);
  2635. // res4.add("FrameStart", res2);
  2636. //
  2637. // res1.clear();
  2638. // res2.clear();
  2639. // resparam.clear();
  2640. // resparam.add("P0", 3);
  2641. // res1.add("SetGeneratortoSyncStatus", resparam);
  2642. // res2.add("{3BEA33D7-9F86-8F34-C890-F2596546C005}", res1);
  2643. // res4.add("FrameIn", res2);
  2644. //
  2645. // res1.clear();
  2646. // res2.clear();
  2647. // resparam.clear();
  2648. // resparam.add("P0", 4);
  2649. // res1.add("SetGeneratortoSyncStatus", resparam);
  2650. // res2.add("{3BEA33D7-9F86-8F34-C890-F2596546C005}", res1);
  2651. // res4.add("FrameOut", res2);
  2652. //
  2653. // // StopCalibration由探测器内部调用
  2654. //
  2655. // res0.add("SMFrameAcquiring", res4);
  2656. //
  2657. // Request.clear();
  2658. // Res.clear();
  2659. // Request.add("P0", res0);
  2660. // nRet = Client.Action("SetSEQResourceAction", Request, Res);
  2661. // printf("-----SetSEQResourceAction return %i\n", nRet);
  2662. //
  2663. // // events
  2664. // res0.clear();
  2665. //
  2666. // res1.clear();
  2667. // res2.clear();
  2668. // res3.clear();
  2669. // res3.add("Need", "1");
  2670. // res3.add("ReadFromAttribute", "0");
  2671. // res0.add("EvtFramePrep", res3);
  2672. //
  2673. // res1.clear();
  2674. // res2.clear();
  2675. // res3.clear();
  2676. // res3.add("Need", "1");
  2677. // res3.add("ReadFromAttribute", "0");
  2678. // res1.add("GENERATORSYNCSTATE", "2");
  2679. // res3.add("{3BEA33D7-9F86-8F34-C890-F2596546C005}", res1);
  2680. // res0.add("EvtExpOn", res3);
  2681. //
  2682. // res1.clear();
  2683. // res2.clear();
  2684. // res3.clear();
  2685. // res3.add("Need", "1");
  2686. // res3.add("ReadFromAttribute", "0");
  2687. // res1.add("DETECTORSTATUS", "5");
  2688. // res3.add("{55C509AD-02C8-4E18-8509-B0C6E736936B}", res1);
  2689. // res0.add("EvtFrameAcq", res3);
  2690. //
  2691. // res1.clear();
  2692. // res2.clear();
  2693. // res3.clear();
  2694. // res3.add("Need", "1");
  2695. // res3.add("ReadFromAttribute", "0");
  2696. // res1.add("XWINDOWSTATUS", "1");
  2697. // res3.add("{55C509AD-02C8-4E18-8509-B0C6E736936B}", res1);
  2698. // res0.add("EvtXwinOn", res3);
  2699. //
  2700. // res1.clear();
  2701. // res2.clear();
  2702. // res3.clear();
  2703. // res3.add("Need", "1");
  2704. // res3.add("ReadFromAttribute", "0");
  2705. // res1.add("XWINDOWSTATUS", "0");
  2706. // res3.add("{55C509AD-02C8-4E18-8509-B0C6E736936B}", res1);
  2707. // res0.add("EvtXwinOff", res3);
  2708. //
  2709. // res1.clear();
  2710. // res2.clear();
  2711. // res3.clear();
  2712. // res3.add("Need", "1");
  2713. // res3.add("ReadFromAttribute", "0");
  2714. // res1.add("GENERATORSYNCSTATE", "3");
  2715. // res3.add("{3BEA33D7-9F86-8F34-C890-F2596546C005}", res1);
  2716. // res0.add("EvtXrayOut", res3);
  2717. //
  2718. // res1.clear();
  2719. // res2.clear();
  2720. // res3.clear();
  2721. // res3.add("Need", "1");
  2722. // res3.add("ReadFromAttribute", "0");
  2723. // res1.add("DETECTORSTATUS", "4");
  2724. // res3.add("{55C509AD-02C8-4E18-8509-B0C6E736936B}", res1);
  2725. // res0.add("EvtEndAcq", res3);
  2726. //
  2727. // res1.clear();
  2728. // res2.clear();
  2729. // res3.clear();
  2730. // res3.add("Need", "1");
  2731. // res3.add("ReadFromAttribute", "0");
  2732. // res1.add("DETECTORSTATUS", "4");
  2733. // res3.add("{55C509AD-02C8-4E18-8509-B0C6E736936B}", res1);
  2734. // res0.add("EvtFrameStandby", res3);
  2735. //
  2736. // res1.clear();
  2737. // res2.clear();
  2738. // res3.clear();
  2739. // res3.add("Need", "0");
  2740. // res3.add("ReadFromAttribute", "0");
  2741. // res0.add("EvtEndPost", res3);
  2742. //
  2743. // res1.clear();
  2744. // res2.clear();
  2745. // res3.clear();
  2746. // res3.add("Need", "1");
  2747. // res3.add("ReadFromAttribute", "0");
  2748. // res0.add("EvtFrameError", res3);
  2749. //
  2750. // res1.clear();
  2751. // res2.clear();
  2752. // res3.clear();
  2753. // res3.add("Need", "1");
  2754. // res3.add("ReadFromAttribute", "0");
  2755. // res0.add("EvtFrameRecover", res3);
  2756. //
  2757. // res1.clear();
  2758. // res2.clear();
  2759. // res3.clear();
  2760. // res3.add("Need", "1");
  2761. // res3.add("ReadFromAttribute", "0");
  2762. // res0.add("EvtSeqEnd", res3);
  2763. //
  2764. // Res.clear();
  2765. // Request.clear();
  2766. // Request.add("P0", res0);
  2767. // nRet = Client.Action("SetSEQResourceEvent", Request, Res);
  2768. // printf("-----SetSEQResourceEvent return %i\n", nRet);
  2769. //
  2770. // res1.clear();
  2771. // res2.clear();
  2772. // res3.clear();
  2773. // res1.add("Sensitivity", "Sensitivity");
  2774. // res1.add("DetectorElementPhysicalSize", "PixelSpacing");
  2775. // res1.add("DetectorElementSpacing", "PixelSpacing");
  2776. // res1.add("DetectorActiveShape", "DetectorActiveShape");
  2777. // res1.add("DetectorActiveDimension", "DetectorActiveDimension");
  2778. // res1.add("DetectorActiveOrigin", "DetectorActiveOrigin");
  2779. // res1.add("LossyImageCompression", "LossyImageCompression");
  2780. // res1.add("RescaleType", "RescaleType");
  2781. // res1.add("PixelIntensityRelationship", "PixelIntensityRelationship");
  2782. // res1.add("FPDCoef", "FPDCoef");
  2783. // res2.add("{18CAB88A-C61C-4BB2-AC28-184FDD4FD160}", res1);
  2784. // res3.add("ImgHeader", res2);
  2785. //
  2786. // res1.clear();
  2787. // res2.clear();
  2788. // res1.add("KVP", "KV");
  2789. // res1.add("XRayTubeCurrent", "MA");
  2790. // res1.add("ExposureTime", "MS");
  2791. // res1.add("ExposureTimeinms", "MS");
  2792. // res1.add("Exposure", "DetectorActiveDimension");
  2793. // res1.add("ExposureinmAs", "DetectorActiveOrigin");
  2794. // res1.add("FocusSpot", "LossyImageCompression");
  2795. // res2.add("{F5C377E6-5C3F-4A3C-9C5F-31295A0F7104}", res1);
  2796. // res3.add("FrameHeader", res2);
  2797. //
  2798. // Request.clear();
  2799. // Res.clear();
  2800. // Request.add("P0", res3);
  2801. // Client.Action("SetECMInfo", Request, Res);
  2802. //
  2803. //
  2804. // Sleep(500);
  2805. // Client.Close();
  2806. // printf("-- Test step done --\n");
  2807. // return DCS_SUCCEED;
  2808. // }
  2809. //
  2810. // return DCS_FAILED;
  2811. //}
  2812. //
  2813. //bool APlatformDcs::WFTSetAPR()
  2814. //{
  2815. // CommonLogicClient Client;
  2816. // string strUnit = Devs_Find("F5C377E6-5C3F-4A3C-9C5F-31295A0F7104", false);
  2817. // int nRet = Client.Open(strUnit.c_str(), ALL_ACCESS);
  2818. // printf("Open %s return %i\n", strUnit.c_str(), nRet);
  2819. // if (nRet == RET_SUCCEED)
  2820. // {
  2821. // int nKv = 70;
  2822. // float fMs = 10.0f, fMa = 100.0f, fMas = 1.0f;
  2823. // int nFile;
  2824. // if (m_statWFT->nCalibrationFrame < 10)
  2825. // nFile = 1;
  2826. // else if (m_statWFT->nCalibrationFrame < 11)
  2827. // nFile = 2;
  2828. // else if (m_statWFT->nCalibrationFrame < 12)
  2829. // nFile = 3;
  2830. // else if (m_statWFT->nCalibrationFrame < 13)
  2831. // nFile = 4;
  2832. // char szFileName[256];
  2833. // sprintf_s(szFileName, "_calkv%i.t", nFile);
  2834. // FILE* fParam;
  2835. // fopen_s(&fParam, szFileName, "r");
  2836. // if (fParam != NULL)
  2837. // {
  2838. // char szBuf[4096] = {};
  2839. // size_t uLen = fread(szBuf, 1, 4096, fParam);
  2840. // printf("fread return %u\n", uLen);
  2841. // char* pszNext = NULL;
  2842. // char* pszTok = strtok_s(szBuf, ";", &pszNext);
  2843. // while (pszTok != NULL)
  2844. // {
  2845. // if (strstr(pszTok, "KV=") != NULL)
  2846. // {
  2847. // nKv = atoi(pszTok + 3);
  2848. // }
  2849. // else if (strstr(pszTok, "MA=") != NULL)
  2850. // {
  2851. // fMa = (float)atof(pszTok + 3);
  2852. // }
  2853. // else if (strstr(pszTok, "MS=") != NULL)
  2854. // {
  2855. // fMs = (float)atof(pszTok + 3);
  2856. // }
  2857. // else if (strstr(pszTok, "MAS=") != NULL)
  2858. // {
  2859. // fMas = (float)atof(pszTok + 4);
  2860. // }
  2861. // pszTok = strtok_s(NULL, ";", &pszNext);
  2862. // }
  2863. // fclose(fParam);
  2864. // }
  2865. // m_statWFT->nCalibrationFrame++;
  2866. //
  2867. // ResDataObject Request, rdoParam, Res;
  2868. // rdoParam.add("FOCUS", 0);
  2869. // rdoParam.add("TECHMODE", 0);
  2870. // rdoParam.add("AECFIELD", 0);
  2871. // rdoParam.add("AECFILM", 0);
  2872. // rdoParam.add("AECDENSITY", 0);
  2873. // rdoParam.add("KV", nKv);
  2874. // rdoParam.add("MA", fMa);
  2875. // rdoParam.add("MS", fMs);
  2876. // rdoParam.add("MAS", fMas);
  2877. // rdoParam.add("DOSE", 0.0f);
  2878. // rdoParam.add("FILTER", "");
  2879. // rdoParam.add("TUBELOAD", 0.0f);
  2880. // Request.add("P0", rdoParam);
  2881. // printf("%s\n", Request.encode());
  2882. // Res.clear();
  2883. // nRet = Client.Action("SetAPR", Request, Res);
  2884. // printf("SetAPR return %i\n", nRet);
  2885. // Client.Close();
  2886. // return (nRet == RET_SUCCEED);
  2887. // }
  2888. //
  2889. // return false;
  2890. //}