1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555 |
- //
- #include <assert.h>
- #include <string>
- #include <limits.h> // PATH_MAX
- #include <unistd.h> // readlink
- #include <cstring>
- #include <dlfcn.h>
- #include <link.h>
- #include <elf.h>
- #include <fcntl.h>
- #include <sys/mman.h>
- #include <sys/stat.h>
- #include "Helper.JSON.hpp"
- #include "CCOS.Dev.Generator.Mould.hpp"
- #include "EasyJSONEncoder.hpp"
- #include "ResDataObject.h"
- #include <fstream>
- using namespace CCOS::Dev::Detail::Generator;
- namespace nsGEN = CCOS::Dev::Detail::Generator;
- template <>
- _tAPRArgs JSONTo (const std::string& in)
- {
- _tAPRArgs rc {};
- ResDataObject json;
- json.decode (in.c_str ());
- rc.nFocus = atoi (((string) json [0] [AttrKey::FOCUS]).c_str ());
- rc.nTechmode = (int) json [0] [AttrKey::TECHMODE];
- rc.fKV = atof (((string) json [0] [AttrKey::KV]).c_str ());
- rc.fMA = atof (((string) json [0] [AttrKey::MA]).c_str ());
- rc.fMS = atof (((string) json [0] [AttrKey::MS]).c_str ());
- rc.fMAS = atof (((string) json [0] [AttrKey::MAS]).c_str ());
- rc.nAECDensity = json [0] [AttrKey::AECDENSITY];
- rc.nAECFilm = json [0] [AttrKey::AECFILM];
- rc.nAECField = json [0] [AttrKey::AECFIELD];
- return rc;
- }
- template <>
- _tAPFArgs JSONTo(const std::string& in)
- {
- _tAPFArgs rc{};
- ResDataObject json;
- json.decode(in.c_str());
- auto& R0 = json[0];
- rc.nFluMode = atoi(((string)R0[AttrKey::FLUMode]).c_str());
- rc.nABSMode = (int)R0[AttrKey::FLUABSStatus];
- rc.nDoseLever = atof(((string)R0[AttrKey::FLUDoseLevel]).c_str());
- rc.nFLKV = atof(((string)R0[AttrKey::FLUKV]).c_str());
- rc.fFLMA = atof(((string)R0[AttrKey::FLUMA]).c_str());
- rc.nPPS = atoi(((string)R0[AttrKey::FLUPPS]).c_str());
- return rc;
- }
- //template <typename _Container, typename T>
- //inline _Container& operator << (_Container& ar, const T& t)
- //{
- // ar.push_back (t);
- // return ar;
- //}
- string nsGEN::GetProcessDirectory()
- {
- string ret = "";
- char szFilename[PATH_MAX] = { 0 };
- // Linux 获取可执行文件路径
- ssize_t res = readlink("/proc/self/exe", szFilename, PATH_MAX);
- if (res <= 0 || res >= PATH_MAX) {
- return ret;
- }
- szFilename[res] = '\0'; // readlink 不会添加终止符
- string fullpath = szFilename;
- string::size_type firstHit = fullpath.find_last_of('\\');
- if (firstHit == string::npos || firstHit == 0)
- {
- return ret;
- }
- ret = fullpath.substr(0, firstHit);//kick last \
- return ret;
- }
- // 获取 ELF 文件中的 .note 段信息
- std::string nsGEN::GetElfNoteVersion(const std::string& filename) {
- int fd = open(filename.c_str(), O_RDONLY);
- if (fd == -1) return "";
- struct stat st;
- if (fstat(fd, &st) == -1) {
- close(fd);
- return "";
- }
- void* map = mmap(0, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
- if (map == MAP_FAILED) {
- close(fd);
- return "";
- }
- std::string version;
- ElfW(Ehdr)* ehdr = static_cast<ElfW(Ehdr)*>(map);
- ElfW(Shdr)* shdrs = reinterpret_cast<ElfW(Shdr)*>((uintptr_t)ehdr + ehdr->e_shoff);
- for (int i = 0; i < ehdr->e_shnum; ++i) {
- if (shdrs[i].sh_type == SHT_NOTE) {
- ElfW(Nhdr)* nhdr = reinterpret_cast<ElfW(Nhdr)*>((uintptr_t)map + shdrs[i].sh_offset);
- uintptr_t ptr = (uintptr_t)nhdr + sizeof(ElfW(Nhdr));
- // 跳过名称
- ptr += nhdr->n_namesz;
- if (nhdr->n_namesz % 4) ptr += 4 - (nhdr->n_namesz % 4);
- // 读取描述信息(版本号)
- if (nhdr->n_descsz > 0) {
- version.assign(reinterpret_cast<const char*>(ptr), nhdr->n_descsz);
- // 移除可能的填充字符
- size_t pos = version.find_first_of('\0');
- if (pos != std::string::npos) {
- version.resize(pos);
- }
- break;
- }
- }
- }
- munmap(map, st.st_size);
- close(fd);
- return version;
- }
- //获取配置文件中指定模块的版本号
- bool nsGEN::GetVersion(string& version, void* hMyModule)
- {
- try {
- std::string modulePath;
- if (hMyModule) {
- Dl_info dl_info;
- if (dladdr(hMyModule, &dl_info)) {
- modulePath = dl_info.dli_fname;
- }
- }
- if (modulePath.empty()) {
- char selfPath[PATH_MAX] = { 0 };
- ssize_t len = readlink("/proc/self/exe", selfPath, sizeof(selfPath) - 1);
- if (len <= 0) return false;
- selfPath[len] = '\0';
- modulePath = selfPath;
- }
- printf("get Generator path: %s\n", modulePath.c_str());
- std::string ver = GetElfNoteVersion(modulePath);
- if (ver.empty()) {
- // 备用方案:使用文件修改时间作为版本号
- struct stat st;
- if (stat(modulePath.c_str(), &st) == 0) {
- ver = "1.0.0." + std::to_string(st.st_mtim.tv_sec);
- }
- }
- if (ver.empty()) return false;
- version += ver;
- return true;
- }
- catch (...) {
- printf("get Generator Mould version failed\n");
- }
- return false;
- }
- bool nsGEN::GetVersion(string& version, ResDataObject& config)
- {
- try {
- std::string procdir = nsGEN::GetProcessDirectory();
- if (procdir.empty()) return false;
- std::string oemdrvpath = (const char*)config["oemdriver"];
- const std::string keystr = "%ROOT%";
- size_t pos = 0;
- while ((pos = oemdrvpath.find(keystr, pos)) != std::string::npos) {
- oemdrvpath.replace(pos, keystr.size(), procdir);
- pos += procdir.size();
- }
- printf("get Generator path: %s\n", oemdrvpath.c_str());
- std::string ver = GetElfNoteVersion(oemdrvpath);
- if (ver.empty()) {
- // 备用方案:使用文件修改时间作为版本号
- struct stat st;
- if (stat(oemdrvpath.c_str(), &st) == 0) {
- ver = "1.0.0." + std::to_string(st.st_mtim.tv_sec);
- }
- }
- if (ver.empty()) return false;
- version += ver;
- return true;
- }
- catch (...) {
- printf("get Generator Mould version failed\n");
- }
- return false;
- }
- bool nsGEN::GetVersion(string& version)
- {
- char selfPath[PATH_MAX] = { 0 };
- ssize_t len = readlink("/proc/self/exe", selfPath, sizeof(selfPath) - 1);
- if (len <= 0) return false;
- selfPath[len] = '\0';
- printf("get Generator path: %s\n", selfPath);
- std::string ver = GetElfNoteVersion(selfPath);
- if (ver.empty()) {
- // 备用方案:使用文件修改时间作为版本号
- struct stat st;
- if (stat(selfPath, &st) == 0) {
- ver = "1.0.0." + std::to_string(st.st_mtim.tv_sec);
- }
- }
- if (ver.empty()) return false;
- version += ver;
- return true;
- }
- void nsGEN::TransJsonText(ResDataObject& config)
- {
- for (int x = 0; x < config.size(); x++)
- {
- //如果有Value
- if (config[x].GetKeyCount("Value") > 0)
- {
- //mLog::FINFO("TRY COVERT [{$}] VALUE {$}", config.GetKey(x), config[x]["Value"].size() > 0 ? config[x]["Value"].encode() : (const char*)config[x]["Value"]);
- if (config[x]["Value"].size() <= 0)
- {
- string va = (const char*)config[x]["Value"];
- config[x] = va.c_str();
- }
- else
- {
- ResDataObject rest = config[x]["Value"];
- config[x] = rest;
- //mLog::FINFO("convert object [{$}], object {$}", config.GetKey(x), rest.encode());
- }
- }
- //mLog::FINFO("After Convert {$}", config.encode());
- }
- }
- //-----------------------------------------------------------------------------
- // nsGEN::GeneratorMould
- //-----------------------------------------------------------------------------
- //Log4CPP::Logger* mLog::gLogger = nullptr;
- nsGEN::GeneratorMould::GeneratorMould ()
- {
- //if (mLog::gLogger == nullptr)
- //{
- // string strLogPath = GetProcessDirectory() + R"(\OEMDrivers\Generator\Conf\Log4CPP.Config.GEN.xml)";
- // //Log4CPP::ThreadContext::Map::Set("LogFileName", "GEN.Mould");
- // Log4CPP::GlobalContext::Map::Set(ECOM::Utility::Hash("LogFileName"), "GEN.Mould");
- // auto rc = Log4CPP::LogManager::LoadConfigFile(strLogPath.c_str());
- // mLog::gLogger = Log4CPP::LogManager::GetLogger("GEN.Mould");
- //}
- ////添加模型日志打印
- //string version;
- //if (GetVersion(version, hMyModule))
- // mLog::Info("\n===============log begin : Mould version:{$} ===================\n", version.c_str());
- //else
- // mLog::Info("\n===============log begin : Mould version:0.0.0.0 ===================\n");
- //不知有何用
- m_DoseUnit.m_GenTotalExpNumber.reset(new TOTALEXPNUMMould(0, 0, 999999, 1));
- m_DoseUnit.m_GenTotalAcqTimes.reset(new TOTALACQTIMESMould(0, 0, 999999, 1));
- m_DoseUnit.m_GenTubeCoolWaitTimes.reset(new TUBECOOLTIMEMould(0, 0, 999999, 1));
- m_DoseUnit.m_GenTubeOverLoadNumber.reset(new TUBEOVERLOADNUMMould(0, 0, 999999, 1));
- m_DoseUnit.m_GenCurrentExpNumber.reset(new CUREXPNUMMould(0, 0, 999999, 1));
- m_DoseUnit.m_Modality.reset(new MODALITYMould("DX"));
- //设备状态
- m_DoseUnit.m_GenSynState.reset(new GENSYNSTATEMould(0, AttrKey::GENERATOR_SYNC_ERR, AttrKey::GENERATOR_RAD_XRAYOFF, 1));
- m_DoseUnit.m_GenState.reset(new GENSTATEMould(0, AttrKey::GENERATOR_STATUS_SHUTDOWN, AttrKey::GENERATOR_STATUS_MAX, 1));
- m_DoseUnit.m_HE.reset(new TUBEHEATMould(0, 0, 100, 1));
- m_DoseUnit.m_WS.reset(new WORKSTATIONMould(1, 0, 5, 1));
- m_DoseUnit.m_ExpMode.reset(new EXPMODEMould(AttrKey::EXPMODE_TYPE::Single));
- m_DoseUnit.m_EXAMMode.reset(new EXAMMODEMould(AttrKey::EXAMMODE_TYPE::MANUAL));
- m_DoseUnit.m_BatteryChargeState.reset(new BATTERYCHARGSTATEMould(0, 0, 2, 1));
- m_DoseUnit.m_ReferenceAirKerma.reset(new REFERENCEAIRKERMAMould(0, 0, 999999.0, 0.01));
- m_DoseUnit.m_TubeInfo.reset(new TUBEINFOMould("null"));
- m_DoseUnit.m_TubeTargetMaterial.reset(new TUBETARGETMATERIALMould(AttrKey::TUBETARGETMATERIAL_TYPE::MO));
- m_DoseUnit.m_TubeAngle.reset(new TUBEANGLEMould(0.0, 0.0, 360.0, 1));
- //点片参数
- m_DoseUnit.m_KV.reset(new KVMould(0.0, 40.0, 150.0, 1.0));
- m_DoseUnit.m_MA.reset(new MAMould(0.0, 1.0, 5000.0, 0.1));
- m_DoseUnit.m_MS.reset(new MSMould(0.0, 1.0, 50000.0, 0.01));
- m_DoseUnit.m_MAS.reset(new MASMould(0.0, 0.5, 5000.0, 0.01));
- m_DoseUnit.m_Techmode.reset(new TECHMODEMould(0, 0, 2, 1));
- m_DoseUnit.m_Focus.reset(new FOCUSMould(1, 0, 1, 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, 40.0, 150.0, 1.0));
- m_DoseUnit.m_PostMA.reset(new POSTMAMould(0.0, 8.0, 1000.0, 0.1));
- m_DoseUnit.m_PostMS.reset(new POSTMSMould(0.0, 1.0, 10000.0, 0.01));
- m_DoseUnit.m_PostMAS.reset(new POSTMASMould(0.0, 0.5, 1000.0, 0.01));
- m_DoseUnit.m_FrameRate.reset(new FRAMERATEMould(0.0, 0.0, 30.0, 0.01));
- m_DoseUnit.m_KVList.reset(new KVLISTMould(""));
- m_DoseUnit.m_mAsList.reset(new MASLISTMould(""));
-
- //透视参数不通用暂时不初始化
- }
- nsGEN::GeneratorMould::~GeneratorMould ()
- {
- //ReleaseLogger();
- //delete g_GENLogger;
- }
- //-----------------------------------------------------------------------------
- // 所有注册应函数
- //-----------------------------------------------------------------------------
- void nsGEN::GeneratorMould::Register (Dispatch* Dispatch)
- {
- //不知有何用
- Dispatch->Get.Push(AttrKey::TOTALEXPSURENUMBER, [this](std::string& out) {
- if (m_DoseUnit.m_GenTotalExpNumber)
- out = m_DoseUnit.m_GenTotalExpNumber->JSGet();
- return RET_STATUS::RET_SUCCEED; });
- Dispatch->Get.Push(AttrKey::TOTALACQTIMES, [this](std::string& out) {
- if (m_DoseUnit.m_GenTotalAcqTimes)
- out = m_DoseUnit.m_GenTotalAcqTimes->JSGet();
- return RET_STATUS::RET_SUCCEED; });
- Dispatch->Get.Push(AttrKey::TUBECOOLWAITTIME, [this](std::string& out) {
- if (m_DoseUnit.m_GenTubeCoolWaitTimes)
- out = m_DoseUnit.m_GenTubeCoolWaitTimes->JSGet();
- return RET_STATUS::RET_SUCCEED; });
- Dispatch->Get.Push(AttrKey::TUBEOVERLOADNUMBER, [this](std::string& out) {
- if (m_DoseUnit.m_GenTubeOverLoadNumber)
- out = m_DoseUnit.m_GenTubeOverLoadNumber->JSGet();
- return RET_STATUS::RET_SUCCEED; });
- Dispatch->Get.Push(AttrKey::CURRENTEXPOSUREBNUMBER, [this](std::string& out) {
- if (m_DoseUnit.m_GenCurrentExpNumber)
- out = m_DoseUnit.m_GenCurrentExpNumber->JSGet();
- return RET_STATUS::RET_SUCCEED; });
- //Modality ?
- Dispatch->Get.Push(AttrKey::MODALITY, [this](std::string& out) {
- if (m_DoseUnit.m_Modality)
- out = m_DoseUnit.m_Modality->JSGet();
- return RET_STATUS::RET_SUCCEED; });
- Dispatch->Action.Push(ActionKey::SetModality, [this](std::string in, std::string& out) {
- ResDataObject json;
- json.decode(in.c_str());
- auto value = (string)json[0];
- if (m_DoseUnit.m_Modality != nullptr)
- {
- m_DoseUnit.m_Modality->Update(value);
- }
- return RET_STATUS::RET_SUCCEED; });
- //热熔
- Dispatch->Get.Push(AttrKey::TUBEHEAT, [this](std::string& out) {
- if (m_DoseUnit.m_HE)
- out = m_DoseUnit.m_HE->JSGet();
- return RET_STATUS::RET_SUCCEED; });
- Dispatch->Action.Push(ActionKey::Query_HE, [this](std::string in, std::string& out) {
- int value = 0;
- RET_STATUS ret = QueryHE(value);
- out = ToJSON(value);return ret;});
- //球管状态
- Dispatch->Get.Push(AttrKey::TUBEINFO, [this](std::string& out) {
- if (m_DoseUnit.m_TubeInfo)
- out = m_DoseUnit.m_TubeInfo->JSGet();
- return RET_STATUS::RET_SUCCEED; });
- Dispatch->Get.Push(AttrKey::TUBEANGLE, [this](std::string& out) {
- if (m_DoseUnit.m_TubeAngle)
- out = m_DoseUnit.m_TubeAngle->JSGet();
- return RET_STATUS::RET_SUCCEED; });
- Dispatch->Action.Push(ActionKey::SetTubeAngle, [this](std::string in, std::string& out) {
- auto value = JSONTo <float>(in);
- if (m_DoseUnit.m_TubeAngle != nullptr)
- {
- m_DoseUnit.m_TubeAngle->Update(value);
- }
- return RET_STATUS::RET_SUCCEED; });
- Dispatch->Get.Push(AttrKey::TUBETARGETMATERIAL, [this](std::string& out) {
- if (m_DoseUnit.m_TubeTargetMaterial)
- out = m_DoseUnit.m_TubeTargetMaterial->JSGet();
- return RET_STATUS::RET_SUCCEED; });
- Dispatch->Action.Push(ActionKey::SetTubeTargetMaterial, [this](std::string in, std::string& out) {
- ResDataObject json;
- json.decode(in.c_str());
- auto value = (string)json[0];
- if (m_DoseUnit.m_TubeTargetMaterial != nullptr)
- {
- m_DoseUnit.m_TubeTargetMaterial->Update(value);
- }
- return RET_STATUS::RET_SUCCEED; });
- //电池状态
- Dispatch->Get.Push(AttrKey::BATTERYCHARGESTATE, [this](std::string& out) {
- if (m_DoseUnit.m_BatteryChargeState)
- out = m_DoseUnit.m_BatteryChargeState->JSGet();
- return RET_STATUS::RET_SUCCEED; });
- Dispatch->Get.Push(AttrKey::REFERENCEAIRKERMA, [this](std::string& out) {
- out = m_DoseUnit.m_ReferenceAirKerma->JSGet();
- return RET_STATUS::RET_SUCCEED; });
- //设备状态
- Dispatch->Get.Push(AttrKey::GENSTATE, [this](std::string& out) {
- if (m_DoseUnit.m_GenState)
- out = m_DoseUnit.m_GenState->JSGet();
- return RET_STATUS::RET_SUCCEED; });
- //曝光模式
- Dispatch->Get.Push(AttrKey::EXPMODE, [this](std::string& out) {
- if (m_DoseUnit.m_ExpMode)
- out = m_DoseUnit.m_ExpMode->JSGet();
- return RET_STATUS::RET_SUCCEED; });
- Dispatch->Set.Push(AttrKey::EXPMODE, [this](std::string in) {
- ResDataObject json;
- json.decode(in.c_str());
- auto value = (string)json[0];
- return SetExpMode(value); });
- Dispatch->Action.Push(ActionKey::SetExpMode, [this](std::string in, std::string& out) {
- ResDataObject json;
- json.decode(in.c_str());
- auto value = (string)json[0];
- return SetExpMode(value); });
- //检查模式
- Dispatch->Get.Push(AttrKey::EXAMMODE, [this](std::string& out) {
- if (m_DoseUnit.m_EXAMMode)
- out = m_DoseUnit.m_EXAMMode->JSGet();
- return RET_STATUS::RET_SUCCEED; });
- Dispatch->Set.Push(AttrKey::EXAMMODE, [this](std::string in) {
- ResDataObject json;
- json.decode(in.c_str());
- auto value = (string)json[0];
- return SetEXAMMode(value); });
- Dispatch->Action.Push(ActionKey::SetEXAMMode, [this](std::string in, std::string& out) {
- ResDataObject json;
- json.decode(in.c_str());
- auto value = (string)json[0];
- return SetEXAMMode(value); });
- //工作位
- Dispatch->Get.Push(AttrKey::WORKSTATION, [this](std::string& out) {
- if (m_DoseUnit.m_WS)
- out = m_DoseUnit.m_WS->JSGet();
- return RET_STATUS::RET_SUCCEED; });
- Dispatch->Set.Push(AttrKey::WORKSTATION, [this](std::string in) {
- printf("JSSetWORKSTATION:%s\n", in.c_str());
- ResDataObject json;
- json.decode(in.c_str());
- string value = json[0].encode();
- int tempws = 0;
- if (value == "Table")
- {
- tempws = 0;
- }
- else if (value == "Wall")
- {
- tempws = 1;
- }
- else if (value == "Direct")
- {
- tempws = 2;
- }
- else if (value == "Free")
- {
- tempws = 3;
- }
- return SetWS(value); });
- Dispatch->Action.Push(ActionKey::SetValue_WORKSTATION, [this](std::string in, std::string& out) {
- printf("JSSetWORKSTATION:%s\n", in.c_str());
- ResDataObject json;
- json.decode(in.c_str());
- string value = json[0].encode();
- int tempws = 0;
- if (value == "Table")
- {
- tempws = 0;
- }
- else if (value == "Wall")
- {
- tempws = 1;
- }
- else if (value == "Direct")
- {
- tempws = 2;
- }
- else if (value == "Free")
- {
- tempws = 3;
- }
- return SetWS(value); });
- //重置
- Dispatch->Action.Push(ActionKey::Reset, [this](std::string in, std::string& out) {
- return Reset(); });
- //同步模式
- Dispatch->Action.Push(ActionKey::ActiveSyncMode, [this](std::string in, std::string& out) {
- ResDataObject json;
- json.decode(in.c_str());
- _tSyncModeArgs t{ };
- if (json.size() >= 3)
- {
- t.strWS = (string)json[0];
- t.strSyncMode = (string)json[1];
- t.strSyncValue = (string)json[2];
- return ActiveSyncMode(t);
- }
- else
- {
- return RET_STATUS::RET_FAILED;
- }});
- Dispatch->Action.Push(ActionKey::SimulateError, [this](std::string in, std::string& out) {
- ResDataObject json;
- json.decode(in.c_str());
- auto value = (string)json[0];
- return SimulateError(value); });
- Dispatch->Action.Push(ActionKey::SetDeviceSleepState, [this](std::string in, std::string& out) {
- ResDataObject json;
- json.decode(in.c_str());
- auto value = (int)json[0];
- return SetDeviceSleepState(value); });
- //注册updata
- Dispatch->Update.Push("CurrentSMState", [this](std::string in, std::string& out) {
- return SetGenCurrentSMState(in); });
- }
- void nsGEN::GeneratorMould::RegisterOther(Dispatch* Dispatch) // 子类可能希望注册更多的
- {
- //遮光器属性
- Dispatch->Action.Push(ActionKey::SetCollimatorLight, [this](std::string in, std::string& out) {
- auto value = JSONTo <float>(in);
- SetCollimatorLight(value);
- return RET_STATUS::RET_SUCCEED;
- });
- }
- void nsGEN::GeneratorMould::RegisterAEC(Dispatch* Dispatch)
- {
- Dispatch->Get.Push(AttrKey::AECDENSITY, [this](std::string& out) {
- if (m_DoseUnit.m_AECDensity)
- out = m_DoseUnit.m_AECDensity->JSGet();
- return RET_STATUS::RET_SUCCEED; });
- Dispatch->Set.Push(AttrKey::AECDENSITY, [this](std::string in) {
- auto value = JSONTo <int>(in);
- return SetAECDensity(value); });
- Dispatch->Action.Push(ActionKey::SetValue_AECDENSITY, [this](std::string in, std::string& out) {
- auto value = JSONTo <int>(in);
- return SetAECDensity(value);});
- Dispatch->Action.Push(ActionKey::IncParam_AECDENSITY, [this](std::string in, std::string& out) {
- return IncAECDensity(); });
- Dispatch->Action.Push(ActionKey::DecParam_AECDENSITY, [this](std::string in, std::string& out) {
- return DecAECDensity(); });
- Dispatch->Get.Push(AttrKey::AECFIELD, [this](std::string& out) {
- if (m_DoseUnit.m_AECField)
- out = m_DoseUnit.m_AECField->JSGet();
- return RET_STATUS::RET_SUCCEED; });
- Dispatch->Set.Push(AttrKey::AECFIELD, [this](std::string in) {
- auto value = JSONTo <int>(in);
- return SetAECField(value); });
- Dispatch->Action.Push(ActionKey::SetValue_AECFIELD, [this](std::string in, std::string& out) {
- auto value = JSONTo <int>(in);
- return SetAECField(value); });
- Dispatch->Get.Push(AttrKey::AECFILM, [this](std::string& out) {
- if (m_DoseUnit.m_AECFilm)
- out = m_DoseUnit.m_AECFilm->JSGet();
- return RET_STATUS::RET_SUCCEED; });
- Dispatch->Set.Push(AttrKey::AECFILM, [this](std::string in) {
- auto value = JSONTo <int>(in);
- return SetAECFilm(value); });
- Dispatch->Action.Push(ActionKey::SetValue_AECFILM, [this](std::string in, std::string& out) {
- auto value = JSONTo <int>(in);
- return SetAECFilm(value); });
- }
- void nsGEN::GeneratorMould::RegisterExpEnable(Dispatch* Dispatch)
- {
- Dispatch->Action.Push(ActionKey::SetExpEnable, [this](std::string in, std::string& out) {
- return SetExpEnable(); });
- Dispatch->Action.Push(ActionKey::SetExpDisable, [this](std::string in, std::string& out) {
- return SetExpDisable(); });
- }
- void nsGEN::GeneratorMould::RegisterGeneratortoSyncStatus(Dispatch* Dispatch)
- {
- Dispatch->Get.Push(AttrKey::GENSYNSTATE, [this](std::string& out) {
- if (m_DoseUnit.m_GenSynState)
- out = m_DoseUnit.m_GenSynState->JSGet();
- return RET_STATUS::RET_SUCCEED; });
- Dispatch->Set.Push(AttrKey::GENSYNSTATE, [this](std::string in) {
- auto value = JSONTo <int>(in);
- return SetGenSynState(value); });
- Dispatch->Action.Push(ActionKey::SetGeneratortoSyncStatus, [this](std::string in, std::string& out) {
- auto value = JSONTo <int>(in);
- return SetGenSynState(value); });
- }
- void nsGEN::GeneratorMould::RegisterRAD(Dispatch* Dispatch)
- {
- //KV
- Dispatch->Get.Push(AttrKey::KVLIST, [this](std::string& out) {
- if (m_DoseUnit.m_KVList)
- out = m_DoseUnit.m_KVList->JSGet();
- return RET_STATUS::RET_SUCCEED; });
- Dispatch->Get.Push(AttrKey::KV, [this](std::string& out) {
- if (m_DoseUnit.m_KV)
- out = m_DoseUnit.m_KV->JSGet();
- return RET_STATUS::RET_SUCCEED; });
- Dispatch->Set.Push(AttrKey::KV, [this](std::string in) {
- auto value = JSONTo <float>(in);
- return SetKV(value); });
- Dispatch->Action.Push(ActionKey::IncParam_KV, [this](std::string in, std::string& out) {
- return IncKV(); });
- Dispatch->Action.Push(ActionKey::DecParam_KV, [this](std::string in, std::string& out) {
- return DecKV(); });
- Dispatch->Action.Push(ActionKey::IncParam_KVL, [this](std::string in, std::string& out) {
- return IncKVL(); });
- Dispatch->Action.Push(ActionKey::DecParam_KVL, [this](std::string in, std::string& out) {
- return DecKVL(); });
- Dispatch->Action.Push(ActionKey::SetValue_KV, [this](std::string in, std::string& out) {
- auto value = JSONTo <float>(in);
- return SetKV(value); });
- //MA
- Dispatch->Get.Push(AttrKey::MA, [this](std::string& out) {
- if (m_DoseUnit.m_MA)
- out = m_DoseUnit.m_MA->JSGet();
- return RET_STATUS::RET_SUCCEED; });
- Dispatch->Set.Push(AttrKey::MA, [this](std::string in) {
- auto value = JSONTo <float>(in);
- return SetMA(value); });
- Dispatch->Action.Push(ActionKey::IncParam_MA, [this](std::string in, std::string& out) {
- return IncMA(); });
- Dispatch->Action.Push(ActionKey::DecParam_MA, [this](std::string in, std::string& out) {
- return DecMA();});
- Dispatch->Action.Push(ActionKey::IncParam_MAL, [this](std::string in, std::string& out) {
- return IncMAL(); });
- Dispatch->Action.Push(ActionKey::DecParam_MAL, [this](std::string in, std::string& out) {
- return DecMAL(); });
- Dispatch->Action.Push(ActionKey::SetValue_MA, [this](std::string in, std::string& out) {
- auto value = JSONTo <float>(in);
- return SetMA(value); });
- //MS
- Dispatch->Get.Push(AttrKey::MS, [this](std::string& out) {
- if (m_DoseUnit.m_MS)
- out = m_DoseUnit.m_MS->JSGet();
- return RET_STATUS::RET_SUCCEED; });
- Dispatch->Set.Push(AttrKey::MS, [this](std::string in) {
- auto value = JSONTo <float>(in);
- return SetMS(value); });
- Dispatch->Action.Push(ActionKey::IncParam_MS, [this](std::string in, std::string& out) {
- return IncMS(); });
- Dispatch->Action.Push(ActionKey::DecParam_MS, [this](std::string in, std::string& out) {
- return DecMS(); });
- Dispatch->Action.Push(ActionKey::IncParam_MSL, [this](std::string in, std::string& out) {
- return IncMSL(); });
- Dispatch->Action.Push(ActionKey::DecParam_MSL, [this](std::string in, std::string& out) {
- return DecMSL(); });
- Dispatch->Action.Push(ActionKey::SetValue_MS, [this](std::string in, std::string& out) {
- auto value = JSONTo <float>(in);
- return SetMS(value); });
-
- //MAS
- Dispatch->Get.Push(AttrKey::MASLIST, [this](std::string& out) {
- if (m_DoseUnit.m_mAsList)
- out = m_DoseUnit.m_mAsList->JSGet();
- return RET_STATUS::RET_SUCCEED; });
- Dispatch->Get.Push(AttrKey::MAS, [this](std::string& out) {
- if (m_DoseUnit.m_MAS)
- out = m_DoseUnit.m_MAS->JSGet();
- return RET_STATUS::RET_SUCCEED; });
- Dispatch->Set.Push(AttrKey::MAS, [this](std::string in) {
- auto value = JSONTo <float>(in);
- return SetMAS(value); });
- Dispatch->Action.Push(ActionKey::IncParam_MAS, [this](std::string in, std::string& out) {
- return IncMAS(); });
- Dispatch->Action.Push(ActionKey::DecParam_MAS, [this](std::string in, std::string& out) {
- return DecMAS(); });
- Dispatch->Action.Push(ActionKey::IncParam_MASL, [this](std::string in, std::string& out) {
- return IncMASL(); });
- Dispatch->Action.Push(ActionKey::DecParam_MASL, [this](std::string in, std::string& out) {
- return DecMASL(); });
- Dispatch->Action.Push(ActionKey::SetValue_MAS, [this](std::string in, std::string& out) {
- auto value = JSONTo <float>(in);
- return SetMAS(value); });
-
- //FOCUS
- Dispatch->Get.Push(AttrKey::FOCUS, [this](std::string& out) {
- if (m_DoseUnit.m_Focus)
- out = m_DoseUnit.m_Focus->JSGet();
- return RET_STATUS::RET_SUCCEED; });
- Dispatch->Set.Push(AttrKey::FOCUS, [this](std::string in) {
- auto value = JSONTo <int>(in);
- return SetFocus(value); });
- Dispatch->Action.Push(ActionKey::SetValue_FOCUS, [this](std::string in, std::string& out) {
- auto value = JSONTo <int>(in);
- return SetFocus(value); });
-
- //TECHMODE
- Dispatch->Get.Push(AttrKey::TECHMODE, [this](std::string& out) {
- if (m_DoseUnit.m_Techmode)
- out = m_DoseUnit.m_Techmode->JSGet();
- return RET_STATUS::RET_SUCCEED; });
- Dispatch->Set.Push(AttrKey::TECHMODE, [this](std::string in) {
- auto value = JSONTo <int>(in);
- return SetTechmode(value); });
- Dispatch->Action.Push(ActionKey::SetValue_TECHMODE, [this](std::string in, std::string& out) {
- auto value = JSONTo <int>(in);
- return SetTechmode(value); });
- //APR
- Dispatch->Action.Push(ActionKey::SetAPR, [this](std::string in, std::string& out) {
- ResDataObject json;
- if (!json.decode(in.c_str())) {
- printf("Failed to decode JSON input\n");
- out = "{\"error\":\"Invalid JSON format\"}";
- return RET_STATUS::RET_FAILED;
- }
- vector<_tAPRArgs> APRarray;
- try
- {
- for (int i = 0; i < json.size(); i++)
- {
- ResDataObject param = json[i];
- _tAPRArgs apr{ };
- try {
- apr.nWS = (int)param[AttrKey::WORKSTATION];
- }
- catch (...) {
- apr.nWS = 0;
- printf("Warning: Invalid WORKSTATION value, using default 0\n");
- }
- try {
- apr.nFocus = (int)param[AttrKey::FOCUS];
- }
- catch (...) {
- apr.nFocus = 0;
- printf("Warning: Invalid FOCUS value, using default 0\n");
- }
- try {
- apr.nTechmode = (int)param[AttrKey::TECHMODE];
- }
- catch (...) {
- apr.nTechmode = 0;
- printf("Warning: Invalid TECHMODE value, using default 0\n");
- }
- try {
- apr.fKV = (float)param[AttrKey::KV];
- }
- catch (...) {
- apr.fKV = 0.0f;
- printf("Warning: Invalid KV value, using default 0.0\n");
- }
- try {
- apr.fMA = (float)param[AttrKey::MA];
- }
- catch (...) {
- apr.fMA = 0.0f;
- printf("Warning: Invalid MA value, using default 0.0\n");
- }
- try {
- apr.fMS = (float)param[AttrKey::MS];
- }
- catch (...) {
- apr.fMS = 0.0f;
- printf("Warning: Invalid MS value, using default 0.0\n");
- }
- try {
- apr.fKV2 = (float)param[AttrKey::KV2];
- }
- catch (...) {
- apr.fKV2 = 0.0f;
- printf("Warning: Invalid KV2 value, using default 0.0\n");
- }
- try {
- apr.fMA2 = (float)param[AttrKey::MA2];
- }
- catch (...) {
- apr.fMA2 = 0.0f;
- printf("Warning: Invalid MA2 value, using default 0.0\n");
- }
- try {
- apr.fMS2 = (float)param[AttrKey::MS2];
- }
- catch (...) {
- apr.fMS2 = 0.0f;
- printf("Warning: Invalid MS2 value, using default 0.0\n");
- }
- try {
- apr.fMAS = (float)param[AttrKey::MAS];
- }
- catch (...) {
- apr.fMAS = 0.0f;
- printf("Warning: Invalid MAS value, using default 0.0\n");
- }
- try {
- apr.nAECDensity = (int)param[AttrKey::AECDENSITY];
- }
- catch (...) {
- apr.nAECDensity = 0;
- printf("Warning: Invalid AECDENSITY value, using default 0\n");
- }
- try {
- apr.nAECFilm = (int)param[AttrKey::AECFILM];
- }
- catch (...) {
- apr.nAECFilm = 0;
- printf("Warning: Invalid AECFILM value, using default 0\n");
- }
- try {
- apr.nAECField = (int)param[AttrKey::AECFIELD];
- }
- catch (...) {
- apr.nAECField = 0;
- printf("Warning: Invalid AECFIELD value, using default 0\n");
- }
- APRarray.push_back(apr);
- }
- }
- catch (const std::exception& e) {
- printf("SetAPR Exception: %s\n", e.what());
- APRarray.push_back(_tAPRArgs{});
- }
- catch (...) {
- printf("SetAPR Unknown Exception\n");
- APRarray.push_back(_tAPRArgs{});
- }
- if (APRarray.empty()) {
- printf("Warning: APRarray is empty, adding default parameters\n");
- APRarray.push_back(_tAPRArgs{});
- }
- if (APRarray.size() > 1) {
- return SetAPRArray(APRarray);
- }
- else {
- return SetAPR(APRarray[0]);
- } });
- Dispatch->Action.Push(ActionKey::SetAPRArray, [this](std::string in, std::string& out) {
- ResDataObject json;
- json.decode(in.c_str());
- vector<_tAPRArgs> APRarray;
- try
- {
- for (int i = 0; i < json.size(); i++)
- {
- ResDataObject param = json[i];
- _tAPRArgs apr{ };
- apr.nWS = (int)param[AttrKey::WORKSTATION];
- apr.nFocus = (int)param[AttrKey::FOCUS];
- apr.nTechmode = (int)param[AttrKey::TECHMODE];
- apr.fKV = (float)param[AttrKey::KV];
- apr.fMA = (float)param[AttrKey::MA];
- apr.fMS = (float)param[AttrKey::MS];
- apr.fKV2 = (float)param[AttrKey::KV2];
- apr.fMA2 = (float)param[AttrKey::MA2];
- apr.fMS2 = (float)param[AttrKey::MS2];
- apr.fMAS = (float)param[AttrKey::MAS];
- apr.nAECDensity = (int)param[AttrKey::AECDENSITY];
- apr.nAECFilm = (int)param[AttrKey::AECFILM];
- apr.nAECField = (int)param[AttrKey::AECFIELD];
- APRarray.push_back(apr);
- }
- }
- catch (...)
- {
- printf("SetAPRArray Crash\n");
- }
- return SetAPRArray(APRarray); });
- //序列点片帧率
- Dispatch->Get.Push(AttrKey::FRAMERATE, [this](std::string& out) {
- if (m_DoseUnit.m_FrameRate)
- out = m_DoseUnit.m_FrameRate->JSGet();
- return RET_STATUS::RET_SUCCEED; });
- Dispatch->Set.Push(AttrKey::FRAMERATE, [this](std::string in) {
- auto value = JSONTo <float>(in);
- return SetFrameRate(value); });
- Dispatch->Action.Push(ActionKey::SetFrameRate, [this](std::string in, std::string& out) {
- auto value = JSONTo <float>(in);
- return SetFrameRate(value); });
- //曝光后的post值
- Dispatch->Action.Push(ActionKey::GetValue_POSTKV, [this](std::string in, std::string& out) {
- float value = 0;
- RET_STATUS ret = QueryPostKV(value);
- ResDataObject tempret;
- tempret = value;
- out = (const char*)tempret;
- return ret; });
- Dispatch->Get.Push(AttrKey::POSTKV, [this](std::string& out) {
- if (m_DoseUnit.m_PostKV)
- out = m_DoseUnit.m_PostKV->JSGet();
- return RET_STATUS::RET_SUCCEED; });
- Dispatch->Action.Push(ActionKey::GetValue_POSTMA, [this](std::string in, std::string& out) {
- float value = 0;
- RET_STATUS ret = QueryPostMA(value);
- ResDataObject tempret;
- tempret = value;
- out = (const char*)tempret;
- return ret; });
- Dispatch->Get.Push(AttrKey::POSTMA, [this](std::string& out) {
- if (m_DoseUnit.m_PostMA)
- out = m_DoseUnit.m_PostMA->JSGet();
- return RET_STATUS::RET_SUCCEED; });
- Dispatch->Action.Push(ActionKey::GetValue_POSTMS, [this](std::string in, std::string& out) {
- float value = 0;
- RET_STATUS ret = QueryPostMS(value);
- ResDataObject tempret;
- tempret = value;
- out = (const char*)tempret;
- return ret; });
- Dispatch->Get.Push(AttrKey::POSTMS, [this](std::string& out) {
- if (m_DoseUnit.m_PostMS)
- out = m_DoseUnit.m_PostMS->JSGet();
- return RET_STATUS::RET_SUCCEED; });
- Dispatch->Action.Push(ActionKey::GetValue_POSTMAS, [this](std::string in, std::string& out) {
- float value = 0;
- RET_STATUS ret = QueryPostMAS(value);
- ResDataObject tempret;
- tempret = value;
- out = (const char*)tempret;
- return ret; });
- Dispatch->Get.Push(AttrKey::POSTMAS, [this](std::string& out) {
- if (m_DoseUnit.m_PostMAS)
- out = m_DoseUnit.m_PostMAS->JSGet();
- return RET_STATUS::RET_SUCCEED; });
- }
- void nsGEN::GeneratorMould::RegisterFluoro(Dispatch* Dispatch)
- {
- //透视模式
- Dispatch->Get.Push(AttrKey::FLUMode, [this](std::string& out) {
- if (m_DoseUnit.m_FLMode)
- out = m_DoseUnit.m_FLMode->JSGet();
- return RET_STATUS::RET_SUCCEED; });
- Dispatch->Get.Push(AttrKey::FLUAccTimeUnit, [this](std::string& out) {
- out = m_DoseUnit.m_FLAccTimeUnit;
- return RET_STATUS::RET_SUCCEED; });
- Dispatch->Set.Push(AttrKey::FLUMode, [this](std::string in) {
- ResDataObject json;
- json.decode(in.c_str());
- auto value = (string)json[0];
- return SetFLFMode(value); });
- Dispatch->Action.Push(ActionKey::SetFLFMode, [this](std::string in, std::string& out) {
- ResDataObject json;
- json.decode(in.c_str());
- auto value = (string)json[0];
- return SetFLFMode(value); });
- //透视KV
- Dispatch->Get.Push(AttrKey::FLUKV, [this](std::string& out) {
- if (m_DoseUnit.m_FLKV)
- out = m_DoseUnit.m_FLKV->JSGet();
- return RET_STATUS::RET_SUCCEED; });
- Dispatch->Set.Push(AttrKey::FLUKV, [this](std::string in) {
- auto value = JSONTo <float>(in);
- return SetFluKV(value); });
- Dispatch->Action.Push(ActionKey::IncParam_FluKV, [this](std::string in, std::string& out) {
- return IncFluKV(); });
- Dispatch->Action.Push(ActionKey::DecParam_FluKV, [this](std::string in, std::string& out) {
- return DecFluKV(); });
- Dispatch->Action.Push(ActionKey::SetValue_FluKV, [this](std::string in, std::string& out) {
- auto value = JSONTo <float>(in);
- return SetFluKV(value); });
- //透视MA
- Dispatch->Get.Push(AttrKey::FLUMA, [this](std::string& out) {
- if (m_DoseUnit.m_FLMA)
- out = m_DoseUnit.m_FLMA->JSGet();
- return RET_STATUS::RET_SUCCEED; });
- Dispatch->Set.Push(AttrKey::FLUMA, [this](std::string in) {
- auto value = JSONTo <float>(in);
- return SetFluMA(value); });
- Dispatch->Action.Push(ActionKey::IncParam_FluMA, [this](std::string in, std::string& out) {
- return IncFluMA(); });
- Dispatch->Action.Push(ActionKey::DecParam_FluMA, [this](std::string in, std::string& out) {
- return DecFluMA(); });
- Dispatch->Action.Push(ActionKey::SetValue_FluMA, [this](std::string in, std::string& out) {
- auto value = JSONTo <float>(in);
- return SetFluMA(value); });
- //透视曝光时间
- Dispatch->Get.Push(AttrKey::FLUMS, [this](std::string& out) {
- if (m_DoseUnit.m_FLMS)
- out = m_DoseUnit.m_FLMS->JSGet();
- return RET_STATUS::RET_SUCCEED; });
- Dispatch->Set.Push(AttrKey::FLUMS, [this](std::string in) {
- auto value = JSONTo <float>(in);
- return SetFluMS(value); });
- Dispatch->Action.Push(ActionKey::IncParam_FluMS, [this](std::string in, std::string& out) {
- return IncFluMS(); });
- Dispatch->Action.Push(ActionKey::DecParam_FluMS, [this](std::string in, std::string& out) {
- return DecFluMS(); });
- Dispatch->Action.Push(ActionKey::SetValue_FluMS, [this](std::string in, std::string& out) {
- auto value = JSONTo <float>(in);
- return SetFluMS(value); });
- //透视帧率
- Dispatch->Get.Push(AttrKey::FLUPPS, [this](std::string& out) {
- if (m_DoseUnit.m_PPS)
- out = m_DoseUnit.m_PPS->JSGet();
- return RET_STATUS::RET_SUCCEED; });
- Dispatch->Set.Push(AttrKey::FLUPPS, [this](std::string in) {
- auto value = JSONTo <float>(in);
- return SetPPS(value); });
- Dispatch->Action.Push(ActionKey::IncParam_PPS, [this](std::string in, std::string& out) {
- return INCPPS(); });
- Dispatch->Action.Push(ActionKey::DecParam_PPS, [this](std::string in, std::string& out) {
- return DECPPS(); });
- Dispatch->Action.Push(ActionKey::SetValue_PPS, [this](std::string in, std::string& out) {
- auto value = JSONTo <float>(in);
- return SetPPS(value); });
- //脉冲脉宽
- Dispatch->Set.Push(AttrKey::FLUpulseWidth, [this](std::string in) {
- auto value = JSONTo <int>(in);
- return SetPluseWidth(value); });
- Dispatch->Action.Push(ActionKey::SetValue_PluseWidth, [this](std::string in, std::string& out) {
- auto value = JSONTo <int>(in);
- return SetPluseWidth(value); });
- //ABS模式
- Dispatch->Set.Push(AttrKey::FLUABSStatus, [this](std::string in) {
- auto value = JSONTo <int>(in);
- return SetABSMode(value); });
- Dispatch->Action.Push(ActionKey::SetValue_ABSMode, [this](std::string in, std::string& out) {
- auto value = JSONTo <int>(in);
- return SetABSMode(value); });
- //ABS曲线
- Dispatch->Set.Push(AttrKey::FLUCurve, [this](std::string in) {
- auto value = JSONTo <int>(in);
- return SetABSCurve(value); });
- Dispatch->Action.Push(ActionKey::IncParam_ABSCurve, [this](std::string in, std::string& out) {
- return IncABSCurve(); });
- Dispatch->Action.Push(ActionKey::DecParam_ABSCurve, [this](std::string in, std::string& out) {
- return DecABSCurve(); });
- Dispatch->Action.Push(ActionKey::SetValue_ABSCurve, [this](std::string in, std::string& out) {
- auto value = JSONTo <int>(in);
- return SetABSCurve(value); });
- //当前EXI
- //Dispatch->Set.Push(AttrKey::ABSValue, this, &GeneratorMould::JSsetABSValue);
- Dispatch->Action.Push(ActionKey::SetValue_ABSValue, [this](std::string in, std::string& out) {
- auto value = JSONTo <float>(in);
- return SetABSValue(value); });
- //目标EXI
- //Dispatch->Set.Push(AttrKey::ABSTargetEXI, this, &GeneratorMould::JSsetABSTargetEXI);
- Dispatch->Action.Push(ActionKey::SetValue_ABSTargetEXI, [this](std::string in, std::string& out) {
- auto value = JSONTo <float>(in);
- return SetABSTargetEXI(value); });
- //APF
- Dispatch->Action.Push(ActionKey::SetValue_APF, [this](std::string in, std::string& out) {
- _tAPFArgs t{ 0 };
- ResDataObject json;
- json.decode(in.c_str());
- auto& R0 = json[0];
- try
- {
- t.nWS = atoi(((string)R0[AttrKey::WORKSTATION]).c_str());
- }
- catch (const std::exception&)
- {
- printf("SetWS Crash\n");
- }
- catch (const ResDataObjectExption&)
- {
- printf("none matches the WORKSTATION\n");
- }
- try
- {
- t.nFluMode = atoi(((string)R0[AttrKey::FLUMode]).c_str());
- }
- catch (const std::exception&)
- {
- }
- catch (const ResDataObjectExption&)
- {
- }
- try
- {
- t.nABSMode = (int)R0[AttrKey::FLUABSStatus];
- }
- catch (const std::exception&)
- {
- }
- catch (const ResDataObjectExption&)
- {
- }
- try
- {
- t.nDoseLever = atof(((string)R0[AttrKey::FLUDoseLevel]).c_str());
- }
- catch (const std::exception&)
- {
- }
- catch (const ResDataObjectExption&)
- {
- }
- try
- {
- t.nFLKV = atof(((string)R0[AttrKey::FLUKV]).c_str());
- }
- catch (const std::exception&)
- {
- }
- catch (const ResDataObjectExption&)
- {
- }
- try
- {
- t.fFLMA = atof(((string)R0[AttrKey::FLUMA]).c_str());
- }
- catch (const std::exception&)
- {
- }
- catch (const ResDataObjectExption&)
- {
- }
- try
- {
- t.nPPS = atoi(((string)R0[AttrKey::FLUPPS]).c_str());
- }
- catch (const std::exception&)
- {
- }
- catch (const ResDataObjectExption&)
- {
- }
- return SetAPF(t); });
- //透视间隔时间、累计时间
- Dispatch->Get.Push(AttrKey::FLUIntTime, [this](std::string& out) {
- out = to_string(GetFluIntTimer());
- return RET_STATUS::RET_SUCCEED; });
- Dispatch->Get.Push(AttrKey::FLUAccTime, [this](std::string& out) {
- out = to_string(GetFluAccTimer());
- return RET_STATUS::RET_SUCCEED; });
- Dispatch->Action.Push(ActionKey::ReSetFluTimer, [this](std::string in, std::string& out) {
- auto value = JSONTo <int>(in);
- return ResetFluTimer(value); });
- //脚闸状态
- Dispatch->Action.Push(ActionKey::SetValue_FluPre, [this](std::string in, std::string& out) {
- auto value = JSONTo <int>(in);
- return SetFluPre(value); });
- Dispatch->Action.Push(ActionKey::SetValue_FluEXP, [this](std::string in, std::string& out) {
- auto value = JSONTo <int>(in);
- return SetFluEXP(value); });
- //MAG
- Dispatch->Action.Push(ActionKey::SetValue_FluMAG, [this](std::string in, std::string& out) {
- auto value = JSONTo <int>(in);
- return SetFluMAG(value); });
- Dispatch->Action.Push(ActionKey::DisableMAG, [this](std::string in, std::string& out) {
- return DisableMAG(); });
-
- //Dose Level
- Dispatch->Action.Push(ActionKey::SetValue_FluDoseLever, [this](std::string in, std::string& out) {
- auto value = JSONTo <int>(in);
- return SetFluDoseLever(value); });
- //半价剂量
- Dispatch->Action.Push(ActionKey::SetValue_HalfDose, [this](std::string in, std::string& out) {
- auto value = JSONTo <int>(in);
- return SetHalfDose(value); });
- //点片曲线
- Dispatch->Action.Push(ActionKey::SetValue_RadCurve, [this](std::string in, std::string& out) {
- auto value = JSONTo <int>(in);
- return TransferRadCurve(value); });
- }
- //-----------------------------------------------------------------------------
- // 所有的消息响应函数
- //-----------------------------------------------------------------------------
- //add by wxx for task226:减少现有模块改造所以不写成纯虚
- RET_STATUS nsGEN::GeneratorMould::IncKVL()
- {
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::GeneratorMould::DecKVL()
- {
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::GeneratorMould::IncMAL()
- {
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::GeneratorMould::DecMAL()
- {
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::GeneratorMould::IncMSL()
- {
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::GeneratorMould::DecMSL()
- {
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::GeneratorMould::IncMASL()
- {
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::GeneratorMould::DecMASL()
- {
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::GeneratorMould::IncAECDensity()
- {
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::GeneratorMould::DecAECDensity()
- {
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::GeneratorMould::SetAPRArray(vector<_tAPRArgs>& APRarray)
- {
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::GeneratorMould::IncFluKV()
- {
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::GeneratorMould::DecFluKV()
- {
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::GeneratorMould::SetFluKV(float value)
- {
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::GeneratorMould::IncFluMA()
- {
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::GeneratorMould::DecFluMA()
- {
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::GeneratorMould::SetFluMA(float value)
- {
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::GeneratorMould::IncFluMS()
- {
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::GeneratorMould::DecFluMS()
- {
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::GeneratorMould::SetFluMS(float value)
- {
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::GeneratorMould::SetPPS(float frameRate)
- {
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::GeneratorMould::INCPPS()
- {
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::GeneratorMould::DECPPS()
- {
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::GeneratorMould::SetPluseWidth(float fplusewidth)
- {
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::GeneratorMould::SetABSMode(int nMode)
- {
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::GeneratorMould::SetABSCurve(int curveNum)
- {
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::GeneratorMould::IncABSCurve()
- {
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::GeneratorMould::DecABSCurve()
- {
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::GeneratorMould::SetABSValue(float fABSValue)
- {
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::GeneratorMould::SetABSTargetEXI(float fEXIValue)
- {
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::GeneratorMould::SetAPF(const _tAPFArgs& t)
- {
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::GeneratorMould::ResetFluTimer(int ntype)
- {
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::GeneratorMould::SetFluPre(int bPrepare)
- {
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::GeneratorMould::SetFluEXP(int bPrepare)
- {
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::GeneratorMould::SetFLFMode(std::string value)
- {
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::GeneratorMould::SetFluMAG(int nsize)
- {
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::GeneratorMould::DisableMAG()
- {
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::GeneratorMould::SetFluDoseLever(int nlever)
- {
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::GeneratorMould::SetHalfDose(int nlever)
- {
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::GeneratorMould::TransferRadCurve(int ncurve)
- {
- return RET_STATUS::RET_SUCCEED;
- }
- //-----------------------------------------------------------------------------
- // 所有的 GetXX 函数
- //-----------------------------------------------------------------------------
- float nsGEN::GeneratorMould::GetFluIntTimer() { if (m_DoseUnit.m_FLAccTime) return m_DoseUnit.m_FLAccTime->Get(); else return 0; }
- float nsGEN::GeneratorMould::GetFluAccTimer() { if (m_DoseUnit.m_FLIntTime) return m_DoseUnit.m_FLIntTime->Get(); else return 0; }
- //-----------------------------------------------------------------------------
- // 所有的 SetXX 函数
- //-----------------------------------------------------------------------------
- RET_STATUS nsGEN::GeneratorMould::SetGenCurrentSMState(const std::string value)
- {
- return RET_STATUS::RET_SUCCEED;
- }
- //-----------------------------------------------------------------------------
- // nsGEN::DriverMould
- //-----------------------------------------------------------------------------
- nsGEN::DriverMould::DriverMould ()
- {
- ConfigInfo GenVender (ConfKey::CcosGeneratorType, "string", "R", "TRUE", "");
- m_ConfigInfo.push_back(GenVender);
- ConfigInfo GenModel (ConfKey::CcosGeneratorModel, "string", "R", "TRUE", "");
- m_ConfigInfo.push_back(GenModel);
- ConfigInfo GenWSTable (ConfKey::CcosWSTable, "int", "RW", "TRUE", "");
- m_ConfigInfo.push_back(GenWSTable);
- ConfigInfo GenWSWall (ConfKey::CcosWSWall, "int", "RW", "TRUE", "");
- m_ConfigInfo.push_back(GenWSWall);
- ConfigInfo GenWSFree (ConfKey::CcosWSFree, "int", "RW", "TRUE", "");
- m_ConfigInfo.push_back(GenWSFree);
- ConfigInfo GenWSTomo (ConfKey::CcosWSTomo, "int", "RW", "TRUE", "");
- m_ConfigInfo.push_back(GenWSTomo);
- ConfigInfo GenWSConventional (ConfKey::CcosWSConventional, "int", "RW", "TRUE", "");
- m_ConfigInfo.push_back(GenWSConventional);
- EasyJSONEncoder synList;
- synList.Set ("0", "1");
- synList.Set ("1", "2");
- ConfigInfo GenSynTable (ConfKey::CcosSynTable, "int", "RW", "FALSE", "");
- GenSynTable.SetList (synList.ToString ().c_str ());
- m_ConfigInfo.push_back(GenSynTable);
- ConfigInfo GenSynWall (ConfKey::CcosSynWall, "int", "RW", "FALSE", "");
- GenSynWall.SetList (synList.ToString ().c_str ());
- m_ConfigInfo.push_back(GenSynWall);
- ConfigInfo GenSynFree (ConfKey::CcosSynFree, "int", "RW", "FALSE", "");
- GenSynFree.SetList (synList.ToString ().c_str ());
- m_ConfigInfo.push_back(GenSynFree);
- ConfigInfo GenSynTomo (ConfKey::CcosSynTomo, "int", "RW", "FALSE", "");
- GenSynTomo.SetList (synList.ToString ().c_str ());
- m_ConfigInfo.push_back(GenSynTomo);
- ConfigInfo GenSynConventional (ConfKey::CcosSynConventional, "int", "RW", "FALSE", "");
- GenSynConventional.SetList (synList.ToString ().c_str ());
- m_ConfigInfo.push_back(GenSynConventional);
- EasyJSONEncoder ConsoleRoleList;
- ConsoleRoleList.Set ("0", "1");
- ConsoleRoleList.Set ("1", "2");
- ConsoleRoleList.Set ("2", "3");
- ConfigInfo GenConsoleRole (ConfKey::CcosConsoleRole, "int", "RW", "FALSE", "");
- GenConsoleRole.SetList (ConsoleRoleList.ToString ().c_str ());
- m_ConfigInfo.push_back(GenConsoleRole);
- ConfigInfo GenIsConnect (ConfKey::CcosIsConnect, "int", "RW", "FALSE", "");
- GenIsConnect.SetList (synList.ToString ().c_str ());
- m_ConfigInfo.push_back(GenIsConnect);
- ConfigInfo GenSCFType (ConfKey::CcosSCFType, "string", "R", "TRUE", "");
- m_ConfigInfo.push_back(GenSCFType);
- EasyJSONEncoder COMList;
- COMList.Set ("0", "COM1");
- COMList.Set ("1", "COM2");
- COMList.Set ("2", "COM3");
- COMList.Set ("3", "COM4");
- COMList.Set ("4", "COM5");
- COMList.Set ("5", "COM6");
- COMList.Set ("6", "COM7");
- COMList.Set ("7", "COM8");
- COMList.Set ("8", "COM9");
- COMList.Set ("9", "COM10");
- COMList.Set ("10", "COM11");
- COMList.Set ("11", "COM12");
- ConfigInfo GenSCFPort (ConfKey::CcosSCFPort, "string", "RW", "TRUE", "");
- GenSCFPort.SetList (COMList.ToString ().c_str ());
- m_ConfigInfo.push_back(GenSCFPort);
- ConfigInfo GenSCFBaudrate (ConfKey::CcosSCFBaudrate, "int", "R", "FALSE", "");
- m_ConfigInfo.push_back(GenSCFBaudrate);
- ConfigInfo GenSCFBytesize (ConfKey::CcosSCFBytesize, "int", "R", "FALSE", "");
- m_ConfigInfo.push_back(GenSCFBytesize);
- ConfigInfo GenSCFParity (ConfKey::CcosSCFParity, "int", "R", "FALSE", "");
- m_ConfigInfo.push_back(GenSCFParity);
- ConfigInfo GenSCFStopbits (ConfKey::CcosSCFStopbits, "int", "R", "FALSE", "");
- m_ConfigInfo.push_back(GenSCFStopbits);
- }
- nsGEN::DriverMould::~DriverMould ()
- {
- }
- std::string nsGEN::DriverMould::GetGUID () const
- {
- return GeneratorDriverType;
- }
- static const auto COM_SCFDllName = "libSerialSCF.so";
- static const auto TCP_SCFDllName = "libTcpipSCF.so";
- string CCOS::Dev::Detail::Generator::DriverMould::GetConnectDLL(string& ConfigFileName)
- {
- std::cout << "DriverMould::GetConnectDLL IN " << std::endl;
- std::cout << "COM_SCFDllName: " << COM_SCFDllName << " TCP_SCFDllName: " << TCP_SCFDllName << std::endl;
- string ConnectDLL = COM_SCFDllName;
- ResDataObject r_config, Connection;
- if (!r_config.loadFile(ConfigFileName.c_str()))
- return ConnectDLL;
- if (r_config["CONFIGURATION"]["connections"].GetKeyCount("Value") > 0)
- {
- Connection = r_config["CONFIGURATION"]["connections"]["Value"];
- }
- else
- {
- Connection = r_config["CONFIGURATION"]["connections"][0];
- }
- if ((string)Connection["type"] == "COM")
- ConnectDLL = COM_SCFDllName;
- else
- ConnectDLL = TCP_SCFDllName;
- return ConnectDLL;
- }
- ResDataObject nsGEN::DriverMould::GetConnectParam(string& ConfigFileName)
- {
- std::cout << "DriverMould::GetConnectParam IN " << std::endl;
- ResDataObject r_config, Connection;
- // 检查文件是否存在
- std::ifstream file(ConfigFileName);
- if (!file) {
- // 文件不存在,直接返回空的Connection对象
- //mLog::Info("file does not exist");
- return Connection;
- }
- if (!r_config.loadFile(ConfigFileName.c_str()))
- return Connection;
- if (r_config["CONFIGURATION"]["connections"].GetKeyCount("Value") > 0)
- {
- Connection = r_config["CONFIGURATION"]["connections"]["Value"];
- }
- else
- {
- Connection = r_config["CONFIGURATION"]["connections"][0];
- }
- return Connection;
- }
|