首页 理论 架构 工程 文档 白皮书 著作 研究 案例 下载 博客 关于 开始使用 →

第二十四篇 Self-Maintenance

第二十四篇 Self-Maintenance

第72章 Detection

Detection 是 SAI/ICAI 自我维护体系的基础环节。

前面已经建立了:

Information
→ Perception
→ Cognition
→ Reasoning
→ Decision
→ Behavior
→ Action
→ Feedback
→ Experience
→ Learning

而自我维护需要增加另一条检测路径:

System
 ↓
Detection
 ↓
Detection Result
 ↓
Risk / Conflict / Diagnosis
 ↓
Decision
 ↓
Repair
 ↓
Verification

Detection 的任务不是直接修复,而是发现当前系统、模块、行为、设备和运行状态是否正常


1. Detection

1.1 Detection 定义

**Detection(检测)**是 SAI/ICAI 对系统内部对象、运行状态、行为过程、设备状态及异常条件进行检查,并形成结构化检测结果的机制。

核心关系:

Target
   ↓
Detection
   ↓
Comparison
   ↓
State Judgment
   ↓
Detection Result

Detection 可以检测:

System
Module
Object
State
Behavior
Action
Device
Connection
Data
Rule
Memory

但 Detection 本身不负责:

Diagnosis
Repair
Decision

例如:

Detection:
发现 Motor_A 当前状态 ERROR

而:

Diagnosis:
判断为什么 ERROR

再进一步:

Repair:
执行恢复操作

因此:

Detection ≠ Diagnosis
Detection ≠ Repair
Detection ≠ Decision

1.2 Detection 的基本结构

Detection
{
    id
    target
    target_type
    check_type
    expected
    actual
    condition
    state
    source
    timestamp
}

例如:

Detection
{
    id: "D001",
    target: "Motor_A",
    target_type: "DEVICE",
    check_type: "STATE",
    expected: "READY",
    actual: "ERROR",
    condition: "state_match",
    state: "ABNORMAL",
    source: "DeviceAdapter",
    timestamp: "2026-09-12 18:00:00"
}

2. 状态检测

状态检测是 Detection 最基础的形式。

核心问题:

当前对象处于什么状态?

例如:

Device_A
state = RUNNING

系统预期:

expected = READY

检测:

expected = READY
actual = RUNNING

结果:

ABNORMAL

2.1 状态检测流程

Target
 ↓
Read State
 ↓
Expected State
 ↓
Compare
 ↓
Detection Result

例如:

Motor_A
Expected = READY
Actual   = ERROR
        ↓
State Detection
        ↓
ABNORMAL

2.2 状态检测结果

可以定义:

NORMAL
ABNORMAL
UNKNOWN
UNAVAILABLE
CONFLICT

需要特别注意:

UNKNOWN ≠ ABNORMAL

例如:

无法读取设备状态

只能得到:

UNKNOWN

不能直接判断:

设备故障

同样:

UNAVAILABLE

表示检测对象当前无法访问,并不等于对象本身一定异常。


2.3 状态变化检测

不仅可以检测当前状态,也可以检测状态变化:

Previous State
      ↓
Current State
      ↓
Compare
      ↓
State Change

例如:

READY
 ↓
RUNNING

结果:

StateChange = VALID

而:

RUNNING
 ↓
ERROR

则:

StateChange = ABNORMAL

状态变化可以进一步进入:

Risk
Diagnosis
Experience
Memory

3. 模块检测

SAI/ICAI 由多个模块构成,因此需要对模块本身进行检测。

例如:

PerceptionEngine
CognitionEngine
ReasoningEngine
DecisionEngine
LearningEngine
Memory
RuleEngine
SATE
Adapter

模块检测关注:

模块是否存在?
模块是否启用?
模块是否正常?
模块依赖是否正常?
模块输入是否正常?
模块输出是否正常?

3.1 Module Detection

结构:

ModuleDetection
{
    module_id
    module_name
    state
    dependency
    input_state
    output_state
    error
    timestamp
}

例如:

ModuleDetection
{
    module_id: "M006",
    module_name: "LearningEngine",
    state: "ACTIVE",
    dependency: "OK",
    input_state: "OK",
    output_state: "OK",
    error: null
}

结果:

NORMAL

3.2 模块依赖检测

模块之间存在依赖:

LearningEngine
      ↓
Memory
      ↓
Storage

如果 Storage 不可用:

Storage
 ↓
