372e4dacb542dcea230cd782dd645c67ac4cb2b8
Exclude .claude directory from version control. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
BLDI Pressure Gauge Model Classification Tool
A VBA-based Excel tool for classifying pressure gauge model codes into product categories.
Features
- Automatic Classification: Classifies model codes into 9 product categories
- High Performance: Uses bulk array operations for fast processing (1000+ records in seconds)
- Priority-Based Logic: Implements a decision funnel classification system
- Comprehensive Testing: Includes full test suite with PRD validation
Categories (Priority Order)
- 喷涂产品 (Spray-coated) - Highest priority
- 卫生型隔膜表 (Sanitary diaphragm)
- 隔膜表 (Diaphragm)
- 差压表 (Differential pressure)
- 膜盒压力表 (Capsule)
- 精密压力表 (Precision)
- 电接点压力表 (Electric contact)
- 常规表 (Regular)
- 其他 (Other) - Default
File Structure
VBA/
├── ClassModules/
│ └── GaugeClassifier.cls # Core classification logic
└── Modules/
├── MainModule.bas # Excel I/O interface
└── TestModule.bas # Test suite
Installation
Method 1: Import VBA Files (Recommended)
- Open your Excel workbook
- Press
Alt + F11to open VBA Editor - In the VBA Editor:
- Go to File → Import File
- Import
VBA/ClassModules/GaugeClassifier.cls - Import
VBA/Modules/MainModule.bas - Import
VBA/Modules/TestModule.bas
- Save your workbook as Excel Macro-Enabled Workbook (.xlsm)
Method 2: Copy Code Manually
- Open VBA Editor (
Alt + F11) - Insert Class Module: Insert → Class Module, name it
GaugeClassifier - Copy contents of
GaugeClassifier.clsto the class module - Insert Standard Module: Insert → Module
- Copy contents of
MainModule.basto the module - Insert another Standard Module for tests
- Copy contents of
TestModule.basto the test module
Usage
Quick Start
-
Enter model codes in column A (starting from A2)
A B ┌────────────────────────────────────┐ 1 │ 型号代码 │ 产品分类 │ ├────────────────────────────────────┤ 2 │ PYTH-100.A0...│ │ 3 │ Y-040.Z0.200..│ │ └────────────────────────────────────┘ -
Run classification:
- Press
Alt + F8 - Select
RunClassification - Click Run
- Press
-
View results in column B
Alternative Methods
Selection-based Classification
- Select cells containing model codes
- Run
RunClassificationOnSelection - Results appear in adjacent column
Clear Results
- Run
ClearClassificationsto remove classifications
Testing
Run All Tests
- Press
Alt + F11to open VBA Editor - Press
Ctrl + Gto open Immediate Window - Run
TestClassifierLogic - View results in Immediate Window
Individual Test Functions
| Function | Description |
|---|---|
TestClassifierLogic() |
Run all PRD test cases (12 tests) |
TestParsingMethods() |
Test string parsing methods |
TestPerformance() |
Performance benchmark (1000 records) |
TestSingleInput() |
Interactive single input test |
Test Cases
All test cases from the PRD are validated:
| # | Input | Expected |
|---|---|---|
| 1 | PYTH-100.A0.531.M201.M02|BP-088.2312.M02.0A3|FBP-251040... |
喷涂产品 |
| 2 | PYTH-063.A0.513.M05.U38.F6A.K15.1.1|BP-058.1509.M05.BB2.F6 |
卫生型隔膜表 |
| 3 | PYTH-063.A0.513.M05.U38.F6BP.K15.1.1|BP-058.1509.M05.BB2.F6 |
喷涂产品 |
| 4 | PYTH-063.A0.513.M201.M09|BP-058.1509.M09.0A2|FC-1520... |
隔膜表 |
| 5 | PYXHN-100.A0.531.M201.M09.H4|BP-088.2518.M09.0A3.YXH|F5... |
隔膜表 |
| 6 | YCSH-100.A0.531.M201.M07|BP-088.2312.M07.0A3.YCS |
差压表 |
| 7 | YE-070.A0.204.G144.K21|BP-058.1509.K21.0A2 |
膜盒压力表 |
| 8 | YB-120.A0.407.Z144.M23|BP-110.5250.P60.0A5 |
精密压力表 |
| 9 | YX-100.A0.200.M204.M16.H4|BP-098.0088.M16.0A3.YX |
电接点压力表 |
| 10 | Y-040.Z0.200.M104.M07|BP-037.1007.M07.0A2 |
常规表 |
| 11 | Y-100.BT.200.M204.M12|BP-098.0088.B17.PA3 |
常规表 |
| 12 | `` (empty) | 其他 |
Classification Logic
String Structure
Model code format: [表头]|[表盘]|[附件]|[法兰隔膜]
Parsing Rules
| Component | Description | Example |
|---|---|---|
| Head | Everything before first | |
PYTH-100.A0.531.M201.M06 |
| Main Model | First word before - in head |
PYTH |
| Flange | Last section if starts with F |
FBP-251040.RF1.049.13... |
Classification Rules
-
Spray-coated (喷涂产品)
- Flange ends with
POR head containsF6AP/F6BP
- Flange ends with
-
Sanitary Diaphragm (卫生型隔膜表)
- Head contains
F6AorF6B(excluding spray variants)
- Head contains
-
Diaphragm (隔膜表)
- Main model starts with
P
- Main model starts with
-
Differential Pressure (差压表)
- Main model starts with
YC
- Main model starts with
-
Capsule (膜盒压力表)
- Main model starts with
YE
- Main model starts with
-
Precision (精密压力表)
- Main model starts with
YB
- Main model starts with
-
Electric Contact (电接点压力表)
- Main model starts with
YX
- Main model starts with
-
Regular (常规表)
- Main model starts with
Y
- Main model starts with
-
Other (其他)
- Everything else (including empty strings)
Performance
Typical performance on standard hardware:
- 100 records: ~0.01 seconds
- 1,000 records: ~0.05 seconds
- 10,000 records: ~0.5 seconds
Uses bulk array operations (Value2) for optimal performance.
Troubleshooting
"No data found" error
- Ensure data starts from cell A2
- Check that column A contains model codes
Runtime error 1004
- Make sure workbook is saved as
.xlsm(macro-enabled) - Check macro security settings: File → Options → Trust Center → Trust Center Settings → Macro Settings
Incorrect classifications
- Verify model code format matches expected structure
- Check for extra spaces or special characters
- Run
TestClassifierLogic()to validate classifier logic
API Reference
GaugeClassifier Class
| Method | Description |
|---|---|
Classify(modelString) As String |
Main classification entry point |
GetHead(fullString) As String |
Extract head section |
GetFlange(fullString) As String |
Extract flange section |
GetMainModel(headString) As String |
Extract main model prefix |
MainModule Functions
| Sub | Description |
|---|---|
RunClassification() |
Process all data in column A |
RunClassificationOnSelection() |
Process selected cells |
ClearClassifications() |
Clear results in column B |
License
Internal tool for BLDI pressure gauge classification.
Support
For issues or questions, refer to the PRD or contact development team.
Description
Languages
VBA
79.6%
Visual Basic 6.0
20.4%