// #include #include #include // PATH_MAX #include // readlink #include #include #include #include #include #include #include #include "Helper.JSON.hpp" #include "CCOS.Dev.Generator.Mould.hpp" #include "EasyJSONEncoder.hpp" #include "ResDataObject.h" #include 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 //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(map); ElfW(Shdr)* shdrs = reinterpret_cast((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((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(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 (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 (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 (in); return SetAECDensity(value); }); Dispatch->Action.Push(ActionKey::SetValue_AECDENSITY, [this](std::string in, std::string& out) { auto value = JSONTo (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 (in); return SetAECField(value); }); Dispatch->Action.Push(ActionKey::SetValue_AECFIELD, [this](std::string in, std::string& out) { auto value = JSONTo (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 (in); return SetAECFilm(value); }); Dispatch->Action.Push(ActionKey::SetValue_AECFILM, [this](std::string in, std::string& out) { auto value = JSONTo (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 (in); return SetGenSynState(value); }); Dispatch->Action.Push(ActionKey::SetGeneratortoSyncStatus, [this](std::string in, std::string& out) { auto value = JSONTo (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 (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 (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 (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 (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 (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 (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 (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 (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 (in); return SetFocus(value); }); Dispatch->Action.Push(ActionKey::SetValue_FOCUS, [this](std::string in, std::string& out) { auto value = JSONTo (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 (in); return SetTechmode(value); }); Dispatch->Action.Push(ActionKey::SetValue_TECHMODE, [this](std::string in, std::string& out) { auto value = JSONTo (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 (in); return SetFrameRate(value); }); Dispatch->Action.Push(ActionKey::SetFrameRate, [this](std::string in, std::string& out) { auto value = JSONTo (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 (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 (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 (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 (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 (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 (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 (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 (in); return SetPPS(value); }); //脉冲脉宽 Dispatch->Set.Push(AttrKey::FLUpulseWidth, [this](std::string in) { auto value = JSONTo (in); return SetPluseWidth(value); }); Dispatch->Action.Push(ActionKey::SetValue_PluseWidth, [this](std::string in, std::string& out) { auto value = JSONTo (in); return SetPluseWidth(value); }); //ABS模式 Dispatch->Set.Push(AttrKey::FLUABSStatus, [this](std::string in) { auto value = JSONTo (in); return SetABSMode(value); }); Dispatch->Action.Push(ActionKey::SetValue_ABSMode, [this](std::string in, std::string& out) { auto value = JSONTo (in); return SetABSMode(value); }); //ABS曲线 Dispatch->Set.Push(AttrKey::FLUCurve, [this](std::string in) { auto value = JSONTo (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 (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 (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 (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 (in); return ResetFluTimer(value); }); //脚闸状态 Dispatch->Action.Push(ActionKey::SetValue_FluPre, [this](std::string in, std::string& out) { auto value = JSONTo (in); return SetFluPre(value); }); Dispatch->Action.Push(ActionKey::SetValue_FluEXP, [this](std::string in, std::string& out) { auto value = JSONTo (in); return SetFluEXP(value); }); //MAG Dispatch->Action.Push(ActionKey::SetValue_FluMAG, [this](std::string in, std::string& out) { auto value = JSONTo (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 (in); return SetFluDoseLever(value); }); //半价剂量 Dispatch->Action.Push(ActionKey::SetValue_HalfDose, [this](std::string in, std::string& out) { auto value = JSONTo (in); return SetHalfDose(value); }); //点片曲线 Dispatch->Action.Push(ActionKey::SetValue_RadCurve, [this](std::string in, std::string& out) { auto value = JSONTo (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; }