ERROR

可能造成:

Memory
 ↓
UNAVAILABLE

进一步影响:

LearningEngine
 ↓
PARTIAL

因此模块检测不能只检查模块自身,还要检查:

Module
 ↓
Dependency
 ↓
Dependency State

4. 行为检测

行为检测负责检查 Behavior 和 Action 的执行过程。

前面定义:

Decision → Behavior → Action

现在加入:

Decision
 ↓
Behavior
 ↓
Detection
 ↓
Action

或者:

Behavior
 ↓
Action
 ↓
Execution
 ↓
Detection

4.1 行为检测内容

检测:

行为是否启动?
行为是否按照条件执行?
行为是否超时?
行为是否成功?
行为是否产生预期结果?
行为是否发生错误?
行为是否被取消?

例如:

Behavior
{
    id: "B001",
    type: "EXECUTE",
    target: "Motor_A",
    action: "START",
    state: "RUNNING"
}

预期:

Motor_A.state = RUNNING

实际:

Motor_A.state = STOPPED

检测结果:

ABNORMAL

4.2 行为过程检测

行为不仅有最终结果,还可以检测过程:

NEW
 ↓
READY
 ↓
RUNNING
 ↓
WAITING
 ↓
SUCCESS

如果出现:

RUNNING
 ↓
TIMEOUT

则形成:

BehaviorDetection = ABNORMAL

如果:

RUNNING
 ↓
SUCCESS

则:

BehaviorDetection = NORMAL

4.3 行为与预期检测

核心:

Expected Behavior Result
          ↓
        Compare
          ↑
Actual Behavior Result

例如:

Action:
POWER_ON

Expected:
Device.state = ON

Actual:
Device.state = OFF

结果:

Detection
{
    target: "Device_A",
    expected: "ON",
    actual: "OFF",
    state: "ABNORMAL"
}

Detection 不直接决定如何修复。


5. 设备检测

设备检测主要用于 SAI 与外部设备交互环境。

前面已经建立:

Device Object
DeviceAdapter
DeviceCommand
DeviceResponse

现在:

Device
 ↓
DeviceAdapter
 ↓
Detection

设备检测可以包括:

Identity
Connection
State
Property
Method
Ability
Command
Response

5.1 身份检测

检查:

Device ID
Model
Serial
Manufacturer
Protocol
Address

例如:

Device_A
id = Motor_A
model = M100
protocol = Modbus

如果实际连接到的设备身份不同:

Expected Device = Motor_A
Actual Device = Motor_B

则:

IDENTITY_CONFLICT

5.2 连接检测

Device
 ↓
Connection Check
 ↓
CONNECTED / DISCONNECTED

例如:

Motor_A
Connection = DISCONNECTED

结果:

UNAVAILABLE

此时不能直接得出:

Motor_A = hardware failure

因为可能只是:

Network Error
Adapter Error
Power Off
Protocol Error

这些属于后续 Diagnosis 的范围。


5.3 属性检测

例如设备对象:

Motor_A
{
    speed: 50,
    temperature: 65,
    voltage: 220
}

检测规则:

temperature <= 80
speed <= 100
voltage = 220

实际:

temperature = 95

则:

Property Detection
        ↓
temperature abnormal

形成:

Detection
{
    target: "Motor_A",
    check_type: "PROPERTY",
    property: "temperature",
    expected: "<= 80",
    actual: 95,
    state: "ABNORMAL"
}

6. 异常检测

异常检测是 Detection 的重要应用。

异常的核心不是:

“不符合我的感觉”

而是:

Actual
  ↓
Compare
  ↓
Expected / Rule / State / Range / History
  ↓
Difference
  ↓
Abnormal Detection

6.1 异常来源

异常可以来自:

状态异常

Expected = READY
Actual = ERROR

属性异常

temperature > allowed_max

行为异常

Expected Result ≠ Actual Result

时间异常

Expected Duration = 10s
Actual Duration = 45s

关系异常

Expected:
Device_A → connected_to → Controller_A

Actual:
No relation

模块异常

Module state = ERROR

数据异常

Required property missing

6.2 异常不是故障

这一点非常重要:

Abnormal ≠ Failure

例如:

温度从 25℃ → 35℃

可能是异常状态,但并不一定意味着设备已经损坏。

因此 Detection 的职责是:

发现异常

而不是:

直接宣布故障原因

后续应该:

Detection
 ↓
Risk
 ↓
Diagnosis

