Files
powershell-scripts/docs/TECHNICAL_ARCHITECTURE.md
cproudlock 96cb1dd946 Remove all emojis from markdown documentation
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-10 11:03:45 -05:00

327 lines
12 KiB
Markdown

# Technical Architecture Documentation
## System Overview
The GE Manufacturing Asset Management System is a comprehensive PowerShell-based solution designed for automated data collection and centralized asset management in manufacturing environments. The system follows a hybrid architecture combining local data collection, remote API integration, and intelligent manufacturing-specific analysis.
## Architecture Components
```
┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐
│ Manufacturing │ │ Data Collection│ │ Centralized │
│ PC (Client) │───▶│ & Processing │───▶│ Database │
│ │ │ (PowerShell) │ │ (MySQL) │
└─────────────────┘ └──────────────────┘ └─────────────────┘
│ │ ▲
│ │ │
▼ ▼ │
┌─────────────────┐ ┌──────────────────┐ │
│ Windows │ │ Manufacturing │ │
│ Registry │ │ Intelligence │ │
│ (GE Settings) │ │ Engine │ │
└─────────────────┘ └──────────────────┘ │
│ │
▼ │
┌──────────────────┐ │
│ Dashboard API │─────────────┘
│ Integration │
└──────────────────┘
```
## Core Components
### 1. Data Collection Engine (`Update-PC-CompleteAsset.ps1`)
**Primary Responsibilities:**
- Orchestrates the entire data collection process
- Coordinates with multiple data sources and APIs
- Handles error recovery and graceful degradation
- Provides real-time feedback and logging
**Key Functions:**
#### `Collect-SystemInfo`
```powershell
# Comprehensive system information gathering
- Hardware identification (manufacturer, model, serial)
- Operating system details and user context
- Memory, domain role, and timezone information
- PC type classification logic
- GE machine number extraction
```
#### `Collect-ShopfloorInfo`
```powershell
# Manufacturing-specific data collection
- Network interface enumeration and analysis
- Serial communication port configurations
- DNC (Direct Numerical Control) settings extraction
- GE Aircraft Engines registry architecture analysis
```
#### `Send-CompleteDataToDashboard`
```powershell
# Centralized data transmission
- Structured API payload construction
- HTTP POST transmission with error handling
- Response validation and feedback processing
```
### 2. Manufacturing Intelligence Engine (`Get-ShopfloorConfig.ps1`)
**Primary Responsibilities:**
- Deep manufacturing environment analysis
- Registry-based configuration extraction
- Network topology identification
- Communication protocol detection
**Key Functions:**
#### `Get-NetworkInterfaceConfig`
```powershell
# Advanced network analysis
- Multi-interface enumeration with active status
- Machine network detection (192.168.*.* identification)
- DHCP vs static configuration analysis
- Gateway and subnet mapping
```
#### `Get-GERegistryInfo` **New in v3.0**
```powershell
# Dual registry architecture analysis
- 32-bit registry path: HKLM:\SOFTWARE\GE Aircraft Engines
- 64-bit registry path: HKLM:\SOFTWARE\WOW6432Node\GE Aircraft Engines
- Smart conflict resolution with priority system
- DualPath communication configuration extraction
- Per-service architecture tracking
```
#### `Get-DNCConfig`
```powershell
# Direct Numerical Control configuration
- GE Aircraft Engines DNC settings extraction
- Multiple registry path analysis
- Communication parameter identification
- Machine integration settings
```
## Data Flow Architecture
### Phase 1: System Discovery
```
PC Environment System Info Collection Classification Engine
├─ Hardware Identification (WMI/CIM)
├─ Operating System Analysis
├─ User Context Determination
└─ Environment Classification (Engineer/Shopfloor/Standard)
```
### Phase 2: Manufacturing Intelligence
```
Registry Analysis Manufacturing Config Service Architecture
├─ GE Aircraft Engines Detection (32-bit/64-bit)
├─ DualPath Configuration Analysis
├─ DNC Service Enumeration
└─ Communication Protocol Mapping
```
### Phase 3: Network Topology
```
Network Interfaces Machine Network Detection Communication Analysis
├─ Active Interface Enumeration
├─ Machine Network Identification (192.168.*.*)
├─ DHCP/Static Configuration Analysis
└─ Serial Port Communication Mapping
```
### Phase 4: Data Consolidation
```
Collected Data JSON Serialization API Payload Construction
├─ System Information Packaging
├─ Manufacturing Configuration JSON
├─ Network Interface Data Arrays
└─ Registry Architecture Metadata
```
### Phase 5: Centralized Storage
```
Dashboard API Database Normalization Relational Storage
├─ PC Table (Basic System Information)
├─ PC_DNC_Config Table (Manufacturing Settings + Registry Architecture)
├─ Network Interfaces (Detailed Network Configuration)
├─ Communication Configs (Serial/Protocol Settings)
└─ Machines Table (Auto-populated from PC machine numbers)
```
### Phase 6: Machine Auto-Population **New in v3.2**
```
PC Data Collection Machine Number Extraction Automated Machine Creation
│ │ │
├─ Registry Scan ├─ Hostname Patterns ├─ Machine Records
├─ DNC Detection ├─ GE Machine Numbers ├─ PC Relationships
└─ Network Analysis └─ Role Classification └─ IP Assignment
```
## Advanced Features
### PC Type Classification Algorithm
```powershell
function Get-PCType {
if (Test-AppsFolder -and Test-VDriveAccess) {
return "Engineer" # Development/Engineering workstations
}
elseif (Test-WindowsLTSC) {
return "Shopfloor" # Manufacturing floor systems
}
else {
return "Standard" # General corporate systems
}
}
```
### GE Machine Number Extraction
```powershell
function Get-GEMachineNumber {
# Pattern matching for GE hostname conventions
if ($Hostname -match '[HG](\d{3})') {
$machineNum = $Matches[1]
return "M$machineNum" # Convert H123/G123 M123
}
}
```
### Machine Auto-Population Architecture **New in v3.2**
The system automatically creates machine records from shopfloor PC data using a multi-phase approach:
#### Phase 1: Machine Number Extraction
```powershell
function Get-GEMachineNumber {
# Priority 1: Registry-based detection
$gePaths = @(
"HKLM:\Software\GE Aircraft Engines\DNC\General",
"HKLM:\Software\WOW6432Node\GE Aircraft Engines\DNC\General"
)
# Priority 2: Hostname pattern matching
if ($Hostname -match '[HG](\d{3})') {
return "M$($Matches[1])" # H3103 M3103
}
}
```
#### Phase 2: Machine Record Creation
```sql
-- Bulk creation for numeric machines
INSERT INTO machines (machinenumber, alias, machinenotes, ipaddress1)
SELECT DISTINCT
p.machinenumber,
CONCAT('Machine ', p.machinenumber),
CONCAT('Auto-discovered | Connected PCs: ',
GROUP_CONCAT(p.hostname), ' | Count: ', COUNT(*)),
(SELECT ni.ipaddress FROM pc_network_interfaces ni
WHERE ni.pcid = p.pcid ORDER BY p.lastupdated DESC LIMIT 1)
FROM pc p
WHERE p.machinenumber REGEXP '^[0-9]+$'
GROUP BY p.machinenumber;
```
#### Phase 3: PC-Machine Relationship Mapping
```sql
-- Junction table for many-to-many relationships
CREATE TABLE machine_pc_relationships (
machine_id INT,
pc_id INT,
pc_role ENUM('control', 'hmi', 'engineering', 'backup', 'unknown'),
is_primary BOOLEAN,
relationship_notes TEXT
);
-- Intelligent role detection
pc_role = CASE
WHEN hostname LIKE '%HMI%' THEN 'hmi'
WHEN hostname LIKE '%CONTROL%' THEN 'control'
WHEN hostname LIKE '%ENG%' THEN 'engineering'
ELSE 'unknown'
END
```
#### Phase 4: Production Results
- **121 Machines Created**: Complete shopfloor inventory
- **115 Numeric Machines**: Standard 4-digit machine numbers (0000-9999)
- **3 M-Prefix Machines**: Legacy naming (M439, M670, M886)
- **1 Special Equipment**: WJPRT (Waterjet Printer)
- **1 Test Machine**: TEST-001
- **Multiple PC Handling**: Machine 0615 has 5 connected PCs
- **Role Classification**: Control, HMI, Engineering, Backup PCs identified
### Dual Registry Architecture Handling **New in v3.0**
```powershell
# Intelligent priority system prevents data overwrites
if ($geInfo.DualPathEnabled -eq $null) {
$geInfo.DualPathEnabled = $efocasValues.DualPath -eq 'YES'
# First registry location sets the value
} else {
# Subsequent locations preserve existing values
Write-Host "DualPath already set from other registry location"
}
```
## Error Handling & Resilience
### Graceful Degradation Strategy
1. **Primary Data Sources**: Continue with secondary methods if WMI/CIM fails
2. **Network Discovery**: Fall back to alternative network enumeration
3. **Registry Access**: Handle permission issues with error logging
4. **API Communication**: Retry logic with exponential backoff
### Comprehensive Logging
```powershell
# Color-coded status reporting
Write-Host "[OK] Component successful" -ForegroundColor Green
Write-Host "[WARN] Non-critical issue" -ForegroundColor Yellow
Write-Host "[FAIL] Critical error" -ForegroundColor Red
```
## Performance Characteristics
### Execution Times (Typical)
- **Standard PC**: ~15-30 seconds (basic system info + network)
- **Shopfloor PC**: ~45-90 seconds (full manufacturing analysis)
- **Engineer PC**: ~20-40 seconds (enhanced system info)
### Resource Utilization
- **Memory**: ~50-100 MB during execution
- **CPU**: Low impact with burst activity during registry scans
- **Network**: Minimal bandwidth (~1-5 KB payload per PC)
### Scalability Metrics
- **Concurrent Executions**: Tested up to 50 simultaneous deployments
- **Error Rate**: <2% in production environments
- **Success Rate**: >98% data collection completion
## Security Considerations
### Required Permissions
- **Administrator Rights**: Required for complete WMI/registry access
- **Network Access**: Dashboard API communication
- **Registry Read**: GE Aircraft Engines configuration access
### Data Protection
- **No Credential Storage**: Scripts don't store or transmit passwords
- **Local Processing**: All analysis performed locally before transmission
- **Minimal Data**: Only relevant asset information transmitted
### Network Security
- **HTTP POST**: Structured API communication
- **Error Handling**: No sensitive information in error messages
- **Timeout Protection**: Prevents hanging network connections
---
**Architecture designed for enterprise manufacturing environments with emphasis on reliability, intelligence, and scalability.**