TrainState

Struct TrainState 

Source
pub struct TrainState {
Show 33 fields pub time: TrackedState<Time>, pub i: TrackedState<usize>, pub offset: TrackedState<Length>, pub offset_back: TrackedState<Length>, pub total_dist: TrackedState<Length>, pub link_idx_front: TrackedState<u32>, pub link_idx_back: TrackedState<u32>, pub offset_in_link: TrackedState<Length>, pub speed: TrackedState<Velocity>, pub speed_limit: TrackedState<Velocity>, pub speed_target: TrackedState<Velocity>, pub dt: TrackedState<Time>, pub length: TrackedState<Length>, pub mass_static: TrackedState<Mass>, pub mass_rot: TrackedState<Mass>, pub mass_freight: TrackedState<Mass>, pub weight_static: TrackedState<Force>, pub res_rolling: TrackedState<Force>, pub res_bearing: TrackedState<Force>, pub res_davis_b: TrackedState<Force>, pub res_aero: TrackedState<Force>, pub res_grade: TrackedState<Force>, pub res_curve: TrackedState<Force>, pub grade_front: TrackedState<Ratio>, pub grade_back: TrackedState<Ratio>, pub elev_front: TrackedState<Length>, pub elev_back: TrackedState<Length>, pub pwr_res: TrackedState<Power>, pub pwr_accel: TrackedState<Power>, pub pwr_whl_out: TrackedState<Power>, pub energy_whl_out: TrackedState<Energy>, pub energy_whl_out_pos: TrackedState<Energy>, pub energy_whl_out_neg: TrackedState<Energy>,
}

Fields§

§time: TrackedState<Time>

time since user-defined datum

§i: TrackedState<usize>

index for time steps

§offset: TrackedState<Length>

Linear-along-track, directional distance of front of train from original starting position of back of train.

If this is provided in InitTrainState::new, it gets set as the train length or the value, whichever is larger, and if it is not provided, then it defaults to the train length.

§offset_back: TrackedState<Length>

Linear-along-track, directional distance of back of train from original starting position of back of train.

§total_dist: TrackedState<Length>

Linear-along-track, cumulative, absolute distance from initial starting position.

§link_idx_front: TrackedState<u32>

Current link containing head end (i.e. pulling locomotives) of train

§link_idx_back: TrackedState<u32>

Current link containing tail/back end of train

§offset_in_link: TrackedState<Length>

Offset from start of current link

§speed: TrackedState<Velocity>

Achieved speed based on consist capabilities and train resistance

§speed_limit: TrackedState<Velocity>

Speed limit

§speed_target: TrackedState<Velocity>

Speed target from meet-pass planner

§dt: TrackedState<Time>

Time step size

§length: TrackedState<Length>

Train length

§mass_static: TrackedState<Mass>

Static mass of train, including freight

§mass_rot: TrackedState<Mass>

Effective additional mass of train due to rotational inertia

§mass_freight: TrackedState<Mass>

Mass of freight being hauled by the train (not including railcar empty weight)

§weight_static: TrackedState<Force>

Static weight of train

§res_rolling: TrackedState<Force>

Rolling resistance force

§res_bearing: TrackedState<Force>

Bearing resistance force

§res_davis_b: TrackedState<Force>

Davis B term resistance force

§res_aero: TrackedState<Force>

Aerodynamic resistance force

§res_grade: TrackedState<Force>

Grade resistance force

§res_curve: TrackedState<Force>

Curvature resistance force

§grade_front: TrackedState<Ratio>

Grade at front of train

§grade_back: TrackedState<Ratio>

Grade at back of train of train if strap method is used

§elev_front: TrackedState<Length>

Elevation at front of train

§elev_back: TrackedState<Length>

Elevation at back of train

§pwr_res: TrackedState<Power>

Power to overcome train resistance forces

§pwr_accel: TrackedState<Power>

Power to overcome inertial forces

§pwr_whl_out: TrackedState<Power>

Total tractive power exerted by locomotive consist

§energy_whl_out: TrackedState<Energy>

Integral of Self::pwr_whl_out

§energy_whl_out_pos: TrackedState<Energy>

Energy out during positive or zero traction

§energy_whl_out_neg: TrackedState<Energy>

Energy out during negative traction (positive value means negative traction)

Implementations§

Source§

impl TrainState

Source

pub fn new( length: Length, mass_static: Mass, mass_rot: Mass, mass_freight: Mass, init_train_state: Option<InitTrainState>, ) -> Self

Source

pub fn res_net(&self) -> Result<Force>

Source

pub fn mass_compound(&self) -> Result<Mass>

All base, freight, and rotational mass

Trait Implementations§

Source§

impl CheckAndResetState for TrainState

Source§

fn check_and_reset<F: Fn() -> String>(&mut self, loc: F) -> Result<()>

Ensure [State::Fresh] and reset to [State::Stale] Read more
Source§

impl Clone for TrainState

Source§

fn clone(&self) -> TrainState

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TrainState

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for TrainState

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for TrainState

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Init for TrainState

Source§

fn init(&mut self) -> Result<(), Error>

Specialized code to execute upon initialization. For any struct with fields that implement Init, this should propagate down the hierarchy.
Source§

