Trax3 3.1.0
trax track library
Loading...
Searching...
No Matches
trax::TrainComponent Struct Referenceabstract

A TrainComponent is a part of a Train. More...

#include <C:/Trend/Development/Trax3/Code/trax/rigid/trains/TrainComponent.h>

Inheritance diagram for trax::TrainComponent:

Classes

struct  Coupling
 Structure describing a coupling between two TrainComponents. More...

Public Types

enum class  DistanceType { actual , min , max , half }
Public Types inherited from trax::RailRunner
enum class  EndType : char {
  none = 0 , north , south , any ,
  all
}
 Types of the RailRunner's end's. More...

Public Member Functions

virtual std::shared_ptr< TrainComponentThisTrainComponent () const noexcept=0
 Gets a shared pointer to this.
virtual TrainGetTrain () const noexcept=0
virtual Orientation GetOrientation () const noexcept=0
virtual std::pair< Train *, OrientationGetTopmostTrain () const noexcept=0
virtual bool IsFinal () const noexcept=0
virtual bool IsParent (const Train &train) const noexcept=0
virtual void Rail (const Location &location, bool bMoveTo, DistanceType distance)=0
 Rails this TrainComponent at the given location.
virtual void ResetToGlobalAnchor (const spat::Frame< Length, One > &anchorPose, DistanceType distance)=0
virtual bool Couple (EndType end, TrainComponent &with, EndType withEnd, bool btriggerPulses=true) noexcept=0
 Couples this TrainComponent with another at the respective ends.
virtual std::pair< std::shared_ptr< TrainComponent >, EndTypeGetCoupledTrainComponent (EndType end) const noexcept=0
 Get the coupled TrainComponent.
virtual Length GetCouplingLength (EndType end, DistanceType distance=DistanceType::max) const noexcept=0
 Gets the length of the coupling from TrainComponent edge to TrainComponent edge.
virtual Length GetOverhang (EndType end, DistanceType distance=DistanceType::actual) const noexcept=0
 Gets the distances from the track location (i.e. global anchor) to the north or south tip of the RailRunner.
virtual Length GetLength (DistanceType distance=DistanceType::actual) const noexcept=0
 Gets the total length of this RailRunner.
virtual Mass GetTotalMass () const noexcept=0
virtual JackJackOnRail () noexcept=0
 Gets a Jack that pulses its Plug if the RailRunner gets railed on a track.
virtual JackJackOnDerail () noexcept=0
 Gets a Jack that pulses its Plug if the RailRunner derails.
virtual void Rail (const Location &location, bool bMoveTo=true)=0
 Attaches this RailRunner onto the specified track location.
virtual void ResetToGlobalAnchor (const spat::Frame< Length, One > &anchorPose)=0
 Sets the position of the RailRunner so that its global anchor alignes to the given global pose.
Train Tip

Gets a reference to the Bogie which makes the outmost tip of this RailRunner.

For a RollingStock and a Train it would get the Bogie with the coupling that reaches out the furthest in the denoted direction.

virtual std::pair< Bogie &, EndTypeGetTipAt (EndType end)=0
virtual std::pair< const Bogie &, EndTypeGetTipAt (EndType end) const =0
Public Member Functions inherited from trax::RailRunner
virtual const char * TypeName () const noexcept=0
virtual std::shared_ptr< RailRunnerThis () const noexcept=0
 Gets a shared pointer to this.
virtual bool IsValid () const noexcept=0
virtual Location GetLocation () const noexcept=0
 Gets the track location were the RailRunner is railed.
virtual void DeRail () noexcept=0
 Take the RailRunner from the track.
virtual bool IsRailed () const noexcept=0
 Is the RailRunner on a track?
virtual spat::Frame< Length, OneGetGlobalAnchor () const =0
 Gets the global anchor of the RailRunner.
virtual void SetVelocity (Velocity velocity)=0
 Sets the velocity of this RailRunner along the track.
virtual Velocity GetVelocity () const =0
virtual void TargetVelocity (Velocity velocity)=0
 Sets the target velocity to aim for by using the supplied Thrust() and Brake() settings.
virtual Velocity TargetVelocity () const noexcept=0
virtual EndType TargetDirection () const noexcept=0
 Gets the principle direction of movement according to the sign of the target velocity.
virtual Power MaximumPowerOutput () const noexcept=0
virtual Power CurrentPowerOutput () const noexcept=0
virtual Velocity MaximumVelocity () const noexcept=0
virtual void Thrust (One byfactor)=0
 Sets the fraction of the maximum thrust to apply in order to reach the target velocity specified by TargetVelocity().
virtual One Thrust () const noexcept=0
 Gets the fraction of the maximum thrust applied.
virtual void ThrustAbsolute (Force thrust)=0
 Sets the thrust as absolute force values. If the value exceeds MaxThrust() it get clipped.
