Skip to content

Commit

Permalink
added a whole ton of doc string improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
calbaker committed Dec 19, 2023
1 parent b38d973 commit b585208
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 13 deletions.
7 changes: 7 additions & 0 deletions rust/altrios-core/src/lin_search_hint.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::imports::*;
use crate::si;

// Per Geordie, we could probably get rid of this `DirT` code
pub type DirT = u8;

#[allow(non_snake_case)]
Expand All @@ -14,11 +15,17 @@ pub mod Dir {
pub const Bwd: DirT = 2;
}

/// Has method that returns offset from start of PathTpc
pub trait GetOffset {
/// Returns offset from start of PathTpc
fn get_offset(&self) -> si::Length;
}

/// Contains method to calculate the index immediately before `offset` given the previous calculated
/// index, `idx`, and a direction `DirT`.
pub trait LinSearchHint {
/// Calculate the index immediately before `offset` given the previous calculated index, `idx`,
/// and a direction `DirT`.
fn calc_idx<const DIR: DirT>(&self, offset: si::Length, idx: usize) -> anyhow::Result<usize>;
}

Expand Down
16 changes: 10 additions & 6 deletions rust/altrios-core/src/track/path_track/link_point.rs
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
use super::super::LinkIdx;
use crate::imports::*;

/// Specifies the relative start of a link within the `PathTpc`
/// Point along PathTpc representing the start of a link and the number of grade, curve, and cat
/// power limit points contained within the same link,`link_idx`, in the PathTpc.
///
/// Note that for the `*_count` fields, these represent points contained in the link for which grade,
/// curve, ... information is known, not including the final point in the link.
#[derive(Debug, Default, Clone, Copy, Serialize, Deserialize, PartialEq, PartialOrd, SerdeAPI)]
#[altrios_api]
pub struct LinkPoint {
/// TODO: Geordie, doc string. What does offset mean here? distance from start of link to front
/// of train? Something else?
/// Distance relative to the start of the PathTpc where `link_idx` starts
#[api(skip_set)]
pub offset: si::Length,
#[api(skip_set)]
/// TODO: Geordie, doc string.
/// Number of grade points in the current link
pub grade_count: usize,
#[api(skip_set)]
/// TODO: Geordie, doc string.
/// Number of curve points in the current link
pub curve_count: usize,
#[api(skip_set)]
/// TODO: Geordie, doc string.
/// Number of catenary power limit points in the current link
pub cat_power_count: usize,
#[api(skip_set)]
/// [LinkIdx] of current link
pub link_idx: LinkIdx,
}

Expand Down
13 changes: 7 additions & 6 deletions rust/altrios-core/src/track/path_track/path_res_coeff.rs
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
use crate::imports::*;

/// Struct containing linear resistance coefficients for a particular offset w.r.t. `PathTpc`
#[derive(Clone, Copy, Default, Debug, PartialEq, PartialOrd, Serialize, Deserialize, SerdeAPI)]
#[altrios_api]
/// TODO: Geordie, doc string.
#[derive(Clone, Copy, Default, Debug, PartialEq, PartialOrd, Serialize, Deserialize, SerdeAPI)]
/// Struct containing linear resistance coefficients for a particular offset with respect to start
/// of `PathTpc`
pub struct PathResCoeff {
#[api(skip_set)]
/// TODO: Geordie, doc string.
/// Distance from start of `PathTpc`
pub offset: si::Length,
#[api(skip_set)]
/// TODO: Geordie, doc string.
/// Non-dimensional grade/curve resistance.
pub res_coeff: si::Ratio,
#[api(skip_set)]
/// TODO: Geordie, doc string.
/// Cumulative sum of `res_coeff` times length up to this `PathResCoeff` along `PathTpc`
pub res_net: si::Length,
}

impl PathResCoeff {
/// Cumulative sum of `res_coeff` times length up to this `offset` along `PathTpc`
pub fn calc_res_val(&self, offset: si::Length) -> si::Length {
self.res_net + self.res_coeff * (offset - self.offset)
}
Expand Down
4 changes: 3 additions & 1 deletion rust/altrios-core/src/track/path_track/path_tpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ use super::train_params::*;
use crate::imports::*;

// TODO: make PathTpc robust to `Vec<LinkPoint>` that ends with `0`
/// Train resistance
/// Vector data used to represent track-dependent train performance parameters along the path the
/// train will follow. This contains all the positionally important data for the train resistance
/// model.
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, SerdeAPI)]
#[altrios_api]
pub struct PathTpc {
Expand Down

0 comments on commit b585208

Please sign in to comment.