18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-12-02 11:56:50 +01:00

Merge staging into feat/derailment-event

This commit is contained in:
jerrrrycho
2026-11-29 18:01:06 +01:00
189 changed files with 7375 additions and 5958 deletions
+100 -100
View File
@@ -106,8 +106,8 @@ void physics::Vehicle::CollisionDetect(VehicleEnd const End, double const dt)
// the velocities along this vehicle's axis: the other vehicle's one is turned around when the vehicles face each
// other (touch with the same ends), as in CouplerForce()
auto const otherdirection{DirPatch(End, otherend)};
auto velocity{V};
auto othervehiclevelocity{othervehicle->V * otherdirection};
auto velocity{travelSpeed};
auto othervehiclevelocity{othervehicle->travelSpeed * otherdirection};
// calculate collision force and new velocities for involved vehicles
auto const VirtualCoupling{(thiscoupler.CouplingFlag == Coupling::none)};
auto CCF{0.0};
@@ -116,12 +116,12 @@ void physics::Vehicle::CollisionDetect(VehicleEnd const End, double const dt)
{
case VehicleEnd::front:
{
CCF = ComputeCollision(velocity, othervehiclevelocity, TotalMass, othervehicle->TotalMass, loss, VirtualCoupling) / dt;
CCF = ComputeCollision(velocity, othervehiclevelocity, totalMass, othervehicle->totalMass, loss, VirtualCoupling) / dt;
break; // yB: ej ej ej, a po
}
case VehicleEnd::rear:
{
CCF = ComputeCollision(othervehiclevelocity, velocity, othervehicle->TotalMass, TotalMass, loss, VirtualCoupling) / dt;
CCF = ComputeCollision(othervehiclevelocity, velocity, othervehicle->totalMass, totalMass, loss, VirtualCoupling) / dt;
break;
}
default:
@@ -152,11 +152,11 @@ void physics::Vehicle::CollisionDetect(VehicleEnd const End, double const dt)
WriteLog("Bad driving: " + Name + " and " + othervehicle->Name + " collided with velocity " + to_string(velocitydifference, 0) + " km/h");
}
if (velocitydifference > SafeCollisionVelocity * (TotalMass / othervehicle->TotalMass))
if (velocitydifference > SafeCollisionVelocity * (totalMass / othervehicle->totalMass))
{
Derail(COLLISION);
}
if (velocitydifference > SafeCollisionVelocity * (othervehicle->TotalMass / TotalMass))
if (velocitydifference > SafeCollisionVelocity * (othervehicle->totalMass / totalMass))
{
othervehicle->Derail(COLLISION);
}
@@ -171,20 +171,20 @@ void physics::Vehicle::CollisionDetect(VehicleEnd const End, double const dt)
// the crush, the vehicles coupled to the wall push it on (crush_hit())
auto const coupled{thiscoupler.CouplingFlag != Coupling::none};
auto const wall = [crushing, coupled](physics::Vehicle const &Vehicle) {
return Vehicle.DamageFlag.HasAll(VehicleDamage::derailed) && (false == crushing || (Vehicle.Derailed == derailment::outcome::none && false == coupled));
return Vehicle.DamageFlag.HasAll(VehicleDamage::derailed) && (false == crushing || (Vehicle.derailOutcome == derailment::outcome::none && false == coupled));
};
if (false == wall(*this))
{
auto const accelerationchange{(velocity - V) / dt};
AccS += accelerationchange * accelerationspike;
V = velocity;
auto const accelerationchange{(velocity - travelSpeed) / dt};
accS += accelerationchange * accelerationspike;
travelSpeed = velocity;
}
if (false == wall(*othervehicle))
{
auto const othervehiclenewvelocity{othervehiclevelocity * otherdirection}; // back along the other vehicle's axis
auto const othervehicleaccelerationchange{(othervehiclenewvelocity - othervehicle->V) / dt};
othervehicle->AccS += othervehicleaccelerationchange * accelerationspike;
othervehicle->V = othervehiclenewvelocity;
auto const othervehicleaccelerationchange{(othervehiclenewvelocity - othervehicle->travelSpeed) / dt};
othervehicle->accS += othervehicleaccelerationchange * accelerationspike;
othervehicle->travelSpeed = othervehiclenewvelocity;
}
}
@@ -199,7 +199,7 @@ void physics::Vehicle::damage_coupler(VehicleEnd const End)
} // HACK: don't break articulated couplings no matter what
if (DamageFlag.Set(VehicleDamage::coupling))
EventFlag = true;
eventFlag = true;
auto const hosetorn{thiscoupler.CouplingFlag.HasAll(Coupling::brakeHose)};
if (hosetorn)
@@ -238,7 +238,7 @@ collision::vehicle_kind physics::Vehicle::collision_kind() const
auto const unit{is_multiple_unit()};
auto const passengers{std::any_of(LoadAttributes.begin(), LoadAttributes.end(), [](auto const &Load) { return ToLower(Load.name).starts_with("passenger"); })};
// a coach heats its compartments; the crash zone is a matter of each end (crush_of())
return collision::kind_of(powered, unit || passengers || (false == powered && trainHeating.power > 0.0), false);
return collision::kind_of(powered, unit || passengers || (false == powered && trainHeating.config.power > 0.0), false);
}
collision::crush_curve physics::Vehicle::crush_curve_at(VehicleEnd const End) const
@@ -248,7 +248,7 @@ collision::crush_curve physics::Vehicle::crush_curve_at(VehicleEnd const End) co
double physics::Vehicle::buffer_height_at(VehicleEnd const End) const
{
auto const loadshare{MaxLoad > 0.f ? LoadAmount / MaxLoad : 0.0};
auto const loadshare{maxLoad > 0.f ? loadAmount / maxLoad : 0.0};
return collision::buffer_height(Couplers[End].collision, collision_kind(), loadshare);
}
@@ -259,19 +259,19 @@ void physics::Vehicle::derail_in_collision(DerailReason const Reason, std::strin
return;
}
// upright, it slides on the sleepers and keeps passing the forces on
Derailed = derailment::outcome::off_rails;
DerailCause = derail_motion::cause::collision;
DerailAcceleration = 0.0;
DerailSide = 0;
CollisionDerail = Reason;
note_derailment(Reason == COLLISION_OVERRIDE ? derailment::reason::overriding : derailment::reason::pushed_off);
EventFlag = true;
derailOutcome = derailment::outcome::off_rails;
derailCause = derail_motion::cause::collision;
derailAcceleration = 0.0;
derailSide = 0;
collisionDerail = Reason;
noteDerailment(Reason == COLLISION_OVERRIDE ? derailment::reason::overriding : derailment::reason::pushed_off);
eventFlag = true;
MainSwitch(false, range_t::local);
if (Vel < 5.0)
{
// HACK: prevent permanent axle spin in static vehicle after a collision
nrot = 0.0;
SlippingWheels = false;
nrotValue = 0.0;
slippingWheels = false;
}
// the brake hoses tear: the brake pipe vents and the rest of the train brakes in emergency
tear_brake_hoses(*this);
@@ -373,15 +373,15 @@ bool physics::Vehicle::crush_hit(VehicleEnd const End, double const dt)
// train. the vehicles coupled to it push it on, as the train behind a derailed vehicle does: a wall to them, it
// stopped the whole train at once, and the vehicles behind it crushed by the energy of the train
auto const coupled{thiscoupler.CouplingFlag != Coupling::none};
auto const wall{false == coupled && DamageFlag.HasAll(VehicleDamage::derailed) && Derailed == derailment::outcome::none};
auto const otherwall{false == coupled && othervehicle->DamageFlag.HasAll(VehicleDamage::derailed) && othervehicle->Derailed == derailment::outcome::none};
auto const wall{false == coupled && DamageFlag.HasAll(VehicleDamage::derailed) && derailOutcome == derailment::outcome::none};
auto const otherwall{false == coupled && othervehicle->DamageFlag.HasAll(VehicleDamage::derailed) && othervehicle->derailOutcome == derailment::outcome::none};
if (wall && otherwall)
{
return false;
}
constexpr double immovable{1e12};
auto const mass{wall ? immovable : TotalMass};
auto const othermass{otherwall ? immovable : othervehicle->TotalMass};
auto const mass{wall ? immovable : totalMass};
auto const othermass{otherwall ? immovable : othervehicle->totalMass};
auto const loss{physical ? coupler_physics::solid_hit_loss(thiscoupler.physics, othercoupler.physics) : (thiscoupler.beta + othercoupler.beta) / 2.0};
auto const firstcurve{crush_curve_at(End)};
@@ -411,8 +411,8 @@ bool physics::Vehicle::crush_hit(VehicleEnd const End, double const dt)
collision::override_input climbing;
climbing.crush1 = Crush1;
climbing.crush2 = Crush2;
climbing.mass1 = TotalMass - Mred;
climbing.mass2 = othervehicle->TotalMass - othervehicle->Mred;
climbing.mass1 = totalMass - mred;
climbing.mass2 = othervehicle->totalMass - othervehicle->mred;
climbing.height1 = buffer_height_at(End);
climbing.height2 = othervehicle->buffer_height_at(otherend);
climbing.anticlimbers = collision::anticlimber_of(thiscoupler.collision, collision_kind()) && collision::anticlimber_of(othercoupler.collision, othervehicle->collision_kind());
@@ -426,7 +426,7 @@ bool physics::Vehicle::crush_hit(VehicleEnd const End, double const dt)
{
thiscoupler.crush_monitored = true;
othercoupler.crush_monitored = true;
++crush_reports;
++crushreportsValue;
auto const crush1{thiscoupler.crush + hit.crush1};
auto const crush2{othercoupler.crush + hit.crush2};
auto const climbed{collision::override_of(climbing_of(crush1, crush2))};
@@ -437,8 +437,8 @@ bool physics::Vehicle::crush_hit(VehicleEnd const End, double const dt)
: std::string{"both would stay on the rails"}};
WriteLog(std::format("collision monitor: {} and {} collided at {:.0f} km/h: the {} end of {} ({:.1f} t {}) would crush by {:.2f} m, the {} end of {} ({:.1f} t {}) by {:.2f} m, "
"at {:.0f} kN; draw gear {}; {}",
Name, othervehicle->Name, closing * 3.6, end_name(End), Name, TotalMass / 1000.0, kind_name(collision_kind()), crush1, end_name(otherend), othervehicle->Name,
othervehicle->TotalMass / 1000.0, kind_name(othervehicle->collision_kind()), crush2, hit.force / 1000.0, torn ? "torn off" : "holds", outcome));
Name, othervehicle->Name, closing * 3.6, end_name(End), Name, totalMass / 1000.0, kind_name(collision_kind()), crush1, end_name(otherend), othervehicle->Name,
othervehicle->totalMass / 1000.0, kind_name(othervehicle->collision_kind()), crush2, hit.force / 1000.0, torn ? "torn off" : "holds", outcome));
}
return false;
}
@@ -463,11 +463,11 @@ bool physics::Vehicle::crush_hit(VehicleEnd const End, double const dt)
auto const apart{End == VehicleEnd::front ? -1.0 : 1.0};
if (false == wall)
{
V += apart * hit.impulse / mass;
travelSpeed += apart * hit.impulse / mass;
}
if (false == otherwall)
{
othervehicle->V -= apart * hit.impulse / othermass * otherdirection;
othervehicle->travelSpeed -= apart * hit.impulse / othermass * otherdirection;
}
record_hit(thiscoupler, hit.force, hit.duration);
record_hit(othercoupler, hit.force, hit.duration);
@@ -481,8 +481,8 @@ bool physics::Vehicle::crush_hit(VehicleEnd const End, double const dt)
return std::format("{} {:.1f} t {}, {} end crushed {:.2f} m, gives at {:.0f} kN; {} {:.1f} t {}, {} end crushed {:.2f} m, gives at {:.0f} kN; force {:.0f} kN, springs {:.0f} kN, "
"closing at {:.1f} km/h at the start of the step; energy {:.0f} kJ of the motion and {:.0f} kJ in the buffers, past the {:.0f} kJ they take in, "
"{:.0f} kJ crushed in the contact",
Name, TotalMass / 1000.0, kind_name(collision_kind()), end_name(End), thiscoupler.crush, firstcurve.force(thiscoupler.crush) / 1000.0, othervehicle->Name,
othervehicle->TotalMass / 1000.0, kind_name(othervehicle->collision_kind()), end_name(otherend), othercoupler.crush,
Name, totalMass / 1000.0, kind_name(collision_kind()), end_name(End), thiscoupler.crush, firstcurve.force(thiscoupler.crush) / 1000.0, othervehicle->Name,
othervehicle->totalMass / 1000.0, kind_name(othervehicle->collision_kind()), end_name(otherend), othercoupler.crush,
secondcurve.force(othercoupler.crush) / 1000.0, hit.force / 1000.0, springs / 1000.0, input.start_velocity * 3.6, kinetic / 1000.0,
thiscoupler.contact.absorbed() / 1000.0, capacity / 1000.0, thiscoupler.contact.crush_work() / 1000.0);
};
@@ -549,11 +549,11 @@ void physics::Vehicle::check_pushed_off(double const dt, double const Distance)
return;
}
collision::pushed_vehicle vehicle;
vehicle.mass = TotalMass - Mred;
vehicle.axles = NAxles > 0 ? NAxles : 4;
vehicle.mass = totalMass - mred;
vehicle.axles = nAxles > 0 ? nAxles : 4;
vehicle.length = Dim.L;
vehicle.pivots = BDist;
vehicle.axle_base = ADist > 0.0 ? ADist : BDist;
vehicle.pivots = bDist;
vehicle.axle_base = aDist > 0.0 ? aDist : bDist;
auto climbs{false};
auto distance{0.0};
@@ -671,9 +671,9 @@ double physics::Vehicle::centre_of_gravity() const
{
auto const kind{EngineType == TEngineType::None ? derailment::vehicle_class::unpowered : derailment::vehicle_class::powered};
auto const empty{CentreOfGravity > 0.0 ? CentreOfGravity : derailment::default_centre_of_gravity(Dim.H, kind)};
auto const loadmass{TotalMass - Mass - Mred};
auto const loadshare{MaxLoad > 0.f ? LoadAmount / MaxLoad : 1.0};
return derailment::loaded_centre_of_gravity(empty, Mass, loadmass, loadshare, Floor, Dim.H);
auto const loadmass{totalMass - emptyMass - mred};
auto const loadshare{maxLoad > 0.f ? loadAmount / maxLoad : 1.0};
return derailment::loaded_centre_of_gravity(empty, emptyMass, loadmass, loadshare, Floor, Dim.H);
}
void physics::Vehicle::check_derailment(TTrackShape const &Shape, TTrackParam const &Track, double const Distance)
@@ -684,10 +684,10 @@ void physics::Vehicle::check_derailment(TTrackShape const &Shape, TTrackParam co
return;
}
derailment::vehicle_state vehicle;
vehicle.mass = TotalMass - Mred;
vehicle.axles = NAxles > 0 ? NAxles : 4;
vehicle.mass = totalMass - mred;
vehicle.axles = nAxles > 0 ? nAxles : 4;
vehicle.length = Dim.L;
vehicle.axle_base = ADist > 0.0 ? ADist : BDist;
vehicle.axle_base = aDist > 0.0 ? aDist : bDist;
vehicle.centre_of_gravity = centre_of_gravity();
for (auto const end : VehicleEnds)
{
@@ -709,7 +709,7 @@ void physics::Vehicle::check_derailment(TTrackShape const &Shape, TTrackParam co
track.buckle_curvature = Shape.buckle_curvature;
track.damage = Track.DamageFlag;
auto const verdict{derailment_monitor.update(vehicle, track, V, Distance)};
auto const verdict{derailment_monitor.update(vehicle, track, travelSpeed, Distance)};
if (verdict.result == derailment::outcome::none)
{
return;
@@ -725,8 +725,8 @@ void physics::Vehicle::check_derailment(TTrackShape const &Shape, TTrackParam co
return;
}
derailment_reported = Track.Name;
++derailment_reports;
WriteLog("derailment monitor: " + Name + " " + derailment::report(verdict, vehicle, track, V, Track.Name != nullptr ? *Track.Name : std::string{}));
++derailmentreportsValue;
WriteLog("derailment monitor: " + Name + " " + derailment::report(verdict, vehicle, track, travelSpeed, Track.Name != nullptr ? *Track.Name : std::string{}));
}
void physics::Vehicle::derail(derailment::verdict const &Verdict, derailment::vehicle_state const &Vehicle, derailment::track_state const &Track, std::string const *TrackName)
@@ -735,20 +735,20 @@ void physics::Vehicle::derail(derailment::verdict const &Verdict, derailment::ve
{
return;
}
Derailed = Verdict.result;
DerailCause = Verdict.result == derailment::outcome::overturned ? derail_motion::cause::overturned : derail_motion::cause::off_rails;
derailOutcome = Verdict.result;
derailCause = Verdict.result == derailment::outcome::overturned ? derail_motion::cause::overturned : derail_motion::cause::off_rails;
// a buckle under it is what derailed it, whichever way it went
note_derailment(Track.buckle_curvature != 0.0 ? derailment::reason::buckle :
Verdict.result == derailment::outcome::overturned ? derailment::reason::overturned :
derailment::reason::flange_climb);
noteDerailment(Track.buckle_curvature != 0.0 ? derailment::reason::buckle :
Verdict.result == derailment::outcome::overturned ? derailment::reason::overturned :
derailment::reason::flange_climb);
// out of the curve; a buckle bending the line against the curve more than the curve does throws it into the curve
DerailAcceleration = std::abs(Track.radius) > 1e-3 && derailment::line_curvature(Track) < 0.0 ? -Verdict.acceleration : Verdict.acceleration;
DerailSide = 0;
EventFlag = true;
derailAcceleration = std::abs(Track.radius) > 1e-3 && derailment::line_curvature(Track) < 0.0 ? -Verdict.acceleration : Verdict.acceleration;
derailSide = 0;
eventFlag = true;
MainSwitch(false, range_t::local);
// the brake hoses tear: the brake pipe vents and the rest of the train brakes in emergency
tear_brake_hoses(*this);
ErrorLog("Bad driving: " + Name + " " + derailment::report(Verdict, Vehicle, Track, V, TrackName != nullptr ? *TrackName : std::string{}));
ErrorLog("Bad driving: " + Name + " " + derailment::report(Verdict, Vehicle, Track, travelSpeed, TrackName != nullptr ? *TrackName : std::string{}));
if (Track.buckle_curvature != 0.0)
{
ErrorLog(std::format("Bad driving: {} derailed on buckled track, the buckle bending the line by 1/{:.0f} m {} the curve", Name, 1.0 / std::abs(Track.buckle_curvature),
@@ -759,26 +759,26 @@ void physics::Vehicle::derail(derailment::verdict const &Verdict, derailment::ve
void physics::Vehicle::rerail()
{
DamageFlag.Clear(VehicleDamage::derailed);
Derailed = derailment::outcome::none;
DerailedBy = derailment::reason::none;
DerailVelocity = 0.0;
derailOutcome = derailment::outcome::none;
derailedBy = derailment::reason::none;
derailVelocity = 0.0;
// and back on the track; what derailed it before has no say in how it leaves the track the next time
OffTrack.reset();
DerailCause = derail_motion::cause::off_rails;
DerailAcceleration = 0.0;
DerailSide = 0;
derailCause = derail_motion::cause::off_rails;
derailAcceleration = 0.0;
derailSide = 0;
derailment_monitor.reset();
derailment_distance = 0.0;
derailmentDistance = 0.0;
derailment_reported.reset();
// nor derailed in a collision
CollisionDerail = NONE;
collisionDerail = NONE;
pushed_off_monitor.reset();
// back on the axis of the track, which the derailment shifted the vehicle off aside and down (a road vehicle keeps
// its place on the road)
if (TestFlag(CategoryFlag, 1))
{
OffsetTrackH = 0.0;
OffsetTrackV = 0.0;
offsetTrackH = 0.0;
offsetTrackV = 0.0;
}
// a derailed vehicle which stopped sleeps (Global.physics_sleepheld) with the friction of the derailment in FStand and
// where the derailment put it, until something wakes it: the physics on, for the friction of the rails and its place on
@@ -789,8 +789,8 @@ void physics::Vehicle::rerail()
void physics::Vehicle::repair_damage()
{
DamageFlag = {};
EngDmgFlag = 0;
WheelFlat = 0.0;
equipmentFaults = {};
wheelFlat = 0.0;
brakes.alarmChain = false;
// the crushed ends rebuilt
for (auto &coupler : Couplers)
@@ -804,41 +804,41 @@ void physics::Vehicle::Derail(DerailReason const Reason)
{
if (DamageFlag.Set(VehicleDamage::derailed))
{
note_derailment(Reason == END_OF_TRACK ? derailment::reason::end_of_track :
Reason == TOO_HIGH_SPEED ? derailment::reason::overspeed :
Reason == GAUGE_MISMATCH ? derailment::reason::track_gauge :
Reason == WRONG_TRACK_TYPE ? derailment::reason::track_type :
Reason == COLLISION ? derailment::reason::collision :
Reason == TRAILED_SWITCH ? derailment::reason::trailed_switch :
derailment::reason::other);
EventFlag = true;
noteDerailment(Reason == END_OF_TRACK ? derailment::reason::end_of_track :
Reason == TOO_HIGH_SPEED ? derailment::reason::overspeed :
Reason == GAUGE_MISMATCH ? derailment::reason::track_gauge :
Reason == WRONG_TRACK_TYPE ? derailment::reason::track_type :
Reason == COLLISION ? derailment::reason::collision :
Reason == TRAILED_SWITCH ? derailment::reason::trailed_switch :
derailment::reason::other);
eventFlag = true;
MainSwitch(false, range_t::local);
auto const velocity{V};
AccS *= 0.65;
V *= 0.65;
auto const velocity{travelSpeed};
accS *= 0.65;
travelSpeed *= 0.65;
// physics.collisions new: the vehicles coupled to it lose the speed with it. the cut in a step stands for the
// train coming to a stop with the vehicle; the coupled ones keeping their speed would run into it at a third of
// the speed of the train, and crush their ends and ride up onto it for a hit no train had
if (Global.collisions == global_settings::collision_model::physical && TestFlag(CategoryFlag, 1))
{
change_train_velocity(V - velocity);
change_train_velocity(travelSpeed - velocity);
}
RunningShape.R = 0;
if (Vel < 5.0)
{
// HACK: prevent permanent axle spin in static vehicle after a collision
nrot = 0.0;
SlippingWheels = false;
nrotValue = 0.0;
slippingWheels = false;
}
// physics.derailment new: off the end of the track the vehicle runs on straight on its wheels, sliding on the
// ground as the vehicles the criteria derail do, and its brake hoses tear
if (Reason == END_OF_TRACK && Global.derailment == global_settings::derailment_model::physical && TestFlag(CategoryFlag, 1))
{
Derailed = derailment::outcome::off_rails;
DerailCause = derail_motion::cause::end_of_track;
DerailAcceleration = 0.0;
DerailSide = 0;
derailOutcome = derailment::outcome::off_rails;
derailCause = derail_motion::cause::end_of_track;
derailAcceleration = 0.0;
derailSide = 0;
tear_brake_hoses(*this);
}
@@ -858,15 +858,15 @@ void physics::Vehicle::Derail(DerailReason const Reason)
}
}
void physics::Vehicle::note_derailment(derailment::reason const Reason)
void physics::Vehicle::noteDerailment(derailment::reason const Reason)
{
DerailedBy = Reason;
DerailVelocity = std::abs(V) * 3.6;
derailedBy = Reason;
derailVelocity = std::abs(travelSpeed) * 3.6;
}
bool physics::Vehicle::leaves_track() const
{
return Global.derailment == global_settings::derailment_model::physical && TestFlag(CategoryFlag, 1) && DamageFlag.HasAll(VehicleDamage::derailed) && Derailed != derailment::outcome::none &&
return Global.derailment == global_settings::derailment_model::physical && TestFlag(CategoryFlag, 1) && DamageFlag.HasAll(VehicleDamage::derailed) && derailOutcome != derailment::outcome::none &&
false == OffTrack.active();
}
@@ -877,12 +877,12 @@ void physics::Vehicle::pull_off(int const Side, double const Acceleration, std::
return;
}
// upright, its flange climbs the rail the coupling pulls it over
Derailed = derailment::outcome::off_rails;
DerailCause = derail_motion::cause::pulled_off;
DerailAcceleration = Acceleration;
DerailSide = Side;
note_derailment(derailment::reason::pulled_off);
EventFlag = true;
derailOutcome = derailment::outcome::off_rails;
derailCause = derail_motion::cause::pulled_off;
derailAcceleration = Acceleration;
derailSide = Side;
noteDerailment(derailment::reason::pulled_off);
eventFlag = true;
MainSwitch(false, range_t::local);
tear_brake_hoses(*this);
derailment_monitor.reset();