Trax3 3.1.0
trax track library
Loading...
Searching...
No Matches
RailRunner.h
1// trax track library
2// AD 2023
3//
4// "Slide!"
5//
6// Fight Club
7//
8//
9// Copyright (c) 2025 Trend Redaktions- und Verlagsgesellschaft mbH
10// Copyright (c) 2019 Marc-Michael Horstmann
11//
12// Permission is hereby granted to any person obtaining a copy of this software
13// and associated source code (the "Software"), to use, view, and study the
14// Software for personal or internal business purposes, subject to the following
15// conditions:
16//
17// 1. Redistribution, modification, sublicensing, or commercial use of the
18// Software is NOT permitted without prior written consent from the copyright
19// holder.
20//
21// 2. The Software is provided "AS IS", without warranty of any kind, express
22// or implied.
23//
24// 3. All copies of the Software must retain this license notice.
25//
26// For further information, please contact: horstmann.marc@trendverlag.de
27
28#pragma once
29
312
313#include "trax/Units.h"
314#include "trax/Identified.h"
315#include "trax/Location.h"
316
317#include <memory>
318
319
320namespace trax{
321
322 struct Jack;
323
325 struct RailRunnerUserData;
326
327
344 struct RailRunner : Identified<RailRunner>
345 {
347 virtual const char* TypeName() const noexcept = 0;
348
349
351 enum class EndType : char{
352 none = 0,
357 };
358
360 virtual std::shared_ptr<RailRunner> This() const noexcept = 0;
361
362
364 virtual bool IsValid() const noexcept = 0;
365
366
367 // Rail/DeRail:
368
369
389 virtual void Rail( const Location& location, bool bMoveTo = true ) = 0;
390
391
396 virtual Location GetLocation() const noexcept = 0;
397
398
402 virtual void DeRail() noexcept = 0;
403
404
409 virtual bool IsRailed() const noexcept = 0;
410
411
412 // Locating in space
413
432 virtual spat::Frame<Length,One> GetGlobalAnchor() const = 0;
433
434
443 virtual void ResetToGlobalAnchor( const spat::Frame<Length,One>& anchorPose ) = 0;
444
445
446 // Driving:
447
456 virtual void SetVelocity( Velocity velocity ) = 0;
457
458
460 virtual Velocity GetVelocity() const = 0;
461
462
474 virtual void TargetVelocity( Velocity velocity ) = 0;
475
476
478 virtual Velocity TargetVelocity() const noexcept = 0;
479
480
488 virtual EndType TargetDirection() const noexcept = 0;
489
490
492 virtual Power MaximumPowerOutput() const noexcept = 0;
493
494
496 virtual Power CurrentPowerOutput() const noexcept = 0;
497
498
501 virtual Velocity MaximumVelocity() const noexcept = 0;
502
503
508 virtual void Thrust( One byfactor ) = 0;
509
510
514 virtual One Thrust() const noexcept = 0;
515
516
519 virtual void ThrustAbsolute( Force thrust ) = 0;
520
521
523 virtual Force ThrustAbsolute() const noexcept = 0;
524
525
534
537 virtual Force MaxThrust() const noexcept = 0;
538
541 virtual Force MaxThrust( Velocity velocity ) const noexcept = 0;
543
544
549 virtual void Brake( One byfactor ) = 0;
550
551
555 virtual One Brake() const noexcept = 0;
556
557
560 virtual void BrakeAbsolute( Force brake ) = 0;
561
562
564 virtual Force BrakeAbsolute() const noexcept = 0;
565
566
570 virtual Force MaxBrake() const noexcept = 0;
571
572
573 // Coupling:
574
582 virtual void ActivateCoupling( EndType end ) = 0;
583
584
591 virtual void DeactivateCoupling( EndType end ) = 0;
592
593
597 virtual bool IsActivated( EndType end ) const noexcept = 0;
598
599
605 virtual bool Uncouple( EndType end = EndType::all, bool btriggerPulses = true ) noexcept = 0;
606
607
612 virtual bool IsCoupled( EndType end = EndType::any ) const noexcept = 0;
613
614
618 virtual Length GetCouplingHeight( EndType end ) const noexcept = 0;
619
620
621 // Jacks 'N Plugs:
622
625 virtual Jack& JackOnCouple( EndType end ) = 0;
626
627
630 virtual Jack& JackOnUnCouple( EndType end ) = 0;
631
632
636
637
641
642
646 virtual void UserData( RailRunnerUserData* pData ) noexcept = 0;
647
648
650 virtual RailRunnerUserData* UserData() const noexcept = 0;
651 };
652
653
655 inline RailRunner::EndType operator!( RailRunner::EndType end ) noexcept{
656 switch( end ){
659 default: return RailRunner::EndType::none;
660 }
661 }
662
664 dclspc std::string ToString( RailRunner::EndType end );
665
666
669 dclspc RailRunner::EndType ToRailRunnerEndType( const std::string& endtype );
670
671}
672
A Location specifies a position on a track system by referencing a track and a TrackLocation on it.
Definition Location.h:110
Value< Dimension< 1, 0, -1 > > Velocity
Velocity.
Definition DimensionedValues.h:331
Value< Dimension< 0, 0, 0 > > One
Dimensionless value.
Definition DimensionedValues.h:319
Value< Dimension< 1, 0, 0 > > Length
Length.
Definition DimensionedValues.h:324
Value< Dimension< 1, 1, -2 > > Force
Force.
Definition DimensionedValues.h:333
Value< Dimension< 2, 1, -3 > > Power
Power.
Definition DimensionedValues.h:339
The namespace provides classes and methods for spatial computations.
Definition Box.h:32
Namespace of all the trax track libraries classes and methods.
Definition Collection.h:17
dclspc RailRunner::EndType ToRailRunnerEndType(const std::string &endtype)
Makes a end type value from a string.
A Frame ("TNBFrame") describes a location in 3d space and an orientation using a right handed coordin...
Definition Frame.h:52
A jack a plug can get connected with.
Definition Jack.h:83
Interface for train and rolling stock that can be railed on a track and might provide brakes and powe...
Definition RailRunner.h:345
virtual Velocity MaximumVelocity() const noexcept=0
virtual std::shared_ptr< RailRunner > This() const noexcept=0
Gets a shared pointer to this.
virtual Power CurrentPowerOutput() const noexcept=0
virtual void DeactivateCoupling(EndType end)=0
Deactivates the coupling at the respective end of the RailRunner.
virtual bool IsValid() const noexcept=0
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.
virtual Location GetLocation() const noexcept=0
Gets the track location were the RailRunner is railed.
virtual void SetVelocity(Velocity velocity)=0
Sets the velocity of this RailRunner along the track.
EndType
Types of the RailRunner's end's.
Definition RailRunner.h:351
@ any
Denotes the north or south end of a Railrunner.
Definition RailRunner.h:355
@ south
Denotes the back end of a RailRunner.
Definition RailRunner.h:354
@ north
Denotes the front end of a RailRunner.
Definition RailRunner.h:353
@ all
Denotes both ends of a RailRunner.
Definition RailRunner.h:356
virtual Jack & JackOnCouple(EndType end)=0
Gets a Jack that pulses its Plug if one (or any) of the RailRunner's outmost couplings get coupled.
virtual void DeRail() noexcept=0
Take the RailRunner from the track.
virtual Velocity GetVelocity() const =0
virtual spat::Frame< Length, One > GetGlobalAnchor() const =0
Gets the global anchor of the RailRunner.
virtual Power MaximumPowerOutput() 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 Force MaxBrake() const noexcept=0
Gets the maximal available braking. This value is determined by the properties of the Wheelsets attac...
virtual Jack & JackOnUnCouple(EndType end)=0
Gets a Jack that pulses its Plug if one (or any) of the RailRunner's outmost couplings get uncoupled ...
virtual bool Uncouple(EndType end=EndType::all, bool btriggerPulses=true) noexcept=0
Uncouples the RailRunner at the specified end.
virtual Jack & JackOnCouplingDeactivated(EndType end)=0
Gets a Jack that pulses its Plug if one (or any) of the RailRunner's outmost couplings get deactivate...
virtual bool IsRailed() const noexcept=0
Is the RailRunner on a track?
virtual Length GetCouplingHeight(EndType end) const noexcept=0
Gets the height of the coupling over the track.
virtual EndType TargetDirection() const noexcept=0
Gets the principle direction of movement according to the sign of the target velocity.
virtual Jack & JackOnCouplingActivated(EndType end)=0
Gets a Jack that pulses its Plug if one (or any) of the RailRunner's outmost couplings get activated.
virtual void BrakeAbsolute(Force brake)=0
Sets the brake as absolute force value. If the value exceeds MaxBrake() it gets clipped.
virtual Force MaxThrust() const noexcept=0
virtual bool IsActivated(EndType end) const noexcept=0
virtual void ActivateCoupling(EndType end)=0
Activates the coupling at the respective end of the RailRunner.
virtual void UserData(RailRunnerUserData *pData) noexcept=0
Sets a pointer to user provided data.
virtual void Thrust(One byfactor)=0
Sets the fraction of the maximum thrust to apply in order to reach the target velocity specified by T...
virtual bool IsCoupled(EndType end=EndType::any) const noexcept=0
Is the coupling coupled?
virtual const char * TypeName() const noexcept=0
virtual void ThrustAbsolute(Force thrust)=0
Sets the thrust as absolute force values. If the value exceeds MaxThrust() it get clipped.
virtual void Rail(const Location &location, bool bMoveTo=true)=0
Attaches this RailRunner onto the specified track location.
virtual void TargetVelocity(Velocity velocity)=0
Sets the target velocity to aim for by using the supplied Thrust() and Brake() settings.