12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559 |
- //
- #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()
- {
- char szFilename[PATH_MAX] = { 0 };
- // 读取当前进程可执行文件的路径
- ssize_t res = readlink("/proc/self/exe", szFilename, PATH_MAX - 1);
- if (res <= 0 || res >= PATH_MAX - 1) {
- std::cerr << "获取进程路径失败,readlink返回值: " << res << std::endl;
- return "";
- }
- szFilename[res] = '\0'; // 确保字符串终止
- std::string fullpath = szFilename;
- // Linux使用正斜杠'/'作为路径分隔符,而非反斜杠'\'
- std::string::size_type lastSlash = fullpath.find_last_of('/');
- if (lastSlash == std::string::npos) {
- // 没有找到路径分隔符,返回空
- return "";
- }
- // 截取到最后一个斜杠之前的部分,即进程所在目录
- return fullpath.substr(0, lastSlash);
- }
- // 获取 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::PrepareAcquisition, [this](std::string in, std::string& out) {
- return PrepareAcquisition(); });
- //同步模式
- 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;
- }
|