Trax3 3.1.0
trax track library
Loading...
Searching...
No Matches
Fixtures.h
1// trax track library
2// AD 2013
3//
4// "the resolution of all the fruitless searches"
5//
6// Peter Gabriel
7//
8// Copyright (c) 2025 Trend Redaktions- und Verlagsgesellschaft mbH
9// Copyright (c) 2019 Marc-Michael Horstmann
10//
11// Permission is hereby granted to any person obtaining a copy of this software
12// and associated source code (the "Software"), to use, view, and study the
13// Software for personal or internal business purposes, subject to the following
14// conditions:
15//
16// 1. Redistribution, modification, sublicensing, or commercial use of the
17// Software is NOT permitted without prior written consent from the copyright
18// holder.
19//
20// 2. The Software is provided "AS IS", without warranty of any kind, express
21// or implied.
22//
23// 3. All copies of the Software must retain this license notice.
24//
25// For further information, please contact: horstmann.marc@trendverlag.de
26
27#pragma once
28
29#include "trax/Location.h"
30#include "trax/Curve.h"
31#include "trax/Sensor.h"
32#include "trax/Signal.h"
33#include "trax/LogicElements.h"
34
35#include <filesystem>
36
38
39 static std::filesystem::path FixturePath();
40
41};
42
44struct TrackFixture{
45 TrackFixture();
46 ~TrackFixture();
47
48 std::shared_ptr<trax::TrackBuilder> m_pTrack;
49};
50
51struct ThreeTracksInALineFixture{
52 ThreeTracksInALineFixture();
53 ~ThreeTracksInALineFixture();
54
55 std::shared_ptr<trax::TrackBuilder> m_pTrack1;
56 std::shared_ptr<trax::TrackBuilder> m_pTrack2;
57 std::shared_ptr<trax::TrackBuilder> m_pTrack3;
58};
59
60struct SwichFixture{
61 SwichFixture();
62 ~SwichFixture();
63
64 std::shared_ptr<trax::TrackBuilder> m_pTrack1;
65 std::shared_ptr<trax::TrackBuilder> m_pTrack2;
66 std::shared_ptr<trax::TrackBuilder> m_pTrack3;
67};
68
69
71struct TrackAndLocation : TrackFixture
72{
73 TrackAndLocation();
74
76};
77
78
79// Circle with radius 10 around the origin made from 4 tracks
80// connected to each other.
81struct TrackCircle : FixtureBase{
82 TrackCircle();
83 ~TrackCircle();
84
85 std::shared_ptr<trax::TrackBuilder> m_pTrack1;
86 std::shared_ptr<trax::TrackBuilder> m_pTrack2;
87 std::shared_ptr<trax::TrackBuilder> m_pTrack3;
88 std::shared_ptr<trax::TrackBuilder> m_pTrack4;
89
90 std::shared_ptr<trax::ArcP> m_pArc1;
91 std::shared_ptr<trax::ArcP> m_pArc2;
92 std::shared_ptr<trax::ArcP> m_pArc3;
93 std::shared_ptr<trax::ArcP> m_pArc4;
94
95 trax::Location m_Location;
96
98};
99//
100//struct TrackCircleIntegrated : TrackCircle{
101// TrackCircleIntegrated() : TrackCircle(trax::Curve::ArcIntegrated){}
102//};
103
104struct SensorFixture : TrackCircle{
105 SensorFixture();
106 ~SensorFixture();
107
108 std::shared_ptr<trax::Sensor> m_pSensor;
109 std::unique_ptr<trax::PulseCounter> m_pPulseCounter;
110 std::unique_ptr<trax::Event> m_pEvent;
111};
112
114public:
115
116 // SignalTarget:
117 bool Notify( const trax::Signal& /*signal*/, dim::Length /*distance*/ ) override{
118 m_bNotifyFlag = true;
119 return true;
120 }
121
122
123 void Active( bool bActive ) noexcept override{
124 m_bActive = bActive;
125 }
126
127 bool Active() const noexcept override{
128 return m_bActive;
129 }
130
131
132 bool m_bNotifyFlag = false;
133private:
134 bool m_bActive = true;
135};
136
137
Definition Fixtures.h:113
bool Notify(const trax::Signal &, dim::Length) override
Method called to notify about a signalling state.
Definition Fixtures.h:117
bool Active() const noexcept override
Definition Fixtures.h:127
void Active(bool bActive) noexcept override
Switches the target on or off to receive notifications from signals.
Definition Fixtures.h:123
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, 0 > > Length
Length.
Definition DimensionedValues.h:324
Definition Fixtures.h:37
trax::Location m_LocationOnTrack
location in middle of the track
Definition Fixtures.h:75
std::shared_ptr< trax::TrackBuilder > m_pTrack
track unattached to system
Definition Fixtures.h:48
A Signal is positioned along a track and is submitted to a Train if it runs over it.
Definition Signal.h:61
Target for signal notification.
Definition Signal.h:407