88 lines
7.3 KiB
XML
88 lines
7.3 KiB
XML
<?xml version="1.0" encoding="UTF-8"?>
|
||
<mxfile host="app.diagrams.net" modified="2026-05-10T00:00:00.000Z"
|
||
agent="AI-Drawio-Replicator" version="24.0.0" type="device">
|
||
<diagram id="page-1" name="传感器工厂模式">
|
||
<mxGraphModel dx="1400" dy="900" grid="1" gridSize="10"
|
||
guides="1" tooltips="1" connect="1" arrows="1"
|
||
fold="1" page="1" pageScale="1"
|
||
pageWidth="1400" pageHeight="900"
|
||
background="#f0f8ff">
|
||
<root>
|
||
<mxCell id="0"/>
|
||
<mxCell id="1" parent="0"/>
|
||
|
||
<!-- 应用层 -->
|
||
<mxCell id="2" value="<div style="display:flex;align-items:center;justify-content:center;gap:15px;font-size:20px;font-weight:bold;"><div style="font-size:40px;">📱</div><div>应用层<br><span style="font-size:16px;font-weight:normal;">(调用者)</span></div></div>" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e6f2ff;strokeColor=#6699cc;strokeWidth=2;shadow=1;fontSize=14;" vertex="1" parent="1">
|
||
<mxGeometry x="100" y="80" width="220" height="100" as="geometry"/>
|
||
</mxCell>
|
||
|
||
<!-- 代码示例 -->
|
||
<mxCell id="3" value="<div style="font-family:monospace;font-size:18px;line-height:1.6;">sensor = <span style="color:#0066cc;font-weight:bold;">sensor_create</span>(SENSOR_DS18B20);<br>sensor->read(); <span style="color:#666666;">// 不关心具体实现</span></div>" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
|
||
<mxGeometry x="380" y="80" width="600" height="100" as="geometry"/>
|
||
</mxCell>
|
||
|
||
<!-- 工厂函数 -->
|
||
<mxCell id="4" value="<div style="display:flex;align-items:center;justify-content:center;gap:15px;font-size:24px;font-weight:bold;"><div style="font-size:40px;">🏭</div><div>工厂函数</div></div>" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e6f9f2;strokeColor=#33cc99;strokeWidth=3;shadow=1;fontSize=14;" vertex="1" parent="1">
|
||
<mxGeometry x="400" y="280" width="280" height="100" as="geometry"/>
|
||
</mxCell>
|
||
|
||
<!-- 工厂函数说明 -->
|
||
<mxCell id="5" value="<div style="font-size:16px;">根据类型参数,选择并返回对应的操作集合</div>" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
|
||
<mxGeometry x="720" y="320" width="350" height="30" as="geometry"/>
|
||
</mxCell>
|
||
|
||
<!-- 传感器操作接口容器 -->
|
||
<mxCell id="6" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e6f2ff;strokeColor=#6699cc;strokeWidth=3;shadow=1;fontSize=14;" vertex="1" parent="1">
|
||
<mxGeometry x="250" y="500" width="700" height="280" as="geometry"/>
|
||
</mxCell>
|
||
|
||
<!-- 传感器操作接口标题 -->
|
||
<mxCell id="7" value="<div style="font-size:24px;font-weight:bold;text-align:center;">传感器操作接口</div>" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f0f7ff;strokeColor=#6699cc;strokeWidth=2;fontSize=14;" vertex="1" parent="6">
|
||
<mxGeometry x="50" y="20" width="600" height="50" as="geometry"/>
|
||
</mxCell>
|
||
|
||
<!-- DS18B20传感器 -->
|
||
<mxCell id="8" value="<div style="display:flex;align-items:center;justify-content:center;gap:10px;font-size:20px;font-weight:bold;"><div style="font-size:36px;">🌡️</div><div>DS18B20<br><span style="font-size:16px;font-weight:normal;font-family:monospace;">.init<br>.read<br>.deinit</span></div></div>" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f0f7ff;strokeColor=#6699cc;strokeWidth=2;fontSize=14;" vertex="1" parent="6">
|
||
<mxGeometry x="50" y="100" width="180" height="160" as="geometry"/>
|
||
</mxCell>
|
||
|
||
<!-- NTC传感器 -->
|
||
<mxCell id="9" value="<div style="display:flex;align-items:center;justify-content:center;gap:10px;font-size:20px;font-weight:bold;"><div style="font-size:36px;">🌡️</div><div>NTC<br><span style="font-size:16px;font-weight:normal;font-family:monospace;">.init<br>.read<br>.deinit</span></div></div>" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e6f9f2;strokeColor=#33cc99;strokeWidth=2;fontSize=14;" vertex="1" parent="6">
|
||
<mxGeometry x="260" y="100" width="180" height="160" as="geometry"/>
|
||
</mxCell>
|
||
|
||
<!-- PT100传感器 -->
|
||
<mxCell id="10" value="<div style="display:flex;align-items:center;justify-content:center;gap:10px;font-size:20px;font-weight:bold;"><div style="font-size:36px;">🌡️</div><div>PT100<br><span style="font-size:16px;font-weight:normal;font-family:monospace;">.init<br>.read<br>.deinit</span></div></div>" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f0f7ff;strokeColor=#6699cc;strokeWidth=2;fontSize=14;" vertex="1" parent="6">
|
||
<mxGeometry x="470" y="100" width="180" height="160" as="geometry"/>
|
||
</mxCell>
|
||
|
||
<!-- 连线1:应用层到工厂函数 -->
|
||
<mxCell id="11" value="<div style="font-size:16px;">调用工厂函数</div>" style="endArrow=classic;html=1;strokeColor=#336699;strokeWidth=2;labelPosition=top;verticalAlign=bottom;labelBackgroundColor=#ffffff;" edge="1" parent="1" source="2" target="4">
|
||
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
||
<mxPoint x="210" y="180" as="sourcePoint"/>
|
||
<mxPoint x="210" y="280" as="targetPoint"/>
|
||
<mxPoint x="400" y="280" as="targetPoint"/>
|
||
</mxGeometry>
|
||
</mxCell>
|
||
|
||
<!-- 连线2:工厂函数到传感器接口 -->
|
||
<mxCell id="12" value="<div style="font-size:16px;">返回具体实例</div>" style="endArrow=classic;html=1;strokeColor=#33cc99;strokeWidth=3;labelPosition=right;verticalAlign=middle;labelBackgroundColor=#ffffff;" edge="1" parent="1" source="4" target="6">
|
||
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
||
<mxPoint x="540" y="380" as="sourcePoint"/>
|
||
<mxPoint x="540" y="500" as="targetPoint"/>
|
||
</mxGeometry>
|
||
</mxCell>
|
||
|
||
<!-- 装饰性图标 -->
|
||
<mxCell id="13" value="📄" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=32;" vertex="1" parent="1">
|
||
<mxGeometry x="480" y="200" width="40" height="40" as="geometry"/>
|
||
</mxCell>
|
||
|
||
<!-- 装饰性箭头 -->
|
||
<mxCell id="14" value="⬇️" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize:48px;color:#33cc99;" vertex="1" parent="1">
|
||
<mxGeometry x="520" y="420" width="40" height="60" as="geometry"/>
|
||
</mxCell>
|
||
</root>
|
||
</mxGraphModel>
|
||
</diagram>
|
||
</mxfile> |