1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232 |
- // APlatformDcs.cpp : 定义 DLL 应用程序的导出函数。
- //
- #include "stdafx.h"
- #include "APlatformDcs.h"
- #include "cdi.h"
- #include "LocalConfig.h"
- #include "BusUnitClient.h"
- #include "CommonLogicClient.h"
- #include <conio.h>
- void PrintCurTime()
- {
- SYSTEMTIME st;
- GetLocalTime(&st);
- 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);
- }
- char *pszPlatformHelpCmds[] = {
- "Hello --yeah...",
- "Procs --shows all the ccos driver process in this machine.",
- "Devs rootpath --shows all the ccos driver process in this process.procpath:[/ccosAlpha]",
- "PrintDev Devpath -- show open response context",
- "Connect rootpath ipaddr --connect target proc to target machine.ipaddr[192.168.2.77]",
- "Disconnect rootpath --disconnect all remote connection",
- "RemoteProcs --shows all the ccos driver process in remote machine.",
- "RemoteDevs rootpath --shows all the ccos driver process in remote process.procpath:[/ccosAlpha]",
- "CT param1[TargetBusId] --close target proc who owns busid",
- "Test param1[0:del,1:add] param2[idstr]",
- "MechTest param1[1:Move,2:Rotate,3:Stop,4:Reset,5:DrTest,6:TomoTest,7:BlindRotateMech] param2",
- "Gen param1[1:SetKV,2:GetKV,3:IncKV,4:DecKV 5:SetMAS,6:GetMAS,7:IncMAS,8:DecMAS 9:SetFocus 10:ExpEnable] param2",
- "Dap Param1[0:reset,1:setFilter,2:setSID,3:setColimatorSize,4:setkv,5:setma,6:setms,7:setmas,8:getdap] Param2[num]",
- "FDacq Param1[AcqModeIndex] Param2[Xwindow ms]",
- "ConfigDriver param1[0:del,1:add,2:ShowAll] param2[driverpath]",
- "Action ActionName param1[devpath]",
- "Exit -- exit the whole modules.channel and all ccos procs",
- "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]",
- ""
- };
- APLATFORMDCS_CAPI CcosConsoleScript* LoadDCS()
- {
- CcosConsoleScript *pNew = new APlatformDcs();
- return pNew;
- }
- APLATFORMDCS_CAPI void UnLoadDCS(CcosConsoleScript* pDcs)
- {
- delete (APlatformDcs*)pDcs;
- }
- APlatformDcs::APlatformDcs(void)
- {
- MacroRegist(APlatformDcs, Hello);
- MacroRegist(APlatformDcs, Procs);
- MacroRegist(APlatformDcs, Devs);
- MacroRegist(APlatformDcs, PrintDev);
- MacroRegist(APlatformDcs, Connect);
- MacroRegist(APlatformDcs, Disconnect);
- MacroRegist(APlatformDcs, RemoteProcs);
- MacroRegist(APlatformDcs, RemoteDevs);
- MacroRegist(APlatformDcs, CT);
- MacroRegist(APlatformDcs, Test);
- MacroRegist(APlatformDcs, Ctrlcpu);
- MacroRegist(APlatformDcs, MechTest);
- MacroRegist(APlatformDcs, Gen);
- MacroRegist(APlatformDcs, Dap);
- MacroRegist(APlatformDcs, AddDPC);
- MacroRegist(APlatformDcs, DelDPC);
- MacroRegist(APlatformDcs, FDacq);
- MacroRegist(APlatformDcs, FDcalib);
- MacroRegist(APlatformDcs, ConfigDriver);
- MacroRegist(APlatformDcs, Action);
- MacroRegist(APlatformDcs, Exit);
- //MacroRegist(APlatformDcs, WorkFlowTest);
- //m_statWFT = new WFTStatus;
- }
- APlatformDcs::~APlatformDcs()
- {
- //if (m_statWFT != NULL)
- // delete m_statWFT;
- }
- void APlatformDcs::Help()
- {
- DWORD i = 0;
- while (strlen(pszPlatformHelpCmds[i]) > 0)
- {
- printf("%s\n", pszPlatformHelpCmds[i]);
- ++i;
- }
- //other script here
- }
- DCS_RET APlatformDcs::Command(ResDataObject &Req)
- {
- //return RUNDCS(APlatformDcs,Req);
- //get addr ;
- //类型转换
- //call this.func(Req);
- return MacroRun(Req);
- //if (gcmds == (const char *)Req[0])
- //{
- // return Hello(Req);
- //}
- //return DCS_NOT_SUPPORT;
- }
- DCS_RET APlatformDcs::Exit(ResDataObject &Req)
- {
- printf("Enter Exit all procs\n");
- string Channel = "/ccosChannel";
- BusUnitClient buClient;
- buClient.SetRouter(CCOS_PACKET_ROUTE_LOCAL);
- if (buClient.Open("/ccosChannel", ALL_ACCESS, 10000) == RET_SUCCEED)
- {
- ResDataObject req, res;
- buClient.Action("ExitDriverProc", req, res);
- buClient.Close();
- printf("hit exit\n");
- }
- return DCS_SUCCEED;
- }
- DCS_RET APlatformDcs::Hello(ResDataObject &Req)
- {
- printf("Hello You Granpa\n");
- string Channel = "/ccosChannel";
- BusUnitClient buClient;
- buClient.SetRouter(CCOS_PACKET_ROUTE_LOCAL);
- if (buClient.Open("/ccosChannel", ALL_ACCESS, 10000) == RET_SUCCEED)
- {
- ResDataObject req, res;
- buClient.Action("ExitDriverProc", req, res);
- buClient.Close();
- printf("hit exit\n");
- }
- return DCS_SUCCEED;
- }
- DCS_RET Procs_Func(ResDataObject &Req,bool Remote)
- {
- string Channel = "/ccosChannel";
- printf("Local Procs\n");
- BusUnitClient buClient;
- if (Remote)
- {
- buClient.SetRouter(CCOS_PACKET_ROUTE_ETH);
- }
- else
- {
- buClient.SetRouter(CCOS_PACKET_ROUTE_LOCAL);
- }
- if (buClient.Open("/ccosChannel", ALL_ACCESS, 10000) == RET_SUCCEED)
- {
- buClient.Close();
- DWORD count = buClient.GetDeviceCount();
- for (DWORD i = 0; i < count; i++)
- {
- UINT64 ProcId, Addr;
- ResDataObject DevType,devpath, MachineId;
- buClient.GetDeviceDescript(i, devpath, DevType, MachineId, ProcId, Addr);
- if (Channel == (const char*)devpath)
- {
- continue;
- }
- 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);
- CommonLogicClient DevClient;
- if (Remote)
- {
- DevClient.SetRouter(CCOS_PACKET_ROUTE_ETH);
- }
- else
- {
- DevClient.SetRouter(CCOS_PACKET_ROUTE_LOCAL);
- }
- if (DevClient.Open((const char*)devpath, ALL_ACCESS, 10000) >= RET_SUCCEED)
- {
- DevClient.Close();
- //printf("Open %s Succeed\n", (const char*)devpath);
- }
- else
- {
- printf("Open %s Failed\n", (const char*)devpath);
- }
- }
- }
- else
- {
- printf("Open local ccosChannel Failed\n");
- }
- return DCS_SUCCEED;
- }
- DCS_RET Devs_Func(ResDataObject &Req,bool Remote)
- {
- vector<string> PathList;
- vector<string> MachineList;
- vector<UINT64> ProcList;
- vector<UINT64> AddrList;
- string Channel = "/ccosChannel";
- //printf("Local Procs\n");
- BusUnitClient buClient;
- if (Remote)
- {
- buClient.SetRouter(CCOS_PACKET_ROUTE_ETH);
- }
- else
- {
- buClient.SetRouter(CCOS_PACKET_ROUTE_LOCAL);
- }
- //buClient.SetRouter(CCOS_PACKET_ROUTE_LOCAL);
- if (buClient.Open("/ccosChannel", ALL_ACCESS, 2000) == RET_SUCCEED)
- {
- buClient.UpdateDeviceResource();
- buClient.Close();
- DWORD count = buClient.GetDeviceCount();
- for (DWORD i = 0; i < count; i++)
- {
- UINT64 ProcId, Addr;
- ResDataObject DevType,devpath, MachineId;
- buClient.GetDeviceDescript(i, devpath, DevType, MachineId, ProcId, Addr);
- if (Channel == (const char*)devpath)
- {
- continue;
- }
- CommonLogicClient DevClient;
- if (Remote)
- {
- DevClient.SetRouter(CCOS_PACKET_ROUTE_ETH);
- }
- else
- {
- DevClient.SetRouter(CCOS_PACKET_ROUTE_LOCAL);
- }
- if (DevClient.Open((const char*)devpath, ALL_ACCESS, 2000) >= RET_SUCCEED)
- {
- DevClient.UpdateDeviceResource();
- DevClient.Close();
- if (Req.size() > 1)
- {
- string path = (const char*)Req[1];
- if (path == ((const char*)devpath))
- {
- PathList.push_back((const char*)devpath);
- MachineList.push_back((const char*)MachineId);
- ProcList.push_back(ProcId);
- AddrList.push_back(Addr);
- }
- }
- else
- {
- PathList.push_back((const char*)devpath);
- MachineList.push_back((const char*)MachineId);
- ProcList.push_back(ProcId);
- AddrList.push_back(Addr);
- }
- }
- }
- }
- else
- {
- printf("Open local ccosChannel Failed\n");
- return DCS_FAILED;
- }
- for (size_t ProcIdx = 0; ProcIdx < ProcList.size(); ProcIdx++)
- {
- BusUnitClient buClient;
- if (Remote)
- {
- buClient.SetRouter(CCOS_PACKET_ROUTE_ETH);
- }
- else
- {
- buClient.SetRouter(CCOS_PACKET_ROUTE_LOCAL);
- }
-
- //buClient.SetRouter(CCOS_PACKET_ROUTE_LOCAL);
- if (buClient.Open(PathList[ProcIdx].c_str(), ALL_ACCESS, 2000) == RET_SUCCEED)
- {
- buClient.UpdateDeviceResource();
- buClient.Close();
- 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]);
- DWORD count = buClient.GetDeviceCount();
- for (DWORD i = 0; i < count; i++)
- {
- UINT64 ProcId, Addr;
- ResDataObject DevType,devpath, MachineId;
- buClient.GetDeviceDescript(i, devpath, DevType, MachineId, ProcId, Addr);
- printf(" devpath[%d]:%s\n devtype:%s\n Addr:%I64u\n", i, (const char*)devpath, (const char*)DevType, Addr);
- CommonLogicClient DevClient;
- if (Remote)
- {
- DevClient.SetRouter(CCOS_PACKET_ROUTE_ETH);
- }
- else
- {
- DevClient.SetRouter(CCOS_PACKET_ROUTE_LOCAL);
- }
- if (DevClient.Open((const char*)devpath, ALL_ACCESS, 2000) >= RET_SUCCEED)
- {
- DevClient.UpdateDeviceResource();
- DevClient.Close();
- //printf("Open %s Succeed\n", (const char*)devpath);
- }
- else
- {
- printf("Open %s Failed\n", (const char*)devpath);
- }
- }
- }
- else
- {
- printf("Open local %s Failed\n", PathList[ProcIdx].c_str());
- }
- }
- return DCS_SUCCEED;
- }
- bool FindSubString(string org, string keystr)
- {
- std::string::size_type pos = 0;
- std::string::size_type keylen = keystr.size();
- if ((pos = org.find(keystr, pos)) != std::string::npos)
- {
- return true;
- }
- return false;
- }
- string Devs_Find(const char *pszKeystr, bool Remote)
- {
- for (size_t ti = 0; ti < 10; ti++)
- {
- vector<string> PathList;
- vector<string> MachineList;
- vector<UINT64> ProcList;
- vector<UINT64> AddrList;
- string Channel = "/ccosChannel";
- //printf("Local Procs\n");
- BusUnitClient buClient;
- if (Remote)
- {
- buClient.SetRouter(CCOS_PACKET_ROUTE_ETH);
- }
- else
- {
- buClient.SetRouter(CCOS_PACKET_ROUTE_LOCAL);
- }
- buClient.SetRouter(CCOS_PACKET_ROUTE_LOCAL);
- if (buClient.Open("/ccosChannel", ALL_ACCESS, 1000) == RET_SUCCEED)
- {
- buClient.Close();
- DWORD count = buClient.GetDeviceCount();
- for (DWORD i = 0; i < count; i++)
- {
- UINT64 ProcId, Addr;
- ResDataObject DevType,devpath, MachineId;
- buClient.GetDeviceDescript(i, devpath, DevType, MachineId, ProcId, Addr);
- if (Channel == (const char*)devpath)
- {
- continue;
- }
- CommonLogicClient DevClient;
- if (Remote)
- {
- DevClient.SetRouter(CCOS_PACKET_ROUTE_ETH);
- }
- else
- {
- DevClient.SetRouter(CCOS_PACKET_ROUTE_LOCAL);
- }
- if (DevClient.Open((const char*)devpath, ALL_ACCESS, 1000) >= RET_SUCCEED)
- {
- DevClient.Close();
- PathList.push_back((const char*)devpath);
- MachineList.push_back((const char*)MachineId);
- ProcList.push_back(ProcId);
- AddrList.push_back(Addr);
- }
- }
- }
- else
- {
- printf("Open local ccosChannel Failed\n");
- return "";
- }
- for (size_t ProcIdx = 0; ProcIdx < ProcList.size(); ProcIdx++)
- {
- BusUnitClient buClient;
- if (Remote)
- {
- buClient.SetRouter(CCOS_PACKET_ROUTE_ETH);
- }
- else
- {
- buClient.SetRouter(CCOS_PACKET_ROUTE_LOCAL);
- }
- buClient.SetRouter(CCOS_PACKET_ROUTE_LOCAL);
- if (buClient.Open(PathList[ProcIdx].c_str(), ALL_ACCESS, 1000) == RET_SUCCEED)
- {
- buClient.Close();
- //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]);
- DWORD count = buClient.GetDeviceCount();
- for (DWORD i = 0; i < count; i++)
- {
- UINT64 ProcId, Addr;
- ResDataObject DevType,devpath, MachineId;
- buClient.GetDeviceDescript(i, devpath, DevType, MachineId, ProcId, Addr);
- //printf(" devpath[%d]:%s\n Addr:%I64u\n", i, (const char*)devpath, Addr);
- if (FindSubString((const char*)devpath, pszKeystr))
- {
- return (const char*)devpath;
- }
- }
- }
- else
- {
- printf("Open local %s Failed\n", PathList[ProcIdx].c_str());
- }
- }
- }
- return "";
- }
- DCS_RET APlatformDcs::Procs(ResDataObject &Req)
- {
- return Procs_Func(Req, false);
- }
- DCS_RET APlatformDcs::Devs(ResDataObject &Req)
- {
- return Devs_Func(Req, false);
- }
- DCS_RET APlatformDcs::PrintDev(ResDataObject &Req)
- {
- if (Req.size() < 2)
- {
- printf("lack of params\n");
- return DCS_FAILED;
- }
- string rootname = (const char*)Req[1];
- CommonLogicClient buClient;
- buClient.SetRouter(CCOS_PACKET_ROUTE_LOCAL);
- if (buClient.Open(rootname.c_str(), ALL_ACCESS, 10000) == RET_SUCCEED)
- {
- ResDataObject DeviceRes;
- if (buClient.GetDeviceResource(&DeviceRes) >= RET_SUCCEED)
- {
- printf("DeviceResource:%s\n", DeviceRes.encode());
- }
- else
- {
- printf("Get DeviceResource:Failed\n");
- }
- buClient.Close();
- }
- else
- {
- printf("Open local %s Failed\n", rootname.c_str());
- }
- return DCS_SUCCEED;
- }
- DCS_RET APlatformDcs::Connect(ResDataObject &Req)
- {
- if (Req.size() <= 2)
- {
- printf("lack of params\n");
- return DCS_FAILED;
- }
- string rootname = (const char*)Req[1];
- //ResDataObject busid = getLocalEbusId();
- //if (busid == getChannelEbusId())
- //{
- // printf("This is Channel Proc.can't do the connection\n");
- // return DCS_FAILED;
- //}
- BusUnitClient buClient;
- buClient.SetRouter(CCOS_PACKET_ROUTE_LOCAL);
- if (buClient.Open(rootname.c_str(), ALL_ACCESS, 10000) == RET_SUCCEED)
- {
- if (buClient.SetEthBusRouterIp((const char *)(Req[2])) >= RET_SUCCEED && buClient.SetEthBusSwitch(1) >= RET_SUCCEED)
- {
- printf("Connect %s to %s Succeed.\n", (const char*)Req[1], (const char *)(Req[2]));
- }
- else
- {
- printf("Connect %s to %s Failed.\n", (const char*)Req[1], (const char *)(Req[2]));
- }
- buClient.Close();
- }
- else
- {
- printf("Open local %s Failed\n", rootname.c_str());
- }
- return DCS_SUCCEED;
- }
- DCS_RET APlatformDcs::Disconnect(ResDataObject &Req)
- {
- if (Req.size() <= 1)
- {
- printf("lack of params\n");
- return DCS_FAILED;
- }
- string rootname = (const char*)Req[1];
- BusUnitClient buClient;
- buClient.SetRouter(CCOS_PACKET_ROUTE_LOCAL);
- if (buClient.Open(rootname.c_str(), ALL_ACCESS, 10000) == RET_SUCCEED)
- {
- if (buClient.SetEthBusSwitch(0) >= RET_SUCCEED)
- {
- printf("Disconnect %s Succeed.\n", (const char*)Req[1]);
- }
- else
- {
- printf("Disconnect %s Failed.\n", (const char*)Req[1]);
- }
- buClient.Close();
- }
- else
- {
- printf("Open local %s Failed\n", rootname.c_str());
- }
- return DCS_SUCCEED;
- }
- DCS_RET APlatformDcs::RemoteProcs(ResDataObject &Req)
- {
- return Procs_Func(Req, true);
- }
- DCS_RET APlatformDcs::RemoteDevs(ResDataObject &Req)
- {
- return Devs_Func(Req, true);
- }
- DCS_RET APlatformDcs::CT(ResDataObject &Req)
- {
- if (Req.size() < 2)
- {
- printf("lack of params\n");
- return DCS_FAILED;
- }
- string devpath;
- devpath = "/";
- devpath += (const char *)Req[1];
- ResDataObject request, response;
- CommonLogicClient DevClient;
- DevClient.SetRouter(CCOS_PACKET_ROUTE_LOCAL);
- if (DevClient.Open((const char*)devpath.c_str(), ALL_ACCESS, 10000) >= RET_SUCCEED)
- {
- DevClient.Action("ExitDriverProc", request, response);
- DevClient.Close();
- }
- return DCS_SUCCEED;
- }
- DCS_RET APlatformDcs::Test(ResDataObject &Req)
- {
- //Test del[0] key[str]
- //Test add[1] key[str]
- ResDataObject NotifyData, ResNotify, ErrorInfo, tempInfo,Obj;
- tempInfo.add("CodeID", "");
- tempInfo.add("Type", "0");
- tempInfo.add("Level", "0");
- ErrorInfo.add(" ", tempInfo);
- ResNotify.add("{F3C37A69-0EF9-4E95-88AC-662F05D5103B}", ErrorInfo);
- Obj.add(CCOS_PACK_CONTEXT, (ResDataObject&)ResNotify);
- const char *pOut = (Obj.encode());
- printf("TestOutput:%s\n", pOut);
- return DCS_SUCCEED;
- char szMDPC[] = "MDPC/RF/Ecom/DRSIM/DrvObj/{399B143C-80F1-4D90-81D1-7C5CECC63EE8}";
- char szSUBDPC[] = "Generator/DR/ECOM/DEMO";
- char szSUBDEV[] = "Generator/DR/ECOM/Device";
- string devpath = Devs_Find(szMDPC, false);
- if (devpath.size() == 0)
- {
- printf("Target Mech Device not exist\n");
- return DCS_FAILED;
- }
- string Keystr = "1234";
- while(1)
- {
- CommonLogicClient DevClient;
- DevClient.SetRouter(CCOS_PACKET_ROUTE_LOCAL);
- if (DevClient.Open((const char*)devpath.c_str(), ALL_ACCESS, 10000) >= RET_SUCCEED)
- {
- ResDataObject request, response;
- for (size_t i = 0; i < 1000000; i++)
- {
- DevClient.CleanupQueue();
- DevClient.UpdateDeviceResource();
- //del dpc first
- request.add("P0", "{18FDF176-DECE-445F-A52C-A14BDD3AC2C1}");
- request.add("P1", Keystr.c_str());
- DevClient.Action("DelDPC", request, response);
- //add dpc
- request.clear(); response.clear();
- request.add("P0", "{18FDF176-DECE-445F-A52C-A14BDD3AC2C1}");
- request.add("P1", Keystr.c_str());
- if (DevClient.Action("AddDPC", request, response) < RET_SUCCEED)
- {
- printf("Failed AddDPC\n");
- break;
- }
- //confirm MDPC::DPC exist
- devpath = Devs_Find(szSUBDPC, false);
- if (devpath.size() == 0)
- {
- printf("Failed find MDPC::DPC\n");
- break;
- }
- //connect
- request.clear(); response.clear();
- if (DevClient.Action("Connect", request, response) < RET_SUCCEED)
- {
- printf("Failed Connenct\n");
- break;
- }
- //confirm MDPC::DPC::device exist
- devpath = Devs_Find(szSUBDEV, false);
- if (devpath.size() == 0)
- {
- printf("Failed find MDPC::DPC::DEVICE\n");
- break;
- }
- //for test
- Sleep(2000);
- //print devs
- ResDataObject ReqObj;
- Devs_Func(ReqObj, false);
- //disconnect
- request.clear(); response.clear();
- if (DevClient.Action("DisConnect", request, response) < RET_SUCCEED)
- {
- printf("Failed DisConnect\n");
- break;
- }
- //confirm MDPC::DPC::device gone
- //del dpc
- //request.add("P0", "{18FDF176-DECE-445F-A52C-A14BDD3AC2C1}");
- //request.add("P1", Keystr.c_str());
- //if (DevClient.Action("DelDPC", request, response) < RET_SUCCEED)
- //{
- // printf("DelDPC Failed\n");
- // break;
- //}
- //confirm MDPC::DPC gone
- //break;
- }
- DevClient.Close();
- }
- }
- return DCS_SUCCEED;
- }
- DCS_RET APlatformDcs::Action(ResDataObject &Req)
- {
- //Action ActionName param1[devpath]
- if (Req.size() < 3)
- {
- printf("lack of params\n");
- return DCS_FAILED;
- }
- CommonLogicClient DevClient;
- DevClient.SetRouter(CCOS_PACKET_ROUTE_LOCAL);
- ResDataObject request, response;
- if (DevClient.Open((const char*)Req[2], ALL_ACCESS, 10000) >= RET_SUCCEED)
- {
- request.clear();
- response.clear();
- if (DevClient.Action(Req[1], request, response) < RET_SUCCEED)
- {
- printf("Failed Action:%s\n", (const char *)Req[1]);
- }
- else
- {
- printf("Succeed Action:%s\n", (const char *)Req[1]);
- }
- DevClient.Close();
- return DCS_SUCCEED;
- }
- printf("can't open device:%s\n", (const char*)Req[1]);
- return DCS_FAILED;
- }
- DCS_RET APlatformDcs::Ctrlcpu(ResDataObject &Req)
- {
- char szCtrlDev[] = "/ccosAlpha/CtrlBox/Ccos/Ecom/Mech/1234/{7C5949CE-E47C-446C-8E66-F264A451BE78}";
- //3 param
- //Test CMDIDX ParamContext
- if (Req.size() < 3)
- {
- printf("lack of params\n");
- return DCS_FAILED;
- }
- //CMD
- //Ioctrl1:1
- //Ioctrl2:2
- //GetIO:3
- //Write:4
- //Read:5
- INT CMD = (INT)Req[1];
- ResDataObject Resource;
- ResDataObject request, response;
- CommonLogicClient DevClient;
- DevClient.SetRouter(CCOS_PACKET_ROUTE_LOCAL);
- if (DevClient.Open((const char*)szCtrlDev, ALL_ACCESS, 10000) >= RET_SUCCEED)
- {
- request.clear();
- response.clear();
- switch (CMD){
- case 1:
- if (Req.size() < 3)
- {
- printf("lack of params\n");
- return DCS_FAILED;
- }
- request.add("P0", (unsigned char)Req[1]);
- request.add("P1", (unsigned char)Req[2]);
- DevClient.Action("IOCTRL1", request, response);
- break;
- case 2:
- if (Req.size() < 4)
- {
- printf("lack of params\n");
- return DCS_FAILED;
- }
- request.add("P0", (unsigned char)Req[1]);
- request.add("P1", (unsigned char)Req[2]);
- request.add("P2", (unsigned char)Req[3]);
- DevClient.Action("IOCTRL2", request, response);
- break;
- case 3:
- if (Req.size() < 2)
- {
- printf("lack of params\n");
- return DCS_FAILED;
- }
- request.add("P0", (unsigned char)Req[1]);
- DevClient.Action("GETIO", request, response);
- break;
- case 4:
- if (Req.size() < 3)
- {
- printf("lack of params\n");
- return DCS_FAILED;
- }
- request.add("P0", (unsigned char)Req[1]);
- request.add("P1", (const char*)Req[2]);
- DevClient.Action("WRITE", request, response);
- break;
- case 5:
- if (Req.size() < 2)
- {
- printf("lack of params\n");
- return DCS_FAILED;
- }
- request.add("P0", (unsigned char)Req[1]);
- DevClient.Action("READ", request, response);
- break;
- default:
- printf("no match cmd\n");
- DevClient.Close();
- return DCS_SUCCEED;
- break;
- }
- DevClient.Close();
- }
- return DCS_SUCCEED;
- }
- DCS_RET APlatformDcs::MechTest(ResDataObject &Req)
- {
- //MechTest param1[1:Move,2:Rotate,3:Stop,4:Reset,5:DrTest,6:TomoTest] param2
- //char szCtrlDev[] = "CtrlBox/Ccos/Ecom/Mech/1234/{F868D8BA-9310-4A71-B21F-47DCF8836021}";
- //string devpath = Devs_Find(szCtrlDev, false);
- //if (devpath.size() == 0)
- //{
- // printf("Target Mech Device not exist\n");
- // return DCS_FAILED;
- //}
- ////3 param
- ////Test CMDIDX ParamContext
- //if (Req.size() < 3)
- //{
- // printf("lack of params\n");
- // return DCS_FAILED;
- //}
- //INT CMD = (INT)Req[1];
- //ResDataObject ExamDr;
- //ResDataObject ExamTomo;
- ////"RF":"Tomo" : "1"
- //ResDataObject ExamInfo;
- //ExamDr.add("Single", "1");
- //ExamTomo.add("TOMO", "1");
- //FLOAT Pos = 0;
- //ResDataObject Resource;
- //ResDataObject request, response;
- //CommonLogicClient DevClient;
- //DevClient.SetRouter(CCOS_PACKET_ROUTE_LOCAL);
- //if (DevClient.Open((const char*)devpath.c_str(), ALL_ACCESS, 10000) >= RET_SUCCEED)
- //{
- // request.clear();
- // response.clear();
- // switch (CMD){
- // case 1://Move
- // Pos = atof((const char*)Req[2]);
- // request.add("P0", Pos);
- // if (DevClient.Action("MoveMech", request, response,30000) < RET_SUCCEED)
- // {
- // printf("MoveMech Action Failed\n");
- // }
- // break;
- // case 2://Rotate
- // Pos = atof((const char*)Req[2]);
- // request.add("P0", Pos);
- // if (DevClient.Action("RotateMech", request, response, 30000) < RET_SUCCEED)
- // {
- // printf("RotateMech Action Failed\n");
- // }
- // break;
- // case 3://Stop
- // //request.add("P0", (FLOAT)Req[2]);
- // if (DevClient.Action("StopMech", request, response, 30000) < RET_SUCCEED)
- // {
- // printf("StopMech Action Failed\n");
- // }
- // break;
- // case 4://Reset
- // //request.add("P0", (FLOAT)Req[2]);
- // if (DevClient.Action("RESET", request, response, 30000) < RET_SUCCEED)
- // {
- // printf("RESET Action Failed\n");
- // }
- // break;
- // case 5://DrTest
- // ExamInfo.add("DX", ExamDr);
- // request.add("P0", ExamInfo);
- // if (DevClient.Action("SetExamInfo", request, response, 30000) < RET_SUCCEED)
- // {
- // printf("SetExamInfo Action Failed\n");
- // }
- // request.clear(); response.clear();
- // request.add("P0", "DX");
- // if (DevClient.Action("SelectExamMode", request, response, 30000) < RET_SUCCEED)
- // {
- // printf("SelectExamMode Action Failed\n");
- // }
- // request.clear(); response.clear();
- // if (DevClient.Action("ResetMech", request, response, 30000) < RET_SUCCEED)
- // {
- // printf("ResetMech Action Failed\n");
- // }
- // request.clear(); response.clear();
- // if (DevClient.Action("FramePrep", request, response, 30000) < RET_SUCCEED)
- // {
- // printf("FramePrep Action Failed\n");
- // }
- // request.clear(); response.clear();
- // if (DevClient.Action("FrameReady", request, response, 30000) < RET_SUCCEED)
- // {
- // printf("FramePrep Action Failed\n");
- // }
- // request.clear(); response.clear();
- // if (DevClient.Action("FrameStart", request, response, 30000) < RET_SUCCEED)
- // {
- // printf("FramePrep Action Failed\n");
- // }
- // request.clear(); response.clear();
- // if (DevClient.Action("FrameEnd", request, response, 30000) < RET_SUCCEED)
- // {
- // printf("FramePrep Action Failed\n");
- // }
- // request.clear(); response.clear();
- // if (DevClient.Action("FramePost", request, response, 30000) < RET_SUCCEED)
- // {
- // printf("FramePrep Action Failed\n");
- // }
- // break;
- // case 6://TomoTest
- // ExamInfo.add("DX", ExamTomo);
- // request.add("P0", ExamInfo);
- // if (DevClient.Action("SetExamInfo", request, response, 30000) < RET_SUCCEED)
- // {
- // printf("SetExamInfo Action Failed\n");
- // }
- // else
- // {
- // printf("SetExamInfo Action Succeed\n");
- // }
- // request.clear(); response.clear();
- // if (DevClient.Action("RESET", request, response, 30000) < RET_SUCCEED)
- // {
- // printf("RESET Action Failed\n");
- // }
- // else
- // {
- // printf("RESET Action Succeed\n");
- // }
- // request.clear(); response.clear();
- // request.add("P0", "DX");
- // if (DevClient.Action("SelectExamMode", request, response, 30000) < RET_SUCCEED)
- // {
- // printf("SelectExamMode Action Failed\n");
- // }
- // else
- // {
- // printf("SelectExamMode Action Succeed\n");
- // }
- // request.clear(); response.clear();
- // if (DevClient.Action("FramePrep", request, response, 30000) < RET_SUCCEED)
- // {
- // printf("FramePrep Action Failed\n");
- // }
- // else
- // {
- // printf("FramePrep Action Succeed\n");
- // }
- // request.clear(); response.clear();
- // if (DevClient.Action("FrameReady", request, response, 30000) < RET_SUCCEED)
- // {
- // printf("FrameReady Action Failed\n");
- // }
- // else
- // {
- // printf("FrameReady Action Succeed\n");
- // }
- // printf("Do HSW 1 or 2--------------\n");
- // break;
- // case 7:
- // Pos = atof((const char*)Req[2]);
- // request.add("P0", Pos);
- // if (DevClient.Action("BlindRotateMech", request, response, 30000) < RET_SUCCEED)
- // {
- // printf("RotateMech Action Failed\n");
- // }
- // break;
- // default:
- // printf("no match cmd\n");
- // DevClient.Close();
- // return DCS_SUCCEED;
- // break;
- // }
- // DevClient.Close();
- //}
- //else
- //{
- // printf("Open Device Failed.\nDev:%s\n", devpath.c_str());
- //}
- return DCS_SUCCEED;
- }
- DCS_RET APlatformDcs::Dap(ResDataObject &Req)
- {
- //Dap Param1[0:reset,1:setFilter,2:setSID,3:setColimatorSize,4:setkv,5:setma,6:setms,7:setmas,8:getdap] Param2[num]
- if (Req.size() < 3)
- {
- printf("lack of params\n");
- return DCS_FAILED;
- }
- //
- char szColimator[] = "DAP/DR/Adapter/V2/Device/{566EC9F1-CE5A-4B31-9D2A-E9E80B4CA0CC}";
- char szDap[] = "DAP/DR/Adapter/V2/Device/{DFCB1BE5-C0D7-411B-8DF3-57EA097923CB}";
- char szDpc[] = "DAP/DR/Adapter/V2/1234/{66888A95-CDBE-6CA6-B53F-86185E4B9C88}";
- string devpath = Devs_Find(szDpc, false);
- if (devpath.size() == 0)
- {
- printf("Target Driver not exist\n");
- return DCS_FAILED;
- }
- string dappath = Devs_Find(szDap, false);
- string colimatorpath = Devs_Find(szColimator, false);
- INT Filter = 0;
- FLOAT Pos = 0;
- INT CMD = (INT)Req[1];
- ResDataObject request, response;
- CommonLogicClient DevClient;
- CommonLogicClient DapClient;
- CommonLogicClient ColimatorClient;
- if (
- (DevClient.Open((const char*)devpath.c_str(), ALL_ACCESS, 10000) >= RET_SUCCEED) &&
- (DapClient.Open((const char*)dappath.c_str(), ALL_ACCESS, 10000) >= RET_SUCCEED) &&
- (ColimatorClient.Open((const char*)colimatorpath.c_str(), ALL_ACCESS, 10000) >= RET_SUCCEED)
- )
- {
- request.clear();
- response.clear();
- switch (CMD){
- case 0://ResetDap
- if (DapClient.Action("FramePrep", request, response, 30000) < RET_SUCCEED)
- {
- printf("FramePrep[ResetDap] Action Failed\n");
- }
- else
- {
- printf("FramePrep[ResetDap] succeed\n");
- }
- break;
- case 1://SetCollimatorFilter
- Filter = atoi((const char*)Req[2]);
- request.add("P0", Filter);
- if (ColimatorClient.Action("SetCollimatorFilter", request, response, 30000) < RET_SUCCEED)
- {
- printf("SetCollimatorFilter Action Failed\n");
- }
- else
- {
- printf("SetCollimatorFilter:%d succeed\n", Filter);
- }
- break;
- case 2://SetSID
- Filter = atoi((const char*)Req[2]);
- request.add("P0", Filter);
- if (ColimatorClient.Action("SetCollimatorSID", request, response, 30000) < RET_SUCCEED)
- {
- printf("SetCollimatorSID Action Failed\n");
- }
- else
- {
- printf("SetCollimatorSID:%d succeed\n", Filter);
- }
- break;
- case 3://SetCollimatorSize
- Filter = atoi((const char*)Req[2]);
- request.add("P0", Filter);
- request.add("P1", Filter);
- if (ColimatorClient.Action("SetCollimatorSize", request, response, 30000) < RET_SUCCEED)
- {
- printf("SetCollimatorSize Action Failed\n");
- }
- else
- {
- printf("SetCollimatorSize:%d succeed\n", Filter);
- }
- break;
- case 4://SetKV
- Pos = (FLOAT)atof((const char*)Req[2]);
- request.add("P0", Pos);
- if (DapClient.Action("SetValue_KV", request, response, 30000) < RET_SUCCEED)
- {
- printf("SetValue_KV Action Failed\n");
- }
- else
- {
- printf("SetValue_KV:%f succeed\n", Pos);
- }
- break;
- case 5://SetMA
- Pos = (FLOAT)atof((const char*)Req[2]);
- request.add("P0", Pos);
- if (DapClient.Action("SetValue_MA", request, response, 30000) < RET_SUCCEED)
- {
- printf("SetValue_MA Action Failed\n");
- }
- else
- {
- printf("SetValue_MA:%f Succeed.\n", (FLOAT)response["P0"]);
- }
- break;
- case 6://SetMS
- Pos = (FLOAT)atof((const char*)Req[2]);
- request.add("P0", Pos);
- if (DapClient.Action("SetValue_MS", request, response, 30000) < RET_SUCCEED)
- {
- printf("SetValue_MS Action Failed\n");
- }
- else
- {
- printf("SetValue_MS:%f Succeed.\n", (FLOAT)response["P0"]);
- }
- break;
- case 7://SetMAS
- Pos = (FLOAT)atof((const char*)Req[2]);
- request.add("P0", Pos);
- if (DapClient.Action("SetValue_MAS", request, response, 30000) < RET_SUCCEED)
- {
- printf("SetValue_MAS Action Failed\n");
- }
- else
- {
- printf("SetValue_MAS:%f Succeed.\n", (FLOAT)response["P0"]);
- }
- break;
- case 8://GetDap
- if (DapClient.Action("GetValue_DAP", request, response, 30000) < RET_SUCCEED)
- {
- printf("GetValue_DAP Action Failed\n");
- }
- else
- {
- printf("GetValue_DAP[%f] succeed\n", (FLOAT)response["P0"]);
- }
- break;
- default:
- printf("no match cmd\n");
- return DCS_SUCCEED;
- break;
- }
- }
- else
- {
- printf("Open Device Failed.\nDev:%s\n", devpath.c_str());
- }
- return DCS_SUCCEED;
- }
- DCS_RET APlatformDcs::Gen(ResDataObject &Req)
- {
- char szDev[] = "Generator/DR/Adapter/V2/Device/{F5C377E6-5C3F-4A3C-9C5F-31295A0F7104}";
- char szSeqDev[] = "Generator/DR/Adapter/V2/Device/{3BEA33D7-9F86-8F34-C890-F2596546C005}";
- string devpath = Devs_Find(szDev, false);
- string Seqdevpath = Devs_Find(szSeqDev, false);
- if (devpath.size() == 0 || Seqdevpath.size() == 0)
- {
- printf("Target Mech Device not exist\n");
- return DCS_FAILED;
- }
- ////3 param
- ////Test CMDIDX ParamContext
- if (Req.size() < 3)
- {
- printf("lack of params\n");
- return DCS_FAILED;
- }
- INT CMD = (INT)Req[1];
- //ResDataObject ExamDr;
- //ResDataObject ExamTomo;
- ////"RF":"Tomo" : "1"
- //ResDataObject ExamInfo;
- //ExamDr.add("Single", "1");
- //ExamTomo.add("TOMO", "1");
- FLOAT Pos = 0;
- //ResDataObject Resource;
- ResDataObject request, response;
- CommonLogicClient DevClient;
- CommonLogicClient SeqClient;
- DevClient.SetRouter(CCOS_PACKET_ROUTE_LOCAL);
- SeqClient.SetRouter(CCOS_PACKET_ROUTE_LOCAL);
- if (SeqClient.Open((const char*)Seqdevpath.c_str(), ALL_ACCESS, 10000) < RET_SUCCEED)
- {
- printf("Open Device Failed.\nDev:%s\n", Seqdevpath.c_str());
- return DCS_FAILED;
- }
- if (DevClient.Open((const char*)devpath.c_str(), ALL_ACCESS, 10000) >= RET_SUCCEED)
- {
- request.clear();
- response.clear();
- switch (CMD){
- case 1://SetKV
- Pos = (FLOAT)atof((const char*)Req[2]);
- request.add("P0", Pos);
- if (DevClient.Action("SetValue_KV", request, response,30000) < RET_SUCCEED)
- {
- printf("SetValue_KV Action Failed\n");
- }
- else
- {
- printf("SetValue_KV:%f succeed\n", Pos);
- }
- break;
- case 2://GetKV
- if (DevClient.Action("GetValue_KV", request, response, 30000) < RET_SUCCEED)
- {
- printf("GetValue_KV Action Failed\n");
- }
- else
- {
- printf("GetValue_KV:%f Succeed.\n", (FLOAT)response["P0"]);
- }
- break;
- case 3://IncKV
- if (DevClient.Action("IncParam_KV", request, response, 30000) < RET_SUCCEED)
- {
- printf("IncParam_KV Action Failed\n");
- }
- else
- {
- printf("IncParam_KV Action Succeed\n");
- }
- break;
- case 4://DecKV
- if (DevClient.Action("DecParam_KV", request, response, 30000) < RET_SUCCEED)
- {
- printf("DecParam_KV Action Failed\n");
- }
- else
- {
- printf("DecParam_KV Action Succeed\n");
- }
- break;
- case 5://SetMAS
- Pos = (FLOAT)atof((const char*)Req[2]);
- request.add("P0", Pos);
- if (DevClient.Action("SetValue_MAS", request, response, 30000) < RET_SUCCEED)
- {
- printf("SetValue_MAS Action Failed\n");
- }
- else
- {
- printf("SetValue_MAS:%f succeed\n", Pos);
- }
- break;
- case 6://GetMAS
- if (DevClient.Action("GetValue_MAS", request, response, 30000) < RET_SUCCEED)
- {
- printf("GetValue_MAS Action Failed\n");
- }
- else
- {
- printf("GetValue_MAS:%f Succeed.\n", (FLOAT)response["P0"]);
- }
- break;
- case 7://IncMAS
- if (DevClient.Action("IncParam_MAS", request, response, 30000) < RET_SUCCEED)
- {
- printf("IncParam_MAS Action Failed\n");
- }
- else
- {
- printf("IncParam_MAS Action Succeed\n");
- }
- break;
- case 8://DecMAS
- if (DevClient.Action("DecParam_MAS", request, response, 30000) < RET_SUCCEED)
- {
- printf("DecParam_MAS Action Failed\n");
- }
- else
- {
- printf("DecParam_MAS Action Succeed\n");
- }
- break;
- case 9://SetFocus
- request.add("P0", (const char*)Req[2]);
- if (DevClient.Action("SetValue_FOCUS", request, response, 30000) < RET_SUCCEED)
- {
- printf("SetValue_FOCUS Action Failed\n");
- }
- else
- {
- printf("SetValue_FOCUS Action Succeed\n");
- }
- break;
- case 10://exp status
- if ((INT)Req[2] != 0)
- {
- //exp enable
- if (SeqClient.Action("FrameReady", request, response, 30000) < RET_SUCCEED)
- {
- printf("EnableExp Action Failed\n");
- }
- else
- {
- printf("EnableExp Action Succeed\n");
- }
- }
- else
- {
- //exp disable
- if (SeqClient.Action("FrameOut", request, response, 30000) < RET_SUCCEED)
- {
- printf("DisableExp Action Failed\n");
- }
- else
- {
- printf("DisableExp Action Succeed\n");
- }
- }
-
- break;
- default:
- printf("no match cmd\n");
- DevClient.Close();
- return DCS_SUCCEED;
- break;
- }
- DevClient.Close();
- }
- else
- {
- printf("Open Device Failed.\nDev:%s\n", devpath.c_str());
- }
- SeqClient.Close();
- return DCS_SUCCEED;
- }
- DCS_RET APlatformDcs::FDacq(ResDataObject &Req)
- {
- char szSync[] = "Detector/DRDevice/Trixell/Pixium/3543EZe/{55C509AD-02C8-4E18-8509-B0C6E736936B}";
- char szAcq[] = "Detector/DRDevice/Trixell/Pixium/3543EZe/{65608C98-C66B-4CC4-8C1F-8C616FFE4CC2}";
- string Acqpath = Devs_Find(szAcq, false);
- string Syncpath = Devs_Find(szSync, false);
- if (Acqpath.size() == 0 || Syncpath.size() == 0)
- {
- printf("Target Mech Device not exist\n");
- return DCS_FAILED;
- }
- if (Req.size() < 3)
- {
- printf("lack of params\n");
- return DCS_FAILED;
- }
- INT AcqMode = (INT)Req[1];
- INT Xwindow = (INT)Req[2];
- ResDataObject request, response;
- CommonLogicClient SyncClient;
- CommonLogicClient AcqClient;
- SyncClient.SetRouter(CCOS_PACKET_ROUTE_LOCAL);
- AcqClient.SetRouter(CCOS_PACKET_ROUTE_LOCAL);
- if (AcqClient.Open((const char*)Acqpath.c_str(), ALL_ACCESS, 10000) >= RET_SUCCEED)
- {
- request.add("P0", AcqMode);
- if (AcqClient.Action("SetAcqMode", request, response, 30000) < RET_SUCCEED)
- {
- printf("SetAcqMode Action Failed\n");
- }
- else
- {
- printf("SetAcqMode succeed\n");
- }
- AcqClient.Close();
- }
- else
- {
- printf("Open Device Failed.\nDev:%s\n", Acqpath.c_str());
- }
- if (SyncClient.Open((const char*)Syncpath.c_str(), ALL_ACCESS, 10000) >= RET_SUCCEED)
- {
- if (SyncClient.Action("EnterExam", request, response, 30000) < RET_SUCCEED)
- {
- printf("EnterExam Action Failed\n");
- }
- else
- {
- printf("EnterExam succeed\n");
- }
- request.add("P0", Xwindow);
- if (SyncClient.Action("SetXwindowSize", request, response, 30000) < RET_SUCCEED)
- {
- printf("SetXwindowSize Action Failed\n");
- }
- else
- {
- printf("EnterExam succeed\n");
- }
- if (SyncClient.Action("PrepareAcquisition", request, response, 30000) < RET_SUCCEED)
- {
- printf("PrepareAcquisition Action Failed\n");
- return DCS_FAILED;
- }
- else
- {
- printf("PrepareAcquisition succeed\n");
- }
- if (SyncClient.Action("StartAcquisition", request, response, 30000) < RET_SUCCEED)
- {
- printf("StartAcquisition Action Failed\n");
- return DCS_FAILED;
- }
- else
- {
- printf("StartAcquisition succeed\n");
- }
- if (SyncClient.Action("StopAcquisition", request, response, 30000) < RET_SUCCEED)
- {
- printf("StopAcquisition Action Failed\n");
- return DCS_FAILED;
- }
- else
- {
- printf("StopAcquisition succeed\n");
- }
- if (SyncClient.Action("ExitExam", request, response, 30000) < RET_SUCCEED)
- {
- printf("ExitExam Action Failed\n");
- return DCS_FAILED;
- }
- else
- {
- printf("ExitExam succeed\n");
- }
- SyncClient.Close();
- }
- else
- {
- printf("Open Device Failed.\nDev:%s\n", Syncpath.c_str());
- }
- return DCS_SUCCEED;
- }
- DCS_RET APlatformDcs::FDcalib(ResDataObject &Req)
- {
- char szDev[] = "Detector/DRDevice/Trixell/Pixium/3543EZe/{BE83E2F7-AB62-421C-BC2E-0C40BEEACCFB}";
- string devpath = Devs_Find(szDev, false);
- if (devpath.size() == 0)
- {
- printf("Target Mech Device not exist\n");
- return DCS_FAILED;
- }
- ResDataObject request, response;
- CommonLogicClient DevClient;
- DevClient.SetRouter(CCOS_PACKET_ROUTE_LOCAL);
- if (DevClient.Open((const char*)devpath.c_str(), ALL_ACCESS, 10000) >= RET_SUCCEED)
- {
- request.add("P0", 1);
- if (DevClient.Action("ActiveCalibration", request, response, 30000) < RET_SUCCEED)
- {
- printf("ActiveCalibration Action Failed\n");
- return DCS_FAILED;
- }
- else
- {
- printf("ActiveCalibration succeed\n");
- }
- if (DevClient.Action("GetRequestedDose", request, response, 30000) < RET_SUCCEED)
- {
- printf("GetRequestedDose Action Failed\n");
- return DCS_FAILED;
- }
- else
- {
- printf("GetRequestedDose succeed\n");
- printf("%s", response.encode());
- }
- if (DevClient.Action("PrepareCalibration", request, response, 30000) < RET_SUCCEED)
- {
- printf("PrepareCalibration Action Failed\n");
- return DCS_FAILED;
- }
- else
- {
- printf("PrepareCalibration succeed\n");
- }
- if (DevClient.Action("StartCalibration", request, response, 30000) < RET_SUCCEED)
- {
- printf("StartCalibration Action Failed\n");
- return DCS_FAILED;
- }
- else
- {
- printf("StartCalibration succeed\n");
- }
- if (DevClient.Action("StopCalibration", request, response, 30000) < RET_SUCCEED)
- {
- printf("StopCalibration Action Failed\n");
- return DCS_FAILED;
- }
- else
- {
- printf("StopCalibration succeed\n");
- }
- DevClient.Close();
- }
- else
- {
- printf("Open Device Failed.\nDev:%s\n", devpath.c_str());
- }
- return DCS_SUCCEED;
- }
- DCS_RET APlatformDcs::AddDPC(ResDataObject &Req)
- {
- char szDev[] = "MDPC/RF/Ecom/RFSIM/Demo/{399B143C-80F1-4D90-81D1-7C5CECC63EE8}";
- #define DetectorID ("{18CAB88A-C61C-4BB2-AC28-184FDD4FD160}")
- string devpath = Devs_Find(szDev, false);
- if (devpath.size() == 0)
- {
- printf("Target Mech Device not exist\n");
- return DCS_FAILED;
- }
- ////3 param
- ////Test CMDIDX ParamContext
- if (Req.size() < 3)
- {
- printf("lack of params : %s\n",Req.encode());
- return DCS_FAILED;
- }
- string CMD = (string)Req[1];
- ResDataObject request, response;
- CommonLogicClient DevClient;
- DevClient.SetRouter(CCOS_PACKET_ROUTE_LOCAL);
- if (DevClient.Open((const char*)devpath.c_str(), ALL_ACCESS, 10000) >= RET_SUCCEED)
- {
- request.clear();
- response.clear();
- request.add("P0", DetectorID);
- request.add("P1", CMD.c_str());
- if (DevClient.Action("AddDPC", request, response, 30000) < RET_SUCCEED)
- {
- printf("AddDPC Action Failed\n");
- }
- else
- {
- printf("AddDPC:%s succeed\n", CMD.c_str());
- }
- DevClient.Close();
- }
- else
- {
- printf("Open Device Failed.\nDev:%s\n", devpath.c_str());
- }
- return DCS_SUCCEED;
- }
- DCS_RET APlatformDcs::DelDPC(ResDataObject &Req)
- {
- char szDev[] = "MDPC/RF/Ecom/RFSIM/Demo/{399B143C-80F1-4D90-81D1-7C5CECC63EE8}";
- #define DetectorID ("{18CAB88A-C61C-4BB2-AC28-184FDD4FD160}")
- string devpath = Devs_Find(szDev, false);
- if (devpath.size() == 0)
- {
- printf("Target Mech Device not exist\n");
- return DCS_FAILED;
- }
- ////3 param
- ////Test CMDIDX ParamContext
- if (Req.size() < 3)
- {
- printf("lack of params\n");
- return DCS_FAILED;
- }
- string CMD = (string)Req[1];
- ResDataObject request, response;
- CommonLogicClient DevClient;
- DevClient.SetRouter(CCOS_PACKET_ROUTE_LOCAL);
- if (DevClient.Open((const char*)devpath.c_str(), ALL_ACCESS, 10000) >= RET_SUCCEED)
- {
- request.clear();
- response.clear();
- request.add("P0", DetectorID);
- request.add("P1", CMD.c_str());
- if (DevClient.Action("DelDPC", request, response, 30000) < RET_SUCCEED)
- {
- printf("DelDPC Action Failed\n");
- }
- else
- {
- printf("DelDPC:%s succeed\n", CMD.c_str());
- }
- DevClient.Close();
- }
- else
- {
- printf("Open Device Failed.\nDev:%s\n", devpath.c_str());
- }
- return DCS_SUCCEED;
- }
- DCS_RET APlatformDcs::ConfigDriver(ResDataObject &Req)
- {
- //ConfigDriver param1[0:del,1:add,2:ShowAll] param2[driverpath]
- if (Req.size() < 3)
- {
- printf("lack of params\n");
- return DCS_FAILED;
- }
- ResDataObject req, res;
- INT ActionType = (INT)Req[1];
- string driverpath = (const char*)Req[2];
- if (ActionType == 0)
- {
- //del
- CommonLogicClient Client;
- Client.SetRouter(CCOS_PACKET_ROUTE_LOCAL);
- if (Client.Open("/ccosChannel", ALL_ACCESS, 10000) == RET_SUCCEED)
- {
- req.add("P0", driverpath.c_str());
- if (Client.Action("ConfigRemoveDriver", req, res) >= RET_SUCCEED)
- {
- printf("ConfigRemoveDriver %s Succeed.\n", driverpath.c_str());
- }
- else
- {
- printf("ConfigRemoveDriver %s Failed.\n", driverpath.c_str());
- }
- Client.Close();
- }
- else
- {
- printf("Open local /ccosChannel Failed\n");
- }
- }
- else if (ActionType == 1)
- {
- //add
- CommonLogicClient Client;
- Client.SetRouter(CCOS_PACKET_ROUTE_LOCAL);
- if (Client.Open("/ccosChannel", ALL_ACCESS, 10000) == RET_SUCCEED)
- {
- req.add("P0", driverpath.c_str());
- if (Client.Action("ConfigLoadDriver", req, res) >= RET_SUCCEED)
- {
- printf("ConfigLoadDriver %s Succeed.\n", driverpath.c_str());
- }
- else
- {
- printf("ConfigLoadDriver %s Failed.\n", driverpath.c_str());
- }
- Client.Close();
- }
- else
- {
- printf("Open local /ccosChannel Failed\n");
- }
- }
- else if (ActionType == 2)
- {
- ResDataObject DevResource;
- //showall
- CommonLogicClient Client;
- Client.SetRouter(CCOS_PACKET_ROUTE_LOCAL);
- if (Client.Open("/ccosChannel", ALL_ACCESS, 10000) == RET_SUCCEED)
- {
- Client.GetDeviceResource(&DevResource);
- Client.Close();
- try{
- printf("%s\n", DevResource.encode());
- ResDataObject FulDrvList, ConfigDrvList;
- FulDrvList = DevResource["Attribute"]["FullDriverList"];
- ConfigDrvList = DevResource["Attribute"]["ConfigDriverList"];
- printf("Full Driver List\n");
- for (size_t i = 0; i < FulDrvList.size(); i++)
- {
- printf("FullDriver[%zu]:%s\n", i, (const char *)FulDrvList.GetKey(i));
- }
- printf("\nConfig Driver List\n");
- for (size_t i = 0; i < ConfigDrvList.size(); i++)
- {
- printf("ConfigDriver[%zu]:%s\n", i, (const char *)ConfigDrvList.GetKey(i));
- }
- printf("\n");
- return DCS_SUCCEED;
- }
- catch (...)
- {
- }
- }
- else
- {
- printf("Open local /ccosChannel Failed\n");
- }
- }
- else
- {
- //ignore
- printf("Wrong Type ActionRequest:%d\n", ActionType);
- return DCS_FAILED;
- }
- return DCS_SUCCEED;
- }
- //
- //DCS_RET APlatformDcs::WorkFlowTest(ResDataObject &Req)
- //{
- // CommonLogicClient Client, fpdClient;
- // int nRet;
- // const char* szPathSubsys = "/DevSubSystem/Subsystem/Rf/ecomdemo/demo/1234/{60E2EAAB-0757-4CF3-A547-F0C0A8167359}";
- // const char* szPathRFFpd = "/DevFPD/Detector/RF/ecomdemo/demo/1C70642C/{18CAB88A-C61C-4BB2-AC28-184FDD4FD160}";
- //
- // if (Req.size() < 2)
- // {
- // printf("lack of params\n");
- // return DCS_FAILED;
- // }
- //
- // INT CMD = (INT)Req[1];
- //
- // switch (CMD)
- // {
- // case 1:
- // nRet = Client.Open(szPathSubsys, ALL_ACCESS);
- // printf("Open return %i\n", nRet);
- // if (nRet == RET_SUCCEED)
- // {
- // printf("Open subsystem Device ok\n");
- // ResDataObject Request, Res;
- // nRet = Client.Action("ActivateSubsystem", Request, Res);
- // Request.add("P0", "Table");
- // nRet = Client.Action("SetWorkStation", Request, Res);
- // printf("SetWorkStation return %i\n", nRet);
- // //Sleep(1000);
- // WFTWaitForState(Client, "WorkStation", "");
- // Request.clear();
- // nRet = Client.Action("StartSMMachine", Request, Res);
- // printf("StartSMMachine return %i\n", nRet);
- //
- // //Sleep(1000);
- // WFTWaitForState(Client, "CurrentSMState", "SeqReady");
- // ResDataObject res1, res2, res3, res4, res0, resparam;
- // resparam.clear();
- // resparam.add("P0", 1);
- // res1.add("SetAcqMode", resparam);
- // res2.add("{65608C98-C66B-4CC4-8C1F-8C616FFE4CC2}", res1);
- // //res2.add("", "");
- // res3.add("FramePrep", res2);
- //
- // resparam.clear();
- // res1.clear();
- // res2.clear();
- // resparam.add("P0", "DX");
- // res1.add("SetModality", resparam);
- // res3["FramePrep"].add("{BDDF7891-3C15-4191-98F5-F4A9918B2872}", res1);
- // //res3.add("FramePrep", res2);
- // res0.add("SMOuter", res3);
- //
- //
- // res1.clear();
- // res2.clear();
- // res1.add("StartAcquisition", "");
- // //res2.add("{18CAB88A-C61C-4BB2-AC28-184FDD4FD160}", res1);
- // res2.add("{55C509AD-02C8-4E18-8509-B0C6E736936B}", res1);
- // res4.add("FrameStart", res2);
- //
- // res1.clear();
- // res2.clear();
- // resparam.clear();
- // resparam.add("P0", 3);
- // res1.add("SetGeneratortoSyncStatus", resparam);
- // res2.add("{3BEA33D7-9F86-8F34-C890-F2596546C005}", res1);
- // res4.add("FrameIn", res2);
- //
- // res1.clear();
- // res2.clear();
- // resparam.clear();
- // resparam.add("P0", 4);
- // res1.add("SetGeneratortoSyncStatus", resparam);
- // res2.add("{3BEA33D7-9F86-8F34-C890-F2596546C005}", res1);
- // res4.add("FrameOut", res2);
- //
- // res1.clear();
- // res2.clear();
- // res1.add("StopAcquisition", "");
- // res2.add("{55C509AD-02C8-4E18-8509-B0C6E736936B}", res1);
- // //res2.add("{18CAB88A-C61C-4BB2-AC28-184FDD4FD160}", res1);
- // res4.add("FrameEnd", res2);
- //
- // res0.add("SMFrameAcquiring", res4);
- //
- // Request.clear();
- // Res.clear();
- // Request.add("P0", res0);
- // nRet = Client.Action("SetSEQResourceAction", Request, Res);
- // printf("-----SetSEQResourceAction return %i\n", nRet);
- //
- // // events
- // res0.clear();
- //
- // res1.clear();
- // res2.clear();
- // res3.clear();
- // res3.add("Need", "1");
- // res3.add("ReadFromAttribute", "0");
- // res0.add("EvtFramePrep", res3);
- //
- // res1.clear();
- // res2.clear();
- // res3.clear();
- // res3.add("Need", "1");
- // res3.add("ReadFromAttribute", "0");
- // res1.add("GENERATORSYNCSTATE", "2");
- // res3.add("{3BEA33D7-9F86-8F34-C890-F2596546C005}", res1);
- // res0.add("EvtExpOn", res3);
- //
- // res1.clear();
- // res2.clear();
- // res3.clear();
- // res3.add("Need", "1");
- // res3.add("ReadFromAttribute", "0");
- // res1.add("DETECTORSTATUS", "5");
- // res3.add("{55C509AD-02C8-4E18-8509-B0C6E736936B}", res1);
- // res0.add("EvtFrameAcq", res3);
- //
- // res1.clear();
- // res2.clear();
- // res3.clear();
- // res3.add("Need", "1");
- // res3.add("ReadFromAttribute", "0");
- // res1.add("XWINDOWSTATUS", "1");
- // res3.add("{55C509AD-02C8-4E18-8509-B0C6E736936B}", res1);
- // res0.add("EvtXwinOn", res3);
- //
- // res1.clear();
- // res2.clear();
- // res3.clear();
- // res3.add("Need", "1");
- // res3.add("ReadFromAttribute", "0");
- // res1.add("XWINDOWSTATUS", "0");
- // res3.add("{55C509AD-02C8-4E18-8509-B0C6E736936B}", res1);
- // res0.add("EvtXwinOff", res3);
- //
- // res1.clear();
- // res2.clear();
- // res3.clear();
- // res3.add("Need", "1");
- // res3.add("ReadFromAttribute", "0");
- // res1.add("GENERATORSYNCSTATE", "3");
- // res3.add("{3BEA33D7-9F86-8F34-C890-F2596546C005}", res1);
- // res0.add("EvtXrayOut", res3);
- //
- // res1.clear();
- // res2.clear();
- // res3.clear();
- // res3.add("Need", "1");
- // res3.add("ReadFromAttribute", "0");
- // res1.add("DETECTORSTATUS", "4");
- // res3.add("{55C509AD-02C8-4E18-8509-B0C6E736936B}", res1);
- // res0.add("EvtEndAcq", res3);
- //
- // res1.clear();
- // res2.clear();
- // res3.clear();
- // res3.add("Need", "1");
- // res3.add("ReadFromAttribute", "0");
- // res1.add("GENERATORSYNCSTATE", "0");
- // res3.add("{3BEA33D7-9F86-8F34-C890-F2596546C005}", res1);
- // res0.add("EvtFrameStandby", res3);
- //
- // res1.clear();
- // res2.clear();
- // res3.clear();
- // res3.add("Need", "0");
- // res3.add("ReadFromAttribute", "0");
- // res0.add("EvtEndPost", res3);
- //
- // res1.clear();
- // res2.clear();
- // res3.clear();
- // res3.add("Need", "1");
- // res3.add("ReadFromAttribute", "0");
- // res0.add("EvtFrameError", res3);
- //
- // res1.clear();
- // res2.clear();
- // res3.clear();
- // res3.add("Need", "1");
- // res3.add("ReadFromAttribute", "0");
- // res0.add("EvtFrameRecover", res3);
- //
- // res1.clear();
- // res2.clear();
- // res3.clear();
- // res3.add("Need", "1");
- // res3.add("ReadFromAttribute", "0");
- // res0.add("EvtSeqEnd", res3);
- //
- // Res.clear();
- // Request.clear();
- // Request.add("P0", res0);
- // nRet = Client.Action("SetSEQResourceEvent", Request, Res);
- // printf("-----SetSEQResourceEvent return %i\n", nRet);
- //
- // res1.clear();
- // res2.clear();
- // res3.clear();
- // res1.add("Sensitivity", "Sensitivity");
- // res1.add("DetectorElementPhysicalSize", "PixelSpacing");
- // res1.add("DetectorElementSpacing", "PixelSpacing");
- // res1.add("DetectorActiveShape", "DetectorActiveShape");
- // res1.add("DetectorActiveDimension", "DetectorActiveDimension");
- // res1.add("DetectorActiveOrigin", "DetectorActiveOrigin");
- // res1.add("LossyImageCompression", "LossyImageCompression");
- // res1.add("RescaleType", "RescaleType");
- // res1.add("PixelIntensityRelationship", "PixelIntensityRelationship");
- // res1.add("FPDCoef", "FPDCoef");
- // res2.add("{18CAB88A-C61C-4BB2-AC28-184FDD4FD160}", res1);
- // res3.add("ImgHeader", res2);
- //
- // res1.clear();
- // res2.clear();
- // res1.add("KVP", "KV");
- // res1.add("XRayTubeCurrent", "MA");
- // res1.add("ExposureTime", "MS");
- // res1.add("ExposureTimeinms", "MS");
- // res1.add("Exposure", "DetectorActiveDimension");
- // res1.add("ExposureinmAs", "DetectorActiveOrigin");
- // res1.add("FocusSpot", "LossyImageCompression");
- // res2.add("{F5C377E6-5C3F-4A3C-9C5F-31295A0F7104}", res1);
- // res3.add("FrameHeader", res2);
- //
- // Request.clear();
- // Res.clear();
- // Request.add("P0", res3);
- // Client.Action("SetECMInfo", Request, Res);
- //
- //
- // // TriggerEventSMMachine EvtFramePrep
- // Request.clear();
- // Request.add("P0", "EvtFramePrep");
- // Res.clear();
- // nRet = Client.Action("TriggerEventSMMachine", Request, Res);
- // printf("-----TriggerEventSMMachine return %i\n", nRet);
- //
- // Sleep(500);
- // Client.Close();
- // printf("-- Test step done --\n");
- // return DCS_SUCCEED;
- //
- // }
- //
- // printf("Open subsystem Device failed\n");
- // return DCS_FAILED;
- //
- // break;
- // case 2:
- // {
- // if (Req.size() < 4)
- // {
- // printf("Lack of params\n");
- // return DCS_FAILED;
- // }
- //
- // int nErr = Req[2];
- // string StatePos = (const char *)Req[3];
- //
- // if (WFTSetErrStatus(nErr, StatePos.c_str()))
- // {
- // return DCS_SUCCEED;
- // }
- // break;
- // }
- // case 3:
- // if (WFTTriggerEvtPrep())
- // {
- // return DCS_SUCCEED;
- // }
- // break;
- // case 4:
- // if (!WFTTriggerEvtExpOn())
- // {
- // return DCS_SUCCEED;
- // }
- // break;
- // case 5:
- // if (WFTReset())
- // {
- // return DCS_SUCCEED;
- // }
- // break;
- // case 6:
- // nRet = Client.Open(szPathSubsys, ALL_ACCESS);
- // printf("Open return %i\n", nRet);
- // if (nRet == RET_SUCCEED)
- // {
- // ResDataObject Request, Res;
- // Request.clear();
- // Request.add("P0", "EvtEndPost");
- // nRet = Client.Action("TriggerEventSMMachine", Request, Res);
- // printf("-----TriggerEventSMMachine return %i\n", nRet);
- // Sleep(100);
- // Client.Close();
- // printf("-- Test step done --\n");
- // return DCS_SUCCEED;
- // }
- // break;
- // case 7:
- // nRet = Client.Open(szPathSubsys, ALL_ACCESS);
- // printf("Open return %i\n", nRet);
- // if (nRet == RET_SUCCEED)
- // {
- // ResDataObject Request, Res;
- // Request.clear();
- // nRet = Client.Action("StopSMMachine", Request, Res);
- // printf("-----StopSMMachine return %i\n", nRet);
- // Sleep(100);
- // Client.Close();
- // printf("-- Test step done --\n");
- // return DCS_SUCCEED;
- // }
- // break;
- // case 0:
- // nRet = Client.Open(szPathSubsys, ALL_ACCESS);
- // printf("Open return %i\n", nRet);
- // if (nRet == RET_SUCCEED)
- // {
- // ResDataObject Request, Res;
- // Request.clear();
- // nRet = Client.Action("DeactivateSubsystem", Request, Res);
- // printf("-----DeactivateSubsystem return %i\n", nRet);
- // Sleep(100);
- // Client.Close();
- // printf("-- Test step done --\n");
- // return DCS_SUCCEED;
- // }
- // break;
- // case 100:
- // nRet = Client.Open(szPathSubsys, ALL_ACCESS);
- // printf("Offset calibration, Open return %i\n", nRet);
- // if (nRet == RET_SUCCEED)
- // {
- // Sleep(2000);
- // Client.Close();
- // printf("-- Test step done --\n");
- // return DCS_SUCCEED;
- // }
- // break;
- // case 101:
- // if (WFTCalibrateGain())
- // {
- // return DCS_SUCCEED;
- // }
- // break;
- // case 200:
- // if (WFTActiveAndStartSMForErr())
- // {
- // return DCS_SUCCEED;
- // }
- //
- // break;
- // case 201:
- // {
- // int nErr = 1;
- // if (Req.size() >= 3)
- // nErr = Req[2];
- // if (WFTTestRunAllStates(nErr))
- // {
- // return DCS_SUCCEED;
- // }
- // break;
- // }
- // case 301:
- // {
- // const char* szStateArray[] = { "FrameReady", "FrameStart", "FrameAcq", "FrameIn", "XrayOut", "FrameOut", "FrameEnd", "FramePost", "FramePrep" };
- // bool bRet = true;
- // bRet = WFTActiveAndStartSMForErr();
- // //for (int i = 0; i < ARRAYSIZE(szStateArray); i++)
- // for (int i = 0; i < 5000; i++)
- // {
- // for (int j = 0; bRet && j < 9; j++)
- // {
- // PrintCurTime();
- // printf("Run A round Sub Test:---------------------------------------------------------- [%d]%s\n",i, szStateArray[j]);
- // //for (int erridx = 1; erridx < 4; erridx++)
- // {
- // int erridx = 1;
- // bRet = WFTTestRunOnce(erridx, szStateArray[j]);//errcode:1(ret ng),2(timeout),3(error)
- // erridx = 3;
- // bRet = WFTTestRunOnce(erridx, szStateArray[j]);//errcode:1(ret ng),2(timeout),3(error)
- //
- // }
- // }
- //
- // }
- //
- // if (bRet)
- // {
- // printf("\n\nPressure Test DONE---------------------\n\n");
- // return DCS_SUCCEED;
- // }
- // else
- // {
- // printf("\n\nPressure Test FAILED---------------------\n\n");
- // }
- //
- // }
- // break;
- // default:
- // break;
- // }
- //
- // return DCS_FAILED;
- //}
- //
- //bool APlatformDcs::WFTWaitForState(CommonLogicClient &client, const char* szKey, const char* szState, int nTimeout)
- //{
- // PACKET_CMD cmd;
- // ResDataObject data;
- // ResDataObject context;
- // BaseJsonDataObject<string> key;
- // key.SetKey("CurrentState");
- // string strKey, value;
- // HANDLE notifyhandle = client.GetNotifyHandle();
- // const int nSleep = 10;
- // int nCounter = 0;
- // while (nCounter < nTimeout / nSleep)
- // {
- // while (client.IsDataArrived())
- // {
- // data.clear();
- // cmd = client.ReadCmd(data);
- // int Idx = data.GetFirstOf(CCOS_PACK_KEY);
- // if (Idx >= 0)
- // {
- // strKey = (const char*)data[CCOS_PACK_KEY];
- // }
- // Idx = data.GetFirstOf(CCOS_PACK_CONTEXT);
- // if (Idx >= 0)
- // {
- // context = data[Idx];
- // }
- // value = (string)context;
- // printf("-- cmd:%d ,strKey: %s, value: %s\n", cmd, strKey.c_str(), value.c_str());
- // if (strKey == "CALIBRATIONSTATUS")
- // {
- // m_statWFT->nCalibrationStatus = (int)context;
- // }
- // else if (strKey == "CALIBRATIONPROGRESS")
- // {
- // m_statWFT->nCalibrationProgress = (int)context;
- // }
- // else if (strKey == "CurrentSMState")
- // {
- // if (value == "FrameError")
- // m_statWFT->nSMState = -1;
- // else if (value == "SeqReady")
- // m_statWFT->nSMState = 0;
- // else
- // m_statWFT->nSMState = 1;
- // }
- //
- // if (strlen(szState) > 0)
- // {
- // if (strKey == szKey)
- // {
- // if (strstr(szState, value.c_str()) != NULL)
- // return true;
- // }
- // }
- // else
- // {
- // if (strKey == szKey)
- // return true;
- // }
- //
- // }
- // Sleep(nSleep);
- // nCounter++;
- // }
- //
- // printf("------------WFTWaitForState timedout %s %s\n", szKey, szState);
- // return false;
- //}
- //
- //bool APlatformDcs::WFTActiveAndStartSMForErr()
- //{
- // CommonLogicClient Client, fpdClient;
- // int nRet;
- // const char* szPathSubsys = "/DevSubSystem/Subsystem/Rf/ecomdemo/demo/1234/{60E2EAAB-0757-4CF3-A547-F0C0A8167359}";
- // const char* szPathRFFpd = "/DevFPD/Detector/RF/ecomdemo/demo/1C70642C/{18CAB88A-C61C-4BB2-AC28-184FDD4FD160}";
- // nRet = Client.Open(szPathSubsys, ALL_ACCESS);
- // printf("Test of Exception or Error condition, Open return %i\n", nRet);
- // if (nRet == RET_SUCCEED)
- // {
- // printf("Open subsystem Device ok\n");
- // ResDataObject Request, Res;
- // nRet = Client.Action("ActivateSubsystem", Request, Res);
- // Request.add("P0", "Table");
- // nRet = Client.Action("SetWorkStation", Request, Res);
- // printf("SetWorkStation return %i\n", nRet);
- //
- // WFTWaitForState(Client, "WorkStation", "");
- //
- // Request.clear();
- // nRet = Client.Action("StartSMMachine", Request, Res);
- // printf("StartSMMachine return %i\n", nRet);
- //
- // WFTWaitForState(Client, "CurrentSMState", "SeqReady");
- //
- // ResDataObject res1, res2, res3, res4, res0, resparam;
- // res1.clear();
- // res1.add("SeqReady", "");
- // res2.add("{66888A95-CDBE-6CA6-B53F-86185E4B9C88}", res1); //ErrDisp DPC
- // res3.add("SeqReady", res2);
- // res2.clear();
- //
- // resparam.clear();
- // resparam.add("P0", 1);
- // res1.add("SetAcqMode", resparam);
- // res2.add("{65608C98-C66B-4CC4-8C1F-8C616FFE4CC2}", res1);
- // res1.clear();
- // res1.add("FramePrep", "");
- // res2.add("{66888A95-CDBE-6CA6-B53F-86185E4B9C88}", res1); //ErrDisp DPC
- // res3.add("FramePrep", res2);
- //
- // res1.clear();
- // res1.add("FrameReady", "");
- // res2.clear();
- // res2.add("{66888A95-CDBE-6CA6-B53F-86185E4B9C88}", res1); //ErrDisp DPC
- // res3.add("FrameReady", res2);
- //
- // res1.clear();
- // res1.add("FramePost", "");
- // res2.clear();
- // res2.add("{66888A95-CDBE-6CA6-B53F-86185E4B9C88}", res1); //ErrDisp DPC
- // res3.add("FramePost", res2);
- //
- // resparam.clear();
- // res1.clear();
- // res2.clear();
- // resparam.add("P0", "DX");
- // res1.add("SetModality", resparam);
- // res3["FramePrep"].add("{BDDF7891-3C15-4191-98F5-F4A9918B2872}", res1);
- // //res3.add("FramePrep", res2);
- // res0.add("SMOuter", res3);
- //
- //
- // res1.clear();
- // res2.clear();
- // res1.add("StartAcquisition", "");
- // //res2.add("{18CAB88A-C61C-4BB2-AC28-184FDD4FD160}", res1);
- // res2.add("{55C509AD-02C8-4E18-8509-B0C6E736936B}", res1);
- // res1.clear();
- // res1.add("FrameStart", "");
- // res2.add("{66888A95-CDBE-6CA6-B53F-86185E4B9C88}", res1); //ErrDisp DPC
- // res4.add("FrameStart", res2);
- //
- // res1.clear();
- // res2.clear();
- // resparam.clear();
- // resparam.add("P0", 3);
- // res1.add("SetGeneratortoSyncStatus", resparam);
- // res2.add("{3BEA33D7-9F86-8F34-C890-F2596546C005}", res1);
- // res1.clear();
- // res1.add("FrameIn", "");
- // res2.add("{66888A95-CDBE-6CA6-B53F-86185E4B9C88}", res1); //ErrDisp DPC
- // res4.add("FrameIn", res2);
- //
- // res1.clear();
- // res2.clear();
- // resparam.clear();
- // resparam.add("P0", 4);
- // res1.add("SetGeneratortoSyncStatus", resparam);
- // res2.add("{3BEA33D7-9F86-8F34-C890-F2596546C005}", res1);
- // res1.clear();
- // res1.add("FrameOut", "");
- // res2.add("{66888A95-CDBE-6CA6-B53F-86185E4B9C88}", res1); //ErrDisp DPC
- // res4.add("FrameOut", res2);
- //
- // res1.clear();
- // res2.clear();
- // res1.add("StopAcquisition", "");
- // res2.add("{55C509AD-02C8-4E18-8509-B0C6E736936B}", res1);
- // //res2.add("{18CAB88A-C61C-4BB2-AC28-184FDD4FD160}", res1);
- // res1.clear();
- // res1.add("FrameEnd", "");
- // res2.clear();
- // res2.add("{66888A95-CDBE-6CA6-B53F-86185E4B9C88}", res1); //ErrDisp DPC
- // res4.add("FrameEnd", res2);
- //
- // res1.clear();
- // res1.add("FrameAcq", "");
- // res2.clear();
- // res2.add("{66888A95-CDBE-6CA6-B53F-86185E4B9C88}", res1); //ErrDisp DPC
- // res4.add("FrameAcq", res2);
- //
- // res1.clear();
- // res1.add("XrayOut", "");
- // res2.clear();
- // res2.add("{66888A95-CDBE-6CA6-B53F-86185E4B9C88}", res1); //ErrDisp DPC
- // res4.add("XrayOut", res2);
- //
- // res0.add("SMFrameAcquiring", res4);
- //
- // Request.clear();
- // Res.clear();
- // Request.add("P0", res0);
- // nRet = Client.Action("SetSEQResourceAction", Request, Res);
- // printf("-----SetSEQResourceAction return %i\n", nRet);
- //
- // // events
- // res0.clear();
- //
- // res1.clear();
- // res2.clear();
- // res3.clear();
- // res3.add("Need", "1");
- // res3.add("ReadFromAttribute", "0");
- // res0.add("EvtFramePrep", res3);
- //
- // res1.clear();
- // res2.clear();
- // res3.clear();
- // res3.add("Need", "1");
- // res3.add("ReadFromAttribute", "0");
- // res1.add("GENERATORSYNCSTATE", "2");
- // res3.add("{3BEA33D7-9F86-8F34-C890-F2596546C005}", res1);
- // res0.add("EvtExpOn", res3);
- //
- // res1.clear();
- // res2.clear();
- // res3.clear();
- // res3.add("Need", "1");
- // res3.add("ReadFromAttribute", "1");
- // res1.add("DETECTORSTATUS", "5");
- // res3.add("{55C509AD-02C8-4E18-8509-B0C6E736936B}", res1);
- // res0.add("EvtFrameAcq", res3);
- //
- // res1.clear();
- // res2.clear();
- // res3.clear();
- // res3.add("Need", "1");
- // res3.add("ReadFromAttribute", "0");
- // res1.add("XWINDOWSTATUS", "1");
- // res3.add("{55C509AD-02C8-4E18-8509-B0C6E736936B}", res1);
- // res0.add("EvtXwinOn", res3);
- //
- // res1.clear();
- // res2.clear();
- // res3.clear();
- // res3.add("Need", "1");
- // res3.add("ReadFromAttribute", "0");
- // res1.add("XWINDOWSTATUS", "0");
- // res3.add("{55C509AD-02C8-4E18-8509-B0C6E736936B}", res1);
- // res0.add("EvtXwinOff", res3);
- //
- // res1.clear();
- // res2.clear();
- // res3.clear();
- // res3.add("Need", "1");
- // res3.add("ReadFromAttribute", "0");
- // res1.add("GENERATORSYNCSTATE", "3");
- // res3.add("{3BEA33D7-9F86-8F34-C890-F2596546C005}", res1);
- // res0.add("EvtXrayOut", res3);
- //
- // res1.clear();
- // res2.clear();
- // res3.clear();
- // res3.add("Need", "1");
- // res3.add("ReadFromAttribute", "0");
- // res1.add("DETECTORSTATUS", "4");
- // res3.add("{55C509AD-02C8-4E18-8509-B0C6E736936B}", res1);
- // res0.add("EvtEndAcq", res3);
- //
- // res1.clear();
- // res2.clear();
- // res3.clear();
- // res3.add("Need", "1");
- // res3.add("ReadFromAttribute", "0");
- // res1.add("GENERATORSYNCSTATE", "0");
- // res3.add("{3BEA33D7-9F86-8F34-C890-F2596546C005}", res1);
- // res0.add("EvtFrameStandby", res3);
- //
- // res1.clear();
- // res2.clear();
- // res3.clear();
- // res3.add("Need", "0");
- // res3.add("ReadFromAttribute", "0");
- // res0.add("EvtEndPost", res3);
- //
- // res1.clear();
- // res2.clear();
- // res3.clear();
- // res3.add("Need", "1");
- // res3.add("ReadFromAttribute", "0");
- // res0.add("EvtFrameError", res3);
- //
- // res1.clear();
- // res2.clear();
- // res3.clear();
- // res3.add("Need", "1");
- // res3.add("ReadFromAttribute", "0");
- // res0.add("EvtFrameRecover", res3);
- //
- // res1.clear();
- // res2.clear();
- // res3.clear();
- // res3.add("Need", "1");
- // res3.add("ReadFromAttribute", "0");
- // res0.add("EvtSeqEnd", res3);
- //
- // Res.clear();
- // Request.clear();
- // Request.add("P0", res0);
- // nRet = Client.Action("SetSEQResourceEvent", Request, Res);
- // printf("-----SetSEQResourceEvent return %i\n", nRet);
- //
- // res1.clear();
- // res2.clear();
- // res3.clear();
- // res1.add("Sensitivity", "Sensitivity");
- // res1.add("DetectorElementPhysicalSize", "PixelSpacing");
- // res1.add("DetectorElementSpacing", "PixelSpacing");
- // res1.add("DetectorActiveShape", "DetectorActiveShape");
- // res1.add("DetectorActiveDimension", "DetectorActiveDimension");
- // res1.add("DetectorActiveOrigin", "DetectorActiveOrigin");
- // res1.add("LossyImageCompression", "LossyImageCompression");
- // res1.add("RescaleType", "RescaleType");
- // res1.add("PixelIntensityRelationship", "PixelIntensityRelationship");
- // res1.add("FPDCoef", "FPDCoef");
- // res2.add("{18CAB88A-C61C-4BB2-AC28-184FDD4FD160}", res1);
- // res3.add("ImgHeader", res2);
- //
- // res1.clear();
- // res2.clear();
- // res1.add("KVP", "KV");
- // res1.add("XRayTubeCurrent", "MA");
- // res1.add("ExposureTime", "MS");
- // res1.add("ExposureTimeinms", "MS");
- // res1.add("Exposure", "DetectorActiveDimension");
- // res1.add("ExposureinmAs", "DetectorActiveOrigin");
- // res1.add("FocusSpot", "LossyImageCompression");
- // res2.add("{F5C377E6-5C3F-4A3C-9C5F-31295A0F7104}", res1);
- // res3.add("FrameHeader", res2);
- //
- // Request.clear();
- // Res.clear();
- // Request.add("P0", res3);
- // Client.Action("SetECMInfo", Request, Res);
- //
- //
- //
- // Sleep(500);
- // Client.Close();
- // printf("-- Test step done --\n");
- // return true;
- //
- // }
- //
- // return false;
- //}
- //
- //bool APlatformDcs::WFTTriggerEvtPrep(int nErr)
- //{
- // CommonLogicClient Client;
- // const char* szPathSubsys = "/DevSubSystem/Subsystem/Rf/ecomdemo/demo/1234/{60E2EAAB-0757-4CF3-A547-F0C0A8167359}";
- // const char* szPathRFFpd = "/DevFPD/Detector/RF/ecomdemo/demo/1C70642C/{18CAB88A-C61C-4BB2-AC28-184FDD4FD160}";
- // int nRet = Client.Open(szPathSubsys, ALL_ACCESS);
- // printf("TriggerEvtPrep, Open return %i\n", nRet);
- // if (nRet == RET_SUCCEED)
- // {
- // printf("Open subsystem Device ok\n");
- // ResDataObject Request, Res;
- // // TriggerEventSMMachine EvtFramePrep
- // Request.clear();
- // Request.add("P0", "EvtFramePrep");
- // Res.clear();
- // nRet = Client.Action("TriggerEventSMMachine", Request, Res);
- // printf("-----TriggerEventSMMachine return %i\n", nRet);
- //
- // if (nErr == 0)
- // WFTWaitForState(Client, "CurrentSMState", "FramePrep");
- // else
- // WFTWaitForState(Client, "CurrentSMState", "FrameError");
- //
- // Client.Close();
- // printf("--WFTTriggerEvtPrep Test step done --\n");
- // return true;
- // }
- //
- // printf("Open subsystem Device failed\n");
- // return false;
- //}
- //
- //bool APlatformDcs::WFTTriggerEvtExpOn()
- //{
- // CommonLogicClient Client;
- // const char* szPathSubsys = "/DevSubSystem/Subsystem/Rf/ecomdemo/demo/1234/{60E2EAAB-0757-4CF3-A547-F0C0A8167359}";
- // int nRet = Client.Open(szPathSubsys, ALL_ACCESS);
- // printf("TriggerEvtExpOn, Open return %i\n", nRet);
- // if (nRet == RET_SUCCEED)
- // {
- // printf("Open subsystem Device ok\n");
- // ResDataObject Request, Res;
- // Request.clear();
- // int nImageNumber = 1;
- // Request.add("P0", nImageNumber);
- // nRet = Client.Action("SetExpNumber", Request, Res);
- // printf("-----SetExpNumber %i\n", nImageNumber);
- //
- // Request.clear();
- // Request.add("P0", "EvtExpOn");
- // nRet = Client.Action("TriggerEventSMMachine", Request, Res);
- // printf("-----TriggerEventSMMachine return %i\n", nRet);
- //
- // WFTWaitForState(Client, "CurrentSMState", "SeqReady|FrameError");
- //
- // Client.Close();
- // printf("--WFTTriggerEvtExpOn Test step done --\n");
- // return true;
- // }
- //
- // Sleep(100);
- // printf("Open subsystem Device failed\n");
- // return false;
- //}
- //
- //bool APlatformDcs::WFTSetErrStatus(int nErr, const char* pszState)
- //{
- // const char* szErrDPC = "/DEded1FA3EE2C2/ErrTest/driver/ecom/dispach/1234/{66888A95-CDBE-6CA6-B53F-86185E4B9C88}";
- // CommonLogicClient Client;
- // int nRet = Client.Open(szErrDPC, ALL_ACCESS);
- // printf("Open ErrDPC return %i\n", nRet);
- // if (nRet == RET_SUCCEED)
- // {
- // ResDataObject Request, Res;
- // Request.clear();
- // int nImageNumber = 1;
- // Request.add("P0", nErr);
- // Request.add("P1", pszState);
- // nRet = Client.Action("SetErrStatus", Request, Res);
- // printf("-----SetErrStatus %s err=%i return %i\n", pszState, nErr, nRet);
- // Sleep(50);
- // Client.Close();
- // printf("-- WFTSetErrStatus Test step done --\n");
- // return true;
- // }
- //
- // printf("Open ErrDPC Device failed\n");
- // return false;
- //}
- //
- //bool APlatformDcs::WFTReset(int nErr)
- //{
- // CommonLogicClient Client;
- // const char* szPathSubsys = "/DevSubSystem/Subsystem/Rf/ecomdemo/demo/1234/{60E2EAAB-0757-4CF3-A547-F0C0A8167359}";
- // int nRet = Client.Open(szPathSubsys, ALL_ACCESS);
- // printf("Open return %i\n", nRet);
- // if (nRet == RET_SUCCEED)
- // {
- // ResDataObject Request, Res;
- // Request.clear();
- // nRet = Client.Action("RESET", Request, Res);
- // printf("-----RESET return %i\n", nRet);
- //
- // WFTWaitForState(Client, "CurrentSMState", "FramePrep", 2000);
- //
- // Client.Close();
- // printf("--WFTReset Test step done, state=%i --\n", m_statWFT->nSMState);
- // return true;
- // }
- //
- // printf("WFTReset, Open Device failed\n");
- // return false;
- //}
- //
- //bool APlatformDcs::WFTTestRunAllStates(int nErr)
- //{
- // const char* szStateArray[] = { "FrameReady", "FrameStart", "FrameAcq", "FrameIn", "XrayOut", "FrameOut", "FrameEnd", "FramePost", "FramePrep" };
- // bool bRet;
- // bRet = WFTActiveAndStartSMForErr();
- // //for (int i = 0; i < ARRAYSIZE(szStateArray); i++)
- // for (int i = 0; bRet && i < 9; i++)
- // {
- // bRet = WFTTestRunOnce(nErr, szStateArray[i]);
- // }
- //
- // return bRet;
- //}
- //
- //bool APlatformDcs::WFTTestRunOnce(int nErr, const char* pszState)
- //{
- // bool bRet;
- // bRet = WFTSetErrStatus(nErr, pszState);
- //
- // m_statWFT->nSMState = -1;
- // if (strstr(pszState, "FrameReady") != NULL || strstr(pszState, "FramePrep") != NULL)
- // {
- // bRet = WFTTriggerEvtPrep(nErr);
- // }
- // else
- // {
- // bRet = WFTTriggerEvtPrep();
- // bRet = WFTTriggerEvtExpOn();
- // Sleep(500);
- // }
- //
- // if (nErr != 0)
- // {
- // bRet = WFTReset(nErr);
- // if (m_statWFT->nSMState > 0)
- // bRet = WFTTriggerEvtExpOn();
- // }
- //
- // return bRet;
- //}
- //
- //bool APlatformDcs::WFTCalibrateGain()
- //{
- // bool bRet = WFTCalibrateGainActive();
- //
- // int nCount = 0;
- // while (1)
- // {
- // printf("WFTCalibrateGain %i, press any key...\n", nCount);
- // _getch();
- // bRet = WFTSetAPR();
- //
- // bRet = WFTTriggerEvtPrep();
- //
- // bRet = WFTTriggerEvtExpOn();
- //
- // if (m_statWFT->nCalibrationStatus == 1 || m_statWFT->nCalibrationProgress == 100)
- // {
- // printf("---CALIBRATION Gain done---\n");
- // break;
- // }
- //
- // nCount++;
- // }
- //
- // return bRet;
- //}
- //
- //bool APlatformDcs::WFTCalibrateGainActive()
- //{
- // CommonLogicClient Client;
- // const char* szPathSubsys = "/DevSubSystem/Subsystem/Rf/ecomdemo/demo/1234/{60E2EAAB-0757-4CF3-A547-F0C0A8167359}";
- //
- // m_statWFT->nCalibrationFrame = 0;
- //
- // int nRet = Client.Open(szPathSubsys, ALL_ACCESS);
- // printf("Gain calibration, Open return %i\n", nRet);
- // if (nRet == RET_SUCCEED)
- // {
- // ResDataObject Request, Res;
- // nRet = Client.Action("ActivateSubsystem", Request, Res);
- // Request.add("P0", "Wall");
- // nRet = Client.Action("SetWorkStation", Request, Res);
- // printf("SetWorkStation return %i\n", nRet);
- // //Sleep(1000);
- // WFTWaitForState(Client, "WorkStation", "");
- //
- // // 执行校正单元ActiveCalibration
- // CommonLogicClient fpdClient;
- // string strCalibUnit = Devs_Find("BE83E2F7-AB62-421C-BC2E-0C40BEEACCFB", false);
- // int nRetFpd = fpdClient.Open(strCalibUnit.c_str(), ALL_ACCESS);
- // printf("Open return %i\n", nRetFpd);
- // if (nRetFpd == RET_SUCCEED)
- // {
- // ResDataObject Request, rdoParam, Res;
- // Request.add("P0", 2); // 1:dark, 2:light
- // Res.clear();
- // nRetFpd = fpdClient.Action("ActiveCalibration", Request, Res);
- // printf("ActiveCalibration return %i\n", nRetFpd);
- // fpdClient.Close();
- // }
- //
- //
- //
- // Request.clear();
- // nRet = Client.Action("StartSMMachine", Request, Res);
- // printf("StartSMMachine return %i\n", nRet);
- //
- // //Sleep(1000);
- // WFTWaitForState(Client, "CurrentSMState", "SeqReady");
- // ResDataObject res1, res2, res3, res4, res0, resparam;
- // resparam.clear();
- // resparam.add("P0", 1);
- // res1.add("SetAcqMode", resparam);
- // res2.add("{65608C98-C66B-4CC4-8C1F-8C616FFE4CC2}", res1);
- // //res2.add("", "");
- // res1.clear();
- // res1.add("PrepareCalibration", "");
- // res2.add("{BE83E2F7-AB62-421C-BC2E-0C40BEEACCFB}", res1);
- // res3.add("FramePrep", res2);
- //
- //
- // resparam.clear();
- // res1.clear();
- // res2.clear();
- // resparam.add("P0", "DX");
- // res1.add("SetModality", resparam);
- // res3["FramePrep"].add("{BDDF7891-3C15-4191-98F5-F4A9918B2872}", res1);
- //
- // res1.clear();
- // res2.clear();
- // res1.add("SetExpEnable", "");
- // //res2.add("{18CAB88A-C61C-4BB2-AC28-184FDD4FD160}", res1);
- // res2.add("{18FDF176-DECE-445F-A52C-A14BDD3AC2C1}", res1);
- // res3.add("FrameReady", res2);
- // res0.add("SMOuter", res3);
- //
- // res1.clear();
- // res2.clear();
- // res1.add("StartCalibration", "");
- // //res2.add("{18CAB88A-C61C-4BB2-AC28-184FDD4FD160}", res1);
- // res2.add("{BE83E2F7-AB62-421C-BC2E-0C40BEEACCFB}", res1);
- // res4.add("FrameStart", res2);
- //
- // res1.clear();
- // res2.clear();
- // resparam.clear();
- // resparam.add("P0", 3);
- // res1.add("SetGeneratortoSyncStatus", resparam);
- // res2.add("{3BEA33D7-9F86-8F34-C890-F2596546C005}", res1);
- // res4.add("FrameIn", res2);
- //
- // res1.clear();
- // res2.clear();
- // resparam.clear();
- // resparam.add("P0", 4);
- // res1.add("SetGeneratortoSyncStatus", resparam);
- // res2.add("{3BEA33D7-9F86-8F34-C890-F2596546C005}", res1);
- // res4.add("FrameOut", res2);
- //
- // // StopCalibration由探测器内部调用
- //
- // res0.add("SMFrameAcquiring", res4);
- //
- // Request.clear();
- // Res.clear();
- // Request.add("P0", res0);
- // nRet = Client.Action("SetSEQResourceAction", Request, Res);
- // printf("-----SetSEQResourceAction return %i\n", nRet);
- //
- // // events
- // res0.clear();
- //
- // res1.clear();
- // res2.clear();
- // res3.clear();
- // res3.add("Need", "1");
- // res3.add("ReadFromAttribute", "0");
- // res0.add("EvtFramePrep", res3);
- //
- // res1.clear();
- // res2.clear();
- // res3.clear();
- // res3.add("Need", "1");
- // res3.add("ReadFromAttribute", "0");
- // res1.add("GENERATORSYNCSTATE", "2");
- // res3.add("{3BEA33D7-9F86-8F34-C890-F2596546C005}", res1);
- // res0.add("EvtExpOn", res3);
- //
- // res1.clear();
- // res2.clear();
- // res3.clear();
- // res3.add("Need", "1");
- // res3.add("ReadFromAttribute", "0");
- // res1.add("DETECTORSTATUS", "5");
- // res3.add("{55C509AD-02C8-4E18-8509-B0C6E736936B}", res1);
- // res0.add("EvtFrameAcq", res3);
- //
- // res1.clear();
- // res2.clear();
- // res3.clear();
- // res3.add("Need", "1");
- // res3.add("ReadFromAttribute", "0");
- // res1.add("XWINDOWSTATUS", "1");
- // res3.add("{55C509AD-02C8-4E18-8509-B0C6E736936B}", res1);
- // res0.add("EvtXwinOn", res3);
- //
- // res1.clear();
- // res2.clear();
- // res3.clear();
- // res3.add("Need", "1");
- // res3.add("ReadFromAttribute", "0");
- // res1.add("XWINDOWSTATUS", "0");
- // res3.add("{55C509AD-02C8-4E18-8509-B0C6E736936B}", res1);
- // res0.add("EvtXwinOff", res3);
- //
- // res1.clear();
- // res2.clear();
- // res3.clear();
- // res3.add("Need", "1");
- // res3.add("ReadFromAttribute", "0");
- // res1.add("GENERATORSYNCSTATE", "3");
- // res3.add("{3BEA33D7-9F86-8F34-C890-F2596546C005}", res1);
- // res0.add("EvtXrayOut", res3);
- //
- // res1.clear();
- // res2.clear();
- // res3.clear();
- // res3.add("Need", "1");
- // res3.add("ReadFromAttribute", "0");
- // res1.add("DETECTORSTATUS", "4");
- // res3.add("{55C509AD-02C8-4E18-8509-B0C6E736936B}", res1);
- // res0.add("EvtEndAcq", res3);
- //
- // res1.clear();
- // res2.clear();
- // res3.clear();
- // res3.add("Need", "1");
- // res3.add("ReadFromAttribute", "0");
- // res1.add("DETECTORSTATUS", "4");
- // res3.add("{55C509AD-02C8-4E18-8509-B0C6E736936B}", res1);
- // res0.add("EvtFrameStandby", res3);
- //
- // res1.clear();
- // res2.clear();
- // res3.clear();
- // res3.add("Need", "0");
- // res3.add("ReadFromAttribute", "0");
- // res0.add("EvtEndPost", res3);
- //
- // res1.clear();
- // res2.clear();
- // res3.clear();
- // res3.add("Need", "1");
- // res3.add("ReadFromAttribute", "0");
- // res0.add("EvtFrameError", res3);
- //
- // res1.clear();
- // res2.clear();
- // res3.clear();
- // res3.add("Need", "1");
- // res3.add("ReadFromAttribute", "0");
- // res0.add("EvtFrameRecover", res3);
- //
- // res1.clear();
- // res2.clear();
- // res3.clear();
- // res3.add("Need", "1");
- // res3.add("ReadFromAttribute", "0");
- // res0.add("EvtSeqEnd", res3);
- //
- // Res.clear();
- // Request.clear();
- // Request.add("P0", res0);
- // nRet = Client.Action("SetSEQResourceEvent", Request, Res);
- // printf("-----SetSEQResourceEvent return %i\n", nRet);
- //
- // res1.clear();
- // res2.clear();
- // res3.clear();
- // res1.add("Sensitivity", "Sensitivity");
- // res1.add("DetectorElementPhysicalSize", "PixelSpacing");
- // res1.add("DetectorElementSpacing", "PixelSpacing");
- // res1.add("DetectorActiveShape", "DetectorActiveShape");
- // res1.add("DetectorActiveDimension", "DetectorActiveDimension");
- // res1.add("DetectorActiveOrigin", "DetectorActiveOrigin");
- // res1.add("LossyImageCompression", "LossyImageCompression");
- // res1.add("RescaleType", "RescaleType");
- // res1.add("PixelIntensityRelationship", "PixelIntensityRelationship");
- // res1.add("FPDCoef", "FPDCoef");
- // res2.add("{18CAB88A-C61C-4BB2-AC28-184FDD4FD160}", res1);
- // res3.add("ImgHeader", res2);
- //
- // res1.clear();
- // res2.clear();
- // res1.add("KVP", "KV");
- // res1.add("XRayTubeCurrent", "MA");
- // res1.add("ExposureTime", "MS");
- // res1.add("ExposureTimeinms", "MS");
- // res1.add("Exposure", "DetectorActiveDimension");
- // res1.add("ExposureinmAs", "DetectorActiveOrigin");
- // res1.add("FocusSpot", "LossyImageCompression");
- // res2.add("{F5C377E6-5C3F-4A3C-9C5F-31295A0F7104}", res1);
- // res3.add("FrameHeader", res2);
- //
- // Request.clear();
- // Res.clear();
- // Request.add("P0", res3);
- // Client.Action("SetECMInfo", Request, Res);
- //
- //
- // Sleep(500);
- // Client.Close();
- // printf("-- Test step done --\n");
- // return DCS_SUCCEED;
- // }
- //
- // return DCS_FAILED;
- //}
- //
- //bool APlatformDcs::WFTSetAPR()
- //{
- // CommonLogicClient Client;
- // string strUnit = Devs_Find("F5C377E6-5C3F-4A3C-9C5F-31295A0F7104", false);
- // int nRet = Client.Open(strUnit.c_str(), ALL_ACCESS);
- // printf("Open %s return %i\n", strUnit.c_str(), nRet);
- // if (nRet == RET_SUCCEED)
- // {
- // int nKv = 70;
- // float fMs = 10.0f, fMa = 100.0f, fMas = 1.0f;
- // int nFile;
- // if (m_statWFT->nCalibrationFrame < 10)
- // nFile = 1;
- // else if (m_statWFT->nCalibrationFrame < 11)
- // nFile = 2;
- // else if (m_statWFT->nCalibrationFrame < 12)
- // nFile = 3;
- // else if (m_statWFT->nCalibrationFrame < 13)
- // nFile = 4;
- // char szFileName[256];
- // sprintf_s(szFileName, "_calkv%i.t", nFile);
- // FILE* fParam;
- // fopen_s(&fParam, szFileName, "r");
- // if (fParam != NULL)
- // {
- // char szBuf[4096] = {};
- // size_t uLen = fread(szBuf, 1, 4096, fParam);
- // printf("fread return %u\n", uLen);
- // char* pszNext = NULL;
- // char* pszTok = strtok_s(szBuf, ";", &pszNext);
- // while (pszTok != NULL)
- // {
- // if (strstr(pszTok, "KV=") != NULL)
- // {
- // nKv = atoi(pszTok + 3);
- // }
- // else if (strstr(pszTok, "MA=") != NULL)
- // {
- // fMa = (float)atof(pszTok + 3);
- // }
- // else if (strstr(pszTok, "MS=") != NULL)
- // {
- // fMs = (float)atof(pszTok + 3);
- // }
- // else if (strstr(pszTok, "MAS=") != NULL)
- // {
- // fMas = (float)atof(pszTok + 4);
- // }
- // pszTok = strtok_s(NULL, ";", &pszNext);
- // }
- // fclose(fParam);
- // }
- // m_statWFT->nCalibrationFrame++;
- //
- // ResDataObject Request, rdoParam, Res;
- // rdoParam.add("FOCUS", 0);
- // rdoParam.add("TECHMODE", 0);
- // rdoParam.add("AECFIELD", 0);
- // rdoParam.add("AECFILM", 0);
- // rdoParam.add("AECDENSITY", 0);
- // rdoParam.add("KV", nKv);
- // rdoParam.add("MA", fMa);
- // rdoParam.add("MS", fMs);
- // rdoParam.add("MAS", fMas);
- // rdoParam.add("DOSE", 0.0f);
- // rdoParam.add("FILTER", "");
- // rdoParam.add("TUBELOAD", 0.0f);
- // Request.add("P0", rdoParam);
- // printf("%s\n", Request.encode());
- // Res.clear();
- // nRet = Client.Action("SetAPR", Request, Res);
- // printf("SetAPR return %i\n", nRet);
- // Client.Close();
- // return (nRet == RET_SUCCEED);
- // }
- //
- // return false;
- //}
|