171 lines
4.6 KiB
Markdown
171 lines
4.6 KiB
Markdown
|
|
# Print Queue & History
|
||
|
|
|
||
|
|
## Summary
|
||
|
|
|
||
|
|
MatterControl maintains print job history for tracking completed prints, managing queued items, and enabling print recovery after failures. The system stores print metadata, tracks progress, and provides analytics on print success rates.
|
||
|
|
|
||
|
|
## Technical Description
|
||
|
|
|
||
|
|
### Architecture
|
||
|
|
|
||
|
|
```
|
||
|
|
Print Management
|
||
|
|
├── Print Queue (FileSystemContainer)
|
||
|
|
│ └── Queued items for printing
|
||
|
|
├── Print History (PlatingHistoryContainer)
|
||
|
|
│ └── Completed/cancelled prints
|
||
|
|
└── PrintTask (database records)
|
||
|
|
└── Print job metadata
|
||
|
|
```
|
||
|
|
|
||
|
|
### PrintTask Entity
|
||
|
|
|
||
|
|
Database model for print jobs:
|
||
|
|
|
||
|
|
```csharp
|
||
|
|
public class PrintTask : Entity
|
||
|
|
{
|
||
|
|
public string PrintName { get; set; }
|
||
|
|
public DateTime PrintStart { get; set; }
|
||
|
|
public DateTime PrintEnd { get; set; }
|
||
|
|
public int PrintTimeSeconds { get; set; }
|
||
|
|
public double PercentDone { get; set; }
|
||
|
|
public bool PrintComplete { get; set; }
|
||
|
|
public string PrinterName { get; set; }
|
||
|
|
public string RecoveryJson { get; set; }
|
||
|
|
public int QualityWasSetByUser { get; set; }
|
||
|
|
}
|
||
|
|
```
|
||
|
|
|
||
|
|
### Print Queue
|
||
|
|
|
||
|
|
Legacy queue system using file system container:
|
||
|
|
|
||
|
|
| Class | Purpose |
|
||
|
|
|-------|---------|
|
||
|
|
| `LegacyQueueFiles` | Queue directory management |
|
||
|
|
| `FileSystemContainer` | Queue item storage |
|
||
|
|
|
||
|
|
Queue directory: `{ApplicationData}/Queue/`
|
||
|
|
|
||
|
|
### History Container
|
||
|
|
|
||
|
|
`PlatingHistoryContainer` provides access to print history:
|
||
|
|
|
||
|
|
| Feature | Description |
|
||
|
|
|---------|-------------|
|
||
|
|
| `NewBedPlate()` | Create new print session |
|
||
|
|
| Content storage | Save print bed state |
|
||
|
|
| History browsing | Access past prints |
|
||
|
|
|
||
|
|
### Print Tracking Flow
|
||
|
|
|
||
|
|
1. **Print Start:**
|
||
|
|
- Create `PrintTask` record
|
||
|
|
- Set `PrintStart` timestamp
|
||
|
|
- Initialize progress to 0%
|
||
|
|
|
||
|
|
2. **During Print:**
|
||
|
|
- Update `PercentDone`
|
||
|
|
- Save recovery data (`RecoveryJson`)
|
||
|
|
|
||
|
|
3. **Print Complete:**
|
||
|
|
- Set `PrintEnd` timestamp
|
||
|
|
- Calculate `PrintTimeSeconds`
|
||
|
|
- Set `PrintComplete` flag
|
||
|
|
|
||
|
|
4. **On Cancel:**
|
||
|
|
- Record partial completion
|
||
|
|
- Preserve recovery data
|
||
|
|
|
||
|
|
### Print Recovery
|
||
|
|
|
||
|
|
Recovery enables resuming failed prints:
|
||
|
|
|
||
|
|
```csharp
|
||
|
|
// PrintRecoveryStream handles recovery
|
||
|
|
public class PrintRecoveryStream : GCodeStream
|
||
|
|
{
|
||
|
|
// Track position and extrusion
|
||
|
|
// Resume from last known good position
|
||
|
|
}
|
||
|
|
```
|
||
|
|
|
||
|
|
**Recovery Data:**
|
||
|
|
- Last printed layer
|
||
|
|
- Current position (X, Y, Z)
|
||
|
|
- Extruded amount
|
||
|
|
- Temperature states
|
||
|
|
|
||
|
|
### History Display
|
||
|
|
|
||
|
|
`RootHistoryContainer` shows print history:
|
||
|
|
|
||
|
|
```
|
||
|
|
History
|
||
|
|
├── Printing History (PrintTask records)
|
||
|
|
│ ├── Print date/time
|
||
|
|
│ ├── Print duration
|
||
|
|
│ ├── Printer used
|
||
|
|
│ └── Completion status
|
||
|
|
└── Plating History
|
||
|
|
└── Saved bed configurations
|
||
|
|
```
|
||
|
|
|
||
|
|
### Statistics Tracking
|
||
|
|
|
||
|
|
| Metric | Storage |
|
||
|
|
|--------|---------|
|
||
|
|
| Total print count | `ApplicationSession.PrintCount` |
|
||
|
|
| Print duration | `PrintTask.PrintTimeSeconds` |
|
||
|
|
| Success rate | Calculated from `PrintComplete` |
|
||
|
|
|
||
|
|
### Events
|
||
|
|
|
||
|
|
| Event | Source | Description |
|
||
|
|
|-------|--------|-------------|
|
||
|
|
| `PrintStarted` | `PrinterConnection` | Print begins |
|
||
|
|
| `PrintFinished` | `PrinterConnection` | Print completes |
|
||
|
|
| `AnyPrintStarted` | `ApplicationController` | Global start event |
|
||
|
|
| `AnyPrintComplete` | `ApplicationController` | Global complete event |
|
||
|
|
|
||
|
|
### Design Rationale
|
||
|
|
|
||
|
|
**Database Storage**: Using SQLite for print tasks enables:
|
||
|
|
- Persistent history across sessions
|
||
|
|
- Query capabilities (by date, printer, etc.)
|
||
|
|
- Recovery data preservation
|
||
|
|
|
||
|
|
**File-Based Queue**: The queue uses file system for:
|
||
|
|
- Simple item management
|
||
|
|
- Visual thumbnails
|
||
|
|
- Easy user access to files
|
||
|
|
|
||
|
|
**Recovery System**: Saving print state allows:
|
||
|
|
- Resume after power failure
|
||
|
|
- Continue after software crash
|
||
|
|
- Re-slice and continue
|
||
|
|
|
||
|
|
## Reference
|
||
|
|
|
||
|
|
### Core Classes
|
||
|
|
|
||
|
|
| Class | Location | Description |
|
||
|
|
|-------|----------|-------------|
|
||
|
|
| `PrintTask` | [DataStorage/Models.cs](MatterControlLib/DataStorage/Models.cs) | Print job record |
|
||
|
|
| `PrintHistory` | [PrintHistory/](MatterControlLib/PrintHistory/) | History UI |
|
||
|
|
| `LegacyQueueFiles` | [PrintQueue/LegacyQueueFiles.cs](MatterControlLib/PrintQueue/LegacyQueueFiles.cs) | Queue management |
|
||
|
|
|
||
|
|
### Library Containers
|
||
|
|
|
||
|
|
| Class | Location | Description |
|
||
|
|
|-------|----------|-------------|
|
||
|
|
| `PlatingHistoryContainer` | [Library/Providers/MatterControl/](MatterControlLib/Library/Providers/MatterControl/) | Print history |
|
||
|
|
| `RootHistoryContainer` | [Library/Providers/MatterControl/](MatterControlLib/Library/Providers/MatterControl/) | History root |
|
||
|
|
|
||
|
|
### Recovery
|
||
|
|
|
||
|
|
| Class | Location | Description |
|
||
|
|
|-------|----------|-------------|
|
||
|
|
| `PrintRecoveryStream` | [PrinterCommunication/Io/](MatterControlLib/PrinterCommunication/Io/) | Recovery stream |
|