Material Detection
Introduction
MaterialDetectionActivity is a MES-specific material detection node used to verify the validity of material barcodes during the production process. This node supports material barcode rule detection, material state detection, material missing process detection, and can automatically write the material barcode to a specified variable.
Configuration Items
Configuration Properties
| Property Name | Display Name | Type | Default Value | Description |
|---|---|---|---|---|
| WriteBrcodeVariable | Write Material Parameter | bool | true | Whether to write material barcode to configured variable |
| WriteRetryCount | Write Retry Count | int | 3 | Write retry count |
| WriteRetryDelay | Write Retry Delay | int | 500 | Write retry delay (ms) |
Process Configuration
| Configuration Item | Description |
|---|---|
| MaterialDetection2 | Material Detection Function Switch |
| MaterielStateDetection | Material State Detection Trigger Timing |
| MaterielMissingProcessDetection | Material Missing Process Detection Trigger Timing |
| MaterialParameters | Material Parameter Configuration List |
Input Variables
| Variable Name | Constant | Type | Description |
|---|---|---|---|
| MaterialDetection_MaterialVariable | FlowItemCollection.MaterialDetectionMaterialVariableKey | string | Material Barcode to Detect |
Output Variables
| Variable Name | Constant | Type | Description |
|---|---|---|---|
| MaterialDetection_Result | FlowItemCollection.MaterialDetectionResultKey | int | Result: 0=Not Executed, 1=Success, 2=Failure, 3=Disabled |
| MaterialDetection_Description | FlowItemCollection.MaterialDetectionDescriptionKey | string | Result Description |
| MaterialDetection_MaterialDetailId | FlowItemCollection.MaterialDetectionMaterialDetailIdKey | string | Material Detail ID |
| MaterialDetection_MaterialName | FlowItemCollection.MaterialDetectionMaterialNameKey | string | Material Name |
| MaterialDetection_MaterialParameter | FlowItemCollection.MaterialDetectionMaterialParameterKey | string | Material Parameter Key |
| MaterialDetection_ProductModel | FlowItemCollection.MaterialDetectionProductModelKey | AssociationProductModel | Product Model |
Business Logic
Execution Flow
┌─────────────────────────────────────────────────────────────┐
│ MaterialDetectionActivity │
├─────────────────────────────────────────────────────────────┤
│ EnterAsync - Initialization Phase │
│ ├─ Set Detection Result = 0 │
│ └─ Clear descriptions and material info │
├───────────────────────────────────────────────────── ────────┤
│ ProcessAsync - Processing Phase │
│ ├─ Check if function is enabled │
│ │ └─ Not Enabled → Result=3, return disabled desc │
│ ├─ Verify Material Barcode │
│ │ └─ Empty → Result=2, return error │
│ ├─ Get Product Model │
│ │ └─ Not Found → Result=2, return error │
│ ├─ Material Barcode Rule Detection │
│ │ └─ Traverse MaterialParameters for verification │
│ ├─ Material State Detection (If Enabled) │
│ ├─ Material Missing Process Detection (If Enabled) │
│ ├─ Write Material Variable (If Configured) │
│ └─ Set Detection Result │
└─────────────────────────────────────────────────────────────┘
Material Detection Flow
-
Barcode Rule Detection
- Traverse material parameters in process configuration.
- Call
IMaterialProvider.VerificationAsyncto verify barcode. - Record material info if matched.
-
Material State Detection (Optional)
- Executed when
MaterielStateDetection = OnMaterialVerification. - Detects material state in current process.
- Executed when
-
Material Missing Process Detection (Optional)
- Executed when
MaterielMissingProcessDetection = OnMaterialVerification. - Detects if material has completed prerequisite processes.
- Executed when
Usage Example
Basic Flow Configuration
┌──────────────────┐ ┌──────────────────┐ ┌──────────────────┐
│ Scan Material Code│────▶│MaterialDetection │────▶│ Subsequent Node │
│ │ │ Mat. Detection │ │ │
└──────────────────┘ └──────────────────┘ └──────────────────┘
Set Material Barcode
{
"Activities": [
{
"Name": "Read Material Barcode",
"Type": "VariableReadActivity",
"VariableName": "MaterialDetection_MaterialVariable"
},
{
"Name": "Material Detection",
"Type": "MaterialDetectionActivity",
"WriteBrcodeVariable": true,
"WriteRetryCount": 3,
"WriteRetryDelay": 500
}
]
}
Error Handling
| Error Scenario | Result Value | Error Message |
|---|---|---|
| Function Not Enabled | 3 | Material Detection Disabled |
| Material Barcode Empty | 2 | Material Barcode: {code} is empty |
| Product Model Not Found | 2 | Product Model Not Found |
| Rule Mismatch | 2 | Specific verification error info |
| State Detection Failed | 2 | Specific detection error info |
| Missing Process Failed | 2 | Specific detection error info |
Notes
- Function Enable: Needs to enable material detection function in process configuration.
- Material Param Config: Needs to configure material parameter list in process.
- Product Model Required: Material detection requires product model information.
- Variable Write: Automatically writes material barcode when
WriteBrcodeVariableis enabled. - Retry Mechanism: Variable write supports retry configuration.
- Detection Order: Barcode rule detection first, then state and missing process detection.