{"id":119079,"date":"2026-10-28T21:16:57","date_gmt":"2026-10-28T13:16:57","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/119079.html"},"modified":"2026-10-28T21:16:57","modified_gmt":"2026-10-28T13:16:57","slug":"%e4%b8%8a%e6%b5%b754321%e6%99%ba%e8%83%bd%e5%88%b6%e9%80%a0%e7%9b%ae%e6%a0%87%e4%b8%8b%ef%bc%8c%e5%9f%ba%e7%a1%80%e7%ba%a7%e6%99%ba%e8%83%bd%e5%b7%a5%e5%8e%82%e7%9a%84","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/119079.html","title":{"rendered":"\u4e0a\u6d77\u201c54321\u201c\u667a\u80fd\u5236\u9020\u76ee\u6807\u4e0b\uff0c\u57fa\u7840\u7ea7\u667a\u80fd\u5de5\u5382\u7684\u201c\u6838\u5fc3\u6570\u636e\u5b9e\u65f6\u91c7\u96c6\u201c\u8981\u91c7\u4ec0\u4e48\u3001\u600e\u4e48\u91c7\uff08\u9644\u67b6\u6784\u4e0e Python \u5b9e\u73b0\uff09"},"content":{"rendered":"<p>\u6458\u8981&#xff1a;\u300a\u4e0a\u6d77\u5e02\u52a0\u5feb\u53d1\u5c55\u65b0\u4e00\u4ee3\u667a\u80fd\u5236\u9020\u884c\u52a8\u65b9\u6848\u300b\u63d0\u51fa\u5230 2028 \u5e74\u57fa\u7840\u7ea7\u667a\u80fd\u5de5\u5382\u7d2f\u8ba1\u8fbe 1600 \u5bb6&#xff0c;\u5e76\u628a\u201c\u5b9e\u73b0\u6838\u5fc3\u6570\u636e\u5b9e\u65f6\u91c7\u96c6\u201d\u5199\u8fdb\u4e86\u57fa\u7840\u7ea7\u7684\u51c6\u5165\u8981\u6c42\u3002\u8fd9\u7bc7\u6587\u7ae0\u4ece\u5de5\u7a0b\u89d2\u5ea6\u62c6\u89e3\u4e09\u4ef6\u4e8b&#xff1a;\u6838\u5fc3\u6570\u636e\u5230\u5e95\u5206\u54ea\u4e09\u5c42\u3001\u8bbe\u5907\u6570\u636e\u4e3a\u4ec0\u4e48\u53ef\u4ee5\u4e0d\u5fc5\u5148\u8fc7 MES&#xff0c;\u4ee5\u53ca\u4e00\u6761\u4ece PLC \/ CNC \u5230\u65f6\u5e8f\u6570\u636e\u5e93\u7684\u6700\u5c0f\u53ef\u7528\u91c7\u96c6\u94fe\u8def&#xff08;\u542b\u53ef\u8fd0\u884c\u7684 Python \u5b9e\u73b0\u4e0e\u4e09\u4e2a\u73b0\u573a\u5751&#xff09;\u3002<\/p>\n<h3>\u672c\u6587\u76ee\u5f55<\/h3>\n<li>\u4e00\u3001\u5148\u7ed9\u7ed3\u8bba<\/li>\n<li>\u4e8c\u3001\u653f\u7b56\u539f\u6587\u91cc&#xff0c;\u548c&#034;\u6570\u636e\u91c7\u96c6&#034;\u76f4\u63a5\u76f8\u5173\u7684\u4e09\u53e5\u8bdd<\/li>\n<li>\u4e09\u3001&#034;\u6838\u5fc3\u6570\u636e&#034;\u5230\u5e95\u6307\u54ea\u4e9b&#xff1a;\u4e00\u5f20\u4e09\u7ea7\u6e05\u5355<\/li>\n<li>\u56db\u3001\u91c7\u96c6\u67b6\u6784&#xff1a;\u8bbe\u5907\u6570\u636e\u4e3a\u4ec0\u4e48\u53ef\u4ee5\u4e0d\u5fc5\u5148\u8fc7 MES<\/li>\n<li>\u4e94\u3001\u5de5\u7a0b\u5b9e\u73b0&#xff1a;\u4ece PLC \/ CNC \u5230\u65f6\u5e8f\u5e93\u7684\u4e00\u6761\u6700\u5c0f\u94fe\u8def<\/li>\n<li>\u516d\u3001\u4e09\u4e2a\u771f\u5b9e\u4f1a\u8e29\u7684\u5751<\/li>\n<li>\u4e03\u3001\u843d\u5730\u68c0\u67e5\u6e05\u5355<\/li>\n<li>\u516b\u3001\u5e38\u89c1\u95ee\u9898<\/li>\n<li>\u4e5d\u3001\u603b\u7ed3<\/li>\n<h3>\u4e00\u3001\u5148\u7ed9\u7ed3\u8bba<\/h3>\n<p>\u5148\u628a\u5224\u65ad\u6446\u51fa\u6765&#xff0c;\u540e\u9762\u518d\u5c55\u5f00\u8bba\u636e&#xff1a;<\/p>\n<li>\u201c\u6838\u5fc3\u6570\u636e\u5b9e\u65f6\u91c7\u96c6\u201d\u4e0d\u662f\u4e00\u53e5\u53e3\u53f7&#xff0c;\u5b83\u662f\u57fa\u7840\u7ea7\u667a\u80fd\u5de5\u5382\u7684\u7b2c\u4e00\u9053\u95e8\u69db\u30021600 \u5bb6\u7684\u57fa\u7840\u76d8&#xff0c;\u6700\u5148\u5361\u5728\u8fd9\u91cc\u7684\u4e0d\u662f\u6a21\u578b\u3001\u4e0d\u662f\u7b97\u529b&#xff0c;\u800c\u662f\u6570\u636e\u80fd\u4e0d\u80fd\u7a33\u5b9a\u91c7\u4e0a\u6765\u3002<\/li>\n<li>\u201c\u6838\u5fc3\u6570\u636e\u201d\u4e0d\u7b49\u4e8e\u628a\u6240\u6709\u70b9\u4f4d\u90fd\u91c7\u4e0a\u6765\u3002\u5b83\u5206\u4e09\u5c42&#xff1a;\u8bbe\u5907\u8fd0\u884c\u72b6\u6001\u3001\u5de5\u5e8f\u8fc7\u7a0b\u91cf\u3001\u4ea7\u51fa\u4e0e\u8d28\u91cf\u7ed3\u679c\u3002\u91c7\u5168\u4e0d\u662f\u76ee\u6807&#xff0c;\u91c7\u5230\u80fd\u56de\u7b54\u4e1a\u52a1\u95ee\u9898\u624d\u662f\u3002<\/li>\n<li>\u8bbe\u5907\u6570\u636e\u4e0d\u5fc5\u5148\u8fc7 MES&#xff08;\u5236\u9020\u6267\u884c\u7cfb\u7edf&#xff0c;Manufacturing Execution System&#xff09;\u3002MES \u64c5\u957f\u5de5\u5355\u3001\u62a5\u5de5\u4e0e\u8ffd\u6eaf&#xff0c;\u4e0d\u64c5\u957f\u9ad8\u9891\u65f6\u5e8f\u6570\u636e&#xff1b;\u628a\u79d2\u7ea7\u70b9\u4f4d\u786c\u585e\u8fdb MES&#xff0c;\u662f\u8fd9\u7c7b\u9879\u76ee\u91cc\u6700\u5e38\u89c1\u4e5f\u6700\u6602\u8d35\u7684\u4e00\u4e2a\u9519\u8bef\u3002<\/li>\n<li>\u6700\u5c0f\u53ef\u7528\u94fe\u8def\u662f\u4e94\u6b65&#xff1a;\u8fb9\u7f18\u7f51\u5173\u91c7\u96c6 \u2192 \u7edf\u4e00\u70b9\u4f4d\u547d\u540d \u2192 MQTT&#xff08;\u6d88\u606f\u961f\u5217\u9065\u6d4b\u4f20\u8f93&#xff0c;Message Queuing Telemetry Transport&#xff09;\u4e0a\u884c \u2192 \u65f6\u5e8f\u6570\u636e\u5e93&#xff08;Time-Series Database&#xff09;\u843d\u5e93 \u2192 \u4e1a\u52a1\u7cfb\u7edf\u6309\u9700\u53d6\u6570\u3002<\/li>\n<h3>\u4e8c\u3001\u653f\u7b56\u539f\u6587\u91cc&#xff0c;\u548c&#034;\u6570\u636e\u91c7\u96c6&#034;\u76f4\u63a5\u76f8\u5173\u7684\u4e09\u53e5\u8bdd<\/h3>\n<p>\u300a\u4e0a\u6d77\u5e02\u52a0\u5feb\u53d1\u5c55\u65b0\u4e00\u4ee3\u667a\u80fd\u5236\u9020\u884c\u52a8\u65b9\u6848\u300b\u7531\u4e0a\u6d77\u5e02\u7ecf\u6d4e\u4fe1\u606f\u5316\u59d4\u4e8e 2026 \u5e74 10 \u6708 27 \u65e5\u5370\u53d1&#xff0c;10 \u6708 28 \u65e5\u7ecf\u4e2d\u56fd\u65b0\u95fb\u7f51\u3001\u8bc1\u5238\u65f6\u62a5\u3001\u6f8e\u6e43\u65b0\u95fb\u7b49\u591a\u5bb6\u5a92\u4f53\u62a5\u9053\u3002\u4e0e\u672c\u6587\u4e3b\u9898\u76f4\u63a5\u76f8\u5173\u7684\u8868\u8ff0\u6709\u4e09\u53e5&#xff1a;<\/p>\n<p>\u7b2c\u4e00\u53e5&#xff0c;\u5199\u5728\u57fa\u7840\u7ea7\u667a\u80fd\u5de5\u5382\u7684\u57f9\u80b2\u8981\u6c42\u91cc&#xff1a;\u5f15\u5bfc\u5236\u9020\u4f01\u4e1a\u5408\u7406\u90e8\u7f72\u667a\u80fd\u5236\u9020\u88c5\u5907\u3001\u8f6f\u4ef6\u548c\u7cfb\u7edf&#xff0c;\u5b9e\u73b0\u6838\u5fc3\u6570\u636e\u5b9e\u65f6\u91c7\u96c6\u3001\u5173\u952e\u751f\u4ea7\u5de5\u5e8f\u81ea\u52a8\u5316\u3001\u751f\u4ea7\u4e0e\u7ecf\u8425\u7ba1\u7406\u4fe1\u606f\u5316\u3002<\/p>\n<p>\u7b2c\u4e8c\u53e5&#xff0c;\u5173\u4e8e\u91cf\u7ea7&#xff1a;\u5230 2028 \u5e74\u5b9e\u73b0\u57fa\u7840\u7ea7\u667a\u80fd\u5de5\u5382\u7d2f\u8ba1\u8fbe 1600 \u5bb6&#xff1b;\u63a8\u52a8\u57fa\u7840\u7ea7\u667a\u80fd\u5de5\u5382 AI \u666e\u53ca\u7387\u8fbe 100%&#xff0c;\u5148\u8fdb\u7ea7\u3001\u5353\u8d8a\u7ea7\u3001\u9886\u822a\u7ea7\u667a\u80fd\u5de5\u5382\u7684 AI \u5e94\u7528\u573a\u666f\u6bd4\u4f8b\u5206\u522b\u8fbe 10%\u300130%\u300170%\u3002<\/p>\n<p>\u7b2c\u4e09\u53e5&#xff0c;\u5173\u4e8e\u68af\u5ea6&#xff1a;\u57fa\u7840\u7ea7 1600 \u5bb6\u3001\u5148\u8fdb\u7ea7 500 \u5bb6\u3001\u5353\u8d8a\u7ea7 50 \u5bb6\u3001\u9886\u822a\u7ea7 5 \u5bb6&#xff0c;\u6784\u6210&#034;54321&#034;\u76ee\u6807\u91cc\u7684\u5de5\u5382\u68af\u5ea6\u90e8\u5206\u3002<\/p>\n<p>\u9700\u8981\u8bf4\u660e\u7684\u662f&#xff0c;\u540c\u6279\u53d1\u5e03\u7684 2000 \u4e2a AI \u5e94\u7528\u573a\u666f\u300110 \u4e2a\u5782\u57df\u5927\u6a21\u578b\u3001300 \u4e2a\u4ee5\u4e0a\u9ad8\u6c34\u5e73\u667a\u80fd\u4f53\u3001\u5de5\u4e1a\u673a\u5668\u4eba\u5bc6\u5ea6 600 \u53f0\/\u4e07\u4eba\u7b49\u6307\u6807&#xff0c;\u4e3b\u8981\u843d\u5728\u5148\u8fdb\u7ea7\u53ca\u4ee5\u4e0a\u3002\u672c\u6587\u53ea\u8ba8\u8bba\u57fa\u7840\u7ea7\u8fd9\u4e00\u5c42\u2014\u2014\u4e5f\u5c31\u662f\u5927\u591a\u6570\u4e2d\u5c0f\u5236\u9020\u4f01\u4e1a\u771f\u6b63\u8981\u8de8\u8fc7\u53bb\u7684\u90a3\u4e00\u6b65\u3002<\/p>\n<h3>\u4e09\u3001&#034;\u6838\u5fc3\u6570\u636e&#034;\u5230\u5e95\u6307\u54ea\u4e9b&#xff1a;\u4e00\u5f20\u4e09\u7ea7\u6e05\u5355<\/h3>\n<p>\u8fd9\u662f\u6211\u88ab\u95ee\u5f97\u6700\u591a\u7684\u95ee\u9898\u3002\u653f\u7b56\u6587\u4ef6\u4e0d\u4f1a\u7ed9\u4f60\u70b9\u4f4d\u8868&#xff0c;\u4f46\u5de5\u7a0b\u4e0a\u53ef\u4ee5\u62c6\u5f97\u5f88\u6e05\u695a&#xff1a;<\/p>\n<table>\n<tr>\u5c42\u7ea7\u5178\u578b\u6570\u636e\u91c7\u6837\u9891\u7387\u8981\u56de\u7b54\u7684\u95ee\u9898\u5e38\u89c1\u6765\u6e90<\/tr>\n<tbody>\n<tr>\n<td>L1 \u8bbe\u5907\u8fd0\u884c\u72b6\u6001<\/td>\n<td>\u5f00\u673a\/\u505c\u673a\/\u5f85\u673a\/\u62a5\u8b66\u3001\u4e3b\u8f74\u8f6c\u901f\u3001\u8fdb\u7ed9\u500d\u7387\u3001\u4e3b\u8f74\u8d1f\u8f7d\u3001\u6e29\u5ea6<\/td>\n<td>\u79d2\u7ea7<\/td>\n<td>\u8fd9\u53f0\u8bbe\u5907\u73b0\u5728\u80fd\u4e0d\u80fd\u5e72\u6d3b&#xff1f;<\/td>\n<td>PLC\u3001CNC \u63a7\u5236\u5668\u3001\u8fb9\u7f18\u7f51\u5173<\/td>\n<\/tr>\n<tr>\n<td>L2 \u5de5\u5e8f\u8fc7\u7a0b\u91cf<\/td>\n<td>\u8282\u62cd\u3001\u5faa\u73af\u65f6\u95f4\u3001\u5de5\u827a\u53c2\u6570&#xff08;\u538b\u529b\u3001\u6e29\u5ea6\u3001\u6d41\u91cf&#xff09;\u3001\u80fd\u8017<\/td>\n<td>\u79d2\u7ea7\u5230\u5206\u949f\u7ea7<\/td>\n<td>\u8fd9\u9053\u5de5\u5e8f\u7a33\u4e0d\u7a33\u3001\u6709\u6ca1\u6709\u6f02\u79fb&#xff1f;<\/td>\n<td>\u4f20\u611f\u5668\u3001\u4eea\u8868\u3001CNC \u5b8f\u53d8\u91cf<\/td>\n<\/tr>\n<tr>\n<td>L3 \u4ea7\u51fa\u4e0e\u8d28\u91cf\u7ed3\u679c<\/td>\n<td>\u5408\u683c\u6570\u3001\u4e0d\u5408\u683c\u6570\u3001\u4e0d\u826f\u4ee3\u7801\u3001\u505c\u673a\u539f\u56e0\u7801\u3001\u5200\u5177\/\u6a21\u5177\u5bff\u547d<\/td>\n<td>\u4ef6\u7ea7\u6216\u6279\u6b21\u7ea7<\/td>\n<td>\u8fd9\u6279\u6d3b\u5e72\u5f97\u600e\u4e48\u6837\u3001\u95ee\u9898\u51fa\u5728\u54ea&#xff1f;<\/td>\n<td>\u4eba\u5de5\u62a5\u5de5\u3001\u89c6\u89c9\u68c0\u6d4b\u3001\u91cf\u5177<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u3010\u914d\u56fe\u4f4d\u7f6e1\u3011\u8bf7\u5728\u6b64\u4e0a\u4f20 \u56fe1_\u6838\u5fc3\u6570\u636e\u4e09\u5c42\u4e0e\u91c7\u96c6\u94fe\u8def.png<\/p>\n<p>\u5173\u952e\u5224\u65ad\u5728\u8fd9\u91cc&#xff1a;\u4e09\u5c42\u90fd\u8981\u91c7&#xff0c;\u4f46\u5b58\u50a8\u7b56\u7565\u5b8c\u5168\u4e0d\u540c\u3002<\/p>\n<p>L1 \u548c L2 \u662f\u65f6\u95f4\u5e8f\u5217&#xff0c;\u5199\u5165\u9891\u7387\u9ad8\u3001\u91cf\u5927&#xff0c;\u5e94\u8be5\u8fdb\u65f6\u5e8f\u6570\u636e\u5e93&#xff1b;L3 \u662f\u4e1a\u52a1\u4e8b\u5b9e&#xff0c;\u5929\u7136\u8981\u8ddf\u5de5\u5355\u3001\u6279\u6b21\u7ed1\u5b9a&#xff0c;\u5e94\u8be5\u8fdb\u4e1a\u52a1\u5e93\u3002\u6211\u89c1\u8fc7\u4e0d\u5c11\u9879\u76ee\u628a\u4e09\u5c42\u6df7\u5728\u4e00\u5f20\u8868\u91cc&#xff0c;\u534a\u5e74\u540e\u6570\u636e\u91cf\u4e0a\u6765&#xff0c;\u4e00\u5f20\u62a5\u8868\u67e5\u4e09\u5206\u949f&#xff0c;\u6700\u540e\u6ca1\u4eba\u613f\u610f\u7528&#xff0c;\u7cfb\u7edf\u5c31\u5e9f\u5728\u90a3\u91cc\u3002<\/p>\n<h3>\u56db\u3001\u91c7\u96c6\u67b6\u6784&#xff1a;\u8bbe\u5907\u6570\u636e\u4e3a\u4ec0\u4e48\u53ef\u4ee5\u4e0d\u5fc5\u5148\u8fc7 MES<\/h3>\n<p>\u8fd9\u662f\u672c\u6587\u6700\u60f3\u8bf4\u6e05\u7684\u4e00\u70b9\u3002<\/p>\n<p>MES \u7684\u5b9a\u4f4d\u662f\u5de5\u5355\u7ba1\u7406\u3001\u62a5\u5de5\u3001\u8d28\u91cf\u8ffd\u6eaf\u548c\u8fc7\u7a0b\u7ba1\u63a7&#xff0c;\u5b83\u7684\u6570\u636e\u7c92\u5ea6\u662f\u4ef6\u3001\u6279\u3001\u73ed\u6b21\u3002\u800c\u8bbe\u5907\u70b9\u4f4d\u662f\u79d2\u7ea7\u751a\u81f3\u4e9a\u79d2\u7ea7\u7684\u3002\u628a\u540e\u8005\u76f4\u63a5\u5199\u8fdb\u524d\u8005\u7684\u5e93\u91cc&#xff0c;\u4f1a\u5e26\u6765\u4e09\u4e2a\u5177\u4f53\u95ee\u9898&#xff1a;<\/p>\n<ul>\n<li>\u5199\u5165\u653e\u5927&#xff1a;\u4e00\u53f0\u8bbe\u5907 50 \u4e2a\u70b9\u4f4d\u30011 \u79d2\u4e00\u6b21&#xff0c;\u4e00\u5929\u5c31\u662f 432 \u4e07\u6761\u8bb0\u5f55\u3002\u4e8c\u5341\u53f0\u8bbe\u5907\u4e00\u4e2a\u6708\u5c31\u4e0a\u4ebf&#xff0c;MES \u6570\u636e\u5e93\u625b\u4e0d\u4f4f\u3002<\/li>\n<li>\u8868\u7ed3\u6784\u81a8\u80c0&#xff1a;\u4e3a\u585e\u4e0b\u9ad8\u9891\u70b9\u4f4d\u800c\u52a0\u7684\u5bbd\u8868&#xff0c;\u4f1a\u8ba9\u539f\u672c\u6e05\u6670\u7684\u5de5\u5355\u6a21\u578b\u53d8\u5f97\u96be\u4ee5\u7ef4\u62a4\u3002<\/li>\n<li>\u62d6\u57ae\u751f\u4ea7\u7cfb\u7edf&#xff1a;MES \u662f\u8f66\u95f4\u6bcf\u5929\u90fd\u8981\u7528\u7684\u7cfb\u7edf&#xff0c;\u4efb\u4f55\u67e5\u8be2\u53d8\u6162\u90fd\u4f1a\u76f4\u63a5\u5f71\u54cd\u6392\u4ea7\u548c\u62a5\u5de5&#xff0c;\u8fd9\u4e2a\u4ee3\u4ef7\u6ca1\u4eba\u613f\u610f\u627f\u62c5\u3002<\/li>\n<\/ul>\n<p>\u66f4\u5408\u7406\u7684\u5206\u5c42\u662f&#xff1a;<\/p>\n<p>\u8bbe\u5907\u5c42&#xff1a;PLC \/ CNC \/ \u4f20\u611f\u5668 \/ \u4eea\u8868<br \/>\n   \u2193  &#xff08;Modbus\u3001OPC UA\u3001\u4e32\u53e3\u3001IO \u91c7\u96c6&#xff09;<br \/>\n\u8fb9\u7f18\u5c42&#xff1a;\u8fb9\u7f18\u7f51\u5173 \u2192 \u70b9\u4f4d\u89c4\u8303\u5316 \u2192 \u672c\u5730\u7f13\u5b58&#xff08;\u65ad\u7f51\u7eed\u4f20&#xff09;<br \/>\n   \u2193  &#xff08;MQTT \u4e0a\u884c&#xff0c;\u5382\u5185\u7f51\u7edc&#xff09;<br \/>\n\u6570\u636e\u5c42&#xff1a;\u65f6\u5e8f\u6570\u636e\u5e93&#xff08;\u79d2\u7ea7\u539f\u59cb &#043; \u5206\u949f\u7ea7\u805a\u5408&#xff09;<br \/>\n   \u2193  &#xff08;\u6807\u51c6\u63a5\u53e3 \/ \u805a\u5408\u89c6\u56fe&#xff09;<br \/>\n\u5e94\u7528\u5c42&#xff1a;MES \u53d6\u5de5\u5355\u6240\u9700\u7ed3\u679c\u3001\u770b\u677f\u53d6\u72b6\u6001\u3001AI \u53d6\u7279\u5f81 <\/p>\n<p>\u8fd9\u5957\u5206\u5c42\u7684\u53e6\u4e00\u4e2a\u597d\u5904\u662f\u8fb9\u754c\u6e05\u6670&#xff1a;\u8bbe\u5907\u539f\u59cb\u6570\u636e\u3001\u65f6\u5e8f\u5e93\u5b58\u3001\u6a21\u578b\u63a8\u7406\u90fd\u653e\u5728\u5382\u5185&#xff0c;\u53ea\u6709\u805a\u5408\u540e\u7684\u7ed3\u679c\u6309\u9700\u5916\u9001\u3002\u5bf9\u90a3\u4e9b\u660e\u786e\u8981\u6c42\u6570\u636e\u4e0d\u51fa\u5382\u7684\u4f01\u4e1a\u6765\u8bf4&#xff0c;\u8fd9\u6761\u94fe\u8def\u5929\u7136\u6ee1\u8db3\u8981\u6c42&#xff0c;\u4e0d\u9700\u8981\u4e8b\u540e\u6253\u8865\u4e01\u3002<\/p>\n<h4>MES \u4e0e\u65f6\u5e8f\u5e93\u7684\u5bf9\u63a5&#xff1a;\u6309\u9700\u53d6\u805a\u5408\u7ed3\u679c<\/h4>\n<p>\u5206\u5c42\u4e4b\u540e&#xff0c;MES \u4e0d\u518d\u76f4\u8fde\u8bbe\u5907\u70b9\u4f4d&#xff0c;\u800c\u662f\u901a\u8fc7\u805a\u5408\u89c6\u56fe\u6216\u6807\u51c6\u63a5\u53e3\u6309\u5de5\u5355\u3001\u6279\u6b21\u53d6\u6570\u3002\u5178\u578b\u505a\u6cd5\u662f&#xff1a;MES \u4fa7\u53ea\u4fdd\u5b58\u5de5\u5355\u53f7\u3001\u6279\u6b21\u53f7\u3001\u8bbe\u5907\u7f16\u53f7\u548c\u8d77\u6b62\u65f6\u95f4&#xff0c;\u53d6\u6570\u65f6\u628a\u8fd9\u6bb5\u65f6\u95f4\u7a97\u53e3\u548c\u70b9\u4f4d\u524d\u7f00\u4f20\u7ed9\u65f6\u5e8f\u5e93&#xff0c;\u7531\u65f6\u5e8f\u5e93\u8fd4\u56de\u5206\u949f\u7ea7\u805a\u5408\u7ed3\u679c\u3002<\/p>\n<p>\u4e0b\u9762\u662f\u4e00\u4e2a SQL \u805a\u5408\u67e5\u8be2\u793a\u4f8b&#xff0c;\u4ece agg_1m \u8868\u6309\u65f6\u95f4\u6bb5\u548c\u70b9\u4f4d\u524d\u7f00\u53d6\u67d0\u5de5\u5355\u5468\u671f\u7684\u8282\u62cd\u4e0e\u4e3b\u8f74\u8d1f\u8f7d\u5747\u503c&#xff1a;<\/p>\n<p>&#8212; \u8f93\u5165&#xff1a;\u5de5\u5355\u5468\u671f\u8d77\u6b62\u65f6\u95f4&#xff08;\u6beb\u79d2&#xff09;\u3001\u8bbe\u5907\u70b9\u4f4d\u524d\u7f00<br \/>\n&#8212; \u8f93\u51fa&#xff1a;\u8be5\u5de5\u5355\u5468\u671f\u5185\u6bcf\u5206\u949f\u7684\u8282\u62cd\u4e0e\u4e3b\u8f74\u8d1f\u8f7d\u5747\u503c<br \/>\nSELECT<br \/>\n    a.ts                                   AS minute_ts,<br \/>\n    a.point                                AS point,<br \/>\n    a.v_avg                                AS avg_value,<br \/>\n    a.v_min                                AS min_value,<br \/>\n    a.v_max                                AS max_value,<br \/>\n    a.v_cnt                                AS sample_cnt<br \/>\nFROM agg_1m a<br \/>\nWHERE a.ts &gt;&#061; :work_order_start_ms<br \/>\n  AND a.ts &lt;  :work_order_end_ms<br \/>\n  AND a.point LIKE :point_prefix || &#039;%&#039;<br \/>\n  AND (<br \/>\n        a.point LIKE &#039;%.PROCESS.cycle_time&#039;<br \/>\n     OR a.point LIKE &#039;%.PROCESS.spindle_load&#039;<br \/>\n      )<br \/>\nORDER BY a.point, a.ts; <\/p>\n<p>\u5982\u679c MES \u9700\u8981\u7684\u662f\u5de5\u5355\u7ea7\u7684\u5355\u4e00\u6570\u503c&#xff0c;\u800c\u4e0d\u662f\u9010\u5206\u949f\u660e\u7ec6&#xff0c;\u53ef\u4ee5\u5728\u5916\u5c42\u518d\u5957\u4e00\u5c42\u805a\u5408&#xff1a;<\/p>\n<p>&#8212; \u5de5\u5355\u7ea7\u6c47\u603b&#xff1a;\u8282\u62cd\u5747\u503c\u3001\u4e3b\u8f74\u8d1f\u8f7d\u5747\u503c\u4e0e\u6837\u672c\u6570<br \/>\nSELECT<br \/>\n    SUM(CASE WHEN point LIKE &#039;%.PROCESS.cycle_time&#039;   THEN v_avg * v_cnt END)<br \/>\n      \/ NULLIF(SUM(CASE WHEN point LIKE &#039;%.PROCESS.cycle_time&#039;   THEN v_cnt END), 0) AS avg_cycle_time,<br \/>\n    SUM(CASE WHEN point LIKE &#039;%.PROCESS.spindle_load&#039; THEN v_avg * v_cnt END)<br \/>\n      \/ NULLIF(SUM(CASE WHEN point LIKE &#039;%.PROCESS.spindle_load&#039; THEN v_cnt END), 0) AS avg_spindle_load,<br \/>\n    SUM(v_cnt) AS total_samples<br \/>\nFROM agg_1m<br \/>\nWHERE ts &gt;&#061; :work_order_start_ms<br \/>\n  AND ts &lt;  :work_order_end_ms<br \/>\n  AND point LIKE :point_prefix || &#039;%&#039;<br \/>\n  AND (point LIKE &#039;%.PROCESS.cycle_time&#039; OR point LIKE &#039;%.PROCESS.spindle_load&#039;); <\/p>\n<p>\u6ce8\u610f\u8fd9\u91cc\u7528\u7684\u662f v_avg * v_cnt \u52a0\u6743&#xff0c;\u800c\u4e0d\u662f\u76f4\u63a5\u5bf9 v_avg \u6c42\u5e73\u5747\u2014\u2014\u5206\u949f\u7ea7\u805a\u5408\u8868\u7684\u6bcf\u4e00\u884c\u4ee3\u8868\u4e0d\u540c\u6570\u91cf\u7684\u539f\u59cb\u6837\u672c&#xff0c;\u76f4\u63a5\u5e73\u5747\u4f1a\u8ba9\u91c7\u6837\u7a00\u758f\u7684\u5206\u949f\u88ab\u8fc7\u5ea6\u653e\u5927\u3002<\/p>\n<p>\u4e3a\u4ec0\u4e48\u8fd9\u79cd\u300c\u6309\u9700\u53d6\u805a\u5408\u7ed3\u679c\u300d\u6bd4 MES \u76f4\u8fde\u8bbe\u5907\u70b9\u4f4d\u66f4\u5408\u7406&#xff0c;\u53ef\u4ee5\u4ece\u4e09\u4e2a\u89d2\u5ea6\u770b&#xff1a;<\/p>\n<ul>\n<li>\u6570\u636e\u91cf\u5dee\u4e86\u4e24\u4e2a\u6570\u91cf\u7ea7&#xff1a;\u4e00\u53f0\u8bbe\u5907\u4e00\u5929 432 \u4e07\u6761\u539f\u59cb\u70b9\u4f4d&#xff0c;\u805a\u5408\u5230\u5206\u949f\u7ea7\u53ea\u5269 1440 \u6761\u3002MES \u6bcf\u6b21\u53d6\u6570\u53ea\u626b\u805a\u5408\u8868&#xff0c;\u67e5\u8be2\u4ece\u5206\u949f\u7ea7\u964d\u5230\u6beb\u79d2\u7ea7&#xff0c;\u5de5\u5355\u62a5\u5de5\u3001\u6279\u6b21\u8ffd\u6eaf\u8fd9\u4e9b\u9ad8\u9891\u64cd\u4f5c\u4e0d\u4f1a\u88ab\u62d6\u6162\u3002<\/li>\n<li>\u804c\u8d23\u8fb9\u754c\u6e05\u6670&#xff1a;\u65f6\u5e8f\u5e93\u8d1f\u8d23\u9ad8\u9891\u5199\u5165\u3001\u964d\u91c7\u6837\u548c\u4fdd\u7559\u7b56\u7565&#xff0c;MES \u8d1f\u8d23\u5de5\u5355\u3001\u6279\u6b21\u548c\u4e1a\u52a1\u8bed\u4e49\u3002MES \u4e0d\u9700\u8981\u7406\u89e3\u70b9\u4f4d\u547d\u540d\u89c4\u5219&#xff0c;\u53ea\u9700\u8981\u77e5\u9053\u300c\u8fd9\u4e2a\u5de5\u5355\u3001\u8fd9\u53f0\u8bbe\u5907\u3001\u8fd9\u6bb5\u65f6\u95f4\u300d&#xff1b;\u70b9\u4f4d\u524d\u7f00\u548c\u805a\u5408\u53e3\u5f84\u7531\u6570\u636e\u5c42\u7edf\u4e00\u7ef4\u62a4&#xff0c;\u6539\u4e00\u6b21\u5168\u5382\u751f\u6548\u3002<\/li>\n<li>\u6545\u969c\u9694\u79bb&#xff1a;\u8bbe\u5907\u6296\u52a8\u3001\u7f51\u5173\u65ad\u8fde\u3001\u8865\u53d1\u6d2a\u5cf0\u90fd\u53d1\u751f\u5728\u65f6\u5e8f\u5e93\u8fd9\u4e00\u4fa7&#xff0c;MES \u7684\u5e93\u4e0d\u4f1a\u88ab\u5199\u5165\u653e\u5927\u6ce2\u53ca\u3002\u53cd\u8fc7\u6765&#xff0c;MES \u5347\u7ea7\u6216\u62a5\u8868\u9ad8\u5cf0\u4e5f\u4e0d\u4f1a\u5f71\u54cd\u91c7\u96c6\u94fe\u8def&#xff0c;\u4e24\u8fb9\u5404\u81ea\u6f14\u8fdb\u3002<\/li>\n<\/ul>\n<p>\u843d\u5730\u65f6\u5efa\u8bae\u628a\u53d6\u6570\u903b\u8f91\u5c01\u88c5\u6210\u4e00\u4e2a\u53ea\u8bfb\u63a5\u53e3&#xff08;\u6bd4\u5982 GET \/api\/oee\/points?work_order&#061;&#8230;&amp;prefix&#061;&#8230;&#xff09;&#xff0c;MES \u53ea\u8c03\u63a5\u53e3\u3001\u4e0d\u5199 SQL\u3002\u8fd9\u6837\u805a\u5408\u53e3\u5f84\u8c03\u6574\u3001\u65f6\u5e8f\u5e93\u4ece SQLite \u6362\u6210 TDengine \u6216 InfluxDB \u65f6&#xff0c;MES \u4fa7\u4e00\u884c\u4ee3\u7801\u90fd\u4e0d\u7528\u6539\u3002<\/p>\n<h3>\u4e94\u3001\u5de5\u7a0b\u5b9e\u73b0&#xff1a;\u4ece PLC \/ CNC \u5230\u65f6\u5e8f\u5e93\u7684\u4e00\u6761\u6700\u5c0f\u94fe\u8def<\/h3>\n<p>\u4e0b\u9762\u7ed9\u4e00\u6bb5\u53ef\u4ee5\u76f4\u63a5\u8dd1\u8d77\u6765\u7684\u53c2\u8003\u5b9e\u73b0\u3002\u4e3a\u4e86\u8ba9\u793a\u4f8b\u4e0d\u4f9d\u8d56\u7279\u5b9a\u786c\u4ef6&#xff0c;\u91c7\u96c6\u4fa7\u505a\u4e86\u53ef\u66ff\u6362\u7684\u5c01\u88c5&#xff1a;\u6709 OPC UA \u670d\u52a1\u5668\u5c31\u8d70 OPC UA&#xff0c;\u6ca1\u6709\u5c31\u7528\u6a21\u62df\u6570\u636e\u5148\u770b\u901a\u94fe\u8def\u3002<\/p>\n<h4>5.1 \u91c7\u96c6\u4e0e\u4e0a\u884c<\/h4>\n<p># -*- coding: utf-8 -*-<br \/>\n&#034;&#034;&#034;<br \/>\n\u8bbe\u5907\u6570\u636e\u91c7\u96c6\u6700\u5c0f\u94fe\u8def\u793a\u4f8b&#xff1a;\u91c7\u96c6 \u2192 \u70b9\u4f4d\u89c4\u8303\u5316 \u2192 MQTT \u4e0a\u884c<br \/>\n\u4f9d\u8d56&#xff1a;pip install asyncua paho-mqtt<br \/>\n\u8bf4\u660e&#xff1a;\u751f\u4ea7\u73af\u5883\u8bf7\u8865\u5168\u5f02\u5e38\u5904\u7406\u3001\u65ad\u7f51\u7eed\u4f20\u4e0e\u9274\u6743\u914d\u7f6e\u3002<br \/>\n&#034;&#034;&#034;<br \/>\nimport asyncio<br \/>\nimport json<br \/>\nimport time<br \/>\nimport random<br \/>\nfrom datetime import datetime<br \/>\n&#8212;&#8212;&#8212;- 1. \u70b9\u4f4d\u547d\u540d\u89c4\u8303\u5316 &#8212;&#8212;&#8212;-<br \/>\n\u547d\u540d\u89c4\u5219&#xff1a;{\u5382\u533a}.{\u4ea7\u7ebf}.{\u8bbe\u5907\u7c7b\u578b}.{\u8bbe\u5907\u7f16\u53f7}.{\u4fe1\u53f7\u7c7b\u522b}.{\u4fe1\u53f7\u540d}<br \/>\n\u8fd9\u4e00\u6b65\u5fc5\u987b\u6700\u5148\u505a\u3002\u540c\u4e00\u53f0\u8bbe\u5907\u5728\u4e09\u4e2a\u7cfb\u7edf\u91cc\u4e09\u4e2a\u540d\u5b57&#xff0c;\u662f\u540e\u671f\u6700\u96be\u6536\u62fe\u7684\u5751\u3002<br \/>\ndef make_point(workshop, line, dev_type, dev_no, category, signal):<br \/>\nreturn f&#034;{workshop}.{line}.{dev_type}.{dev_no}.{category}.{signal}&#034;<br \/>\ndef normalize(value, scale&#061;1.0, offset&#061;0.0, precision&#061;2):<br \/>\n&#034;&#034;&#034;\u91cf\u7a0b\u6362\u7b97 &#043; \u7cbe\u5ea6\u6536\u655b&#xff0c;\u907f\u514d\u6d6e\u70b9\u566a\u58f0\u6c61\u67d3\u65f6\u5e8f\u5e93&#034;&#034;&#034;<br \/>\nreturn round(value * scale &#043; offset, precision)<br \/>\n&#8212;&#8212;&#8212;- 2. \u91c7\u96c6\u5c01\u88c5 &#8212;&#8212;&#8212;-<br \/>\nclass MockSource:<br \/>\n&#034;&#034;&#034;\u6a21\u62df\u6570\u636e\u6e90&#xff1a;\u6ca1\u6709\u771f\u5b9e\u8bbe\u5907\u65f6\u5148\u628a\u94fe\u8def\u8dd1\u901a&#xff08;\u964d\u7ea7\u65b9\u6848&#xff09;&#034;&#034;&#034;<br \/>\ndef init(self, device_no):<br \/>\nself.device_no &#061; device_no<br \/>\nself._state &#061; &#034;RUN&#034;<br \/>\nasync def read(self):<br \/>\n    # \u771f\u5b9e\u573a\u666f\u66ff\u6362\u4e3a OPC UA \/ Modbus \u8bfb\u53d6<br \/>\n    if random.random() &amp;lt; 0.03:<br \/>\n        self._state &#061; random.choice([&#034;RUN&#034;, &#034;IDLE&#034;, &#034;ALARM&#034;])<br \/>\n    return {<br \/>\n        &#034;state&#034;: self._state,                        # \u8bbe\u5907\u72b6\u6001&#xff08;\u79bb\u6563\u91cf&#xff09;<br \/>\n        &#034;spindle_load&#034;: normalize(random.uniform(20, 85)),   # \u4e3b\u8f74\u8d1f\u8f7d %<br \/>\n        &#034;spindle_speed&#034;: normalize(random.uniform(800, 3000), precision&#061;0),  # \u8f6c\u901f rpm<br \/>\n        &#034;cycle_time&#034;: normalize(random.uniform(45, 75)),     # \u8282\u62cd \u79d2<br \/>\n    }<br \/>\nclass OpcUaSource:<br \/>\n&#034;&#034;&#034;<br \/>\n\u771f\u5b9e OPC UA \u91c7\u96c6&#xff1a;\u8fde\u63a5\u670d\u52a1\u5668 \u2192 \u6309 NodeId \u6279\u91cf\u8bfb\u53d6 \u2192 \u65ad\u7ebf\u91cd\u8fde &#043; \u8bfb\u53d6\u8d85\u65f6<br \/>\n\u5173\u952e\u53c2\u6570\u8bf4\u660e&#xff1a;<br \/>\nendpoint      : OPC UA \u670d\u52a1\u5668\u5730\u5740&#xff0c;\u5982 opc.tcp:\/\/192.168.1.10:4840<br \/>\nnode_map      : \u4fe1\u53f7\u540d \u2192 NodeId \u7684\u6620\u5c04&#xff0c;NodeId \u5f62\u5982 &#034;ns&#061;2;s&#061;CNC01.SpindleLoad&#034;<br \/>\nread_timeout  : \u5355\u6b21\u6279\u91cf\u8bfb\u53d6\u8d85\u65f6&#xff08;\u79d2&#xff09;&#xff0c;\u8d85\u65f6\u5373\u5224\u5b9a\u672c\u6b21\u91c7\u96c6\u5931\u8d25&#xff0c;\u907f\u514d\u4e3b\u5faa\u73af\u88ab\u5361\u6b7b<br \/>\nreconnect_interval : \u65ad\u7ebf\u540e\u91cd\u8fde\u95f4\u9694&#xff08;\u79d2&#xff09;&#xff0c;\u6307\u6570\u9000\u907f\u7684\u8d77\u59cb\u503c<br \/>\nmax_reconnect_interval : \u91cd\u8fde\u95f4\u9694\u4e0a\u9650&#xff08;\u79d2&#xff09;&#xff0c;\u9632\u6b62\u65e0\u9650\u589e\u957f<br \/>\n&#034;&#034;&#034;<br \/>\ndef init(self, endpoint, node_map, read_timeout&#061;3.0,<br \/>\nreconnect_interval&#061;1.0, max_reconnect_interval&#061;30.0):<br \/>\nself.endpoint &#061; endpoint<br \/>\nself.node_map &#061; node_map<br \/>\nself.read_timeout &#061; read_timeout<br \/>\nself.reconnect_interval &#061; reconnect_interval<br \/>\nself.max_reconnect_interval &#061; max_reconnect_interval<br \/>\nself._client &#061; None<br \/>\nself._nodes &#061; {}          # \u4fe1\u53f7\u540d \u2192 Node \u5bf9\u8c61&#xff0c;\u8fde\u63a5\u6210\u529f\u540e\u4e00\u6b21\u6027\u5efa\u597d<br \/>\nself._connected &#061; False<br \/>\nasync def connect(self):<br \/>\n    &#034;&#034;&#034;\u5efa\u7acb\u8fde\u63a5\u5e76\u7f13\u5b58 Node \u5bf9\u8c61&#xff1b;\u5931\u8d25\u65f6\u629b\u51fa\u5f02\u5e38\u7531\u4e0a\u5c42\u91cd\u8fde\u903b\u8f91\u5904\u7406&#034;&#034;&#034;<br \/>\n    from asyncua import Client<br \/>\n    self._client &#061; Client(url&#061;self.endpoint, timeout&#061;self.read_timeout)<br \/>\n    await self._client.connect()<br \/>\n    # \u6279\u91cf\u9884\u53d6 Node \u5bf9\u8c61&#xff0c;\u907f\u514d\u6bcf\u6b21\u8bfb\u53d6\u90fd\u91cd\u65b0\u89e3\u6790 NodeId<br \/>\n    self._nodes &#061; {<br \/>\n        signal: self._client.get_node(node_id)<br \/>\n        for signal, node_id in self.node_map.items()<br \/>\n    }<br \/>\n    self._connected &#061; True<br \/>\n    print(f&#034;[opcua] \u5df2\u8fde\u63a5 {self.endpoint}&#xff0c;\u70b9\u4f4d {len(self._nodes)} \u4e2a&#034;)<\/p>\n<p>async def read(self):<br \/>\n    &#034;&#034;&#034;\u6309 NodeId \u6279\u91cf\u8bfb\u53d6&#xff1b;\u65ad\u7ebf\u6216\u8d85\u65f6\u8fd4\u56de None&#xff0c;\u7531\u4e3b\u5faa\u73af\u51b3\u5b9a\u662f\u5426\u964d\u7ea7&#034;&#034;&#034;<br \/>\n    if not self._connected:<br \/>\n        return None<br \/>\n    try:<br \/>\n        # read_values \u4e00\u6b21\u8bf7\u6c42\u8bfb\u591a\u4e2a\u8282\u70b9&#xff0c;\u6bd4\u9010\u4e2a read_value \u5c11\u4e00\u4e2a\u6570\u91cf\u7ea7\u7684\u5f80\u8fd4<br \/>\n        values &#061; await asyncio.wait_for(<br \/>\n            self._nodes_read(), timeout&#061;self.read_timeout<br \/>\n        )<br \/>\n        return values<br \/>\n    except asyncio.TimeoutError:<br \/>\n        print(f&#034;[opcua] \u8bfb\u53d6\u8d85\u65f6&#xff08;&amp;gt;{self.read_timeout}s&#xff09;&#xff0c;\u672c\u6b21\u91c7\u96c6\u8df3\u8fc7&#034;)<br \/>\n        return None<br \/>\n    except Exception as e:<br \/>\n        print(f&#034;[opcua] \u8bfb\u53d6\u5f02\u5e38&#xff1a;{e}&#xff0c;\u6807\u8bb0\u65ad\u7ebf&#034;)<br \/>\n        self._connected &#061; False<br \/>\n        return None<\/p>\n<p>async def _nodes_read(self):<br \/>\n    &#034;&#034;&#034;\u5185\u90e8&#xff1a;\u6309 node_map \u987a\u5e8f\u6279\u91cf\u8bfb\u53d6\u5e76\u7ec4\u88c5\u4e3a {\u4fe1\u53f7\u540d: \u503c}&#034;&#034;&#034;<br \/>\n    signals &#061; list(self._nodes.keys())<br \/>\n    nodes &#061; [self._nodes[s] for s in signals]<br \/>\n    raw_values &#061; await self._client.read_values(nodes)<br \/>\n    result &#061; {}<br \/>\n    for signal, value in zip(signals, raw_values):<br \/>\n        # \u79bb\u6563\u91cf&#xff08;state&#xff09;\u4fdd\u6301\u5b57\u7b26\u4e32\u8bed\u4e49&#xff0c;\u6a21\u62df\u91cf\u4e0e MockSource \u5bf9\u9f50<br \/>\n        if signal &#061;&#061; &#034;state&#034;:<br \/>\n            result[signal] &#061; &#034;RUN&#034; if value else &#034;IDLE&#034;<br \/>\n        else:<br \/>\n            result[signal] &#061; normalize(float(value))<br \/>\n    return result<\/p>\n<p>async def ensure_connected(self):<br \/>\n    &#034;&#034;&#034;\u65ad\u7ebf\u91cd\u8fde&#xff1a;\u6307\u6570\u9000\u907f&#xff0c;\u76f4\u5230\u8fde\u4e0a\u6216\u8fbe\u5230\u4e0a\u9650&#034;&#034;&#034;<br \/>\n    delay &#061; self.reconnect_interval<br \/>\n    while not self._connected:<br \/>\n        try:<br \/>\n            await self.connect()<br \/>\n            return True<br \/>\n        except Exception as e:<br \/>\n            print(f&#034;[opcua] \u91cd\u8fde\u5931\u8d25&#xff1a;{e}&#xff0c;{delay:.1f}s \u540e\u91cd\u8bd5&#034;)<br \/>\n            await asyncio.sleep(delay)<br \/>\n            delay &#061; min(delay * 2, self.max_reconnect_interval)<br \/>\n    return True<\/p>\n<p>async def close(self):<br \/>\n    if self._client:<br \/>\n        try:<br \/>\n            await self._client.disconnect()<br \/>\n        except Exception:<br \/>\n            pass<br \/>\n    self._connected &#061; False<br \/>\n&#8212;&#8212;&#8212;- 3. MQTT \u4e0a\u884c &#8212;&#8212;&#8212;-<br \/>\nclass MqttUploader:<br \/>\ndef init(self, host, port&#061;1883, topic&#061;&#034;factory\/l1\/telemetry&#034;):<br \/>\nimport paho.mqtt.client as mqtt<br \/>\nself.topic &#061; topic<br \/>\nself.client &#061; mqtt.Client(client_id&#061;f&#034;gw-{int(time.time())}&#034;)<br \/>\nself.client.connect(host, port, keepalive&#061;60)<br \/>\nself.client.loop_start()<br \/>\ndef publish(self, payload: dict):<br \/>\n    # qos&#061;1 \u4fdd\u8bc1\u81f3\u5c11\u4e00\u6b21\u9001\u8fbe&#xff1b;\u65f6\u5e8f\u6570\u636e\u5141\u8bb8\u5c11\u91cf\u91cd\u590d&#xff0c;\u4e0d\u5141\u8bb8\u4e22<br \/>\n    self.client.publish(self.topic, json.dumps(payload), qos&#061;1)<br \/>\n&#8212;&#8212;&#8212;- 4. \u4e3b\u5faa\u73af &#8212;&#8212;&#8212;-<br \/>\nasync def main():<br \/>\nworkshop, line &#061; &#034;SH01&#034;, &#034;LINE_A&#034;<br \/>\ndevices &#061; [(&#034;CNC&#034;, &#034;01&#034;), (&#034;CNC&#034;, &#034;02&#034;)]<br \/>\n# \u6709 OPC UA \u670d\u52a1\u5668\u5c31\u8d70\u771f\u5b9e\u91c7\u96c6&#xff0c;\u6ca1\u6709\u5219\u964d\u7ea7\u4e3a MockSource<br \/>\nUSE_OPCUA &#061; True<br \/>\nOPCUA_ENDPOINT &#061; &#034;opc.tcp:\/\/192.168.1.10:4840&#034;<br \/>\nNODE_MAP &#061; {<br \/>\n    &#034;state&#034;:         &#034;ns&#061;2;s&#061;CNC01.Status.State&#034;,<br \/>\n    &#034;spindle_load&#034;:  &#034;ns&#061;2;s&#061;CNC01.Process.SpindleLoad&#034;,<br \/>\n    &#034;spindle_speed&#034;: &#034;ns&#061;2;s&#061;CNC01.Process.SpindleSpeed&#034;,<br \/>\n    &#034;cycle_time&#034;:    &#034;ns&#061;2;s&#061;CNC01.Process.CycleTime&#034;,<br \/>\n}<\/p>\n<p>sources &#061; {}<br \/>\nfor dev_type, dev_no in devices:<br \/>\n    if USE_OPCUA:<br \/>\n        src &#061; OpcUaSource(OPCUA_ENDPOINT, NODE_MAP)<br \/>\n        await src.ensure_connected()<br \/>\n        sources[dev_no] &#061; src<br \/>\n    else:<br \/>\n        sources[dev_no] &#061; MockSource(dev_no)<\/p>\n<p># \u751f\u4ea7\u73af\u5883\u66ff\u6362\u4e3a\u771f\u5b9e broker \u5730\u5740<br \/>\nup &#061; MqttUploader(host&#061;&#034;127.0.0.1&#034;)<\/p>\n<p>while True:<br \/>\n    ts &#061; datetime.utcnow().isoformat(timespec&#061;&#034;milliseconds&#034;) &#043; &#034;Z&#034;<br \/>\n    batch &#061; []<br \/>\n    for dev_type, dev_no in devices:<br \/>\n        src &#061; sources[dev_no]<br \/>\n        raw &#061; await src.read()<br \/>\n        # \u8bfb\u53d6\u5931\u8d25&#xff1a;OPC UA \u65ad\u7ebf\u65f6\u964d\u7ea7\u5230 MockSource&#xff0c;\u4fdd\u8bc1\u94fe\u8def\u4e0d\u65ad\u6d41<br \/>\n        if raw is None:<br \/>\n            if isinstance(src, OpcUaSource):<br \/>\n                print(f&#034;[{dev_no}] OPC UA \u4e0d\u53ef\u7528&#xff0c;\u964d\u7ea7\u4e3a\u6a21\u62df\u6570\u636e&#034;)<br \/>\n                raw &#061; await MockSource(dev_no).read()<br \/>\n                asyncio.create_task(src.ensure_connected())  # \u540e\u53f0\u91cd\u8fde<br \/>\n            else:<br \/>\n                continue<br \/>\n        for signal, value in raw.items():<br \/>\n            category &#061; &#034;STATUS&#034; if signal &#061;&#061; &#034;state&#034; else &#034;PROCESS&#034;<br \/>\n            batch.append({<br \/>\n                &#034;ts&#034;: ts,<br \/>\n                &#034;point&#034;: make_point(workshop, line, dev_type, dev_no, category, signal),<br \/>\n                &#034;value&#034;: value,<br \/>\n            })<br \/>\n    # \u6279\u91cf\u4e0a\u62a5&#xff0c;\u907f\u514d\u9010\u70b9\u53d1\u9001\u628a broker \u6253\u6ee1<br \/>\n    up.publish({&#034;ts&#034;: ts, &#034;data&#034;: batch})<br \/>\n    print(f&#034;[{ts}] \u4e0a\u62a5 {len(batch)} \u4e2a\u70b9\u4f4d&#034;)<br \/>\n    await asyncio.sleep(1)<br \/>\nif name &#061;&#061; &#034;main&#034;:<br \/>\nasyncio.run(main()) <\/p>\n<h5>\u65ad\u7f51\u7eed\u4f20\u4e0e\u5f02\u5e38\u5904\u7406<\/h5>\n<p>\u4e0a\u9762\u90a3\u6bb5\u4ee3\u7801\u6709\u4e00\u4e2a\u81f4\u547d\u5047\u8bbe&#xff1a;\u7f51\u7edc\u4e00\u76f4\u662f\u901a\u7684\u3002\u8f66\u95f4\u91cc\u65ad\u7f51\u662f\u5e38\u6001\u2014\u2014\u4ea4\u6362\u673a\u91cd\u542f\u3001\u65e0\u7ebf AP \u6389\u7ebf\u3001broker \u5347\u7ea7&#xff0c;\u4efb\u4f55\u4e00\u6b21\u6296\u52a8\u90fd\u4f1a\u8ba9 publish \u629b\u5f02\u5e38\u6216\u8005\u9759\u9ed8\u4e22\u5305\u3002\u6240\u4ee5\u8fb9\u7f18\u7f51\u5173\u5fc5\u987b\u81ea\u5e26\u4e00\u5757\u672c\u5730\u7f13\u5b58&#xff0c;\u65ad\u8fde\u65f6\u5199\u672c\u5730\u3001\u91cd\u8fde\u540e\u6309\u65f6\u95f4\u987a\u5e8f\u8865\u53d1\u3002<\/p>\n<p>\u8fd9\u91cc\u7528 SQLite \u505a\u73af\u5f62\u7f13\u5b58\u961f\u5217&#xff0c;\u96f6\u5916\u90e8\u4f9d\u8d56&#xff0c;\u6389\u7535\u4e5f\u4e0d\u4e22\u3002\u4e09\u4e2a\u8bbe\u8ba1\u8981\u70b9&#xff1a;<\/p>\n<ul>\n<li>\u73af\u5f62\u961f\u5217&#xff1a;\u8868\u91cc\u53ea\u4fdd\u7559\u6700\u8fd1 N \u6761&#xff08;\u6bd4\u5982 50 \u4e07\u6761&#xff09;&#xff0c;\u8d85\u51fa\u540e\u6309 ts \u6dd8\u6c70\u6700\u8001\u7684&#xff0c;\u9632\u6b62\u78c1\u76d8\u88ab\u5199\u6ee1\u628a\u7f51\u5173\u641e\u5d29\u3002<\/li>\n<li>\u6309\u65f6\u95f4\u987a\u5e8f\u8865\u53d1&#xff1a;\u8865\u53d1\u65f6\u4e25\u683c\u6309 ts \u5347\u5e8f\u53d6&#xff0c;\u4fdd\u8bc1\u65f6\u5e8f\u5e93\u91cc\u7684\u6570\u636e\u4e0d\u4e71\u5e8f&#xff0c;\u5426\u5219\u964d\u91c7\u6837\u548c\u8d8b\u52bf\u67e5\u8be2\u90fd\u4f1a\u51fa\u95ee\u9898\u3002<\/li>\n<li>\u5e42\u7b49\u53bb\u91cd&#xff1a;qos&#061;1 \u662f\u201c\u81f3\u5c11\u4e00\u6b21\u201d&#xff0c;\u91cd\u8fde\u8865\u53d1\u3001broker \u91cd\u6295\u90fd\u4f1a\u4ea7\u751f\u91cd\u590d\u3002\u843d\u5e93\u4fa7\u7528 (ts, point) \u505a\u8054\u5408\u4e3b\u952e&#xff0c;INSERT OR REPLACE \u5e42\u7b49\u5199\u5165&#xff0c;\u91cd\u590d\u6570\u636e\u81ea\u7136\u88ab\u8986\u76d6\u3002<\/li>\n<\/ul>\n<p># -*- coding: utf-8 -*-<br \/>\n&#034;&#034;&#034;<br \/>\n\u65ad\u7f51\u7eed\u4f20&#xff1a;SQLite \u73af\u5f62\u7f13\u5b58\u961f\u5217 &#043; \u91cd\u8fde\u8865\u53d1<br \/>\n\u4f9d\u8d56&#xff1a;pip install paho-mqtt<br \/>\n\u601d\u8def&#xff1a;\u53d1\u9001\u524d\u5148\u843d\u672c\u5730&#xff0c;\u53d1\u9001\u6210\u529f\u518d\u5220\u9664&#xff1b;\u65ad\u8fde\u65f6\u53ea\u5199\u4e0d\u5220&#xff0c;\u91cd\u8fde\u540e\u6309 ts \u5347\u5e8f\u8865\u53d1\u3002<br \/>\n&#034;&#034;&#034;<br \/>\nimport json<br \/>\nimport sqlite3<br \/>\nimport time<br \/>\nimport threading<br \/>\nCACHE_DB &#061; &#034;edge_cache.db&#034;<br \/>\nMAX_ROWS &#061; 500_000          # \u73af\u5f62\u961f\u5217\u5bb9\u91cf&#xff0c;\u6309\u78c1\u76d8\u548c\u65ad\u7f51\u65f6\u957f\u4f30\u7b97<br \/>\nBATCH_SIZE &#061; 500            # \u5355\u6b21\u8865\u53d1\u6279\u91cf&#xff0c;\u907f\u514d\u4e00\u6b21\u6027\u628a broker \u6253\u6ee1<br \/>\nclass LocalQueue:<br \/>\n&#034;&#034;&#034;\u672c\u5730\u73af\u5f62\u7f13\u5b58\u961f\u5217&#xff1a;\u5148\u843d\u76d8&#xff0c;\u518d\u53d1\u9001&#xff0c;\u6210\u529f\u624d\u5220\u9664&#034;&#034;&#034;<br \/>\ndef __init__(self, db_path&#061;CACHE_DB, max_rows&#061;MAX_ROWS):<br \/>\n    self.max_rows &#061; max_rows<br \/>\n    self._lock &#061; threading.Lock()<br \/>\n    self.conn &#061; sqlite3.connect(db_path, check_same_thread&#061;False)<br \/>\n    self.conn.execute(&#034;PRAGMA journal_mode&#061;WAL&#034;)   # \u8bfb\u5199\u5e76\u53d1\u66f4\u7a33&#xff0c;\u6389\u7535\u66f4\u5b89\u5168<br \/>\n    self.conn.execute(&#034;&#034;&#034;<br \/>\n        CREATE TABLE IF NOT EXISTS outbox (<br \/>\n            id     INTEGER PRIMARY KEY AUTOINCREMENT,<br \/>\n            ts     TEXT NOT NULL,      &#8212; ISO8601 \u6beb\u79d2\u65f6\u95f4\u6233&#xff0c;\u8865\u53d1\u6392\u5e8f\u4f9d\u636e<br \/>\n            topic  TEXT NOT NULL,<br \/>\n            payload TEXT NOT NULL<br \/>\n        )<br \/>\n    &#034;&#034;&#034;)<br \/>\n    self.conn.execute(&#034;CREATE INDEX IF NOT EXISTS idx_outbox_ts ON outbox(ts)&#034;)<br \/>\n    self.conn.commit()<br \/>\ndef put(self, ts, topic, payload):<br \/>\n&#034;&#034;&#034;\u5165\u961f&#xff1a;\u5199\u5165\u672c\u5730&#xff0c;\u540c\u65f6\u505a\u73af\u5f62\u6dd8\u6c70&#034;&#034;&#034;<br \/>\nwith self._lock:<br \/>\nself.conn.execute(<br \/>\n&#034;INSERT INTO outbox (ts, topic, payload) VALUES (?, ?, ?)&#034;,<br \/>\n(ts, topic, json.dumps(payload, ensure_ascii&#061;False)),<br \/>\n)<br \/>\n# \u73af\u5f62\u6dd8\u6c70&#xff1a;\u53ea\u4fdd\u7559\u6700\u8fd1 max_rows \u6761<br \/>\nself.conn.execute(<br \/>\n&#034;DELETE FROM outbox WHERE id &lt;&#061; (SELECT MAX(id) &#8211; ? FROM outbox)&#034;,<br \/>\n(self.max_rows,),<br \/>\n)<br \/>\nself.conn.commit()<br \/>\ndef peek_batch(self, limit&#061;BATCH_SIZE):<br \/>\n&#034;&#034;&#034;\u6309\u65f6\u95f4\u987a\u5e8f\u53d6\u4e00\u6279\u5f85\u8865\u53d1\u6570\u636e&#034;&#034;&#034;<br \/>\nwith self._lock:<br \/>\ncur &#061; self.conn.execute(<br \/>\n&#034;SELECT id, ts, topic, payload FROM outbox ORDER BY ts ASC, id ASC LIMIT ?&#034;,<br \/>\n(limit,),<br \/>\n)<br \/>\nreturn cur.fetchall()<br \/>\ndef ack(self, ids):<br \/>\n&#034;&#034;&#034;\u53d1\u9001\u6210\u529f\u540e\u5220\u9664&#xff0c;ack \u4e4b\u524d\u5d29\u6e83\u4f1a\u91cd\u53d1&#xff0c;\u9760\u4e0b\u6e38\u5e42\u7b49\u515c\u5e95&#034;&#034;&#034;<br \/>\nif not ids:<br \/>\nreturn<br \/>\nwith self._lock:<br \/>\nself.conn.executemany(&#034;DELETE FROM outbox WHERE id &#061; ?&#034;, [(i,) for i in ids])<br \/>\nself.conn.commit()<br \/>\ndef pending(self):<br \/>\nwith self._lock:<br \/>\nreturn self.conn.execute(&#034;SELECT COUNT(*) FROM outbox&#034;).fetchone()[0]<br \/>\nclass ReliableUploader:<br \/>\n&#034;&#034;&#034;\u5e26\u65ad\u7f51\u7eed\u4f20\u7684 MQTT \u4e0a\u884c\u5c01\u88c5&#034;&#034;&#034;<br \/>\ndef init(self, host, port&#061;1883, topic&#061;&#034;factory\/l1\/telemetry&#034;):<br \/>\nimport paho.mqtt.client as mqtt<br \/>\nself.topic &#061; topic<br \/>\nself.queue &#061; LocalQueue()<br \/>\nself.online &#061; False<br \/>\nself.client &#061; mqtt.Client(client_id&#061;f&#034;gw-{int(time.time())}&#034;)<br \/>\nself.client.on_connect &#061; self._on_connect<br \/>\nself.client.on_disconnect &#061; self._on_disconnect<br \/>\nself.client.connect_async(host, port, keepalive&#061;60)  # \u5f02\u6b65\u8fde\u63a5&#xff0c;\u65ad\u7f51\u4e0d\u963b\u585e\u4e3b\u5faa\u73af<br \/>\nself.client.loop_start()<br \/>\ndef _on_connect(self, client, userdata, flags, rc):<br \/>\nself.online &#061; (rc &#061;&#061; 0)<br \/>\nif self.online:<br \/>\nprint(&#034;[mqtt] \u5df2\u8fde\u63a5&#xff0c;\u5f00\u59cb\u8865\u53d1\u672c\u5730\u7f13\u5b58&#034;)<br \/>\nthreading.Thread(target&#061;self._flush, daemon&#061;True).start()<br \/>\ndef _on_disconnect(self, client, userdata, rc):<br \/>\nself.online &#061; False<br \/>\nprint(f&#034;[mqtt] \u8fde\u63a5\u65ad\u5f00 rc&#061;{rc}&#xff0c;\u8f6c\u5165\u672c\u5730\u7f13\u5b58\u6a21\u5f0f&#034;)<br \/>\ndef publish(self, ts, payload):<br \/>\n&#034;&#034;&#034;\u7edf\u4e00\u5165\u53e3&#xff1a;\u65e0\u8bba\u5728\u7ebf\u4e0e\u5426&#xff0c;\u5148\u843d\u672c\u5730&#xff0c;\u518d\u5c1d\u8bd5\u53d1\u9001&#034;&#034;&#034;<br \/>\nself.queue.put(ts, self.topic, payload)<br \/>\nif self.online:<br \/>\nself._flush()<br \/>\ndef _flush(self):<br \/>\n&#034;&#034;&#034;\u6309\u65f6\u95f4\u987a\u5e8f\u8865\u53d1&#xff0c;\u53d1\u9001\u6210\u529f\u624d ack \u5220\u9664&#034;&#034;&#034;<br \/>\nwhile self.online:<br \/>\nrows &#061; self.queue.peek_batch()<br \/>\nif not rows:<br \/>\nreturn<br \/>\nok_ids &#061; []<br \/>\nfor rid, ts, topic, payload in rows:<br \/>\ninfo &#061; self.client.publish(topic, payload, qos&#061;1)<br \/>\n# wait_for_publish \u786e\u8ba4 broker \u5df2\u63a5\u6536&#xff0c;\u907f\u514d\u201c\u5047\u6210\u529f\u201d\u4e22\u6570\u636e<br \/>\ntry:<br \/>\ninfo.wait_for_publish(timeout&#061;5)<br \/>\nif info.is_published():<br \/>\nok_ids.append(rid)<br \/>\nelse:<br \/>\nbreak<br \/>\nexcept Exception:<br \/>\nself.online &#061; False<br \/>\nbreak<br \/>\nself.queue.ack(ok_ids)<br \/>\nif not self.online:<br \/>\nreturn<br \/>\n&#8212;&#8212;&#8212;- \u843d\u5e93\u4fa7&#xff1a;qos&#061;1 \u91cd\u590d\u6570\u636e\u7684\u5e42\u7b49\u53bb\u91cd &#8212;&#8212;&#8212;-<br \/>\ndef init_sink(conn):<br \/>\n&#034;&#034;&#034;ts &#043; point \u8054\u5408\u4e3b\u952e&#xff0c;\u5929\u7136\u5e42\u7b49&#xff1a;\u91cd\u590d\u5199\u5165\u53ea\u4f1a\u8986\u76d6&#xff0c;\u4e0d\u4f1a\u4ea7\u751f\u810f\u6570\u636e&#034;&#034;&#034;<br \/>\nconn.execute(&#034;&#034;&#034;<br \/>\nCREATE TABLE IF NOT EXISTS raw (<br \/>\nts    TEXT NOT NULL,     &#8212; \u4e0e\u4e0a\u884c payload \u4e2d\u7684 ts \u5b8c\u5168\u4e00\u81f4<br \/>\npoint TEXT NOT NULL,<br \/>\nvalue REAL,<br \/>\nPRIMARY KEY (ts, point)<br \/>\n)<br \/>\n&#034;&#034;&#034;)<br \/>\nconn.commit()<br \/>\ndef write_idempotent(conn, rows):<br \/>\n&#034;&#034;&#034;rows: [(ts, point, value), &#8230;]<br \/>\nqos&#061;1 \u4e0b\u540c\u4e00\u6761\u6570\u636e\u53ef\u80fd\u88ab\u6295\u9012\u591a\u6b21&#xff0c;INSERT OR REPLACE \u4fdd\u8bc1\u7ed3\u679c\u4e00\u81f4\u3002<br \/>\n&#034;&#034;&#034;<br \/>\nconn.executemany(<br \/>\n&#034;INSERT OR REPLACE INTO raw (ts, point, value) VALUES (?, ?, ?)&#034;, rows<br \/>\n)<br \/>\nconn.commit()<br \/>\nif name &#061;&#061; &#034;main&#034;:<br \/>\nup &#061; ReliableUploader(host&#061;&#034;127.0.0.1&#034;)<br \/>\nwhile True:<br \/>\nts &#061; time.strftime(&#034;%Y-%m-%dT%H:%M:%S&#034;, time.gmtime()) &#043; &#034;.000Z&#034;<br \/>\nup.publish(ts, {&#034;ts&#034;: ts, &#034;data&#034;: [{&#034;point&#034;: &#034;SH01.LINE_A.CNC.01.PROCESS.spindle_load&#034;, &#034;value&#034;: 62.5}]})<br \/>\nprint(f&#034;[{ts}] \u672c\u5730\u5f85\u8865\u53d1 {up.queue.pending()} \u6761&#034;)<br \/>\ntime.sleep(1) <\/p>\n<p>\u51e0\u4e2a\u5bb9\u6613\u5ffd\u7565\u7684\u7ec6\u8282&#xff1a;<\/p>\n<ul>\n<li>\u5148\u843d\u76d8\u518d\u53d1\u9001&#xff0c;\u800c\u4e0d\u662f\u53d1\u9001\u5931\u8d25\u518d\u843d\u76d8\u3002\u540e\u8005\u5728\u8fdb\u7a0b\u88ab kill \u6216\u6389\u7535\u65f6\u4f1a\u4e22\u6389\u6b63\u5728\u53d1\u9001\u7684\u90a3\u4e00\u6279\u3002<\/li>\n<li>ack \u4e4b\u524d\u5d29\u6e83\u4f1a\u91cd\u53d1&#xff0c;\u8fd9\u662f\u6709\u610f\u4e3a\u4e4b\u2014\u2014\u5b81\u53ef\u91cd\u590d&#xff0c;\u4e0d\u53ef\u4e22\u5931\u3002\u91cd\u590d\u7531\u4e0b\u6e38 (ts, point) \u4e3b\u952e\u515c\u4f4f\u3002<\/li>\n<li>\u8865\u53d1\u8981\u9650\u901f\u3002\u65ad\u7f51\u4e24\u5c0f\u65f6\u53ef\u80fd\u79ef\u538b\u51e0\u5341\u4e07\u6761&#xff0c;\u91cd\u8fde\u540e\u4e00\u6b21\u6027\u704c\u8fdb\u53bb\u4f1a\u628a broker \u548c\u65f6\u5e8f\u5e93\u6253\u6ee1&#xff0c;\u6240\u4ee5\u7528 BATCH_SIZE \u5206\u6279&#xff0c;\u5fc5\u8981\u65f6\u52a0 sleep\u3002<\/li>\n<li>\u73af\u5f62\u5bb9\u91cf\u8981\u7b97\u6e05\u695a\u300250 \u4e07\u6761\u6309\u6bcf\u79d2 100 \u6761\u7b97\u7ea6 1.4 \u5c0f\u65f6&#xff0c;\u5982\u679c\u73b0\u573a\u65ad\u7f51\u53ef\u80fd\u8d85\u8fc7\u8fd9\u4e2a\u65f6\u957f&#xff0c;\u5c31\u8981\u8c03\u5927 MAX_ROWS \u6216\u964d\u4f4e\u91c7\u96c6\u9891\u7387\u3002<\/li>\n<\/ul>\n<h4>5.2 \u843d\u5e93\u4e0e\u964d\u91c7\u6837<\/h4>\n<p>\u65f6\u5e8f\u6570\u636e\u843d\u5730\u540e&#xff0c;\u771f\u6b63\u51b3\u5b9a\u8fd9\u5957\u7cfb\u7edf\u80fd\u6d3b\u591a\u4e45\u7684\u662f\u964d\u91c7\u6837\u7b56\u7565\u3002\u539f\u59cb\u6570\u636e\u4fdd\u7559\u77ed\u671f&#xff0c;\u805a\u5408\u6570\u636e\u4fdd\u7559\u957f\u671f&#xff0c;\u5426\u5219\u534a\u5e74\u540e\u67e5\u8be2\u6027\u80fd\u4f1a\u5d29\u6389\u3002<\/p>\n<p># -*- coding: utf-8 -*-<br \/>\n&#034;&#034;&#034;<br \/>\n\u65f6\u5e8f\u6570\u636e\u843d\u5e93\u4e0e\u964d\u91c7\u6837\u793a\u4f8b&#xff08;SQLite \u7248&#xff0c;\u96f6\u5916\u90e8\u4f9d\u8d56\u5373\u53ef\u8fd0\u884c&#xff09;<br \/>\n\u751f\u4ea7\u73af\u5883\u53ef\u66ff\u6362\u4e3a InfluxDB \/ TDengine&#xff0c;\u903b\u8f91\u4e00\u81f4\u3002<br \/>\n&#034;&#034;&#034;<br \/>\nimport sqlite3<br \/>\nimport time<br \/>\nfrom datetime import datetime, timedelta<br \/>\nDB &#061; &#034;telemetry.db&#034;<br \/>\ndef init_db(conn):<br \/>\nconn.execute(&#034;&#034;&#034;<br \/>\nCREATE TABLE IF NOT EXISTS raw (<br \/>\nts INTEGER NOT NULL,     &#8212; \u6beb\u79d2\u65f6\u95f4\u6233<br \/>\npoint TEXT NOT NULL,     &#8212; \u70b9\u4f4d\u5168\u540d<br \/>\nvalue REAL,<br \/>\nPRIMARY KEY (ts, point)<br \/>\n)<br \/>\n&#034;&#034;&#034;)<br \/>\nconn.execute(&#034;&#034;&#034;<br \/>\nCREATE TABLE IF NOT EXISTS agg_1m (<br \/>\nts INTEGER NOT NULL,     &#8212; \u5bf9\u9f50\u5230\u5206\u949f<br \/>\npoint TEXT NOT NULL,<br \/>\nv_avg REAL, v_min REAL, v_max REAL, v_cnt INTEGER,<br \/>\nPRIMARY KEY (ts, point)<br \/>\n)<br \/>\n&#034;&#034;&#034;)<br \/>\nconn.execute(&#034;CREATE INDEX IF NOT EXISTS idx_raw_point ON raw(point, ts)&#034;)<br \/>\nconn.commit()<br \/>\ndef write_batch(conn, rows):<br \/>\n&#034;&#034;&#034;rows: [(ts_ms, point, value), &#8230;]&#034;&#034;&#034;<br \/>\nconn.executemany(<br \/>\n&#034;INSERT OR REPLACE INTO raw (ts, point, value) VALUES (?, ?, ?)&#034;, rows<br \/>\n)<br \/>\nconn.commit()<br \/>\ndef rollup_to_1m(conn, end_ms, window_min&#061;1):<br \/>\n&#034;&#034;&#034;\u628a\u7a97\u53e3\u5185\u7684\u539f\u59cb\u6570\u636e\u805a\u5408\u4e3a\u5206\u949f\u7ea7&#xff0c;\u5e76\u5220\u9664\u5df2\u805a\u5408\u7684\u539f\u59cb\u6570\u636e&#034;&#034;&#034;<br \/>\nstart_ms &#061; end_ms &#8211; window_min * 60 * 1000<br \/>\ncur &#061; conn.execute(&#034;&#034;&#034;<br \/>\nSELECT point,<br \/>\nAVG(value), MIN(value), MAX(value), COUNT(*)<br \/>\nFROM raw WHERE ts &gt;&#061; ? AND ts &lt; ? GROUP BY point<br \/>\n&#034;&#034;&#034;, (start_ms, end_ms))<br \/>\nagg &#061; cur.fetchall()<br \/>\nminute_ts &#061; (end_ms \/\/ 60000) * 60000<br \/>\nconn.executemany(<br \/>\n&#034;INSERT OR REPLACE INTO agg_1m (ts, point, v_avg, v_min, v_max, v_cnt) &#034;<br \/>\n&#034;VALUES (?, ?, ?, ?, ?, ?)&#034;,<br \/>\n[(minute_ts, p, a, mi, ma, c) for p, a, mi, ma, c in agg]<br \/>\n)<br \/>\nconn.execute(&#034;DELETE FROM raw WHERE ts &gt;&#061; ? AND ts &lt; ?&#034;, (start_ms, end_ms))<br \/>\nconn.commit()<br \/>\nreturn len(agg)<br \/>\ndef query_trend(conn, point, hours&#061;8):<br \/>\n&#034;&#034;&#034;\u67e5\u8be2\u8fd1 N \u5c0f\u65f6\u8d8b\u52bf&#xff1a;\u4f18\u5148\u8d70\u805a\u5408\u8868&#xff0c;\u8fd9\u662f\u770b\u677f\u80fd\u79d2\u5f00\u7684\u539f\u56e0&#034;&#034;&#034;<br \/>\nsince &#061; int((datetime.utcnow() &#8211; timedelta(hours&#061;hours)).timestamp() * 1000)<br \/>\ncur &#061; conn.execute(<br \/>\n&#034;SELECT ts, v_avg FROM agg_1m WHERE point &#061; ? AND ts &gt;&#061; ? ORDER BY ts&#034;,<br \/>\n(point, since)<br \/>\n)<br \/>\nreturn cur.fetchall()<br \/>\nif name &#061;&#061; &#034;main&#034;:<br \/>\nconn &#061; sqlite3.connect(DB)<br \/>\ninit_db(conn)<br \/>\n# \u6a21\u62df\u5199\u5165 120 \u79d2\u6570\u636e&#xff08;\u6bcf\u79d2\u4e00\u4e2a\u70b9&#xff09;<br \/>\nnow &#061; int(time.time() * 1000)<br \/>\nrows &#061; []<br \/>\nfor i in range(120):<br \/>\n    ts &#061; now &#8211; (120 &#8211; i) * 1000<br \/>\n    rows.append((ts, &#034;SH01.LINE_A.CNC.01.PROCESS.spindle_load&#034;, 40 &#043; i % 30))<br \/>\nwrite_batch(conn, rows)<br \/>\nprint(&#034;\u5199\u5165\u539f\u59cb\u70b9\u4f4d\u6570:&#034;, len(rows))<br \/>\n\u805a\u5408\u4e3a\u5206\u949f\u7ea7<br \/>\nn &#061; rollup_to_1m(conn, now, window_min&#061;5)<br \/>\nprint(&#034;\u805a\u5408\u70b9\u4f4d:&#034;, n)<br \/>\n\u67e5\u8be2\u8d8b\u52bf<br \/>\ntrend &#061; query_trend(conn, &#034;SH01.LINE_A.CNC.01.PROCESS.spindle_load&#034;)<br \/>\nprint(&#034;\u8d8b\u52bf\u70b9\u6570:&#034;, len(trend), &#034;\u793a\u4f8b:&#034;, trend[:3])<br \/>\nconn.close()&lt;\/code&gt;&lt;\/pre&gt;<br \/>\n\u8fd9\u6bb5\u4ee3\u7801\u8dd1\u8d77\u6765\u4e0d\u9700\u8981\u4efb\u4f55\u5916\u90e8\u670d\u52a1&#xff0c;\u5efa\u8bae\u5148\u5728\u7b14\u8bb0\u672c\u4e0a\u628a\u94fe\u8def\u8d70\u4e00\u904d&#xff0c;\u518d\u63a5\u5230\u771f\u5b9e\u8bbe\u5907\u4e0a\u3002\u987a\u5e8f\u5f88\u91cd\u8981&#xff1a;\u5148\u9a8c\u8bc1\u94fe\u8def&#xff0c;\u518d\u63a5\u8bbe\u5907&#xff0c;\u53cd\u8fc7\u6765\u505a\u4f1a\u5728\u73b0\u573a\u6d6a\u8d39\u5927\u91cf\u65f6\u95f4\u3002<br \/>\n\u516d\u3001\u4e09\u4e2a\u771f\u5b9e\u4f1a\u8e29\u7684\u5751<br \/>\n\u5751\u4e00&#xff1a;\u8001\u65e7\u8bbe\u5907\u6ca1\u6709\u7f51\u53e3\u3002<br \/>\n\u5341\u5e74\u524d\u7684 CNC \u53ea\u6709 RS-232 \u4e32\u53e3&#xff0c;\u6216\u8005\u8fde PLC \u90fd\u6ca1\u6709\u3002\u53ef\u884c\u505a\u6cd5\u6709\u4e09\u6863&#xff1a;\u6709\u4e32\u53e3\u7684\u8d70 Modbus RTU \u8f6c\u7f51\u5173&#xff1b;\u53ea\u6709 IO \u4fe1\u53f7\u7684\u7528 IO \u6a21\u5757\u91c7\u8fd0\u884c\u72b6\u6001&#xff1b;\u8fde\u72b6\u6001\u90fd\u91c7\u4e0d\u5230\u7684&#xff0c;\u7528\u5916\u63a5\u7535\u6d41\u4e92\u611f\u5668\u6d4b\u6574\u673a\u529f\u7387&#xff0c;\u53cd\u63a8\u8fd0\u884c\/\u5f85\u673a\/\u505c\u673a\u2014\u2014\u8fd9\u4e0d\u662f\u53d6\u5de7&#xff0c;\u800c\u662f\u5f88\u591a\u8001\u4ea7\u7ebf\u552f\u4e00\u80fd\u843d\u5730\u7684\u65b9\u6848&#xff0c;\u7cbe\u5ea6\u4e5f\u591f\u7528\u6765\u7b97 OEE&#xff08;\u8bbe\u5907\u7efc\u5408\u6548\u7387&#xff0c;Overall Equipment Effectiveness&#xff09;\u3002<br \/>\n\u5751\u4e8c&#xff1a;\u70b9\u4f4d\u547d\u540d\u6ca1\u6709\u6807\u51c6\u3002<br \/>\n\u540c\u4e00\u53f0\u6ce8\u5851\u673a&#xff0c;\u5728\u8bbe\u5907\u53f0\u8d26\u91cc\u53eb&#034;IM-03&#034;&#xff0c;\u5728\u7535\u5de5\u53e3\u91cc\u53eb&#034;\u4e09\u53f7\u673a&#034;&#xff0c;\u5728 MES \u91cc\u53eb&#034;INJ_003&#034;\u3002\u4e09\u4e2a\u540d\u5b57\u6307\u5411\u540c\u4e00\u53f0\u8bbe\u5907&#xff0c;\u4efb\u4f55\u8de8\u7cfb\u7edf\u5bf9\u8d26\u90fd\u8981\u4eba\u5de5\u7ffb\u8bd1\u3002\u5148\u5efa\u70b9\u4f4d\u5b57\u5178\u518d\u91c7\u96c6&#xff0c;\u547d\u540d\u89c4\u5219\u53c2\u8003\u524d\u6587 make_point()&#xff0c;\u5168\u5382\u7edf\u4e00\u4e00\u6b21&#xff0c;\u540e\u9762\u6240\u6709\u7cfb\u7edf\u90fd\u53d7\u76ca\u3002<br \/>\n\u5751\u4e09&#xff1a;\u6ca1\u6709\u964d\u91c7\u6837\u7b56\u7565\u3002<br \/>\n\u524d\u9762\u7ed9\u4e86 rollup_to_1m() \u7684\u5b9e\u73b0\u3002\u6ca1\u6709\u5b83&#xff0c;\u79d2\u7ea7\u539f\u59cb\u6570\u636e\u5b58\u4e00\u5e74&#xff0c;\u67e5\u8be2\u4f1a\u4ece\u79d2\u7ea7\u9000\u5316\u5230\u5206\u949f\u7ea7&#xff0c;\u770b\u677f\u6253\u4e0d\u5f00&#xff0c;\u5de5\u7a0b\u5e08\u5c31\u5f00\u59cb\u6000\u7591\u8fd9\u5957\u7cfb\u7edf\u7684\u4ef7\u503c\u3002\u539f\u59cb 30 \u5929 &#043; \u5206\u949f\u7ea7 2 \u5e74 &#043; \u5c0f\u65f6\u7ea7 5 \u5e74&#xff0c;\u662f\u5927\u591a\u6570\u4e2d\u5c0f\u5382\u591f\u7528\u7684\u914d\u6bd4\u3002<br \/>\n\u4e03\u3001\u843d\u5730\u68c0\u67e5\u6e05\u5355<br \/>\n\u3010\u914d\u56fe\u4f4d\u7f6e2\u3011\u8bf7\u5728\u6b64\u4e0a\u4f20 \u56fe2_\u843d\u5730\u68c0\u67e5\u6e05\u5355.png<br \/>\n\u6309\u8fd9\u4e2a\u987a\u5e8f\u63a8\u8fdb&#xff0c;\u53ef\u4ee5\u5c11\u8d70\u5f88\u591a\u5f2f\u8def&#xff1a;<br \/>\n\u76d8\u70b9\u8bbe\u5907\u6e05\u5355&#xff1a;\u578b\u53f7\u3001\u51fa\u5382\u5e74\u4efd\u3001\u63a7\u5236\u5668\u7c7b\u578b\u3001\u53ef\u63d0\u4f9b\u7684\u63a5\u53e3&#xff08;\u7f51\u53e3 \/ \u4e32\u53e3 \/ IO \/ \u65e0&#xff09;<br \/>\n\u786e\u5b9a\u4e09\u5c42\u6570\u636e\u8303\u56f4&#xff1a;L1 \u91c7\u54ea\u4e9b\u3001L2 \u91c7\u54ea\u4e9b\u3001L3 \u600e\u4e48\u8ddf\u5de5\u5355\u7ed1\u5b9a&#xff0c;\u5148\u505a\u51cf\u6cd5<br \/>\n\u5efa\u7acb\u70b9\u4f4d\u5b57\u5178&#xff1a;\u5168\u5382\u7edf\u4e00\u547d\u540d&#xff0c;\u4e00\u6b21\u5230\u4f4d<br \/>\n\u786e\u8ba4\u91c7\u96c6\u9891\u7387&#xff1a;L1 \u79d2\u7ea7\u3001L2 \u79d2\u5230\u5206\u949f\u7ea7\u3001L3 \u4e8b\u4ef6\u89e6\u53d1&#xff0c;\u4e0d\u8981\u4e00\u5f8b\u6700\u9ad8\u9891<br \/>\n\u9009\u5b9a\u5b58\u50a8\u65b9\u6848&#xff1a;\u65f6\u5e8f\u5e93\u9009\u578b &#043; \u964d\u91c7\u6837\u914d\u6bd4 &#043; \u5907\u4efd\u7b56\u7565<br \/>\n\u660e\u786e\u6570\u636e\u8fb9\u754c&#xff1a;\u54ea\u4e9b\u5728\u5382\u5185\u3001\u54ea\u4e9b\u53ef\u5916\u9001\u3001\u8c01\u80fd\u8bbf\u95ee<br \/>\n\u5148\u8dd1\u901a\u4e00\u6761\u4ea7\u7ebf&#xff1a;\u4e00\u6761\u7ebf\u8dd1\u987a\u518d\u590d\u5236&#xff0c;\u4e0d\u8981\u5168\u5382\u94fa\u5f00<br \/>\n\u9a8c\u6536\u6807\u51c6\u5199\u8fdb\u5408\u540c&#xff1a;\u91c7\u96c6\u8986\u76d6\u7387\u3001\u6570\u636e\u5b8c\u6574\u7387\u3001\u65ad\u7f51\u7eed\u4f20\u65f6\u957f&#xff0c;\u80fd\u91cf\u5316\u7684\u90fd\u91cf\u5316<br \/>\n\u516b\u3001\u5e38\u89c1\u95ee\u9898<br \/>\nQ1&#xff1a;\u4e00\u5b9a\u8981\u5148\u4e0a MES \u624d\u80fd\u7b97\u57fa\u7840\u7ea7\u667a\u80fd\u5de5\u5382\u5417&#xff1f;<br \/>\n\u4e0d\u662f\u3002\u653f\u7b56\u5bf9\u57fa\u7840\u7ea7\u7684\u8868\u8ff0\u662f&#034;\u6838\u5fc3\u6570\u636e\u5b9e\u65f6\u91c7\u96c6\u3001\u5173\u952e\u751f\u4ea7\u5de5\u5e8f\u81ea\u52a8\u5316\u3001\u751f\u4ea7\u4e0e\u7ecf\u8425\u7ba1\u7406\u4fe1\u606f\u5316&#034;\u4e09\u4ef6\u4e8b\u5e76\u5217&#xff0c;\u91c7\u96c6\u662f\u5176\u4e2d\u4e4b\u4e00&#xff0c;\u5e76\u4e0d\u4ee5 MES \u4e3a\u524d\u7f6e\u6761\u4ef6\u3002\u5b9e\u9645\u5de5\u7a0b\u4e2d&#xff0c;\u5148\u628a\u8bbe\u5907\u6570\u636e\u91c7\u4e0a\u6765\u3001\u5b58\u597d\u3001\u80fd\u7528&#xff0c;\u53cd\u800c\u80fd\u4e3a\u540e\u7eed MES \u9009\u578b\u63d0\u4f9b\u66f4\u771f\u5b9e\u7684\u4f9d\u636e\u2014\u2014\u81f3\u5c11\u4f60\u77e5\u9053\u81ea\u5df1\u5230\u5e95\u8981\u7ba1\u4ec0\u4e48\u3002<br \/>\nQ2&#xff1a;\u91c7\u96c6\u9891\u7387\u662f\u4e0d\u662f\u8d8a\u9ad8\u8d8a\u597d&#xff1f;<br \/>\n\u4e0d\u662f\u3002\u9891\u7387\u8981\u5339\u914d\u4e1a\u52a1\u95ee\u9898&#xff1a;\u7b97 OEE \u7528\u79d2\u7ea7\u8db3\u591f&#xff0c;\u5206\u6790\u5de5\u827a\u6f02\u79fb\u5206\u949f\u7ea7\u8db3\u591f&#xff0c;\u505a\u5200\u5177\u5bff\u547d\u9884\u6d4b\u53ef\u80fd\u8981\u4e9a\u79d2\u7ea7\u3002\u6309\u95ee\u9898\u5b9a\u9891\u7387&#xff0c;\u9ad8\u9891\u6570\u636e\u7684\u5b58\u50a8\u4e0e\u8ba1\u7b97\u6210\u672c\u662f\u6301\u7eed\u7684&#xff0c;\u4e0d\u662f\u4e00\u6b21\u6027\u7684\u3002<br \/>\nQ3&#xff1a;\u8981\u6c42\u6570\u636e\u4e0d\u51fa\u5382&#xff0c;\u8fd8\u80fd\u505a AI \u5206\u6790\u5417&#xff1f;<br \/>\n\u80fd&#xff0c;\u800c\u4e14\u8fd9\u662f\u66f4\u5e38\u89c1\u7684\u90e8\u7f72\u65b9\u5f0f\u3002\u91c7\u96c6\u3001\u5b58\u50a8\u3001\u6a21\u578b\u63a8\u7406\u5168\u90e8\u653e\u5728\u5382\u5185&#xff0c;\u53ea\u6709\u9700\u8981\u8de8\u5382\u534f\u540c\u7684\u805a\u5408\u7ed3\u679c&#xff08;\u6bd4\u5982\u96c6\u56e2\u7ea7\u4ea7\u80fd\u770b\u677f&#xff09;\u624d\u5916\u9001\u3002\u79c1\u6709\u5316\u90e8\u7f72\u7684\u6280\u672f\u6808\u5df2\u7ecf\u5f88\u6210\u719f&#xff0c;\u9700\u8981\u6743\u8861\u7684\u662f\u7b97\u529b\u6210\u672c&#xff0c;\u4e0d\u662f\u53ef\u884c\u6027\u3002<br \/>\nQ4&#xff1a;1600 \u5bb6\u57fa\u7840\u7ea7\u7684&#034;\u6838\u5fc3\u6570\u636e\u5b9e\u65f6\u91c7\u96c6&#034;\u6709\u6ca1\u6709\u91cf\u5316\u6807\u51c6&#xff1f;<br \/>\n\u76ee\u524d\u516c\u5f00\u8868\u8ff0\u4e2d\u6ca1\u6709\u7ed9\u51fa\u70b9\u4f4d\u6570\u91cf\u3001\u91c7\u96c6\u9891\u7387\u7684\u5177\u4f53\u9608\u503c&#xff0c;\u53ea\u660e\u786e\u4e86&#034;\u5b9e\u65f6\u91c7\u96c6&#034;\u8fd9\u4e2a\u6027\u8d28\u8981\u6c42\u3002\u5de5\u7a0b\u4e0a\u7684\u5224\u65ad\u4f9d\u636e\u662f&#xff1a;\u91c7\u5230\u7684\u6570\u636e\u80fd\u5426\u56de\u7b54&#034;\u8bbe\u5907\u73b0\u5728\u80fd\u4e0d\u80fd\u5e72\u6d3b&#034;&#034;\u8fd9\u9053\u5de5\u5e8f\u7a33\u4e0d\u7a33&#034;&#034;\u8fd9\u6279\u6d3b\u5e72\u5f97\u600e\u4e48\u6837&#034;\u8fd9\u4e09\u4e2a\u95ee\u9898\u3002\u80fd\u56de\u7b54&#xff0c;\u5c31\u8fbe\u5230\u4e86\u57fa\u7840\u7ea7\u8fd9\u4e00\u6b65\u7684\u5b9e\u8d28\u8981\u6c42\u3002<br \/>\n\u4e5d\u3001\u603b\u7ed3<br \/>\n\u56de\u5230\u653f\u7b56\u90a3\u4e09\u53e5\u8bdd\u3002\u57fa\u7840\u7ea7 1600 \u5bb6\u8fd9\u4e2a\u91cf\u7ea7\u610f\u5473\u7740&#xff0c;\u7edd\u5927\u591a\u6570\u5de5\u5382\u8981\u8de8\u7684\u7b2c\u4e00\u6b65\u4e0d\u662f\u9009\u5927\u6a21\u578b\u3001\u4e0d\u662f\u4e70\u673a\u5668\u4eba&#xff0c;\u800c\u662f\u628a\u8f66\u95f4\u91cc\u90a3\u4e9b\u5df2\u7ecf\u5b58\u5728\u4e86\u5341\u5e74\u3001\u4e8c\u5341\u5e74\u7684\u8bbe\u5907\u6570\u636e&#xff0c;\u7a33\u5b9a\u3001\u5b8c\u6574\u3001\u53ef\u8ffd\u6eaf\u5730\u91c7\u4e0a\u6765\u3002<br \/>\n\u8fd9\u4e00\u5c42\u7684\u95e8\u69db\u4e0d\u9ad8&#xff0c;\u4f46\u5f88\u5b9e&#xff1a;\u9700\u8981\u7684\u662f\u70b9\u4f4d\u5b57\u5178\u3001\u91c7\u96c6\u94fe\u8def\u3001\u65f6\u5e8f\u5b58\u50a8\u548c\u964d\u91c7\u6837\u7b56\u7565&#xff0c;\u800c\u4e0d\u662f\u6982\u5ff5\u3002\u628a\u8fd9\u4e00\u5c42\u505a\u624e\u5b9e&#xff0c;\u4e0a\u9762\u90a3\u4e9b AI \u573a\u666f\u624d\u6709\u7740\u843d&#xff1b;\u8df3\u8fc7\u8fd9\u4e00\u5c42\u76f4\u63a5\u8c08\u667a\u80fd\u4f53&#xff0c;\u6700\u540e\u5f80\u5f80\u505c\u5728\u6f14\u793a\u91cc\u3002<br \/>\n\u53c2\u8003\u4e0e\u8bf4\u660e<br \/>\n\u653f\u7b56\u6765\u6e90&#xff1a;\u300a\u4e0a\u6d77\u5e02\u52a0\u5feb\u53d1\u5c55\u65b0\u4e00\u4ee3\u667a\u80fd\u5236\u9020\u884c\u52a8\u65b9\u6848\u300b&#xff0c;\u4e0a\u6d77\u5e02\u7ecf\u6d4e\u4fe1\u606f\u5316\u59d4&#xff0c;2026 \u5e74 10 \u6708 27 \u65e5\u5370\u53d1&#xff1b;2026 \u5e74 10 \u6708 28 \u65e5\u7ecf\u4e2d\u56fd\u65b0\u95fb\u7f51\u3001\u8bc1\u5238\u65f6\u62a5\u3001\u6f8e\u6e43\u65b0\u95fb\u7b49\u5a92\u4f53\u62a5\u9053\u3002\u6587\u4e2d\u5f15\u7528\u7684\u6570\u5b57\u5747\u6765\u81ea\u4e0a\u8ff0\u516c\u5f00\u62a5\u9053\u3002<br \/>\n\u5229\u76ca\u76f8\u5173&#xff1a;\u672c\u4eba\u4ece\u4e8b\u5de5\u5382 AI \u7cfb\u7edf\u7684\u843d\u5730\u5de5\u4f5c&#xff0c;\u6587\u4e2d\u67b6\u6784\u4e0e\u4ee3\u7801\u6765\u81ea\u5b9e\u9645\u90e8\u7f72\u8fc7\u7684\u9879\u76ee&#xff0c;\u5ba2\u6237\u540d\u79f0\u4e0e\u5177\u4f53\u6570\u636e\u56e0\u672a\u83b7\u516c\u5f00\u6388\u6743\u5df2\u505a\u8131\u654f&#xff0c;\u793a\u4f8b\u4ee3\u7801\u4e3a\u8131\u654f\u540e\u7684\u7b80\u5316\u7248\u672c\u3002<br \/>\n\u8bf4\u660e&#xff1a;\u672c\u6587\u5199\u4f5c\u8fc7\u7a0b\u4e2d\u4f7f\u7528\u4e86 AI \u5de5\u5177\u8f85\u52a9\u6574\u7406\u8d44\u6599\u4e0e\u6821\u5bf9&#xff0c;\u6280\u672f\u5224\u65ad\u4e0e\u73b0\u573a\u7ecf\u9a8c\u7531\u672c\u4eba\u8d1f\u8d23\u3002\u6587\u4e2d\u7684\u653f\u7b56\u5f15\u7528\u53ef\u81ea\u884c\u6838\u9a8c\u3002 <\/p>\n<h4>5.3 \u4ece\u91c7\u96c6\u6570\u636e\u7b97 OEE<\/h4>\n<p>\u6570\u636e\u91c7\u4e0a\u6765\u3001\u5b58\u597d\u4e86&#xff0c;\u63a5\u4e0b\u6765\u8981\u56de\u7b54\u4e00\u4e2a\u8001\u677f\u6700\u5173\u5fc3\u7684\u95ee\u9898&#xff1a;\u8fd9\u5957\u8bbe\u5907\u5230\u5e95\u6709\u591a\u5c11\u6709\u6548\u4ea7\u51fa\u3002OEE&#xff08;\u8bbe\u5907\u7efc\u5408\u6548\u7387&#xff0c;Overall Equipment Effectiveness&#xff09;\u5c31\u662f\u6807\u51c6\u7b54\u6848&#xff0c;\u5b83\u7531\u4e09\u4e2a\u56e0\u5b50\u76f8\u4e58\u5f97\u5230&#xff1a;<\/p>\n<p>OEE &#061; \u53ef\u7528\u7387&#xff08;Availability&#xff09; \u00d7 \u6027\u80fd\u7387&#xff08;Performance&#xff09; \u00d7 \u826f\u54c1\u7387&#xff08;Quality&#xff09; <\/p>\n<p>\u4e09\u4e2a\u56e0\u5b50\u5206\u522b\u5bf9\u5e94\u524d\u6587\u4e09\u7ea7\u6e05\u5355\u91cc\u7684\u4e0d\u540c\u5c42&#xff0c;\u8fd9\u4e5f\u662f\u4e3a\u4ec0\u4e48\u4e09\u5c42\u90fd\u8981\u91c7&#xff1a;<\/p>\n<table>\n<tr>OEE \u56e0\u5b50\u8ba1\u7b97\u516c\u5f0f\u4f9d\u8d56\u7684\u6570\u636e\u5c42\u5177\u4f53\u70b9\u4f4d<\/tr>\n<tbody>\n<tr>\n<td>\u53ef\u7528\u7387 A<\/td>\n<td>\u5b9e\u9645\u8fd0\u884c\u65f6\u95f4 \/ \u8ba1\u5212\u751f\u4ea7\u65f6\u95f4<\/td>\n<td>L1 \u8bbe\u5907\u8fd0\u884c\u72b6\u6001<\/td>\n<td>STATUS.state&#xff08;RUN \/ IDLE \/ ALARM&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>\u6027\u80fd\u7387 P<\/td>\n<td>\u7406\u8bba\u8282\u62cd \u00d7 \u5b9e\u9645\u4ea7\u51fa \/ \u5b9e\u9645\u8fd0\u884c\u65f6\u95f4<\/td>\n<td>L2 \u5de5\u5e8f\u8fc7\u7a0b\u91cf<\/td>\n<td>PROCESS.cycle_time&#xff08;\u5b9e\u9645\u8282\u62cd&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>\u826f\u54c1\u7387 Q<\/td>\n<td>\u5408\u683c\u6570 \/ \u603b\u4ea7\u51fa\u6570<\/td>\n<td>L3 \u4ea7\u51fa\u4e0e\u8d28\u91cf\u7ed3\u679c<\/td>\n<td>\u5408\u683c\u6570\u3001\u4e0d\u5408\u683c\u6570&#xff08;\u62a5\u5de5\u6216\u89c6\u89c9\u68c0\u6d4b&#xff09;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u4e00\u53e5\u8bdd\u8bb0\u6cd5&#xff1a;L1 \u51b3\u5b9a\u673a\u5668\u8f6c\u4e0d\u8f6c&#xff0c;L2 \u51b3\u5b9a\u8f6c\u5f97\u5feb\u4e0d\u5feb&#xff0c;L3 \u51b3\u5b9a\u8f6c\u51fa\u6765\u7684\u6d3b\u597d\u4e0d\u597d\u3002\u7f3a\u4efb\u4f55\u4e00\u5c42&#xff0c;OEE \u90fd\u7b97\u4e0d\u51fa\u6765\u2014\u2014\u53ea\u6709 L1 \u80fd\u7b97\u53ef\u7528\u7387&#xff0c;\u53ea\u6709 L1&#043;L2 \u80fd\u7b97\u6027\u80fd\u548c\u53ef\u7528\u7387&#xff0c;\u4e09\u5c42\u9f50\u5168\u624d\u662f\u5b8c\u6574\u7684 OEE\u3002<\/p>\n<p>\u4e0b\u9762\u8fd9\u6bb5\u4ee3\u7801\u76f4\u63a5\u590d\u7528 5.2 \u91cc\u7684 raw \u4e0e agg_1m \u4e24\u5f20\u8868&#xff0c;\u96f6\u5916\u90e8\u4f9d\u8d56\u5373\u53ef\u8fd0\u884c&#xff1a;<\/p>\n<p># -*- coding: utf-8 -*-<br \/>\n&#034;&#034;&#034;<br \/>\n\u4ece\u91c7\u96c6\u6570\u636e\u8ba1\u7b97 OEE&#xff1a;\u53ef\u7528\u7387 \u00d7 \u6027\u80fd\u7387 \u00d7 \u826f\u54c1\u7387<br \/>\n\u4f9d\u8d56&#xff1a;\u4ec5\u6807\u51c6\u5e93&#xff0c;\u590d\u7528 5.2 \u7684 raw \/ agg_1m \u4e24\u5f20\u8868<br \/>\n\u8bf4\u660e&#xff1a;L3 \u7684\u4ea7\u51fa\u4e0e\u8d28\u91cf\u6570\u636e\u5728\u771f\u5b9e\u9879\u76ee\u91cc\u6765\u81ea MES \u62a5\u5de5\u6216\u89c6\u89c9\u68c0\u6d4b&#xff0c;<br \/>\n      \u8fd9\u91cc\u7528\u4e00\u5f20 production \u8868\u6a21\u62df&#xff0c;\u5b57\u6bb5\u4e0e MES \u4fa7\u4fdd\u6301\u4e00\u81f4\u3002<br \/>\n&#034;&#034;&#034;<br \/>\nimport sqlite3<br \/>\nimport time<br \/>\nDB &#061; &#034;telemetry.db&#034;<br \/>\nPOINT_PREFIX &#061; &#034;SH01.LINE_A.CNC.01&#034;<br \/>\nIDEAL_CYCLE_TIME &#061; 50.0      # \u7406\u8bba\u8282\u62cd&#xff08;\u79d2\/\u4ef6&#xff09;&#xff0c;\u6765\u81ea\u5de5\u827a\u6587\u4ef6\u6216\u8bbe\u5907\u989d\u5b9a\u503c<br \/>\nPLANNED_MINUTES &#061; 60         # \u7edf\u8ba1\u7a97\u53e3&#xff1a;\u8ba1\u5212\u751f\u4ea7 60 \u5206\u949f<br \/>\ndef init_production(conn):<br \/>\n&#034;&#034;&#034;L3 \u4ea7\u51fa\u4e0e\u8d28\u91cf\u7ed3\u679c&#xff1a;\u771f\u5b9e\u573a\u666f\u7531 MES \u62a5\u5de5\u6216\u89c6\u89c9\u68c0\u6d4b\u5199\u5165&#034;&#034;&#034;<br \/>\nconn.execute(&#034;&#034;&#034;<br \/>\nCREATE TABLE IF NOT EXISTS production (<br \/>\nts          INTEGER NOT NULL,   &#8212; \u62a5\u5de5\u65f6\u95f4&#xff08;\u6beb\u79d2&#xff09;<br \/>\ndevice      TEXT NOT NULL,      &#8212; \u8bbe\u5907\u7f16\u53f7<br \/>\ngood_count  INTEGER NOT NULL,   &#8212; \u5408\u683c\u6570<br \/>\nbad_count   INTEGER NOT NULL,   &#8212; \u4e0d\u5408\u683c\u6570<br \/>\nPRIMARY KEY (ts, device)<br \/>\n)<br \/>\n&#034;&#034;&#034;)<br \/>\nconn.commit()<br \/>\ndef calc_availability(conn, prefix, start_ms, end_ms, planned_minutes):<br \/>\n&#034;&#034;&#034;\u53ef\u7528\u7387 A &#061; \u5b9e\u9645\u8fd0\u884c\u65f6\u95f4 \/ \u8ba1\u5212\u751f\u4ea7\u65f6\u95f4<br \/>\n\u6570\u636e\u6765\u6e90&#xff1a;L1 \u8bbe\u5907\u8fd0\u884c\u72b6\u6001&#xff0c;\u4ece agg_1m \u91cc\u53d6 state \u7684\u5206\u949f\u7ea7\u6837\u672c\u3002<br \/>\n\u7ea6\u5b9a&#xff1a;state \u70b9\u4f4d value&#061;1 \u8868\u793a RUN&#xff0c;0 \u8868\u793a\u975e RUN&#xff08;IDLE\/ALARM\/\u505c\u673a&#xff09;\u3002<br \/>\n&#034;&#034;&#034;<br \/>\ncur &#061; conn.execute(&#034;&#034;&#034;<br \/>\nSELECT SUM(v_avg * v_cnt) \/ NULLIF(SUM(v_cnt), 0)<br \/>\nFROM agg_1m<br \/>\nWHERE point &#061; ? AND ts &gt;&#061; ? AND ts &lt; ?<br \/>\n&#034;&#034;&#034;, (f&#034;{prefix}.STATUS.state&#034;, start_ms, end_ms))<br \/>\nrow &#061; cur.fetchone()<br \/>\nrun_ratio &#061; row[0] if row and row[0] is not None else 0.0<br \/>\nplanned_ms &#061; planned_minutes * 60 * 1000<br \/>\nrun_ms &#061; run_ratio * planned_ms<br \/>\nreturn run_ms, planned_ms, (run_ms \/ planned_ms if planned_ms else 0.0)<br \/>\ndef calc_performance(conn, prefix, start_ms, end_ms, run_ms, ideal_cycle):<br \/>\n&#034;&#034;&#034;\u6027\u80fd\u7387 P &#061; \u7406\u8bba\u8282\u62cd \u00d7 \u5b9e\u9645\u4ea7\u51fa \/ \u5b9e\u9645\u8fd0\u884c\u65f6\u95f4<br \/>\n\u6570\u636e\u6765\u6e90&#xff1a;L2 \u5de5\u5e8f\u8fc7\u7a0b\u91cf&#xff0c;\u5b9e\u9645\u8282\u62cd\u53d6 agg_1m \u7684\u52a0\u6743\u5747\u503c\u3002<br \/>\n\u5b9e\u9645\u4ea7\u51fa &#061; \u5b9e\u9645\u8fd0\u884c\u65f6\u95f4 \/ \u5b9e\u9645\u5e73\u5747\u8282\u62cd\u3002<br \/>\n&#034;&#034;&#034;<br \/>\ncur &#061; conn.execute(&#034;&#034;&#034;<br \/>\nSELECT SUM(v_avg * v_cnt) \/ NULLIF(SUM(v_cnt), 0)<br \/>\nFROM agg_1m<br \/>\nWHERE point &#061; ? AND ts &gt;&#061; ? AND ts &lt; ?<br \/>\n&#034;&#034;&#034;, (f&#034;{prefix}.PROCESS.cycle_time&#034;, start_ms, end_ms))<br \/>\nrow &#061; cur.fetchone()<br \/>\nactual_cycle &#061; row[0] if row and row[0] is not None else 0.0<br \/>\nif actual_cycle &lt;&#061; 0 or run_ms &lt;&#061; 0:<br \/>\nreturn 0.0, 0.0, 0.0<br \/>\nactual_output &#061; run_ms \/ 1000.0 \/ actual_cycle      # \u5b9e\u9645\u4ea7\u51fa\u4ef6\u6570<br \/>\nperformance &#061; (ideal_cycle * actual_output) \/ (run_ms \/ 1000.0)<br \/>\nreturn actual_cycle, actual_output, min(performance, 1.0)   # \u4e0a\u9650\u622a\u65ad\u5230 1<br \/>\ndef calc_quality(conn, device, start_ms, end_ms):<br \/>\n&#034;&#034;&#034;\u826f\u54c1\u7387 Q &#061; \u5408\u683c\u6570 \/ \u603b\u4ea7\u51fa\u6570<br \/>\n\u6570\u636e\u6765\u6e90&#xff1a;L3 \u4ea7\u51fa\u4e0e\u8d28\u91cf\u7ed3\u679c&#xff0c;\u6765\u81ea production \u8868&#xff08;MES \u62a5\u5de5&#xff09;\u3002<br \/>\n&#034;&#034;&#034;<br \/>\ncur &#061; conn.execute(&#034;&#034;&#034;<br \/>\nSELECT SUM(good_count), SUM(good_count &#043; bad_count)<br \/>\nFROM production<br \/>\nWHERE device &#061; ? AND ts &gt;&#061; ? AND ts &lt; ?<br \/>\n&#034;&#034;&#034;, (device, start_ms, end_ms))<br \/>\nrow &#061; cur.fetchone()<br \/>\ngood &#061; row[0] or 0<br \/>\ntotal &#061; row[1] or 0<br \/>\nreturn good, total, (good \/ total if total else 0.0)<br \/>\ndef calc_oee(conn, prefix, device, end_ms, planned_minutes&#061;PLANNED_MINUTES,<br \/>\nideal_cycle&#061;IDEAL_CYCLE_TIME):<br \/>\n&#034;&#034;&#034;OEE &#061; A \u00d7 P \u00d7 Q&#xff0c;\u8fd4\u56de\u5b8c\u6574\u660e\u7ec6\u4fbf\u4e8e\u6392\u67e5\u662f\u54ea\u4e00\u9879\u62d6\u540e\u817f&#034;&#034;&#034;<br \/>\nstart_ms &#061; end_ms &#8211; planned_minutes * 60 * 1000<br \/>\nrun_ms, planned_ms, a &#061; calc_availability(<br \/>\n    conn, prefix, start_ms, end_ms, planned_minutes)<br \/>\nactual_cycle, output, p &#061; calc_performance(<br \/>\n    conn, prefix, start_ms, end_ms, run_ms, ideal_cycle)<br \/>\ngood, total, q &#061; calc_quality(conn, device, start_ms, end_ms)<br \/>\noee &#061; a * p * q<br \/>\nreturn {<br \/>\n&#034;window&#034;: (start_ms, end_ms),<br \/>\n&#034;run_minutes&#034;: round(run_ms \/ 60000, 2),<br \/>\n&#034;planned_minutes&#034;: planned_minutes,<br \/>\n&#034;actual_cycle&#034;: round(actual_cycle, 2),<br \/>\n&#034;ideal_cycle&#034;: ideal_cycle,<br \/>\n&#034;output&#034;: round(output, 1),<br \/>\n&#034;good&#034;: good,<br \/>\n&#034;total&#034;: total,<br \/>\n&#034;A&#034;: round(a, 4),<br \/>\n&#034;P&#034;: round(p, 4),<br \/>\n&#034;Q&#034;: round(q, 4),<br \/>\n&#034;OEE&#034;: round(oee, 4),<br \/>\n}<br \/>\nif name &#061;&#061; &#034;main&#034;:<br \/>\nconn &#061; sqlite3.connect(DB)<br \/>\ninit_production(conn)<br \/>\nnow &#061; int(time.time() * 1000)<br \/>\nstart &#061; now &#8211; PLANNED_MINUTES * 60 * 1000<br \/>\n&#8212;- \u6a21\u62df\u5199\u5165 L1 \/ L2 \u7684\u5206\u949f\u7ea7\u805a\u5408\u6570\u636e&#xff08;\u771f\u5b9e\u573a\u666f\u7531 5.2 \u7684 rollup_to_1m \u751f\u6210&#xff09;&#8212;-<br \/>\nrows &#061; []<br \/>\nfor i in range(PLANNED_MINUTES):<br \/>\nts &#061; start &#043; i * 60 * 1000<br \/>\n# \u524d 45 \u5206\u949f RUN&#xff0c;\u540e 15 \u5206\u949f\u505c\u673a \u2192 \u53ef\u7528\u7387\u7ea6 0.75<br \/>\nstate &#061; 1.0 if i &amp;lt; 45 else 0.0<br \/>\nrows.append((ts, f&#034;{POINT_PREFIX}.STATUS.state&#034;, state, state, state, 60))<br \/>\n# \u5b9e\u9645\u8282\u62cd 55 \u79d2&#xff0c;\u7406\u8bba 50 \u79d2 \u2192 \u6027\u80fd\u7387\u7ea6 0.909<br \/>\nrows.append((ts, f&#034;{POINT_PREFIX}.PROCESS.cycle_time&#034;, 55.0, 54.0, 56.0, 60))<br \/>\nconn.executemany(<br \/>\n&#034;INSERT OR REPLACE INTO agg_1m (ts, point, v_avg, v_min, v_max, v_cnt) &#034;<br \/>\n&#034;VALUES (?, ?, ?, ?, ?, ?)&#034;, rows)<br \/>\n&#8212;- \u6a21\u62df\u5199\u5165 L3 \u4ea7\u51fa\u4e0e\u8d28\u91cf&#xff08;\u771f\u5b9e\u573a\u666f\u6765\u81ea MES \u62a5\u5de5&#xff09;&#8212;-<br \/>\nconn.execute(<br \/>\n&#034;INSERT OR REPLACE INTO production (ts, device, good_count, bad_count) &#034;<br \/>\n&#034;VALUES (?, ?, ?, ?)&#034;, (now, &#034;CNC.01&#034;, 48, 2))<br \/>\nconn.commit()<br \/>\nresult &#061; calc_oee(conn, POINT_PREFIX, &#034;CNC.01&#034;, now)<br \/>\nprint(&#034;&#061;&#034; * 46)<br \/>\nprint(f&#034;\u7edf\u8ba1\u7a97\u53e3&#xff1a;{PLANNED_MINUTES} \u5206\u949f  \u8bbe\u5907&#xff1a;CNC.01&#034;)<br \/>\nprint(f&#034;\u8fd0\u884c\u65f6\u95f4&#xff1a;{result[&#039;run_minutes&#039;]} \/ {result[&#039;planned_minutes&#039;]} \u5206\u949f&#034;)<br \/>\nprint(f&#034;\u5b9e\u9645\u8282\u62cd&#xff1a;{result[&#039;actual_cycle&#039;]} \u79d2  \u7406\u8bba\u8282\u62cd&#xff1a;{result[&#039;ideal_cycle&#039;]} \u79d2&#034;)<br \/>\nprint(f&#034;\u4ea7\u51fa&#xff1a;{result[&#039;output&#039;]} \u4ef6  \u5408\u683c&#xff1a;{result[&#039;good&#039;]} \/ {result[&#039;total&#039;]}&#034;)<br \/>\nprint(&#034;-&#034; * 46)<br \/>\nprint(f&#034;\u53ef\u7528\u7387 A &#061; {result[&#039;A&#039;]:.2%}&#034;)<br \/>\nprint(f&#034;\u6027\u80fd\u7387 P &#061; {result[&#039;P&#039;]:.2%}&#034;)<br \/>\nprint(f&#034;\u826f\u54c1\u7387 Q &#061; {result[&#039;Q&#039;]:.2%}&#034;)<br \/>\nprint(f&#034;OEE     &#061; {result[&#039;OEE&#039;]:.2%}&#034;)<br \/>\nprint(&#034;&#061;&#034; * 46)<br \/>\nconn.close()&lt;\/code&gt;&lt;\/pre&gt;<br \/>\n\u793a\u4f8b\u8f93\u51fa&#xff08;\u6ce8\u91ca\u5f62\u5f0f&#xff0c;\u4fbf\u4e8e\u5bf9\u7167&#xff09;&#xff1a;<br \/>\n\u7edf\u8ba1\u7a97\u53e3&#xff1a;60 \u5206\u949f  \u8bbe\u5907&#xff1a;CNC.01<br \/>\n\u8fd0\u884c\u65f6\u95f4&#xff1a;45.0 \/ 60 \u5206\u949f<br \/>\n\u5b9e\u9645\u8282\u62cd&#xff1a;55.0 \u79d2  \u7406\u8bba\u8282\u62cd&#xff1a;50.0 \u79d2<br \/>\n\u4ea7\u51fa&#xff1a;49.1 \u4ef6  \u5408\u683c&#xff1a;48 \/ 50<br \/>\n\u53ef\u7528\u7387 A &#061; 75.00%<br \/>\n\u6027\u80fd\u7387 P &#061; 90.91%<br \/>\n\u826f\u54c1\u7387 Q &#061; 96.00%<br \/>\nOEE     &#061; 65.45%<br \/>\n\u8fd9\u4e2a 65.45% \u5c31\u662f\u5178\u578b\u7684\u300c\u80fd\u770b\u4f46\u4e0d\u591f\u597d\u300d&#xff1a;\u53ef\u7528\u7387 75% \u8bf4\u660e\u505c\u673a\u65f6\u95f4\u5360\u4e86\u56db\u5206\u4e4b\u4e00&#xff0c;\u662f\u6700\u5927\u7684\u77ed\u677f&#xff1b;\u6027\u80fd\u7387 90.91% \u8bf4\u660e\u8282\u62cd\u6bd4\u7406\u8bba\u503c\u6162\u4e86\u7ea6 10%&#xff0c;\u53ef\u80fd\u662f\u5de5\u827a\u53c2\u6570\u504f\u4fdd\u5b88\u6216\u5200\u5177\u78e8\u635f&#xff1b;\u826f\u54c1\u7387 96% \u5df2\u7ecf\u4e0d\u9519\u3002\u6392\u67e5\u987a\u5e8f\u5e94\u8be5\u662f\u5148\u770b A\u3001\u518d\u770b P\u3001\u6700\u540e\u770b Q\u2014\u2014\u505c\u673a\u635f\u5931\u901a\u5e38\u6700\u5bb9\u6613\u6539\u5584&#xff0c;\u4e5f\u6700\u5bb9\u6613\u88ab\u5ffd\u89c6\u3002<br \/>\n\u51e0\u4e2a\u843d\u5730\u65f6\u8981\u6ce8\u610f\u7684\u70b9&#xff1a;<br \/>\n\u7406\u8bba\u8282\u62cd\u5fc5\u987b\u6765\u81ea\u5de5\u827a\u6587\u4ef6&#xff0c;\u4e0d\u80fd\u62ff\u5386\u53f2\u6700\u5feb\u503c\u5f53\u57fa\u51c6&#xff0c;\u5426\u5219\u6027\u80fd\u7387\u6c38\u8fdc\u63a5\u8fd1 100%&#xff0c;\u5931\u53bb\u8bca\u65ad\u610f\u4e49\u3002<br \/>\n\u8ba1\u5212\u751f\u4ea7\u65f6\u95f4\u8981\u6263\u6389\u8ba1\u5212\u505c\u673a&#xff08;\u6362\u73ed\u3001\u8ba1\u5212\u4fdd\u517b\u3001\u65e0\u6392\u4ea7&#xff09;&#xff0c;\u5426\u5219\u53ef\u7528\u7387\u4f1a\u88ab\u7cfb\u7edf\u6027\u4f4e\u4f30\u3002<br \/>\nL3 \u6570\u636e\u8981\u80fd\u5bf9\u4e0a\u5de5\u5355\u3002OEE \u6309\u73ed\u6b21\u3001\u6309\u5de5\u5355\u3001\u6309\u8bbe\u5907\u4e09\u4e2a\u7ef4\u5ea6\u90fd\u8981\u80fd\u5207&#xff0c;\u8fd9\u8981\u6c42 production \u8868\u5e26\u4e0a\u5de5\u5355\u53f7\u548c\u73ed\u6b21\u5b57\u6bb5&#xff0c;\u800c\u4e0d\u662f\u53ea\u8bb0\u4e00\u4e2a\u603b\u6570\u3002<br \/>\nOEE \u662f\u8bca\u65ad\u6307\u6807&#xff0c;\u4e0d\u662f\u8003\u6838\u6307\u6807\u3002\u4e00\u65e6\u62ff\u6765\u8003\u6838&#xff0c;\u73b0\u573a\u5c31\u4f1a\u5f00\u59cb\u6311\u6570\u636e\u2014\u2014\u628a\u62a5\u8b66\u6539\u6210\u5f85\u673a\u3001\u628a\u4e0d\u826f\u54c1\u632a\u5230\u4e0b\u4e2a\u73ed\u6b21&#xff0c;\u6307\u6807\u597d\u770b\u4e86&#xff0c;\u95ee\u9898\u8fd8\u5728\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6458\u8981&#xff1a;\u300a\u4e0a\u6d77\u5e02\u52a0\u5feb\u53d1\u5c55\u65b0\u4e00\u4ee3\u667a\u80fd\u5236\u9020\u884c\u52a8\u65b9\u6848\u300b\u63d0\u51fa\u5230 2028 \u5e74\u57fa\u7840\u7ea7\u667a\u80fd\u5de5\u5382\u7d2f\u8ba1\u8fbe 1600 \u5bb6&#xff0c;\u5e76\u628a\u201c\u5b9e\u73b0\u6838\u5fc3\u6570\u636e\u5b9e\u65f6\u91c7\u96c6\u201d\u5199\u8fdb\u4e86\u57fa\u7840\u7ea7\u7684\u51c6\u5165\u8981\u6c42\u3002\u8fd9\u7bc7\u6587\u7ae0\u4ece\u5de5\u7a0b\u89d2\u5ea6\u62c6\u89e3\u4e09\u4ef6\u4e8b&#xff1a;\u6838\u5fc3\u6570\u636e\u5230\u5e95\u5206\u54ea\u4e09\u5c42\u3001\u8bbe\u5907\u6570\u636e\u4e3a\u4ec0\u4e48\u53ef\u4ee5\u4e0d\u5fc5\u5148\u8fc7 MES&#xff0c;\u4ee5\u53ca\u4e00\u6761\u4ece PLC \/ CNC \u5230\u65f6\u5e8f\u6570\u636e\u5e93\u7684\u6700\u5c0f\u53ef\u7528\u91c7\u96c6\u94fe\u8def&#xff08;\u542b\u53ef\u8fd0\u884c\u7684 Python \u5b9e\u73b0\u4e0e\u4e09\u4e2a\u73b0\u573a\u5751&#xff09;\u3002<br \/>\n\u672c\u6587\u76ee\u5f55<br \/>\n\u4e00\u3001\u5148\u7ed9\u7ed3\u8bba\u4e8c\u3001\u653f\u7b56\u539f\u6587\u91cc&amp;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[13546,1311,81,2606,188],"topic":[],"class_list":["post-119079","post","type-post","status-publish","format-standard","hentry","category-server","tag-13546","tag-opc-ua","tag-python","tag-2606","tag-188"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u4e0a\u6d77\u201c54321\u201c\u667a\u80fd\u5236\u9020\u76ee\u6807\u4e0b\uff0c\u57fa\u7840\u7ea7\u667a\u80fd\u5de5\u5382\u7684\u201c\u6838\u5fc3\u6570\u636e\u5b9e\u65f6\u91c7\u96c6\u201c\u8981\u91c7\u4ec0\u4e48\u3001\u600e\u4e48\u91c7\uff08\u9644\u67b6\u6784\u4e0e Python \u5b9e\u73b0\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/119079.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u4e0a\u6d77\u201c54321\u201c\u667a\u80fd\u5236\u9020\u76ee\u6807\u4e0b\uff0c\u57fa\u7840\u7ea7\u667a\u80fd\u5de5\u5382\u7684\u201c\u6838\u5fc3\u6570\u636e\u5b9e\u65f6\u91c7\u96c6\u201c\u8981\u91c7\u4ec0\u4e48\u3001\u600e\u4e48\u91c7\uff08\u9644\u67b6\u6784\u4e0e Python \u5b9e\u73b0\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6458\u8981&#xff1a;\u300a\u4e0a\u6d77\u5e02\u52a0\u5feb\u53d1\u5c55\u65b0\u4e00\u4ee3\u667a\u80fd\u5236\u9020\u884c\u52a8\u65b9\u6848\u300b\u63d0\u51fa\u5230 2028 \u5e74\u57fa\u7840\u7ea7\u667a\u80fd\u5de5\u5382\u7d2f\u8ba1\u8fbe 1600 \u5bb6&#xff0c;\u5e76\u628a\u201c\u5b9e\u73b0\u6838\u5fc3\u6570\u636e\u5b9e\u65f6\u91c7\u96c6\u201d\u5199\u8fdb\u4e86\u57fa\u7840\u7ea7\u7684\u51c6\u5165\u8981\u6c42\u3002\u8fd9\u7bc7\u6587\u7ae0\u4ece\u5de5\u7a0b\u89d2\u5ea6\u62c6\u89e3\u4e09\u4ef6\u4e8b&#xff1a;\u6838\u5fc3\u6570\u636e\u5230\u5e95\u5206\u54ea\u4e09\u5c42\u3001\u8bbe\u5907\u6570\u636e\u4e3a\u4ec0\u4e48\u53ef\u4ee5\u4e0d\u5fc5\u5148\u8fc7 MES&#xff0c;\u4ee5\u53ca\u4e00\u6761\u4ece PLC \/ CNC \u5230\u65f6\u5e8f\u6570\u636e\u5e93\u7684\u6700\u5c0f\u53ef\u7528\u91c7\u96c6\u94fe\u8def&#xff08;\u542b\u53ef\u8fd0\u884c\u7684 Python \u5b9e\u73b0\u4e0e\u4e09\u4e2a\u73b0\u573a\u5751&#xff09;\u3002 \u672c\u6587\u76ee\u5f55 \u4e00\u3001\u5148\u7ed9\u7ed3\u8bba\u4e8c\u3001\u653f\u7b56\u539f\u6587\u91cc&amp;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/119079.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-10-28T13:16:57+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"17 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/119079.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/119079.html\",\"name\":\"\u4e0a\u6d77\u201c54321\u201c\u667a\u80fd\u5236\u9020\u76ee\u6807\u4e0b\uff0c\u57fa\u7840\u7ea7\u667a\u80fd\u5de5\u5382\u7684\u201c\u6838\u5fc3\u6570\u636e\u5b9e\u65f6\u91c7\u96c6\u201c\u8981\u91c7\u4ec0\u4e48\u3001\u600e\u4e48\u91c7\uff08\u9644\u67b6\u6784\u4e0e Python \u5b9e\u73b0\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-10-28T13:16:57+00:00\",\"dateModified\":\"2026-10-28T13:16:57+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/119079.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/119079.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/119079.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u4e0a\u6d77\u201c54321\u201c\u667a\u80fd\u5236\u9020\u76ee\u6807\u4e0b\uff0c\u57fa\u7840\u7ea7\u667a\u80fd\u5de5\u5382\u7684\u201c\u6838\u5fc3\u6570\u636e\u5b9e\u65f6\u91c7\u96c6\u201c\u8981\u91c7\u4ec0\u4e48\u3001\u600e\u4e48\u91c7\uff08\u9644\u67b6\u6784\u4e0e Python \u5b9e\u73b0\uff09\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u4e0a\u6d77\u201c54321\u201c\u667a\u80fd\u5236\u9020\u76ee\u6807\u4e0b\uff0c\u57fa\u7840\u7ea7\u667a\u80fd\u5de5\u5382\u7684\u201c\u6838\u5fc3\u6570\u636e\u5b9e\u65f6\u91c7\u96c6\u201c\u8981\u91c7\u4ec0\u4e48\u3001\u600e\u4e48\u91c7\uff08\u9644\u67b6\u6784\u4e0e Python \u5b9e\u73b0\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/119079.html","og_locale":"zh_CN","og_type":"article","og_title":"\u4e0a\u6d77\u201c54321\u201c\u667a\u80fd\u5236\u9020\u76ee\u6807\u4e0b\uff0c\u57fa\u7840\u7ea7\u667a\u80fd\u5de5\u5382\u7684\u201c\u6838\u5fc3\u6570\u636e\u5b9e\u65f6\u91c7\u96c6\u201c\u8981\u91c7\u4ec0\u4e48\u3001\u600e\u4e48\u91c7\uff08\u9644\u67b6\u6784\u4e0e Python \u5b9e\u73b0\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6458\u8981&#xff1a;\u300a\u4e0a\u6d77\u5e02\u52a0\u5feb\u53d1\u5c55\u65b0\u4e00\u4ee3\u667a\u80fd\u5236\u9020\u884c\u52a8\u65b9\u6848\u300b\u63d0\u51fa\u5230 2028 \u5e74\u57fa\u7840\u7ea7\u667a\u80fd\u5de5\u5382\u7d2f\u8ba1\u8fbe 1600 \u5bb6&#xff0c;\u5e76\u628a\u201c\u5b9e\u73b0\u6838\u5fc3\u6570\u636e\u5b9e\u65f6\u91c7\u96c6\u201d\u5199\u8fdb\u4e86\u57fa\u7840\u7ea7\u7684\u51c6\u5165\u8981\u6c42\u3002\u8fd9\u7bc7\u6587\u7ae0\u4ece\u5de5\u7a0b\u89d2\u5ea6\u62c6\u89e3\u4e09\u4ef6\u4e8b&#xff1a;\u6838\u5fc3\u6570\u636e\u5230\u5e95\u5206\u54ea\u4e09\u5c42\u3001\u8bbe\u5907\u6570\u636e\u4e3a\u4ec0\u4e48\u53ef\u4ee5\u4e0d\u5fc5\u5148\u8fc7 MES&#xff0c;\u4ee5\u53ca\u4e00\u6761\u4ece PLC \/ CNC \u5230\u65f6\u5e8f\u6570\u636e\u5e93\u7684\u6700\u5c0f\u53ef\u7528\u91c7\u96c6\u94fe\u8def&#xff08;\u542b\u53ef\u8fd0\u884c\u7684 Python \u5b9e\u73b0\u4e0e\u4e09\u4e2a\u73b0\u573a\u5751&#xff09;\u3002 \u672c\u6587\u76ee\u5f55 \u4e00\u3001\u5148\u7ed9\u7ed3\u8bba\u4e8c\u3001\u653f\u7b56\u539f\u6587\u91cc&amp;","og_url":"https:\/\/www.wsisp.com\/helps\/119079.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-10-28T13:16:57+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"17 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/119079.html","url":"https:\/\/www.wsisp.com\/helps\/119079.html","name":"\u4e0a\u6d77\u201c54321\u201c\u667a\u80fd\u5236\u9020\u76ee\u6807\u4e0b\uff0c\u57fa\u7840\u7ea7\u667a\u80fd\u5de5\u5382\u7684\u201c\u6838\u5fc3\u6570\u636e\u5b9e\u65f6\u91c7\u96c6\u201c\u8981\u91c7\u4ec0\u4e48\u3001\u600e\u4e48\u91c7\uff08\u9644\u67b6\u6784\u4e0e Python \u5b9e\u73b0\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-10-28T13:16:57+00:00","dateModified":"2026-10-28T13:16:57+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/119079.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/119079.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/119079.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u4e0a\u6d77\u201c54321\u201c\u667a\u80fd\u5236\u9020\u76ee\u6807\u4e0b\uff0c\u57fa\u7840\u7ea7\u667a\u80fd\u5de5\u5382\u7684\u201c\u6838\u5fc3\u6570\u636e\u5b9e\u65f6\u91c7\u96c6\u201c\u8981\u91c7\u4ec0\u4e48\u3001\u600e\u4e48\u91c7\uff08\u9644\u67b6\u6784\u4e0e Python \u5b9e\u73b0\uff09"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/119079","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=119079"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/119079\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=119079"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=119079"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=119079"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=119079"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}