Skip to content

Commit

Permalink
made use of Network::from_file consistent with Python API
Browse files Browse the repository at this point in the history
  • Loading branch information
calbaker committed Apr 3, 2024
1 parent 6a2d82f commit 4da2727
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
3 changes: 1 addition & 2 deletions rust/altrios-core/src/meet_pass/dispatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,7 @@ mod test_dispatch {
fn test_simple_dispatch() {
let mut network_file_path = project_root::get_project_root().unwrap();
network_file_path.push("../python/altrios/resources/networks/Taconite.yaml");
let network =
Vec::<Link>::from_file(network_file_path.as_os_str().to_str().unwrap()).unwrap();
let network = Network::from_file(network_file_path.as_os_str().to_str().unwrap()).unwrap();
network.validate().unwrap();

let train_sims = vec![
Expand Down
6 changes: 2 additions & 4 deletions rust/altrios-core/src/meet_pass/train_disp/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,7 @@ mod test_train_disp {
fn test_make_train_fwd() {
let mut network_file_path = project_root::get_project_root().unwrap();
network_file_path.push("../python/altrios/resources/networks/Taconite.yaml");
let network =
Vec::<Link>::from_file(network_file_path.as_os_str().to_str().unwrap()).unwrap();
let network = Network::from_file(network_file_path.as_os_str().to_str().unwrap()).unwrap();
network.validate().unwrap();

let speed_limit_train_sim = crate::train::speed_limit_train_sim_fwd();
Expand All @@ -246,8 +245,7 @@ mod test_train_disp {
// TODO: Make this test depend on a better file
let mut network_file_path = project_root::get_project_root().unwrap();
network_file_path.push("../python/altrios/resources/networks/Taconite.yaml");
let network =
Vec::<Link>::from_file(network_file_path.as_os_str().to_str().unwrap()).unwrap();
let network = Network::from_file(network_file_path.as_os_str().to_str().unwrap()).unwrap();

network.validate().unwrap();
let speed_limit_train_sim = crate::train::speed_limit_train_sim_rev();
Expand Down
9 changes: 9 additions & 0 deletions rust/altrios-core/src/track/link/link_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,15 @@ impl ObjState for Link {
/// Python
pub struct Network(pub Vec<Link>);

impl ObjState for Network {
fn is_fake(&self) -> bool {
self.0.is_fake()
}
fn validate(&self) -> ValidationResults {
self.0.validate()
}
}

impl SerdeAPI for Network {
fn from_file<P: AsRef<Path>>(filepath: P) -> anyhow::Result<Self> {
let filepath = filepath.as_ref();
Expand Down

0 comments on commit 4da2727

Please sign in to comment.