Compare commits

...

2 Commits

Author SHA1 Message Date
3fe2d4aa0e 修复了质量模型中的错误 2025-06-04 15:26:50 +08:00
b2e5036b2c 修复无法调取数据包模型的问题 2025-06-04 14:00:46 +08:00
14 changed files with 87 additions and 18 deletions

1
.gitignore vendored
View File

@ -38,3 +38,4 @@ build/
#log
log/
logs/
Packages/

View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<Model>
<Name>XNGroundHandling</Name>
<Description>ATA04地面操纵模型</Description>
<Author>Jin</Author>
<Version>1.0.0</Version>
<CreateTime>2025-02-19 16:22:17</CreateTime>
<ChangeTime>2025-02-19 16:22:19</ChangeTime>
<Node>0-0</Node>
<Priority>99</Priority>
<MathLib>ATA04_SACSCGroundHandling_2.0.143.1H_20250506/libSACSCGroundHandling.so.2.0.143.1H</MathLib>
<CommandList/>
</Model>

Binary file not shown.

Binary file not shown.

View File

@ -169,6 +169,18 @@ public:
*/
void SetSetFreq(double setFreq);
/**
* @brief
* @return const std::string&:
*/
const std::string &GetLibPath();
/**
* @brief
* @param sLibPath: std::string类型
*/
void SetLibPath(const std::string &sLibPath);
/**
* @brief
* @details

View File

@ -78,6 +78,8 @@ void XNModelManager::LoadModel(const std::string &modelPath, const std::string &
model->SetFramework(GetFramework());
model->SetInitializeType(initialType);
model->SetThreadID(threadID);
std::string workPath = GetFramework()->GetWorkPath() + "/Packages/";
model->SetLibPath(workPath);
if (initialType == 0) {
// 使用std::filesystem处理路径
std::filesystem::path configPath =

View File

@ -192,6 +192,18 @@ void XNModelObject::SetSetFreq(double setFreq)
d->_setFreq = setFreq;
}
const std::string &XNModelObject::GetLibPath()
{
T_D();
return d->_sLibPath;
}
void XNModelObject::SetLibPath(const std::string &sLibPath)
{
T_D();
d->_sLibPath = sLibPath;
}
// 初始化函数
void XNModelObject::Initialize()
{
@ -378,19 +390,16 @@ void XNModelObject::ParseConfig()
std::string mathlib = XNSim::getStringFromSqlite3(stmt, 13);
if (mathlib.length() > 0) {
// 使用标准C++文件路径处理
std::filesystem::path xmlPath(GetXmlPath());
d->_sLibPath = xmlPath.parent_path().string() + "/" + mathlib;
//std::filesystem::path xmlPath(GetXmlPath());
//d->_sLibPath = xmlPath.parent_path().string() + "/" + mathlib;
std::string libPath = d->_sLibPath + "/" + mathlib;
// 使用标准C++动态库加载
d->_dynamicLib = dlopen(d->_sLibPath.c_str(), RTLD_LAZY);
d->_dynamicLib = dlopen(libPath.c_str(), RTLD_LAZY);
if (d->_dynamicLib) { // 动态库加载成功
LOG_INFO("0x2163 Model %1 loaded algorithm dynamic library %2 successfully!",
GetObjectName(), d->_sLibPath);
LOG_INFO("0x2163 模型 %1 加载数据包模型动态库 %2 成功!", GetObjectName(), libPath);
} else {
LOG_WARNING(
"0x2160 Model %1 failed to find algorithm dynamic library %2, will not call "
"algorithm!",
GetObjectName(), d->_sLibPath);
LOG_WARNING("0x2160 模型 %1 未找到数据包模型动态库 %2, 将不调用数据包模型!",
GetObjectName(), libPath);
d->_dynamicLib = nullptr;
}
}

View File

@ -169,6 +169,18 @@ public:
*/
void SetSetFreq(double setFreq);
/**
* @brief
* @return const std::string&:
*/
const std::string &GetLibPath();
/**
* @brief
* @param sLibPath: std::string类型
*/
void SetLibPath(const std::string &sLibPath);
/**
* @brief
* @details

View File

@ -124,7 +124,7 @@ bool XNScenarioManager::ParseScenarioXml(const std::string &XmlPath)
std::string libName = service->Attribute("ClassName");
std::string serviceVersion = service->Attribute("Version");
libName = XNSim::getFileNameWithoutExt(libName);
std::string dynamicLibName = servicePath + "lib" + libName + ".so." + serviceVersion;
std::string dynamicLibName = servicePath + "/lib" + libName + ".so." + serviceVersion;
// 加载动态库
GetFramework()->GetServiceManager()->LoadService(dynamicLibName, libName,
serviceVersion, 0);
@ -177,7 +177,7 @@ bool XNScenarioManager::ParseScenarioXml(const std::string &XmlPath)
std::string libName = model->Attribute("ClassName");
std::string modelVersion = model->Attribute("Version");
libName = XNSim::getFileNameWithoutExt(libName);
std::string dynamicLibName = modelPath + "lib" + libName + ".so." + modelVersion;
std::string dynamicLibName = modelPath + "/lib" + libName + ".so." + modelVersion;
// 加载动态库
GetFramework()->GetModelManager()->LoadModel(dynamicLibName, libName, modelVersion,
planeName, 0, threadID);
@ -195,12 +195,12 @@ bool XNScenarioManager::ParseConfig(const std::string &ConfigID)
{
T_D();
// 获取数据库路径
std::string dbPath = std::getenv("XNCore");
if (dbPath.empty()) {
std::string XNCorePath = std::getenv("XNCore");
if (XNCorePath.empty()) {
LOG_ERROR("0x1015 未设置XNCore环境变量, 引擎将退出!");
return false;
}
dbPath += "/database/XNSim.db";
std::string dbPath = XNCorePath + "/database/XNSim.db";
// 打开数据库
sqlite3 *db;
@ -239,15 +239,31 @@ bool XNScenarioManager::ParseConfig(const std::string &ConfigID)
std::string version = XNSim::getStringFromSqlite3(stmt, 4);
std::string kernel = XNSim::getStringFromSqlite3(stmt, 5);
std::string rootPath = XNSim::getStringFromSqlite3(stmt, 7);
if (rootPath.empty()) {
LOG_WARNING("0x1020 未设置工作目录,使用默认工作目录: %1", XNCorePath);
rootPath = XNCorePath;
}
GetFramework()->SetWorkPath(rootPath);
// 设置模型库目录
std::string modelPath = rootPath + XNSim::getStringFromSqlite3(stmt, 8);
if (modelPath.empty()) {
LOG_WARNING("0x1020 未设置模型库目录,使用默认模型库目录: %1/Models", XNCorePath);
modelPath = XNCorePath + "/Models";
}
GetFramework()->SetModelPath(modelPath);
// 设置服务库目录
std::string servicePath = rootPath + XNSim::getStringFromSqlite3(stmt, 9);
if (servicePath.empty()) {
LOG_WARNING("0x1020 未设置服务库目录,使用默认服务库目录: %1/Services", XNCorePath);
servicePath = XNCorePath + "/Services";
}
GetFramework()->SetServicePath(servicePath);
// 设置域ID
uint32_t domainID = std::stoul(XNSim::getStringFromSqlite3(stmt, 10));
if (domainID == 0 || domainID > 225) {
LOG_WARNING("0x1020 域ID设置错误使用默认域ID: 10");
domainID = 10;
}
GetFramework()->GetDDSManager()->SetDomainID(domainID);
// 读取CPU亲和性
std::string cpuAff = XNSim::getStringFromSqlite3(stmt, 6);
@ -279,7 +295,7 @@ bool XNScenarioManager::ParseConfig(const std::string &ConfigID)
std::string ServiceName = XNSim::getStringFromSqlite3(servicesStmt, 3);
ClassName = XNSim::getFileNameWithoutExt(ClassName);
std::string dynamicLibName = servicePath + "lib" + ClassName + ".so." + ServiceVersion;
std::string dynamicLibName = servicePath + "/lib" + ClassName + ".so." + ServiceVersion;
// 加载动态库
GetFramework()->GetServiceManager()->LoadService(dynamicLibName, ClassName, ServiceVersion,
1);
@ -373,7 +389,7 @@ bool XNScenarioManager::ParseConfig(const std::string &ConfigID)
std::string ModelName = XNSim::getStringFromSqlite3(modelsStmt, 3);
ClassName = XNSim::getFileNameWithoutExt(ClassName);
std::string dynamicLibName = modelPath + "lib" + ClassName + ".so." + ModelVersion;
std::string dynamicLibName = modelPath + "/lib" + ClassName + ".so." + ModelVersion;
// 加载动态库
LOG_INFO("0x1021 加载模型: %1", dynamicLibName);
GetFramework()->GetModelManager()->LoadModel(dynamicLibName, ClassName, ModelVersion,

View File

@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16)
project(XNGroundHandling LANGUAGES CXX)
set(MODEL_VERSION "1.0.0.0")
set(MODEL_VERSION "2.0.143.1")
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

View File

@ -49,6 +49,10 @@ void XNWeightBalance::PrepareForExecute()
{
T_D();
XNModelObject::PrepareForExecute();
InitializeData();
d->_inputInterface.Initialize(GetFramework(), GetUniqueId(), 1);
d->_outputInterface.Initialize(GetFramework(), GetUniqueId(), 2);
d->_heartbeatInterface.Initialize(GetFramework(), GetUniqueId(), 2);
}
void XNWeightBalance::StepUpdate()