6.3 异常检测示例

规则:

IF
Motor.temperature > 80

THEN
Detection = ABNORMAL

当前:

Motor.temperature = 92

得到:

DetectionResult
{
    target: "Motor_A",
    type: "PROPERTY",
    expected: "<= 80",
    actual: 92,
    state: "ABNORMAL"
}

随后:

DetectionResult
       ↓
Risk Analysis
       ↓
Diagnosis

7. Detection Result

Detection 最终必须形成结构化的 Detection Result

不能只返回:

正常

或者:

有问题

而应该记录:

检测对象
检测类型
预期状态
实际状态
差异
检测状态
来源
时间

7.1 DetectionResult 结构

DetectionResult
{
    id
    detection_id
    target
    target_type
    check_type

    expected
    actual
    difference

    state
    severity

    source
    message

    started_at
    completed_at
}

例如:

DetectionResult
{
    id: "DR001",
    detection_id: "D001",

    target: "Motor_A",
    target_type: "DEVICE",
    check_type: "PROPERTY",

    expected: "<= 80",
    actual: 92,
    difference: 12,

    state: "ABNORMAL",
    severity: "HIGH",

    source: "DeviceAdapter",

    message: "temperature exceeds allowed range"
}

7.2 Detection Result 状态

建议使用:

NORMAL
ABNORMAL
UNKNOWN
UNAVAILABLE
CONFLICT
ERROR

其中:

NORMAL

表示检测通过。

ABNORMAL

表示检测发现实际状态与预期存在异常差异。

UNKNOWN

表示信息不足。

UNAVAILABLE

表示目标暂时无法检测。

CONFLICT

表示多个检测结果互相冲突。

ERROR

表示检测过程本身发生错误。


Detection 完整运行模型

Detection Target
       ↓
Select Check
       ↓
Read Actual State
       ↓
Load Expected State
       ↓
Compare
       ↓
Judge
       ↓
DetectionResult

完整自我维护路径:

System
   ↓
Detection
   ↓
DetectionResult
   ↓
Risk
   ↓
Diagnosis
   ↓
Decision
   ↓
Repair
   ↓
Verification
   ↓
Detection

因此 Detection 是一个可以循环运行的机制:

Detection
   ↓
Repair
   ↓
Verification
   ↓
Detection

Detection 与前面模块的关系

Perception
    ↓
获取外部信息

Cognition
    ↓
理解信息

Reasoning
    ↓
形成结论

Decision
    ↓
选择行动

Behavior
    ↓
组织执行

Action
    ↓
实际操作

Feedback
    ↓
返回结果

Detection
    ↓
检查是否符合预期

同时 Detection 也可以直接检查系统内部:

Module
Object
Memory
Rule
Behavior
Action
Device
Connection
Data

本章核心模型

                 Detection
                     │
        ┌────────────┼────────────┐
        ↓            ↓            ↓
     State        Module       Behavior
        ↓            ↓            ↓
     Device       Data         Action
        └────────────┼────────────┘
                     ↓
              Abnormal Check
                     ↓
              DetectionResult
                     ↓
          ┌──────────┼──────────┐
          ↓          ↓          ↓
         Risk     Diagnosis   Memory

自我维护闭环:

Detection
   ↓
Detection Result
   ↓
Risk
   ↓
Diagnosis
   ↓
Decision
   ↓
Repair
   ↓
Verification
   ↓
Detection

本章核心定义

Detection 是 SAI/ICAI 对系统模块、对象状态、行为执行、设备状态、数据及运行条件进行检查,并通过预期状态、规则、范围、关系或历史状态与实际状态进行比较,从而发现正常、异常、未知、不可用、冲突或检测错误的机制。

核心关系:

Expected + Actual + Comparison
              ↓
          Detection
              ↓
       Detection Result

最重要的边界:

Detection  = 发现有没有问题
Risk       = 判断可能造成什么风险
Diagnosis  = 判断问题是什么
Decision   = 决定怎么办
Repair     = 执行修复
Verification = 验证修复是否有效

这样第72章 Detection 就可以自然连接下一阶段:

Detection
   ↓
Risk
   ↓
Diagnosis
   ↓
Repair
   ↓
Verification

也就与前面已经建立的 第247章 ICAI自我维护 MVC:Detection → Risk → Conflict → Diagnosis → Repair → Verification 形成一致的自我维护主线。

Leave a Reply

Your email address will not be published. Required fields are marked *