diff --git a/Release/database/XNSim.db b/Release/database/XNSim.db index d7759ae..d1135b3 100644 Binary files a/Release/database/XNSim.db and b/Release/database/XNSim.db differ diff --git a/XNCore/XNModelObject.cpp b/XNCore/XNModelObject.cpp index 65f4a41..1d52e39 100755 --- a/XNCore/XNModelObject.cpp +++ b/XNCore/XNModelObject.cpp @@ -362,18 +362,18 @@ void XNModelObject::ParseConfig() return; } - d->_sDescription = XNSim::getStringFromSqlite3(stmt, 7); - d->_sAuthor = XNSim::getStringFromSqlite3(stmt, 6); + d->_sDescription = XNSim::getStringFromSqlite3(stmt, 6); + d->_sAuthor = XNSim::getStringFromSqlite3(stmt, 5); d->_sVersion = XNSim::getStringFromSqlite3(stmt, 2); // 解析时间 - std::string createTimeStr = XNSim::getStringFromSqlite3(stmt, 8); - std::string changeTimeStr = XNSim::getStringFromSqlite3(stmt, 9); + std::string createTimeStr = XNSim::getStringFromSqlite3(stmt, 7); + std::string changeTimeStr = XNSim::getStringFromSqlite3(stmt, 8); d->_cCreatTime = XNSim::parseISOTime(createTimeStr); d->_cChangeTime = XNSim::parseISOTime(changeTimeStr); - d->_runFreq = XNSim::safe_stoi(XNSim::getStringFromSqlite3(stmt, 10)); - d->_runNode = XNSim::safe_stoi(XNSim::getStringFromSqlite3(stmt, 11)); - d->_runPriority = XNSim::safe_stoi(XNSim::getStringFromSqlite3(stmt, 12)); + d->_runFreq = XNSim::safe_stoi(XNSim::getStringFromSqlite3(stmt, 9)); + d->_runNode = XNSim::safe_stoi(XNSim::getStringFromSqlite3(stmt, 10)); + d->_runPriority = XNSim::safe_stoi(XNSim::getStringFromSqlite3(stmt, 11)); // 注册周期性函数 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) { // 使用标准C++文件路径处理 - //std::filesystem::path xmlPath(GetXmlPath()); - //d->_sLibPath = xmlPath.parent_path().string() + "/" + mathlib; std::string libPath = d->_sLibPath + "/" + mathlib; // 使用标准C++动态库加载 d->_dynamicLib = dlopen(libPath.c_str(), RTLD_LAZY); diff --git a/XNCore/XNScenarioManager.cpp b/XNCore/XNScenarioManager.cpp index 6f0a422..285a786 100755 --- a/XNCore/XNScenarioManager.cpp +++ b/XNCore/XNScenarioManager.cpp @@ -235,31 +235,20 @@ bool XNScenarioManager::ParseConfig(const std::string &ConfigID) return false; } std::string planeName = XNSim::getStringFromSqlite3(stmt, 1); + std::string confName = XNSim::getStringFromSqlite3(stmt, 2); std::string osName = XNSim::getStringFromSqlite3(stmt, 3); 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; - } + std::string rootPath = XNCorePath + "/Configuration/" + confName; GetFramework()->SetWorkPath(rootPath); // 设置模型库目录 - std::string modelPath = rootPath + XNSim::getStringFromSqlite3(stmt, 8); - if (modelPath.empty()) { - LOG_WARNING("0x1020 未设置模型库目录,使用默认模型库目录: %1/Models", XNCorePath); - modelPath = XNCorePath + "/Models"; - } + std::string modelPath = rootPath + "/Models"; GetFramework()->SetModelPath(modelPath); // 设置服务库目录 - std::string servicePath = rootPath + XNSim::getStringFromSqlite3(stmt, 9); - if (servicePath.empty()) { - LOG_WARNING("0x1020 未设置服务库目录,使用默认服务库目录: %1/Services", XNCorePath); - servicePath = XNCorePath + "/Services"; - } + std::string servicePath = rootPath + "/Services"; GetFramework()->SetServicePath(servicePath); // 设置域ID - uint32_t domainID = std::stoul(XNSim::getStringFromSqlite3(stmt, 10)); + uint32_t domainID = std::stoul(XNSim::getStringFromSqlite3(stmt, 7)); if (domainID == 0 || domainID > 225) { LOG_WARNING("0x1020 域ID设置错误,使用默认域ID: 10"); domainID = 10; diff --git a/XNCore/XNServiceObject.cpp b/XNCore/XNServiceObject.cpp index 15b6b63..c4ba212 100755 --- a/XNCore/XNServiceObject.cpp +++ b/XNCore/XNServiceObject.cpp @@ -238,18 +238,18 @@ void XNServiceObject::ParseConfig() sqlite3_close(db); return; } - d->_sDescription = XNSim::getStringFromSqlite3(stmt, 5); - d->_sAuthor = XNSim::getStringFromSqlite3(stmt, 4); + d->_sDescription = XNSim::getStringFromSqlite3(stmt, 4); + d->_sAuthor = XNSim::getStringFromSqlite3(stmt, 3); d->_sVersion = XNSim::getStringFromSqlite3(stmt, 2); // 解析时间 - std::string createTimeStr = XNSim::getStringFromSqlite3(stmt, 6); - std::string changeTimeStr = XNSim::getStringFromSqlite3(stmt, 7); + std::string createTimeStr = XNSim::getStringFromSqlite3(stmt, 5); + std::string changeTimeStr = XNSim::getStringFromSqlite3(stmt, 6); d->_cCreateTime = XNSim::parseISOTime(createTimeStr); d->_cChangeTime = XNSim::parseISOTime(changeTimeStr); // 读取服务命令列表 - std::string commandListStr = XNSim::getStringFromSqlite3(stmt, 8); + std::string commandListStr = XNSim::getStringFromSqlite3(stmt, 7); if (!commandListStr.empty()) { try { 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()) { try { d->_otherParams = XN_JSON::parse(otherParamsStr); diff --git a/XNEngine/XNEngine.cpp b/XNEngine/XNEngine.cpp index 7ec7439..4c75db3 100755 --- a/XNEngine/XNEngine.cpp +++ b/XNEngine/XNEngine.cpp @@ -585,17 +585,17 @@ bool XNEngine::ParseDataBase(const std::string &ConfigId) return sqlite3_column_int(stmt, column) != 0; }; - bool isDebug = readBoolean(stmt, 11); - bool isInfo = readBoolean(stmt, 12); - bool isWarn = readBoolean(stmt, 13); - bool isError = readBoolean(stmt, 14); + bool isDebug = readBoolean(stmt, 8); + bool isInfo = readBoolean(stmt, 9); + bool isWarn = readBoolean(stmt, 10); + bool isError = readBoolean(stmt, 11); SetConsoleOutput(isDebug, isInfo, isWarn, isError); - isDebug = readBoolean(stmt, 15); - isInfo = readBoolean(stmt, 16); - isWarn = readBoolean(stmt, 17); - isError = readBoolean(stmt, 18); + isDebug = readBoolean(stmt, 12); + isInfo = readBoolean(stmt, 13); + isWarn = readBoolean(stmt, 14); + isError = readBoolean(stmt, 15); SetLogLevel(isDebug, isInfo, isWarn, isError); diff --git a/XNSimPortal/components/service-development.js b/XNSimPortal/components/service-development.js index 75d0e38..e78abe7 100644 --- a/XNSimPortal/components/service-development.js +++ b/XNSimPortal/components/service-development.js @@ -863,10 +863,10 @@ class ServiceDevelopment extends HTMLElement { } } }, - { text: '生成代码', color: '#805ad5', action: () => alert('生成代码功能即将上线') }, - { text: '编辑代码', color: '#d69e2e', action: () => alert('编辑代码功能即将上线') }, - { text: '服务编译', color: '#dd6b20', action: () => alert('服务编译功能即将上线') }, - { text: '服务提交', color: '#e53e3e', action: () => alert('服务提交功能即将上线') } + { text: '生成模板代码', color: '#805ad5', action: () => this.generateTemplateCode() }, + { text: '下载模板代码', color: '#d69e2e', action: () => this.downloadTemplateCode() }, + { text: '上传服务代码', color: '#dd6b20', action: () => this.uploadServiceCode() }, + { text: '服务编译发布', color: '#e53e3e', action: () => this.compileAndPublishService() } ]; buttonConfigs.forEach(config => { @@ -947,25 +947,11 @@ class ServiceDevelopment extends HTMLElement { basicInfoSection.appendChild(leftColumn); 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 = ` - - - `; - - codePathSection.appendChild(codePathGroup); - // 添加 CmdList 和 OtherParam 字段 const jsonFieldsSection = document.createElement('div'); jsonFieldsSection.className = 'form-section json-fields'; jsonFieldsSection.style.cssText = 'margin-top: 20px; border-top: 1px solid #e2e8f0; padding-top: 20px;'; - + // CmdList 字段 const cmdListGroup = document.createElement('div'); cmdListGroup.className = 'form-group'; @@ -1028,7 +1014,6 @@ class ServiceDevelopment extends HTMLElement { // 组装表单 form.appendChild(basicInfoSection); - form.appendChild(codePathSection); form.appendChild(jsonFieldsSection); formContainer.appendChild(form); container.appendChild(formContainer); @@ -1080,7 +1065,6 @@ class ServiceDevelopment extends HTMLElement { Author: form.querySelector('#author').value, Description: form.querySelector('#description').value, ChangeTime: form.querySelector('#changeTime').value, - CodePath: form.querySelector('#codePath').value, CmdList: cmdListInput.value, OtherParam: otherParamInput.value, isUpdate: this.isEditMode, @@ -1574,7 +1558,6 @@ class ServiceDevelopment extends HTMLElement { Description: '', CreatTime: this.getCurrentDateTime(), ChangeTime: this.getCurrentDateTime(), - CodePath: '', CmdList: [], // 初始化为空数组 OtherParam: '{}' // 初始化为空对象的 JSON 字符串 }; @@ -1794,6 +1777,34 @@ class ServiceDevelopment extends HTMLElement { 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); \ No newline at end of file diff --git a/XNSimPortal/utils/service-utils.js b/XNSimPortal/utils/service-utils.js index 2dc2952..9861bd9 100644 --- a/XNSimPortal/utils/service-utils.js +++ b/XNSimPortal/utils/service-utils.js @@ -26,7 +26,7 @@ function getServiceVersionsByClassName(className) { // 查询该类名下的所有版本 const versions = db.prepare(` - SELECT ClassName, Name, Version, CodePath, Author, Description, + SELECT ClassName, Name, Version, Author, Description, CreatTime, ChangeTime, CmdList, OtherParam FROM 'XNServiceVersion' WHERE ClassName = ? @@ -88,7 +88,6 @@ function saveServiceVersion(versionData) { Version = ?, Author = ?, Description = ?, - CodePath = ?, ChangeTime = ?, CmdList = ?, OtherParam = ? @@ -98,7 +97,6 @@ function saveServiceVersion(versionData) { versionData.Version, versionData.Author, versionData.Description || '', - versionData.CodePath || '', changeTime, // 使用前端传来的时间或生成的当前时间 versionData.CmdList || '[]', versionData.OtherParam || '{}', @@ -152,14 +150,13 @@ function saveNewServiceVersion(db, versionData) { // 插入新版本 const insertResult = db.prepare(` INSERT INTO 'XNServiceVersion' ( - ClassName, Name, Version, CodePath, Author, Description, + ClassName, Name, Version, Author, Description, CreatTime, ChangeTime, CmdList, OtherParam - ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?) + ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) `).run( versionData.ClassName, versionData.Name, versionData.Version, - versionData.CodePath || '', versionData.Author, versionData.Description || '', createTime, // 使用前端传来的创建时间或生成的当前时间