virtual Force ThrustAbsolute () const noexcept=0
virtual void Brake (One byfactor)=0
 Sets the fraction of the maximum braking to apply in order
to reach a zero velocity.
virtual One Brake () const noexcept=0
 Gets the fraction of the maximum braking applied.
virtual void BrakeAbsolute (Force brake)=0
 Sets the brake as absolute force value. If the value exceeds MaxBrake() it gets clipped.
virtual Force BrakeAbsolute () const noexcept=0
virtual Force MaxBrake () const noexcept=0
 Gets the maximal available braking. This value is determined by the properties of the Wheelsets attached to WheelFrames wich in turn are attached to a bogie.
virtual void ActivateCoupling (EndType end)=0
 Activates the coupling at the respective end of the RailRunner.
virtual void DeactivateCoupling (EndType end)=0
 Deactivates the coupling at the respective end of the RailRunner.
virtual bool IsActivated (EndType end) const noexcept=0
virtual bool Uncouple (EndType end=EndType::all, bool btriggerPulses=true) noexcept=0
 Uncouples the RailRunner at the specified end.
virtual bool IsCoupled (EndType end=EndType::any) const noexcept=0
 Is the coupling coupled?
virtual Length GetCouplingHeight (EndType end) const noexcept=0
 Gets the height of the coupling over the track.
virtual JackJackOnCouple (EndType end)=0
 Gets a Jack that pulses its Plug if one (or any) of the RailRunner's outmost couplings get coupled.
virtual JackJackOnUnCouple (EndType end)=0
 Gets a Jack that pulses its Plug if one (or any) of the RailRunner's outmost couplings get uncoupled or breaks.
virtual JackJackOnCouplingActivated (EndType end)=0
 Gets a Jack that pulses its Plug if one (or any) of the RailRunner's outmost couplings get activated.
virtual JackJackOnCouplingDeactivated (EndType end)=0
 Gets a Jack that pulses its Plug if one (or any) of the RailRunner's outmost couplings get deactivated.
virtual void UserData (RailRunnerUserData *pData) noexcept=0
 Sets a pointer to user provided data.
virtual RailRunnerUserData * UserData () const noexcept=0
virtual Force MaxThrust () const noexcept=0
virtual Force MaxThrust (Velocity velocity) const noexcept=0
Public Member Functions inherited from trax::Identified< RailRunner >
virtual const std::string & Reference (const std::string &name) const=0
 Gets a reference that was set for this object by name.
virtual const std::vector< char const * > & ReferenceNames (const std::string &namePart) const=0
 Searches for all reference names that countain namePart as substring in the name.
virtual IDType ID () const noexcept=0
 Identified (const Identified &)=delete
Identified & operator= (const Identified &)=delete

Protected Member Functions

virtual void SetTrain (Train *pTrain) noexcept=0
virtual void SetOrientation (Orientation orientation) noexcept=0

Friends

class Train_Imp

Detailed Description

A TrainComponent is a part of a Train.

Member Function Documentation

◆ Couple()

virtual bool trax::TrainComponent::Couple ( EndType end,
TrainComponent & with,
EndType withEnd,
bool btriggerPulses = true )
pure virtualnoexcept

Couples this TrainComponent with another at the respective ends.

It doesn't matter, wether the two couplings are near each other or not. The coupling will try to maintain the actual distance of the two TrainComponent's ends. The coupling attempt will fail if the two TrainComponent are already coupled (with different partners or the same parters at different ends) or if one of the couplings is deactivated. An coupling attempt will also fail, when two couplings wear different coupling type indices.

See also
Bogie::CouplingProps.
Parameters
endEnd of this TrainComponent.
withOther TrainComponent.
withEndOther TrainComponent's end to couple with.
btriggerPulsesIf true the respective JackOnCouple jacks are pulsing.
Returns
true if a new coupling was established or the two TrainComponent were already properly coupled.

Implemented in trax::Train.

◆ GetCoupledTrainComponent()

virtual std::pair< std::shared_ptr< TrainComponent >, EndType > trax::TrainComponent::GetCoupledTrainComponent ( EndType end) const
pure virtualnoexcept

Get the coupled TrainComponent.

The coupled train component is the parent to the Bogie coupled at this TrainComponent's tip Bogie, that is topmost in its hierarchy of TrainComponents, but not also a parent to this TrainComponent.

Parameters
endEnd type of this TrainComponent.
Returns
A pointer to the other TrainComponent coupled at end, or
nullptr if none and the other TrainComponent's end type.

◆ GetCouplingLength()

virtual Length trax::TrainComponent::GetCouplingLength ( EndType end,
DistanceType distance = DistanceType::max ) const
pure virtualnoexcept

