CapacityMode#
Tells how a resource's capacity is spread over the buckets of a load profile. It's the type of ResourceLoad::capacity_mode , returned by Project::load_profile . The mode decides the capacity value of every LoadBucket of that resource.
Declaration#
Copy # [ derive ( Clone, Copy, Debug, PartialEq, Eq ) ]
pub enum CapacityMode {
Calendar,
Flat,
}
With the serde feature, the variants serialize as "calendar" and "flat".
Variants#
Variant
Description
Calendar
Capacity follows the resource's calendar: buckets with working time on that calendar get the resource's capacity, all others get 0. Reported when the resource has a calendar, config.calendar_mode is CalendarMode::Resource and config.use_calendars is true.
Flat
Every bucket gets the resource's capacity, non-working time included. Reported in all other cases: no resource calendar, a task calendar mode, or use_calendars: false.
The capacity value itself is ResourceData::capacity . The calendar setting lives in SchedulingConfig .
Example#
Copy use plen_core:: {
CalendarData, CapacityMode, DateTime, ProfileQuery, Project, ProjectData, ResourceData,
SolveOptions, TaskData, Worktime,
} ;
fn main ( ) -> Result < ( ) , Box < dyn std:: error:: Error> > {
let monday = DateTime:: from_ymd_hm( 2026 , 8 , 10 , 8 , 0 ) . ok_or ( " invalid date" ) ? ;
let mut task = TaskData:: new( " a" ) ;
task. start_date = Some ( monday) ;
task. duration = Some ( 1. 0 ) ;
let data = ProjectData {
tasks: vec! [ task] ,
calendars: vec! [ CalendarData {
id: " tue_sat" . into ( ) ,
worktime: Some ( Worktime {
days: Some ( [ false , false , true , true , true , true , true ] ) ,
.. Default :: default( )
} ) ,
} ] ,
resources: vec! [
ResourceData { id: " office" . into ( ) , capacity: None , calendar_id: None } ,
ResourceData { id: " shop" . into ( ) , capacity: None , calendar_id: Some ( " tue_sat" . into ( ) ) } ,
] ,
.. Default :: default( )
} ;
let mut project = Project:: default( ) ;
project. solve ( Some ( data) , & SolveOptions:: default( ) ) ? ;
let from = DateTime:: from_ymd_hm( 2026 , 8 , 10 , 0 , 0 ) . ok_or ( " invalid date" ) ? ;
let to = DateTime:: from_ymd_hm( 2026 , 8 , 17 , 0 , 0 ) . ok_or ( " invalid date" ) ? ;
let profile = project. load_profile ( & ProfileQuery:: new( from, to) . into ( ) ) ? ;
for row in & profile. resources {
let capacity: Vec < f64 > = row. buckets. iter ( ) . map ( | b | b. capacity ) . collect ( ) ;
match row. capacity_mode {
CapacityMode:: Calendar => println! ( " {} : calendar {capacity:?} " , row. resource) ,
CapacityMode:: Flat => println! ( " {} : flat {capacity:?} " , row. resource) ,
}
}
Ok ( ( ) )
}
office has no calendar and gets Flat capacity 1.0 every day. shop gets Calendar, with capacity 0 on Monday and Sunday.
For how capacity and load compare in a profile, see Resource load .
ResourceLoad - carries the mode for each resource in a profile
CalendarMode - the config setting that selects Calendar capacity
ResourceData - supplies the capacity value the mode spreads over buckets
Resource Load - compares both modes on one project