error C2371: “Dt_RECORD_HighLowBeamInfos_FC”: 重定义;不同的基类型

objfusn代码里面引用的两个头文件,有些结构体定义了两遍,导致编译时报错,那么只要注释掉一个定义结构体的代码就可以了。

在这里插入图片描述
编译objfusn时,当前在workspace里面的结构体(bus),会影响生成的可执行文件

3395 [Pipeline] sh 3396 + python script/stage/datasend.py -report=report_checkstyle.json,report_detekt.json,report_coverity.json,report_lint.json,report_findbugs.json,report_linescan.json,report_sonarscan.json,report_oppocheck.json,report_ca_scan.json,report_oppocheck.json,report_coverity.json,report_lint.json,report_ca_scan.json -autoscore=false 3397 [2025-11-18 10:56:50,086]: {u'ca_scan': {u'checkvalue': 3, u'errormessage': u'\u5fc5\u89e3\u95ee\u9898\u6570\uff1a\u81f4\u547d-P0(0\uff09\u3001\u4e25\u91cd-P1(3)\n\u8be6\u60c5\u53ef\u89c1: https://ca-ee.oppoer.me/t/JxoUjhqNd7Q/p/VIRTUAL-OPLUS-ANDROID-OPEN_PUB/code-analysis/repos/583/question-lists/access?projectId=412852&ordering=-ci_time&branch=b%2Fmaster&state=1&severity=1%2C2', u'review_lable': u'code-check', u'rule_tt_msg': u'', u'result': u'-1', u'correctionguide': u'https://odocs.myoas.com/docs/DT4Ewm9l35QWY8M5/', u'review_acount': u'oppo_codecheck', u'engineer': u'', u'rule_tt_reviewers': u'', u'review_score': u'-1'}, u'sonar_scan': {u'checkvalue': 0, u'errormessage': u'\u5f53\u524d\u4ed3\u5e93\u5df2\u5207CA_SCAN,\u8be5\u626b\u63cf\u5f15\u64ce\u5df2\u5728CA_SCAN\u4e2d\u96c6\u6210\uff0c\u8df3\u8fc7', u'review_lable': u'code-check', u'rule_tt_msg': u'', u'result': u'1', u'correctionguide': u'', u'review_acount': u'oppo_codecheck', u'engineer': u'', u'rule_tt_reviewers': u'', u'review_score': u'1'}, u'detekt': {u'checkvalue': 0, u'errormessage': u'\u5f53\u524d\u4ed3\u5e93\u5df2\u5207CA_SCAN,\u8be5\u626b\u63cf\u5f15\u64ce\u5df2\u5728CA_SCAN\u4e2d\u96c6\u6210\uff0c\u8df3\u8fc7', u'review_lable': u'code-check', u'rule_tt_msg': u'', u'result': u'1', u'correctionguide': u'', u'review_acount': u'oppo_codecheck', u'engineer': u'', u'rule_tt_reviewers': u'', u'review_score': u'1'}, u'checkstyle': {u'checkvalue': 0, u'errormessage': u'\u5f53\u524d\u4ed3\u5e93\u5df2\u5207CA_SCAN,\u8be5\u626b\u63cf\u5f15\u64ce\u5df2\u5728CA_SCAN\u4e2d\u96c6\u6210\uff0c\u8df3\u8fc7', u'review_lable': u'code-check', u'rule_tt_msg': u'', u'result': u'1', u'correctionguide': u'', u'review_acount': u'oppo_codecheck', u'engineer': u'', u'rule_tt_reviewers': u'', u'review_score': u'1'}, u'coverity': {u'checkvalue': u'0:0', u'errormessage': u'Coverity Check Pass!', u'review_lable': u'code-check', u'rule_tt_msg': u'', u'result': u'1', u'correctionguide': u'\n', u'review_acount': u'oppo_codecheck', u'engineer': u'Code Quality service already included in ITSM. If there is any issues, pls contact IT6000 for consultation error report.', u'rule_tt_reviewers': u'', u'review_score': u'1'}, u'lint': {u'checkvalue': 0, u'errormessage': u'\u68c0\u67e5\u7ed3\u679c\u65e0error; warning\u4e3a1482\u4e2a, warning\u5f53\u524d\u4e0d\u8fdb\u884c\u95e8\u7981\u5361\u63a7. \u8be6\u60c5\u89c1:http://report.codegate.scm.myoas.com/codecheck/2025-11-18/9b27b686-aa82-40f8-8a85-9f001283e880/lint/', u'review_lable': u'code-check', u'rule_tt_msg': u'', u'result': u'1', u'correctionguide': u'\u6307\u5bfc\u6587\u6863: https://odocs.myoas.com/docs/913JVW6yM0H4gG3E \n\u76f8\u5173\u53d1\u6587http://mo.myoas.com/Auditing/Auditing/Index?AT=8&FIC=220113155613226972&Title=\u5173\u4e8eAndroid Lint\u68c0\u6d4b\u80fd\u529b\u52a0\u5f3a\u901a\u77e5&RF=2', u'review_acount': u'oppo_codecheck', u'engineer': u'Code Quality service already included in ITSM. If there is any issues, pls contact IT6000 for consultation error report.', u'rule_tt_reviewers': u'', u'review_score': u'1'}, u'findbugs': {u'checkvalue': 0, u'errormessage': u'\u5f53\u524d\u4ed3\u5e93\u5df2\u5207CA_SCAN,\u8be5\u626b\u63cf\u5f15\u64ce\u5df2\u5728CA_SCAN\u4e2d\u96c6\u6210\uff0c\u8df3\u8fc7', u'review_lable': u'code-check', u'rule_tt_msg': u'', u'result': u'1', u'correctionguide': u'', u'review_acount': u'oppo_codecheck', u'engineer': u'', u'rule_tt_reviewers': u'', u'review_score': u'1'}, u'oppocheck': {u'checkvalue': u'oppocheck', u'errormessage': u'', u'review_lable': u'oppo-check', u'rule_tt_msg': u'', u'result': u'1', u'correctionguide': u'', u'review_acount': u'oppo_codecheck', u'engineer': u'', u'rule_tt_reviewers': u'', u'review_score': u'0'}, u'junit_coverage': {u'checkvalue': 0, u'errormessage': u'\u975e\u5e94\u7528\u4ed3\u5e93\u6216\u975e\u5168\u91cf\uff0c\u65e0\u6cd5\u626b\u63cf', u'review_lable': u'code-check', u'rule_tt_msg': u'', u'result': u'1', u'correctionguide': u'', u'review_acount': u'oppo_codecheck', u'engineer': u'', u'rule_tt_reviewers': u'', u'review_score': u'1'}} 3398 [2025-11-18 10:56:50,093]: Starting new HTTPS connection (1): panter.myoas.com 3399 [2025-11-18 10:56:50,126]: update client_trigger data of id: 11649928, issues_count: 3, department: /外部合作伙伴/ODM/ 3400 [2025-11-18 10:56:50,131]: Starting new HTTPS connection (1): panter.myoas.com 3401 args.reportreport_checkstyle.json,report_detekt.json,report_coverity.json,report_lint.json,report_findbugs.json,report_linescan.json,report_sonarscan.json,report_oppocheck.json,report_ca_scan.json,report_oppocheck.json,report_coverity.json,report_lint.json,report_ca_scan.json 3402 args.autoscore false 3403 host=codecheck-quality-pro.mysql.oppo.local, port=33066, user=codegate, db=db_codegate 3404 Connect database success 3405 Start to get department path from email: v-huanghaijie@vanyol.com 3406 Search exemption record for change: http://gerrit.rom.scm.adc.com:8080/c/oplus/app/CommercialEngineerMode/+/2118309, patch_set_num: 2 3407 {"status": "1", "autoscore": "false", "build_url": "https://noah.myoas.com/micro-app/pipeline-app/xbuild/log/index?id=9b27b686-aa82-40f8-8a85-9f001283e880", "checkresult": "failed", "msg": "", "data": {"ca_scan": {"checkvalue": 3, "errormessage": "\u5fc5\u89e3\u95ee\u9898\u6570\uff1a\u81f4\u547d-P0(0\uff09\u3001\u4e25\u91cd-P1(3)\n\u8be6\u60c5\u53ef\u89c1: https://ca-ee.oppoer.me/t/JxoUjhqNd7Q/p/VIRTUAL-OPLUS-ANDROID-OPEN_PUB/code-analysis/repos/583/question-lists/access?projectId=412852&ordering=-ci_time&branch=b%2Fmaster&state=1&severity=1%2C2", "review_lable": "code-check", "rule_tt_msg": "", "result": "-1", "correctionguide": "https://odocs.myoas.com/docs/DT4Ewm9l35QWY8M5/", "review_acount": "oppo_codecheck", "engineer": "", "rule_tt_reviewers": "", "review_score": "-1"}, "sonar_scan": {"checkvalue": 0, "errormessage": "\u5f53\u524d\u4ed3\u5e93\u5df2\u5207CA_SCAN,\u8be5\u626b\u63cf\u5f15\u64ce\u5df2\u5728CA_SCAN\u4e2d\u96c6\u6210\uff0c\u8df3\u8fc7", "review_lable": "code-check", "rule_tt_msg": "", "result": "1", "correctionguide": "", "review_acount": "oppo_codecheck", "engineer": "", "rule_tt_reviewers": "", "review_score": "1"}, "detekt": {"checkvalue": 0, "errormessage": "\u5f53\u524d\u4ed3\u5e93\u5df2\u5207CA_SCAN,\u8be5\u626b\u63cf\u5f15\u64ce\u5df2\u5728CA_SCAN\u4e2d\u96c6\u6210\uff0c\u8df3\u8fc7", "review_lable": "code-check", "rule_tt_msg": "", "result": "1", "correctionguide": "", "review_acount": "oppo_codecheck", "engineer": "", "rule_tt_reviewers": "", "review_score": "1"}, "checkstyle": {"checkvalue": 0, "errormessage": "\u5f53\u524d\u4ed3\u5e93\u5df2\u5207CA_SCAN,\u8be5\u626b\u63cf\u5f15\u64ce\u5df2\u5728CA_SCAN\u4e2d\u96c6\u6210\uff0c\u8df3\u8fc7", "review_lable": "code-check", "rule_tt_msg": "", "result": "1", "correctionguide": "", "review_acount": "oppo_codecheck", "engineer": "", "rule_tt_reviewers": "", "review_score": "1"}, "coverity": {"checkvalue": "0:0", "errormessage": "Coverity Check Pass!", "review_lable": "code-check", "rule_tt_msg": "", "result": "1", "correctionguide": "\n", "review_acount": "oppo_codecheck", "engineer": "Code Quality service already included in ITSM. If there is any issues, pls contact IT6000 for consultation error report.", "rule_tt_reviewers": "", "review_score": "1"}, "lint": {"checkvalue": 0, "errormessage": "\u68c0\u67e5\u7ed3\u679c\u65e0error; warning\u4e3a1482\u4e2a, warning\u5f53\u524d\u4e0d\u8fdb\u884c\u95e8\u7981\u5361\u63a7. \u8be6\u60c5\u89c1:http://report.codegate.scm.myoas.com/codecheck/2025-11-18/9b27b686-aa82-40f8-8a85-9f001283e880/lint/", "review_lable": "code-check", "rule_tt_msg": "", "result": "1", "correctionguide": "\u6307\u5bfc\u6587\u6863: https://odocs.myoas.com/docs/913JVW6yM0H4gG3E \n\u76f8\u5173\u53d1\u6587http://mo.myoas.com/Auditing/Auditing/Index?AT=8&FIC=220113155613226972&Title=\u5173\u4e8eAndroid Lint\u68c0\u6d4b\u80fd\u529b\u52a0\u5f3a\u901a\u77e5&RF=2", "review_acount": "oppo_codecheck", "engineer": "Code Quality service already included in ITSM. If there is any issues, pls contact IT6000 for consultation error report.", "rule_tt_reviewers": "", "review_score": "1"}, "findbugs": {"checkvalue": 0, "errormessage": "\u5f53\u524d\u4ed3\u5e93\u5df2\u5207CA_SCAN,\u8be5\u626b\u63cf\u5f15\u64ce\u5df2\u5728CA_SCAN\u4e2d\u96c6\u6210\uff0c\u8df3\u8fc7", "review_lable": "code-check", "rule_tt_msg": "", "result": "1", "correctionguide": "", "review_acount": "oppo_codecheck", "engineer": "", "rule_tt_reviewers": "", "review_score": "1"}, "oppocheck":[2025-11-18 10:56:50,189]: Starting new HTTPS connection (1): cqc-ee.oppoer.me 3408 {"checkvalue": "oppocheck", "errormessage": "", "review_lable": "oppo-check", "rule_tt_msg": "", "result": "1", "correctionguide": "", "review_acount": "oppo_codecheck", "engineer": "", "rule_tt_reviewers": "", "review_score": "0"}, "junit_coverage": {"checkvalue": 0, "errormessage": "\u975e\u5e94\u7528\u4ed3\u5e93\u6216\u975e\u5168\u91cf\uff0c\u65e0\u6cd5\u626b\u63cf", "review_lable": "code-check", "rule_tt_msg": "", "result": "1", "correctionguide": "", "review_acount": "oppo_codecheck", "engineer": "", "rule_tt_reviewers": "", "review_score": "1"}}} 3409 Update CQC build status success 3410 [Pipeline] echo 3411 return exitValue :0 3412 [Pipeline] sh 3413 + python script/stage/collect_data.py false report_checkstyle.json,report_detekt.json,report_coverity.json,report_lint.json,report_findbugs.json,report_linescan.json,report_sonarscan.json,report_oppocheck.json,report_ca_scan.json,report_oppocheck.json,report_coverity.json,report_lint.json,report_ca_scan.json 3414 [2025-11-18 10:56:50,374]: ========================= ALL JSON INFO ========================= 3415 [2025-11-18 10:56:50,374]: {'Project': 'oplus/app/CommercialEngineerMode', 'PipelineCategory': '', 'stagedata': [{u'checkstyle': {u'checkvalue': 0, u'errormessage': u'\u5f53\u524d\u4ed3\u5e93\u5df2\u5207CA_SCAN,\u8be5\u626b\u63cf\u5f15\u64ce\u5df2\u5728CA_SCAN\u4e2d\u96c6\u6210\uff0c\u8df3\u8fc7', u'review_lable': u'code-check', u'rule_tt_msg': u'', u'result': u'1', u'correctionguide': u'', u'review_acount': u'oppo_codecheck', u'engineer': u'', u'rule_tt_reviewers': u'', u'review_score': u'1'}}, {u'detekt': {u'checkvalue': 0, u'errormessage': u'\u5f53\u524d\u4ed3\u5e93\u5df2\u5207CA_SCAN,\u8be5\u626b\u63cf\u5f15\u64ce\u5df2\u5728CA_SCAN\u4e2d\u96c6\u6210\uff0c\u8df3\u8fc7', u'review_lable': u'code-check', u'rule_tt_msg': u'', u'result': u'1', u'correctionguide': u'', u'review_acount': u'oppo_codecheck', u'engineer': u'', u'rule_tt_reviewers': u'', u'review_score': u'1'}}, {u'coverity': {u'checkvalue': u'0:0', u'errormessage': u'Coverity Check Pass!', u'review_lable': u'code-check', u'rule_tt_msg': u'', u'result': u'1', u'correctionguide': u'\n', u'review_acount': u'oppo_codecheck', u'engineer': u'Code Quality service already included in ITSM. If there is any issues, pls contact IT6000 for consultation error report.', u'rule_tt_reviewers': u'', u'review_score': u'1'}}, {u'lint': {u'checkvalue': 0, u'errormessage': u'\u68c0\u67e5\u7ed3\u679c\u65e0error; warning\u4e3a1482\u4e2a, warning\u5f53\u524d\u4e0d\u8fdb\u884c\u95e8\u7981\u5361\u63a7. \u8be6\u60c5\u89c1:http://report.codegate.scm.myoas.com/codecheck/2025-11-18/9b27b686-aa82-40f8-8a85-9f001283e880/lint/', u'review_lable': u'code-check', u'rule_tt_msg': u'', u'result': u'1', u'correctionguide': u'\u6307\u5bfc\u6587\u6863: https://odocs.myoas.com/docs/913JVW6yM0H4gG3E \n\u76f8\u5173\u53d1\u6587http://mo.myoas.com/Auditing/Auditing/Index?AT=8&FIC=220113155613226972&Title=\u5173\u4e8eAndroid Lint\u68c0\u6d4b\u80fd\u529b\u52a0\u5f3a\u901a\u77e5&RF=2', u'review_acount': u'oppo_codecheck', u'engineer': u'Code Quality service already included in ITSM. If there is any issues, pls contact IT6000 for consultation error report.', u'rule_tt_reviewers': u'', u'review_score': u'1'}}, {u'findbugs': {u'checkvalue': 0, u'errormessage': u'\u5f53\u524d\u4ed3\u5e93\u5df2\u5207CA_SCAN,\u8be5\u626b\u63cf\u5f15\u64ce\u5df2\u5728CA_SCAN\u4e2d\u96c6\u6210\uff0c\u8df3\u8fc7', u'review_lable': u'code-check', u'rule_tt_msg': u'', u'result': u'1', u'correctionguide': u'', u'review_acount': u'oppo_codecheck', u'engineer': u'', u'rule_tt_reviewers': u'', u'review_score': u'1'}}, {u'junit_coverage': {u'checkvalue': 0, u'errormessage': u'\u975e\u5e94\u7528\u4ed3\u5e93\u6216\u975e\u5168\u91cf\uff0c\u65e0\u6cd5\u626b\u63cf', u'review_lable': u'code-check', u'rule_tt_msg': u'', u'result': u'1', u'correctionguide': u'', u'review_acount': u'oppo_codecheck', u'engineer': u'', u'rule_tt_reviewers': u'', u'review_score': u'1'}}, {u'sonar_scan': {u'checkvalue': 0, u'errormessage': u'\u5f53\u524d\u4ed3\u5e93\u5df2\u5207CA_SCAN,\u8be5\u626b\u63cf\u5f15\u64ce\u5df2\u5728CA_SCAN\u4e2d\u96c6\u6210\uff0c\u8df3\u8fc7', u'review_lable': u'code-check', u'rule_tt_msg': u'', u'result': u'1', u'correctionguide': u'', u'review_acount': u'oppo_codecheck', u'engineer': u'', u'rule_tt_reviewers': u'', u'review_score': u'1'}}, {u'oppocheck': {u'checkvalue': u'oppocheck', u'errormessage': u'', u'review_lable': u'oppo-check', u'rule_tt_msg': u'', u'result': u'1', u'correctionguide': u'', u'review_acount': u'oppo_codecheck', u'engineer': u'', u'rule_tt_reviewers': u'', u'review_score': u'0'}}, [{u'ca_scan': {u'checkvalue': 3, u'errormessage': u'\u5fc5\u89e3\u95ee\u9898\u6570\uff1a\u81f4\u547d-P0(0\uff09\u3001\u4e25\u91cd-P1(3)\n\u8be6\u60c5\u53ef\u89c1: https://ca-ee.oppoer.me/t/JxoUjhqNd7Q/p/VIRTUAL-OPLUS-ANDROID-OPEN_PUB/code-analysis/repos/583/question-lists/access?projectId=412852&ordering=-ci_time&branch=b%2Fmaster&state=1&severity=1%2C2', u'review_lable': u'code-check', u'rule_tt_msg': u'', u'result': u'-1', u'correctionguide': u'https://odocs.myoas.com/docs/DT4Ewm9l35QWY8M5/', u'review_acount': u'oppo_codecheck', u'engineer': u'', u'rule_tt_reviewers': u'', u'review_score': u'-1'}}], {u'oppocheck': {u'checkvalue': u'oppocheck', u'errormessage': u'', u'review_lable': u'oppo-check', u'rule_tt_msg': u'', u'result': u'1', u'correctionguide': u'', u'review_acount': u'oppo_codecheck', u'engineer': u'', u'rule_tt_reviewers': u'', u'review_score': u'0'}}, {u'coverity': {u'checkvalue': u'0:0', u'errormessage': u'Coverity Check Pass!', u'review_lable': u'code-check', u'rule_tt_msg': u'', u'result': u'1', u'correctionguide': u'\n', u'review_acount': u'oppo_codecheck', u'engineer': u'Code Quality service already included in ITSM. If there is any issues, pls contact IT6000 for consultation error report.', u'rule_tt_reviewers': u'', u'review_score': u'1'}}, {u'lint': {u'checkvalue': 0, u'errormessage': u'\u68c0\u67e5\u7ed3\u679c\u65e0error; warning\u4e3a1482\u4e2a, warning\u5f53\u524d\u4e0d\u8fdb\u884c\u95e8\u7981\u5361\u63a7. \u8be6\u60c5\u89c1:http://report.codegate.scm.myoas.com/codecheck/2025-11-18/9b27b686-aa82-40f8-8a85-9f001283e880/lint/', u'review_lable': u'code-check', u'rule_tt_msg': u'', u'result': u'1', u'correctionguide': u'\u6307\u5bfc\u6587\u6863: https://odocs.myoas.com/docs/913JVW6yM0H4gG3E \n\u76f8\u5173\u53d1\u6587http://mo.myoas.com/Auditing/Auditing/Index?AT=8&FIC=220113155613226972&Title=\u5173\u4e8eAndroid Lint\u68c0\u6d4b\u80fd\u529b\u52a0\u5f3a\u901a\u77e5&RF=2', u'review_acount': u'oppo_codecheck', u'engineer': u'Code Quality service already included in ITSM. If there is any issues, pls contact IT6000 for consultation error report.', u'rule_tt_reviewers': u'', u'review_score': u'1'}}, [{u'ca_scan': {u'checkvalue': 3, u'errormessage': u'\u5fc5\u89e3\u95ee\u9898\u6570\uff1a\u81f4\u547d-P0(0\uff09\u3001\u4e25\u91cd-P1(3)\n\u8be6\u60c5\u53ef\u89c1: https://ca-ee.oppoer.me/t/JxoUjhqNd7Q/p/VIRTUAL-OPLUS-ANDROID-OPEN_PUB/code-analysis/repos/583/question-lists/access?projectId=412852&ordering=-ci_time&branch=b%2Fmaster&state=1&severity=1%2C2', u'review_lable': u'code-check', u'rule_tt_msg': u'', u'result': u'-1', u'correctionguide': u'https://odocs.myoas.com/docs/DT4Ewm9l35QWY8M5/', u'review_acount': u'oppo_codecheck', u'engineer': u'', u'rule_tt_reviewers': u'', u'review_score': u'-1'}}]], 'PatchUrl': 'http://gerrit.rom.scm.adc.com:8080/c/oplus/app/CommercialEngineerMode/+/2118309', 'BuildNumber': '449723', 'GERRIT_REFSPEC': 'refs/changes/09/2118309/2', 'BuildUrl': 'https://noah.myoas.com/micro-app/pipeline-app/xbuild/log/index?id=9b27b686-aa82-40f8-8a85-9f001283e880', 'Branch': 'b/master', 'FrameError': 0, 'CQC_ID': '7734f9c0-c429-11f0-b374-fa1623f58112', 'EMAIL': 'v-huanghaijie@vanyol.com', 'JOB_NAME': 'Code_Quailiy_Gate_Pipeline_V2.0', 'GerritServer': 'gerrit.rom.scm.adc.com'} 3416 [Pipeline] archiveArtifacts 3417 Archiving artifacts 3418 [Pipeline] sh 3419 + /mnt/buildtools2/pkg/qct/software/python/3.8.2/bin/python3 script/CQG_V3/stage/trigger_collect_build_info_job.py http://10.234.45.229:8089/jenkins/ 449723 http://10.234.45.229:8089/jenkins/job/Code_Quailiy_Gate_Pipeline_V2.0/449723/artifact/outfile.txt 3420 [Pipeline] echo 3421 report_checkstyle.json,report_detekt.json,report_coverity.json,report_lint.json,report_findbugs.json,report_linescan.json,report_sonarscan.json,report_oppocheck.json,report_ca_scan.json,report_oppocheck.json,report_coverity.json,report_lint.json,report_ca_scan.json 3422 [Pipeline] cleanWs 3423 [WS-CLEANUP] Deleting project workspace... 3424 [WS-CLEANUP] Deferred wipeout is used... 3425 [WS-CLEANUP] done 3426 [Pipeline] } 3427 [Pipeline] // node 3428
11-19
host=codecheck-quality-pro.mysql.oppo.local, port=33066, user=codegate, db=db_codegate 3358 Connect database success 3359 Start to get department path from email: v-huanghaijie@vanyol.com 3360 Search exemption record for change: http://gerrit.rom.scm.adc.com:8080/c/oplus/app/CommercialEngineerMode/+/2118309, patch_set_num: 3 3361 {"status": "1", "autoscore": "false", "build_url": "https://noah.myoas.com/micro-app/pipeline-app/xbuild/log/index?id=88b02455-cf39-42f5-b0c0-21d94a3b5716", "checkresult": "failed", "msg": "", "data": {"lint": {"checkvalue": 0, "errormessage": "\u68c0\u67e5\u7ed3\u679c\u65e0error; warning\u4e3a1482\u4e2a, warning\u5f53\u524d\u4e0d\u8fdb\u884c\u95e8\u7981\u5361\u63a7. \u8be6\u60c5\u89c1:http://report.codegate.scm.myoas.com/codecheck/2025-11-18/88b02455-cf39-42f5-b0c0-21d94a3b5716/lint/", "review_lable": "code-check", "rule_tt_msg": "", "result": "1", "correctionguide": "\u6307\u5bfc\u6587\u6863: https://odocs.myoas.com/docs/913JVW6yM0H4gG3E \n\u76f8\u5173\u53d1\u6587http://mo.myoas.com/Auditing/Auditing/Index?AT=8&FIC=220113155613226972&Title=\u5173\u4e8eAndroid Lint\u68c0\u6d4b\u80fd\u529b\u52a0\u5f3a\u901a\u77e5&RF=2", "review_acount": "oppo_codecheck", "engineer": "Code Quality service already included in ITSM. If there is any issues, pls contact IT6000 for consultation error report.", "rule_tt_reviewers": "", "review_score": "1"}, "checkstyle": {"checkvalue": 0, "errormessage": "\u5f53\u524d\u4ed3\u5e93\u5df2\u5207CA_SCAN,\u8be5\u626b\u63cf\u5f15\u64ce\u5df2\u5728CA_SCAN\u4e2d\u96c6\u6210\uff0c\u8df3\u8fc7", "review_lable": "code-check", "rule_tt_msg": "", "result": "1", "correctionguide": "", "review_acount": "oppo_codecheck", "engineer": "", "rule_tt_reviewers": "", "review_score": "1"}, "junit_coverage": {"checkvalue": 0, "errormessage": "\u975e\u5e94\u7528\u4ed3\u5e93\u6216\u975e\u5168\u91cf\uff0c\u65e0\u6cd5\u626b\u63cf", "review_lable": "code-check", "rule_tt_msg": "", "result": "1", "correctionguide": "", "review_acount": "oppo_codecheck", "engineer": "", "rule_tt_reviewers": "", "review_score": "1"}, "detekt": {"checkvalue": 0, "errormessage": "\u5f53\u524d\u4ed3\u5e93\u5df2\u5207CA_SCAN,\u8be5\u626b\u63cf\u5f15\u64ce\u5df2\u5728CA_SCAN\u4e2d\u96c6\u6210\uff0c\u8df3\u8fc7", "review_lable": "code-check", "rule_tt_msg": "", "result": "1", "correctionguide": "", "review_acount": "oppo_codecheck", "engineer": "", "rule_tt_reviewers": "", "review_score": "1"}, "sonar_scan": {"checkvalue": 0, "errormessage": "\u5f53\u524d\u4ed3\u5e93\u5df2\u5207CA_SCAN,\u8be5\u626b\u63cf\u5f15\u64ce\u5df2\u5728CA_SCAN\u4e2d\u96c6\u6210\uff0c\u8df3\u8fc7", "review_lable": "code-check", "rule_tt_msg": "", "result": "1", "correctionguide": "", "review_acount": "oppo_codecheck", "engineer": "", "rule_tt_reviewers": "", "review_score": "1"}, "oppocheck": {"checkvalue": "oppocheck", "errormessage": "", "review_lable": "oppo-check", "rule_tt_msg": "", "result": "1", "correctionguide": "", "review_acount": "oppo_codecheck", "engineer": "", "rule_tt_reviewers": "", "review_score": "0"}, "build": {"checkvalue": "-1", "errormessage": "oppo_codecheck build failed, please check [oppobuild] log to see the error info, if [oppobuild] is success, then contact us!", "review_lable": "code-check", "rule_tt_msg": "", "result": "-1", "correctionguide": "oppo_codecheck build failed, please check [oppobuild] log to see the error info, if [oppobuild] is success, then contact us!", "review_acount": "oppo_codecheck", "engineer": "Code Quality service already included in ITSM. If there is any issues, pls contact IT6000 for consultation error report.", "rule_tt_reviewers": "", "review_score": "-1"}, "coverity": {"checkvalue": 0, "errormessage": "\u7f16\u8bd1\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u7f16\u8bd1\u65e5\u5fd7: https://noah.myoas.com/micro-app/pipeline-app/xb[2025-11-18 15:38:18,340]: Starting new HTTPS connection (1): cqc-ee.oppoer.me 3362 uild/log/index?id=88b02455-cf39-42f5-b0c0-21d94a3b5716", "review_lable": "code-check", "rule_tt_msg": "", "result": "-1", "correctionguide": "", "review_acount": "oppo_codecheck", "engineer": "", "rule_tt_reviewers": "", "review_score": "-1"}, "findbugs": {"checkvalue": 0, "errormessage": "\u5f53\u524d\u4ed3\u5e93\u5df2\u5207CA_SCAN,\u8be5\u626b\u63cf\u5f15\u64ce\u5df2\u5728CA_SCAN\u4e2d\u96c6\u6210\uff0c\u8df3\u8fc7", "review_lable": "code-check", "rule_tt_msg": "", "result": "1", "correctionguide": "", "review_acount": "oppo_codecheck", "engineer": "", "rule_tt_reviewers": "", "review_score": "1"}, "ca_scan": {"checkvalue": 1, "errormessage": "\u7f16\u8bd1\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u7f16\u8bd1\u65e5\u5fd7: https://noah.myoas.com/micro-app/pipeline-app/xbuild/log/index?id=88b02455-cf39-42f5-b0c0-21d94a3b5716", "review_lable": "code-check", "rule_tt_msg": "", "result": "-1", "correctionguide": "https://odocs.myoas.com/docs/DT4Ewm9l35QWY8M5/", "review_acount": "oppo_codecheck", "engineer": "", "rule_tt_reviewers": "", "review_score": "-1"}}} 3363 Update CQC build status success 3364 [Pipeline] echo 3365 return exitValue :0 3366 [Pipeline] sh 3367 + python script/stage/collect_data.py false report_checkstyle.json,report_detekt.json,report_coverity.json,report_lint.json,report_findbugs.json,report_linescan.json,report_sonarscan.json,report_oppocheck.json,report_ca_scan.json,report_oppocheck.json,report_build.json,report_lint.json,report_ca_scan.json 3368 [2025-11-18 15:38:18,727]: ========================= ALL JSON INFO ========================= 3369 [2025-11-18 15:38:18,727]: {'Project': 'oplus/app/CommercialEngineerMode', 'PipelineCategory': '', 'stagedata': [{u'checkstyle': {u'checkvalue': 0, u'errormessage': u'\u5f53\u524d\u4ed3\u5e93\u5df2\u5207CA_SCAN,\u8be5\u626b\u63cf\u5f15\u64ce\u5df2\u5728CA_SCAN\u4e2d\u96c6\u6210\uff0c\u8df3\u8fc7', u'review_lable': u'code-check', u'rule_tt_msg': u'', u'result': u'1', u'correctionguide': u'', u'review_acount': u'oppo_codecheck', u'engineer': u'', u'rule_tt_reviewers': u'', u'review_score': u'1'}}, {u'detekt': {u'checkvalue': 0, u'errormessage': u'\u5f53\u524d\u4ed3\u5e93\u5df2\u5207CA_SCAN,\u8be5\u626b\u63cf\u5f15\u64ce\u5df2\u5728CA_SCAN\u4e2d\u96c6\u6210\uff0c\u8df3\u8fc7', u'review_lable': u'code-check', u'rule_tt_msg': u'', u'result': u'1', u'correctionguide': u'', u'review_acount': u'oppo_codecheck', u'engineer': u'', u'rule_tt_reviewers': u'', u'review_score': u'1'}}, {u'coverity': {u'checkvalue': 0, u'errormessage': u'\u521d\u59cb\u72b6\u6001', u'review_lable': u'code-check', u'rule_tt_msg': u'', u'result': u'-1', u'correctionguide': u'', u'review_acount': u'oppo_codecheck', u'engineer': u'', u'rule_tt_reviewers': u'', u'review_score': u'-1'}}, {u'lint': {u'checkvalue': 0, u'errormessage': u'\u68c0\u67e5\u7ed3\u679c\u65e0error; warning\u4e3a1482\u4e2a, warning\u5f53\u524d\u4e0d\u8fdb\u884c\u95e8\u7981\u5361\u63a7. \u8be6\u60c5\u89c1:http://report.codegate.scm.myoas.com/codecheck/2025-11-18/88b02455-cf39-42f5-b0c0-21d94a3b5716/lint/', u'review_lable': u'code-check', u'rule_tt_msg': u'', u'result': u'1', u'correctionguide': u'\u6307\u5bfc\u6587\u6863: https://odocs.myoas.com/docs/913JVW6yM0H4gG3E \n\u76f8\u5173\u53d1\u6587http://mo.myoas.com/Auditing/Auditing/Index?AT=8&FIC=220113155613226972&Title=\u5173\u4e8eAndroid Lint\u68c0\u6d4b\u80fd\u529b\u52a0\u5f3a\u901a\u77e5&RF=2', u'review_acount': u'oppo_codecheck', u'engineer': u'Code Quality service already included in ITSM. If there is any issues, pls contact IT6000 for consultation error report.', u'rule_tt_reviewers': u'', u'review_score': u'1'}}, {u'findbugs': {u'checkvalue': 0, u'errormessage': u'\u5f53\u524d\u4ed3\u5e93\u5df2\u5207CA_SCAN,\u8be5\u626b\u63cf\u5f15\u64ce\u5df2\u5728CA_SCAN\u4e2d\u96c6\u6210\uff0c\u8df3\u8fc7', u'review_lable': u'code-check', u'rule_tt_msg': u'', u'result': u'1', u'correctionguide': u'', u'review_acount': u'oppo_codecheck', u'engineer': u'', u'rule_tt_reviewers': u'', u'review_score': u'1'}}, {u'junit_coverage': {u'checkvalue': 0, u'errormessage': u'\u975e\u5e94\u7528\u4ed3\u5e93\u6216\u975e\u5168\u91cf\uff0c\u65e0\u6cd5\u626b\u63cf', u'review_lable': u'code-check', u'rule_tt_msg': u'', u'result': u'1', u'correctionguide': u'', u'review_acount': u'oppo_codecheck', u'engineer': u'', u'rule_tt_reviewers': u'', u'review_score': u'1'}}, {u'sonar_scan': {u'checkvalue': 0, u'errormessage': u'\u5f53\u524d\u4ed3\u5e93\u5df2\u5207CA_SCAN,\u8be5\u626b\u63cf\u5f15\u64ce\u5df2\u5728CA_SCAN\u4e2d\u96c6\u6210\uff0c\u8df3\u8fc7', u'review_lable': u'code-check', u'rule_tt_msg': u'', u'result': u'1', u'correctionguide': u'', u'review_acount': u'oppo_codecheck', u'engineer': u'', u'rule_tt_reviewers': u'', u'review_score': u'1'}}, {u'oppocheck': {u'checkvalue': u'oppocheck', u'errormessage': u'', u'review_lable': u'oppo-check', u'rule_tt_msg': u'', u'result': u'1', u'correctionguide': u'', u'review_acount': u'oppo_codecheck', u'engineer': u'', u'rule_tt_reviewers': u'', u'review_score': u'0'}}, [{u'ca_scan': {u'checkvalue': 1, u'errormessage': u'\u5fc5\u89e3\u95ee\u9898\u6570\uff1a\u81f4\u547d-P0(0\uff09\u3001\u4e25\u91cd-P1(1)\n\u8be6\u60c5\u53ef\u89c1: https://ca-ee.oppoer.me/t/JxoUjhqNd7Q/p/VIRTUAL-OPLUS-ANDROID-OPEN_PUB/code-analysis/repos/583/question-lists/access?projectId=412852&ordering=-ci_time&branch=b%2Fmaster&state=1&severity=1%2C2', u'review_lable': u'code-check', u'rule_tt_msg': u'', u'result': u'-1', u'correctionguide': u'https://odocs.myoas.com/docs/DT4Ewm9l35QWY8M5/', u'review_acount': u'oppo_codecheck', u'engineer': u'', u'rule_tt_reviewers': u'', u'review_score': u'-1'}}], {u'oppocheck': {u'checkvalue': u'oppocheck', u'errormessage': u'', u'review_lable': u'oppo-check', u'rule_tt_msg': u'', u'result': u'1', u'correctionguide': u'', u'review_acount': u'oppo_codecheck', u'engineer': u'', u'rule_tt_reviewers': u'', u'review_score': u'0'}}, {u'build': {u'checkvalue': u'-1', u'errormessage': u'oppo_codecheck build failed, please check [oppobuild] log to see the error info, if [oppobuild] is success, then contact us!', u'review_lable': u'code-check', u'rule_tt_msg': u'', u'result': u'-1', u'correctionguide': u'oppo_codecheck build failed, please check [oppobuild] log to see the error info, if [oppobuild] is success, then contact us!', u'review_acount': u'oppo_codecheck', u'engineer': u'Code Quality service already included in ITSM. If there is any issues, pls contact IT6000 for consultation error report.', u'rule_tt_reviewers': u'', u'review_score': u'-1'}}, {u'lint': {u'checkvalue': 0, u'errormessage': u'\u68c0\u67e5\u7ed3\u679c\u65e0error; warning\u4e3a1482\u4e2a, warning\u5f53\u524d\u4e0d\u8fdb\u884c\u95e8\u7981\u5361\u63a7. \u8be6\u60c5\u89c1:http://report.codegate.scm.myoas.com/codecheck/2025-11-18/88b02455-cf39-42f5-b0c0-21d94a3b5716/lint/', u'review_lable': u'code-check', u'rule_tt_msg': u'', u'result': u'1', u'correctionguide': u'\u6307\u5bfc\u6587\u6863: https://odocs.myoas.com/docs/913JVW6yM0H4gG3E \n\u76f8\u5173\u53d1\u6587http://mo.myoas.com/Auditing/Auditing/Index?AT=8&FIC=220113155613226972&Title=\u5173\u4e8eAndroid Lint\u68c0\u6d4b\u80fd\u529b\u52a0\u5f3a\u901a\u77e5&RF=2', u'review_acount': u'oppo_codecheck', u'engineer': u'Code Quality service already included in ITSM. If there is any issues, pls contact IT6000 for consultation error report.', u'rule_tt_reviewers': u'', u'review_score': u'1'}}, [{u'ca_scan': {u'checkvalue': 1, u'errormessage': u'\u5fc5\u89e3\u95ee\u9898\u6570\uff1a\u81f4\u547d-P0(0\uff09\u3001\u4e25\u91cd-P1(1)\n\u8be6\u60c5\u53ef\u89c1: https://ca-ee.oppoer.me/t/JxoUjhqNd7Q/p/VIRTUAL-OPLUS-ANDROID-OPEN_PUB/code-analysis/repos/583/question-lists/access?projectId=412852&ordering=-ci_time&branch=b%2Fmaster&state=1&severity=1%2C2', u'review_lable': u'code-check', u'rule_tt_msg': u'', u'result': u'-1', u'correctionguide': u'https://odocs.myoas.com/docs/DT4Ewm9l35QWY8M5/', u'review_acount': u'oppo_codecheck', u'engineer': u'', u'rule_tt_reviewers': u'', u'review_score': u'-1'}}]], 'PatchUrl': 'http://gerrit.rom.scm.adc.com:8080/c/oplus/app/CommercialEngineerMode/+/2118309', 'BuildNumber': '447640', 'GERRIT_REFSPEC': 'refs/changes/09/2118309/3', 'BuildUrl': 'https://noah.myoas.com/micro-app/pipeline-app/xbuild/log/index?id=88b02455-cf39-42f5-b0c0-21d94a3b5716', 'Branch': 'b/master', 'FrameError': 0, 'CQC_ID': 'cc14e29e-c450-11f0-9e2c-fa16e5c5d301', 'EMAIL': 'v-huanghaijie@vanyol.com', 'JOB_NAME': 'Code_Quailiy_Gate_Pipeline_V2.0', 'GerritServer': 'gerrit.rom.scm.adc.com'} 3370 [Pipeline] archiveArtifacts 3371 Archiving artifacts 3372 [Pipeline] sh 3373 + /mnt/buildtools2/pkg/qct/software/python/3.8.2/bin/python3 script/CQG_V3/stage/trigger_collect_build_info_job.py http://10.234.15.229:8089/jenkins/ 447640 http://10.234.15.229:8089/jenkins/job/Code_Quailiy_Gate_Pipeline_V2.0/447640/artifact/outfile.txt 3374 [Pipeline] echo 3375 report_checkstyle.json,report_detekt.json,report_coverity.json,report_lint.json,report_findbugs.json,report_linescan.json,report_sonarscan.json,report_oppocheck.json,report_ca_scan.json,report_oppocheck.json,report_build.json,report_lint.json,report_ca_scan.json 3376 [Pipeline] cleanWs 3377 [WS-CLEANUP] Deleting project workspace... 3378 [WS-CLEANUP] Deferred wipeout is used... 3379 [WS-CLEANUP] done 3380 [Pipeline] } 3381 [Pipeline] // node 3382 [Pipeline] } 3383 [Pipeline] // stage 3384 [Pipeline] } 3385 [Pipeline] // node 3386 [Pipeline] End of Pipeline 3387 ERROR: script returned exit code 1 3388 Finished: FAILURE
最新发布
11-19
[ 112.067571][ C3] watchdog: BUG: soft lockup - CPU#3 stuck for 45s! [kswapd0:92] [ 112.067595][ C3] CPU#3 Utilization every 4s during lockup: [ 112.067604][ C3] #1: 99% system, 0% softirq, 2% hardirq, 0% idle [ 112.067616][ C3] #2: 100% system, 0% softirq, 2% hardirq, 0% idle [ 112.067626][ C3] #3: 99% system, 0% softirq, 2% hardirq, 0% idle [ 112.067637][ C3] #4: 99% system, 0% softirq, 2% hardirq, 0% idle [ 112.067647][ C3] #5: 99% system, 0% softirq, 2% hardirq, 0% idle [ 112.069748][ C3] Kernel panic - not syncing: softlockup: hung tasks [ 112.069757][ C3] CPU: 3 PID: 92 Comm: kswapd0 Tainted: G WC OEL 6.6.77-android15-8-maybe-dirty-debug #1 26355baeea0d5a5b13bd48d2f34bd75f41add861 [ 112.069768][ C3] Hardware name: Qualcomm Technologies, Inc. Kunzite QRD (DT) [ 112.069776][ C3] Call trace: [ 112.069784][ C3] dump_backtrace+0xf0/0x140 [ 112.069795][ C3] show_stack+0x18/0x28 [ 112.069805][ C3] dump_stack_lvl+0x70/0xa4 [ 112.069816][ C3] panic+0x158/0x3e4 [ 112.069827][ C3] watchdog_timer_fn+0x394/0x494 [ 112.069839][ C3] __hrtimer_run_queues+0x1d8/0x40c [ 112.069852][ C3] hrtimer_interrupt+0xf4/0x3b8 [ 112.069863][ C3] arch_timer_handler_virt+0x50/0x64 [ 112.069875][ C3] handle_percpu_devid_irq+0x100/0x320 [ 112.069888][ C3] generic_handle_domain_irq+0x5c/0x88 [ 112.069900][ C3] gic_handle_irq+0x4c/0x114 [ 112.069911][ C3] call_on_irq_stack+0x3c/0x70 [ 112.069921][ C3] do_interrupt_handler+0x7c/0xe8 [ 112.069932][ C3] el1_interrupt+0x34/0x58 [ 112.069943][ C3] el1h_64_irq_handler+0x18/0x24 [ 112.069954][ C3] el1h_64_irq+0x68/0x6c [ 112.069963][ C3] queued_spin_lock_slowpath+0x9c/0x51c [ 112.069974][ C3] do_raw_spin_lock+0x104/0x120 [ 112.069985][ C3] _raw_spin_lock+0x74/0x98 [ 112.069995][ C3] __swap_duplicate+0xa4/0x1fc [ 112.070007][ C3] shmem_writepage+0x35c/0x6a0 [ 112.070018][ C3] pageout+0xe8/0x440 [ 112.070029][ C3] shrink_folio_list+0xb38/0x15bc [ 112.070041][ C3] shrink_inactive_list+0x2a0/0x574 [ 112.070053][ C3] shrink_lruvec+0x54c/0xa1c [ 112.070064][ C3] shrink_node+0x270/0x11c4 [ 112.070074][ C3] balance_pgdat+0x8c0/0x1140 [ 112.070084][ C3] kswapd+0x35c/0x6cc [ 112.070096][ C3] kthread+0x118/0x158 [ 112.070107][ C3] ret_from_fork+0x10/0x20 [ 112.070117][ C3] SMP: stopping secondary CPUs [ 112.070137][ C4] VendorHooks: CPU4: stopping [ 112.070140][ C4] CPU: 4 PID: 0 Comm: swapper/4 Tainted: G WC OEL 6.6.77-android15-8-maybe-dirty-debug #1 26355baeea0d5a5b13bd48d2f34bd75f41add861 [ 112.070143][ C4] Hardware name: Qualcomm Technologies, Inc. Kunzite QRD (DT) [ 112.070144][ C4] pstate: 20400005 (nzCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--) [ 112.070146][ C4] pc : arch_local_irq_enable+0x4/0xc [ 112.070151][ C4] lr : cpuidle_enter_state+0x180/0x31c [ 112.070154][ C4] sp : ffffffc0833cbd70 [ 112.070154][ C4] x29: ffffffc0833cbd80 x28: ffffffc082508000 x27: 0000000000000010 [ 112.070157][ C4] x26: 0000000000000000 x25: 0000000000000000 x24: 0000000000000001 [ 112.070159][ C4] x23: 0000001a17e68b53 x22: 0000001a17c039f6 x21: 0000000000000000 [ 112.070162][ C4] x20: ffffff8021ea1080 x19: ffffff88f5620bf8 x18: ffffffc083385028 [ 112.070164][ C4] x17: 00000000d0c6e49b x16: 00000000d0c6e49b x15: 0000000000000000 [ 112.070166][ C4] x14: 000000000000002a x13: 0000000000000004 x12: 00000000803fc064 [ 112.070168][ C4] x11: 0000000000000015 x10: ffffffc082508730 x9 : 0000000100000001 [ 112.070170][ C4] x8 : 0000000100000001 x7 : 0000000000000001 x6 : ffffffc07c81a18c [ 112.070172][ C4] x5 : 0000000000000000 x4 : 0000000000000001 x3 : 000000000005c074 [ 112.070174][ C4] x2 : ffffff88f5620bf8 x1 : ffffffc081476e68 x0 : 0000000000000004 [ 112.070176][ C4] Call trace: [ 112.070177][ C4] arch_local_irq_enable+0x4/0xc [ 112.070180][ C4] cpuidle_enter+0x38/0x54 [ 112.070184][ C4] do_idle+0x1cc/0x2d8 [ 112.070187][ C4] cpu_startup_entry+0x34/0x3c [ 112.070189][ C4] secondary_start_kernel+0x138/0x160 [ 112.070192][ C4] __secondary_switched+0xc0/0xc4 [ 112.070195][ C7] VendorHooks: CPU7: stopping [ 112.070198][ C7] CPU: 7 PID: 0 Comm: swapper/7 Tainted: G WC OEL 6.6.77-android15-8-maybe-dirty-debug #1 26355baeea0d5a5b13bd48d2f34bd75f41add861 [ 112.070201][ C7] Hardware name: Qualcomm Technologies, Inc. Kunzite QRD (DT) [ 112.070202][ C7] pstate: 20400005 (nzCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--) [ 112.070205][ C7] pc : arch_local_irq_enable+0x4/0xc [ 112.070210][ C7] lr : cpuidle_enter_state+0x180/0x31c [ 112.070213][ C7] sp : ffffffc0833e3d70 [ 112.070214][ C7] x29: ffffffc0833e3d80 x28: ffffffc082508000 x27: 0000000000000080 [ 112.070217][ C7] x26: 0000000000000000 x25: 0000000000000000 x24: 0000000000000001 [ 112.070220][ C7] x23: 0000001a17e68f99 x22: 0000001a17849ae6 x21: 0000000000000000 [ 112.070222][ C7] x20: ffffff8021ea7880 x19: ffffff88f5bf3bf8 x18: ffffffc08339d028 [ 112.070224][ C7] x17: 00000000d0c6e49b x16: 00000000d0c6e49b x15: 0000000000000000 [ 112.070227][ C7] x14: 000000000000002a x13: 0000000000000004 x12: 00000000803fc079 [ 112.070228][ C7] x11: 0000000000000015 x10: ffffffc082508730 x9 : 0000000100000001 [ 112.070231][ C7] x8 : 0000000100000001 x7 : 0000000000000001 x6 : ffffffc07c81a18c [ 112.070233][ C7] x5 : 0000000000000000 x4 : 0000000000000001 x3 : 000000000005d004 [ 112.070235][ C7] x2 : ffffff88f5bf3bf8 x1 : ffffffc081476e68 x0 : 0000000000000007 [ 112.070237][ C7] Call trace: [ 112.070237][ C7] arch_local_irq_enable+0x4/0xc [ 112.070241][ C7] cpuidle_enter+0x38/0x54 [ 112.070245][ C7] do_idle+0x1cc/0x2d8 [ 112.070247][ C7] cpu_startup_entry+0x34/0x3c [ 112.070250][ C7] secondary_start_kernel+0x138/0x160 [ 112.070253][ C7] __secondary_switched+0xc0/0xc4 [ 112.070256][ C5] VendorHooks: CPU5: stopping [ 112.070258][ C5] CPU: 5 PID: 0 Comm: swapper/5 Tainted: G WC OEL 6.6.77-android15-8-maybe-dirty-debug #1 26355baeea0d5a5b13bd48d2f34bd75f41add861 [ 112.070261][ C5] Hardware name: Qualcomm Technologies, Inc. Kunzite QRD (DT) [ 112.070262][ C5] pstate: 20400005 (nzCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--) [ 112.070264][ C5] pc : arch_local_irq_enable+0x4/0xc [ 112.070268][ C5] lr : cpuidle_enter_state+0x180/0x31c [ 112.070270][ C5] sp : ffffffc0833d3d70 [ 112.070271][ C5] x29: ffffffc0833d3d80 x28: ffffffc082508000 x27: 0000000000000020 [ 112.070274][ C5] x26: 0000000000000000 x25: 0000000000000000 x24: 0000000000000001 [ 112.070276][ C5] x23: 0000001a17e68bf0 x22: 0000001a16518ae8 x21: 0000000000000000 [ 112.070278][ C5] x20: ffffff8021ea5080 x19: ffffff88f5811bf8 x18: ffffffc08338d028 [ 112.070280][ C5] x17: 00000000d0c6e49b x16: 00000000d0c6e49b x15: 0000000000000000 [ 112.070282][ C5] x14: 000000000000002a x13: 0000000000000004 x12: 00000000803fc067 [ 112.070284][ C5] x11: 0000000000000015 x10: ffffffc082508730 x9 : 0000000100000001 [ 112.070286][ C5] x8 : 0000000100000001 x7 : 0000000000000001 x6 : ffffffc07c81a18c [ 112.070288][ C5] x5 : 0000000000000000 x4 : 0000000000000001 x3 : 000000000005b934 [ 112.070290][ C5] x2 : ffffff88f5811bf8 x1 : ffffffc081476e68 x0 : 0000000000000005 [ 112.070293][ C5] Call trace: [ 112.070293][ C5] arch_local_irq_enable+0x4/0xc [ 112.070296][ C5] cpuidle_enter+0x38/0x54 [ 112.070299][ C5] do_idle+0x1cc/0x2d8 [ 112.070302][ C5] cpu_startup_entry+0x34/0x3c [ 112.070305][ C5] secondary_start_kernel+0x138/0x160 [ 112.070308][ C5] __secondary_switched+0xc0/0xc4 [ 112.070310][ C6] VendorHooks: CPU6: stopping [ 112.070313][ C6] CPU: 6 PID: 0 Comm: swapper/6 Tainted: G WC OEL 6.6.77-android15-8-maybe-dirty-debug #1 26355baeea0d5a5b13bd48d2f34bd75f41add861 [ 112.070317][ C6] Hardware name: Qualcomm Technologies, Inc. Kunzite QRD (DT) [ 112.070318][ C6] pstate: 20400005 (nzCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--) [ 112.070320][ C6] pc : arch_local_irq_enable+0x4/0xc [ 112.070325][ C6] lr : cpuidle_enter_state+0x180/0x31c [ 112.070328][ C6] sp : ffffffc0833dbd70 [ 112.070329][ C6] x29: ffffffc0833dbd80 x28: ffffffc082508000 x27: 0000000000000040 [ 112.070333][ C6] x26: 0000000000000000 x25: 0000000000000000 x24: 0000000000000001 [ 112.070335][ C6] x23: 0000001a17e68e61 x22: 0000001a1749838a x21: 0000000000000000 [ 112.070338][ C6] x20: ffffff8021ea6080 x19: ffffff88f5a02bf8 x18: ffffffc083395028 [ 112.070340][ C6] x17: 00000000d0c6e49b x16: 00000000d0c6e49b x15: 0000000000000000 [ 112.070342][ C6] x14: 000000000000002a x13: 0000000000000004 x12: 00000000803fc073 [ 112.070344][ C6] x11: 0000000000000015 x10: ffffffc082508730 x9 : 0000000100000001 [ 112.070346][ C6] x8 : 0000000100000001 x7 : 0000000000000001 x6 : ffffffc07c81a18c [ 112.070348][ C6] x5 : 0000000000000000 x4 : 0000000000000001 x3 : 000000000005ea74 [ 112.070350][ C6] x2 : ffffff88f5a02bf8 x1 : ffffffc081476e68 x0 : 0000000000000006 [ 112.070352][ C6] Call trace: [ 112.070353][ C6] arch_local_irq_enable+0x4/0xc [ 112.070356][ C6] cpuidle_enter+0x38/0x54 [ 112.070359][ C6] do_idle+0x1cc/0x2d8 [ 112.070362][ C6] cpu_startup_entry+0x34/0x3c [ 112.070365][ C6] secondary_start_kernel+0x138/0x160 [ 112.070368][ C6] __secondary_switched+0xc0/0xc4 [ 112.070371][ C0] VendorHooks: CPU0: stopping [ 112.070377][ C0] CPU: 0 PID: 0 Comm: swapper/0 Tainted: G WC OEL 6.6.77-android15-8-maybe-dirty-debug #1 26355baeea0d5a5b13bd48d2f34bd75f41add861 [ 112.070383][ C0] Hardware name: Qualcomm Technologies, Inc. Kunzite QRD (DT) [ 112.070385][ C0] pstate: 20400005 (nzCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--) [ 112.070391][ C0] pc : arch_local_irq_enable+0x4/0xc [ 112.070398][ C0] lr : cpuidle_enter_state+0x180/0x31c [ 112.070404][ C0] sp : ffffffc0824e3d30 [ 112.070406][ C0] x29: ffffffc0824e3d40 x28: ffffffc082508000 x27: 0000000000000001 [ 112.070415][ C0] x26: 0000000000000000 x25: 0000000000000000 x24: 0000000000000001 [ 112.070422][ C0] x23: 0000001a17e6863d x22: 0000001a1784635b x21: 0000000000000000 [ 112.070429][ C0] x20: ffffff8021e90880 x19: ffffff88f4e5cbf8 x18: ffffffc08251a078 [ 112.070437][ C0] x17: 00000000d0c6e49b x16: 00000000d0c6e49b x15: 0000000000000000 [ 112.070444][ C0] x14: 000000000000002a x13: 0000000000000004 x12: 00000000803fc04b [ 112.070451][ C0] x11: 0000000000000015 x10: ffffffc082508730 x9 : 0000000100000001 [ 112.070459][ C0] x8 : 0000000100000001 x7 : 0000000000000000 x6 : ffffffc07c81a18c [ 112.070466][ C0] x5 : 0000000000000000 x4 : 0000000000000001 x3 : 0000000000060f3c [ 112.070473][ C0] x2 : ffffff88f4e5cbf8 x1 : ffffffc081476e68 x0 : 0000000000000000 [ 112.070480][ C0] Call trace: [ 112.070482][ C0] arch_local_irq_enable+0x4/0xc [ 112.070489][ C0] cpuidle_enter+0x38/0x54 [ 112.070495][ C0] do_idle+0x1cc/0x2d8 [ 112.070501][ C0] cpu_startup_entry+0x34/0x3c [ 112.070507][ C0] rest_init+0xe4/0xe8 [ 112.070512][ C0] arch_call_rest_init+0x10/0x14 [ 112.070519][ C0] start_kernel+0x39c/0x454 [ 112.070525][ C0] __primary_switched+0xc8/0x8c2c [ 112.070531][ C1] VendorHooks: CPU1: stopping [ 112.070538][ C1] CPU: 1 PID: 0 Comm: swapper/1 Tainted: G WC OEL 6.6.77-android15-8-maybe-dirty-debug #1 26355baeea0d5a5b13bd48d2f34bd75f41add861 [ 112.070544][ C1] Hardware name: Qualcomm Technologies, Inc. Kunzite QRD (DT) [ 112.070546][ C1] pstate: 20400005 (nzCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--) [ 112.070551][ C1] pc : arch_local_irq_enable+0x4/0xc [ 112.070559][ C1] lr : cpuidle_enter_state+0x180/0x31c [ 112.070565][ C1] sp : ffffffc0833b3d70 [ 112.070567][ C1] x29: ffffffc0833b3d80 x28: ffffffc082508000 x27: 0000000000000002 [ 112.070575][ C1] x26: 0000000000000000 x25: 0000000000000000 x24: 0000000000000001 [ 112.070582][ C1] x23: 0000001a17e6897f x22: 0000001a1746dd08 x21: 0000000000000000 [ 112.070590][ C1] x20: ffffff8021e90080 x19: ffffff88f504dbf8 x18: ffffffc08336d028 [ 112.070597][ C1] x17: 00000000d0c6e49b x16: 00000000d0c6e49b x15: 0000000000000000 [ 112.070604][ C1] x14: 000000000000002a x13: 0000000000000004 x12: 00000000803fc05b [ 112.070612][ C1] x11: 0000000000000015 x10: ffffffc082508730 x9 : 0000000100000001 [ 112.070620][ C1] x8 : 0000000100000001 x7 : 0000000000000001 x6 : ffffffc07c81a18c [ 112.070627][ C1] x5 : 0000000000000000 x4 : 0000000000000001 x3 : 00000000000101cc [ 112.070634][ C1] x2 : ffffff88f504dbf8 x1 : ffffffc081476e68 x0 : 0000000000000001 [ 112.070641][ C1] Call trace: [ 112.070643][ C1] arch_local_irq_enable+0x4/0xc [ 112.070650][ C1] cpuidle_enter+0x38/0x54 [ 112.070656][ C1] do_idle+0x1cc/0x2d8 [ 112.070662][ C1] cpu_startup_entry+0x34/0x3c [ 112.070668][ C1] secondary_start_kernel+0x138/0x160 [ 112.070674][ C1] __secondary_switched+0xc0/0xc4 [ 112.070680][ C2] VendorHooks: CPU2: stopping [ 112.070687][ C2] CPU: 2 PID: 0 Comm: swapper/2 Tainted: G WC OEL 6.6.77-android15-8-maybe-dirty-debug #1 26355baeea0d5a5b13bd48d2f34bd75f41add861 [ 112.070693][ C2] Hardware name: Qualcomm Technologies, Inc. Kunzite QRD (DT) [ 112.070695][ C2] pstate: 20400005 (nzCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--) [ 112.070700][ C2] pc : arch_local_irq_enable+0x4/0xc [ 112.070708][ C2] lr : cpuidle_enter_state+0x180/0x31c [ 112.070714][ C2] sp : ffffffc0833bbd70 [ 112.070716][ C2] x29: ffffffc0833bbd80 x28: ffffffc082508000 x27: 0000000000000004 [ 112.070725][ C2] x26: 0000000000000000 x25: 0000000000000000 x24: 0000000000000001 [ 112.070732][ C2] x23: 0000001a17e68c24 x22: 0000001a1783c9f4 x21: 0000000000000000 [ 112.070739][ C2] x20: ffffff8021ea4080 x19: ffffff88f523ebf8 x18: ffffffc083375028 [ 112.070747][ C2] x17: 00000000d0c6e49b x16: 00000000d0c6e49b x15: 0000000000000000 [ 112.070755][ C2] x14: 000000000000002a x13: 0000000000000004 x12: 00000000803fc068 [ 112.070762][ C2] x11: 0000000000000015 x10: ffffffc082508730 x9 : 0000000100000001 [ 112.070770][ C2] x8 : 0000000100000001 x7 : 0000000000000001 x6 : ffffffc07c81a18c [ 112.070777][ C2] x5 : 0000000000000000 x4 : 0000000000000001 x3 : 000000000000efc4 [ 112.070784][ C2] x2 : ffffff88f523ebf8 x1 : ffffffc081476e68 x0 : 0000000000000002 [ 112.070791][ C2] Call trace: [ 112.070793][ C2] arch_local_irq_enable+0x4/0xc [ 112.070800][ C2] cpuidle_enter+0x38/0x54 [ 112.070806][ C2] do_idle+0x1cc/0x2d8 [ 112.070812][ C2] cpu_startup_entry+0x34/0x3c [ 112.070818][ C2] secondary_start_kernel+0x138/0x160 [ 112.070824][ C2] __secondary_switched+0xc0/0xc4 [ 112.071023][ C3] ipa ipa3_panic_notifier:7649 IPA clk off not saving the IPA registers [ 112.071670][ C3] ipa ipa3_panic_notifier:7667 [ 112.071670][ C3] ---- Active Clients Table ---- [ 112.071670][ C3] IPA_CLIENT_APPS_LAN_COAL_CONS 27 ENDPOINT [ 112.071670][ C3] IPA_CLIENT_APPS_LAN_CONS -27 ENDPOINT [ 112.071670][ C3] TAG_PROCESS -27 SPECIAL [ 112.071670][ C3] [ 112.071670][ C3] Total active clients count: 0 [ 112.071670][ C3] [ 112.071691][ C3] Skip md ftrace buffer dump for: 0x1609e0 [ 112.071715][ C3] ufshcd-qcom 1d84000.ufshc: ......dumping ufs info ....... [ 112.071726][ C3] ufshcd-qcom 1d84000.ufshc: UFS Host state=1 [ 112.071735][ C3] ufshcd-qcom 1d84000.ufshc: outstanding reqs=0x0 tasks=0x0 [ 112.071745][ C3] ufshcd-qcom 1d84000.ufshc: saved_err=0x0, saved_uic_err=0x0 [ 112.071755][ C3] ufshcd-qcom 1d84000.ufshc: Device power mode=1, UIC link state=1 [ 112.071764][ C3] ufshcd-qcom 1d84000.ufshc: PM in progress=0, sys. suspended=0 [ 112.071774][ C3] ufshcd-qcom 1d84000.ufshc: Clk gate=1 [ 112.071783][ C3] ufshcd-qcom 1d84000.ufshc: last_hibern8_exit_tstamp at 0 us, hibern8_exit_cnt=6 [ 112.071792][ C3] ufshcd-qcom 1d84000.ufshc: last intr at 106736081 us, last intr status=0x1 [ 112.071802][ C3] ufshcd-qcom 1d84000.ufshc: error handling flags=0x0, req. abort count=0 [ 112.071812][ C3] ufshcd-qcom 1d84000.ufshc: hba->ufs_version=0x300, Host capabilities=0x1587031f, caps=0x138b [ 112.071822][ C3] ufshcd-qcom 1d84000.ufshc: quirks=0x0, dev. quirks=0x140 [ 112.071831][ C3] ufshcd-qcom 1d84000.ufshc: [RX, TX]: gear=[3, 3], lane[2, 2], rate = 2 [ 112.071841][ C3] ufshcd-qcom 1d84000.ufshc: UFS RPM level = 3 [ 112.071850][ C3] ufshcd-qcom 1d84000.ufshc: UFS SPM level = 3 [ 112.071859][ C3] ufshcd-qcom 1d84000.ufshc: host_blocked=0 [ 112.071859][ C3] host_failed =0 [ 112.071859][ C3] Host self-block=0 [ 112.071869][ C3] ufshcd-qcom 1d84000.ufshc: ............. ufs dump complete .......... [ 112.071880][ C3] CPU0 next event is 116036000000 [ 112.071888][ C3] CPU1 next event is 116040000000 [ 112.071896][ C3] CPU2 next event is 112768459540 [ 112.071904][ C3] CPU3 next event is 9223372036854775807 [ 112.071912][ C3] CPU4 next event is 112052000000 [ 112.071920][ C3] CPU5 next event is 112060000000 [ 112.071928][ C3] CPU6 next event is 112064000000 [ 112.071936][ C3] CPU7 next event is 112052000000 [ 112.440504][ C3] pageowner minidump region exhausted [ 112.444650][ C3] kgsl kgsl-3d0: snapshot: device is powered off [ 112.644720][ C3] Kernel Offset: disabled [ 112.644729][ C3] CPU features: 0x000002,c0000000,70020043,1001720b [ 112.644739][ C3] Memory Limit: 0 MB [ 112.644749][ C3] metis-doublecyc: cpu: 3 [ 112.661175][ C3] Triggering late bite [ 112.661574][ C3] Top irqs in last 4901 ms: [ 112.661584][ C3] IRQ 11 [GICv3:arch_timer] - 4624 times [ 112.661593][ C3] IRQ 28 [GICv3:apps_rsc-drv-2] - 73 times [ 112.661602][ C3] IRQ 293 [GICv3:msm_drm] - 82 times [ 112.661611][ C3] IRQ 266 [GICv3:gsi] - 29 times [ 112.661620][ C3] IRQ 271 [GICv3:kgsl_3d0_irq] - 22 times [ 112.661632][ C3] gh-watchdog hypervisor:qcom,gh-watchdog: Causing a QCOM Apps Watchdog bite! [ 112.661648][ C3] gh-watchdog hypervisor:qcom,gh-watchdog: vWdog-CTL: 1, vWdog-time since last pet: 589, vWdog-expired status: 代码线升级后改动导致机器反复重启,多次堆栈均是在下面逻辑: [ 112.069963][ C3] queued_spin_lock_slowpath+0x9c/0x51c [ 112.069974][ C3] do_raw_spin_lock+0x104/0x120 [ 112.069985][ C3] _raw_spin_lock+0x74/0x98 [ 112.069995][ C3] __swap_duplicate+0xa4/0x1fc 是否代码逻辑问题导致
10-27
import os, re, glob, math, random, argparse, warnings from pathlib import Path import numpy as np import scipy.io as sio import scipy.signal as sig from scipy.stats import kurtosis import yaml import matplotlib.pyplot as plt from sklearn.manifold import TSNE from collections import defaultdict warnings.filterwarnings("ignore") # ========== 础工具 ========== def load_cfg(p): with open(p, "r", encoding="utf-8") as f: return yaml.safe_load(f) def ensure_1d(x): if x is None: return None x = np.asarray(x) if x.ndim == 1: return x.astype(np.float64) return x.reshape(-1).astype(np.float64) def detrend(x): return sig.detrend(x, type="linear") def bandpass(x, fs, f1, f2, order=4): f2 = min(f2, 0.45*fs) if f1 >= f2: f1, f2 = max(5.0, min(f1, 0.45*fs-10)), max(50.0, min(f2, 0.45*fs-5)) sos = sig.butter(order, [f1, f2], btype="bandpass", fs=fs, output="sos") return sig.sosfiltfilt(sos, x) def envelope(x): return np.abs(sig.hilbert(x)) def zscore(x, eps=1e-8): std = x.std() if not np.isfinite(std) or std < eps: return np.zeros_like(x) return (x - x.mean()) / (std + eps) def resample_to_uniform(x, fs_src, fs_tgt): x = np.asarray(x, dtype=np.float64) if x.size == 0 or fs_src <= 0 or fs_tgt <= 0 or abs(fs_src - fs_tgt) < 1e-9: return x n_out = max(1, int(round(len(x) * float(fs_tgt) / float(fs_src)))) t_src = np.linspace(0.0, (len(x)-1)/fs_src, num=len(x), endpoint=True) t_new = np.linspace(0.0, (len(x)-1)/fs_src, num=n_out, endpoint=True) return np.interp(t_new, t_src, x).astype(np.float64) def windowing(x, fs, win_sec=1.0, overlap=0.5, drop_edges_sec=0.0): x = x[int(drop_edges_sec*fs):] step = int(win_sec*fs*(1-overlap)) L = int(win_sec*fs) out = [] for s in range(0, max(1, len(x)-L+1), step if step>0 else L): seg = x[s:s+L] if len(seg)==L: out.append(seg) if not out and len(x)>0: out = [np.pad(x, (0, L-len(x)))[:L]] return out def spectral_kurtosis_band(x, fs, nfft=2048, hop=None, fmin=50, fmax=None, topk=1, bw_frac=0.15): x = np.asarray(x, dtype=np.float64) if hop is None: hop = nfft // 4 if fmax is None: fmax = fs*0.45 if len(x) < nfft: return [], None, None win = np.hanning(nfft) specs = [] for i in range(0, len(x)-nfft+1, hop): seg = x[i:i+nfft] * win X = np.fft.rfft(seg) P = np.abs(X)**2 specs.append(P) if len(specs) == 0: return [], None, None S = np.stack(specs, 0) freqs = np.fft.rfftfreq(nfft, 1.0/fs) m = (freqs >= fmin) & (freqs <= fmax) S = S[:, m]; freqs = freqs[m] if S.shape[1] < 10: return [], None, None mu1 = S.mean(axis=0) var = ((S - mu1)**2).mean(axis=0) + 1e-12 mu4 = ((S - mu1)**4).mean(axis=0) sk = mu4 / (var**2) - 3.0 idx = np.argsort(sk)[::-1][:topk] bands = [] for i in idx: fc = freqs[i] bw = max(20.0, fc * bw_frac) f1 = max(freqs[0], fc - bw/2.0) f2 = min(freqs[-1], fc + bw/2.0) if f2 > f1 + 5.0: bands.append((float(f1), float(f2))) return bands, freqs, sk def order_resample(x, fs, rpm, spr=200): if rpm is None or rpm <= 0: return x, fs fr = rpm / 60.0 T = len(x) / fs n_rev = fr * T if n_rev < 1e-3: return x, fs N = int(max(4*spr, n_rev * spr)) t = np.arange(len(x)) / fs theta = 2*np.pi*fr*t theta_target = np.linspace(theta[0], theta[-1], N) x_res = np.interp(theta_target, theta, x).astype(np.float64) fs_equiv = spr * fr return x_res, fs_equiv def parse_rpm_from_name(fn): m = re.search(r"\((\d+)\s*rpm\)", fn.replace("RPM","rpm")) if m: return float(m.group(1)) return None def read_mat_any(path): mat = sio.loadmat(path, squeeze_me=True, struct_as_record=False) keys_map = {k.lower(): k for k in mat.keys()} def pick_any(*cands): for c in cands: lc = c.lower() if lc in keys_map: return mat[keys_map[lc]] return None de = pick_any('DE','DE_value','X_DE','DE_time','x_de','x_de_time') fe = pick_any('FE','FE_value','X_FE','FE_time','x_fe','x_fe_time') ba = pick_any('BA','BA_value','X_BA','BA_time','x_ba','x_ba_time') time = pick_any('time','t','time_series','DE_time','FE_time','BA_time','X_DE_time','X_FE_time','X_BA_time') rpm = pick_any('rpm','x118rpm','speed','rot_rpm') # 兜底:挑最长 ndarray 为 DE if all(v is None for v in [de,fe,ba]): cands = [v.reshape(-1) for v in mat.values() if isinstance(v, np.ndarray) and v.size>100] if cands: de = max(cands, key=lambda a: a.size) return {"DE":ensure_1d(de), "FE":ensure_1d(fe), "BA":ensure_1d(ba), "time":ensure_1d(time), "RPM":rpm} def bearing_freqs(rpm, n, d, D, theta_deg=0.0): fr = float(rpm) / 60.0 c = (d / D) * math.cos(math.radians(theta_deg)) bpfo = 0.5 * n * fr * (1 - c) bpfi = 0.5 * n * fr * (1 + c) bsf = (D/(2*d)) * fr * (1 - c**2) ftf = 0.5 * fr * (1 - c) return fr, bpfo, bpfi, bsf, ftf def is_under_dir(child_path, parent_dir): try: child = Path(child_path).resolve() parent = Path(parent_dir).resolve() return parent in child.parents or child == parent except Exception: return False # ========== 标签推断 ========== def infer_label_from_path(p): p_norm = p.replace("\\","/").lower() if "/b/" in p_norm or os.sep+"b"+os.sep in p_norm: return "B" if "/ir/" in p_norm or os.sep+"ir"+os.sep in p_norm: return "IR" if "/or/" in p_norm or os.sep+"or"+os.sep in p_norm: return "OR" if "normal" in p_norm or "n_" in os.path.basename(p_norm): return "N" if "normal_data" in p_norm: return "N" return "UNK" # ========== 预处理主流程 ========== def choose_rpm(rec, fpath, cfg, rpm_pref=None): # 1) mat 变量 rr = rec.get("RPM") if rr is not None and np.isscalar(rr): try: val = float(rr) if val > 0: return val except: pass # 2) 文件名 val = parse_rpm_from_name(Path(fpath).name) if val is not None and val > 0: return val # 3) 外部优先提示(目标域 rpm_approx 等) if rpm_pref is not None and rpm_pref > 0: return float(rpm_pref) # 4) 源域候选 cand = cfg.get("conditions",{}).get("rpm_source_candidates", [1797,1772,1750,1730]) return float(cand[0]) if len(cand)>0 else None def preprocess_one_file(fpath, cfg, out_dir, fs_out=32000, use_order=True, rpm_pref=None, verbose=False): rec = read_mat_any(fpath) # 选通道(优先 DE,其次 FE,再 BA) x = rec["DE"]; used_ch = "DE" if x is None: x = rec["FE"]; used_ch = "FE" if x is None: x = rec["BA"]; used_ch = "BA" if x is None or x.size < 10: return None # 源采样率估计:time -> fs 或文件名猜测(48kHz/12kHz) fs_src = None if rec["time"] is not None and len(rec["time"])>1: dt = float(np.median(np.diff(rec["time"]))) if dt > 0: fs_src = 1.0/dt if fs_src is None: fs_src = 48000.0 if "48khz" in fpath.lower() else 12000.0 # 统一重采样到 fs_out x = resample_to_uniform(x, fs_src, fs_out) fs_eff = fs_out # 去趋势 if cfg["preprocess_default"].get("detrend", True): x = detrend(x) # 阶次分析(常速/近似常速),并回采样到 fs_out rpm_val = choose_rpm(rec, fpath, cfg, rpm_pref=rpm_pref) if use_order and (rpm_val is not None) and (rpm_val>0): x_ord, fs_ord = order_resample(x, fs_eff, rpm_val, spr=int(cfg["preprocess_default"].get("order_spr",200))) x = resample_to_uniform(x_ord, fs_ord, fs_out) # 回到统一 fs fs_eff = fs_out # 谱峭度 -> 自适应带通 pp = cfg["preprocess_default"] use_sk = pp.get("use_spectral_kurtosis", True) if use_sk: bands, freqs, sk = spectral_kurtosis_band( x, fs_eff, nfft=pp.get("sk_nfft", 2048), fmin=pp.get("sk_fmin", 50), fmax=pp.get("sk_fmax", int(0.45*fs_eff)), topk=pp.get("sk_topk", 1), bw_frac=pp.get("sk_bw_frac", 0.15) ) if len(bands)>0: f1, f2 = bands[0] else: f1, f2 = pp.get("bandpass_hz",[500,10000]) else: f1, f2 = pp.get("bandpass_hz",[500,10000]) x_bp = bandpass(x, fs_eff, f1, f2) x_env = envelope(x_bp) x_norm = zscore(x_env) if pp.get("normalize","zscore")=="zscore" else x_env # 切片 seg = pp.get("segment", {"win_sec":1.0,"overlap":0.5,"drop_edges_sec":0.0}) wins = windowing(x_norm, fs_eff, seg.get("win_sec",1.0), seg.get("overlap",0.5), seg.get("drop_edges_sec",0.0)) if not wins: return None # 保存 .npy(每个窗口一个文件),生成索引 os.makedirs(out_dir, exist_ok=True) label = infer_label_from_path(fpath) # "B"/"IR"/"OR"/"N"/"UNK" base = Path(fpath).stem rows = [] for i,w in enumerate(wins): outp = os.path.join(out_dir, f"{base}__{i:04d}.npy") np.save(outp, w.astype(np.float32)) rows.append((outp, label, used_ch, f1, f2, rpm_val, fs_eff)) # 返回可视化需要的中间结果 return { "rows": rows, "raw": x, "bp": x_bp, "env": x_env, "norm": x_norm, "fs": fs_eff, "band": (f1,f2), "sk": (freqs, sk) if use_sk else (None, None), "label": label, "used_ch": used_ch } # ========== 可视化 ========== def plot_one_sample(figdir, recinfo, cfg, title_hint=""): os.makedirs(figdir, exist_ok=True) x, x_bp, x_env, fs = recinfo["raw"], recinfo["bp"], recinfo["env"], recinfo["fs"] label, band = recinfo["label"], recinfo["band"] freqs, sk = recinfo["sk"] # 1) 原始 vs 预处理后(时域) T = np.arange(len(x))/fs plt.figure(figsize=(10,3)) plt.plot(T, x, lw=0.6) plt.title(f"Raw waveform ({title_hint})") plt.xlabel("Time (s)"); plt.ylabel("Amplitude"); plt.tight_layout() plt.savefig(os.path.join(figdir, f"{title_hint}_raw.png")); plt.close() T2 = np.arange(len(x_bp))/fs plt.figure(figsize=(10,3)) plt.plot(T2, x_bp, lw=0.6) plt.title(f"Bandpassed waveform {band} Hz ({title_hint})") plt.xlabel("Time (s)"); plt.ylabel("Amplitude"); plt.tight_layout() plt.savefig(os.path.join(figdir, f"{title_hint}_bandpassed.png")); plt.close() plt.figure(figsize=(10,3)) plt.plot(T2, x_env, lw=0.6) plt.title(f"Envelope (Hilbert) ({title_hint})") plt.xlabel("Time (s)"); plt.ylabel("Amplitude"); plt.tight_layout() plt.savefig(os.path.join(figdir, f"{title_hint}_envelope.png")); plt.close() # 2) PSD f, Pxx = sig.welch(x_bp, fs=fs, nperseg=4096) plt.figure(figsize=(6,4)) plt.semilogy(f, Pxx + 1e-12) plt.title(f"PSD (bandpassed) ({title_hint})"); plt.xlabel("Hz"); plt.ylabel("PSD") plt.tight_layout(); plt.savefig(os.path.join(figdir, f"{title_hint}_psd.png")); plt.close() # 3) 包络谱 N = 1<<int(np.ceil(np.log2(len(x_env)))) Ef = np.fft.rfftfreq(N, 1.0/fs) Es = np.abs(np.fft.rfft(x_env, N)) plt.figure(figsize=(8,4)) plt.plot(Ef, Es, lw=0.7) plt.xlim(0, min(5000, fs*0.45)) plt.title(f"Envelope spectrum ({title_hint})"); plt.xlabel("Hz"); plt.ylabel("|E(f)|") # 叠加轴承故障特征频率(用 DE 几何) geom = cfg["bearings"]["DE"] rpm_approx = recinfo["rows"][0][5] or cfg["conditions"]["rpm_source_candidates"][0] _, bpfo, bpfi, bsf, ftf = bearing_freqs(rpm_approx, geom["n"], geom["d_in"], geom["D_in"], geom["theta_deg"]) for name,base in [("BPFI",bpfi),("BPFO",bpfo),("BSF",bsf),("FTF",ftf)]: for k in [1,2]: f0 = k*base if f0 < fs*0.45: plt.axvline(f0, ls="--", lw=0.7, color="r") plt.text(f0, max(Es)*0.05, f"{name}{k}", rotation=90, va="bottom", ha="right", fontsize=8) plt.tight_layout(); plt.savefig(os.path.join(figdir, f"{title_hint}_envelope_spectrum.png")); plt.close() # 4) 谱峭度(若开启) if freqs is not None and sk is not None: plt.figure(figsize=(8,3)) plt.plot(freqs, sk, lw=0.8) plt.title(f"Spectral kurtosis ({title_hint})") plt.xlabel("Hz"); plt.ylabel("SK") if band: plt.axvspan(band[0], band[1], color="orange", alpha=0.25, label=f"Band {band[0]:.0f}-{band[1]:.0f} Hz") plt.legend() plt.tight_layout(); plt.savefig(os.path.join(figdir, f"{title_hint}_spectral_kurtosis.png")); plt.close() def tsne_overview(emb_list, lab_list, out_png): if len(emb_list)==0: return X = np.vstack(emb_list) L = np.array(lab_list) tsne = TSNE(n_components=2, perplexity=30, learning_rate="auto", init="pca") Z = tsne.fit_transform(X) plt.figure(figsize=(6,5)) for cls, col in zip(["OR","IR","B","N","UNK"], ["tab:blue","tab:orange","tab:green","tab:red","tab:gray"]): m = (L==cls) if m.sum()>0: plt.scatter(Z[m,0], Z[m,1], s=10, alpha=0.7, label=cls, c=col) plt.legend(); plt.title("t-SNE on log-magnitude spectrum features") plt.tight_layout(); plt.savefig(out_png); plt.close() # ========== 文件收集(source / target / all)========== def collect_source_files(cfg): root = cfg["paths"]["source_dir"] files = [] layout = cfg["source_domain"]["folder_layout"] for block in layout: bpath = os.path.join(root, block["path"]) if "classes" in block: for c in block["classes"]: files += glob.glob(os.path.join(bpath, c, "**", "*.mat"), recursive=True) if "files" in block: files += [os.path.join(bpath, f) for f in block["files"]] return sorted(files) def collect_target_files(cfg): root = cfg["paths"]["target_dir"] pat = cfg.get("target_domain", {}).get("files_pattern", "[A-P].mat") files = glob.glob(os.path.join(root, pat)) if not files: files = glob.glob(os.path.join(root, "*.mat")) return sorted(files) def collect_all_files(cfg): # 递归 root_dir 下所有 .mat(包含源域 + 目标域) root = cfg["paths"]["root_dir"] return sorted(glob.glob(os.path.join(root, "**", "*.mat"), recursive=True)) # ========== 主流程 ========== def main(): ap = argparse.ArgumentParser() ap.add_argument("--cfg", type=str, required=True) ap.add_argument("--out", type=str, default="./preprocessed") ap.add_argument("--max_per_class", type=int, default=999999) ap.add_argument("--fs_out", type=float, default=32000) ap.add_argument("--seed", type=int, default=0) ap.add_argument("--scope", type=str, choices=["source","target","all"], default="source", help="选择处理范围:source=仅源域;target=仅目标域;all=根目录下所有 .mat") args = ap.parse_args() random.seed(args.seed); np.random.seed(args.seed) cfg = load_cfg(args.cfg) fs_out = int(cfg["target_domain"]["fs_hz"]) if args.fs_out is None else int(args.fs_out) # 根据 scope 选择文件 if args.scope == "source": mat_files = collect_source_files(cfg) elif args.scope == "target": mat_files = collect_target_files(cfg) else: mat_files = collect_all_files(cfg) print(f"[INFO] found mat files: {len(mat_files)} (scope={args.scope})") os.makedirs(args.out, exist_ok=True) index_rows = ["file,window,label,channel,f1,f2,rpm,fs"] by_label_counter = defaultdict(int) tsne_feats, tsne_labels = [], [] per_class_limit = args.max_per_class random.shuffle(mat_files) viz_keep = defaultdict(list) target_dir = cfg["paths"]["target_dir"] target_rpm_approx = cfg.get("target_domain", {}).get("rpm_approx", None) for fp in mat_files: lab = infer_label_from_path(fp) if lab not in ["OR","IR","B","N","UNK"]: lab = "UNK" if by_label_counter[lab] >= per_class_limit: continue # 目标域优先使用 rpm_approx;否则走通用选择 rpm_pref = None if args.scope in ("target", "all"): if is_under_dir(fp, target_dir) and target_rpm_approx is not None: try: rpm_pref = float(target_rpm_approx) except: rpm_pref = None info = preprocess_one_file( fp, cfg, out_dir=args.out, fs_out=fs_out, use_order=cfg["preprocess_default"].get("use_order_tracking", True), rpm_pref=rpm_pref ) if info is None: continue for (wpath, label, ch, f1, f2, rpm, fs) in info["rows"]: index_rows.append(f"{wpath},{label},{ch},{f1:.2f},{f2:.2f},{rpm},{fs}") by_label_counter[lab] += 1 # 取少量窗口做 t-SNE 的简易频谱特征 for r in info["rows"][:3]: w = np.load(r[0]) N = 1<<int(np.ceil(np.log2(len(w)))) Wf = np.fft.rfft(w, N) feat = np.log1p(np.abs(Wf))[:2048] tsne_feats.append(feat.astype(np.float32)) tsne_labels.append(lab) if len(viz_keep[lab]) < 2: viz_keep[lab].append((fp, info)) with open(os.path.join(args.out, "index.csv"), "w", encoding="utf-8") as f: f.write("\n".join(index_rows)) print(f"[INFO] saved index.csv with {len(index_rows)-1} rows") figdir = os.path.join(args.out, "figs") for lab, lst in viz_keep.items(): for _, (fp, info) in enumerate(lst): title = f"{lab}_{Path(fp).stem}" plot_one_sample(figdir, info, cfg, title_hint=title) if len(tsne_feats) > 10: tsne_overview(tsne_feats, tsne_labels, os.path.join(args.out, "tsne_overview.png")) print("[INFO] saved tsne_overview.png") print("[COUNT] per class (processed files):", dict(by_label_counter)) print(f"[DONE] preprocessed windows saved to: {args.out}") if __name__ == "__main__": main() 这段python代码错误:usage: preprocess_and_viz.py [-h] --cfg CFG [--out OUT] [--max_per_class MAX_PER_CLASS] [--fs_out FS_OUT] [--seed SEED] [--scope {source,target,all}] preprocess_and_viz.py: error: the following arguments are required: --cfg 怎么修改
09-25
import argparse import os import torch from exp.exp_main import Exp_Main import random import numpy as np if __name__ == '__main__': parser = argparse.ArgumentParser(description='Autoformer & Transformer family for Time Series Forecasting') # random seed parser.add_argument('--random_seed', type=int, default=2021, help='random seed') # basic config parser.add_argument('--is_training', type=int, required=True, default=1, help='status') parser.add_argument('--model_id', type=str, required=True, default='test', help='model id') parser.add_argument('--model', type=str, required=True, default='Autoformer', help='model name, options: [Autoformer, Informer, Transformer]') # data loader parser.add_argument('--data', type=str, required=True, default='ETTm1', help='dataset type') parser.add_argument('--root_path', type=str, default='./data/ETT/', help='root path of the data file') parser.add_argument('--data_path', type=str, default='ETTh1.csv', help='data file') parser.add_argument('--features', type=str, default='M', help='forecasting task, options:[M, S, MS]; M:multivariate predict multivariate, S:univariate predict univariate, MS:multivariate predict univariate') parser.add_argument('--target', type=str, default='sensor1_clean', help='target feature in S or MS task') parser.add_argument('--freq', type=str, default='d', help='freq for time features encoding, options:[s:secondly, t:minutely, h:hourly, d:daily, b:business days, w:weekly, m:monthly], you can also use more detailed freq like 15min or 3h') parser.add_argument('--checkpoints', type=str, default='./checkpoints/', help='location of model checkpoints') # forecasting task parser.add_argument('--seq_len', type=int, default=12, help='input sequence length') parser.add_argument('--label_len', type=int, default=6, help='start token length') parser.add_argument('--pred_len', type=int, default=1, help='prediction sequence length') # DLinear #parser.add_argument('--individual', action='store_true', default=False, help='DLinear: a linear layer for each variate(channel) individually') # PatchTST parser.add_argument('--fc_dropout', type=float, default=0.05, help='fully connected dropout') parser.add_argument('--head_dropout', type=float, default=0.0, help='head dropout') parser.add_argument('--patch_len', type=int, default=16, help='patch length') parser.add_argument('--stride', type=int, default=8, help='stride') parser.add_argument('--padding_patch', default='end', help='None: None; end: padding on the end') parser.add_argument('--revin', type=int, default=1, help='RevIN; True 1 False 0') parser.add_argument('--affine', type=int, default=0, help='RevIN-affine; True 1 False 0') parser.add_argument('--subtract_last', type=int, default=0, help='0: subtract mean; 1: subtract last') parser.add_argument('--decomposition', type=int, default=0, help='decomposition; True 1 False 0') parser.add_argument('--kernel_size', type=int, default=25, help='decomposition-kernel') parser.add_argument('--individual', type=int, default=0, help='individual head; True 1 False 0') # Formers parser.add_argument('--embed_type', type=int, default=0, help='0: default 1: value embedding + temporal embedding + positional embedding 2: value embedding + temporal embedding 3: value embedding + positional embedding 4: value embedding') parser.add_argument('--enc_in', type=int, default=10, help='encoder input size') # DLinear with --individual, use this hyperparameter as the number of channels parser.add_argument('--dec_in', type=int, default=10, help='decoder input size') parser.add_argument('--c_out', type=int, default=10, help='output size') parser.add_argument('--d_model', type=int, default=128, help='dimension of model') parser.add_argument('--n_heads', type=int, default=4, help='num of heads') parser.add_argument('--e_layers', type=int, default=1, help='num of encoder layers') parser.add_argument('--d_layers', type=int, default=1, help='num of decoder layers') parser.add_argument('--d_ff', type=int, default=256, help='dimension of fcn') parser.add_argument('--moving_avg', type=int, default=25, help='window size of moving average') parser.add_argument('--factor', type=int, default=1, help='attn factor') parser.add_argument('--distil', action='store_false', help='whether to use distilling in encoder, using this argument means not using distilling', default=True) parser.add_argument('--dropout', type=float, default=0.05, help='dropout') parser.add_argument('--embed', type=str, default='timeF', help='time features encoding, options:[timeF, fixed, learned]') parser.add_argument('--activation', type=str, default='gelu', help='activation') parser.add_argument('--output_attention', action='store_true', help='whether to output attention in ecoder') parser.add_argument('--do_predict', action='store_true', help='whether to predict unseen future data') # optimization parser.add_argument('--num_workers', type=int, default=10, help='data loader num workers') parser.add_argument('--itr', type=int, default=2, help='experiments times') parser.add_argument('--train_epochs', type=int, default=30, help='train epochs') parser.add_argument('--batch_size', type=int, default=16, help='batch size of train input data') parser.add_argument('--patience', type=int, default=3, help='early stopping patience') parser.add_argument('--learning_rate', type=float, default=0.0001, help='optimizer learning rate') parser.add_argument('--des', type=str, default='test', help='exp description') parser.add_argument('--loss', type=str, default='mse', help='loss function') parser.add_argument('--lradj', type=str, default='type3', help='adjust learning rate') parser.add_argument('--pct_start', type=float, default=0.3, help='pct_start') parser.add_argument('--use_amp', action='store_true', help='use automatic mixed precision training', default=False) # GPU parser.add_argument('--use_gpu', type=bool, default=True, help='use gpu') parser.add_argument('--gpu', type=int, default=0, help='gpu') parser.add_argument('--use_multi_gpu', action='store_true', help='use multiple gpus', default=False) parser.add_argument('--devices', type=str, default='0,1,2,3', help='device ids of multile gpus') parser.add_argument('--test_flop', action='store_true', default=False, help='See utils/tools for usage') args = parser.parse_args() # random seed fix_seed = args.random_seed random.seed(fix_seed) torch.manual_seed(fix_seed) np.random.seed(fix_seed) args.use_gpu = True if torch.cuda.is_available() and args.use_gpu else False if args.use_gpu and args.use_multi_gpu: args.dvices = args.devices.replace(' ', '') device_ids = args.devices.split(',') args.device_ids = [int(id_) for id_ in device_ids] args.gpu = args.device_ids[0] print('Args in experiment:') print(args) Exp = Exp_Main if args.is_training: for ii in range(args.itr): # setting record of experiments setting = '{}_{}_{}_ft{}_sl{}_ll{}_pl{}_dm{}_nh{}_el{}_dl{}_df{}_fc{}_eb{}_dt{}_{}_{}'.format( args.model_id, args.model, args.data, args.features, args.seq_len, args.label_len, args.pred_len, args.d_model, args.n_heads, args.e_layers, args.d_layers, args.d_ff, args.factor, args.embed, args.distil, args.des,ii) exp = Exp(args) # set experiments print('>>>>>>>start training : {}>>>>>>>>>>>>>>>>>>>>>>>>>>'.format(setting)) exp.train(setting) print('>>>>>>>testing : {}<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<'.format(setting)) exp.test(setting) if args.do_predict: print('>>>>>>>predicting : {}<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<'.format(setting)) exp.predict(setting, True) torch.cuda.empty_cache() else: ii = 0 setting = '{}_{}_{}_ft{}_sl{}_ll{}_pl{}_dm{}_nh{}_el{}_dl{}_df{}_fc{}_eb{}_dt{}_{}_{}'.format(args.model_id, args.model, args.data, args.features, args.seq_len, args.label_len, args.pred_len, args.d_model, args.n_heads, args.e_layers, args.d_layers, args.d_ff, args.factor, args.embed, args.distil, args.des, ii) exp = Exp(args) # set experiments print('>>>>>>>testing : {}<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<'.format(setting)) exp.test(setting, test=1) torch.cuda.empty_cache() 帮我看一下我的代码,到底有没有进预测,感觉误差很小,这是真实预测出来的吗# exp/exp_main.py from data_provider.data_factory import data_provider from exp.exp_basic import Exp_Basic from utils.tools import EarlyStopping, adjust_learning_rate, test_params_flop from utils.metrics import metric import numpy as np import torch import torch.nn as nn from torch import optim from torch.optim import lr_scheduler import os import time import warnings import matplotlib.pyplot as plt warnings.filterwarnings('ignore') # ========= 通用小工具 ========= def ensure_dir(path): if not os.path.exists(path): os.makedirs(path, exist_ok=True) def plot_loss_curve(train_hist, val_hist, save_path): """ 训练/验证损失曲线: x 轴是 epoch 数(多少个 epoch 就有多少个点,不受 seq_len=12 影响) """ if not train_hist: return plt.figure(figsize=(6, 4)) plt.plot(train_hist, label="train") if val_hist: plt.plot(val_hist, label="val") plt.xlabel("epoch") plt.ylabel("loss") plt.title("Train and Val Loss") plt.legend() plt.tight_layout() plt.savefig(save_path, dpi=150) plt.close() def plot_batch_predictions(inputs, trues, preds, pred_len, folder_path, prefix="test"): """ 画一个 batch 中第 1 条样本: 左边:encoder 输入(真实) 右边:decoder 部分:真实/预测 注意:这里 inputs / trues / preds 已经是“反归一化后”的原始数值 """ try: if len(preds) == 0: return # inputs, trues, preds: [N, L, C] inputs = np.asarray(inputs) trues = np.asarray(trues) preds = np.asarray(preds) x = inputs[0] # [L_in, C] y_true = trues[0] # [L_out, C] y_pred = preds[0] # [L_out, C] ch = -1 # 取最后一个通道画(你可以改成 0 看第一列) x_ch = x[:, ch] y_true_ch = y_true[:, ch] y_pred_ch = y_pred[:, ch] gt = np.concatenate([x_ch, y_true_ch], axis=0) pd = np.concatenate([x_ch, y_pred_ch], axis=0) t = np.arange(len(gt)) plt.figure(figsize=(8, 4)) plt.plot(t, gt, label="Ground Truth") plt.plot(t, pd, label="Prediction") plt.axvline(len(x_ch) - 1, color="gray", linestyle="--", linewidth=1) plt.xlabel("Time index") plt.ylabel("Value") plt.title(f"{prefix} prediction example") plt.legend() plt.tight_layout() fname = os.path.join(folder_path, f"{prefix}_pred_0.png") plt.savefig(fname, dpi=150) plt.close() except Exception as e: print(f"[WARN] plot_batch_predictions error: {e}") pass def plot_full_series_predictions(inputs, trues, preds, pred_len, folder_path, prefix="test_full"): """ 把测试集所有窗口拼成一条“完整时间序列”: - 蓝色:全程真实值 Ground Truth (full) - 橙色:最后 30% 区间的预测值 Prediction (last 30%) 这段时间上的“真实值”仍然可见(蓝线),所以预测区间是“蓝+橙”两条线对比。 注意:此处 inputs / trues / preds 已经是反归一化后的原始数值。 """ try: if len(preds) == 0: return inputs = np.asarray(inputs) # [N, L_in, C] trues = np.asarray(trues) # [N, L_out, C] preds = np.asarray(preds) # [N, L_out, C] N, L_in, C = inputs.shape _, L_out, _ = trues.shape ch = 0 # 使用最后一个通道 gt_list = [] pd_list = [] for i in range(N): x_ch = inputs[i, :, ch] # encoder 段 y_true_ch = trues[i, :, ch] # decoder 真值 y_pred_ch = preds[i, :, ch] # decoder 预测 if i == 0: # 第一段:完整放入 encoder + 输出 gt_list.append(x_ch) gt_list.append(y_true_ch) pd_list.append(x_ch) pd_list.append(y_pred_ch) else: # 后续段:只追加最后 pred_len 点,避免大量重复 gt_list.append(y_true_ch[-pred_len:]) pd_list.append(y_pred_ch[-pred_len:]) full_gt = np.concatenate(gt_list, axis=0) # 全程真实值(包括预测区间) full_pd = np.concatenate(pd_list, axis=0) # 全程预测拼接 T = len(full_gt) split = int(T * 0.7) # 70% 分界(你要改成 80% 就把 0.7 改成 0.8) t = np.arange(T) plt.figure(figsize=(10, 4)) # 全程真实值(包括最后 30%) plt.plot(t, full_gt, label="Ground Truth (full)", linewidth=1.5) # 只在最后 30% 区间画预测曲线,与真实值重合对比 plt.plot(t[split:], full_pd[split:], label="Prediction (last 30%)", linewidth=1) plt.axvline(split, color="gray", linestyle="--", linewidth=1) plt.xlabel("Time index") plt.ylabel("Value") plt.title(f"{prefix} prediction example (full series)") plt.legend() plt.tight_layout() fname = os.path.join(folder_path, f"{prefix}_full_series.png") plt.savefig(fname, dpi=150) plt.close() except Exception as e: print(f"[WARN] plot_full_series_predictions error: {e}") pass # ========= 主实验类 ========= class Exp_Main(Exp_Basic): def __init__(self, args): super(Exp_Main, self).__init__(args) # 单独实现 build_model,避免依赖 Exp_Basic 里的 NotImplemented def _build_model(self): from models import Informer, Autoformer, Transformer, DLinear, Linear, NLinear, PatchTST model_dict = { 'Autoformer': Autoformer, 'Transformer': Transformer, 'Informer': Informer, 'DLinear': DLinear, 'NLinear': NLinear, 'Linear': Linear, 'PatchTST': PatchTST, } model = model_dict[self.args.model].Model(self.args).float() if self.args.use_multi_gpu and self.args.use_gpu: model = nn.DataParallel(model, device_ids=self.args.device_ids) return model def _get_data(self, flag): data_set, data_loader = data_provider(self.args, flag) return data_set, data_loader def _select_optimizer(self): return optim.Adam(self.model.parameters(), lr=self.args.learning_rate) def _select_criterion(self): return nn.MSELoss() # 验证集损失 def vali(self, vali_data, vali_loader, criterion): self.model.eval() total_loss = [] with torch.no_grad(): for batch_x, batch_y, batch_x_mark, batch_y_mark in vali_loader: batch_x = batch_x.float().to(self.device) batch_y = batch_y.float() batch_x_mark = batch_x_mark.float().to(self.device) batch_y_mark = batch_y_mark.float().to(self.device) # decoder input dec_inp = torch.zeros_like(batch_y[:, -self.args.pred_len:, :]).float() dec_inp = torch.cat( [batch_y[:, :self.args.label_len, :], dec_inp], dim=1 ).to(self.device) if 'Linear' in self.args.model or 'TST' in self.args.model: outputs = self.model(batch_x) else: if self.args.output_attention: outputs = self.model(batch_x, batch_x_mark, dec_inp, batch_y_mark)[0] else: outputs = self.model(batch_x, batch_x_mark, dec_inp, batch_y_mark) f_dim = -1 if self.args.features == 'MS' else 0 outputs = outputs[:, -self.args.pred_len:, f_dim:] batch_y = batch_y[:, -self.args.pred_len:, f_dim:].to(self.device) loss = criterion(outputs, batch_y) total_loss.append(loss.item()) self.model.train() return float(np.mean(total_loss)) if total_loss else float('inf') # 训练 def train(self, setting): train_data, train_loader = self._get_data('train') vali_data, vali_loader = self._get_data('val') test_data, test_loader = self._get_data('test') ckpt_dir = os.path.join(self.args.checkpoints, setting) ensure_dir(ckpt_dir) train_steps = len(train_loader) early_stopping = EarlyStopping(patience=self.args.patience, verbose=True) model_optim = self._select_optimizer() criterion = self._select_criterion() if self.args.use_amp: scaler = torch.cuda.amp.GradScaler() scheduler = lr_scheduler.OneCycleLR( optimizer=model_optim, steps_per_epoch=train_steps, pct_start=self.args.pct_start, epochs=self.args.train_epochs, max_lr=self.args.learning_rate ) train_hist = [] val_hist = [] for epoch in range(self.args.train_epochs): epoch_loss = [] self.model.train() t0 = time.time() for i, (batch_x, batch_y, batch_x_mark, batch_y_mark) in enumerate(train_loader): model_optim.zero_grad() batch_x = batch_x.float().to(self.device) batch_y = batch_y.float().to(self.device) batch_x_mark = batch_x_mark.float().to(self.device) batch_y_mark = batch_y_mark.float().to(self.device) # decoder input dec_inp = torch.zeros_like(batch_y[:, -self.args.pred_len:, :]).float() dec_inp = torch.cat( [batch_y[:, :self.args.label_len, :], dec_inp], dim=1 ).to(self.device) if self.args.use_amp: with torch.cuda.amp.autocast(): if 'Linear' in self.args.model or 'TST' in self.args.model: outputs = self.model(batch_x) else: if self.args.output_attention: outputs = self.model(batch_x, batch_x_mark, dec_inp, batch_y_mark)[0] else: outputs = self.model(batch_x, batch_x_mark, dec_inp, batch_y_mark) f_dim = -1 if self.args.features == 'MS' else 0 outputs = outputs[:, -self.args.pred_len:, f_dim:] target = batch_y[:, -self.args.pred_len:, f_dim:] loss = criterion(outputs, target) scaler.scale(loss).backward() scaler.step(model_optim) scaler.update() else: if 'Linear' in self.args.model or 'TST' in self.args.model: outputs = self.model(batch_x) else: if self.args.output_attention: outputs = self.model(batch_x, batch_x_mark, dec_inp, batch_y_mark)[0] else: outputs = self.model(batch_x, batch_x_mark, dec_inp, batch_y_mark) f_dim = -1 if self.args.features == 'MS' else 0 outputs = outputs[:, -self.args.pred_len:, f_dim:] target = batch_y[:, -self.args.pred_len:, f_dim:] loss = criterion(outputs, target) loss.backward() model_optim.step() if self.args.lradj == 'TST': adjust_learning_rate(model_optim, scheduler, epoch + 1, self.args, printout=False) scheduler.step() epoch_loss.append(loss.item()) train_loss = float(np.mean(epoch_loss)) if epoch_loss else float('inf') vali_loss = self.vali(vali_data, vali_loader, criterion) test_loss = self.vali(test_data, test_loader, criterion) train_hist.append(train_loss) val_hist.append(vali_loss) print("Epoch: {} cost time: {}".format(epoch + 1, time.time() - t0)) print("Epoch: {0}, Steps: {1} | Train Loss: {2:.7f} Vali Loss: {3:.7f} Test Loss: {4:.7f}".format( epoch + 1, train_steps, train_loss, vali_loss, test_loss)) early_stopping(vali_loss, self.model, ckpt_dir) if early_stopping.early_stop: print("Early stopping") break if self.args.lradj != 'TST': adjust_learning_rate(model_optim, scheduler, epoch + 1, self.args) else: print('Updating learning rate to {}'.format(scheduler.get_last_lr()[0])) # 保存损失曲线(epoch 数量 = 你训练的 epoch 数) result_dir = os.path.join('results', setting) ensure_dir(result_dir) plot_loss_curve(train_hist, val_hist, os.path.join(result_dir, 'loss_curve.png')) best_model_path = os.path.join(ckpt_dir, 'checkpoint.pth') self.model.load_state_dict(torch.load(best_model_path)) return self.model # 测试 def test(self, setting, test=0): test_data, test_loader = self._get_data('test') if test: self.model.load_state_dict( torch.load(os.path.join('./checkpoints', setting, 'checkpoint.pth')) ) self.model.eval() preds = [] trues = [] inputs = [] folder_path = os.path.join('results', setting) ensure_dir(folder_path) with torch.no_grad(): for batch_x, batch_y, batch_x_mark, batch_y_mark in test_loader: batch_x = batch_x.float().to(self.device) batch_y = batch_y.float().to(self.device) batch_x_mark = batch_x_mark.float().to(self.device) batch_y_mark = batch_y_mark.float().to(self.device) dec_inp = torch.zeros_like(batch_y[:, -self.args.pred_len:, :]).float() dec_inp = torch.cat( [batch_y[:, :self.args.label_len, :], dec_inp], dim=1 ).to(self.device) if 'Linear' in self.args.model or 'TST' in self.args.model: outputs = self.model(batch_x) else: if self.args.output_attention: outputs = self.model(batch_x, batch_x_mark, dec_inp, batch_y_mark)[0] else: outputs = self.model(batch_x, batch_x_mark, dec_inp, batch_y_mark) f_dim = -1 if self.args.features == 'MS' else 0 outputs = outputs[:, -self.args.pred_len:, f_dim:] batch_y = batch_y[:, -self.args.pred_len:, f_dim:] preds.append(outputs.detach().cpu().numpy()) trues.append(batch_y.detach().cpu().numpy()) inputs.append(batch_x.detach().cpu().numpy()) if self.args.test_flop: test_params_flop((batch_x.shape[1], batch_x.shape[2])) exit() preds = np.array(preds) trues = np.array(trues) inputs = np.array(inputs) preds = preds.reshape(-1, preds.shape[-2], preds.shape[-1]) trues = trues.reshape(-1, trues.shape[-2], trues.shape[-1]) inputs = inputs.reshape(-1, inputs.shape[-2], inputs.shape[-1]) # ========= 反归一化:还原成 Excel 原始数值 ========= scaler = getattr(test_data, 'scaler', None) if scaler is not None: # inputs N_in, L_in, C_in = inputs.shape inputs_2d = inputs.reshape(-1, C_in) inputs_2d = scaler.inverse_transform(inputs_2d) inputs = inputs_2d.reshape(N_in, L_in, C_in) # preds / trues N_out, L_out, C_out = preds.shape preds_2d = preds.reshape(-1, C_out) trues_2d = trues.reshape(-1, C_out) preds_2d = scaler.inverse_transform(preds_2d) trues_2d = scaler.inverse_transform(trues_2d) preds = preds_2d.reshape(N_out, L_out, C_out) trues = trues_2d.reshape(N_out, L_out, C_out) # ========= 反归一化结束 ========= mae, mse, rmse, mape, mspe, rse, corr = metric(preds, trues) print('mse:{}, mae:{}, rse:{}'.format(mse, mae, rse)) with open("result.txt", "a", encoding="utf-8") as f: f.write(setting + "\n") f.write('mse:{}, mae:{}, rse:{}'.format(mse, mae, rse)) f.write('\n\n') np.save(os.path.join(folder_path, 'pred.npy'), preds) # 单窗口示例 + 全序列图(此时已经是原始数值) plot_batch_predictions(inputs, trues, preds, self.args.pred_len, folder_path, prefix="test") plot_full_series_predictions(inputs, trues, preds, self.args.pred_len, folder_path, prefix="test") return # 预测模式(如果用 --do_predict) def predict(self, setting, load=False): pred_data, pred_loader = self._get_data('pred') if load: best_model_path = os.path.join(self.args.checkpoints, setting, 'checkpoint.pth') self.model.load_state_dict(torch.load(best_model_path)) self.model.eval() preds = [] inputs = [] trues = [] with torch.no_grad(): for batch_x, batch_y, batch_x_mark, batch_y_mark in pred_loader: batch_x = batch_x.float().to(self.device) batch_y = batch_y.float() batch_x_mark = batch_x_mark.float().to(self.device) batch_y_mark = batch_y_mark.float().to(self.device) dec_inp = torch.zeros( [batch_y.shape[0], self.args.pred_len, batch_y.shape[2]] ).float().to(self.device) dec_inp = torch.cat( [batch_y[:, :self.args.label_len, :], dec_inp], dim=1 ).to(self.device) if 'Linear' in self.args.model or 'TST' in self.args.model: outputs = self.model(batch_x) else: if self.args.output_attention: outputs = self.model(batch_x, batch_x_mark, dec_inp, batch_y_mark)[0] else: outputs = self.model(batch_x, batch_x_mark, dec_inp, batch_y_mark) preds.append(outputs.detach().cpu().numpy()) inputs.append(batch_x.detach().cpu().numpy()) trues.append(batch_y[:, -self.args.pred_len:, :].detach().cpu().numpy()) preds = np.array(preds) inputs = np.array(inputs) trues = np.array(trues) preds = preds.reshape(-1, preds.shape[-2], preds.shape[-1]) inputs = inputs.reshape(-1, inputs.shape[-2], inputs.shape[-1]) trues = trues.reshape(-1, trues.shape[-2], trues.shape[-1]) # 预测模式下同样做反归一化 scaler = getattr(pred_data, 'scaler', None) if scaler is not None: N_in, L_in, C_in = inputs.shape inputs_2d = inputs.reshape(-1, C_in) inputs_2d = scaler.inverse_transform(inputs_2d) inputs = inputs_2d.reshape(N_in, L_in, C_in) N_out, L_out, C_out = preds.shape preds_2d = preds.reshape(-1, C_out) trues_2d = trues.reshape(-1, C_out) preds_2d = scaler.inverse_transform(preds_2d) trues_2d = scaler.inverse_transform(trues_2d) preds = preds_2d.reshape(N_out, L_out, C_out) trues = trues_2d.reshape(N_out, L_out, C_out) folder_path = os.path.join('results', setting) ensure_dir(folder_path) np.save(os.path.join(folder_path, 'real_prediction.npy'), preds) # 单窗口 + 全序列预测图 plot_batch_predictions(inputs, trues, preds, self.args.pred_len, folder_path, prefix="predict") plot_full_series_predictions(inputs, trues, preds, self.args.pred_len, folder_path, prefix="predict") return
11-12
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值