Files
cnc_wams/项目分析/LinuxCNC数据系统核心原理高清流程图.svg
2026-07-05 22:13:40 -04:00

198 lines
17 KiB
XML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<svg xmlns="http://www.w3.org/2000/svg" width="5200" height="6600" viewBox="0 0 5200 6600">
<defs>
<marker id="arrow" markerWidth="18" markerHeight="18" refX="14" refY="6" orient="auto" markerUnits="strokeWidth">
<path d="M2,2 L14,6 L2,10 Z" fill="#203a53"/>
</marker>
<style>
svg { background: #ffffff; }
text { font-family: Noto Sans CJK SC, DejaVu Sans, sans-serif; fill: #17212b; }
.title { font-size: 78px; font-weight: 850; }
.subtitle { font-size: 35px; fill: #53606c; }
.section { font-size: 43px; font-weight: 850; fill: #233d56; }
.boxtitle { font-size: 35px; font-weight: 850; }
.boxbody { font-size: 27px; fill: #33495d; }
.smalltitle { font-size: 29px; font-weight: 850; }
.smallbody { font-size: 24px; fill: #35495e; }
.label { font-size: 25px; font-weight: 750; fill: #25415d; }
.foot { font-size: 26px; fill: #52606d; }
</style>
</defs>
<rect x="0" y="0" width="5200" height="6600" fill="#ffffff"/>
<text x="2600" y="118" class="title" text-anchor="middle">LinuxCNC 数据系统核心原理</text>
<text x="2600" y="176" class="subtitle" text-anchor="middle">INI / NML / Task / Interpreter / Motion Shared Memory / HAL / GUI</text>
<rect x="130" y="260" width="4940" height="660" rx="36" fill="#eef6ff" stroke="#9fb9d2" stroke-width="4"/>
<text x="164" y="326" class="section">1. 静态装配层INI 决定系统如何启动</text>
<rect x="250" y="390" width="960" height="250" rx="18" fill="#ffffff" stroke="#386d9d" stroke-width="4"/>
<text x="730.0" y="434" class="boxtitle" text-anchor="middle">INI 文件</text>
<text x="278" y="474" class="boxbody">机器拓扑、KINS、JOINTS、TRAJ、DISPLAY、HALFILE、HA</text>
<text x="278" y="505" class="boxbody">LCMD、NML_FILE。INI</text>
<text x="278" y="536" class="boxbody">是启动装配说明,不是实时数据通道。</text>
<rect x="1510" y="390" width="920" height="250" rx="18" fill="#ffffff" stroke="#386d9d" stroke-width="4"/>
<text x="1970.0" y="434" class="boxtitle" text-anchor="middle">scripts/linuxcnc</text>
<text x="1538" y="474" class="boxbody">读取 INI启动</text>
<text x="1538" y="505" class="boxbody">linuxcncsvr、realtime、milltask、halui、HAL</text>
<text x="1538" y="536" class="boxbody">配置和 GUI。</text>
<rect x="2730" y="390" width="900" height="250" rx="18" fill="#ffffff" stroke="#386d9d" stroke-width="4"/>
<text x="3180.0" y="434" class="boxtitle" text-anchor="middle">模块装配</text>
<text x="2758" y="474" class="boxbody">loadrt motmod / kinematics / pid /</text>
<text x="2758" y="505" class="boxbody">驱动loadusr halui / Vismach / GUI 组件。</text>
<rect x="3910" y="390" width="920" height="250" rx="18" fill="#ffffff" stroke="#386d9d" stroke-width="4"/>
<text x="4370.0" y="434" class="boxtitle" text-anchor="middle">初始参数落地</text>
<text x="3938" y="474" class="boxbody">INI 值被转写到 task 状态、motion config、HAL</text>
<text x="3938" y="505" class="boxbody">pin/param 或组件启动参数。</text>
<path d="M 1210 515 L 1510 515" fill="none" stroke="#203a53" stroke-width="6" marker-end="url(#arrow)"/>
<path d="M 2430 515 L 2730 515" fill="none" stroke="#203a53" stroke-width="6" marker-end="url(#arrow)"/>
<path d="M 3630 515 L 3910 515" fill="none" stroke="#203a53" stroke-width="6" marker-end="url(#arrow)"/>
<rect x="130" y="1020" width="4940" height="940" rx="36" fill="#f8f3ff" stroke="#b59ad7" stroke-width="4"/>
<text x="164" y="1086" class="section">2. NML跨进程命令 / 状态 / 错误总线</text>
<rect x="250" y="1180" width="930" height="250" rx="18" fill="#ffffff" stroke="#7a4eb0" stroke-width="4"/>
<text x="715.0" y="1224" class="boxtitle" text-anchor="middle">emcCommand</text>
<text x="278" y="1264" class="boxbody">GUI、halui、外部客户端写入命令。典型命令MDI、A</text>
<text x="278" y="1295" class="boxbody">UTO_RUN、SET_MODE、SET_STATE、ABORT。</text>
<rect x="1520" y="1180" width="900" height="250" rx="18" fill="#ffffff" stroke="#7a4eb0" stroke-width="4"/>
<text x="1970.0" y="1224" class="boxtitle" text-anchor="middle">milltask</text>
<text x="1548" y="1264" class="boxbody">读取 NML 命令,检查状态合法性,调度</text>
<text x="1548" y="1295" class="boxbody">interpreter、motion、IO、tool、spindle。</text>
<rect x="2760" y="1180" width="930" height="250" rx="18" fill="#ffffff" stroke="#7a4eb0" stroke-width="4"/>
<text x="3225.0" y="1224" class="boxtitle" text-anchor="middle">emcStatus</text>
<text x="2788" y="1264" class="boxbody">task 汇总 EMC_STATtask、motion、io。GUI/halui</text>
<text x="2788" y="1295" class="boxbody">读取该状态。</text>
<rect x="4030" y="1180" width="780" height="250" rx="18" fill="#ffffff" stroke="#7a4eb0" stroke-width="4"/>
<text x="4420.0" y="1224" class="boxtitle" text-anchor="middle">emcError</text>
<text x="4058" y="1264" class="boxbody">错误、操作信息、诊断消息通道。</text>
<path d="M 1180 1305 L 1520 1305" fill="none" stroke="#203a53" stroke-width="6" marker-end="url(#arrow)"/>
<rect x="1160.0" y="1257.0" width="380" height="42" rx="10" fill="#ffffff" opacity="0.94"/>
<text x="1350.0" y="1287.0" class="label" text-anchor="middle">命令</text>
<path d="M 2420 1305 L 2760 1305" fill="none" stroke="#203a53" stroke-width="6" marker-end="url(#arrow)"/>
<rect x="2400.0" y="1257.0" width="380" height="42" rx="10" fill="#ffffff" opacity="0.94"/>
<text x="2590.0" y="1287.0" class="label" text-anchor="middle">状态汇总</text>
<path d="M 3690 1305 L 4030 1305" fill="none" stroke="#203a53" stroke-width="6" marker-end="url(#arrow)"/>
<rect x="3670.0" y="1257.0" width="380" height="42" rx="10" fill="#ffffff" opacity="0.94"/>
<text x="3860.0" y="1287.0" class="label" text-anchor="middle">错误/信息</text>
<rect x="580" y="1600" width="1180" height="190" rx="14" fill="#ffffff" stroke="#7a4eb0" stroke-width="3"/>
<text x="1170.0" y="1636" class="smalltitle" text-anchor="middle">linuxcncsvr</text>
<text x="602" y="1668" class="smallbody">NML channel master/server通常最先启动。</text>
<rect x="2260" y="1600" width="1420" height="190" rx="14" fill="#ffffff" stroke="#7a4eb0" stroke-width="3"/>
<text x="2970.0" y="1636" class="smalltitle" text-anchor="middle">EMC_STAT</text>
<text x="2282" y="1668" class="smallbody">EMC_TASK_STAT + EMC_MOTION_STAT + EMC_IO_STAT。</text>
<rect x="130" y="2060" width="4940" height="1000" rx="36" fill="#fff8eb" stroke="#d49a35" stroke-width="4"/>
<text x="164" y="2126" class="section">3. Task / Interpreter把人的意图转成规范动作</text>
<rect x="250" y="2220" width="880" height="260" rx="18" fill="#ffffff" stroke="#b36b00" stroke-width="4"/>
<text x="690.0" y="2264" class="boxtitle" text-anchor="middle">GUI / halui 意图</text>
<text x="278" y="2304" class="boxbody">按钮、MDI、自动运行、暂停、jog、模式切换。它</text>
<text x="278" y="2335" class="boxbody">们表达意图,不直接控制 servo 周期。</text>
<rect x="1420" y="2220" width="900" height="260" rx="18" fill="#ffffff" stroke="#b36b00" stroke-width="4"/>
<text x="1870.0" y="2264" class="boxtitle" text-anchor="middle">Interpreter</text>
<text x="1448" y="2304" class="boxbody">读取</text>
<text x="1448" y="2335" class="boxbody">G-code维护模态组、坐标系、G92、刀补、参数、r</text>
<text x="1448" y="2366" class="boxbody">emap、子程序调用。</text>
<rect x="2610" y="2220" width="920" height="260" rx="18" fill="#ffffff" stroke="#b36b00" stroke-width="4"/>
<text x="3070.0" y="2264" class="boxtitle" text-anchor="middle">Canonical Commands</text>
<text x="2638" y="2304" class="boxbody">直线、圆弧、主轴、IO、M68 analog</text>
<text x="2638" y="2335" class="boxbody">output、换刀等规范动作。</text>
<rect x="3820" y="2220" width="900" height="260" rx="18" fill="#ffffff" stroke="#b36b00" stroke-width="4"/>
<text x="4270.0" y="2264" class="boxtitle" text-anchor="middle">taskintf.cc</text>
<text x="3848" y="2304" class="boxbody">把规范动作转成 emcmot_command_t 或</text>
<text x="3848" y="2335" class="boxbody">IO/tool/spindle 命令。</text>
<path d="M 1130 2350 L 1420 2350" fill="none" stroke="#203a53" stroke-width="6" marker-end="url(#arrow)"/>
<path d="M 2320 2350 L 2610 2350" fill="none" stroke="#203a53" stroke-width="6" marker-end="url(#arrow)"/>
<path d="M 3530 2350 L 3820 2350" fill="none" stroke="#203a53" stroke-width="6" marker-end="url(#arrow)"/>
<rect x="640" y="2700" width="1240" height="190" rx="14" fill="#ffffff" stroke="#b36b00" stroke-width="3"/>
<text x="1260.0" y="2736" class="smalltitle" text-anchor="middle">M68 E3 Q1</text>
<text x="662" y="2768" class="smallbody">解释器 -&gt; SET_AUX_OUTPUT_VALUE -&gt; EMC_MOTION_SET_AOUT。</text>
<rect x="2350" y="2700" width="1320" height="190" rx="14" fill="#ffffff" stroke="#b36b00" stroke-width="3"/>
<text x="3010.0" y="2736" class="smalltitle" text-anchor="middle">关键边界</text>
<text x="2372" y="2768" class="smallbody">G-code 不直接写 HAL它先进入 task/interpreter。</text>
<rect x="130" y="3160" width="4940" height="1020" rx="36" fill="#eefaf1" stroke="#65a36f" stroke-width="4"/>
<text x="164" y="3226" class="section">4. Motion Shared Memory非实时 task 与实时 motion 的边界</text>
<rect x="250" y="3320" width="1050" height="300" rx="18" fill="#ffffff" stroke="#3f7d4a" stroke-width="4"/>
<text x="775.0" y="3364" class="boxtitle" text-anchor="middle">emcmot_command_t</text>
<text x="278" y="3404" class="boxbody">task 写入motion 读取。包含 command</text>
<text x="278" y="3435" class="boxbody">code、pos、vel、acc、tool_offset、AOUT/DOUT、spindle</text>
<text x="278" y="3466" class="boxbody">等命令参数。</text>
<rect x="1580" y="3320" width="1030" height="300" rx="18" fill="#ffffff" stroke="#3f7d4a" stroke-width="4"/>
<text x="2095.0" y="3364" class="boxtitle" text-anchor="middle">emcmot_status_t</text>
<text x="1608" y="3404" class="boxbody">motion 周期更新task 读取。包含</text>
<text x="1608" y="3435" class="boxbody">carte_pos_cmd/fb、joint/axis/spindle、queue、analog_ou</text>
<text x="1608" y="3466" class="boxbody">tput、heartbeat。</text>
<rect x="2890" y="3320" width="920" height="300" rx="18" fill="#ffffff" stroke="#3f7d4a" stroke-width="4"/>
<text x="3350.0" y="3364" class="boxtitle" text-anchor="middle">emcmot_config_t</text>
<text x="2918" y="3404" class="boxbody">实时 motion 配置joint 数、kinematics</text>
<text x="2918" y="3435" class="boxbody">type、速度/加速度限制等。</text>
<rect x="4090" y="3320" width="760" height="300" rx="18" fill="#ffffff" stroke="#3f7d4a" stroke-width="4"/>
<text x="4470.0" y="3364" class="boxtitle" text-anchor="middle">head / tail</text>
<text x="4118" y="3404" class="boxbody">读取 status 时检查 head ==</text>
<text x="4118" y="3435" class="boxbody">tail避免读到半更新快照。</text>
<path d="M 1300 3470 L 1580 3470" fill="none" stroke="#203a53" stroke-width="6" marker-end="url(#arrow)"/>
<rect x="1250.0" y="3422.0" width="380" height="42" rx="10" fill="#ffffff" opacity="0.94"/>
<text x="1440.0" y="3452.0" class="label" text-anchor="middle">执行后反馈</text>
<path d="M 2610 3470 L 2890 3470" fill="none" stroke="#203a53" stroke-width="6" marker-end="url(#arrow)"/>
<path d="M 3810 3470 L 4090 3470" fill="none" stroke="#203a53" stroke-width="6" marker-end="url(#arrow)"/>
<rect x="670" y="3840" width="1260" height="190" rx="14" fill="#ffffff" stroke="#3f7d4a" stroke-width="3"/>
<text x="1300.0" y="3876" class="smalltitle" text-anchor="middle">usrmotWriteEmcmotCommand()</text>
<text x="692" y="3908" class="smallbody">加 command_mutex复制 command等待 commandNumEcho。</text>
<rect x="2530" y="3840" width="1320" height="190" rx="14" fill="#ffffff" stroke="#3f7d4a" stroke-width="3"/>
<text x="3190.0" y="3876" class="smalltitle" text-anchor="middle">usrmotReadEmcmotStatus()</text>
<text x="2552" y="3908" class="smallbody">复制 status检查 head/tail 一致性。</text>
<rect x="130" y="4280" width="4940" height="1080" rx="36" fill="#eef9f8" stroke="#4b9c9a" stroke-width="4"/>
<text x="164" y="4346" class="section">5. Realtime Motion + HAL周期执行与机器信号网络</text>
<rect x="250" y="4440" width="920" height="300" rx="18" fill="#ffffff" stroke="#2b7a78" stroke-width="4"/>
<text x="710.0" y="4484" class="boxtitle" text-anchor="middle">servo-thread</text>
<text x="278" y="4524" class="boxbody">固定周期运行。执行</text>
<text x="278" y="4555" class="boxbody">motion-controller、PID、驱动、仿真组件等 HAL</text>
<text x="278" y="4586" class="boxbody">function。</text>
<rect x="1450" y="4440" width="980" height="300" rx="18" fill="#ffffff" stroke="#2b7a78" stroke-width="4"/>
<text x="1940.0" y="4484" class="boxtitle" text-anchor="middle">motion-controller</text>
<text x="1478" y="4524" class="boxbody">轨迹取点、switchkins、forward/inverse</text>
<text x="1478" y="4555" class="boxbody">kinematics、limits、probe、jog、homing、status。</text>
<rect x="2710" y="4440" width="900" height="300" rx="18" fill="#ffffff" stroke="#2b7a78" stroke-width="4"/>
<text x="3160.0" y="4484" class="boxtitle" text-anchor="middle">HAL pins</text>
<text x="2738" y="4524" class="boxbody">motion、joint、spindle、驱动、Vismach、halui</text>
<text x="2738" y="4555" class="boxbody">都通过 pin 暴露实时变量。</text>
<rect x="3890" y="4440" width="900" height="300" rx="18" fill="#ffffff" stroke="#2b7a78" stroke-width="4"/>
<text x="4340.0" y="4484" class="boxtitle" text-anchor="middle">HAL signals</text>
<text x="3918" y="4524" class="boxbody">net 命令将 pin 连接到同一 signal。通常一个</text>
<text x="3918" y="4555" class="boxbody">writer多个 reader。</text>
<path d="M 1170 4590 L 1450 4590" fill="none" stroke="#203a53" stroke-width="6" marker-end="url(#arrow)"/>
<path d="M 2430 4590 L 2710 4590" fill="none" stroke="#203a53" stroke-width="6" marker-end="url(#arrow)"/>
<path d="M 3610 4590 L 3890 4590" fill="none" stroke="#203a53" stroke-width="6" marker-end="url(#arrow)"/>
<rect x="520" y="5020" width="1200" height="190" rx="14" fill="#ffffff" stroke="#2b7a78" stroke-width="3"/>
<text x="1120.0" y="5056" class="smalltitle" text-anchor="middle">HAL shared memory</text>
<text x="542" y="5088" class="smallbody">component list / pin list / signal list / param list / function list /</text>
<text x="542" y="5115" class="smallbody">thread list。</text>
<rect x="2080" y="5020" width="1200" height="190" rx="14" fill="#ffffff" stroke="#2b7a78" stroke-width="3"/>
<text x="2680.0" y="5056" class="smalltitle" text-anchor="middle">net 的本质</text>
<text x="2102" y="5088" class="smallbody">把 pin data pointer 指向同一个 signal value。</text>
<rect x="3620" y="5020" width="1040" height="190" rx="14" fill="#ffffff" stroke="#2b7a78" stroke-width="3"/>
<text x="4140.0" y="5056" class="smalltitle" text-anchor="middle">实时原则</text>
<text x="3642" y="5088" class="smallbody">控制闭环必须在 motion/HAL 内,不能依赖 GUI poll。</text>
<rect x="130" y="5460" width="4940" height="900" rx="36" fill="#f6f7f9" stroke="#9da8b3" stroke-width="4"/>
<text x="164" y="5526" class="section">6. 状态回流与 GUI 显示</text>
<rect x="250" y="5620" width="920" height="250" rx="18" fill="#ffffff" stroke="#5b6570" stroke-width="4"/>
<text x="710.0" y="5664" class="boxtitle" text-anchor="middle">motion status</text>
<text x="278" y="5704" class="boxbody">实时 motion 更新 emcmot_status_t。</text>
<rect x="1470" y="5620" width="920" height="250" rx="18" fill="#ffffff" stroke="#5b6570" stroke-width="4"/>
<text x="1930.0" y="5664" class="boxtitle" text-anchor="middle">task update</text>
<text x="1498" y="5704" class="boxbody">emcMotionUpdate() 将 motion status 汇总到</text>
<text x="1498" y="5735" class="boxbody">EMC_MOTION_STAT。</text>
<rect x="2690" y="5620" width="920" height="250" rx="18" fill="#ffffff" stroke="#5b6570" stroke-width="4"/>
<text x="3150.0" y="5664" class="boxtitle" text-anchor="middle">EMC_STAT</text>
<text x="2718" y="5704" class="boxbody">顶层状态task + motion + io。写入 emcStatus</text>
<text x="2718" y="5735" class="boxbody">NML。</text>
<rect x="3910" y="5620" width="920" height="250" rx="18" fill="#ffffff" stroke="#5b6570" stroke-width="4"/>
<text x="4370.0" y="5664" class="boxtitle" text-anchor="middle">GUI / halui</text>
<text x="3938" y="5704" class="boxbody">poll</text>
<text x="3938" y="5735" class="boxbody">emcStatus显示位置、模式、状态、错误、队列、模</text>
<text x="3938" y="5766" class="boxbody">态。</text>
<path d="M 1170 5745 L 1470 5745" fill="none" stroke="#203a53" stroke-width="6" marker-end="url(#arrow)"/>
<path d="M 2390 5745 L 2690 5745" fill="none" stroke="#203a53" stroke-width="6" marker-end="url(#arrow)"/>
<path d="M 3610 5745 L 3910 5745" fill="none" stroke="#203a53" stroke-width="6" marker-end="url(#arrow)"/>
<path d="M 4360 5620 L 4360 5350 L 390 5350 L 390 4740" fill="none" stroke="#203a53" stroke-width="6" marker-end="url(#arrow)" stroke-dasharray="18 12"/>
<rect x="190" y="5298" width="400" height="42" rx="10" fill="#ffffff" opacity="0.94"/>
<text x="390" y="5328" class="label" text-anchor="middle">HAL/Vismach 也可直接读 HAL</text>
<text x="2600" y="6460" class="foot" text-anchor="middle">核心原则NML 表达系统命令/状态HAL 表达实时机器信号motion shared memory 是 task 与实时控制的边界。</text>
<text x="2600" y="6505" class="foot" text-anchor="middle">输出文件:项目分析/LinuxCNC数据系统核心原理高清流程图.png源文件项目分析/LinuxCNC数据系统核心原理高清流程图.svg</text>
</svg>