工厂数据建模
适用版本EdgeCloudEnterprise
Demo UNS 如何组织
Section titled “Demo UNS 如何组织”来自有物理位置的机器和设备的工业数据,通常基于 ISA-95 标准建模。
Enterprise (Level 4)└── Site (Level 3/4) └── Area (Level 3) └── Work Center / Process Cell (Level 2/3) └── Equipment / Unit (Level 1/2) └── Control Module / Device (Level 0/1)DemoFactory└── Site_01 └── Production └── Line_01 └── WorkOrderExecution ├── Metric │ ├── Target_Qty │ ├── Produced_Qty │ ├── Defect_Qty │ └── Completion_Rate └── State ├── CurrentWorkOrder └── WorkOrderStatus{ "namespace": [ { "name": "DemoFactory", "alias": "DemoFactory_9e50bbcd833d", "type": "PATH", "children": [ { "name": "Site_01", "alias": "DemoFactory__6d1fcad14e86", "type": "PATH", "children": [ { "name": "Production", "alias": "__Site_01_Pro_91523d2ad304", "type": "PATH", "children": [ { "name": "Line_01", "alias": "__Production__acd5841c1ada", "type": "PATH", "children": [ { "name": "WorkOrderExecution", "alias": "__Line_01_Wor_54904ff56e91", "type": "PATH", "children": [ { "name": "Metric", "alias": "metric_233fd84305c4", "type": "PATH", "children": [ { "name": "Target_Qty", "alias": "Target_Qty_8646b092e543", "type": "TOPIC", "topicType": "METRIC", "description": "Target quantity for the current Work Order.", "fields": [ { "name": "production_order_id", "type": "STRING" }, { "name": "plan_id", "type": "STRING" }, { "name": "plan_number", "type": "STRING" }, { "name": "work_order_id", "type": "STRING" }, { "name": "value", "type": "DOUBLE" }, { "name": "unit", "type": "STRING" }, { "name": "timestamp", "type": "DATETIME" } ], "enableHistory": "TRUE", "mockData": "FALSE" }, { "name": "Produced_Qty", "alias": "Produced_Qty_1f8cd3e11f77", "type": "TOPIC", "topicType": "METRIC", "description": "Produced quantity for the current Work Order.", "fields": [ { "name": "production_order_id", "type": "STRING" }, { "name": "plan_id", "type": "STRING" }, { "name": "plan_number", "type": "STRING" }, { "name": "work_order_id", "type": "STRING" }, { "name": "value", "type": "DOUBLE" }, { "name": "unit", "type": "STRING" }, { "name": "timestamp", "type": "DATETIME" } ], "enableHistory": "TRUE", "mockData": "FALSE" }, { "name": "Defect_Qty", "alias": "Defect_Qty_b48fb3563ec1", "type": "TOPIC", "topicType": "METRIC", "description": "Defect quantity for the current Work Order.", "fields": [ { "name": "production_order_id", "type": "STRING" }, { "name": "plan_id", "type": "STRING" }, { "name": "plan_number", "type": "STRING" }, { "name": "work_order_id", "type": "STRING" }, { "name": "value", "type": "DOUBLE" }, { "name": "unit", "type": "STRING" }, { "name": "timestamp", "type": "DATETIME" } ], "enableHistory": "TRUE", "mockData": "FALSE" }, { "name": "Completion_Rate", "alias": "Completion_R_7294e38e1530", "type": "TOPIC", "topicType": "METRIC", "description": "Completion percentage for the current Work Order.", "fields": [ { "name": "production_order_id", "type": "STRING" }, { "name": "plan_id", "type": "STRING" }, { "name": "plan_number", "type": "STRING" }, { "name": "work_order_id", "type": "STRING" }, { "name": "value", "type": "DOUBLE" }, { "name": "unit", "type": "STRING" }, { "name": "timestamp", "type": "DATETIME" } ], "enableHistory": "TRUE", "mockData": "FALSE" } ] }, { "name": "State", "alias": "state_539a0f331fe0", "type": "PATH", "children": [ { "name": "CurrentWorkOrder", "alias": "CurrentWorkO_a638320784dd", "type": "TOPIC", "topicType": "STATE", "description": "Current active Work Order on Line_01.", "fields": [ { "name": "production_order_id", "type": "STRING" }, { "name": "plan_id", "type": "STRING" }, { "name": "plan_number", "type": "STRING" }, { "name": "work_order_id", "type": "STRING" }, { "name": "target_line", "type": "STRING" }, { "name": "workstation", "type": "STRING" }, { "name": "product_code", "type": "STRING" }, { "name": "target_qty", "type": "DOUBLE" }, { "name": "unit", "type": "STRING" }, { "name": "started_at", "type": "DATETIME" }, { "name": "updated_at", "type": "DATETIME" } ], "enableHistory": "TRUE", "mockData": "FALSE" }, { "name": "WorkOrderStatus", "alias": "WorkOrderSta_e24e3bf113d1", "type": "TOPIC", "topicType": "STATE", "description": "Execution status of the current Work Order.", "fields": [ { "name": "production_order_id", "type": "STRING" }, { "name": "plan_id", "type": "STRING" }, { "name": "plan_number", "type": "STRING" }, { "name": "work_order_id", "type": "STRING" }, { "name": "status", "type": "STRING" }, { "name": "reason", "type": "STRING" }, { "name": "updated_at", "type": "DATETIME" } ], "enableHistory": "TRUE", "mockData": "FALSE" } ] } ] } ] } ] } ] } ] } ]}对于 ERP 中的生产订单、工单计划等业务计划和流程对象,应根据业务上下文进行建模。
业务数据建模指南
Section titled “业务数据建模指南”Factory / Business Domain / Business Object / Topic Type / Topic-
业务域:确认数据所属的业务流程或系统。
Terminal window ERPMESWMSQMSEAMLIMSPlanningInventoryMaintenanceQualityLogistics... -
业务对象:业务域中被管理的核心对象。
Terminal window ProductionOrdersWorkOrderPlanMaterialInventoryQualityInspectionMaintenanceOrdersPurchaseOrdersShipments... -
Topic 类型:从 Metric、Action 和 State 中选择数据类型。
Topic 类型 用途 示例 STATE 当前状态或当前事实 工单状态、订单状态、设备状态 METRIC 连续变化的数值 温度、速度、产量、OEE、能耗 ACTION 给外部执行者的命令 启动设备、停止设备、重置报警、请求下发工单
DemoFactory└── ERP ├── ProductionOrders │ └── State │ ├── UpsertProductionOrder │ └── OrderList └── WorkOrderPlan ├── Metric │ └── SplitCount └── State ├── PlanStatus └── WorkOrderList{ "namespace": [ { "name": "DemoFactory", "alias": "DemoFactory_f925c1ec5041", "type": "PATH", "children": [ { "name": "ERP", "alias": "DemoFactory__e504805b1973", "type": "PATH", "children": [ { "name": "ProductionOrders", "alias": "__ERP_Product_1e7984ac3a1d", "type": "PATH", "children": [ { "name": "State", "alias": "state_c2616c8698fa", "type": "PATH", "children": [ { "name": "UpsertProductionOrder", "alias": "UpsertProduc_d5f166da35c6", "type": "TOPIC", "topicType": "STATE", "description": "Event for creating or updating a Production Order from WOM or ERP simulation.", "fields": [ { "name": "event_id", "type": "STRING" }, { "name": "event_type", "type": "STRING" }, { "name": "source", "type": "STRING" }, { "name": "production_order_id", "type": "STRING" }, { "name": "order_number", "type": "STRING" }, { "name": "product_code", "type": "STRING" }, { "name": "planned_qty", "type": "DOUBLE" }, { "name": "unit", "type": "STRING" }, { "name": "status", "type": "STRING" }, { "name": "due_date", "type": "DATETIME" }, { "name": "updated_at", "type": "DATETIME" } ], "enableHistory": "TRUE", "mockData": "FALSE" }, { "name": "OrderList", "alias": "OrderList_11fbca51a2bd", "type": "TOPIC", "topicType": "STATE", "description": "Retained compatibility snapshot of current Production Orders.", "fields": [ { "name": "orders", "type": "STRING" }, { "name": "updated_at", "type": "DATETIME" } ], "enableHistory": "TRUE", "mockData": "FALSE" } ] } ] }, { "name": "WorkOrderPlan", "alias": "__ERP_WorkOrd_19f04960daf5", "type": "PATH", "children": [ { "name": "Metric", "alias": "metric_17258b809a4f", "type": "PATH", "children": [ { "name": "SplitCount", "alias": "SplitCount_032e86f5fbfc", "type": "TOPIC", "topicType": "METRIC", "description": "Number of executable Work Orders generated from a Work Order Plan.", "fields": [ { "name": "production_order_id", "type": "STRING" }, { "name": "plan_id", "type": "STRING" }, { "name": "plan_number", "type": "STRING" }, { "name": "split_count", "type": "INTEGER" }, { "name": "updated_at", "type": "DATETIME" } ], "enableHistory": "TRUE", "mockData": "FALSE" } ] }, { "name": "State", "alias": "state_884cee548bf7", "type": "PATH", "children": [ { "name": "PlanStatus", "alias": "PlanStatus_2e21c1327c49", "type": "TOPIC", "topicType": "STATE", "description": "Current lifecycle status of a Work Order Plan.", "fields": [ { "name": "production_order_id", "type": "STRING" }, { "name": "plan_id", "type": "STRING" }, { "name": "plan_number", "type": "STRING" }, { "name": "status", "type": "STRING" }, { "name": "updated_at", "type": "DATETIME" } ], "enableHistory": "TRUE", "mockData": "FALSE" }, { "name": "WorkOrderList", "alias": "WorkOrderLis_887b92f26fc2", "type": "TOPIC", "topicType": "STATE", "description": "Split result list generated from a sent Work Order Plan.", "fields": [ { "name": "production_order_id", "type": "STRING" }, { "name": "plan_id", "type": "STRING" }, { "name": "plan_number", "type": "STRING" }, { "name": "split_count", "type": "INTEGER" }, { "name": "lines", "type": "STRING" }, { "name": "updated_at", "type": "DATETIME" } ], "enableHistory": "TRUE", "mockData": "FALSE" } ] } ] } ] } ] } ]}设计 topic 消息内容时,需要同时考虑要消费的数据和要回写的数据。
-
Action
Action 消息内容会自动包含
_timestamp,用于记录数据存入 Tier0 数据库的时间。Terminal window {"light_turn_on": true,"height_adjust": 12.5,"_timestamp": "2026-07-10T10:00:00Z"}Terminal window {"water_pump_off": true,"window_close": true,"_timestamp": "2026-07-10T10:00:00Z"} -
Metric
Metric 消息内容会自动包含
_timestamp和_quality:前者记录数据存入 Tier0 数据库的时间,后者用于映射数据质量。Terminal window {"production_order_id": "PO-20260710-001","plan_id": "PLAN-001","plan_number": "WOP-20260710-001","split_count": 3,"updated_at": "2026-07-10T10:00:00Z","_timestamp": "2026-07-10T10:00:00Z","_quality": "Good"}Terminal window {"production_order_id": "PO-20260710-001","plan_id": "PLAN-001","plan_number": "WOP-20260710-001","work_order_id": "WO-001","value": 1200,"unit": "pcs","timestamp": "2026-07-10T10:00:00Z","_timestamp": "2026-07-10T10:00:00Z","_quality": "Good"} -
State
State 消息内容会自动包含
_timestamp,用于记录数据存入 Tier0 数据库的时间。Terminal window {"event_id": "EVT-001","event_type": "UPSERT","source": "ERP","production_order_id": "PO-20260710-001","order_number": "PO-001","product_code": "SKU-1001","planned_qty": 1200,"unit": "pcs","status": "Released","due_date": "2026-07-12T00:00:00Z","updated_at": "2026-07-10T10:00:00Z","_timestamp": "2026-07-10T10:00:00Z"}Terminal window {"production_order_id": "PO-20260710-001","plan_id": "PLAN-001","plan_number": "WOP-20260710-001","work_order_id": "WO-001","status": "Running","reason": "In production","updated_at": "2026-07-10T10:00:00Z","_timestamp": "2026-07-10T10:00:00Z"}
如何避免 Topic 爆炸
Section titled “如何避免 Topic 爆炸”Tier0 设计了三种固定的 Topic 类型, Metric, Action 和 State 来避免 topic 爆炸.
-
将
Metric用于高频实时数据将高频测量值和遥测数据统一放在
Metric下,而不是为每个信号细节创建 topic。Terminal window Factory_A└── SMT_Line_1└── Machine_001├── Temperature_Value├── Temperature_Unit├── Temperature_Status└── Speed_ValueTerminal window Factory_A└── SMT_Line_1└── Metric└── Machine_001消息内容:
Terminal window {"temperature": 80,"temperature_unit": "Celsius","temperature_status": "Normal","speed": 300} -
将
State用于低频状态数据将低频状态、快照和当前业务状态放在
State下。避免为作业、批次或订单等变化实体分别创建新 topic。 -
将
Action用于低频动作数据将命令、请求和操作员动作放在
Action下。动作输入应作为 topic 的字段,而不是为每个参数创建一个 topic。