第21章 InformationSource
本章大纲
- 信息来源
- Human
- Device
- Sensor
- System
- Network
- Database
- API
- Environment
- Source 标识
- Source 管理
21.1 信息来源
**InformationSource(信息来源)**用于描述 Information 是从哪里产生、获取或接收到的。
在第19章中,Information 定义了:
Information
├── id
├── type
├── source
├── content
├── time
├── state
├── context
├── object
└── metadata
其中:
source
就是 InformationSource 的重要组成部分。
例如:
温度 = 32℃
单独看,只是一个数据。
如果加入来源:
Source = TemperatureSensor-01
那么 SAI 就知道:
这条信息是谁提供的?
因此:
Information
↓
InformationSource
↓
Source Identification
↓
Information Processing
InformationSource 本身不是 Information。
可以区分为:
Information
→ 具体接收到的信息
InformationSource
→ 信息从哪里来
21.2 Human
**Human(人)**是 SAI 最常见的信息来源之一。
例如:
“打开风扇”
“房间太热了”
“检查一下设备”
来源可以表示:
Source Type = human
Source ID = human-001
信息:
Content = “打开风扇”
形成:
Human
↓
Information
↓
Language / Instruction
Human Source 可以进一步描述:
Human
├── id
├── name
├── role
├── state
└── metadata
例如:
human-001
role = operator
这里的 Human 只是信息来源对象。
它不意味着 SAI 必须对人的身份进行复杂判断。
21.3 Device
**Device(设备)**可以直接产生 Information。
例如:
Fan
Robot
Vehicle
Display
Motor
Controller
设备可能提供:
Device
├── State
├── Property
├── Event
├── Error
└── Data
例如风扇:
Fan-001
state = ON
speed = 3
形成:
Device
↓
Information
↓
Device Information
设备作为 InformationSource 时,可以记录:
source.type = device
source.id = fan-001
这样 SAI 可以知道:
Fan-001
↓
产生了这条信息
21.4 Sensor
**Sensor(传感器)**是特殊的信息来源。
例如:
Temperature Sensor
Humidity Sensor
Distance Sensor
Position Sensor
Motion Sensor
Light Sensor
传感器通常产生实时数据:
Sensor
↓
Measurement
↓
Information
例如:
TemperatureSensor-01
temperature = 32
unit = C
形成:
Source
├── type = sensor
└── id = temperature-sensor-01
Information
├── type = data
├── content = 32
└── metadata.unit = C
传感器与普通 Device 可以存在层级关系:
Device
└── Sensor
所以:
Sensor 是 Device 的一种特殊信息来源
但在 SAI Framework 中单独定义 Sensor Source,可以让感知系统更加明确。
21.5 System
**System(系统)**可以作为 InformationSource。
例如:
Operating System
Business System
Control System
SAI Internal System
Monitoring System
系统可能产生:
System Event
System State
System Data
System Error
System Notification
例如:
Source = monitoring-system
Content = device-error
数据流:
System
↓
Information
↓
Event / State / Data
↓
Perception
在 SAI Framework 中,System Source 可以用于连接其他软件系统。
21.6 Network
**Network(网络)**本身通常不是信息内容,而是 Information 的传输来源或来源环境。
例如:
Network
├── TCP
├── HTTP
├── WebSocket
├── MQTT
└── Other Protocol
例如:
Network
↓
HTTP Request
↓
Information
或者:
Device
↓
Network
↓
SAI
↓
Information
需要注意:
Network ≠ Information
网络主要解决:
信息如何传输
而 Information 解决:
传输了什么
例如:
HTTP
↓
temperature=32
↓
Information
因此 Network 可以作为 Source 的辅助描述:
source.type = device
source.id = sensor-001
source.transport = network
source.protocol = http
21.7 Database
**Database(数据库)**可以作为 InformationSource。
例如:
Database
↓
Record
↓
Information
假设数据库保存:
temperature = 32
humidity = 70
SAI 读取以后:
Database
↓
Data
↓
Information
Source 可以表示:
source.type = database
source.id = environment-db
但是数据库只是信息来源。
数据库本身不负责:
感知
认知
推理
决策
它只提供数据。
因此:
Database
↓
InformationSource
↓
Information
↓
SAI Processing
这与第13章 Model 的关系也需要区分。
Database
→ 数据存储设施
Model
→ SAI 内部数据组织方式
InformationSource
→ 描述信息从哪里获取
21.8 API
**API(Application Programming Interface)**也是一种 InformationSource。
例如:
External API
↓
JSON
↓
Information
假设 API 返回:
{
"temperature": 32,
"humidity": 70
}
SAI 接收到后可以组织为:
Information
├── Source
│ ├── type = api
│ └── id = weather-api
│
├── Type
│ └── data
│
└── Content
├── temperature = 32
└── humidity = 70
API Source 可以记录:
source.type
source.id
source.endpoint
source.protocol
但需要特别注意:
API 是信息获取方式或外部接口,不是 SAI 的认知机制。
因此:
API
↓
获取信息
↓
Information
↓
SAI 内部处理
21.9 Environment
**Environment(环境)**是非常重要的信息来源。
对于机器人、车辆、无人设备和环境控制 Individual,外部环境持续产生大量信息。
例如:
Environment
├── Temperature
├── Humidity
├── Light
├── Objects
├── Motion
├── Distance
├── Position
├── Weather
└── Events
例如:
Environment
↓
Temperature = 32
↓
Information
或者:
Environment
↓
Person entered room
↓
Event Information
环境与 Sensor 的区别:
Environment
→ 信息实际存在的外部世界
Sensor
→ 获取环境信息的设备
例如:
真实环境
│
├── Temperature = 32
├── Person = PRESENT
└── Fan = OFF
│
▼
TemperatureSensor
│
▼
Information
因此:
Environment ≠ Sensor
Sensor 是获取环境信息的设备,而 Environment 是被感知的外部世界。
21.10 Source 标识
InformationSource 不能只有一个简单的名称。
为了让 SAI 能够区分不同来源,可以建立统一 Source 标识。
基本结构:
Source
├── id
├── type
├── name
├── state
└── metadata
例如:
Source
{
id: "temperature-sensor-01",
type: "sensor",
name: "Room Temperature Sensor",
state: "online"
}
21.10.1 Source ID
id 用于唯一标识来源。
例如:
human-001
fan-001
sensor-001
system-001
database-001
api-001
environment-001
推荐使用:
type + unique id
例如:
sensor-001
device-001
api-001
这样可以避免不同来源之间产生混淆。
21.10.2 Source Type
Source Type 表示来源类别:
human
device
sensor
system
network
database
api
environment
例如:
source.id = sensor-001
source.type = sensor
21.10.3 Source Name
Name 用于人类阅读:
id = sensor-001
name = Room Temperature Sensor
ID 用于系统识别:
sensor-001
Name 用于显示:
Room Temperature Sensor
因此:
ID ≠ Name
21.10.4 Source State
Source 自身也可能具有状态。
例如:
online
offline
disabled
error
unknown
例如:
Sensor
id = sensor-001
state = online
如果设备断开:
state = offline
这时候 SAI 可以进一步判断:
Information
是否还能继续使用?
21.11 Source 管理
当 SAI 中存在大量信息来源时,就需要 Source Manager。
基本结构:
InformationSourceManager
│
├── register()
├── remove()
├── get()
├── has()
├── update()
└── all()
例如:
<?php
namespace SAI\Information;
class InformationSource
{
protected $id;
protected $type;
protected $name;
protected $state;
public function __construct($id, $type, $name)
{
$this->id = $id;
$this->type = $type;
$this->name = $name;
$this->state = 'online';
}
public function getId()
{
return $this->id;
}
public function getType()
{
return $this->type;
}
public function getName()
{
return $this->name;
}
public function setState($state)
{
$this->state = $state;
}
public function getState()
{
return $this->state;
}
}
然后建立管理器:
<?php
namespace SAI\Information;
class InformationSourceManager
{
protected $sources = array();
public function register(InformationSource $source)
{
$this->sources[$source->getId()] = $source;
}
public function get($id)
{
if (!isset($this->sources[$id])) {
return null;
}
return $this->sources[$id];
}
public function has($id)
{
return isset($this->sources[$id]);
}
public function remove($id)
{
unset($this->sources[$id]);
}
public function all()
{
return $this->sources;
}
}
例如注册来源:
$manager = new InformationSourceManager();
$manager->register(
new InformationSource(
'sensor-001',
'sensor',
'Room Temperature Sensor'
)
);
$manager->register(
new InformationSource(
'fan-001',
'device',
'Room Fan'
)
);
$manager->register(
new InformationSource(
'human-001',
'human',
'Operator'
)
);
形成:
InformationSourceManager
│
├── sensor-001
│ └── Temperature Sensor
│
├── fan-001
│ └── Fan
│
└── human-001
└── Operator
Source 与 Information 的关系
这是本章最重要的关系。
InformationSource
│
│ produces / provides
▼
Information
│
▼
Perception
例如:
TemperatureSensor-01
│
│ produces
▼
Information-001
│
├── type = data
├── content = 32
└── time = 14:00
Information 中保存:
source = temperature-sensor-01
于是 SAI 可以追溯:
Information
↓
Source
↓
Sensor
反过来也可以查询:
Source
↓
产生了哪些 Information?
这对于:
日志
追踪
状态判断
故障诊断
信息验证
经验形成
都有意义。
多来源信息
现实中的一个对象可能同时拥有多个 InformationSource。
例如房间:
Room
│
├── TemperatureSensor
├── HumiditySensor
├── Camera
├── DoorSensor
└── Human
产生:
TemperatureSensor
↓
temperature = 32
HumiditySensor
↓
humidity = 70
DoorSensor
↓
door = OPEN
Human
↓
“打开风扇”
进入 SAI:
Information
│
┌──────────┼──────────┐
▼ ▼ ▼
Temperature Humidity Door
│ │ │
└──────────┼──────────┘
▼
Perception
│
Cognition
这样 Individual 才能形成更加完整的场景认识。
本章完整结构
InformationSource 可以形成如下体系:
InformationSource
│
├── Human
│
├── Device
│ └── Sensor
│
├── System
│
├── Network
│
├── Database
│
├── API
│
└── Environment
统一标识:
Source
├── ID
├── Type
├── Name
├── State
└── Metadata
统一管理:
InformationSourceManager
│
├── register
├── get
├── has
├── remove
├── update
└── all
完整信息流:
Human
Device
Sensor
System
Network
Database
API
Environment
│
▼
InformationSource
│
▼
Information
│
▼
Information Type
│
▼
Perception
│
▼
Element
│
▼
Object
│
▼
Cognition
本章小结
第21章建立了 SAI Framework 的 InformationSource 信息来源体系。
核心概念可以归纳为:
Information
→ 接收到什么
InformationSource
→ 信息从哪里来
InformationType
→ 这是什么类型的信息
主要信息来源:
Human
Device
Sensor
System
Network
Database
API
Environment
其中需要特别区分:
Environment
→ 信息实际存在的外部世界
Sensor
→ 获取信息的设备
Network
→ 信息传输方式
Database
→ 信息存储来源
API
→ 外部系统接口
System
→ 软件系统来源
最终形成:
Source
↓
Information
↓
Information Type
↓
Perception
↓
Element
↓
Object
↓
Relation
↓
Cognition
因此,InformationSource 的作用不是处理信息,而是建立信息与其来源之间的可识别、可追踪、可管理关系。
本章 PHP 类、Manager、数据结构和运行流程均为 SAI Framework 教程设计示例,未作为实际项目执行验证。