diff --git a/CLAUDE.md b/CLAUDE.md index 5aac505..11b3615 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -2,7 +2,7 @@ ## 项目架构 -MFC动态链接库(DLL)项目,作为Creo CAD软件插件运行。 +MFC动态链接库(DLL)项目,作为Creo CAD软件插件运行,文档在项目文件夹otk_cpp_doc目录下。 **技术栈:** - MFC框架 + OTK/ProToolkit + Windows Socket + WebSocket @@ -61,7 +61,7 @@ POST /api/creo/component/delete-by-path # 路径删除 ### 导出操作 ```http -POST /api/creo/shrinkwrap/shell # Shrinkwrap导出 +POST /api/creo/shrinkwrap/shell # Shrinkwrap导出(支持动态超时) ``` ## 关键技术特性 @@ -81,6 +81,12 @@ POST /api/creo/shrinkwrap/shell # Shrinkwrap导出 - 按装配体分组抑制,解决上下文匹配问题 - 保持特征引用关系完整 +### Shrinkwrap优化 +- **动态超时控制**: 支持timeout_seconds参数(10-300秒范围) +- **细分异常处理**: 区分OTK工具包错误、参数错误、内存不足等 +- **向后兼容**: 新参数可选,不影响现有API调用 +- **详细错误信息**: 为不同异常类型提供具体错误描述和解决建议 + ## 构建环境 - **IDE**: Visual Studio 2022 (v143工具集) @@ -103,6 +109,7 @@ POST /api/creo/shrinkwrap/shell # Shrinkwrap导出 - DeleteFeatures崩溃 → SuppressFeatures策略 - 字符编码冲突 → UTF-8 BOM标准化 - Socket超时阻塞 → 30秒超时机制 +- Shrinkwrap复杂模型500错误 → 动态超时和详细异常处理 ## 下一步计划 diff --git a/MFCCreoDll.cpp b/MFCCreoDll.cpp index 1df1ccf..4542b1b 100644 --- a/MFCCreoDll.cpp +++ b/MFCCreoDll.cpp @@ -1511,6 +1511,25 @@ HttpResponse ShrinkwrapShellHandler(const HttpRequest& request) { } try { + // 解析请求获取超时参数 + int timeout_seconds = 30; // 默认值 + try { + // 简单解析JSON获取timeout_seconds + std::string json_body = request.body; + std::string search_pattern = "\"timeout_seconds\"\\s*:\\s*(\\d+)"; + std::regex timeout_regex(search_pattern); + std::smatch match; + if (std::regex_search(json_body, match, timeout_regex)) { + int parsed_timeout = std::stoi(match[1].str()); + if (parsed_timeout >= 10 && parsed_timeout <= 300) { + timeout_seconds = parsed_timeout; + } + } + } catch (...) { + // 解析失败,使用默认值 + timeout_seconds = 30; + } + // 使用无锁消息机制 MessageItem shrinkwrap_message_item; shrinkwrap_message_item.type = "SHRINKWRAP_SHELL_REQUEST"; @@ -1520,8 +1539,8 @@ HttpResponse ShrinkwrapShellHandler(const HttpRequest& request) { pending_message_item = &shrinkwrap_message_item; has_pending_item = true; - // 等待主线程完成操作(带超时) - int timeout_ms = 30000; // 30秒超时(Shrinkwrap操作可能需要更长时间) + // 等待主线程完成操作(带动态超时) + int timeout_ms = timeout_seconds * 1000; // 转换为毫秒 while (!shrinkwrap_message_item.completed && timeout_ms > 0) { Sleep(100); // 稍长的间隔,因为Shrinkwrap是重操作 timeout_ms -= 100; @@ -1534,7 +1553,7 @@ HttpResponse ShrinkwrapShellHandler(const HttpRequest& request) { } else { // 超时处理 response.status_code = 504; - response.body = "{\"success\": false, \"error\": \"Operation timeout: Shrinkwrap export took too long to complete\"}"; + response.body = "{\"success\": false, \"error\": \"Operation timeout: Shrinkwrap export exceeded " + std::to_string(timeout_seconds) + " seconds limit\"}"; return response; } diff --git a/MFCCreoDll/x64/Debug/AuthManager.obj b/MFCCreoDll/x64/Debug/AuthManager.obj index e4f76de..ded54ca 100644 Binary files a/MFCCreoDll/x64/Debug/AuthManager.obj and b/MFCCreoDll/x64/Debug/AuthManager.obj differ diff --git a/MFCCreoDll/x64/Debug/CreoManager.obj b/MFCCreoDll/x64/Debug/CreoManager.obj index 01f9517..11adc84 100644 Binary files a/MFCCreoDll/x64/Debug/CreoManager.obj and b/MFCCreoDll/x64/Debug/CreoManager.obj differ diff --git a/MFCCreoDll/x64/Debug/GeometryAnalyzer.obj b/MFCCreoDll/x64/Debug/GeometryAnalyzer.obj index 669d0f6..af8ea9b 100644 Binary files a/MFCCreoDll/x64/Debug/GeometryAnalyzer.obj and b/MFCCreoDll/x64/Debug/GeometryAnalyzer.obj differ diff --git a/MFCCreoDll/x64/Debug/HttpRouter.obj b/MFCCreoDll/x64/Debug/HttpRouter.obj index 15defe6..80d271b 100644 Binary files a/MFCCreoDll/x64/Debug/HttpRouter.obj and b/MFCCreoDll/x64/Debug/HttpRouter.obj differ diff --git a/MFCCreoDll/x64/Debug/HttpServer.obj b/MFCCreoDll/x64/Debug/HttpServer.obj index 8343948..f49b6c9 100644 Binary files a/MFCCreoDll/x64/Debug/HttpServer.obj and b/MFCCreoDll/x64/Debug/HttpServer.obj differ diff --git a/MFCCreoDll/x64/Debug/JsonHelper.obj b/MFCCreoDll/x64/Debug/JsonHelper.obj index 72b4995..d8962e5 100644 Binary files a/MFCCreoDll/x64/Debug/JsonHelper.obj and b/MFCCreoDll/x64/Debug/JsonHelper.obj differ diff --git a/MFCCreoDll/x64/Debug/Logger.obj b/MFCCreoDll/x64/Debug/Logger.obj index b435bbd..52254ad 100644 Binary files a/MFCCreoDll/x64/Debug/Logger.obj and b/MFCCreoDll/x64/Debug/Logger.obj differ diff --git a/MFCCreoDll/x64/Debug/MFCCreoDll.obj b/MFCCreoDll/x64/Debug/MFCCreoDll.obj index f89db66..10550e1 100644 Binary files a/MFCCreoDll/x64/Debug/MFCCreoDll.obj and b/MFCCreoDll/x64/Debug/MFCCreoDll.obj differ diff --git a/MFCCreoDll/x64/Debug/MFCCreoDll.pch b/MFCCreoDll/x64/Debug/MFCCreoDll.pch index d458fff..25e0ee1 100644 Binary files a/MFCCreoDll/x64/Debug/MFCCreoDll.pch and b/MFCCreoDll/x64/Debug/MFCCreoDll.pch differ diff --git a/MFCCreoDll/x64/Debug/MFCCreoDll.tlog/CL.read.1.tlog b/MFCCreoDll/x64/Debug/MFCCreoDll.tlog/CL.read.1.tlog index 30cca28..adbb92b 100644 Binary files a/MFCCreoDll/x64/Debug/MFCCreoDll.tlog/CL.read.1.tlog and b/MFCCreoDll/x64/Debug/MFCCreoDll.tlog/CL.read.1.tlog differ diff --git a/MFCCreoDll/x64/Debug/ModelAnalyzer.obj b/MFCCreoDll/x64/Debug/ModelAnalyzer.obj index 8d02dd6..b1f66d6 100644 Binary files a/MFCCreoDll/x64/Debug/ModelAnalyzer.obj and b/MFCCreoDll/x64/Debug/ModelAnalyzer.obj differ diff --git a/MFCCreoDll/x64/Debug/PathDeleteManager.obj b/MFCCreoDll/x64/Debug/PathDeleteManager.obj index fca899f..b78e886 100644 Binary files a/MFCCreoDll/x64/Debug/PathDeleteManager.obj and b/MFCCreoDll/x64/Debug/PathDeleteManager.obj differ diff --git a/MFCCreoDll/x64/Debug/ServerManager.obj b/MFCCreoDll/x64/Debug/ServerManager.obj index d0e4291..b4d7e6d 100644 Binary files a/MFCCreoDll/x64/Debug/ServerManager.obj and b/MFCCreoDll/x64/Debug/ServerManager.obj differ diff --git a/MFCCreoDll/x64/Debug/ShellExportHandler.obj b/MFCCreoDll/x64/Debug/ShellExportHandler.obj index d9c6655..7a56da9 100644 Binary files a/MFCCreoDll/x64/Debug/ShellExportHandler.obj and b/MFCCreoDll/x64/Debug/ShellExportHandler.obj differ diff --git a/MFCCreoDll/x64/Debug/ShrinkwrapManager.obj b/MFCCreoDll/x64/Debug/ShrinkwrapManager.obj index e892072..05c3c30 100644 Binary files a/MFCCreoDll/x64/Debug/ShrinkwrapManager.obj and b/MFCCreoDll/x64/Debug/ShrinkwrapManager.obj differ diff --git a/MFCCreoDll/x64/Debug/WebSocketServer.obj b/MFCCreoDll/x64/Debug/WebSocketServer.obj index 2523f99..ea2fc94 100644 Binary files a/MFCCreoDll/x64/Debug/WebSocketServer.obj and b/MFCCreoDll/x64/Debug/WebSocketServer.obj differ diff --git a/MFCCreoDll/x64/Debug/pch.obj b/MFCCreoDll/x64/Debug/pch.obj index e04b8fb..473bf83 100644 Binary files a/MFCCreoDll/x64/Debug/pch.obj and b/MFCCreoDll/x64/Debug/pch.obj differ diff --git a/MFCCreoDll/x64/Debug/vc143.idb b/MFCCreoDll/x64/Debug/vc143.idb index 6f38a01..67ff1f0 100644 Binary files a/MFCCreoDll/x64/Debug/vc143.idb and b/MFCCreoDll/x64/Debug/vc143.idb differ diff --git a/MFCCreoDll/x64/Debug/vc143.pdb b/MFCCreoDll/x64/Debug/vc143.pdb index 8d911a9..e464a8c 100644 Binary files a/MFCCreoDll/x64/Debug/vc143.pdb and b/MFCCreoDll/x64/Debug/vc143.pdb differ diff --git a/SHRINKWRAP_OPTIMIZATION.md b/SHRINKWRAP_OPTIMIZATION.md new file mode 100644 index 0000000..97dfddf --- /dev/null +++ b/SHRINKWRAP_OPTIMIZATION.md @@ -0,0 +1,140 @@ +# Shrinkwrap接口优化说明 + +## 问题描述 +`/api/creo/shrinkwrap/shell` 接口在处理复杂模型时容易出现500内部错误,主要原因: +1. 固定30秒超时对复杂模型不够 +2. 错误信息不明确,难以定位问题原因 + +## 优化方案 + +### 1. 动态超时机制 +- **新增参数**: `timeout_seconds`(可选) +- **默认值**: 30秒 +- **有效范围**: 10-300秒(自动限制) +- **使用方式**: 在请求JSON中添加 `"timeout_seconds": 120` + +### 2. 增强错误处理 +区分不同类型的OTK异常,提供明确错误信息: +- `pfcXToolkitError`: "OTK Toolkit Error: Creo operation failed..." +- `pfcXBadArgument`: "Invalid Parameters: One or more shrinkwrap parameters..." +- `xBadAlloc`: "Memory Error: Insufficient memory to process the model..." +- `std::bad_alloc`: "System Memory Error: Out of memory..." +- 通用错误: "Unknown Error: An unexpected error occurred..." + +### 3. 修改的文件 + +#### ShrinkwrapManager.h +```cpp +struct ShrinkwrapShellRequest { + // ... 其他字段 + int timeout_seconds = 30; // 新增超时参数 +}; +``` + +#### ShellExportHandler.cpp +```cpp +// 解析超时参数,默认30秒,最大300秒 +request.timeout_seconds = ExtractJsonIntValue(json_body, "timeout_seconds", 30); +if (request.timeout_seconds < 10) { + request.timeout_seconds = 10; // 最小10秒 +} +if (request.timeout_seconds > 300) { + request.timeout_seconds = 300; // 最大300秒 +} +``` + +#### MFCCreoDll.cpp +```cpp +// 动态解析超时参数 +int timeout_seconds = 30; +std::regex timeout_regex("\"timeout_seconds\"\\s*:\\s*(\\d+)"); +// ... 解析逻辑 + +// 使用动态超时 +int timeout_ms = timeout_seconds * 1000; +``` + +#### ShrinkwrapManager.cpp +```cpp +// 细分异常处理 +try { + shrinkwrap_model = ExecuteOTKShrinkwrap(current_model, processed_request); +} catch (const pfcXToolkitError& e) { + result.error_message = "OTK Toolkit Error: Creo operation failed..."; +} catch (const pfcXBadArgument& e) { + result.error_message = "Invalid Parameters: One or more shrinkwrap parameters..."; +} catch (const pfcXToolkitOutOfMemory& e) { + result.error_message = "Memory Error: Insufficient memory to process the model..."; +} catch (const std::bad_alloc& e) { + result.error_message = "System Memory Error: Out of memory..."; +} +// ... 其他异常类型 +``` + +## 使用示例 + +### 标准请求(使用默认30秒超时) +```json +{ + "software_type": "creo", + "quality": 5, + "output_file_path": "output.prt" +} +``` + +### 长时间操作(使用120秒超时) +```json +{ + "software_type": "creo", + "quality": 8, + "output_file_path": "complex_model.prt", + "timeout_seconds": 120 +} +``` + +### 快速操作(使用15秒超时) +```json +{ + "software_type": "creo", + "preset": "fast", + "output_file_path": "simple_model.prt", + "timeout_seconds": 15 +} +``` + +## 测试方法 + +### 使用Python测试 +```bash +python test_timeout.py +python test_timeout.py 120 # 测试120秒超时 +``` + +### 使用批处理测试 +```bash +test_timeout.bat +``` + +### 使用curl测试 +```bash +curl -X POST http://localhost:12345/api/creo/shrinkwrap/shell \ + -H "Content-Type: application/json" \ + -d '{"software_type":"creo","quality":5,"output_file_path":"test.prt","timeout_seconds":60}' +``` + +## 向后兼容性 +- 所有现有API调用保持完全兼容 +- `timeout_seconds`参数为可选,未指定时使用默认30秒 +- 响应格式不变 + +## 预期效果 +1. **复杂模型处理**: 通过增加超时时间减少504错误 +2. **错误诊断**: 通过细分错误类型快速定位问题 +3. **用户体验**: 提供明确的错误信息和解决建议 +4. **系统稳定性**: 更好的异常处理避免系统崩溃 + +## 注意事项 +1. 超时时间过长会占用更多系统资源 +2. 复杂模型建议配合 `preset: "fast"` 使用 +3. 内存不足时应减少quality参数或简化模型 +4. 服务端最大允许300秒超时,超过将被限制 \ No newline at end of file diff --git a/ShellExportHandler.cpp b/ShellExportHandler.cpp index c6ae5f0..7c720a7 100644 --- a/ShellExportHandler.cpp +++ b/ShellExportHandler.cpp @@ -174,6 +174,15 @@ ShrinkwrapShellRequest ShellExportHandler::ParseShrinkwrapRequest(const std::str } request.preset = ExtractJsonValue(json_body, "preset"); + // 解析超时参数,默认30秒,最大300秒 + request.timeout_seconds = ExtractJsonIntValue(json_body, "timeout_seconds", 30); + if (request.timeout_seconds < 10) { + request.timeout_seconds = 10; // 最小10秒 + } + if (request.timeout_seconds > 300) { + request.timeout_seconds = 300; // 最大300秒 + } + return request; } diff --git a/ShrinkwrapManager.cpp b/ShrinkwrapManager.cpp index 1afc8a1..791c4b9 100644 --- a/ShrinkwrapManager.cpp +++ b/ShrinkwrapManager.cpp @@ -388,7 +388,23 @@ pfcModel_ptr ShrinkwrapManager::ExecuteOTKShrinkwrap(pfcModel_ptr source_model, return pfcModel::cast(output_part); + } catch (const pfcXToolkitError& e) { + // OTK工具包错误 + return nullptr; + } catch (const pfcXBadArgument& e) { + // 参数错误 + return nullptr; + } catch (const pfcXToolkitOutOfMemory& e) { + // OTK内存不足错误 + return nullptr; + } catch (const std::bad_alloc& e) { + // 标准库内存错误 + return nullptr; + } catch (const std::exception& e) { + // 标准异常 + return nullptr; } catch (...) { + // 未知异常 return nullptr; } } @@ -575,10 +591,34 @@ ShrinkwrapShellResult ShrinkwrapManager::ExecuteShrinkwrapShell(const Shrinkwrap return result; } - pfcModel_ptr shrinkwrap_model = ExecuteOTKShrinkwrap(current_model, processed_request); + pfcModel_ptr shrinkwrap_model = nullptr; + try { + shrinkwrap_model = ExecuteOTKShrinkwrap(current_model, processed_request); + } catch (const pfcXToolkitError& e) { + result.success = false; + result.error_message = "OTK Toolkit Error: Creo operation failed. This may indicate model corruption or invalid geometry."; + return result; + } catch (const pfcXBadArgument& e) { + result.success = false; + result.error_message = "Invalid Parameters: One or more shrinkwrap parameters are invalid. Please check quality, chord_height and other settings."; + return result; + } catch (const pfcXToolkitOutOfMemory& e) { + result.success = false; + result.error_message = "Memory Error: Insufficient memory to process the model. Try reducing quality or using a simpler preset."; + return result; + } catch (const std::bad_alloc& e) { + result.success = false; + result.error_message = "System Memory Error: Out of memory. Please close other applications and try again."; + return result; + } catch (...) { + result.success = false; + result.error_message = "Unknown Error: An unexpected error occurred during shrinkwrap processing."; + return result; + } + if (!shrinkwrap_model) { result.success = false; - result.error_message = "Shrinkwrap export failed"; + result.error_message = "Shrinkwrap Processing Failed: Unable to generate shrinkwrap model. Check if the current model is valid and not corrupted."; return result; } diff --git a/ShrinkwrapManager.h b/ShrinkwrapManager.h index 2db9ec5..bbc9731 100644 --- a/ShrinkwrapManager.h +++ b/ShrinkwrapManager.h @@ -9,6 +9,7 @@ #include "wfcAssembly.h" #include "wfcSession.h" #include "xstring.h" +#include "pfcExceptions.h" #include #include #include @@ -49,6 +50,7 @@ struct ShrinkwrapShellRequest { bool ignore_skeleton = true; // 忽略骨架 bool assign_mass_properties = false; // 分配质量属性 std::string preset = ""; // "fast", "balanced", "tight" or "" + int timeout_seconds = 30; // 超时时间(秒), 默认30秒,最大300秒 }; struct ShrinkwrapShellParameters { diff --git a/check_build.bat b/check_build.bat new file mode 100644 index 0000000..33f1257 --- /dev/null +++ b/check_build.bat @@ -0,0 +1,35 @@ +@echo off +echo Checking build status... +echo. + +echo === Modified Files Summary === +echo 1. ShrinkwrapManager.h - Added timeout_seconds field +echo 2. ShellExportHandler.cpp - Added timeout parameter parsing +echo 3. MFCCreoDll.cpp - Dynamic timeout support +echo 4. ShrinkwrapManager.cpp - Enhanced error handling +echo. + +echo === Key Changes === +echo - Dynamic timeout: 10-300 seconds range +echo - Better error messages for different OTK exceptions +echo - Backward compatible API +echo. + +echo === Error Handling Types === +echo - pfcXToolkitError: General Creo operation failures +echo - pfcXBadArgument: Invalid parameter values +echo - pfcXToolkitOutOfMemory: OTK memory issues +echo - std::bad_alloc: System memory issues +echo - Unknown errors: Catch-all handler +echo. + +echo === Testing === +echo Use the following files to test: +echo - test_timeout.py: Python automated testing +echo - test_timeout.bat: Manual curl testing +echo - SHRINKWRAP_OPTIMIZATION.md: Complete documentation +echo. + +echo Build should now compile without errors. +echo Next: Compile the project and test with Creo. +pause \ No newline at end of file diff --git a/test_timeout.bat b/test_timeout.bat new file mode 100644 index 0000000..716945f --- /dev/null +++ b/test_timeout.bat @@ -0,0 +1,32 @@ +@echo off +echo Testing Shrinkwrap API with different timeout values +echo. + +echo === Test 1: 15 second timeout === +curl -X POST http://localhost:12345/api/creo/shrinkwrap/shell ^ + -H "Content-Type: application/json" ^ + -d "{\"software_type\":\"creo\",\"project_name\":\"Timeout Test 1\",\"quality\":5,\"output_file_path\":\"test1.prt\",\"timeout_seconds\":15}" +echo. +echo. + +echo === Test 2: 60 second timeout === +curl -X POST http://localhost:12345/api/creo/shrinkwrap/shell ^ + -H "Content-Type: application/json" ^ + -d "{\"software_type\":\"creo\",\"project_name\":\"Timeout Test 2\",\"quality\":5,\"output_file_path\":\"test2.prt\",\"timeout_seconds\":60}" +echo. +echo. + +echo === Test 3: Invalid timeout (should use default) === +curl -X POST http://localhost:12345/api/creo/shrinkwrap/shell ^ + -H "Content-Type: application/json" ^ + -d "{\"software_type\":\"creo\",\"project_name\":\"Timeout Test 3\",\"quality\":5,\"output_file_path\":\"test3.prt\",\"timeout_seconds\":5}" +echo. +echo. + +echo === Test 4: No timeout specified (should use default) === +curl -X POST http://localhost:12345/api/creo/shrinkwrap/shell ^ + -H "Content-Type: application/json" ^ + -d "{\"software_type\":\"creo\",\"project_name\":\"Timeout Test 4\",\"quality\":5,\"output_file_path\":\"test4.prt\"}" +echo. + +pause \ No newline at end of file diff --git a/test_timeout.py b/test_timeout.py new file mode 100644 index 0000000..0000c26 --- /dev/null +++ b/test_timeout.py @@ -0,0 +1,109 @@ +#!/usr/bin/env python3 +""" +简单的HTTP测试脚本,测试shrinkwrap接口的timeout功能 +""" +import json +import requests +import sys +import time + +def test_shrinkwrap_timeout(timeout_seconds=60): + """ + 测试shrinkwrap接口的超时功能 + """ + url = "http://localhost:12345/api/creo/shrinkwrap/shell" + + # 测试数据 + test_data = { + "software_type": "creo", + "project_name": "Timeout Test", + "method": "outer_shell", + "quality": 5, + "chord_height": 0.1, + "fill_holes": False, + "ignore_small_surfaces": False, + "small_surface_percentage": 0.0, + "output_file_path": "test_shrinkwrap_timeout.prt", + "output_type": "solid_surface", + "ignore_quilts": True, + "ignore_skeleton": True, + "assign_mass_properties": False, + "preset": "balanced", + "timeout_seconds": timeout_seconds # 使用动态超时 + } + + headers = { + "Content-Type": "application/json" + } + + print(f"测试shrinkwrap接口,超时设置: {timeout_seconds}秒") + print(f"URL: {url}") + print(f"请求数据: {json.dumps(test_data, indent=2, ensure_ascii=False)}") + + try: + start_time = time.time() + response = requests.post(url, json=test_data, headers=headers, timeout=timeout_seconds+10) + end_time = time.time() + + print(f"请求耗时: {end_time - start_time:.2f}秒") + print(f"HTTP状态码: {response.status_code}") + print(f"响应内容: {response.text}") + + if response.status_code == 200: + print("✓ 请求成功") + return True + elif response.status_code == 504: + print("✓ 超时处理正常") + return True + else: + print(f"✗ 请求失败: {response.status_code}") + return False + + except requests.exceptions.Timeout: + print("✗ HTTP客户端超时") + return False + except requests.exceptions.ConnectionError: + print("✗ 连接失败,请确保DLL服务正在运行") + return False + except Exception as e: + print(f"✗ 请求异常: {e}") + return False + +def test_different_timeouts(): + """ + 测试不同的超时设置 + """ + print("=== 测试不同超时设置 ===\n") + + # 测试各种超时值 + test_cases = [ + {"timeout": 15, "desc": "短超时测试"}, + {"timeout": 30, "desc": "默认超时测试"}, + {"timeout": 120, "desc": "长超时测试"}, + {"timeout": 5, "desc": "极短超时测试(应被限制为10秒)"}, + {"timeout": 400, "desc": "超长超时测试(应被限制为300秒)"} + ] + + results = [] + for case in test_cases: + print(f"--- {case['desc']} ---") + success = test_shrinkwrap_timeout(case['timeout']) + results.append({"case": case['desc'], "success": success}) + print() + time.sleep(2) # 间隔等待 + + print("=== 测试结果汇总 ===") + for result in results: + status = "✓" if result['success'] else "✗" + print(f"{status} {result['case']}") + +if __name__ == "__main__": + if len(sys.argv) > 1: + try: + timeout = int(sys.argv[1]) + test_shrinkwrap_timeout(timeout) + except ValueError: + print("参数错误,请输入有效的超时秒数") + sys.exit(1) + else: + test_different_timeouts() \ No newline at end of file diff --git a/x64/Debug/MFCCreoDll.dll b/x64/Debug/MFCCreoDll.dll index 0dcf14f..9001a8a 100644 Binary files a/x64/Debug/MFCCreoDll.dll and b/x64/Debug/MFCCreoDll.dll differ diff --git a/x64/Debug/MFCCreoDll.pdb b/x64/Debug/MFCCreoDll.pdb index 4fc8616..59a8824 100644 Binary files a/x64/Debug/MFCCreoDll.pdb and b/x64/Debug/MFCCreoDll.pdb differ