Create a new simulation with the given buffer capacity.
(capacity: usize)
| 85 | impl Simulation { |
| 86 | /// Create a new simulation with the given buffer capacity. |
| 87 | pub fn new(capacity: usize) -> Self { |
| 88 | let mut cpu = MultiTimeSeriesState::with_range(4, capacity, 0.0, 100.0); |
| 89 | cpu.set_label(0, "Core 0".to_string()); |
| 90 | cpu.set_label(1, "Core 1".to_string()); |
| 91 | cpu.set_label(2, "Core 2".to_string()); |
| 92 | cpu.set_label(3, "Core 3".to_string()); |
| 93 | |
| 94 | // btop panel: 20 CPU cores with sparklines (capacity 50 matches original demo_btop) |
| 95 | let btop_cores: Vec<MiniTimeSeriesState> = (0..20) |
| 96 | .map(|_| MiniTimeSeriesState::with_range(50, 0.0, 100.0)) |
| 97 | .collect(); |
| 98 | |
| 99 | let btop_spark_scratch = Vec::with_capacity(btop_cores.first().map_or(0, |s| s.capacity())); |
| 100 | |
| 101 | Self { |
| 102 | cpu, |
| 103 | cpu_cores: [ |
| 104 | TimeSeriesState::with_range(capacity, 0.0, 100.0), |
| 105 | TimeSeriesState::with_range(capacity, 0.0, 100.0), |
| 106 | TimeSeriesState::with_range(capacity, 0.0, 100.0), |
| 107 | TimeSeriesState::with_range(capacity, 0.0, 100.0), |
| 108 | ], |
| 109 | cpu_values: [25.0, 45.0, 35.0, 55.0], |
| 110 | network: DualTimeSeriesState::with_ranges(capacity, (0.0, 100.0), (0.0, 100.0)), |
| 111 | rx_series: TimeSeriesState::with_range(capacity, 0.0, 100.0), |
| 112 | tx_series: TimeSeriesState::with_range(capacity, 0.0, 100.0), |
| 113 | rx_value: 30.0, |
| 114 | tx_value: 15.0, |
| 115 | memory: TimeSeriesState::with_range(capacity, 0.0, 100.0), |
| 116 | mem_value: 42.0, |
| 117 | btop_cores, |
| 118 | btop_spark_scratch, |
| 119 | // btop memory: capacity 30 matches original demo_btop narrower graphs |
| 120 | btop_mem_used: TimeSeriesState::with_range(30, 0.0, 100.0), |
| 121 | btop_mem_available: TimeSeriesState::with_range(30, 0.0, 100.0), |
| 122 | btop_mem_cached: TimeSeriesState::with_range(30, 0.0, 100.0), |
| 123 | btop_mem_free: TimeSeriesState::with_range(30, 0.0, 100.0), |
| 124 | btop_mem_values: BtopMemValues { |
| 125 | total_gb: 32.0, |
| 126 | used_gb: 18.0, |
| 127 | available_gb: 10.0, |
| 128 | cached_gb: 6.0, |
| 129 | free_gb: 8.0, |
| 130 | swap_total_gb: 8.0, |
| 131 | swap_used_gb: 1.2, |
| 132 | }, |
| 133 | btop_disks: vec![ |
| 134 | DiskInfo { |
| 135 | name: "/".into(), |
| 136 | total_gb: 120.0, |
| 137 | used_gb: 54.0, |
| 138 | }, |
| 139 | DiskInfo { |
| 140 | name: "/home".into(), |
| 141 | total_gb: 500.0, |
| 142 | used_gb: 360.0, |
| 143 | }, |
| 144 | ], |