impl Mass for TrainState

Source§

fn mass(&self) -> Result<Option<Mass>>

Static mass of train, not including effective rotational mass

Source§

fn set_mass( &mut self, _new_mass: Option<Mass>, _side_effect: MassSideEffect, ) -> Result<()>

Sets component mass to mass, or if None is provided for mass, sets mass based on other component parameters (e.g. power and power density, sum of fields containing mass)
Source§

fn derived_mass(&self) -> Result<Option<Mass>>

Returns derived mass (e.g. sum of mass fields, or calculation involving mass specific properties). If
Source§

fn expunge_mass_fields(&mut self)

Sets all fields that are used in calculating derived mass to None. Does not touch self.mass.
Source§

fn set_mass_specific_property(&mut self) -> Result<()>

Sets any mass-specific property with appropriate side effects
Source§

impl ObjState for TrainState

Source§

impl PartialEq for TrainState

Source§

fn eq(&self, other: &TrainState) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl SaveState for TrainState

Source§

fn save_state<F: Fn() -> String>(&mut self, loc: F) -> Result<()>

Implementation for objects without save_interval

Source§

impl SerdeAPI for TrainState

Source§

const ACCEPTED_BYTE_FORMATS: &'static [&'static str] = _

Source§

const ACCEPTED_STR_FORMATS: &'static [&'static str] = _

Source§

const RESOURCES_SUBDIR: &'static str = ""

Source§

const RESOURCES_DIR: &'static Dir<'_> = _

Source§

fn from_resource<P: AsRef<Path>>( filepath: P, skip_init: bool, ) -> Result<Self, Error>

Read (deserialize) an object from a resource file packaged with the altrios-core crate Read more
Source§

fn list_resources() -> Result<Vec<PathBuf>, Error>

List the available resources in the resources directory Read more
Source§

fn to_file<P: AsRef<Path>>(&self, filepath: P) -> Result<()>

Write (serialize) an object to a file. Supported file extensions are listed in ACCEPTED_BYTE_FORMATS. Creates a new file if it does not already exist, otherwise truncates the existing file. Read more
Source§

fn from_file<P: AsRef<Path>>( filepath: P, skip_init: bool, ) -> Result<Self, Error>

Read (deserialize) an object from a file. Supported file extensions are listed in ACCEPTED_BYTE_FORMATS. Read more
Source§

fn to_writer<W: Write>(&self, wtr: W, format: &str) -> Result<()>

Write (serialize) an object into anything that implements std::io::Write Read more
Source§

fn to_str(&self, format: &str) -> Result<String>

Write (serialize) an object into a string Read more
Source§

fn from_str<S: AsRef<str>>( contents: S, format: &str, skip_init: bool, ) -> Result<Self>

Read (deserialize) an object from a string Read more
Source§

fn from_reader<R: Read>( rdr: &mut R, format: &str, skip_init: bool, ) -> Result<Self, Error>

Deserialize an object from anything that implements std::io::Read Read more
Source§

fn to_json(&self) -> Result<String>

Write (serialize) an object to a JSON string
Source§

fn from_json<S: AsRef<str>>(json_str: S, skip_init: bool) -> Result<Self>

Read (deserialize) an object from a JSON string Read more
Source§

fn to_msg_pack(&self) -> Result<Vec<u8>>

Write (serialize) an object to a message pack
Source§

fn from_msg_pack(msg_pack: &[u8], skip_init: bool) -> Result<Self>

Read (deserialize) an object from a message pack Read more
Source§

fn to_toml(&self) -> Result<String>

Write (serialize) an object to a TOML string
Source§

fn from_toml<S: AsRef<str>>(toml_str: S, skip_init: bool) -> Result<Self>

Read (deserialize) an object from a TOML string Read more
Source§

fn to_yaml(&self) -> Result<String>

Write (serialize) an object to a YAML string
Source§

fn from_yaml<S: AsRef<str>>(yaml_str: S, skip_init: bool) -> Result<Self>

Read (deserialize) an object from a YAML string Read more
Source§

impl Serialize for TrainState

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl SetCumulative for TrainState

Source§

fn set_cumulative<F: Fn() -> String>(&mut self, dt: Time, loc: F) -> Result<()>

Sets cumulative values based on rate values
Source§

impl Step for TrainState

Source§

fn step<F: Fn() -> String>(&mut self, loc: F) -> Result<()>

Increments i field of this and all contained structs, recursively Read more
Source§

impl Valid for TrainState

Source§

fn valid() -> Self

Source§

impl StateMethods for TrainState

Source§

impl StructuralPartialEq for TrainState

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> EqDefault for T
where T: Default + PartialEq,

Source§

fn eq_default(&self) -> bool

Checks if an instance of Self is equal to Self::default
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> ObjStateConst for T
where T: ObjState,

Source§

fn is_real(&self) -> bool

Source§

fn is_valid(&self) -> bool

Source§

fn real(&self) -> Option<&T>

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> SendSyncUnwindSafe for T
where T: Send + Sync + UnwindSafe + ?Sized,

Source§

impl<T> Ungil for T
where T: Send,