# SPC Collection Model
## 1. Function Overview
The SPC Collection Model belongs to the basic module of the MES system. It is used to configure the result parameter collection points for process units, enabling real-time collection and monitoring of production process data. SPC (Statistical Process Control) is used to monitor the stability of production processes.
**Core Functions:**
- SCADA Point Binding: Configure the association relationship between process units and collection points
- Collection Parameter Management: Manage data collection parameters for collection points
**Function Screenshot**:

## 2. Term Explanation
| Term | Definition | Description |
|------|------------|-------------|
| SPC | Statistical Process Control | Used to monitor the stability of production processes |
| SCADA | Supervisory Control and Data Acquisition | Used for real-time data collection and monitoring |
| Data Type | Type of collected data | Including first inspection data, result data |
| Result Parameter | Result parameters of process units | Defines output data after process execution |
| First Inspection Data | First piece inspection data | Inspection data for the first product produced |
## 3. Data Model Relationship Description
### 3.1 SPC Collection Configuration Components
A complete SPC collection configuration consists of the following four elements:
```mermaid
flowchart LR
subgraph SPC Collection Configuration Elements
direction TB
A[Process Unit] --> B[SPC Collection Configuration]
C[Data Type] --> B
D[SCADA Point] --> B
end
B --> E[Save to Corresponding Data Table]
```
| Element | Description | Example |
|---------|-------------|---------|
| Process Unit | Which process to configure for | Cell assembly process |
| Data Type | Business type of the data | First Inspection Data / Result Data |
| SCADA Point | Source point of the data | TEMP_001 |
### 3.2 Data Type and Data Table Mapping
The data type determines which table the data is saved to:
```mermaid
flowchart TB
subgraph Data Type
DT1["First Inspection Data
(First Inspection)"]
DT2["Result Data
(Result Data)"]
end
subgraph Corresponding Data Table
T1["First Inspection Data Table
Saves first piece inspection data"]
T2["Result Parameter Table
Saves process result data"]
end
DT1 -->|"Data Type=First Inspection"| T1
DT2 -->|"Data Type=Result"| T2
```
### 3.3 Collection Entry Description
SCADA data collection has only one entry interface `set_node_data`, with 4 callers:
```mermaid
flowchart TB
subgraph SCADA Collection Entry
A[set_node_data Interface]
end
subgraph Callers
B[EdgeMange]
C[EPS]
D[MES Internal Call]
E[Device Call]
end
B --> A
C --> A
D --> A
E --> A
style D fill:#90EE90
```
| Caller | Description | Relationship with SPC Configuration |
|--------|-------------|-------------------------------------|
| EdgeMange | Edge manager push | Does not use SPC configuration |
| EPS | EPS system push | Does not use SPC configuration |
| MES Internal Call | MES internal business call | **Uses SPC configuration** |
| Device Call | Direct device call | Does not use SPC configuration |
**This function configures the collection rules for "MES Internal Call".**
### 3.4 MES Internal Call Collection Process
When MES internal business calls the `set_node_data` interface, the SPC collection configuration determines where the data is saved:
```mermaid
sequenceDiagram
participant MES业务 as MES Internal Business
participant SCADA as set_node_data Interface
participant SPC配置 as SPC Collection Configuration
participant DB as Database
MES业务->>SCADA: Call set_node_data
Parameters: Point Code, Collected Value
SCADA->>SPC配置: Query configuration by point code
SPC配置-->>SCADA: Return: Process Unit, Data Type, SCADA Point
SCADA->>DB: Save to corresponding data table based on data type
DB-->>SCADA: Save successful
SCADA-->>MES业务: Return result
```
### 3.5 Configuration Examples
| Configuration ID | Process Unit | Data Type | Data Table | SCADA Point |
|-----------------|--------------|-----------|------------|-------------|
| Config 1 | Cell Assembly Process | First Inspection Data | First Inspection Data Table | TEMP_001 |
| Config 2 | Cell Assembly Process | Result Data | Result Parameter Table | PRESS_001 |
| Config 3 | Formation Process | Result Data | Result Parameter Table | VOLT_001 |
## 4. SPC Collection Model Interaction Flow
### 4.1 SCADA Point Binding
#### 4.1.1 Point Binding Description
Point binding establishes the association between process units and SCADA collection points, enabling automatic collection of production data.
**Function Screenshot**:

#### 4.1.2 Add Point Binding
**Operation Steps:**
1. Go to [Production Configuration] → [SPC Collection Model] → [SCADA Point Binding]
2. Click [Add] button
3. Select the process unit to bind
4. Select or configure SCADA collection points
5. Set collection parameters
6. Click [Save] to complete point binding
**Field Description:**
| Field | Description | Required |
|-------|-------------|----------|
| Process Unit | Process unit to bind the point | Yes |
| Point Code | Point code in SCADA system | Yes |
| Point Name | Descriptive name of the point | Yes |
| Data Type | Data type of the point, e.g., "Numeric", "Switch" | Yes |
| Collection Frequency | Data collection frequency in seconds | Yes |
| Status | Enabled/Disabled | No |
| Remarks | Other supplementary information | No |
**[Important]** The point code must match the configuration in the SCADA system, otherwise data collection will fail.
**[Important]** The same point code cannot be bound to the same process unit repeatedly.
**Function Screenshot**:

#### 4.1.3 Edit Point Binding
**Operation Steps:**
1. Go to [Production Configuration] → [SPC Collection Model] → [SCADA Point Binding]
2. Find the binding record to edit in the list
3. Click [Edit] button
4. Modify the information to update
5. Click [Save] to complete modification
**[Note]** Historical collected data is not affected.
#### 4.1.4 Delete Point Binding
**Operation Steps:**
1. Go to [Production Configuration] → [SPC Collection Model] → [SCADA Point Binding]
2. Find the binding record to delete in the list
3. Click [Delete] button
4. Confirm the delete operation
**[Note]** After deleting the point binding, subsequent data collection for this point will stop, but collected data will be retained.
#### 4.1.5 Point Binding Query
**Query Conditions:**
| Query Condition | Description |
|----------------|-------------|
| Process Unit | Filter by process unit |
| Point Code | Exact query by point code |
| Point Name | Fuzzy query by point name |
| Status | Filter by enabled/disabled status |
| Creation Time | Filter by creation time range |