1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275 |
- #include <assert.h>
- #include "Helper.JSON.hpp"
- #include "CCOS.Dev.Generator.Demo.hpp"
- #include "LogLocalHelper.h"
- #include "Log4CPP.h"
- using namespace CCOS::Dev::Detail::Generator;
- namespace nsGEN = CCOS::Dev::Detail::Generator;
- #pragma warning (disable:4305)
- #define DEMO_DAEC_Flag 1
- //-----------------------------------------------------------------------------
- // DemoDevice
- //-----------------------------------------------------------------------------
- float g_MA_List[] = { 8, 10, 12.5, 16, 20, 25, 32, 40, 50, 64, 80, 100, 125, 160, 200, 250, 320, 400, 500, 640 };
- float g_MAS_List[] = { 1, 1.25, 1.6, 2, 2.5, 3.2, 4, 5, 6.4, 8, 10, 12.5, 16, 20, 25, 32, 40, 50, 64, 80, 100, 125, 160, 200, 250, 320, 400, 500, 640, 800, 1000 };
- float g_MS_List[] = { 1, 2, 3, 4, 5, 6, 8, 10, 12, 16, 20, 25, 32, 40, 50, 64, 80, 100, 125, 160, 200, 250, 320, 400, 500, 640, 800, 1000, 1250, 1600, 2000, 2500, 3200, 4000, 5000, 6400, 8000, 10000 };
- float g_KV_List[] = { 400, 405, 410, 415, 420, 430, 440, 450, 460, 470, 480, 490, 500, 510, 520, 535, 550, 560, 570, 585, 600, 615, 630, 645, 660, 680, 700, 715, 730, 750, 770, 790, 810, 830, 850, 875, 900, 930, 960, 1000, 1020, 1050, 1090, 1130, 1170, 1210, 1250, 1290, 1330, 1370, 1410, 1450, 1500 };//<!--KV * 10-->
- int g_AECFIELD_List[] = { 1, 10, 100, 11, 101, 110, 111 };
- std::vector <float> gf_MA_List = { 8, 10, 12.5, 16, 20, 25, 32, 40, 50, 64, 80, 100, 125, 160, 200, 250, 320, 400, 500, 640 };
- std::unique_ptr<OemCollimator> nsGEN::DemoDevice::m_pCollDev = nullptr; //遮光器逻辑实体指针
- std::unique_ptr<OemMechanical> nsGEN::DemoDevice::m_pMechDev = nullptr; //机架逻辑实体指针
- template<typename T>
- int FindPositon(T* pList, int nListSize, T& value)
- {
- if (pList == NULL || nListSize == 0) return -1;
- if (value <= pList[0])
- {
- value = pList[0];
- return 0;
- }
- if (value >= pList[nListSize - 1])
- {
- value = pList[nListSize - 1];
- return nListSize - 1;
- }
- for (int i = 0; i < nListSize - 1; i++)
- {
- if (value >= pList[i] && value <= pList[i + 1])
- {
- int npos = 0;
- if (abs(value - pList[i]) >= abs(value - pList[i + 1]))
- {
- value = pList[i + 1];
- npos = i + 1;
- }
- else
- {
- value = pList[i];
- npos = i;
- }
- return npos;
- }
- }
- return -1;
- }
- nsGEN::DemoDevice::DemoDevice(std::shared_ptr <IOEventCenter> center, string configfile) : super(center), superGen()
- {
- //FINFO("DEMO ver 3.0.0.1");
- if (!configfile.empty())
- {
- ResDataObject Conftemp;
- Conftemp.loadFile(configfile.c_str());
- m_GenConfig = Conftemp["CONFIGURATION"];
- TransJsonText(m_GenConfig);
- string version;
- void* hMyModule;
- if (GetVersion(version, hMyModule))
- FINFO("\n===============log begin : DEMO version:{$} ===================\n", version.c_str());
- else
- FINFO("\n===============log begin : DEMO version:0.0.0.0 ===================\n");
- m_iStateChangeInterval = (int)m_GenConfig["StateChangeInterval"];
- m_iAutoExpActWaitTime = (int)m_GenConfig["AutoExpActWaitTime"];
- m_bIsDemo = ((int)m_GenConfig["IsDemo"]);
- FINFO("Config:StateChangeInterval[{$}],AutoExpActWaitTime[{$}],IsDemo[{$}]",
- m_iStateChangeInterval, m_iAutoExpActWaitTime, m_bIsDemo);
- }
- else
- {
- FINFO("\n===============log begin : DEMO version:3.0.0.1 ===================\n");
- m_iStateChangeInterval = 500;
- m_iAutoExpActWaitTime = 5;
- m_bIsDemo = true;
- FINFO("default:StateChangeInterval[{$}],AutoExpActWaitTime[{$}],IsDemo[{$}]",
- m_iStateChangeInterval, m_iAutoExpActWaitTime, m_bIsDemo);
- }
- //通用
- m_DoseUnit.m_GenSynState.reset(new GENSYNSTATEMould(AttrKey::GENERATOR_RAD_OFF, AttrKey::GENERATOR_RAD_OFF, AttrKey::GENERATOR_RAD_XRAYOFF, 1));
- m_DoseUnit.m_GenState.reset(new GENSTATEMould(4, AttrKey::GENERATOR_STATUS_SHUTDOWN, AttrKey::GENERATOR_STATUS_MAX, 1));
- m_DoseUnit.m_GenTotalExpNumber.reset(new TOTALEXPNUMMould(0, 0, 9999, 1));
- m_DoseUnit.m_GenTotalAcqTimes.reset(new TOTALACQTIMESMould(0, 0, 9999, 1));
- m_DoseUnit.m_GenTubeCoolWaitTimes.reset(new TUBECOOLTIMEMould(0, 0, 9999, 1));
- m_DoseUnit.m_GenTubeOverLoadNumber.reset(new TUBEOVERLOADNUMMould(0, 0, 9999, 1));
- m_DoseUnit.m_GenCurrentExpNumber.reset(new CUREXPNUMMould(0, 0, 9999, 1));
- m_DoseUnit.m_ExpMode.reset(new EXPMODEMould(AttrKey::EXPMODE_TYPE::Single));
- m_DoseUnit.m_WS.reset(new WORKSTATIONMould(1, 0, 5, 1));
- m_DoseUnit.m_HE.reset(new TUBEHEATMould(0, 0, 100, 1));
- m_DoseUnit.m_TubeTargetMaterial.reset(new TUBETARGETMATERIALMould(AttrKey::TUBETARGETMATERIAL_TYPE::MO));
- m_DoseUnit.m_TubeAngle.reset(new TUBEANGLEMould(0, 0, 360, 1));
- //点片
- m_DoseUnit.m_KV.reset(new KVMould(0.0, 0.0, 150.0, 1.0));
- m_DoseUnit.m_MA.reset(new MAMould(0.0, 0.0, 1000.0, 0.1));
- m_DoseUnit.m_MS.reset(new MSMould(0.0, 0.0, 10000.0, 0.01));
- m_DoseUnit.m_MAS.reset(new MASMould(0.0, 0.0, 1000.0, 0.01));
- m_DoseUnit.m_Techmode.reset(new TECHMODEMould(AttrKey::TECHMODE_TYPE::TECHMODE_NOAEC_2P, AttrKey::TECHMODE_NOAEC_3P, AttrKey::TECHMODE_AEC_2P, 1));
- m_DoseUnit.m_Focus.reset(new FOCUSMould(AttrKey::FOCUS_TYPE::FOCUS_LARGE, AttrKey::FOCUS_SMALL, AttrKey::FOCUS_LARGE, 1));
- m_DoseUnit.m_AECField.reset(new AECFIELDMould(0, 0, 111, 1));
- m_DoseUnit.m_AECFilm.reset(new AECFILMMould(0, 0, 2, 1));
- m_DoseUnit.m_AECDensity.reset(new AECDENSITYMould(0, -4, 4, 1));
- m_DoseUnit.m_PostKV.reset(new POSTKVMould(0.0, 0.0, 150.0, 1.0));
- m_DoseUnit.m_PostMA.reset(new POSTMAMould(0.0, 0.0, 1000.0, 0.1));
- m_DoseUnit.m_PostMS.reset(new POSTMSMould(0.0, 0.0, 10000.0, 0.01));
- m_DoseUnit.m_PostMAS.reset(new POSTMASMould(0.0, 0.0, 1000.0, 0.01));
- //透视
- m_DoseUnit.m_FLKV.reset(new FLUKVMould(0.0, 40.0, 150.0, 1));
- m_DoseUnit.m_FLMA.reset(new FLUMAMould(0.0, 0.5, 800.0, 0.1));
- m_DoseUnit.m_FLMS.reset(new FLUMSMould(0.0, 1.0, 10000.0, 0.01));
- m_DoseUnit.m_FLAccTime.reset(new FLAccTimeMould(0.0, 0.0, 300.0, 1));
- m_DoseUnit.m_FLIntTime.reset(new FLUIntTimeMould(0.0, 0.0, 1000.0, 1));
- m_DoseUnit.m_PPS.reset(new PPSMould(0.0, 0.0, 60.0, 1));
- m_DoseUnit.m_FLMode.reset(new FLUModeMould(AttrKey::GENERATOR_FLUMode::GENERATOR_FLMODE_NOTFLU));
- m_DoseUnit.m_ABSStatus.reset(new FLUABSStatusMould(AttrKey::GENERATOR_ABSStatus::GENERATOR_ABS_OFF));
- m_DoseUnit.m_MagSize.reset(new FLUMagMould(0, 0, 3, 1));
- m_DoseUnit.m_DoseLevel.reset(new FLUDoseLevelMould(AttrKey::GENERATOR_DoseLevel::GENERATOR_DOSE_LOW));
- m_DoseUnit.m_Curve.reset(new FLUCurveMould(0, 1, 3, 1));
- //other
- m_MSGUnit.reset(new nsDetail::MSGUnit(center, GeneratorUnitType));
- OnRegister();
- GetConfData();
- //add by wxx:for 品臻3025ZF测试
- m_iAutoExpFlag = 0;
- m_pHardwareStatusThread = 0;
- StartHardwareStatusThread();
- }
- nsGEN::DemoDevice::~DemoDevice()
- {
- FINFO("\n===============log end ===================\n");
- if (m_pHardwareStatusThread != 0) {
- pthread_cancel(m_pHardwareStatusThread); // 请求取消线程
- pthread_join(m_pHardwareStatusThread, nullptr); // 等待线程结束
- m_pHardwareStatusThread = 0;
- }
- m_pCollDev.release();
- m_pCollDev = nullptr;
- m_pMechDev.release();
- m_pMechDev = nullptr;
- }
- void nsGEN::DemoDevice::OnRegister()
- {
- auto Disp = m_Dispatch.Lock().As();
- superGen::Register(Disp);
- superGen::RegisterRAD(Disp);
- superGen::RegisterAEC(Disp);
- superGen::RegisterExpEnable(Disp);
- superGen::RegisterGeneratortoSyncStatus(Disp);
- superGen::RegisterFluoro(Disp);
- Disp->Get.Push(m_MSGUnit->GetKey().c_str(), [this](std::string& out) { out = m_MSGUnit->JSGet(); return RET_STATUS::RET_SUCCEED; });
- auto fun_StartMove = [this](auto in, auto& out)
- {
- return StartMove();
- };
- Disp->Action.Push("StartMove", fun_StartMove);
- auto fun_EndMove = [this](auto in, auto& out)
- {
- return EndMove();
- };
- Disp->Action.Push("EndMove", fun_EndMove);
- auto fun_DirectlyNotify = [this](auto in, auto& out)
- {
- return DirectlyNotify(in);
- };
- Disp->Action.Push("DirectlyNotify", fun_DirectlyNotify);
- auto fun_DirectlyCMD = [this](auto in, auto& out)
- {
- return DirectlyCMD(in);
- };
- Disp->Action.Push("DirectlyCMD", fun_DirectlyCMD);
- }
- //设备方法
- std::string nsGEN::DemoDevice::GetGUID() const
- {
- printf("\n===============GetGUID : %s ===================\n", GeneratorUnitType);
- return GeneratorUnitType;
- }
- RET_STATUS nsGEN::DemoDevice::SetWS(std::string value)
- {
- FDEBUG("Enter SetWS:[{$}]", value.c_str());
- int tempws = 1;
- string strWS = "";
- cfgWorkStationKey trWS = cfgWorkStationKey(value.c_str());
- if (m_arrWSMap.find(trWS) != m_arrWSMap.end())
- {
- m_strCurrentWSName = trWS;
- tempws = m_arrWSMap[m_strCurrentWSName].nWSNamber;
- strWS = m_arrWSMap[m_strCurrentWSName].strWSNAme;
- FDEBUG("Set WS number [{$}][{$}]", strWS.c_str(), tempws);
- }
- else
- {
- FDEBUG("Set WS number default 1");
- m_strCurrentWSName = cfgWorkStationKey(1);
- }
- m_DoseUnit.m_WS->Update(atoi(value.c_str()));
- FireNotify(m_DoseUnit.m_WS->GetKey(), m_DoseUnit.m_WS->JSGet());
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::DemoDevice::QueryHE(int& value)
- {
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::DemoDevice::StartMove() //发生器无此设置
- {
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::DemoDevice::EndMove() //发生器无此设置
- {
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::DemoDevice::DirectlyNotify(string& value)
- {
- ResDataObject json;
- json.decode(value.c_str());
- FDEBUG("Enter DirectlyNotify:[{$}]", json.encode());
- string strKey = (string)json["NotifyKey"];
- string strValue = (string)json["NotifyValue"];
- FireNotify(strKey, strValue);
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::DemoDevice::DirectlyCMD(string& value)
- {
- ResDataObject json;
- json.decode(value.c_str());
- FDEBUG("Enter DirectlyCMD:[{$}]", json.encode());
- string strCMD = (string)json["CMDText"];
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::DemoDevice::SetGenSynState(int value)
- {
- FDEBUG("Enter SetGenSynState:[{$}]", value);
- switch (value)
- {
- case AttrKey::GENERATOR_RAD_OFF:
- {
-
- }break;
- case AttrKey::GENERATOR_RAD_PREPARE:
- {
-
- }break;
- case AttrKey::GENERATOR_RAD_READY:
- {
-
- }break;
- case AttrKey::GENERATOR_RAD_XRAYON:
- {
- if (m_DoseUnit.m_ExpMode->JSGet() == AttrKey::EXPMODE_TYPE::Stitch)
- {
- if (!m_APRarray.empty())
- {
- int aprnum = m_DoseUnit.m_GenCurrentExpNumber->Get();
- SetAPR(m_APRarray[aprnum]);
- m_DoseUnit.m_GenCurrentExpNumber->Update(++aprnum);
- FDEBUG("SetAPRArray:[totalEXP:{$}, currentEXP:{$}]", m_DoseUnit.m_GenTotalExpNumber->Get(), m_DoseUnit.m_GenCurrentExpNumber->Get());
- }
- else
- {
- FWARN("APRarray is empty");
- }
- }
- else if (m_DoseUnit.m_ExpMode->JSGet() == AttrKey::EXPMODE_TYPE::PulseSerial ||
- m_DoseUnit.m_ExpMode->JSGet() == AttrKey::EXPMODE_TYPE::CoutineSerial)
- {
- value = AttrKey::GENERATOR_FLU_XRAYON;
- }
- }break;
- case AttrKey::GENERATOR_RAD_XRAYOFF:
- {
- FINFO("SetGenSynState:4 exp Status value:POSTKV[{$}],POSTMA[{$}],POSTMS[{$}],POSTMAS[{$}]",
- m_DoseUnit.m_PostKV->Get(), m_DoseUnit.m_PostMA->Get(), m_DoseUnit.m_PostMS->Get(), m_DoseUnit.m_PostMAS->Get());
- std::cout << "SetGenSynState:4 exp Status value:POSTKV["
- << m_DoseUnit.m_PostKV->Get()
- << "],POSTMA[" << m_DoseUnit.m_PostMA->Get()
- << "],POSTMS[" << m_DoseUnit.m_PostMS->Get()
- << "],POSTMAS[" << m_DoseUnit.m_PostMAS->Get()
- << "]" << std::endl;
- FireNotify(AttrKey::POSTKV, m_DoseUnit.m_PostKV->JSGet());
- FireNotify(AttrKey::POSTMA, m_DoseUnit.m_PostMA->JSGet());
- #if DEMO_DAEC_Flag
- int temp = m_DoseUnit.m_PostMS->Get();
- if (m_DoseUnit.m_Techmode->Get() == AttrKey::TECHMODE_TYPE::TECHMODE_AEC_3P ||
- m_DoseUnit.m_Techmode->Get() == AttrKey::TECHMODE_TYPE::TECHMODE_AEC_2P ||
- m_DoseUnit.m_Techmode->Get() == AttrKey::TECHMODE_TYPE::TECHMODE_AEC_1P)
- {
- temp /= 2;
- }
- FireNotify(AttrKey::POSTMS, temp);
- #else
- FireNotify(AttrKey::POSTMS, m_DoseUnit.m_PostMS->JSGet());
- #endif // DEMO_DAEC_Flag
- FireNotify(AttrKey::POSTMAS, m_DoseUnit.m_PostMAS->JSGet());
- if (m_DoseUnit.m_ExpMode->JSGet() == AttrKey::EXPMODE_TYPE::PulseSerial ||
- m_DoseUnit.m_ExpMode->JSGet() == AttrKey::EXPMODE_TYPE::CoutineSerial)
- {
- value = AttrKey::GENERATOR_FLU_XRAYOFF;
- }
- }break;
- case AttrKey::GENERATOR_FLU_READY:
- {
-
- }break;
- case AttrKey::GENERATOR_FLU_XRAYON:
- {
-
- }break;
- case AttrKey::GENERATOR_FLU_XRAYOFF:
- {
-
- }break;
- default:
- break;
- }
- m_DoseUnit.m_GenSynState->Update(value);
- FireNotify(m_DoseUnit.m_GenSynState->GetKey(), value);
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::DemoDevice::SetGenState(int value)
- {
- FDEBUG("Enter SetGenState:[{$}]", value);
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::DemoDevice::SetExpEnable()
- {
- FDEBUG("Enter SetExpEnable");
- FINFO("Request Fault Status:GENSTATE STATUS_SHUTDOWN -> STATUS_STANDBY");
- m_DoseUnit.m_GenState->Update(nsGEN::AttrKey::GENERATOR_STATUS_STANDBY);
- FireNotify(AttrKey::GENSTATE, m_DoseUnit.m_GenState->JSGet());
- FireNotify(m_DoseUnit.m_KVList->GetKey(), m_DoseUnit.m_KVList->JSGet());
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::DemoDevice::SetExpDisable()
- {
- FDEBUG("Enter SetExpDisable");
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS CCOS::Dev::Detail::Generator::DemoDevice::PrepareAcquisition()
- {
- m_DoseUnit.m_GenState->Update(nsGEN::AttrKey::GENERATOR_STATUS_STANDBY);
- FireNotify(AttrKey::GENSTATE, m_DoseUnit.m_GenState->JSGet());
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::DemoDevice::Reset()
- {
- FDEBUG("Enter Reset");
- //FireErrorMessage(false, 0, "clear all Gen error");
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::DemoDevice::SetExpMode(std::string value)
- {
- //add for dcm img hard
- FDEBUG("Enter SetExpMode:[{$}]", value.c_str());
- if (m_DoseUnit.m_ExpMode->Update(value))
- {
- FireNotify(AttrKey::EXPMODE, m_DoseUnit.m_ExpMode->JSGet());
- }
- FireNotify(AttrKey::GENSTATE, m_DoseUnit.m_GenState->JSGet());
- m_DoseUnit.m_GenTotalExpNumber->Update(0);
- m_DoseUnit.m_GenCurrentExpNumber->Update(0);
- //add for dcm img hard
- FireNotify(m_DoseUnit.m_TubeTargetMaterial->GetKey(), m_DoseUnit.m_TubeTargetMaterial->JSGet());
- FireNotify(m_DoseUnit.m_TubeAngle->GetKey(), m_DoseUnit.m_TubeAngle->JSGet());
- if (m_pCollDev != nullptr)
- {
- FINFO("act CollDev ReportMessageToDicom");
- m_pCollDev->ReportMessageToDicom();
- }
- if (m_pMechDev != nullptr)
- {
- FINFO("act MechDev ReportMessageToDicom");
- m_pMechDev->ReportMessageToDicom();
- }
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::DemoDevice::SetEXAMMode(std::string value)
- {
- FDEBUG("Enter SetEXAMMode:[{$}]", value.c_str());
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::DemoDevice::ActiveSyncMode(_tSyncModeArgs value)
- {
- FDEBUG("Enter ActiveSyncMode:Sync[{$},{$}],WS[{$}]", value.strSyncMode.c_str(), value.strSyncValue.c_str(), value.strWS.c_str());
- return RET_STATUS::RET_SUCCEED;
- }
- //点片
- RET_STATUS nsGEN::DemoDevice::IncKV()
- {
- FDEBUG("Enter IncKV");
- if (m_bIsDemo)
- {
- if (!m_DoseUnit.m_KV->CanInc()) return RET_STATUS::RET_SUCCEED;
- m_DoseUnit.m_KV->Inc();
- FireNotify(m_DoseUnit.m_KV->GetKey(), m_DoseUnit.m_KV->JSGet());
- m_DoseUnit.m_PostKV->Update(m_DoseUnit.m_KV->Get());
- }
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::DemoDevice::DecKV()
- {
- FDEBUG("Enter DecKV");
- if (m_bIsDemo)
- {
- if (!m_DoseUnit.m_KV->CanDec()) return RET_STATUS::RET_SUCCEED;
- m_DoseUnit.m_KV->Dec();
- m_DoseUnit.m_PostKV->Update(m_DoseUnit.m_KV->Get());
- FireNotify(m_DoseUnit.m_KV->GetKey(), m_DoseUnit.m_KV->JSGet());
- }
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::DemoDevice::SetKV(float value)
- {
- FDEBUG("Enter SetKV:[{$}]", value);
- if (m_bIsDemo)
- {
- m_DoseUnit.m_KV->Update(value);
- m_DoseUnit.m_PostKV->Update(value);
- FireNotify(m_DoseUnit.m_KV->GetKey(), m_DoseUnit.m_KV->JSGet());
- }
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::DemoDevice::IncKVL()
- {
- FDEBUG("Enter IncKVL");
- if (m_bIsDemo)
- {
- float tempKV = m_DoseUnit.m_KV->Get();
- tempKV += 4;
- if (m_DoseUnit.m_KV->Update(tempKV))
- {
- FDEBUG("IncKVL:[{$}] ok", tempKV);
- FireNotify(m_DoseUnit.m_KV->GetKey(), m_DoseUnit.m_KV->JSGet());
- return RET_STATUS::RET_SUCCEED;
- }
- else
- {
- FDEBUG("IncKVL:[{$}] failed,Exceeding limit", tempKV);
- return RET_STATUS::RET_FAILED;
- }
- }
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::DemoDevice::DecKVL()
- {
- FDEBUG("Enter DecKVL");
- if (m_bIsDemo)
- {
- float tempKV = m_DoseUnit.m_KV->Get();
- tempKV -= 4;
- if (m_DoseUnit.m_KV->Update(tempKV))
- {
- FDEBUG("DecKVL:[{$}] ok", tempKV);
- FireNotify(m_DoseUnit.m_KV->GetKey(), m_DoseUnit.m_KV->JSGet());
- return RET_STATUS::RET_SUCCEED;
- }
- else
- {
- FDEBUG("DecKVL:[{$}] failed,Exceeding limit", tempKV);
- return RET_STATUS::RET_FAILED;
- }
- }
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::DemoDevice::IncMA()
- {
- FDEBUG("Enter IncMA");
- if (m_bIsDemo)
- {
- if (m_DoseUnit.m_Techmode->Get() != AttrKey::TECHMODE_TYPE::TECHMODE_NOAEC_3P &&
- m_DoseUnit.m_Techmode->Get() != AttrKey::TECHMODE_TYPE::TECHMODE_AEC_3P)
- {
- FWARN("Techmode is not 3P, can't IncMA");
- return RET_STATUS::RET_SUCCEED;
- }
- float value = m_DoseUnit.m_MA->Get();
- int npos = FindPositon(g_MA_List, sizeof(g_MA_List) / sizeof(float), value);
- if (npos < 0)
- {
- return RET_STATUS::RET_FAILED;
- }
- else if (npos == sizeof(g_MA_List) / sizeof(float) - 1)
- {
- return RET_STATUS::RET_SUCCEED;
- }
- npos += 1;
- float temp = g_MA_List[npos];
- m_DoseUnit.m_MA->Update(temp);
- m_DoseUnit.m_PostMA->Update(temp);
- FireNotify(m_DoseUnit.m_MA->GetKey(), m_DoseUnit.m_MA->JSGet());
- ComputeMAS();
- }
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::DemoDevice::DecMA()
- {
- FDEBUG("Enter DecMA");
- if (m_bIsDemo)
- {
- if (m_DoseUnit.m_Techmode->Get() != AttrKey::TECHMODE_TYPE::TECHMODE_NOAEC_3P &&
- m_DoseUnit.m_Techmode->Get() != AttrKey::TECHMODE_TYPE::TECHMODE_AEC_3P)
- {
- FWARN("Techmode is not 3P, can't DecMA");
- return RET_STATUS::RET_FAILED;
- }
- float value = m_DoseUnit.m_MA->Get();
- int npos = FindPositon(g_MA_List, sizeof(g_MA_List) / sizeof(float), value);
- if (npos < 0)
- {
- return RET_STATUS::RET_FAILED;
- }
- else if (npos == 0)
- {
- return RET_STATUS::RET_SUCCEED;
- }
- npos -= 1;
- float temp = g_MA_List[npos];
- m_DoseUnit.m_MA->Update(temp);
- m_DoseUnit.m_PostMA->Update(temp);
- FireNotify(m_DoseUnit.m_MA->GetKey(), m_DoseUnit.m_MA->JSGet());
- ComputeMAS();
- }
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::DemoDevice::SetMA(float value)
- {
- FDEBUG("Enter SetMA:[{$}]", value);
- if (m_bIsDemo)
- {
- //if (m_DoseUnit.m_Techmode->Get() != AttrKey::TECHMODE_TYPE::TECHMODE_NOAEC_3P &&
- // m_DoseUnit.m_Techmode->Get() != AttrKey::TECHMODE_TYPE::TECHMODE_AEC_3P)
- //{
- // FWARN("Techmode is not 3P, can't SetMA");
- // return RET_STATUS::RET_FAILED;
- //}
- int npos = FindPositon(g_MA_List, sizeof(g_MA_List) / sizeof(float), value);
- if (npos < 0)
- {
- return RET_STATUS::RET_FAILED;
- }
- float temp = g_MA_List[npos];
- m_DoseUnit.m_MA->Update(temp);
- m_DoseUnit.m_PostMA->Update(temp);
- FireNotify(m_DoseUnit.m_MA->GetKey(), m_DoseUnit.m_MA->JSGet());
- }
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::DemoDevice::IncMS()
- {
- FDEBUG("Enter IncMS");
- if (m_bIsDemo)
- {
- if (m_DoseUnit.m_Techmode->Get() != AttrKey::TECHMODE_TYPE::TECHMODE_NOAEC_3P &&
- m_DoseUnit.m_Techmode->Get() != AttrKey::TECHMODE_TYPE::TECHMODE_AEC_3P)
- {
- FWARN("Techmode is not 3P, can't IncMAS");
- return RET_STATUS::RET_FAILED;
- }
- float value = m_DoseUnit.m_MS->Get();
- int npos = FindPositon(g_MS_List, sizeof(g_MS_List) / sizeof(float), value);
- if (npos < 0)
- {
- return RET_STATUS::RET_FAILED;
- }
- else if (npos == sizeof(g_MS_List) / sizeof(float) - 1)
- {
- return RET_STATUS::RET_SUCCEED;
- }
- npos += 1;
- float temp = g_MS_List[npos];
- m_DoseUnit.m_MS->Update(temp);
- m_DoseUnit.m_PostMS->Update(temp);
- FireNotify(m_DoseUnit.m_MS->GetKey(), m_DoseUnit.m_MS->JSGet());
- ComputeMAS();
- }
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::DemoDevice::DecMS()
- {
- FDEBUG("Enter DecMS");
- if (m_bIsDemo)
- {
- if (m_DoseUnit.m_Techmode->Get() != AttrKey::TECHMODE_TYPE::TECHMODE_NOAEC_3P &&
- m_DoseUnit.m_Techmode->Get() != AttrKey::TECHMODE_TYPE::TECHMODE_AEC_3P)
- {
- FWARN("Techmode is not 3P, can't DecMS");
- return RET_STATUS::RET_FAILED;
- }
- float value = m_DoseUnit.m_MS->Get();
- int npos = FindPositon(g_MS_List, sizeof(g_MS_List) / sizeof(float), value);
- if (npos < 0)
- {
- return RET_STATUS::RET_FAILED;
- }
- else if (npos == 0)
- {
- return RET_STATUS::RET_SUCCEED;
- }
- npos -= 1;
- float temp = g_MS_List[npos];
- m_DoseUnit.m_MS->Update(temp);
- m_DoseUnit.m_PostMS->Update(temp);
- FireNotify(m_DoseUnit.m_MS->GetKey(), m_DoseUnit.m_MS->JSGet());
- ComputeMAS();
- }
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::DemoDevice::SetMS(float value)
- {
- FDEBUG("Enter SetMS:[{$}]", value);
- if (m_bIsDemo)
- {
- //if (m_DoseUnit.m_Techmode->Get() != AttrKey::TECHMODE_TYPE::TECHMODE_NOAEC_3P &&
- // m_DoseUnit.m_Techmode->Get() != AttrKey::TECHMODE_TYPE::TECHMODE_AEC_3P)
- //{
- // FWARN("Techmode is not 3P, can't SetMS");
- // return RET_STATUS::RET_FAILED;
- //}
- int npos = FindPositon(g_MS_List, sizeof(g_MS_List) / sizeof(float), value);
- if (npos < 0)
- {
- return RET_STATUS::RET_FAILED;
- }
- float temp = g_MS_List[npos];
- m_DoseUnit.m_MS->Update(temp);
- m_DoseUnit.m_PostMS->Update(temp);
- FireNotify(m_DoseUnit.m_MS->GetKey(), m_DoseUnit.m_MS->JSGet());
- }
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::DemoDevice::IncMAS()
- {
- FDEBUG("Enter IncMAS");
- if (m_bIsDemo)
- {
- /*if (m_DoseUnit.m_Techmode->Get() != AttrKey::TECHMODE_TYPE::TECHMODE_NOAEC_2P &&
- m_DoseUnit.m_Techmode->Get() != AttrKey::TECHMODE_TYPE::TECHMODE_AEC_2P)
- {
- FWARN("Techmode is not 2P, can't IncMAS");
- return RET_STATUS::RET_NOSUPPORT;
- }*/
- float value = m_DoseUnit.m_MAS->Get();
- int npos = FindPositon(g_MAS_List, sizeof(g_MAS_List) / sizeof(float), value);
- if (npos < 0)
- {
- return RET_STATUS::RET_SUCCEED;
- }
- else if (npos == sizeof(g_MAS_List) / sizeof(float) - 1)
- {
- return RET_STATUS::RET_SUCCEED;
- }
- npos += 1;
- float temp = g_MAS_List[npos];
- m_DoseUnit.m_MAS->Update(temp);
- m_DoseUnit.m_PostMAS->Update(temp);
- FireNotify(m_DoseUnit.m_MAS->GetKey(), m_DoseUnit.m_MAS->JSGet());
- }
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::DemoDevice::DecMAS()
- {
- FDEBUG("Enter DecMAS");
- if (m_bIsDemo)
- {
- /*if (m_DoseUnit.m_Techmode->Get() != AttrKey::TECHMODE_TYPE::TECHMODE_NOAEC_2P &&
- m_DoseUnit.m_Techmode->Get() != AttrKey::TECHMODE_TYPE::TECHMODE_AEC_2P)
- {
- FWARN("Techmode is not 2P, can't DecMAS");
- return RET_STATUS::RET_NOSUPPORT;
- }*/
- float value = m_DoseUnit.m_MAS->Get();
- int npos = FindPositon(g_MAS_List, sizeof(g_MAS_List) / sizeof(float), value);
- if (npos < 0)
- {
- return RET_STATUS::RET_FAILED;
- }
- else if (npos == 0)
- {
- return RET_STATUS::RET_SUCCEED;
- }
- npos -= 1;
- float temp = g_MAS_List[npos];
- m_DoseUnit.m_MAS->Update(temp);
- m_DoseUnit.m_PostMAS->Update(temp);
- FireNotify(m_DoseUnit.m_MAS->GetKey(), m_DoseUnit.m_MAS->JSGet());
- }
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::DemoDevice::SetMAS(float value)
- {
- FDEBUG("Enter SetMAS:[{$}]", value);
- if (m_bIsDemo)
- {
- //if (m_DoseUnit.m_Techmode->Get() != AttrKey::TECHMODE_TYPE::TECHMODE_NOAEC_2P &&
- // m_DoseUnit.m_Techmode->Get() != AttrKey::TECHMODE_TYPE::TECHMODE_AEC_2P)
- //{
- // FWARN("Techmode is not 2P, can't SetMAS");
- // return RET_STATUS::RET_NOSUPPORT;
- //}
- int npos = FindPositon(g_MAS_List, sizeof(g_MAS_List) / sizeof(float), value);
- if (npos < 0)
- {
- return RET_STATUS::RET_FAILED;
- }
- float temp = g_MAS_List[npos];
- m_DoseUnit.m_MAS->Update(temp);
- m_DoseUnit.m_PostMAS->Update(temp);
- FireNotify(m_DoseUnit.m_MAS->GetKey(), m_DoseUnit.m_MAS->JSGet());
- }
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::DemoDevice::IncMASL()
- {
- FDEBUG("Enter IncMASL");
- if (m_bIsDemo)
- {
- if (m_DoseUnit.m_Techmode->Get() != AttrKey::TECHMODE_TYPE::TECHMODE_NOAEC_2P &&
- m_DoseUnit.m_Techmode->Get() != AttrKey::TECHMODE_TYPE::TECHMODE_AEC_2P)
- {
- FWARN("Techmode is not 2P, can't IncMASL");
- return RET_STATUS::RET_NOSUPPORT;
- }
- float tempMAS = m_DoseUnit.m_MAS->Get();
- tempMAS += 4;
- if (m_DoseUnit.m_MAS->Update(tempMAS))
- {
- FDEBUG("IncMASL:[{$}] ok", tempMAS);
- FireNotify(m_DoseUnit.m_MAS->GetKey(), m_DoseUnit.m_MAS->JSGet());
- return RET_STATUS::RET_SUCCEED;
- }
- else
- {
- FDEBUG("IncMASL:[{$}] failed,Exceeding limit", tempMAS);
- return RET_STATUS::RET_FAILED;
- }
- }
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::DemoDevice::DecMASL()
- {
- FDEBUG("Enter DecMASL");
- if (m_bIsDemo)
- {
- if (m_DoseUnit.m_Techmode->Get() != AttrKey::TECHMODE_TYPE::TECHMODE_NOAEC_2P &&
- m_DoseUnit.m_Techmode->Get() != AttrKey::TECHMODE_TYPE::TECHMODE_AEC_2P)
- {
- FWARN("Techmode is not 2P, can't DecMASL");
- return RET_STATUS::RET_NOSUPPORT;
- }
- float tempMAS = m_DoseUnit.m_MAS->Get();
- tempMAS -= 4;
- if (m_DoseUnit.m_MAS->Update(tempMAS))
- {
- FDEBUG("DecMASL:[{$}] ok", tempMAS);
- FireNotify(m_DoseUnit.m_MAS->GetKey(), m_DoseUnit.m_MAS->JSGet());
- return RET_STATUS::RET_SUCCEED;
- }
- else
- {
- FDEBUG("DecMASL:[{$}] failed,Exceeding limit", tempMAS);
- return RET_STATUS::RET_FAILED;
- }
- }
- return RET_STATUS::RET_SUCCEED;
- }
- void nsGEN::DemoDevice::ComputeMAS()
- {
- float tempMa = m_DoseUnit.m_MA->Get();
- float tempMs = m_DoseUnit.m_MS->Get();
- float tempMAS = tempMa * tempMs / 1000.0f;
- //m_DoseUnit.m_MAS->Update(tempMAS);
- m_DoseUnit.m_PostMAS->Update(tempMAS);
- FDEBUG("ComputeMAS:MA[{$}] MS[{$}] tempMAS[{$}] MAS[{$}] postMAS[{$}]",
- tempMa, tempMs,tempMAS,m_DoseUnit.m_MAS->Get(), m_DoseUnit.m_PostMAS->Get());
- FireNotify(m_DoseUnit.m_MAS->GetKey(), tempMAS);
- }
- RET_STATUS nsGEN::DemoDevice::SetTechmode(int value)
- {
- FDEBUG("Enter SetTechmode:[{$}]", value);
- if (m_bIsDemo)
- {
- if (!m_DoseUnit.m_Techmode->Verify(value)) return RET_STATUS::RET_SUCCEED;
- m_DoseUnit.m_Techmode->Update(value);
- FireNotify(m_DoseUnit.m_Techmode->GetKey(), m_DoseUnit.m_Techmode->JSGet());
- switch (value)
- {
- case AttrKey::TECHMODE_TYPE::TECHMODE_NOAEC_3P:
- {
- FireNotify(m_DoseUnit.m_MA->GetKey(), m_DoseUnit.m_MA->JSGet());
- FireNotify(m_DoseUnit.m_MS->GetKey(), m_DoseUnit.m_MS->JSGet());
- ComputeMAS();
- }
- break;
- case AttrKey::TECHMODE_TYPE::TECHMODE_NOAEC_2P:
- {
- FireNotify(m_DoseUnit.m_MA->GetKey(), "0");
- FireNotify(m_DoseUnit.m_MS->GetKey(), "0");
- FireNotify(m_DoseUnit.m_MAS->GetKey(), m_DoseUnit.m_MAS->JSGet());
- }
- break;
- case AttrKey::TECHMODE_TYPE::TECHMODE_AEC_3P:
- {
- FireNotify(m_DoseUnit.m_MA->GetKey(), m_DoseUnit.m_MA->JSGet());
- FireNotify(m_DoseUnit.m_MS->GetKey(), m_DoseUnit.m_MS->JSGet());
- ComputeMAS();
- }
- break;
- case AttrKey::TECHMODE_TYPE::TECHMODE_AEC_2P:
- {
- FireNotify(m_DoseUnit.m_MA->GetKey(), "0");
- FireNotify(m_DoseUnit.m_MS->GetKey(), "0");
- FireNotify(m_DoseUnit.m_MAS->GetKey(), m_DoseUnit.m_MAS->JSGet());
- }
- break;
- }
- }
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::DemoDevice::SetFocus(int value)
- {
- FDEBUG("Enter SetFocus:[{$}]", value);
- if (m_bIsDemo)
- {
- if (!m_DoseUnit.m_Focus->Verify(value)) return RET_STATUS::RET_SUCCEED;
- m_DoseUnit.m_Focus->Update(value);
- FireNotify(m_DoseUnit.m_Focus->GetKey(), m_DoseUnit.m_Focus->JSGet());
- if (m_DoseUnit.m_Focus->Get() == AttrKey::FOCUS_SMALL)
- FireNotify(AttrKey::FOCUSSIZE, m_DoseUnit.m_FocusSmall);
- else
- FireNotify(AttrKey::FOCUSSIZE, m_DoseUnit.m_FocusLarge);
- }
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::DemoDevice::SetAECDensity(int value)
- {
- FDEBUG("Enter SetAECDensity:[{$}]", value);
- if (m_bIsDemo)
- {
- if (m_DoseUnit.m_Techmode->Get() != AttrKey::TECHMODE_TYPE::TECHMODE_AEC_1P &&
- m_DoseUnit.m_Techmode->Get() != AttrKey::TECHMODE_TYPE::TECHMODE_AEC_2P &&
- m_DoseUnit.m_Techmode->Get() != AttrKey::TECHMODE_TYPE::TECHMODE_AEC_3P)
- {
- printf("\n Techmode is not AEC, can't SetAECDensity");
- return RET_STATUS::RET_NOSUPPORT;
- }
- if (!m_DoseUnit.m_AECDensity->Verify(value)) return RET_STATUS::RET_FAILED;
- m_DoseUnit.m_AECDensity->Update(value);
- FireNotify(m_DoseUnit.m_AECDensity->GetKey(), m_DoseUnit.m_AECDensity->JSGet());
- }
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::DemoDevice::IncAECDensity()
- {
- FDEBUG("Enter IncAECDensity");
- if (m_bIsDemo)
- {
- FDEBUG("Enter IncAECDensity");
- if (m_DoseUnit.m_Techmode->Get() != AttrKey::TECHMODE_TYPE::TECHMODE_AEC_1P &&
- m_DoseUnit.m_Techmode->Get() != AttrKey::TECHMODE_TYPE::TECHMODE_AEC_2P &&
- m_DoseUnit.m_Techmode->Get() != AttrKey::TECHMODE_TYPE::TECHMODE_AEC_3P)
- {
- FWARN("Techmode is not AEC, can't IncAECDensity");
- return RET_STATUS::RET_NOSUPPORT;
- }
- if (m_DoseUnit.m_AECDensity->CanInc())
- {
- m_DoseUnit.m_AECDensity->Inc();
- FireNotify(m_DoseUnit.m_AECDensity->GetKey(), m_DoseUnit.m_AECDensity->JSGet());
- }
- }
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::DemoDevice::DecAECDensity()
- {
- FDEBUG("Enter DecAECDensity");
- if (m_bIsDemo)
- {
- FDEBUG("Enter DecAECDensity");
- if (m_DoseUnit.m_Techmode->Get() != AttrKey::TECHMODE_TYPE::TECHMODE_AEC_1P &&
- m_DoseUnit.m_Techmode->Get() != AttrKey::TECHMODE_TYPE::TECHMODE_AEC_2P &&
- m_DoseUnit.m_Techmode->Get() != AttrKey::TECHMODE_TYPE::TECHMODE_AEC_3P)
- {
- FWARN("Techmode is not AEC, can't DecAECDensity");
- return RET_STATUS::RET_NOSUPPORT;
- }
- if (m_DoseUnit.m_AECDensity->CanDec())
- {
- m_DoseUnit.m_AECDensity->Dec();
- FireNotify(m_DoseUnit.m_AECDensity->GetKey(), m_DoseUnit.m_AECDensity->JSGet());
- }
- }
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::DemoDevice::SetAECField(int value)
- {
- FDEBUG("Enter SetAECField:[{$}]", value);
- if (m_bIsDemo)
- {
- if (m_DoseUnit.m_Techmode->Get() != AttrKey::TECHMODE_V2TYPE::ET_AEC)
- {
- printf("\n Techmode is not AEC, can't set AEC");
- return RET_STATUS::RET_FAILED;
- }
- if (!m_DoseUnit.m_AECField->Verify(value)) return RET_STATUS::RET_SUCCEED;
- int npos = FindPositon(g_AECFIELD_List, sizeof(g_AECFIELD_List) / sizeof(int), value);
- if (npos < 0)
- {
- return RET_STATUS::RET_FAILED;
- }
- int temp = value;
- m_DoseUnit.m_AECField->Update(temp);
- FireNotify(m_DoseUnit.m_AECField->GetKey(), m_DoseUnit.m_AECField->JSGet());
- }
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::DemoDevice::SetAECFilm(int value)
- {
- FDEBUG("Enter SetAECFilm:[{$}]", value);
- if (m_bIsDemo)
- {
- if (m_DoseUnit.m_Techmode->Get() != AttrKey::TECHMODE_V2TYPE::ET_AEC)
- {
- printf("\n Techmode is not AEC, can't set AEC");
- return RET_STATUS::RET_FAILED;
- }
- if (!m_DoseUnit.m_AECFilm->Verify(value)) return RET_STATUS::RET_SUCCEED;
- m_DoseUnit.m_AECFilm->Update(value);
- FireNotify(m_DoseUnit.m_AECFilm->GetKey(), m_DoseUnit.m_AECFilm->JSGet());
- }
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::DemoDevice::SetAPR(const _tAPRArgs& t)
- {
- FDEBUG("SetAPR:KV={$},MA={$},MS={$},MAS={$},Focus={$},Techmode={$},WS={$},AECDensity={$},AECField={$},AECFilm={$}",
- t.fKV, t.fMA, t.fMS, t.fMAS, t.nFocus, t.nTechmode, t.nWS, t.nAECDensity, t.nAECField, t.nAECFilm);
- if (m_bIsDemo)
- {
- //note:缺少WS
- SetTechmode(t.nTechmode);
- SetKV(t.fKV);
- SetMA(t.fMA);
- SetMS(t.fMS);
- SetMAS(t.fMAS);
- SetFocus(t.nFocus);
- SetAECDensity(t.nAECDensity);
- SetAECField(t.nAECField);
- SetAECFilm(t.nAECFilm);
- if (m_DoseUnit.m_Techmode->Get() == AttrKey::TECHMODE_TYPE::TECHMODE_NOAEC_3P ||
- m_DoseUnit.m_Techmode->Get() == AttrKey::TECHMODE_TYPE::TECHMODE_AEC_3P)
- {
- ComputeMAS();
- }
- m_DoseUnit.m_HE->Update(50);
- FireNotify(m_DoseUnit.m_HE->GetKey(), m_DoseUnit.m_HE->JSGet());
- }
- else
- {
- FireNotify(m_DoseUnit.m_Techmode->GetKey(), t.nTechmode);
- FireNotify(m_DoseUnit.m_KV->GetKey(), t.fKV);
- FireNotify(m_DoseUnit.m_MA->GetKey(), t.fMA);
- FireNotify(m_DoseUnit.m_MS->GetKey(), t.fMS);
- FireNotify(m_DoseUnit.m_MAS->GetKey(), t.fMAS);
- FireNotify(m_DoseUnit.m_Focus->GetKey(), t.nFocus);
- FireNotify(m_DoseUnit.m_AECDensity->GetKey(), t.nAECDensity);
- FireNotify(m_DoseUnit.m_AECField->GetKey(), t.nAECField);
- FireNotify(m_DoseUnit.m_AECFilm->GetKey(), t.nAECFilm);
- }
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::DemoDevice::SetAPRArray(vector<_tAPRArgs>& APRarray)
- {
- FDEBUG("SetAPRArray:[size:{$}]", APRarray.size());
- if (m_bIsDemo)
- {
- m_APRarray = APRarray;
- for (int i = 0; i < m_APRarray.size(); i++)
- {
- FDEBUG("APRArray[{$}]:WS={$},Techmode={$},Focus={$},KV={$},MA={$},MS={$},MAS={$},AECDensity={$},AECField={$},AECFilm={$}",
- i, m_APRarray[i].nWS, m_APRarray[i].nTechmode, m_APRarray[i].nFocus,
- m_APRarray[i].fKV, m_APRarray[i].fMA, m_APRarray[i].fMS, m_APRarray[i].fMAS,
- m_APRarray[i].nAECDensity, m_APRarray[i].nAECField, m_APRarray[i].nAECFilm);
- }
- if (!m_APRarray.empty())
- {
- SetAPR(m_APRarray[0]);
- m_DoseUnit.m_GenTotalExpNumber->Update(m_APRarray.size());
- m_DoseUnit.m_GenCurrentExpNumber->Update(1);
- FDEBUG("SetAPRArray:[totalEXP:{$}, currentEXP:{$}]", m_DoseUnit.m_GenTotalExpNumber->Get(), m_DoseUnit.m_GenCurrentExpNumber->Get());
- }
- }
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::DemoDevice::QueryPostKV(float& value)
- {
- value = m_DoseUnit.m_KV->Get();
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::DemoDevice::QueryPostMA(float& value)
- {
- value = m_DoseUnit.m_MA->Get();
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::DemoDevice::QueryPostMS(float& value)
- {
- value = m_DoseUnit.m_MS->Get();
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::DemoDevice::QueryPostMAS(float& value)
- {
- value = m_DoseUnit.m_MAS->Get();
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::DemoDevice::SetFrameRate(float frameRate)
- {
- FDEBUG("Enter SetFrameRate:[{$}]", frameRate);
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::DemoDevice::SetCollimatorDev(OemCollimator* dev)
- {
- FDEBUG("Enter SetCollimatorDev");
- if (dev)
- m_pCollDev.reset(dev);
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::DemoDevice::SetMechDev(OemMechanical* dev)
- {
- FDEBUG("Enter SetMechDev");
- if (dev)
- m_pMechDev.reset(dev);
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::DemoDevice::SetCollimatorSize(int xsize, int ysize)
- {
- FDEBUG("Enter SetCollimatorSize:[x:{$}, y:{$}]", xsize, ysize);
- if (m_pCollDev)
- {
- m_pCollDev->UpdateCollimatorXSize(xsize);
- m_pCollDev->UpdateCollimatorYSize(ysize);
- }
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::DemoDevice::SetCollimatorLight(unsigned short pParams)
- {
- FDEBUG("Enter SetCollimatorLight:[{$}]", (int)pParams);
- //此处应该发送指令给GEN,并且该指令可以控制 coll 的LED
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::DemoDevice::SetAutoTracking(int nAutoTracking)
- {
- FDEBUG("Enter SetAutoTracking:[{$}]", nAutoTracking);
- if (m_pMechDev)
- m_pMechDev->UpdateMammo_Depress(nAutoTracking);
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::DemoDevice::SetFilter(int nFilterType)
- {
- FDEBUG("Enter SetFilter:[{$}]", nFilterType);
- if (m_pMechDev)
- {
- m_pMechDev->UpdateMammo_FT(nFilterType);
- }
- if (m_pCollDev)
- {
- m_pCollDev->UpdateCollimatorFilter(nFilterType);
- }
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::DemoDevice::SetGrid(int nGridType)
- {
- FDEBUG("Enter SetGrid:[{$}]", nGridType);
- if (m_pMechDev)
- m_pMechDev->UpdateGrid(nGridType);
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::DemoDevice::GetTomoResults(ResDataObject& resultAngle, ResDataObject& resultHeight)
- {
- RET_STATUS ret = RET_STATUS::RET_SUCCEED;
- if (resultAngle.size() == 1 && resultHeight.size() == 1)
- {
- m_resultAngle.update(resultAngle.GetKey(0), (float)resultAngle[0]);
- FINFO("GetTomoResults insert, key={$},value={$}", resultAngle.GetKey(0), (float)resultAngle[0]);
- }
- else
- {
- FINFO("GetTomoResults size={$}", m_resultAngle.size());
- for (int i = 0; i < m_resultAngle.size(); i++)
- {
- resultAngle.update(m_resultAngle.GetKey(i), (float)m_resultAngle[i]);
- FINFO("GetTomoResults ket={$} ,resule={$}", m_resultAngle.GetKey(i), (float)m_resultAngle[i]);
- }
- resultHeight.update("0", 63.71);
- resultHeight.update("1", 63.97);
- resultHeight.update("2", 64.21);
- resultHeight.update("3", 64.41);
- resultHeight.update("4", 64.59);
- resultHeight.update("5", 64.73);
- resultHeight.update("6", 64.84);
- resultHeight.update("7", 64.92);
- resultHeight.update("8", 64.97);
- resultHeight.update("9", 64.99);
- resultHeight.update("10", 64.98);
- resultHeight.update("11", 64.94);
- resultHeight.update("12", 64.87);
- resultHeight.update("13", 64.72);
- resultHeight.update("14", 64.63);
- resultHeight.update("15", 64.47);
- resultHeight.update("16", 64.28);
- resultHeight.update("17", 64.05);
- m_resultAngle.clear();
- }
- return ret;
- }
- //透视
- RET_STATUS nsGEN::DemoDevice::IncFluKV()
- {
- FDEBUG("Enter IncFluKV");
- float KV = m_DoseUnit.m_FLKV->Get()+1;
- if (m_DoseUnit.m_FLKV->Update(KV))
- {
- FireNotify(m_DoseUnit.m_FLKV->GetKey(), m_DoseUnit.m_FLKV->JSGet());
- }
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::DemoDevice::DecFluKV()
- {
- FDEBUG("Enter DecFluKV");
- float KV = m_DoseUnit.m_FLKV->Get() - 1;
- if (m_DoseUnit.m_FLKV->Update(KV))
- {
- FireNotify(m_DoseUnit.m_FLKV->GetKey(), m_DoseUnit.m_FLKV->JSGet());
- }
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::DemoDevice::SetFluKV(float value)
- {
- FDEBUG("Enter SetFluKV:[{$}]", value);
- if (m_DoseUnit.m_FLKV->Update(value))
- {
- FireNotify(m_DoseUnit.m_FLKV->GetKey(), m_DoseUnit.m_FLKV->JSGet());
- }
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::DemoDevice::IncFluMA()
- {
- FDEBUG("Enter IncFluKV");
- float MA = m_DoseUnit.m_FLMA->Get()+1;
- if (m_DoseUnit.m_FLMA->Update(MA))
- {
- FireNotify(m_DoseUnit.m_FLMA->GetKey(), m_DoseUnit.m_FLMA->JSGet());
- }
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::DemoDevice::DecFluMA()
- {
- FDEBUG("Enter DecFluKV");
- float MA = m_DoseUnit.m_FLMA->Get() - 1;
- if (m_DoseUnit.m_FLMA->Update(MA))
- {
- FireNotify(m_DoseUnit.m_FLMA->GetKey(), m_DoseUnit.m_FLMA->JSGet());
- }
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::DemoDevice::SetFluMA(float value)
- {
- FDEBUG("Enter SetFluMA:[{$}]", value);
- if (m_DoseUnit.m_FLMA->Update(value))
- {
- FireNotify(m_DoseUnit.m_FLMA->GetKey(), m_DoseUnit.m_FLMA->JSGet());
- }
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::DemoDevice::IncFluMS()
- {
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::DemoDevice::DecFluMS()
- {
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::DemoDevice::SetFluMS(float value)
- {
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::DemoDevice::SetPPS(float frameRate)
- {
- FDEBUG("Enter SetPPS:[{$}]", frameRate);
- if (m_DoseUnit.m_PPS->Update(frameRate))
- {
- FireNotify(AttrKey::FLUPPS, m_DoseUnit.m_PPS->JSGet());
- }
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::DemoDevice::INCPPS()
- {
- FDEBUG("Enter INCPPS");
- float PPS = m_DoseUnit.m_PPS->Get()+1;
- if (m_DoseUnit.m_PPS->Update(PPS))
- {
- FireNotify(AttrKey::FLUPPS, m_DoseUnit.m_PPS->JSGet());
- }
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::DemoDevice::DECPPS()
- {
- FDEBUG("Enter DECPPS");
- float PPS = m_DoseUnit.m_PPS->Get() - 1;
- if (m_DoseUnit.m_PPS->Update(PPS))
- {
- FireNotify(AttrKey::FLUPPS, m_DoseUnit.m_PPS->JSGet());
- }
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::DemoDevice::SetPluseWidth(float fplusewidth)
- {
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::DemoDevice::SetABSMode(int nMode)
- {
- FDEBUG("Enter SetABSMode:[{$}]", nMode);
- if (m_DoseUnit.m_ABSStatus->Update(nMode))
- {
- FireNotify(m_DoseUnit.m_ABSStatus->GetKey(), m_DoseUnit.m_ABSStatus->JSGet());
- }
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::DemoDevice::SetABSCurve(int curveNum)
- {
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::DemoDevice::IncABSCurve()
- {
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::DemoDevice::DecABSCurve()
- {
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::DemoDevice::SetABSValue(float fABSValue)
- {
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::DemoDevice::SetABSTargetEXI(float fEXIValue)
- {
- return RET_STATUS::RET_SUCCEED;
- }
- float nsGEN::DemoDevice::GetFluIntTimer()
- {
- return RET_STATUS::RET_SUCCEED;
- }
- float nsGEN::DemoDevice::GetFluAccTimer()
- {
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::DemoDevice::ResetFluTimer(int ntype)
- {
- FDEBUG("ReSetFluAccTimer:[{$}]", ntype);
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::DemoDevice::SetFluPre(int bPrepare)
- {
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::DemoDevice::SetFluEXP(int bPrepare)
- {
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::DemoDevice::SetFLFMode(std::string value)
- {
- FDEBUG("Enter SetFLFMode:[{$}]", value.c_str());
- if (value == "CF")
- {
- m_DoseUnit.m_FLMode->Update(AttrKey::GENERATOR_FLMODE_CF);
- SetExpMode(AttrKey::EXPMODE_TYPE::CoutineSerial);
- }
- else if (value == "PF")
- {
- m_DoseUnit.m_FLMode->Update(AttrKey::GENERATOR_FLMODE_PF);
- SetExpMode(AttrKey::EXPMODE_TYPE::PulseSerial);
- }
- FireNotify(AttrKey::FLUMode, m_DoseUnit.m_FLMode->JSGet());
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::DemoDevice::SetFluMAG(int nsize)
- {
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::DemoDevice::DisableMAG()
- {
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::DemoDevice::SetFluDoseLever(int nlever)
- {
- FDEBUG("Enter SetFluDoseLever:[{$}]", nlever);
- if (m_DoseUnit.m_DoseLevel->Update(nlever))
- {
- FireNotify(AttrKey::FLUDoseLevel, m_DoseUnit.m_DoseLevel->JSGet());
- }
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::DemoDevice::SetHalfDose(int nlever)
- {
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::DemoDevice::TransferRadCurve(int ncurve)
- {
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::DemoDevice::SetAPF(const _tAPFArgs& t)
- {
- FDEBUG("SetAPF: nWS={$}, Flu mode={$}, ABS mode={$}, DoseLever={$}, nFlkv={$}, FlMA={$}",
- t.nWS, t.nFluMode, t.nABSMode, t.nDoseLever, t.nFLKV, t.fFLMA, t.nPPS);
- if (m_DoseUnit.m_FLKV->Update(t.nFLKV))
- {
- FireNotify(m_DoseUnit.m_FLKV->GetKey(), m_DoseUnit.m_FLKV->JSGet());
- }
- if (m_DoseUnit.m_FLMA->Update(t.fFLMA))
- {
- FireNotify(m_DoseUnit.m_FLMA->GetKey(), m_DoseUnit.m_FLMA->JSGet());
- }
- if (m_DoseUnit.m_PPS->Update(t.nPPS))
- {
- FireNotify(AttrKey::FLUPPS, m_DoseUnit.m_PPS->JSGet());
- }
- if (m_DoseUnit.m_DoseLevel->Update(t.nDoseLever))
- {
- FireNotify(AttrKey::FLUDoseLevel, m_DoseUnit.m_DoseLevel->JSGet());
- }
- if (m_DoseUnit.m_FLMode->Update(t.nFluMode))
- {
- FireNotify(AttrKey::FLUMode, m_DoseUnit.m_FLMode->JSGet());
- }
- if (m_DoseUnit.m_ABSStatus->Update(t.nABSMode))
- {
- FireNotify(m_DoseUnit.m_ABSStatus->GetKey(), m_DoseUnit.m_ABSStatus->JSGet());
- }
- return RET_STATUS::RET_SUCCEED;
- }
- //额外
- void nsGEN::DemoDevice::FireNotify(string key, int context)
- {
- //std::unique_lock<std::mutex> uqeLock(m_MSGLock);
- char szInfo[64] = { 0 };
- sprintf(szInfo, "%d", context);
- std::string str = szInfo;
- EventCenter->OnNotify(1, key, str);//(int)ATTRACTION_SET 2
- }
- void nsGEN::DemoDevice::FireNotify(std::string key, float context)
- {
- //std::unique_lock<std::mutex> uqeLock(m_MSGLock);
- char szInfo[64] = { 0 };
- sprintf(szInfo, "%.2f", context);
- std::string str = szInfo;
- EventCenter->OnNotify(1, key, str);//(int)ATTRACTION_SET 2
- }
- void nsGEN::DemoDevice::FireNotify(std::string key, std::string context)
- {
- //std::unique_lock<std::mutex> uqeLock(m_MSGLock);
- EventCenter->OnNotify(1, key, context);
- }
- int nsGEN::DemoDevice::GetConfData()
- {
- //灯丝大小
- if (m_GenConfig.GetKeyCount(ConfKey::CcosTubeInfo) > 0)
- {
- string tempValue = m_GenConfig[ConfKey::CcosTubeInfo].encode();
- m_DoseUnit.m_TubeInfo.reset(new TUBEINFOMould(tempValue));
- }
- if (m_GenConfig.GetKeyCount(ConfKey::CcosFocusSmall) > 0)
- {
- float tempValue = (float)m_GenConfig[ConfKey::CcosFocusSmall];
- m_DoseUnit.m_FocusSmall = tempValue;
- }
- if (m_GenConfig.GetKeyCount(ConfKey::CcosFocusLarge) > 0)
- {
- float tempValue = (float)m_GenConfig[ConfKey::CcosFocusLarge];
- m_DoseUnit.m_FocusLarge = tempValue;
- }
- //同步模式
- if (m_GenConfig.GetKeyCount("WSTable") > 0)
- {
- int WSNamber = (int)m_GenConfig["WSTable"];
- EnSYNMode WSSYN = (EnSYNMode)((int)m_GenConfig["SYNTable"]);
- m_arrWSMap[cfgWorkStationKey("Table", AttrKey::TABLE)] = cfgWorkStationData("Table", WSNamber, WSSYN);
- FDEBUG("cfg Table WS[{$}],SYN[{$}]", WSNamber, (int)WSSYN);
- }
- if (m_GenConfig.GetKeyCount("WSWall") > 0)
- {
- int WSNamber = (int)m_GenConfig["WSWall"];
- EnSYNMode WSSYN = (EnSYNMode)((int)m_GenConfig["SYNWall"]);
- m_arrWSMap[cfgWorkStationKey("Wall", AttrKey::WALL)] = cfgWorkStationData("Wall", WSNamber, WSSYN);
- FDEBUG("cfg Wall WS[{$}],SYN[{$}]", WSNamber, (int)WSSYN);
- }
- if (m_GenConfig.GetKeyCount("WSFree") > 0)
- {
- int WSNamber = (int)m_GenConfig["WSFree"];
- EnSYNMode WSSYN = (EnSYNMode)((int)m_GenConfig["SYNFree"]);
- m_arrWSMap[cfgWorkStationKey("Free", AttrKey::MOBILE)] = cfgWorkStationData("Free", WSNamber, WSSYN);
- FDEBUG("cfg Free WS[{$}],SYN[{$}]", WSNamber, (int)WSSYN);
- }
- if (m_GenConfig.GetKeyCount("WSTomo") > 0)
- {
- int WSNamber = (int)m_GenConfig["WSTomo"];
- EnSYNMode WSSYN = (EnSYNMode)((int)m_GenConfig["SYNTomo"]);
- m_arrWSMap[cfgWorkStationKey("Tomo", AttrKey::TOMO)] = cfgWorkStationData("Tomo", WSNamber, WSSYN);
- FDEBUG("cfg Tomo WS[{$}],SYN[{$}]", WSNamber, (int)WSSYN);
- }
- if (m_GenConfig.GetKeyCount("WSConventional") > 0)
- {
- int WSNamber = (int)m_GenConfig["WSConventional"];
- EnSYNMode WSSYN = (EnSYNMode)((int)m_GenConfig["SYNConventional"]);
- m_arrWSMap[cfgWorkStationKey("Direct", AttrKey::CONVENTIONAL)] = cfgWorkStationData("Direct", WSNamber, WSSYN);
- FDEBUG("cfg Conventional WS[{$}],SYN[{$}]", WSNamber, (int)WSSYN);
- }
- //参数初始化
- ResDataObject temp;
- temp.update("Max", 150);
- temp.update("Min", 40);
- temp.update("List", "");
- for (int i = 0; i < sizeof(g_KV_List) / sizeof(g_KV_List[0]); i++)
- {
- char chindex[4] = { 0 };
- sprintf(chindex, "%d", i);
- temp["List"].add(chindex, g_KV_List[i] / 10.0f);
- }
- m_DoseUnit.m_KVList.reset(new KVLISTMould(temp.encode()));
- temp.clear();
- temp.update("Max", 1000);
- temp.update("Min", 8);
- temp.update("List", "");
- for (int i = 0; i < sizeof(g_MAS_List) / sizeof(g_MAS_List[0]); i++)
- {
- char chindex[4] = { 0 };
- sprintf(chindex, "%d", i);
- temp["List"].add(chindex, g_MAS_List[i]);
- }
- m_DoseUnit.m_mAsList.reset(new MASLISTMould(temp.encode()));
- //add by wxx for delworks:解决前端提出KV值太少的问题 20230913
- FireNotify(m_DoseUnit.m_KVList->GetKey(), m_DoseUnit.m_KVList->JSGet());
- return true;
- }
- void nsGEN::DemoDevice::FireErrorMessage(const bool Act, const int Code, const char* ResInfo)
- {
- string ErrorCode("Demo_ERR_");
- ErrorCode += std::to_string(Code);
- int level = Demo_REGULATION_LEVEL::REG_ERRO;
- if (Act)
- {
- FERROR("add {$}:{$}", ErrorCode.c_str(), ResInfo);
- m_MSGUnit->AddErrorMessage(ErrorCode.c_str(), level, ResInfo);
- }
- else
- {
- FERROR("del {$}:{$}", ErrorCode.c_str(), ResInfo);
- if (Code == 0)
- m_MSGUnit->DelErrorMessage("0", level, ResInfo);
- else
- m_MSGUnit->DelErrorMessage(ErrorCode.c_str(), level, ResInfo);
- }
- }
- void nsGEN::DemoDevice::FireWarnMessage(const bool Act, const int Code, const char* ResInfo)
- {
- string ErrorCode("Demo_WAR_");
- ErrorCode += std::to_string(Code);
- int level = Demo_REGULATION_LEVEL::REG_WARN;
- if (Act)
- {
- FERROR("add {$}:{$}", ErrorCode.c_str(), ResInfo);
- m_MSGUnit->AddWarnMessage(ErrorCode.c_str(), level, ResInfo);
- }
- else
- {
- FERROR("del {$}:{$}", ErrorCode.c_str(), ResInfo);
- m_MSGUnit->DelWarnMessage(ErrorCode.c_str(), level, ResInfo);
- }
- }
- bool nsGEN::DemoDevice::StartHardwareStatusThread()
- {
- FINFO("enter Start HardwareStatus Thread ");
- if (m_pHardwareStatusThread == 0) // Linux使用0表示无效线程ID
- {
- // 创建线程属性对象(可选)
- pthread_attr_t attr;
- pthread_attr_init(&attr);
- pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
- // 创建线程
- int ret = pthread_create(&m_pHardwareStatusThread,
- &attr,
- HardwareStatusThread,
- this);
- pthread_attr_destroy(&attr); // 销毁属性对象
- if (ret != 0)
- {
- FERROR("Start HardwareStatus Thread Failed");
- return false;
- }
- }
- return true;
- }
- void* nsGEN::DemoDevice::HardwareStatusThread(void* pParam)
- {
- DemoDevice* pCurGen = (DemoDevice*)pParam;
- if (pCurGen == NULL)
- {
- return NULL;
- }
- usleep(1500000);
- FINFO("HardwareStatusThread start");
- bool bActExpFlag = false;
- FINFO("m_iStateChangeInterval = {$},m_iAutoExpActWaitTime = {$}", pCurGen->m_iStateChangeInterval, pCurGen->m_iAutoExpActWaitTime);;
- FINFO("Request Fault Status:GENSTATE STATUS_SHUTDOWN -> STATUS_STANDBY");
- pCurGen->m_DoseUnit.m_GenState->Update(nsGEN::AttrKey::GENERATOR_STATUS_STANDBY);
- pCurGen->FireNotify(AttrKey::GENSTATE, pCurGen->m_DoseUnit.m_GenState->JSGet());
- while (true)
- {
- while (!bActExpFlag)
- {
- //FINFO("loopAction: begin \n");
- if (pCurGen->m_iAutoExpFlag > 0)
- {
- pCurGen->m_iAutoExpFlag = 0;
- usleep(pCurGen->m_iAutoExpActWaitTime*1000);
- if (pCurGen->m_iAutoExpFlag == 0)
- {
- FINFO("loopAction: start Exp Workflow \n");
- bActExpFlag = true;
- break;
- }
- else
- {
- FINFO("loopAction: Exp param changed restart wait \n");
- continue;
- }
- }
- usleep(pCurGen->m_iAutoExpActWaitTime*1000);
- }
- while (bActExpFlag)
- {
- FINFO("loopAction: act exp Workflow \n");
- switch (pCurGen->m_DoseUnit.m_GenSynState->Get())
- {
- case nsGEN::AttrKey::GENERATOR_RAD_OFF:
- {
- FINFO("exp Status change:RAD_OFF -> PREPARE(PR1)", pCurGen->m_DoseUnit.m_GenSynState->Get());
- pCurGen->m_DoseUnit.m_GenSynState->Update(nsGEN::AttrKey::GENERATOR_RAD_PREPARE);
- }break;
- case nsGEN::AttrKey::GENERATOR_RAD_PREPARE:
- {
- FINFO("exp Status change:PREPARE(PR1) -> RAD_READY(PR2)", pCurGen->m_DoseUnit.m_GenSynState->Get());
- pCurGen->m_DoseUnit.m_GenSynState->Update(nsGEN::AttrKey::GENERATOR_RAD_READY);
- }break;
- case nsGEN::AttrKey::GENERATOR_RAD_READY:
- {
- FINFO("exp Status change:RAD_READY(PR2) -> XRAYON(XR1)", pCurGen->m_DoseUnit.m_GenSynState->Get());
- pCurGen->m_DoseUnit.m_GenSynState->Update(nsGEN::AttrKey::GENERATOR_RAD_XRAYON);
- }break;
- case nsGEN::AttrKey::GENERATOR_RAD_XRAYON:
- {
- FINFO("exp Status change:XRAYON(XR1) -> XRAYOFF(XR0)", pCurGen->m_DoseUnit.m_GenSynState->Get());
- pCurGen->m_DoseUnit.m_GenSynState->Update(nsGEN::AttrKey::GENERATOR_RAD_XRAYOFF);
- FDEBUG("Request Fault Status:GENSTATE STATUS_STANDBY -> STATUS_EXP");
- pCurGen->m_DoseUnit.m_GenState->Update(nsGEN::AttrKey::GENERATOR_STATUS_EXP);
- pCurGen->FireNotify(AttrKey::GENSTATE, pCurGen->m_DoseUnit.m_GenState->JSGet());
- FINFO("exp Status value:POSTKV[{$}],POSTMA[{$}],POSTMS[{$}],POSTMAS[{$}]",
- pCurGen->m_DoseUnit.m_PostKV->Get(), pCurGen->m_DoseUnit.m_PostMA->Get(), pCurGen->m_DoseUnit.m_PostMS->Get(), pCurGen->m_DoseUnit.m_PostMAS->Get());
- pCurGen->FireNotify(AttrKey::POSTKV, pCurGen->m_DoseUnit.m_PostKV->JSGet());
- pCurGen->FireNotify(AttrKey::POSTMA, pCurGen->m_DoseUnit.m_PostMA->JSGet());
- #if DEMO_DAEC_Flag
- int temp = pCurGen->m_DoseUnit.m_PostMS->Get();
- if (pCurGen->m_DoseUnit.m_Techmode->Get() == AttrKey::TECHMODE_TYPE::TECHMODE_AEC_3P ||
- pCurGen->m_DoseUnit.m_Techmode->Get() == AttrKey::TECHMODE_TYPE::TECHMODE_AEC_2P ||
- pCurGen->m_DoseUnit.m_Techmode->Get() == AttrKey::TECHMODE_TYPE::TECHMODE_AEC_1P)
- {
- temp /= 2;
- }
- pCurGen->FireNotify(AttrKey::POSTMS, temp);
- #else
- pCurGen->FireNotify(AttrKey::POSTMS, pCurGen->m_DoseUnit.m_PostMS->JSGet());
- #endif // DEMO_DAEC_Flag
- pCurGen->FireNotify(AttrKey::POSTMAS, pCurGen->m_DoseUnit.m_PostMAS->JSGet());
- }break;
- case nsGEN::AttrKey::GENERATOR_RAD_XRAYOFF:
- {
- FINFO("exp Status change:XRAYOFF(XR0) -> RAD_OFF", pCurGen->m_DoseUnit.m_GenSynState->Get());
- pCurGen->m_DoseUnit.m_GenSynState->Update(nsGEN::AttrKey::GENERATOR_RAD_OFF);
- FDEBUG("Request Fault Status:GENSTATE STATUS_EXP -> STATUS_STANDBY");
- pCurGen->m_DoseUnit.m_GenState->Update(nsGEN::AttrKey::GENERATOR_STATUS_STANDBY);
- pCurGen->FireNotify(AttrKey::GENSTATE, pCurGen->m_DoseUnit.m_GenState->JSGet());
- }
- default:
- {
- bActExpFlag = false;
- }
- }
- pCurGen->FireNotify(pCurGen->m_DoseUnit.m_GenSynState->GetKey(), pCurGen->m_DoseUnit.m_GenSynState->JSGet());
- usleep(pCurGen->m_iStateChangeInterval*1000);
- }
- }
- FINFO("HardwareStatusThread stop");
- return NULL;
- }
- //驱动
- nsGEN::DemoDriver::DemoDriver()
- {
- m_bDemoMode = false;
- m_bDemoConnected = false;
- m_bDemoInitDataFlag = false;
- m_pDriGenDev = nullptr;
- //m_pDriCollDev = nullptr;
- //m_pDriMechDev = nullptr;
- m_pAttribute.reset(new ResDataObject());
- m_pDescription.reset(new ResDataObject());
- }
- nsGEN::DemoDriver::~DemoDriver()
- {
- }
- auto nsGEN::DemoDriver::CreateDevice(int index) -> std::unique_ptr <IODevice>
- {
- std::cout << "Enter CreateDevice, index=" << index<< std::endl;
- FINFO("Enter CreateDevice, index={$}", index);
-
- if (index == 0)
- {
- m_pDriGenDev = new DemoDevice(EventCenter, m_ConfigFileName);
- auto dev = std::unique_ptr<IODevice>(new IODevice(m_pDriGenDev));
- return dev;
- }
- else if (index == 1)
- {
- std::cout << "Enter CreateDevice COLL" << std::endl;
- FINFO("Enter CreateDevice COLL");
- if (m_bDemoInitDataFlag)
- {
- int nXSize = (atoi)(((string)m_InitDataFile["CONFIGURATION"]["XSize"]).c_str());
- int nYSize = (atoi)(((string)m_InitDataFile["CONFIGURATION"]["YSize"]).c_str());
- int nFilter = (atoi)(((string)m_InitDataFile["CONFIGURATION"]["Filter"]).c_str());
- int nSID = (atoi)(((string)m_InitDataFile["CONFIGURATION"]["SID"]).c_str());
- int nAngle = (atoi)(((string)m_InitDataFile["CONFIGURATION"]["Angle"]).c_str());
- int nMode = (atoi)(((string)m_InitDataFile["CONFIGURATION"]["Mode"]).c_str());
- m_pDriCollDev = new OemCollimator(std::shared_ptr<IOEventCenter>(new IOEventCenter()), nXSize, nYSize, nFilter, nSID, nAngle, nMode);
- }
- else
- m_pDriCollDev = new OemCollimator(std::shared_ptr<IOEventCenter>(new IOEventCenter()));
- auto dev = std::unique_ptr <IODevice>(new IODevice(m_pDriCollDev));
- m_pDriCollDev->SetCtrlDev(m_pDriGenDev);
- m_pDriGenDev->SetCollimatorDev(m_pDriCollDev);
- FINFO("Leave CreateDevice COLL");
- return dev;
- }
- else if (index == 2)
- {
- std::cout << "Enter CreateDevice Mech" << std::endl;
- FINFO("Enter CreateDevice Mech");
- if (m_bDemoInitDataFlag)
- {
- int nGrid = (atoi)(((string)m_InitDataFile["CONFIGURATION"]["Grid"]).c_str());
- int nAE = (atoi)(((string)m_InitDataFile["CONFIGURATION"]["AE"]).c_str());
- int nFT = (atoi)(((string)m_InitDataFile["CONFIGURATION"]["FT"]).c_str());
- int nPressureState = (atoi)(((string)m_InitDataFile["CONFIGURATION"]["PressureState"]).c_str());
- int nCompPressureDEC = (atoi)(((string)m_InitDataFile["CONFIGURATION"]["CompPressureDEC"]).c_str());
- int nDepress = (atoi)(((string)m_InitDataFile["CONFIGURATION"]["Depress"]).c_str());
- float fMechAngle = (atof)(((string)m_InitDataFile["CONFIGURATION"]["MechAngle"]).c_str());
- float fMechHeight = (atof)(((string)m_InitDataFile["CONFIGURATION"]["MechHeight"]).c_str());
- float fPressureValue = (atof)(((string)m_InitDataFile["CONFIGURATION"]["PressureValue"]).c_str());
- float fAGD = (atof)(((string)m_InitDataFile["CONFIGURATION"]["AGD"]).c_str());
- float fMAG = (atof)(((string)m_InitDataFile["CONFIGURATION"]["MAG"]).c_str());
- m_pDriMechDev = new OemMechanical(std::shared_ptr<IOEventCenter>(new IOEventCenter()), nGrid, nAE, nFT, nPressureState, nCompPressureDEC, nDepress, fMechAngle, fMechHeight, fPressureValue, fAGD, fMAG);
- }
- else
- m_pDriMechDev = new OemMechanical(std::shared_ptr<IOEventCenter>(new IOEventCenter()));
- auto dev = std::unique_ptr <IODevice>(new IODevice(m_pDriMechDev));
- m_pDriMechDev->SetCtrlDev(m_pDriGenDev);
- m_pDriGenDev->SetMechDev(m_pDriMechDev);
- FINFO("Leave CreateDevice Mech");
- return dev;
- }
- std::cout << "unknown index" << std::endl;
- FERROR("unknown index");
- unique_ptr <IODevice> dev;
- return dev;
- }
- void nsGEN::DemoDriver::FireNotify(int code, std::string key, std::string content)
- {
- EventCenter->OnNotify(code, key, content);
- }
- //Log4CPP::Logger* mLog::gLogger = nullptr;
- void nsGEN::DemoDriver::Prepare()
- {
- // 初始化日志系统
- std::string strLogPath = GetProcessDirectory() + R"(/Conf/log_config.xml)";
- std::string LogHost = "DemoGEN";
- std::string moduleName = "DemoGEN";
- bool ret = initLogModule(
- LogHost, // 主机名(用于日志路径中的{host}占位符)
- moduleName, // 唯一模块名
- strLogPath, // 配置文件路径
- true // 是否输出到控制台(可选)
- );
- if (!ret) {
- std::cerr << "Log init failed!" << std::endl;
- return;
- }
- GENDEMO_SetLocalModuleName(moduleName);
- ResDataObject r_config;
- if (r_config.loadFile(m_ConfigFileName.c_str()))
- {
- if(r_config["CONFIGURATION"].GetKeyCount("IsDemo")>0)
- {
- m_bDemoMode = (atoi)(((string)r_config["CONFIGURATION"]["IsDemo"]).c_str());
- }
- }
- string strDataPath = GetProcessDirectory() + R"(/OEMDrivers/Generator/Demo/InitData.xml)";
- try {
- if (m_InitDataFile.loadFile(strDataPath.c_str()))
- {
- m_bDemoInitDataFlag = true;
- FINFO("exist InitData");
- }
- //else
- FINFO("can not open InitData[{$}]", strDataPath.c_str());
- }
- catch (const ResDataObjectExption&)
- {
- FERROR("open InitData failed");
- }
- }
- bool nsGEN::DemoDriver::Connect()
- {
- m_bDemoConnected = true;
- return true; //return SCF_ERR::SCF_SUCCEED;
- }
- void nsGEN::DemoDriver::Disconnect()
- {
- m_bDemoConnected = false;
- }
- bool nsGEN::DemoDriver::isConnected() const
- {
- return m_bDemoConnected;
- }
- std::string nsGEN::DemoDriver::DriverProbe()
- {
- printf("line= %d,%s %s\n", __LINE__, __FUNCTION__, m_ConfigFileName.c_str());
- ResDataObject r_config, HardwareInfo;
- if (r_config.loadFile(m_ConfigFileName.c_str()))
- {
- HardwareInfo.add("MajorID", r_config["CONFIGURATION"]["MajorID"]);
- HardwareInfo.add("MinorID", r_config["CONFIGURATION"]["MinorID"]);
- HardwareInfo.add("VendorID", r_config["CONFIGURATION"]["VendorID"]);
- HardwareInfo.add("ProductID", r_config["CONFIGURATION"]["ProductID"]);
- HardwareInfo.add("SerialID", r_config["CONFIGURATION"]["SerialID"]);
- }
- else
- {
- HardwareInfo.add("MajorID", "Generator");
- HardwareInfo.add("MinorID", "Dr");
- HardwareInfo.add("VendorID", "DEMO");
- HardwareInfo.add("ProductID", "HF");
- HardwareInfo.add("SerialID", "1234");
- }
- string ret = HardwareInfo.encode();
- printf("line= %d,%s %s\n", __LINE__, __FUNCTION__, m_ConfigFileName.c_str());
- return ret;
- }
- bool nsGEN::DemoDriver::GetDeviceConfig(std::string& Cfg)
- {
- //printf("line= %d,%s\n", __LINE__, __FUNCTION__);
- //Cfg = m_GenConfig.encode();
- //return true;
- Cfg = m_DeviceConfigSend.encode();
- printf("GetDeviceConfig over , %s", Cfg.c_str());
- return true;
- }
- bool nsGEN::DemoDriver::SetDeviceConfig(std::string Cfg)
- {
- FINFO("--Func-- SetDeviceConfig {$}\n", Cfg.c_str());
- printf("\n--Func-- SetDeviceConfig %s\n", Cfg.c_str());
- ResDataObject DeviceConfig;
- DeviceConfig.decode(Cfg.c_str());
- ResDataObject DescriptionTempEx;
- DescriptionTempEx = DeviceConfig["DeviceConfig"]["Attribute"];
- FDEBUG("Attribute:{$}", DescriptionTempEx.encode());
- bool bSaveFile = false; //true:重新保存配置文件
- string strAccess = "";
- for (int i = 0; i < DescriptionTempEx.size(); i++)
- {
- string strKey = DescriptionTempEx.GetKey(i);
- FINFO("{$}", strKey.c_str());
- printf("%s\n", strKey.c_str());
- try
- {
- if (m_pAttribute->GetFirstOf(strKey.c_str()) >= 0)
- {
- strAccess = (string)(*m_pDescription)[strKey.c_str()]["Access"];
- if ("RW" == strAccess)
- {
- //修改对应配置,在其他单元的配置项要同时调用其修改函数修改真实值
- //1. 修改内存中的值,用于给上层发消息
- (*m_pAttribute)[strKey.c_str()] = DescriptionTempEx[i];
- //2. 拿到Innerkey
- int nConfigInfoCount = (int)m_Configurations["ConfigToolInfo"].GetKeyCount("AttributeInfo");
- FINFO("nConfigInfoCount {$}", nConfigInfoCount);
- string strTemp = ""; //存储AttributeKey
- for (int nInfoIndex = 0; nInfoIndex < nConfigInfoCount; nInfoIndex++)
- {
- strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeKey"];
- if (strTemp == strKey)
- {
- strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["InnerKey"];
- break;
- }
- }
- //3. 修改配置文件中的值
- if (SetDeviceConfigValue(m_Configurations, strTemp.c_str(), 1, DescriptionTempEx[i]))
- {
- FDEBUG("SetDeviceConfigValue over");
- bSaveFile = true;
- }
- }
- else
- {
- FINFO("{$} is not a RW configuration item", strKey.c_str());
- }
- }
- else
- {
- FINFO("without this attribute {$}", strKey.c_str());
- }
- }
- catch (ResDataObjectExption& e)
- {
- printf("\nSetDriverConfig crashed: %s\n", e.what());
- FERROR("SetDriverConfig crashed: {$}", e.what());
- return false;
- }
- }
- if (bSaveFile)
- {
- //3. 重新保存配置文件
- SaveConfigFile(true);
- }
- return true;
- }
- bool nsGEN::DemoDriver::SaveConfigFile(bool bSendNotify)
- {
- m_ConfigAll["CONFIGURATION"] = m_Configurations;
- bool bRt = m_ConfigAll.SaveFile(m_ConfigFileName.c_str());
- FINFO("SaveConfigFile over {$}", bRt);
- return true;
- }
- bool nsGEN::DemoDriver::GetDeviceConfigValue(ResDataObject config, const char* pInnerKey, int nPathID, string& strValue)
- {
- strValue = "";
- string strTemp = pInnerKey;
- if (1 == nPathID) //从DriverConfig路径下每个DPC自己的配置文件读取
- {
- int pos = 0;
- ResDataObject resTemp = config;
- while ((pos = strTemp.find_first_of(',')) != string::npos)
- {
- string Key = strTemp.substr(0, pos);
- string TempValue = resTemp[Key.c_str()].encode();
- // printf("-TempValue=== %s", TempValue.c_str());
- resTemp.clear();
- resTemp.decode(TempValue.c_str());
- strTemp = strTemp.substr(pos + 1, strTemp.length() - pos - 1);
- //printf("-************--%s", strTemp.c_str());
- }
- if (strTemp != "")
- {
- strValue = (string)resTemp[strTemp.c_str()];
- }
- else
- {
- strValue = (string)resTemp;
- }
- }
- //printf("------------%s", strValue.c_str());
- return true;
- }
- bool nsGEN::DemoDriver::SetDeviceConfigValue(ResDataObject& config, const char* pInnerKey, int nPathID, const char* szValue)
- {
- string strTemp = pInnerKey;
- FDEBUG("Begin to change {$} item value to {$}", pInnerKey, szValue);
- printf("\n Begin to change {%s} item value to {%s}\n", pInnerKey, szValue);
- if (1 == nPathID) //从DriverConfig路径下每个DPC自己的配置文件读取
- {
- try {
- int pos = 0;
- ResDataObject* resTemp = &config;
- while ((pos = strTemp.find_first_of(',')) != string::npos)
- {
- string Key = strTemp.substr(0, pos);
- resTemp = &(*resTemp)[Key.c_str()];
- strTemp = strTemp.substr(pos + 1, strTemp.length() - pos - 1);
- }
- if (strTemp != "")
- {
- //if ((strTemp.compare("WSTable") == 0) ||
- // (strTemp.compare("WSWall") == 0) ||
- // (strTemp.compare("WSFree") == 0) ||
- // (strTemp.compare("WSTomo") == 0) ||
- // (strTemp.compare("WSConventional") == 0)
- // )
- //{
- // int sum = (*szValue) + 1;
- // (*resTemp)[strTemp.c_str()] = (char*)(&sum);
- //}
- //else
- // (*resTemp)[strTemp.c_str()] = szValue;
- (*resTemp)[strTemp.c_str()] = szValue;
- }
- else
- {
- *resTemp = szValue;
- }
- }
- catch (ResDataObjectExption& e)
- {
- FERROR("SetDriverConfigvalue crashed: {$}", e.what());
- return false;
- }
- }
- return true;
- }
- std::string nsGEN::DemoDriver::GetResource()
- {
- ResDataObject r_config, temp;
- if (!temp.loadFile(m_ConfigFileName.c_str()))
- {
- return "";
- }
- m_ConfigAll = temp;
- r_config = temp["CONFIGURATION"];
- m_Configurations = r_config;
- ResDataObject DescriptionTemp;
- ResDataObject DescriptionSend;
- ResDataObject m_DescriptionSend;
- ResDataObject ListTemp;
- string strTemp = ""; //用于读取字符串配置信息
- string strIndex = ""; //用于读取配置信息中的List项
- int nTemp = -1; //用于读取整型配置信息
- char sstream[10] = { 0 }; //用于转换值
- string strValue = ""; //用于存储配置的值
- string strType = ""; //用于存储配置的类型 int/float/string...
- /***
- * 1. 通过循环,将所有配置项写到pDeviceConfig
- * 2. 记录配置项的内部key以及配置类型,类型对应了不同配置文件路径,用于读写真实值
- ***/
- try
- {
- //便利ConfigToolInfo 中 所有的AttributeInfo 属性段
- int nConfigInfoCount = (int)m_Configurations["ConfigToolInfo"].GetKeyCount("AttributeInfo");
- m_pAttribute->clear();
- m_pDescription->clear();
- for (int nInfoIndex = 0; nInfoIndex < nConfigInfoCount; nInfoIndex++)
- {
- DescriptionTemp.clear();
- DescriptionSend.clear();
- ListTemp.clear();
- //AttributeType
- strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["Type"];
- DescriptionTemp.add(ConfKey::CcosType, strTemp.c_str());//CcosGeneratorAttribute
- DescriptionSend.add(ConfKey::CcosType, strTemp.c_str());//CcosGeneratorAttribute
- strType = strTemp; //记录配置项的类型
- //AttributeKey
- //1. 根据AttributeType,内部key和配置路径,拿到当前的真实值
- strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["InnerKey"];
- nTemp = (int)m_Configurations["ConfigToolInfo"][nInfoIndex]["PathID"];
- GetDeviceConfigValue(r_config, strTemp.c_str(), nTemp, strValue); //得到strValue的值
- //printf("********************************innerkey=%s --strValue = %s\n", strTemp.c_str(), strValue.c_str());
- //2. 赋值
- strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeKey"];
- if ("int" == strType)
- {
- (*m_pAttribute).add(strTemp.c_str(), atoi(strValue.c_str()));
- }
- else if ("float" == strType)
- {
- (*m_pAttribute).add(strTemp.c_str(), atoi(strValue.c_str()));
- }
- else //其它先按string类型处理
- {
- (*m_pAttribute).add(strTemp.c_str(), strValue.c_str());
- }
- //printf("********************************outkey =%s --strValue = %s\n", strTemp.c_str(), strValue.c_str());
- //AttributeAccess
- strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["Access"];
- DescriptionTemp.add(ConfKey::CcosAccess, strTemp.c_str());
- DescriptionSend.add(ConfKey::CcosAccess, strTemp.c_str());
- /*
- //AttributeRangeMin
- strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["RangeMin"];
- if (strTemp != "") //不需要的配置项为空
- {
- DescriptionTemp.add(ConfKey::CcosRangeMin, strTemp.c_str());
- }
- //AttributeRangeMax
- strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["RangeMax"];
- if (strTemp != "") //不需要的配置项为空
- {
- DescriptionTemp.add(ConfKey::CcosRangeMax, strTemp.c_str());
- }
- */
- //AttributeList
- nTemp = m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["ListNum"];
- if (nTemp > 0) //ListNum不大于0时说明不需要list配置
- {
- for (int nListIndex = 0; nListIndex < nTemp; nListIndex++)
- {
- strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["ListInfo"][nListIndex];
- auto temKey = std::to_string(nListIndex);
- ListTemp.add(temKey.c_str(), strTemp.c_str());
- }
- DescriptionTemp.add(ConfKey::CcosList, ListTemp);
- DescriptionSend.add(ConfKey::CcosList, ListTemp.encode());
- }
- //AttributeRequired
- strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["Required"];
- DescriptionTemp.add(ConfKey::CcosRequired, strTemp.c_str());
- DescriptionSend.add(ConfKey::CcosRequired, strTemp.c_str());
- //AttributeDefaultValue
- strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["DefaultValue"];
- if (strTemp != "") //不需要的配置项为空
- {
- DescriptionTemp.add(ConfKey::CcosDefaultValue, strTemp.c_str());
- DescriptionSend.add(ConfKey::CcosDefaultValue, strTemp.c_str());
- }
- strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeKey"];
- (*m_pDescription).add(strTemp.c_str(), DescriptionTemp);
- m_DescriptionSend.add(strTemp.c_str(), DescriptionSend.encode());
- }
- }
- catch (ResDataObjectExption& e)
- {
- FERROR("Get config error: {$}", e.what());
- return "";
- }
- ResDataObject resDeviceResource;
- resDeviceResource.add(ConfKey::CcosGeneratorAttribute, (*m_pAttribute));
- resDeviceResource.add(ConfKey::CcosGeneratorDescription, (*m_pDescription));
- ResDataObject DescriptionTempEx;
- DescriptionTempEx.add(ConfKey::CcosGeneratorConfig, resDeviceResource);
- m_DeviceConfig.clear();
- m_DeviceConfig = DescriptionTempEx;
- //FDEBUG("local ************* get resource over {$}", DescriptionTempEx.encode());
- //printf("local ************* get resource over %s \n", DescriptionTempEx.encode());
- resDeviceResource.clear();
- resDeviceResource.add(ConfKey::CcosGeneratorAttribute, (*m_pAttribute));
- resDeviceResource.add(ConfKey::CcosGeneratorDescription, m_DescriptionSend);
- DescriptionTempEx.clear();
- DescriptionTempEx.add(ConfKey::CcosGeneratorConfig, resDeviceResource);
- m_DeviceConfigSend.clear();
- m_DeviceConfigSend = DescriptionTempEx;
- string res = m_DeviceConfigSend.encode();
- //printf("%s", res.c_str());
- //FDEBUG("get resource over {$}", DescriptionTempEx.encode());
- //printf("************* get resource over %s \n", DescriptionTempEx.encode());
- return res;
- }
- std::string nsGEN::DemoDriver::DeviceProbe()
- {
- printf("line= %d,%s\n", __LINE__, __FUNCTION__);
- ResDataObject r_config, HardwareInfo;
- if (r_config.loadFile(m_ConfigFileName.c_str()))
- {
- HardwareInfo.add("MajorID", r_config["CONFIGURATION"]["MajorID"]);
- HardwareInfo.add("MinorID", r_config["CONFIGURATION"]["MinorID"]);
- HardwareInfo.add("VendorID", r_config["CONFIGURATION"]["VendorID"]);
- HardwareInfo.add("ProductID", r_config["CONFIGURATION"]["ProductID"]);
- HardwareInfo.add("SerialID", r_config["CONFIGURATION"]["SerialID"]);
- }
- else
- {
- HardwareInfo.add("MajorID", "Generator");
- HardwareInfo.add("MinorID", "Dr");
- HardwareInfo.add("VendorID", "DEMO");
- HardwareInfo.add("ProductID", "HF");
- HardwareInfo.add("SerialID", "1234");
- }
- string ret = HardwareInfo.encode();
- return ret;
- }
- void nsGEN::DemoDriver::Dequeue(const char* Packet, DWORD Length)
- {
- //DecodeFrame(Packet, Length); //无真实数据,此处直接空.
- }
- //In Demo mode ,will not enter here
- int nsGEN::DemoDriver::callbackPackageProcess(const char* RecData, DWORD nLength, DWORD& PacketLength)
- {
- return 0;
- }
- //-----------------------------------------------------------------------------
- // GetIODriver & CreateIODriver
- //-----------------------------------------------------------------------------
- static nsGEN::DemoDriver gIODriver;
- extern "C" CCOS::Dev::IODriver * GetIODriver() // 返回静态对象的引用, 调用者不能删除 !
- {
- return &gIODriver;
- }
- extern "C" CCOS::Dev::IODriver * CreateIODriver() // 返回新对象, 调用者必须自行删除此对象 !
- {
- return new nsGEN::DemoDriver();
- }
|