Gets the length of the coupling from TrainComponent edge to TrainComponent edge.

This is the length of the coupling, not the distance between the two TrainComponents. It is the sum of the two radii of the couplings trigger spheres; or 0_m if not coupled.

Parameters
endEnd of this TrainComponent to get the coupling length for.
distanceThe type of the data of the coupling to get the length for.
Returns
The length of the coupling at the denoted end.

◆ GetLength()

virtual Length trax::TrainComponent::GetLength ( DistanceType distance = DistanceType::actual) const
pure virtualnoexcept

Gets the total length of this RailRunner.

Returns
the sum of the two overhangs.

◆ GetOrientation()

virtual Orientation trax::TrainComponent::GetOrientation ( ) const
pure virtualnoexcept
Returns
the orientation of this component in the Train.

◆ GetOverhang()

virtual Length trax::TrainComponent::GetOverhang ( EndType end,
DistanceType distance = DistanceType::actual ) const
pure virtualnoexcept

Gets the distances from the track location (i.e. global anchor) to the north or south tip of the RailRunner.

The tip of a RailRunner is at the outmost coupling position.

Returns
southern overhang.

◆ GetTipAt() [1/2]

virtual std::pair< const Bogie &, EndType > trax::TrainComponent::GetTipAt ( EndType end) const
pure virtual
Parameters
endDenotes the Railrunner's end to search for the outmost Bogie.
Exceptions
std::invalid_argumentif end is none.
Returns
The Bogie at the tip, and the end type of the coupling at the tip.

◆ GetTipAt() [2/2]

virtual std::pair< Bogie &, EndType > trax::TrainComponent::GetTipAt ( EndType end)
pure virtual
Parameters
endDenotes the Railrunner's end to search for the outmost Bogie.
Exceptions
std::invalid_argumentif end is none.
Returns
The Bogie at the tip, and the end type of the coupling at the tip.

◆ GetTopmostTrain()

virtual std::pair< Train *, Orientation > trax::TrainComponent::GetTopmostTrain ( ) const
pure virtualnoexcept
Returns
The topmost parent Train in the TrainComponent hierarchy and this components orientation relative to it.

◆ GetTotalMass()

virtual Mass trax::TrainComponent::GetTotalMass ( ) const
pure virtualnoexcept
Returns
the total mass of this TrainComponent.

◆ GetTrain()

virtual Train * trax::TrainComponent::GetTrain ( ) const
pure virtualnoexcept
Returns
the train this component belongs to.

◆ IsFinal()

virtual bool trax::TrainComponent::IsFinal ( ) const
pure virtualnoexcept
Returns
true if this can not hold TrainComponents itself.

◆ IsParent()

virtual bool trax::TrainComponent::IsParent ( const Train & train) const
pure virtualnoexcept
Returns
true if train is a direct or indirect parent train of this component.

◆ Rail() [1/2]

virtual void trax::TrainComponent::Rail ( const Location & location,
bool bMoveTo,
DistanceType distance )
pure virtual

Rails this TrainComponent at the given location.

If bMoveTo is true, the TrainComponent will be moved to the location, the internal distances of coupled components are resolved by 'distance' if this happens to be a Train.

◆ Rail() [2/2]

virtual void trax::RailRunner::Rail ( const Location & location,
bool bMoveTo = true )
virtual

Attaches this RailRunner onto the specified track location.

The trackjoints of the WheelFrames will be attached to the track at locations that might differ from location, depending in the RailRunners definition of its location on the tracks. If a WheelFrame gets railed, in this railing process, its JackOnRail will pulse. If some railing is present already it gets overriden.

Parameters
locationThe location to rail this RailRunner. If railing is successful this location will be returned by GetLocation().
bMoveToIf true the RailRunner will be moved to the transitional 3D pose of location, prior to railing. If this is a Train, the actual coupling distances will be respected. See
See also
TrainComponent::Rail for details.
Exceptions
std::out_of_rangeif a dead end is encountered on the track system.
std::logic_errorIf there are no suitable WheelFrame children in the RailRunner to rail.
std::invalid_argumentIf location is not on a track.
std::out_of_rangeIf the railrunner would end up off the track system.
std::logic_errorIf the present configuration does not allow railing.

Implements trax::RailRunner.

◆ ResetToGlobalAnchor()

virtual void trax::RailRunner::ResetToGlobalAnchor ( const spat::Frame< Length, One > & anchorPose)
virtual

Sets the position of the RailRunner so that its global anchor alignes to the given global pose.

The whole RailRunner will be moved so the assigned anchor alignes with the given global pose. This can be used to relocate the RailRunner when not railed.

Parameters
anchorPoseThe pose to align the global anchor with.
Exceptions
std::logic_errorif there is no privilged anchor.

Implements trax::RailRunner.


The documentation for this struct was generated from the following file: