diff options
Diffstat (limited to 'crates/fparkan-runtime/src/lib.rs')
| -rw-r--r-- | crates/fparkan-runtime/src/lib.rs | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/crates/fparkan-runtime/src/lib.rs b/crates/fparkan-runtime/src/lib.rs index 5f3f436e..0ac5197f 100644 --- a/crates/fparkan-runtime/src/lib.rs +++ b/crates/fparkan-runtime/src/lib.rs @@ -4496,10 +4496,18 @@ fn control_resource_budget_pass( table: &mut MissionControlDeviceTableState, delta_time_seconds: f32, ) -> Result<(), ControlResourceAccessError> { + control_resource_budget_pass_with_motion(table, delta_time_seconds, None) +} + +fn control_resource_budget_pass_with_motion( + table: &mut MissionControlDeviceTableState, + delta_time_seconds: f32, + motion: Option<mobile_budget::DriveMotion>, +) -> Result<(), ControlResourceAccessError> { let delta_time_seconds = checked_control_float(0, "Control resource interval", delta_time_seconds)?; let mut updated = table.clone(); - control_resource_budget_pass_inner(&mut updated, delta_time_seconds)?; + control_resource_budget_pass_inner(&mut updated, delta_time_seconds, motion)?; *table = updated; Ok(()) } @@ -4507,6 +4515,7 @@ fn control_resource_budget_pass( fn control_resource_budget_pass_inner( table: &mut MissionControlDeviceTableState, delta_time_seconds: f32, + motion: Option<mobile_budget::DriveMotion>, ) -> Result<(), ControlResourceAccessError> { let device_count = match &table.status { MissionControlDeviceTableStatus::Available(devices) => devices.len(), @@ -4534,7 +4543,12 @@ fn control_resource_budget_pass_inner( let mut positive_rate_sum = 0.0_f32; for index in 0..device_count { let device = control_budget_device(table, index)?; - let rate = control_device_resource_rate(table, &device, delta_time_seconds)?; + let rate = match motion { + Some(motion) if device.factory_tag == 5 => { + motion.rate(table, device, delta_time_seconds)? + } + _ => control_device_resource_rate(table, device, delta_time_seconds)?, + }; if rate > 0.0 { positive_rate_sum = checked_control_sum( device.factory_tag, @@ -8381,6 +8395,7 @@ mod tests { PreparedComponentControl { source: synthetic_resource_key(940), native_profile_words: [0; 27], + uniform_drive_factor_bits: None, model_node_count: 3, bindings: Vec::new(), timeline_rows: Vec::new(), @@ -8888,6 +8903,7 @@ mod tests { PreparedComponentControl { source: synthetic_resource_key(100 + index), native_profile_words: [0; 27], + uniform_drive_factor_bits: None, model_node_count: 0, bindings: Vec::new(), timeline_rows: Vec::new(), |
