use crate::EntityId;
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct NonControllableSource {
pub id: EntityId,
pub name: String,
pub bus_id: EntityId,
pub entry_stage_id: Option<i32>,
pub exit_stage_id: Option<i32>,
pub max_generation_mw: f64,
pub curtailment_cost: f64,
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_non_controllable_construction() {
let source = NonControllableSource {
id: EntityId::from(1),
name: "Eólica Caetité".to_string(),
bus_id: EntityId::from(7),
entry_stage_id: None,
exit_stage_id: None,
max_generation_mw: 300.0,
curtailment_cost: 0.01,
};
assert_eq!(source.id, EntityId::from(1));
assert_eq!(source.name, "Eólica Caetité");
assert_eq!(source.bus_id, EntityId::from(7));
assert_eq!(source.entry_stage_id, None);
assert_eq!(source.exit_stage_id, None);
assert!((source.max_generation_mw - 300.0).abs() < f64::EPSILON);
assert!((source.curtailment_cost - 0.01).abs() < f64::EPSILON);
}
#[test]
fn test_non_controllable_curtailment_cost() {
let source = NonControllableSource {
id: EntityId::from(2),
name: "Solar Pirapora".to_string(),
bus_id: EntityId::from(3),
entry_stage_id: Some(12),
exit_stage_id: None,
max_generation_mw: 400.0,
curtailment_cost: 5.0,
};
assert!((source.curtailment_cost - 5.0).abs() < f64::EPSILON);
}
}