Files
ProductionCycleCheck/INSTALL.md
Misaka_Company 31a12fc9f5 Add BLDI pressure gauge classification tool
Implement VBA-based Excel tool for automatic classification of
pressure gauge model codes into 9 product categories.

Features:
- GaugeClassifier class with parsing and classification logic
- MainModule for Excel I/O with bulk array operations
- TestModule with comprehensive test suite (12 test cases)
- Complete documentation (README, INSTALL, algorithm guide)

Categories: 喷涂产品, 卫生型隔膜表, 隔膜表, 差压表,
膜盒压力表, 精密压力表, 电接点压力表, 常规表, 其他

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-11 16:51:22 +08:00

225 lines
6.6 KiB
Markdown

# Installation Guide - BLDI Pressure Gauge Classification Tool
## Quick Installation (5 Steps)
### Step 1: Prepare Excel File
1. Create a new Excel workbook or open existing one
2. Save as **Excel Macro-Enabled Workbook (.xlsm)**
- File → Save As
- Select "Excel Macro-Enabled Workbook (*.xlsm)"
### Step 2: Open VBA Editor
- Press `Alt + F11` (or Developer → Visual Basic)
### Step 3: Import GaugeClassifier Class
1. In VBA Editor: **File → Import File...**
2. Navigate to: `VBA/ClassModules/GaugeClassifier.cls`
3. Click **Open**
4. Verify in Project Explorer (Ctrl+R) under "Class Modules"
### Step 4: Import MainModule
1. **File → Import File...**
2. Navigate to: `VBA/Modules/MainModule.bas`
3. Click **Open**
4. Verify under "Modules"
### Step 5: Import TestModule
1. **File → Import File...**
2. Navigate to: `VBA/Modules/TestModule.bas`
3. Click **Open**
4. Verify under "Modules"
### Step 6: Verify Installation
1. Press `Alt + F8` to open Macro dialog
2. You should see:
- `RunClassification`
- `RunClassificationOnSelection`
- `ClearClassifications`
- `TestClassifierLogic`
- `TestParsingMethods`
- `TestPerformance`
- `TestSingleInput`
## Project Structure After Import
```
VBAProject (YourWorkbookName)
├── Class Objects
│ └── GaugeClassifier
├── Modules
│ ├── MainModule
│ └── TestModule
└── Sheets (your worksheets)
```
## Running Tests
### 1. Basic Classification Test
1. Open Immediate Window: `Ctrl + G`
2. Run: Press `F5` in TestModule or use `Alt + F8``TestClassifierLogic`
3. Check Immediate Window for results
Expected output:
```
========================================
GaugeClassifier Test Results
========================================
[✓ PASS] Test 1: 喷涂产品
[✓ PASS] Test 2: 卫生型隔膜表
[✓ PASS] Test 3: 喷涂产品
...
========================================
Summary:
Total: 12
Passed: 12
Failed: 0
========================================
```
### 2. Performance Test
1. Run `TestPerformance` from Macro dialog
2. Should process 1000 records in < 1 second
## First Use
### 1. Prepare Data
In your worksheet:
- **Column A**: Model codes (from A2 downward)
- **Column B**: Will contain classifications (auto-generated)
Example:
```
A B
┌────────────────────────────────────────────────────┐
1 │ 型号代码 │ 产品分类 │
├────────────────────────────────────────────────────┤
2 │ PYTH-100.A0.531.M201.M02|BP-088.2312...|FBP-...│
3 │ Y-040.Z0.200.M104.M07|BP-037.1007.M07.0A2 │
4 │ YX-100.A0.200.M204.M16.H4|BP-098.0088... │
└────────────────────────────────────────────────────┘
```
### 2. Run Classification
1. Click anywhere in your data sheet
2. Press `Alt + F8`
3. Select `RunClassification`
4. Click **Run**
### 3. View Results
Classifications appear in column B automatically.
## Alternative Installation: Manual Copy
If import doesn't work, create modules manually:
### Create GaugeClassifier.cls
1. In VBA Editor: **Insert → Class Module**
2. Name it: `GaugeClassifier` (in Properties window, F4)
3. Paste contents from `VBA/ClassModules/GaugeClassifier.cls`
### Create MainModule.bas
1. **Insert → Module**
2. Name it: `MainModule`
3. Paste contents from `VBA/Modules/MainModule.bas`
### Create TestModule.bas
1. **Insert → Module**
2. Name it: `TestModule`
3. Paste contents from `VBA/Modules/TestModule.bas`
## Troubleshooting
### Import Errors
**Error: "File not found"**
- Verify file paths are correct
- Use full path if needed: `C:\Users\Administrator\Desktop\生产周期核对\VBA\...`
**Error: "Invalid file format"**
- Ensure you're importing `.cls` and `.bas` files, not source code files
- Check files aren't open in another program
### Runtime Errors
**Error: "Compile error: User-defined type not defined"**
- Make sure `GaugeClassifier` is imported as a **Class Module**, not standard module
- Delete and re-import as Class Module
**Error: "Runtime error 1004"**
- Check macro security settings:
- File → Options → Trust Center → Trust Center Settings
- Macro Settings → Enable all macros (or add to Trusted Locations)
**Error: "Object variable not set"**
- Ensure you're running from a worksheet, not VBA Editor
- Check that `GaugeClassifier` class module exists
### Missing Macros in Dialog
If macros don't appear in `Alt + F8`:
1. Check they're in standard modules (not class modules)
2. Ensure module names are correct: `MainModule`, `TestModule`
3. Try closing and reopening workbook
4. Check Excel Trust Center settings
## Security Settings
### Enable Macros (One-time)
1. **File → Options → Trust Center → Trust Center Settings**
2. **Macro Settings**
3. Select: **Enable all macros** (use with caution)
OR **Disable all macros with notification** (recommended)
4. If using notification: Click "Enable Content" when opening workbook
### Add to Trusted Location (Recommended)
1. **File → Options → Trust Center → Trust Center Settings**
2. **Trusted Locations**
3. Click "Add new location"
4. Browse to: `C:\Users\Administrator\Desktop\生产周期核对\`
5. Check "Subfolders of this location are also trusted"
6. Click **OK**
## Configuration
### Change Input/Output Columns
Edit `MainModule.bas`:
```vba
' Current: Read from A, write to B
Set dataRange = ws.Range("A2:A" & lastRow) ' Change input column
ws.Range("B2:B" & (lastRow)).Value = outputData ' Change output column
```
### Add Custom Categories
Edit `GaugeClassifier.cls` in the `Classify` function.
## Uninstallation
1. Open VBA Editor (`Alt + F11`)
2. In Project Explorer:
- Right-click `GaugeClassifier` → Remove File
- Right-click `MainModule` → Remove File
- Right-click `TestModule` → Remove File
3. Save workbook
## Verification Checklist
- [ ] Workbook saved as `.xlsm`
- [ ] All three modules imported successfully
- [ ] `GaugeClassifier` is a Class Module
- [ ] `MainModule` and `TestModule` are standard Modules
- [ ] Macros visible in `Alt + F8` dialog
- [ ] `TestClassifierLogic` runs successfully with all tests passing
- [ ] Can classify sample data in worksheet
## Support
If issues persist:
1. Check Excel version (requires Excel 2007 or later)
2. Verify Windows security permissions
3. Try on a new blank workbook
4. Consult README.md for additional documentation