V0.33.1.250623_alpha:修改XNCore和XNEngine适配数据库的修改
This commit is contained in:
parent
884b0a52ac
commit
63442f0e27
Binary file not shown.
@ -362,18 +362,18 @@ void XNModelObject::ParseConfig()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
d->_sDescription = XNSim::getStringFromSqlite3(stmt, 7);
|
d->_sDescription = XNSim::getStringFromSqlite3(stmt, 6);
|
||||||
d->_sAuthor = XNSim::getStringFromSqlite3(stmt, 6);
|
d->_sAuthor = XNSim::getStringFromSqlite3(stmt, 5);
|
||||||
d->_sVersion = XNSim::getStringFromSqlite3(stmt, 2);
|
d->_sVersion = XNSim::getStringFromSqlite3(stmt, 2);
|
||||||
|
|
||||||
// 解析时间
|
// 解析时间
|
||||||
std::string createTimeStr = XNSim::getStringFromSqlite3(stmt, 8);
|
std::string createTimeStr = XNSim::getStringFromSqlite3(stmt, 7);
|
||||||
std::string changeTimeStr = XNSim::getStringFromSqlite3(stmt, 9);
|
std::string changeTimeStr = XNSim::getStringFromSqlite3(stmt, 8);
|
||||||
d->_cCreatTime = XNSim::parseISOTime(createTimeStr);
|
d->_cCreatTime = XNSim::parseISOTime(createTimeStr);
|
||||||
d->_cChangeTime = XNSim::parseISOTime(changeTimeStr);
|
d->_cChangeTime = XNSim::parseISOTime(changeTimeStr);
|
||||||
d->_runFreq = XNSim::safe_stoi(XNSim::getStringFromSqlite3(stmt, 10));
|
d->_runFreq = XNSim::safe_stoi(XNSim::getStringFromSqlite3(stmt, 9));
|
||||||
d->_runNode = XNSim::safe_stoi(XNSim::getStringFromSqlite3(stmt, 11));
|
d->_runNode = XNSim::safe_stoi(XNSim::getStringFromSqlite3(stmt, 10));
|
||||||
d->_runPriority = XNSim::safe_stoi(XNSim::getStringFromSqlite3(stmt, 12));
|
d->_runPriority = XNSim::safe_stoi(XNSim::getStringFromSqlite3(stmt, 11));
|
||||||
|
|
||||||
// 注册周期性函数
|
// 注册周期性函数
|
||||||
auto framework = GetFramework();
|
auto framework = GetFramework();
|
||||||
@ -387,11 +387,11 @@ void XNModelObject::ParseConfig()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 加载动态库
|
// 加载动态库
|
||||||
std::string mathlib = XNSim::getStringFromSqlite3(stmt, 13);
|
std::string mathlibPath = XNSim::getStringFromSqlite3(stmt, 12);
|
||||||
|
std::string mathlibName = XNSim::getStringFromSqlite3(stmt, 13);
|
||||||
|
std::string mathlib = mathlibPath + "/" + mathlibName;
|
||||||
if (mathlib.length() > 0) {
|
if (mathlib.length() > 0) {
|
||||||
// 使用标准C++文件路径处理
|
// 使用标准C++文件路径处理
|
||||||
//std::filesystem::path xmlPath(GetXmlPath());
|
|
||||||
//d->_sLibPath = xmlPath.parent_path().string() + "/" + mathlib;
|
|
||||||
std::string libPath = d->_sLibPath + "/" + mathlib;
|
std::string libPath = d->_sLibPath + "/" + mathlib;
|
||||||
// 使用标准C++动态库加载
|
// 使用标准C++动态库加载
|
||||||
d->_dynamicLib = dlopen(libPath.c_str(), RTLD_LAZY);
|
d->_dynamicLib = dlopen(libPath.c_str(), RTLD_LAZY);
|
||||||
|
@ -235,31 +235,20 @@ bool XNScenarioManager::ParseConfig(const std::string &ConfigID)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
std::string planeName = XNSim::getStringFromSqlite3(stmt, 1);
|
std::string planeName = XNSim::getStringFromSqlite3(stmt, 1);
|
||||||
|
std::string confName = XNSim::getStringFromSqlite3(stmt, 2);
|
||||||
std::string osName = XNSim::getStringFromSqlite3(stmt, 3);
|
std::string osName = XNSim::getStringFromSqlite3(stmt, 3);
|
||||||
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 = XNCorePath + "/Configuration/" + confName;
|
||||||
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 + "/Models";
|
||||||
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 + "/Services";
|
||||||
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, 7));
|
||||||
if (domainID == 0 || domainID > 225) {
|
if (domainID == 0 || domainID > 225) {
|
||||||
LOG_WARNING("0x1020 域ID设置错误,使用默认域ID: 10");
|
LOG_WARNING("0x1020 域ID设置错误,使用默认域ID: 10");
|
||||||
domainID = 10;
|
domainID = 10;
|
||||||
|
@ -238,18 +238,18 @@ void XNServiceObject::ParseConfig()
|
|||||||
sqlite3_close(db);
|
sqlite3_close(db);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
d->_sDescription = XNSim::getStringFromSqlite3(stmt, 5);
|
d->_sDescription = XNSim::getStringFromSqlite3(stmt, 4);
|
||||||
d->_sAuthor = XNSim::getStringFromSqlite3(stmt, 4);
|
d->_sAuthor = XNSim::getStringFromSqlite3(stmt, 3);
|
||||||
d->_sVersion = XNSim::getStringFromSqlite3(stmt, 2);
|
d->_sVersion = XNSim::getStringFromSqlite3(stmt, 2);
|
||||||
|
|
||||||
// 解析时间
|
// 解析时间
|
||||||
std::string createTimeStr = XNSim::getStringFromSqlite3(stmt, 6);
|
std::string createTimeStr = XNSim::getStringFromSqlite3(stmt, 5);
|
||||||
std::string changeTimeStr = XNSim::getStringFromSqlite3(stmt, 7);
|
std::string changeTimeStr = XNSim::getStringFromSqlite3(stmt, 6);
|
||||||
d->_cCreateTime = XNSim::parseISOTime(createTimeStr);
|
d->_cCreateTime = XNSim::parseISOTime(createTimeStr);
|
||||||
d->_cChangeTime = XNSim::parseISOTime(changeTimeStr);
|
d->_cChangeTime = XNSim::parseISOTime(changeTimeStr);
|
||||||
|
|
||||||
// 读取服务命令列表
|
// 读取服务命令列表
|
||||||
std::string commandListStr = XNSim::getStringFromSqlite3(stmt, 8);
|
std::string commandListStr = XNSim::getStringFromSqlite3(stmt, 7);
|
||||||
if (!commandListStr.empty()) {
|
if (!commandListStr.empty()) {
|
||||||
try {
|
try {
|
||||||
XN_JSON commandList = XN_JSON::parse(commandListStr);
|
XN_JSON commandList = XN_JSON::parse(commandListStr);
|
||||||
@ -273,7 +273,7 @@ void XNServiceObject::ParseConfig()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 读取其他参数
|
// 读取其他参数
|
||||||
std::string otherParamsStr = XNSim::getStringFromSqlite3(stmt, 9);
|
std::string otherParamsStr = XNSim::getStringFromSqlite3(stmt, 8);
|
||||||
if (!otherParamsStr.empty()) {
|
if (!otherParamsStr.empty()) {
|
||||||
try {
|
try {
|
||||||
d->_otherParams = XN_JSON::parse(otherParamsStr);
|
d->_otherParams = XN_JSON::parse(otherParamsStr);
|
||||||
|
@ -585,17 +585,17 @@ bool XNEngine::ParseDataBase(const std::string &ConfigId)
|
|||||||
return sqlite3_column_int(stmt, column) != 0;
|
return sqlite3_column_int(stmt, column) != 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool isDebug = readBoolean(stmt, 11);
|
bool isDebug = readBoolean(stmt, 8);
|
||||||
bool isInfo = readBoolean(stmt, 12);
|
bool isInfo = readBoolean(stmt, 9);
|
||||||
bool isWarn = readBoolean(stmt, 13);
|
bool isWarn = readBoolean(stmt, 10);
|
||||||
bool isError = readBoolean(stmt, 14);
|
bool isError = readBoolean(stmt, 11);
|
||||||
|
|
||||||
SetConsoleOutput(isDebug, isInfo, isWarn, isError);
|
SetConsoleOutput(isDebug, isInfo, isWarn, isError);
|
||||||
|
|
||||||
isDebug = readBoolean(stmt, 15);
|
isDebug = readBoolean(stmt, 12);
|
||||||
isInfo = readBoolean(stmt, 16);
|
isInfo = readBoolean(stmt, 13);
|
||||||
isWarn = readBoolean(stmt, 17);
|
isWarn = readBoolean(stmt, 14);
|
||||||
isError = readBoolean(stmt, 18);
|
isError = readBoolean(stmt, 15);
|
||||||
|
|
||||||
SetLogLevel(isDebug, isInfo, isWarn, isError);
|
SetLogLevel(isDebug, isInfo, isWarn, isError);
|
||||||
|
|
||||||
|
@ -863,10 +863,10 @@ class ServiceDevelopment extends HTMLElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ text: '生成代码', color: '#805ad5', action: () => alert('生成代码功能即将上线') },
|
{ text: '生成模板代码', color: '#805ad5', action: () => this.generateTemplateCode() },
|
||||||
{ text: '编辑代码', color: '#d69e2e', action: () => alert('编辑代码功能即将上线') },
|
{ text: '下载模板代码', color: '#d69e2e', action: () => this.downloadTemplateCode() },
|
||||||
{ text: '服务编译', color: '#dd6b20', action: () => alert('服务编译功能即将上线') },
|
{ text: '上传服务代码', color: '#dd6b20', action: () => this.uploadServiceCode() },
|
||||||
{ text: '服务提交', color: '#e53e3e', action: () => alert('服务提交功能即将上线') }
|
{ text: '服务编译发布', color: '#e53e3e', action: () => this.compileAndPublishService() }
|
||||||
];
|
];
|
||||||
|
|
||||||
buttonConfigs.forEach(config => {
|
buttonConfigs.forEach(config => {
|
||||||
@ -947,25 +947,11 @@ class ServiceDevelopment extends HTMLElement {
|
|||||||
basicInfoSection.appendChild(leftColumn);
|
basicInfoSection.appendChild(leftColumn);
|
||||||
basicInfoSection.appendChild(rightColumn);
|
basicInfoSection.appendChild(rightColumn);
|
||||||
|
|
||||||
// 代码路径
|
|
||||||
const codePathSection = document.createElement('div');
|
|
||||||
codePathSection.className = 'form-section code-path';
|
|
||||||
codePathSection.style.cssText = 'margin-top: 20px; border-top: 1px solid #e2e8f0; padding-top: 20px;';
|
|
||||||
|
|
||||||
const codePathGroup = document.createElement('div');
|
|
||||||
codePathGroup.className = 'form-group';
|
|
||||||
codePathGroup.innerHTML = `
|
|
||||||
<label for="codePath">代码路径 (CodePath)</label>
|
|
||||||
<input type="text" id="codePath" name="CodePath" value="${this.currentVersion.CodePath || ''}" title="服务代码文件的路径">
|
|
||||||
`;
|
|
||||||
|
|
||||||
codePathSection.appendChild(codePathGroup);
|
|
||||||
|
|
||||||
// 添加 CmdList 和 OtherParam 字段
|
// 添加 CmdList 和 OtherParam 字段
|
||||||
const jsonFieldsSection = document.createElement('div');
|
const jsonFieldsSection = document.createElement('div');
|
||||||
jsonFieldsSection.className = 'form-section json-fields';
|
jsonFieldsSection.className = 'form-section json-fields';
|
||||||
jsonFieldsSection.style.cssText = 'margin-top: 20px; border-top: 1px solid #e2e8f0; padding-top: 20px;';
|
jsonFieldsSection.style.cssText = 'margin-top: 20px; border-top: 1px solid #e2e8f0; padding-top: 20px;';
|
||||||
|
|
||||||
// CmdList 字段
|
// CmdList 字段
|
||||||
const cmdListGroup = document.createElement('div');
|
const cmdListGroup = document.createElement('div');
|
||||||
cmdListGroup.className = 'form-group';
|
cmdListGroup.className = 'form-group';
|
||||||
@ -1028,7 +1014,6 @@ class ServiceDevelopment extends HTMLElement {
|
|||||||
|
|
||||||
// 组装表单
|
// 组装表单
|
||||||
form.appendChild(basicInfoSection);
|
form.appendChild(basicInfoSection);
|
||||||
form.appendChild(codePathSection);
|
|
||||||
form.appendChild(jsonFieldsSection);
|
form.appendChild(jsonFieldsSection);
|
||||||
formContainer.appendChild(form);
|
formContainer.appendChild(form);
|
||||||
container.appendChild(formContainer);
|
container.appendChild(formContainer);
|
||||||
@ -1080,7 +1065,6 @@ class ServiceDevelopment extends HTMLElement {
|
|||||||
Author: form.querySelector('#author').value,
|
Author: form.querySelector('#author').value,
|
||||||
Description: form.querySelector('#description').value,
|
Description: form.querySelector('#description').value,
|
||||||
ChangeTime: form.querySelector('#changeTime').value,
|
ChangeTime: form.querySelector('#changeTime').value,
|
||||||
CodePath: form.querySelector('#codePath').value,
|
|
||||||
CmdList: cmdListInput.value,
|
CmdList: cmdListInput.value,
|
||||||
OtherParam: otherParamInput.value,
|
OtherParam: otherParamInput.value,
|
||||||
isUpdate: this.isEditMode,
|
isUpdate: this.isEditMode,
|
||||||
@ -1574,7 +1558,6 @@ class ServiceDevelopment extends HTMLElement {
|
|||||||
Description: '',
|
Description: '',
|
||||||
CreatTime: this.getCurrentDateTime(),
|
CreatTime: this.getCurrentDateTime(),
|
||||||
ChangeTime: this.getCurrentDateTime(),
|
ChangeTime: this.getCurrentDateTime(),
|
||||||
CodePath: '',
|
|
||||||
CmdList: [], // 初始化为空数组
|
CmdList: [], // 初始化为空数组
|
||||||
OtherParam: '{}' // 初始化为空对象的 JSON 字符串
|
OtherParam: '{}' // 初始化为空对象的 JSON 字符串
|
||||||
};
|
};
|
||||||
@ -1794,6 +1777,34 @@ class ServiceDevelopment extends HTMLElement {
|
|||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 生成模板代码
|
||||||
|
generateTemplateCode() {
|
||||||
|
console.log('生成模板代码功能');
|
||||||
|
// TODO: 实现生成模板代码的具体功能
|
||||||
|
alert('生成模板代码功能即将上线');
|
||||||
|
}
|
||||||
|
|
||||||
|
// 下载模板代码
|
||||||
|
downloadTemplateCode() {
|
||||||
|
console.log('下载模板代码功能');
|
||||||
|
// TODO: 实现下载模板代码的具体功能
|
||||||
|
alert('下载模板代码功能即将上线');
|
||||||
|
}
|
||||||
|
|
||||||
|
// 上传服务代码
|
||||||
|
uploadServiceCode() {
|
||||||
|
console.log('上传服务代码功能');
|
||||||
|
// TODO: 实现上传服务代码的具体功能
|
||||||
|
alert('上传服务代码功能即将上线');
|
||||||
|
}
|
||||||
|
|
||||||
|
// 服务编译发布
|
||||||
|
compileAndPublishService() {
|
||||||
|
console.log('服务编译发布功能');
|
||||||
|
// TODO: 实现服务编译发布的具体功能
|
||||||
|
alert('服务编译发布功能即将上线');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
customElements.define('service-development', ServiceDevelopment);
|
customElements.define('service-development', ServiceDevelopment);
|
@ -26,7 +26,7 @@ function getServiceVersionsByClassName(className) {
|
|||||||
|
|
||||||
// 查询该类名下的所有版本
|
// 查询该类名下的所有版本
|
||||||
const versions = db.prepare(`
|
const versions = db.prepare(`
|
||||||
SELECT ClassName, Name, Version, CodePath, Author, Description,
|
SELECT ClassName, Name, Version, Author, Description,
|
||||||
CreatTime, ChangeTime, CmdList, OtherParam
|
CreatTime, ChangeTime, CmdList, OtherParam
|
||||||
FROM 'XNServiceVersion'
|
FROM 'XNServiceVersion'
|
||||||
WHERE ClassName = ?
|
WHERE ClassName = ?
|
||||||
@ -88,7 +88,6 @@ function saveServiceVersion(versionData) {
|
|||||||
Version = ?,
|
Version = ?,
|
||||||
Author = ?,
|
Author = ?,
|
||||||
Description = ?,
|
Description = ?,
|
||||||
CodePath = ?,
|
|
||||||
ChangeTime = ?,
|
ChangeTime = ?,
|
||||||
CmdList = ?,
|
CmdList = ?,
|
||||||
OtherParam = ?
|
OtherParam = ?
|
||||||
@ -98,7 +97,6 @@ function saveServiceVersion(versionData) {
|
|||||||
versionData.Version,
|
versionData.Version,
|
||||||
versionData.Author,
|
versionData.Author,
|
||||||
versionData.Description || '',
|
versionData.Description || '',
|
||||||
versionData.CodePath || '',
|
|
||||||
changeTime, // 使用前端传来的时间或生成的当前时间
|
changeTime, // 使用前端传来的时间或生成的当前时间
|
||||||
versionData.CmdList || '[]',
|
versionData.CmdList || '[]',
|
||||||
versionData.OtherParam || '{}',
|
versionData.OtherParam || '{}',
|
||||||
@ -152,14 +150,13 @@ function saveNewServiceVersion(db, versionData) {
|
|||||||
// 插入新版本
|
// 插入新版本
|
||||||
const insertResult = db.prepare(`
|
const insertResult = db.prepare(`
|
||||||
INSERT INTO 'XNServiceVersion' (
|
INSERT INTO 'XNServiceVersion' (
|
||||||
ClassName, Name, Version, CodePath, Author, Description,
|
ClassName, Name, Version, Author, Description,
|
||||||
CreatTime, ChangeTime, CmdList, OtherParam
|
CreatTime, ChangeTime, CmdList, OtherParam
|
||||||
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||||
`).run(
|
`).run(
|
||||||
versionData.ClassName,
|
versionData.ClassName,
|
||||||
versionData.Name,
|
versionData.Name,
|
||||||
versionData.Version,
|
versionData.Version,
|
||||||
versionData.CodePath || '',
|
|
||||||
versionData.Author,
|
versionData.Author,
|
||||||
versionData.Description || '',
|
versionData.Description || '',
|
||||||
createTime, // 使用前端传来的创建时间或生成的当前时间
|
createTime, // 使用前端传来的创建时间或生成的当前时间
|
||||||
|
Loading…
x
Reference in New Issue
Block a user