Compare commits
2 Commits
fefd229495
...
3fe2d4aa0e
Author | SHA1 | Date | |
---|---|---|---|
3fe2d4aa0e | |||
b2e5036b2c |
1
.gitignore
vendored
1
.gitignore
vendored
@ -38,3 +38,4 @@ build/
|
|||||||
#log
|
#log
|
||||||
log/
|
log/
|
||||||
logs/
|
logs/
|
||||||
|
Packages/
|
||||||
|
13
Release/Models/XNGroundHandling_V2.0.143.1.mcfg
Normal file
13
Release/Models/XNGroundHandling_V2.0.143.1.mcfg
Normal 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.
BIN
Release/Models/libXNGroundHandling.so.2.0.143.1
Normal file
BIN
Release/Models/libXNGroundHandling.so.2.0.143.1
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -169,6 +169,18 @@ public:
|
|||||||
*/
|
*/
|
||||||
void SetSetFreq(double setFreq);
|
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 单步执行函数
|
* @brief 单步执行函数
|
||||||
* @details 模型默认的周期性执行函数
|
* @details 模型默认的周期性执行函数
|
||||||
|
@ -78,6 +78,8 @@ void XNModelManager::LoadModel(const std::string &modelPath, const std::string &
|
|||||||
model->SetFramework(GetFramework());
|
model->SetFramework(GetFramework());
|
||||||
model->SetInitializeType(initialType);
|
model->SetInitializeType(initialType);
|
||||||
model->SetThreadID(threadID);
|
model->SetThreadID(threadID);
|
||||||
|
std::string workPath = GetFramework()->GetWorkPath() + "/Packages/";
|
||||||
|
model->SetLibPath(workPath);
|
||||||
if (initialType == 0) {
|
if (initialType == 0) {
|
||||||
// 使用std::filesystem处理路径
|
// 使用std::filesystem处理路径
|
||||||
std::filesystem::path configPath =
|
std::filesystem::path configPath =
|
||||||
|
@ -192,6 +192,18 @@ void XNModelObject::SetSetFreq(double setFreq)
|
|||||||
d->_setFreq = 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()
|
void XNModelObject::Initialize()
|
||||||
{
|
{
|
||||||
@ -378,19 +390,16 @@ void XNModelObject::ParseConfig()
|
|||||||
std::string mathlib = XNSim::getStringFromSqlite3(stmt, 13);
|
std::string mathlib = XNSim::getStringFromSqlite3(stmt, 13);
|
||||||
if (mathlib.length() > 0) {
|
if (mathlib.length() > 0) {
|
||||||
// 使用标准C++文件路径处理
|
// 使用标准C++文件路径处理
|
||||||
std::filesystem::path xmlPath(GetXmlPath());
|
//std::filesystem::path xmlPath(GetXmlPath());
|
||||||
d->_sLibPath = xmlPath.parent_path().string() + "/" + mathlib;
|
//d->_sLibPath = xmlPath.parent_path().string() + "/" + mathlib;
|
||||||
|
std::string libPath = d->_sLibPath + "/" + mathlib;
|
||||||
// 使用标准C++动态库加载
|
// 使用标准C++动态库加载
|
||||||
d->_dynamicLib = dlopen(d->_sLibPath.c_str(), RTLD_LAZY);
|
d->_dynamicLib = dlopen(libPath.c_str(), RTLD_LAZY);
|
||||||
if (d->_dynamicLib) { // 动态库加载成功
|
if (d->_dynamicLib) { // 动态库加载成功
|
||||||
LOG_INFO("0x2163 Model %1 loaded algorithm dynamic library %2 successfully!",
|
LOG_INFO("0x2163 模型 %1 加载数据包模型动态库 %2 成功!", GetObjectName(), libPath);
|
||||||
GetObjectName(), d->_sLibPath);
|
|
||||||
} else {
|
} else {
|
||||||
LOG_WARNING(
|
LOG_WARNING("0x2160 模型 %1 未找到数据包模型动态库 %2, 将不调用数据包模型!",
|
||||||
"0x2160 Model %1 failed to find algorithm dynamic library %2, will not call "
|
GetObjectName(), libPath);
|
||||||
"algorithm!",
|
|
||||||
GetObjectName(), d->_sLibPath);
|
|
||||||
d->_dynamicLib = nullptr;
|
d->_dynamicLib = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -169,6 +169,18 @@ public:
|
|||||||
*/
|
*/
|
||||||
void SetSetFreq(double setFreq);
|
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 单步执行函数
|
* @brief 单步执行函数
|
||||||
* @details 模型默认的周期性执行函数
|
* @details 模型默认的周期性执行函数
|
||||||
|
@ -124,7 +124,7 @@ bool XNScenarioManager::ParseScenarioXml(const std::string &XmlPath)
|
|||||||
std::string libName = service->Attribute("ClassName");
|
std::string libName = service->Attribute("ClassName");
|
||||||
std::string serviceVersion = service->Attribute("Version");
|
std::string serviceVersion = service->Attribute("Version");
|
||||||
libName = XNSim::getFileNameWithoutExt(libName);
|
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,
|
GetFramework()->GetServiceManager()->LoadService(dynamicLibName, libName,
|
||||||
serviceVersion, 0);
|
serviceVersion, 0);
|
||||||
@ -177,7 +177,7 @@ bool XNScenarioManager::ParseScenarioXml(const std::string &XmlPath)
|
|||||||
std::string libName = model->Attribute("ClassName");
|
std::string libName = model->Attribute("ClassName");
|
||||||
std::string modelVersion = model->Attribute("Version");
|
std::string modelVersion = model->Attribute("Version");
|
||||||
libName = XNSim::getFileNameWithoutExt(libName);
|
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,
|
GetFramework()->GetModelManager()->LoadModel(dynamicLibName, libName, modelVersion,
|
||||||
planeName, 0, threadID);
|
planeName, 0, threadID);
|
||||||
@ -195,12 +195,12 @@ bool XNScenarioManager::ParseConfig(const std::string &ConfigID)
|
|||||||
{
|
{
|
||||||
T_D();
|
T_D();
|
||||||
// 获取数据库路径
|
// 获取数据库路径
|
||||||
std::string dbPath = std::getenv("XNCore");
|
std::string XNCorePath = std::getenv("XNCore");
|
||||||
if (dbPath.empty()) {
|
if (XNCorePath.empty()) {
|
||||||
LOG_ERROR("0x1015 未设置XNCore环境变量, 引擎将退出!");
|
LOG_ERROR("0x1015 未设置XNCore环境变量, 引擎将退出!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
dbPath += "/database/XNSim.db";
|
std::string dbPath = XNCorePath + "/database/XNSim.db";
|
||||||
|
|
||||||
// 打开数据库
|
// 打开数据库
|
||||||
sqlite3 *db;
|
sqlite3 *db;
|
||||||
@ -239,15 +239,31 @@ bool XNScenarioManager::ParseConfig(const std::string &ConfigID)
|
|||||||
std::string version = XNSim::getStringFromSqlite3(stmt, 4);
|
std::string version = XNSim::getStringFromSqlite3(stmt, 4);
|
||||||
std::string kernel = XNSim::getStringFromSqlite3(stmt, 5);
|
std::string kernel = XNSim::getStringFromSqlite3(stmt, 5);
|
||||||
std::string rootPath = XNSim::getStringFromSqlite3(stmt, 7);
|
std::string rootPath = XNSim::getStringFromSqlite3(stmt, 7);
|
||||||
|
if (rootPath.empty()) {
|
||||||
|
LOG_WARNING("0x1020 未设置工作目录,使用默认工作目录: %1", XNCorePath);
|
||||||
|
rootPath = XNCorePath;
|
||||||
|
}
|
||||||
GetFramework()->SetWorkPath(rootPath);
|
GetFramework()->SetWorkPath(rootPath);
|
||||||
// 设置模型库目录
|
// 设置模型库目录
|
||||||
std::string modelPath = rootPath + XNSim::getStringFromSqlite3(stmt, 8);
|
std::string modelPath = rootPath + XNSim::getStringFromSqlite3(stmt, 8);
|
||||||
|
if (modelPath.empty()) {
|
||||||
|
LOG_WARNING("0x1020 未设置模型库目录,使用默认模型库目录: %1/Models", XNCorePath);
|
||||||
|
modelPath = XNCorePath + "/Models";
|
||||||
|
}
|
||||||
GetFramework()->SetModelPath(modelPath);
|
GetFramework()->SetModelPath(modelPath);
|
||||||
// 设置服务库目录
|
// 设置服务库目录
|
||||||
std::string servicePath = rootPath + XNSim::getStringFromSqlite3(stmt, 9);
|
std::string servicePath = rootPath + XNSim::getStringFromSqlite3(stmt, 9);
|
||||||
|
if (servicePath.empty()) {
|
||||||
|
LOG_WARNING("0x1020 未设置服务库目录,使用默认服务库目录: %1/Services", XNCorePath);
|
||||||
|
servicePath = XNCorePath + "/Services";
|
||||||
|
}
|
||||||
GetFramework()->SetServicePath(servicePath);
|
GetFramework()->SetServicePath(servicePath);
|
||||||
// 设置域ID
|
// 设置域ID
|
||||||
uint32_t domainID = std::stoul(XNSim::getStringFromSqlite3(stmt, 10));
|
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);
|
GetFramework()->GetDDSManager()->SetDomainID(domainID);
|
||||||
// 读取CPU亲和性
|
// 读取CPU亲和性
|
||||||
std::string cpuAff = XNSim::getStringFromSqlite3(stmt, 6);
|
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);
|
std::string ServiceName = XNSim::getStringFromSqlite3(servicesStmt, 3);
|
||||||
|
|
||||||
ClassName = XNSim::getFileNameWithoutExt(ClassName);
|
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,
|
GetFramework()->GetServiceManager()->LoadService(dynamicLibName, ClassName, ServiceVersion,
|
||||||
1);
|
1);
|
||||||
@ -373,7 +389,7 @@ bool XNScenarioManager::ParseConfig(const std::string &ConfigID)
|
|||||||
std::string ModelName = XNSim::getStringFromSqlite3(modelsStmt, 3);
|
std::string ModelName = XNSim::getStringFromSqlite3(modelsStmt, 3);
|
||||||
|
|
||||||
ClassName = XNSim::getFileNameWithoutExt(ClassName);
|
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);
|
LOG_INFO("0x1021 加载模型: %1", dynamicLibName);
|
||||||
GetFramework()->GetModelManager()->LoadModel(dynamicLibName, ClassName, ModelVersion,
|
GetFramework()->GetModelManager()->LoadModel(dynamicLibName, ClassName, ModelVersion,
|
||||||
|
@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16)
|
|||||||
|
|
||||||
project(XNGroundHandling LANGUAGES CXX)
|
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 17)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
@ -49,6 +49,10 @@ void XNWeightBalance::PrepareForExecute()
|
|||||||
{
|
{
|
||||||
T_D();
|
T_D();
|
||||||
XNModelObject::PrepareForExecute();
|
XNModelObject::PrepareForExecute();
|
||||||
|
InitializeData();
|
||||||
|
d->_inputInterface.Initialize(GetFramework(), GetUniqueId(), 1);
|
||||||
|
d->_outputInterface.Initialize(GetFramework(), GetUniqueId(), 2);
|
||||||
|
d->_heartbeatInterface.Initialize(GetFramework(), GetUniqueId(), 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void XNWeightBalance::StepUpdate()
|
void XNWeightBalance::StepUpdate()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user