mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-12-03 06:35:21 +01:00
feat(physics): a switch run through from its frog end is damaged; physics.derailment new keeps it out of use and splits a vehicle running onto it from its points
A rail vehicle running onto a switch from its frog end by the way the switch is not set to pushes its blades over. Before, the switch was just thrown to that way and nothing remembered it. Now the switch is marked as run through, the log tells it once per run-through, and the scenery can react through the memory cell and event __simulation.runthrough. With physics.derailment new the damaged switch stays out of use for the run: switch events no longer throw it, a vehicle running onto it from its points pushes the loose blades over under its first axle and runs forked (the #496 limits derail it, cause split_switch), and a run-through above 60 km/h derails the vehicle at the switch (cause run_through). In monitor mode the run does not change; the log tells what new would do. Every switch is still taken as trailable, as before.
This commit is contained in:
+2
-2
@@ -572,13 +572,13 @@ track: no offset, no roll, nothing travelled.
|
||||
| `f32` | roll [rad] of its body, to the left positive: about 1.57 on its side |
|
||||
| `f32` | distance [m] it went on the ground since it left the rails |
|
||||
| `u8` | 1 lying on its side, 0 upright |
|
||||
| `u8` | what derailed it, finer: the code of the cause of the memory cell `__simulation.derailment` (tests/scenarios/README.md): 1 the flange climbed, 2 overturned, 3 the end of the track, 4 pulled off, 5 a collision (the legacy model), 6 a buckle, 7 overriding, 8 pushed off, 9 too fast in a curve (the legacy draw), 10 the gauge, 11 a track of another kind, 12 a trailed switch, 13 something else. In phases 0 and 1 too |
|
||||
| `u8` | what derailed it, finer: the code of the cause of the memory cell `__simulation.derailment` (tests/scenarios/README.md): 1 the flange climbed, 2 overturned, 3 the end of the track, 4 pulled off, 5 a collision (the legacy model), 6 a buckle, 7 overriding, 8 pushed off, 9 too fast in a curve (the legacy draw), 10 the gauge, 11 a track of another kind, 12 a trailed switch, 13 something else, 14 it ran through a switch set the other way too fast, 15 a switch run through before split it (both `physics.derailment new`, world/switchfork.h). In phases 0 and 1 too |
|
||||
| `str` | name of the track it derailed on, empty for a track without a name |
|
||||
|
||||
The last two came later: a reader of an older file finds the record shorter. The finer cause is 0 when the
|
||||
simulator didn't know it yet. The cause before them stays one of 1-5, the closest one: a buckle 1 or 2, the
|
||||
way the vehicle went; overriding and pushing off 5; a trailed switch, the legacy draw in a curve, the gauge,
|
||||
the kind of track and something else 1.
|
||||
the kind of track and something else, and the two of a switch run through, 1.
|
||||
|
||||
### 0x3F end
|
||||
|
||||
|
||||
@@ -325,11 +325,20 @@ void physics::Vehicle::derail_in_collision(DerailReason const Reason, std::strin
|
||||
}
|
||||
|
||||
void physics::Vehicle::derail_forked(int const Side, std::string const &Why)
|
||||
{
|
||||
derail_at_switch(Side, derailment::reason::none, "running forked, " + Why);
|
||||
}
|
||||
|
||||
void physics::Vehicle::derail_at_switch(int const Side, derailment::reason const Reason, std::string const &Why)
|
||||
{
|
||||
if (false == DamageFlag.Set(VehicleDamage::derailed))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (Reason != derailment::reason::none)
|
||||
{
|
||||
noteDerailment(Reason);
|
||||
}
|
||||
// upright, the flange climbed the rail: it slides on the sleepers as one derailed by the criteria of derailment.h
|
||||
derailOutcome = derailment::outcome::off_rails;
|
||||
// physics.derailment new: it leaves the track to the side the other way of the switch lies on
|
||||
@@ -347,7 +356,7 @@ void physics::Vehicle::derail_forked(int const Side, std::string const &Why)
|
||||
// the brake hoses tear: the brake pipe vents and the rest of the train brakes in emergency
|
||||
tear_brake_hoses(*this);
|
||||
derailment_monitor.reset();
|
||||
ErrorLog(std::format("Bad driving: {} derailed running forked, {}", Name, Why));
|
||||
ErrorLog(std::format("Bad driving: {} derailed {}", Name, Why));
|
||||
}
|
||||
namespace
|
||||
{
|
||||
|
||||
@@ -298,6 +298,8 @@ std::string_view reason_name(reason const Reason) {
|
||||
case reason::track_type: return "track_type";
|
||||
case reason::trailed_switch: return "trailed_switch";
|
||||
case reason::other: return "other";
|
||||
case reason::run_through: return "run_through";
|
||||
case reason::split_switch: return "split_switch";
|
||||
}
|
||||
return "other";
|
||||
}
|
||||
|
||||
@@ -248,7 +248,9 @@ enum class reason : std::uint8_t {
|
||||
track_gauge = 10, // the gauge of the track doesn't fit the vehicle
|
||||
track_type = 11, // a track of another kind than the vehicle
|
||||
trailed_switch = 12, // it trailed through a switch with a movable nose set the other way
|
||||
other = 13 // something else derailed it: a SetDamage command of a scenery
|
||||
other = 13, // something else derailed it: a SetDamage command of a scenery
|
||||
run_through = 14, // it ran through a switch set the other way too fast (new, world/switchfork.h)
|
||||
split_switch = 15 // running onto a switch run through before from its points it ran forked on the loose blades (new)
|
||||
};
|
||||
// the name of the cause in the log and the memory cell, e.g. "end_of_track"
|
||||
std::string_view reason_name(reason Reason);
|
||||
|
||||
@@ -1231,6 +1231,10 @@ class Vehicle
|
||||
// the rail: it leaves the rails upright, the reason told in the log. Side is the side of its front the way the
|
||||
// switch was thrown to lies on (1 the left, -1 the right, 0 unknown), the way it goes off the track to
|
||||
void derail_forked(int Side, std::string const &Why);
|
||||
// physics.derailment new: the vehicle leaves the rails upright at a switch, as derail_forked() has it, for the
|
||||
// Reason (none: not told, as running forked): it ran through the switch too fast, or the switch run through before
|
||||
// split it (world/switchfork.h). Why goes to the log after "Bad driving: <name> derailed "
|
||||
void derail_at_switch(int Side, derailment::reason Reason, std::string const &Why);
|
||||
bool DirectionForward();
|
||||
bool DirectionBackward(void); /*! kierunek ruchu*/
|
||||
bool EIMDirectionChangeAllow(void) const;
|
||||
|
||||
@@ -153,6 +153,22 @@ state_manager::report_derailment( TDynamicObject const &Vehicle, derailment::not
|
||||
test().vehicle_derailed( Vehicle, Notice );
|
||||
}
|
||||
|
||||
void
|
||||
state_manager::report_run_through( TTrack const &Switch, TDynamicObject const &Vehicle, double const Speed ) {
|
||||
|
||||
auto const name { std::string( run_through_name ) };
|
||||
if( auto *cell { Memory.find( name ) } ) {
|
||||
cell->UpdateValues(
|
||||
( Switch.name().empty() ? std::string( "none" ) : Switch.name() ) + " " + Vehicle.name(),
|
||||
Speed,
|
||||
static_cast<double>( Switch.SwitchExtension != nullptr ? Switch.SwitchExtension->CurrentIndex : 0 ),
|
||||
basic_event::flags::text | basic_event::flags::value1 | basic_event::flags::value2 );
|
||||
}
|
||||
if( auto *launched { Events.FindEvent( name ) } ) {
|
||||
Events.AddToQuery( launched, &Vehicle );
|
||||
}
|
||||
}
|
||||
|
||||
// legacy method, calculates changes in simulation state over specified time
|
||||
void
|
||||
state_manager::update( double const Deltatime, int Iterationcount ) {
|
||||
|
||||
@@ -82,6 +82,13 @@ public:
|
||||
report_derailment( TDynamicObject const &Vehicle, derailment::notice const &Notice );
|
||||
// name of the memory cell and of the event of a derailment of any vehicle
|
||||
static constexpr std::string_view derailment_name { "__simulation.derailment" };
|
||||
// the vehicle ran through the switch (world/switchfork.h) at the Speed [km/h]: the scenery which asked for it. its
|
||||
// memory cell __simulation.runthrough gets "<switch> <vehicle>", value 1 the speed, value 2 the way the blades were
|
||||
// pushed over to, then its event of that name runs, the vehicle its activator. the events <switch>:forced+ and
|
||||
// <switch>:forced- of the scenery run as they always did. as with the derailment, nothing is made at the start
|
||||
void
|
||||
report_run_through( TTrack const &Switch, TDynamicObject const &Vehicle, double Speed );
|
||||
static constexpr std::string_view run_through_name { "__simulation.runthrough" };
|
||||
|
||||
private:
|
||||
// members
|
||||
|
||||
@@ -164,10 +164,48 @@ vehicle reads the cell of that vehicle, `<vehicle>:derailed`, not `__simulation.
|
||||
| 11 | `track_type` | a track of another kind (a road vehicle on rails, say) |
|
||||
| 12 | `trailed_switch` | it trailed through a switch with a movable nose set the other way |
|
||||
| 13 | `other` | something else set the derailment (a `SetDamage` command) |
|
||||
| 14 | `run_through` | it ran through a switch set the other way faster than 60 km/h (`new`, see [A switch run through](#a-switch-run-through)) |
|
||||
| 15 | `split_switch` | running onto a switch run through before from its points it ran forked on the loose blades (`new`) |
|
||||
|
||||
The memory cell isn't made by the simulator because a node made at the start would take the random numbers of the
|
||||
scene and change every run of a scenery. `eu07_td_off_track_end_scenery_told` is an example.
|
||||
|
||||
### A switch run through
|
||||
|
||||
A rail vehicle running onto a switch from its frog end by the way the switch isn't set to pushes its blades over
|
||||
("rozprucie zwrotnicy", `world/switchfork.h`). It always went that way: the switch is thrown to that way at once, the
|
||||
events `<switch>:forced+` / `<switch>:forced-` of the scenery run, and the train goes on along the way it came by (a
|
||||
switch with a movable nose derails it, cause 12). Since the run-through PR the switch is also damaged for the rest of
|
||||
the run, and the log tells it once for each run-through:
|
||||
|
||||
```
|
||||
switch zwr02 run through by ep07-424 at 23 km/h
|
||||
```
|
||||
|
||||
Only a vehicle moving on a loaded scenery counts: one laid onto the tracks as the scenery loads, across a switch set
|
||||
the other way, throws it as before and damages nothing. With `physics.derailment new`:
|
||||
|
||||
- the damaged switch is out of use, as the rules of PKP PLK have it until it's checked on site (Ir-1 § 5 ust. 14,
|
||||
Ie-10 (E-18) § 29-30):
|
||||
`switch` events (the signaller's levers among them) don't throw it any more, the first refused throw is told
|
||||
(`switch <name> was run through: out of use until checked, its throws refused`). Wheels coming from the frog end by
|
||||
the other way still push it over;
|
||||
- a vehicle running onto it from its points (the train that ran through backing over it, which Ir-9 § 9 ust. 10
|
||||
forbids): the flange of its leading wheel pushes the loose blades over to the other way (`Switch "<name>", run through
|
||||
before, gave way under <vehicle> ...`), the axles after it take that way and the vehicle runs forked, as at a switch
|
||||
thrown under it: past the limits of forked running it leaves the rails (`Bad driving: <vehicle> derailed running
|
||||
forked on a switch run through before, ...`, cause 15 `split_switch`);
|
||||
- a vehicle running through faster than 60 km/h (`switch_fork::run_through_speed`, a guess above the run-throughs at up
|
||||
to 53 km/h that didn't derail in the reports of PKBWK) leaves the rails at it (cause 14 `run_through`).
|
||||
|
||||
With `monitor` (the default) nothing of that happens: the log tells what `new` would do (`derailment monitor: switch
|
||||
<name> was run through, physics.derailment new refuses its throws`, `derailment monitor: <vehicle> ran onto switch
|
||||
"<name>" from its points, run through before: ...`). `old` and `off`: the log line of the run-through only.
|
||||
|
||||
A scenery that wants to react declares the memory cell and the event `__simulation.runthrough`, as for a derailment:
|
||||
the cell gets the text `<switch> <vehicle>`, value 1 the speed [km/h], value 2 the way the blades were pushed over to,
|
||||
then the event runs, the vehicle its activator.
|
||||
|
||||
A signal is passed at danger when the head of a train goes past a signal which its driver
|
||||
has in its speed table, showing stop. So it's the driver's view that counts: a train without
|
||||
a driver isn't watched, and neither is a signal the driver never scanned (a train placed at
|
||||
@@ -662,6 +700,18 @@ by the way the switch was set to then (the locomotive jumped 0.78 m off its trac
|
||||
split onto the two tracks with nothing in the log, and the AI traced its route through the switch as set (after the
|
||||
throw under the standing train through `tor1p`, track 1, while its head was on track 2).
|
||||
|
||||
The `eu07_td_switch_run_through_*` cases (fragment `td_switch_run_through.scn`, see [A switch run through](#a-switch-run-through))
|
||||
run through `zwr02` from its frog end: the route of track 1 sets it for the train, and as the train starts on track 1
|
||||
(`event2` of `tdo_n1734`) it is thrown back to track 2. The fragment declares `__simulation.runthrough`, whose
|
||||
event checks the switch and the way in the cell.
|
||||
|
||||
| case | what | result |
|
||||
| --- | --- | --- |
|
||||
| `eu07_td_switch_run_through_trailing` | the timetable train (EU07 and three coaches) runs through at 40 km/h | stays on the rails, the switch is told run through, the scenery is told; stops at Przystanek after 1403 m |
|
||||
| `eu07_td_switch_run_through_trailing_new` | as above, `physics.derailment new`; the switch thrown back to track 2 under the coaches once the locomotive is on the line | under 60 km/h it stays on the rails; the throw is refused, the coaches go on along track 1 |
|
||||
| `eu07_td_switch_run_through_backs` | an EU07 alone runs through at 26 km/h, stops on the line before a memory cell at stop at z 1500, changes direction and backs over `zwr02` from its points | `monitor`: backs onto track 1 on the rails, the log tells what `new` would do; passes on `tdo_n1744` |
|
||||
| `eu07_td_switch_run_through_backs_derails` | as above, `physics.derailment new` | its leading wheel pushes the loose blades to track 2, the rear bogie takes it: forked, it derails (`split_switch`) at 32 km/h, which ends the test |
|
||||
|
||||
### Cases on a mission of a scenery
|
||||
|
||||
The cases made from players' reports (eu07/maszyna#421, #506, #524, #525) run a whole mission
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
{
|
||||
"description": "A switch run through, then backed over (Ir-9 section 9 ust. 10 forbids it: a switch run through is out of use until checked). An EU07 on its own leaves track 1 of Stacja1 through zwr02 from its frog end, the switch thrown back to track 2 as it starts: it runs through it. It stops on the line before a signal at stop (a memory cell at z 1500), clear of the switch, changes direction and backs over zwr02 from its points onto track 1. physics.derailment monitor (the default): it backs over the switch as before, on the rails, the log tells that new would push the loose blades over under it; the test passes back on tdo_n1744.",
|
||||
"base_scenery": "td.scn",
|
||||
"time": "10:34",
|
||||
"fragment": "td_switch_run_through.scn",
|
||||
"vars": {
|
||||
"trainsets": [
|
||||
"trainset none tdo_n1734 50.0 0.0",
|
||||
"node -1 0 {{vehicle}} dynamic pkp\\4e_v1 4e-004 4e 0 headdriver 0 0 enddynamic",
|
||||
"endtrainset"
|
||||
],
|
||||
"route": "node -1 0 autotest_route_launcher eventlauncher 0 0 0 -1 none 1034 keyctrl04 end",
|
||||
"throw": "zwr02_0",
|
||||
"throw_after": "zwr02_0",
|
||||
"order": "Obey_train 0 0"
|
||||
},
|
||||
"track_events": {
|
||||
"tdo_n1734": [
|
||||
"event0 autotest_wake",
|
||||
"event2 autotest_throw"
|
||||
],
|
||||
"tdo_n145": [
|
||||
"event2 autotest_stop_info",
|
||||
"event0 autotest_reverse"
|
||||
],
|
||||
"tdo_n1744": [
|
||||
"event1 autotest_back",
|
||||
"event2 autotest_back"
|
||||
]
|
||||
},
|
||||
"ini": [
|
||||
"gfxrenderer null"
|
||||
],
|
||||
"test_config": [
|
||||
"test.timeout 500",
|
||||
"test.standstill 120"
|
||||
],
|
||||
"timeout": 700,
|
||||
"checks": [
|
||||
{
|
||||
"type": "log_contains",
|
||||
"pattern": "\\sswitch zwr02 run through by autotest_\\S+ at [0-9]+ km/h$"
|
||||
},
|
||||
{
|
||||
"type": "log_contains",
|
||||
"pattern": "EVENT LAUNCHED.*: autotest_reverse_done$"
|
||||
},
|
||||
{
|
||||
"type": "log_contains",
|
||||
"pattern": "derailment monitor: autotest_\\S+ ran onto switch \"zwr02\" from its points, run through before: physics.derailment new pushes its loose blades over"
|
||||
},
|
||||
{
|
||||
"type": "on_track",
|
||||
"vehicles": "{{vehicle}}",
|
||||
"max_offset": 0.6
|
||||
},
|
||||
{
|
||||
"type": "log_lacks",
|
||||
"pattern": "Bad driving"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
{
|
||||
"description": "As eu07_td_switch_run_through_backs, with physics.derailment new: backing over zwr02 from its points, run through before, the EU07 pushes its loose blades over with its leading wheel, its rear bogie takes the other way and the locomotive runs forked: past the limit of its bogies it leaves the rails (cause split_switch), and with test.fail_on_derailment the derailment ends the test.",
|
||||
"base_scenery": "td.scn",
|
||||
"time": "10:34",
|
||||
"fragment": "td_switch_run_through.scn",
|
||||
"vars": {
|
||||
"trainsets": [
|
||||
"trainset none tdo_n1734 50.0 0.0",
|
||||
"node -1 0 {{vehicle}} dynamic pkp\\4e_v1 4e-004 4e 0 headdriver 0 0 enddynamic",
|
||||
"endtrainset"
|
||||
],
|
||||
"route": "node -1 0 autotest_route_launcher eventlauncher 0 0 0 -1 none 1034 keyctrl04 end",
|
||||
"throw": "zwr02_0",
|
||||
"throw_after": "zwr02_0",
|
||||
"order": "Obey_train 0 0"
|
||||
},
|
||||
"track_events": {
|
||||
"tdo_n1734": [
|
||||
"event0 autotest_wake",
|
||||
"event2 autotest_throw"
|
||||
],
|
||||
"tdo_n145": [
|
||||
"event2 autotest_stop_info",
|
||||
"event0 autotest_reverse"
|
||||
],
|
||||
"tdo_n1744": [
|
||||
"event1 autotest_back",
|
||||
"event2 autotest_back"
|
||||
]
|
||||
},
|
||||
"ini": [
|
||||
"gfxrenderer null",
|
||||
"physics.derailment new"
|
||||
],
|
||||
"test_config": [
|
||||
"test.timeout 500",
|
||||
"test.standstill 120",
|
||||
"test.fail_on_derailment yes"
|
||||
],
|
||||
"timeout": 700,
|
||||
"checks": [
|
||||
{
|
||||
"type": "log_contains",
|
||||
"pattern": "\\sswitch zwr02 run through by autotest_\\S+ at [0-9]+ km/h$"
|
||||
},
|
||||
{
|
||||
"type": "log_contains",
|
||||
"pattern": "EVENT LAUNCHED.*: autotest_reverse_done$"
|
||||
},
|
||||
{
|
||||
"type": "log_contains",
|
||||
"pattern": "Switch \"zwr02\", run through before, gave way under autotest_\\S+ running onto it from its points"
|
||||
},
|
||||
{
|
||||
"type": "log_contains",
|
||||
"pattern": "Bad driving: autotest_\\S+ derailed running forked on a switch run through before, its bogies on the two ways of switch \"zwr02\""
|
||||
},
|
||||
{
|
||||
"type": "log_contains",
|
||||
"pattern": "test: derailment \\(exit code 15\\) after [0-9.]+ s of simulation time: autotest_\\S+ derailed \\(split_switch\\)"
|
||||
},
|
||||
{
|
||||
"type": "log_lacks",
|
||||
"pattern": "derailment monitor: "
|
||||
}
|
||||
],
|
||||
"expect": "derailment"
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
{
|
||||
"description": "Switch run through (rozprucie zwrotnicy): the td/rozklad timetable train, an EU07 with three coaches, leaves track 1 of Stacja1 on td.scn through zwr02 from its frog end; the route of track 1 set the switch for it, and as the train starts it is thrown back to track 2 (event2 of tdo_n1734). The wheels of the locomotive push the blades over at low speed: the train runs on along the way it came by, stays on the rails and runs its timetable to the stop at Przystanek; the log tells the run-through once, with the vehicle and its speed. physics.derailment monitor (the default): nothing else changes. The scenery is told through the memory cell and the event __simulation.runthrough, which checks the switch and the way in the cell.",
|
||||
"base_scenery": "td.scn",
|
||||
"time": "10:34",
|
||||
"fragment": "td_switch_run_through.scn",
|
||||
"vars": {
|
||||
"trainsets": [
|
||||
"trainset td/rozklad tdo_n1734 0.0 0.1",
|
||||
"node -1 0 {{vehicle}} dynamic pkp\\4e_v1 4e-004 4e 0 headdriver 3 0 enddynamic",
|
||||
"node -1 0 {{vehicle}}_c1 dynamic pkp\\bdhpumn_v3 bdhpumn_50512608068-6 BDHPUMN_TAPICERKA_1 0 nobody 3 0 enddynamic",
|
||||
"node -1 0 {{vehicle}}_c2 dynamic pkp\\bdhpumn_v3 bdhpumn_50512608068-6 BDHPUMN_TAPICERKA_1 0 nobody 3 0 enddynamic",
|
||||
"node -1 0 {{vehicle}}_c3 dynamic pkp\\bdhpumn_v3 bdhpumn_50512608068-6 BDHPUMN_TAPICERKA_1 0 nobody 0 0 enddynamic",
|
||||
"endtrainset"
|
||||
],
|
||||
"route": "node -1 0 autotest_route_launcher eventlauncher 0 0 0 -1 none 1034 keyctrl04 end",
|
||||
"throw": "zwr02_0",
|
||||
"throw_after": "zwr02_0",
|
||||
"order": "Obey_train 0 0"
|
||||
},
|
||||
"track_events": {
|
||||
"tdo_n1734": "event2 autotest_throw"
|
||||
},
|
||||
"ini": [
|
||||
"gfxrenderer null"
|
||||
],
|
||||
"duration": 300,
|
||||
"timeout": 600,
|
||||
"checks": [
|
||||
{
|
||||
"type": "starts",
|
||||
"min_speed": 20,
|
||||
"within": 240
|
||||
},
|
||||
{
|
||||
"type": "stops",
|
||||
"moving_speed": 20,
|
||||
"stop_speed": 1.0,
|
||||
"hold": 0,
|
||||
"min_distance": 1380,
|
||||
"max_distance": 1420
|
||||
},
|
||||
{
|
||||
"type": "on_track",
|
||||
"vehicles": "{{vehicle}}",
|
||||
"max_offset": 0.6
|
||||
},
|
||||
{
|
||||
"type": "log_contains",
|
||||
"pattern": "EVENT LAUNCHED.*: autotest_throw_done$"
|
||||
},
|
||||
{
|
||||
"type": "log_contains",
|
||||
"pattern": "\\sswitch zwr02 run through by autotest_\\S+ at [0-9]+ km/h$"
|
||||
},
|
||||
{
|
||||
"type": "log_contains",
|
||||
"pattern": "EVENT LAUNCHED.*: autotest_runthrough_told$"
|
||||
},
|
||||
{
|
||||
"type": "log_lacks",
|
||||
"pattern": "Bad driving"
|
||||
},
|
||||
{
|
||||
"type": "log_lacks",
|
||||
"pattern": "derailment monitor: "
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
{
|
||||
"description": "As eu07_td_switch_run_through_trailing, with physics.derailment new: under the 60 km/h of switch_fork::run_through_speed the train runs through zwr02 and stays on the rails, the switch is damaged. When the locomotive has run onto the line (event2 of tdo_n145) an event throws zwr02 back to track 2 under the coaches, as a signaller's lever would: the switch run through is out of use, the throw is refused (told once in the log), and the coaches go on along track 1 as before.",
|
||||
"base_scenery": "td.scn",
|
||||
"time": "10:34",
|
||||
"fragment": "td_switch_run_through.scn",
|
||||
"vars": {
|
||||
"trainsets": [
|
||||
"trainset td/rozklad tdo_n1734 0.0 0.1",
|
||||
"node -1 0 {{vehicle}} dynamic pkp\\4e_v1 4e-004 4e 0 headdriver 3 0 enddynamic",
|
||||
"node -1 0 {{vehicle}}_c1 dynamic pkp\\bdhpumn_v3 bdhpumn_50512608068-6 BDHPUMN_TAPICERKA_1 0 nobody 3 0 enddynamic",
|
||||
"node -1 0 {{vehicle}}_c2 dynamic pkp\\bdhpumn_v3 bdhpumn_50512608068-6 BDHPUMN_TAPICERKA_1 0 nobody 3 0 enddynamic",
|
||||
"node -1 0 {{vehicle}}_c3 dynamic pkp\\bdhpumn_v3 bdhpumn_50512608068-6 BDHPUMN_TAPICERKA_1 0 nobody 0 0 enddynamic",
|
||||
"endtrainset"
|
||||
],
|
||||
"route": "node -1 0 autotest_route_launcher eventlauncher 0 0 0 -1 none 1034 keyctrl04 end",
|
||||
"throw": "zwr02_0",
|
||||
"throw_after": "zwr02_0",
|
||||
"order": "Obey_train 0 0"
|
||||
},
|
||||
"track_events": {
|
||||
"tdo_n1734": "event2 autotest_throw",
|
||||
"tdo_n145": "event2 autotest_throw_after"
|
||||
},
|
||||
"ini": [
|
||||
"gfxrenderer null",
|
||||
"physics.derailment new"
|
||||
],
|
||||
"duration": 300,
|
||||
"timeout": 600,
|
||||
"checks": [
|
||||
{
|
||||
"type": "starts",
|
||||
"min_speed": 20,
|
||||
"within": 240
|
||||
},
|
||||
{
|
||||
"type": "stops",
|
||||
"moving_speed": 20,
|
||||
"stop_speed": 1.0,
|
||||
"hold": 0,
|
||||
"min_distance": 1380,
|
||||
"max_distance": 1420
|
||||
},
|
||||
{
|
||||
"type": "on_track",
|
||||
"vehicles": "{{vehicle}}",
|
||||
"max_offset": 0.6
|
||||
},
|
||||
{
|
||||
"type": "log_contains",
|
||||
"pattern": "EVENT LAUNCHED.*: autotest_throw_done$"
|
||||
},
|
||||
{
|
||||
"type": "log_contains",
|
||||
"pattern": "\\sswitch zwr02 run through by autotest_\\S+ at [0-9]+ km/h$"
|
||||
},
|
||||
{
|
||||
"type": "log_lacks",
|
||||
"pattern": "Bad driving"
|
||||
},
|
||||
{
|
||||
"type": "log_contains",
|
||||
"pattern": "switch zwr02 was run through: out of use until checked, its throws refused"
|
||||
},
|
||||
{
|
||||
"type": "log_contains",
|
||||
"pattern": "EVENT LAUNCHED.*: autotest_throw_after$"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
// added by tests/scenarios/run.py to td.scn, whose own trainsets were removed.
|
||||
// a switch run through ("rozprucie zwrotnicy", world/switchfork.h): a train leaves track 1 of Stacja1 through zwr02,
|
||||
// trailing, from its frog end, with the switch thrown back to track 2 (position 0) as it starts, so its wheels push
|
||||
// the blades over. zwr02 (see td_switch_thrown.scn): points at z 1436 (tdo_n145, the line, z 1436-1536), the ways end at
|
||||
// z 1402 (tor2k, track 2, position 0; tdo_n1744, track 1, position 1). The route of track 1 (keyctrl04) sets it to
|
||||
// position 1 and opens the exit signal of track 1.
|
||||
{{trainsets}}
|
||||
|
||||
// the route of track 1, at 10:34
|
||||
{{route}}
|
||||
|
||||
// the throw against the train (vars.throw), once: an event hung on the tracks of the case (track_events) sets it off
|
||||
node -1 0 autotest_thrown memcell 0 0 0 thrown 0 0 none endmemcell
|
||||
event autotest_throw multiple 0 autotest_thrown {{throw}} autotest_throw_done condition memcompare * 0 * endevent
|
||||
event autotest_throw_done UpdateValues 0 autotest_thrown * 1 * endevent
|
||||
// the scenery told of the run-through: the simulator writes "<switch> <vehicle>", the speed and the way the blades were
|
||||
// pushed to (1, track 1) to the memory cell __simulation.runthrough, then runs its event, which checks the cell
|
||||
node -1 0 __simulation.runthrough memcell 0 0 0 none 0 0 none endmemcell
|
||||
node -1 0 autotest_told memcell 0 0 0 none 0 0 none endmemcell
|
||||
event __simulation.runthrough multiple 0 __simulation.runthrough autotest_runthrough_told condition memcompare zwr02* * 1 endevent
|
||||
event autotest_runthrough_told UpdateValues 0 autotest_told told * * endevent
|
||||
// a throw of the switch once it has been run through, by an event like a signaller's lever (vars.throw_after)
|
||||
event autotest_throw_after multiple 0 none {{throw_after}} endevent
|
||||
|
||||
// a driver of a trainset of velocity 0 sleeps until it gets an order: event0 of its track gives it vars.order, once
|
||||
node -1 0 autotest_ordered memcell 0 0 0 ordered 0 0 none endmemcell
|
||||
event autotest_wake multiple 0 autotest_ordered autotest_order autotest_order_given condition memcompare * 0 * endevent
|
||||
event autotest_order PutValues 0 none 0 0 0 {{order}} endevent
|
||||
event autotest_order_given UpdateValues 0 autotest_ordered * 1 * endevent
|
||||
|
||||
// a signal at stop on the line past zwr02 for a train running out of the station: the memory cell stands beside the
|
||||
// track at z 1500 and event2 of tdo_n145 reads it (track_events). The train stops with its head before it, clear of the
|
||||
// switch. Standing there (event0 of tdo_n145) its driver is told once to change direction: it backs over zwr02 from its
|
||||
// points, onto track 1. Back on tdo_n1744 (event1/event2) the test passes
|
||||
node -1 0 autotest_stop memcell 0.396825 0.2 1500.0 SetVelocity 0 0 none endmemcell
|
||||
event autotest_stop_info getvalues 0 autotest_stop endevent
|
||||
node -1 0 autotest_reversed memcell 0 0 0 reversed 0 0 none endmemcell
|
||||
event autotest_reverse multiple 2 autotest_reversed autotest_reverse_order autotest_reverse_done condition memcompare * 0 * endevent
|
||||
event autotest_reverse_order PutValues 0 none 0 0 0 Change_direction 0 0 endevent
|
||||
event autotest_reverse_done UpdateValues 0 autotest_reversed * 1 * endevent
|
||||
event autotest_back multiple 0 autotest_reversed autotest_pass_back condition memcompare * 1 * endevent
|
||||
event autotest_pass_back UpdateValues 0 __test.result backed_over_the_switch 1 * endevent
|
||||
event autotest_pass_running UpdateValues 0 __test.result ran_clear_of_the_switch 1 * endevent
|
||||
@@ -359,9 +359,11 @@ TEST_CASE("derailment: what the scenery and the test mode are told") {
|
||||
CHECK(static_cast<int>(dr::reason::track_type) == 11);
|
||||
CHECK(static_cast<int>(dr::reason::trailed_switch) == 12);
|
||||
CHECK(static_cast<int>(dr::reason::other) == 13);
|
||||
CHECK(static_cast<int>(dr::reason::run_through) == 14);
|
||||
CHECK(static_cast<int>(dr::reason::split_switch) == 15);
|
||||
}
|
||||
SUBCASE("each cause has a name of one word") {
|
||||
for (int code = 0; code <= 13; ++code) {
|
||||
for (int code = 0; code <= 15; ++code) {
|
||||
auto const name{dr::reason_name(static_cast<dr::reason>(code))};
|
||||
CAPTURE(code);
|
||||
CHECK_FALSE(name.empty());
|
||||
@@ -369,6 +371,8 @@ TEST_CASE("derailment: what the scenery and the test mode are told") {
|
||||
}
|
||||
CHECK(dr::reason_name(dr::reason::end_of_track) == "end_of_track");
|
||||
CHECK(dr::reason_name(dr::reason::flange_climb) == "flange_climb");
|
||||
CHECK(dr::reason_name(dr::reason::run_through) == "run_through");
|
||||
CHECK(dr::reason_name(dr::reason::split_switch) == "split_switch");
|
||||
}
|
||||
SUBCASE("the memory cell: the vehicle, the cause and the track, none for a track without a name") {
|
||||
dr::notice notice{"ep07-424", dr::reason::overturned, "tdo_n222", 113.4};
|
||||
|
||||
@@ -292,3 +292,75 @@ TEST_CASE("switch fork: coupled vehicles forked on the switch of td.scn") {
|
||||
// 15.5 m into the switch, the ends 0.48 m apart
|
||||
CHECK(*derails == doctest::Approx(15.5).epsilon(0.03));
|
||||
}
|
||||
|
||||
// a switch run through ("rozprucie zwrotnicy"): an axle coming onto it from the frog end by the way it isn't set to
|
||||
|
||||
TEST_CASE("switch run through: an axle from the frog end by the way the switch isn't set to") {
|
||||
// set the way it comes by: it runs on as it always did
|
||||
CHECK_FALSE(sf::runs_through(0, 0));
|
||||
CHECK_FALSE(sf::runs_through(1, 1));
|
||||
// set the other way: its flanges push the blades over
|
||||
CHECK(sf::runs_through(0, 1));
|
||||
CHECK(sf::runs_through(1, 0));
|
||||
// the set way is taken by its lowest bit, as TTrack::Switch() does
|
||||
CHECK_FALSE(sf::runs_through(1, 3));
|
||||
CHECK(sf::runs_through(0, 3));
|
||||
// no way of the switch, a crossroads or a turntable: no run-through
|
||||
CHECK_FALSE(sf::runs_through(-1, 0));
|
||||
CHECK_FALSE(sf::runs_through(2, 0));
|
||||
}
|
||||
|
||||
TEST_CASE("switch run through: the loose blades under a wheel from the points") {
|
||||
// the flange of the leading wheel pushes them over to the other way: the axles after it take that one, forked
|
||||
CHECK(sf::pushed_over(0) == 1);
|
||||
CHECK(sf::pushed_over(1) == 0);
|
||||
CHECK(sf::pushed_over(3) == 0);
|
||||
// the leading axle keeps the way it ran onto, the one after it is on the other: forked
|
||||
CHECK(sf::forked(sf::pushed_over(1), 1));
|
||||
CHECK(sf::forked(sf::pushed_over(0), 0));
|
||||
}
|
||||
|
||||
TEST_CASE("switch run through: the speed it derails over") {
|
||||
CHECK(sf::run_through_speed == 60.0);
|
||||
// a shunting move, a train leaving a station: the train passes, the switch is damaged
|
||||
CHECK_FALSE(sf::run_through_derails(0.0));
|
||||
CHECK_FALSE(sf::run_through_derails(25.0));
|
||||
// the run-throughs of the accident reports, none of them derailed: an SA138 at 35-39 km/h (PKBWK 2/2025), an EMU at
|
||||
// about 53 km/h (PKBWK 6/2024)
|
||||
CHECK_FALSE(sf::run_through_derails(39.0));
|
||||
CHECK_FALSE(sf::run_through_derails(53.0));
|
||||
CHECK_FALSE(sf::run_through_derails(60.0));
|
||||
// over it the leading wheel climbs
|
||||
CHECK(sf::run_through_derails(60.5));
|
||||
CHECK(sf::run_through_derails(80.0));
|
||||
// going backwards the speed counts the same
|
||||
CHECK(sf::run_through_derails(-80.0));
|
||||
CHECK_FALSE(sf::run_through_derails(-20.0));
|
||||
}
|
||||
|
||||
TEST_CASE("switch run through: what physics.derailment does about it") {
|
||||
SUBCASE("new refuses the throws and derails, telling nothing more") {
|
||||
auto const rules{sf::rules_of(sf::run_through_model::physical)};
|
||||
CHECK(rules.refuses_throws);
|
||||
CHECK(rules.derails);
|
||||
CHECK_FALSE(rules.tells);
|
||||
}
|
||||
SUBCASE("monitor changes nothing, the log tells") {
|
||||
auto const rules{sf::rules_of(sf::run_through_model::monitor)};
|
||||
CHECK_FALSE(rules.refuses_throws);
|
||||
CHECK_FALSE(rules.derails);
|
||||
CHECK(rules.tells);
|
||||
}
|
||||
SUBCASE("old and off: the log line of the run-through and the damage only") {
|
||||
auto const rules{sf::rules_of(sf::run_through_model::legacy)};
|
||||
CHECK_FALSE(rules.refuses_throws);
|
||||
CHECK_FALSE(rules.derails);
|
||||
CHECK_FALSE(rules.tells);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("switch run through: the log line") {
|
||||
CHECK(sf::run_through_text("zwr02", "autotest_eu07_td_x", 23.4) == "switch zwr02 run through by autotest_eu07_td_x at 23 km/h");
|
||||
CHECK(sf::run_through_text("zwr02", "sm42-123", -7.6) == "switch zwr02 run through by sm42-123 at 8 km/h");
|
||||
CHECK(sf::run_through_text("", "sm42-123", 5.0) == "switch (unnamed) run through by sm42-123 at 5 km/h");
|
||||
}
|
||||
|
||||
@@ -686,6 +686,9 @@ private:
|
||||
void update_forks();
|
||||
// running forked past what the vehicle takes, as physics.derailment has it
|
||||
void fork_past( fork_watch &Watch, int const Side, std::string const &Why );
|
||||
// the leading axle ran onto the Switch, run through before, from its points: its flange pushes the loose blades over,
|
||||
// the axles after it run forked (physics.derailment new), or the log tells they would (monitor)
|
||||
void split_at( TTrack &Switch );
|
||||
|
||||
std::string rTypeName; // nazwa typu pojazdu
|
||||
std::string rReplacableSkin; // nazwa tekstury pojazdu
|
||||
|
||||
@@ -371,12 +371,16 @@ void TDynamicObject::watch_fork_entries( double const Distance ) {
|
||||
auto const &trailing { forwards ? Axle1 : Axle0 };
|
||||
auto *const leadingentry { forwards ? frontentry : rearentry };
|
||||
auto *const trailingentry { forwards ? rearentry : frontentry };
|
||||
if( leadingentry != nullptr
|
||||
&& leadingentry->run_through() ) {
|
||||
split_at( *leadingentry );
|
||||
}
|
||||
if( trailingentry != nullptr ) {
|
||||
auto const ahead { path_ahead( leading, trailingentry ) };
|
||||
if( switch_fork::forked( trailing.GetPath(), ahead ) ) {
|
||||
m_forkbogies = { trailingentry, false };
|
||||
WriteLog(
|
||||
"Switch \"" + switch_name( trailingentry ) + "\" thrown under " + physics->Name
|
||||
"Switch \"" + switch_name( trailingentry ) + ( trailingentry->run_through() ? "\", run through before, under " : "\" thrown under " ) + physics->Name
|
||||
+ ": running forked, its " + ( forwards ? "rear" : "front" ) + " bogie took way " + std::to_string( trailing.GetPath() )
|
||||
+ ", the " + ( forwards ? "front" : "rear" ) + " one way " + std::to_string( *ahead ) );
|
||||
}
|
||||
@@ -388,7 +392,7 @@ void TDynamicObject::watch_fork_entries( double const Distance ) {
|
||||
if( switch_fork::forked( leading.GetPath(), ahead ) ) {
|
||||
m_forkends[ end ] = { leadingentry, false };
|
||||
WriteLog(
|
||||
"Switch \"" + switch_name( leadingentry ) + "\" thrown under " + physics->Name
|
||||
"Switch \"" + switch_name( leadingentry ) + ( leadingentry->run_through() ? "\", run through before, under " : "\" thrown under " ) + physics->Name
|
||||
+ ": running forked, it took way " + std::to_string( leading.GetPath() )
|
||||
+ ", " + physics->Neighbours[ end ].vehicle->physics->Name + " coupled at its " + ( end == VehicleEnd::front ? "front" : "rear" )
|
||||
+ " way " + std::to_string( *ahead ) );
|
||||
@@ -468,6 +472,33 @@ void TDynamicObject::update_forks() {
|
||||
}
|
||||
}
|
||||
|
||||
void TDynamicObject::split_at( TTrack &Switch ) {
|
||||
|
||||
if( physics->DamageFlag.HasAll( VehicleDamage::derailed )
|
||||
|| false == TestFlag( physics->CategoryFlag, 1 )
|
||||
|| ( Switch.iCategoryFlag & 1 ) == 0
|
||||
|| DebugModeFlag ) {
|
||||
return;
|
||||
}
|
||||
auto const rules { run_through_rules() };
|
||||
auto const set { Switch.SwitchExtension->CurrentIndex & 1 };
|
||||
if( rules.tells ) {
|
||||
WriteLog(
|
||||
"derailment monitor: " + physics->Name + " ran onto switch \"" + switch_name( &Switch ) + "\" from its points, run through before:"
|
||||
" physics.derailment new pushes its loose blades over to way " + std::to_string( switch_fork::pushed_over( set ) )
|
||||
+ " under it, its axles after the first one run forked" );
|
||||
}
|
||||
if( false == rules.derails ) {
|
||||
return;
|
||||
}
|
||||
// the flange of its leading wheel pushes the loose blades over: the axles after it take the other way, as at a switch
|
||||
// thrown under the vehicle, and running forked derails it (update_forks())
|
||||
WriteLog(
|
||||
"Switch \"" + switch_name( &Switch ) + "\", run through before, gave way under " + physics->Name
|
||||
+ " running onto it from its points: its blades pushed over to way " + std::to_string( switch_fork::pushed_over( set ) ) );
|
||||
Switch.Switch( switch_fork::pushed_over( set ) );
|
||||
}
|
||||
|
||||
void TDynamicObject::fork_past( fork_watch &Watch, int const Side, std::string const &Why ) {
|
||||
|
||||
if( physics->DamageFlag.HasAll( VehicleDamage::derailed )
|
||||
@@ -478,7 +509,13 @@ void TDynamicObject::fork_past( fork_watch &Watch, int const Side, std::string c
|
||||
switch( Global.derailment ) {
|
||||
case global_settings::derailment_model::physical: {
|
||||
Watch.told = true;
|
||||
physics->derail_forked( Side, Why );
|
||||
if( Watch.Switch->run_through() ) {
|
||||
// the loose blades of a switch run through before put it on the two ways: split by the switch
|
||||
physics->derail_at_switch( Side, derailment::reason::split_switch, "running forked on a switch run through before, " + Why );
|
||||
}
|
||||
else {
|
||||
physics->derail_forked( Side, Why );
|
||||
}
|
||||
break;
|
||||
}
|
||||
case global_settings::derailment_model::monitor: {
|
||||
|
||||
@@ -1897,6 +1897,11 @@ switch_event::run_() {
|
||||
for( auto &target : m_targets ) {
|
||||
auto *targettrack { static_cast<TTrack *>( std::get<scene::basic_node *>( target ) ) };
|
||||
if( targettrack == nullptr ) { continue; }
|
||||
// a switch run through stays as the wheels left it, out of use until checked (physics.derailment new)
|
||||
if( targettrack->eType == tt_Switch
|
||||
&& targettrack->throw_refused( m_switchstate ) ) {
|
||||
continue;
|
||||
}
|
||||
// event effect code
|
||||
targettrack->Switch(
|
||||
m_switchstate,
|
||||
|
||||
+71
-1
@@ -2321,12 +2321,45 @@ double TTrack::nose_throw() const {
|
||||
|
||||
namespace {
|
||||
|
||||
// the vehicle (o) ran through the switch, its blades pushed over already: the switch is damaged, the log and the scenery
|
||||
// told, and a vehicle that did it too fast derails (physics.derailment new)
|
||||
void mark_run_through( TTrack &Track, TDynamicObject &o ) {
|
||||
|
||||
auto const speed { o.GetVelocity() };
|
||||
Track.SwitchExtension->m_runthrough = true;
|
||||
WriteLog( switch_fork::run_through_text( Track.name(), o.name(), speed ) );
|
||||
simulation::State.report_run_through( Track, o, speed );
|
||||
if( false == switch_fork::run_through_derails( speed )
|
||||
|| o.physics->DamageFlag.HasAll( VehicleDamage::derailed )
|
||||
|| DebugModeFlag ) {
|
||||
return;
|
||||
}
|
||||
auto const rules { run_through_rules() };
|
||||
auto const why { std::format(
|
||||
"running through switch \"{}\" set the other way at {:.0f} km/h, more than the {:.0f} km/h its blades and lock are taken to stand",
|
||||
Track.name(), speed, switch_fork::run_through_speed ) };
|
||||
if( rules.derails ) {
|
||||
o.physics->derail_at_switch( 0, derailment::reason::run_through, why );
|
||||
}
|
||||
else if( rules.tells ) {
|
||||
WriteLog( "derailment monitor: " + o.name() + " derailed " + why );
|
||||
}
|
||||
}
|
||||
|
||||
// the switch run through against the way it's set: the event of that queued, the blades pushed over, a vehicle derailed at a movable nose
|
||||
void trail_switch( TTrack &Track, int const i, TDynamicObject const *o ) {
|
||||
void trail_switch( TTrack &Track, int const i, TDynamicObject *o ) {
|
||||
|
||||
if( i == Track.SwitchExtension->CurrentIndex ) {
|
||||
return;
|
||||
}
|
||||
// a vehicle running on the rails of the scenery: not one laid onto the tracks as the scenery loads, nor one at a stand
|
||||
auto const runsthrough {
|
||||
o != nullptr
|
||||
&& simulation::is_ready
|
||||
&& ( Track.iCategoryFlag & 1 ) != 0
|
||||
&& TestFlag( o->physics->CategoryFlag, 1 )
|
||||
&& o->GetVelocity() > 0.01
|
||||
&& switch_fork::runs_through( i, Track.SwitchExtension->CurrentIndex ) };
|
||||
switch (i)
|
||||
{
|
||||
case 0:
|
||||
@@ -2346,10 +2379,47 @@ void trail_switch( TTrack &Track, int const i, TDynamicObject const *o ) {
|
||||
// the wheels can't push the nose of the frog over, the vehicle runs off the rails at it
|
||||
o->physics->Derail( TRAILED_SWITCH );
|
||||
}
|
||||
if( runsthrough ) {
|
||||
mark_run_through( Track, *o );
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
switch_fork::run_through_rules run_through_rules() {
|
||||
|
||||
switch( Global.derailment ) {
|
||||
case global_settings::derailment_model::physical: { return switch_fork::rules_of( switch_fork::run_through_model::physical ); }
|
||||
case global_settings::derailment_model::monitor: { return switch_fork::rules_of( switch_fork::run_through_model::monitor ); }
|
||||
default: { return switch_fork::rules_of( switch_fork::run_through_model::legacy ); }
|
||||
}
|
||||
}
|
||||
|
||||
bool TTrack::run_through() const {
|
||||
|
||||
return eType == tt_Switch && SwitchExtension != nullptr && SwitchExtension->m_runthrough;
|
||||
}
|
||||
|
||||
bool TTrack::throw_refused( int const State ) {
|
||||
|
||||
if( false == run_through()
|
||||
|| ( State & 1 ) == SwitchExtension->CurrentIndex ) {
|
||||
return false;
|
||||
}
|
||||
auto const rules { run_through_rules() };
|
||||
if( false == SwitchExtension->m_throwrefusaltold ) {
|
||||
if( rules.refuses_throws ) {
|
||||
SwitchExtension->m_throwrefusaltold = true;
|
||||
WriteLog( "switch " + name() + " was run through: out of use until checked, its throws refused" );
|
||||
}
|
||||
else if( rules.tells ) {
|
||||
SwitchExtension->m_throwrefusaltold = true;
|
||||
WriteLog( "derailment monitor: switch " + name() + " was run through, physics.derailment new refuses its throws" );
|
||||
}
|
||||
}
|
||||
return rules.refuses_throws;
|
||||
}
|
||||
|
||||
bool TTrack::SwitchForced(int i, TDynamicObject *o)
|
||||
{ // rozprucie rozjazdu
|
||||
if (SwitchExtension)
|
||||
|
||||
@@ -27,6 +27,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "model/material.h"
|
||||
#include "scene/scenenode.h"
|
||||
#include "utilities/Names.h"
|
||||
#include "world/switchfork.h"
|
||||
|
||||
namespace scene {
|
||||
class basic_cell;
|
||||
@@ -55,6 +56,9 @@ enum TEnvironmentType {
|
||||
|
||||
class basic_event;
|
||||
class TTrack;
|
||||
|
||||
// what the physics.derailment set does about a switch run through (world/switchfork.h)
|
||||
switch_fork::run_through_rules run_through_rules();
|
||||
class TGroundNode;
|
||||
class TSubRect;
|
||||
class TTraction;
|
||||
@@ -108,6 +112,8 @@ class TSwitchExtension
|
||||
TTrack *pNextAnim = nullptr; // następny tor do animowania
|
||||
basic_event *evPlus = nullptr,
|
||||
*evMinus = nullptr; // zdarzenia sygnalizacji rozprucia
|
||||
bool m_runthrough { false }; // run through by a vehicle: damaged for the rest of the run (world/switchfork.h)
|
||||
bool m_throwrefusaltold { false }; // the log told a throw of it was (or, monitor, would be) refused
|
||||
float fVelocity = -1.0; // maksymalne ograniczenie prędkości (ustawianej eventem)
|
||||
glm::dvec3 vTrans; // docelowa translacja przesuwnicy
|
||||
material_handle m_material3 = 0; // texture of auto generated switch trackbed
|
||||
@@ -336,6 +342,11 @@ public:
|
||||
std::vector<TTrack const *> join_switches(); // the switches the free ends were joined to, one for each joint
|
||||
bool Switch(int i, float const t = -1.f, float const d = -1.f);
|
||||
bool SwitchForced(int i, TDynamicObject *o);
|
||||
// a switch run through by a vehicle (world/switchfork.h), damaged
|
||||
bool run_through() const;
|
||||
// a throw of the switch to the State by an event: physics.derailment new refuses it at a switch run through,
|
||||
// monitor tells it would. true when it's refused, the log told once for the switch
|
||||
bool throw_refused( int State );
|
||||
int CrossSegment(int from, int into);
|
||||
inline int GetSwitchState() {
|
||||
return SwitchExtension ? SwitchExtension->CurrentIndex : -1; };
|
||||
|
||||
@@ -12,6 +12,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <format>
|
||||
#include <numbers>
|
||||
|
||||
namespace switch_fork {
|
||||
@@ -86,4 +87,29 @@ state coupling(double const Offset) {
|
||||
return {std::abs(Offset), buffer_head_width};
|
||||
}
|
||||
|
||||
bool runs_through(int const Path, int const Set) {
|
||||
return (Path == 0 || Path == 1) && Path != (Set & 1);
|
||||
}
|
||||
|
||||
int pushed_over(int const Set) {
|
||||
return 1 - (Set & 1);
|
||||
}
|
||||
|
||||
bool run_through_derails(double const Speed) {
|
||||
return std::abs(Speed) > run_through_speed;
|
||||
}
|
||||
|
||||
run_through_rules rules_of(run_through_model const Model) {
|
||||
switch (Model) {
|
||||
case run_through_model::physical: return {true, true, false};
|
||||
case run_through_model::monitor: return {false, false, true};
|
||||
case run_through_model::legacy:
|
||||
default: return {};
|
||||
}
|
||||
}
|
||||
|
||||
std::string run_through_text(std::string_view const Switch, std::string_view const Vehicle, double const Speed) {
|
||||
return std::format("switch {} run through by {} at {:.0f} km/h", Switch.empty() ? std::string_view{"(unnamed)"} : Switch, Vehicle, std::abs(Speed));
|
||||
}
|
||||
|
||||
} // namespace switch_fork
|
||||
|
||||
@@ -12,6 +12,8 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include <array>
|
||||
#include <cstddef>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
|
||||
// a switch thrown under a train (forked running, "jazda widłowa"). the wheels past the tips of the blades stay on the
|
||||
@@ -92,4 +94,50 @@ state coupling(double Offset);
|
||||
// atan2(-x, z)
|
||||
double heading(double X, double Z);
|
||||
|
||||
// ---- a switch run through ("rozprucie zwrotnicy")
|
||||
//
|
||||
// an axle coming onto a switch from its frog end by the way the switch isn't set to: its wheel flanges push the blades
|
||||
// over to that way, against the drive and the lock. the blades follow the wheels, so the train goes on along the way it
|
||||
// came by (TTrack::SwitchForced(), as it always did here), but the switch is damaged: its blades may be bent or no longer
|
||||
// fit the stock rail, its lock and its drive broken, and the signal box loses the detection of its position. the rules
|
||||
// of PKP PLK take such a switch out of use until it's been checked on site (Ir-1 § 5 ust. 14, Id-4 annex 17, Ie-10 (E-18)
|
||||
// §29 ust. 5 and §30), and forbid the train that ran through it to back over it (Ir-9 § 9 ust. 10): the blades, locked no
|
||||
// more, may gape or stand between the two ways, and a move from the points splits on them. here the switch stays damaged
|
||||
// for the rest of the run: physics.derailment new refuses the throws of the events (the signaller's levers among them),
|
||||
// and the flange of the leading wheel of each vehicle running onto it from its points pushes the loose blades over to the
|
||||
// other way: the axles after it take that way, the vehicle runs forked and the limits of forked running above derail it
|
||||
// (TDynamicObject::split_at()). monitor tells both in the log and changes nothing; old and off neither. every switch is
|
||||
// taken as trailable, as it always was here: it's thrown by the wheels, not left between the ways
|
||||
|
||||
// the axle came onto the switch from its frog end by the way Path [0, 1]; the switch is set the Set way: it runs through
|
||||
bool runs_through(int Path, int Set);
|
||||
|
||||
// the way the loose blades of a switch run through before, set the Set way, go to under the flange of a wheel running
|
||||
// onto it from its points: the other one
|
||||
int pushed_over(int Set);
|
||||
|
||||
// the speed [km/h] above which running through a switch derails the vehicle that does it (physics.derailment new). no
|
||||
// rule or report gives one. the run-throughs the Polish accident board looked into didn't derail the train that ran
|
||||
// through: an SA138 at 35-39 km/h (PKBWK 2/2025, Gdynia Główna 2023), an EMU at about 53 km/h (PKBWK 6/2024,
|
||||
// Skierniewice 2023), only the switch and its point machine were damaged. the limit is taken above them, so that none of
|
||||
// those would derail here; a guess, to be replaced by a number from a source
|
||||
inline constexpr double run_through_speed{60.0};
|
||||
bool run_through_derails(double Speed);
|
||||
|
||||
// what physics.derailment does about a switch run through
|
||||
enum class run_through_model {
|
||||
legacy, // old, off: the log line and the damage only
|
||||
monitor, // the log tells what new would do
|
||||
physical // new
|
||||
};
|
||||
struct run_through_rules {
|
||||
bool refuses_throws{false}; // the throws of the events are refused
|
||||
bool derails{false}; // a vehicle the switch splits, or that runs through it too fast, leaves the rails
|
||||
bool tells{false}; // the log tells what new would do: a throw it would refuse, a vehicle it would derail
|
||||
};
|
||||
run_through_rules rules_of(run_through_model Model);
|
||||
|
||||
// the log line of a run-through: "switch <name> run through by <vehicle> at <speed> km/h"
|
||||
std::string run_through_text(std::string_view Switch, std::string_view Vehicle, double Speed);
|
||||
|
||||
} // namespace switch_fork
|
||||
|
||||
Reference in New Issue
Block a user