mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-12-03 07:45:25 +01:00
a608373d94
Since #552 the state of physics::Vehicle and of its parts is private, and since #531 the vehicle, the AI and the cab live in other files under other names. The snapshot code is ported to that: - the state of a vehicle's physics is saved and loaded by physics::Vehicle::SnapshotSave() and SnapshotLoad() (physics/components/snapshot.cpp), with the tables of the variables in a nested snapshot_members; capture_mover() and apply_mover() only hand it the entry. The parts with private state (low voltage, line breaker, line contactors, protective relays, converter, air of the pantographs, compressor, air supply) give a plain Snapshot of it and take it back (TakeSnapshot(), RestoreSnapshot()); the rest goes through their queries and setters - the keys, their order and the numbers in them are unchanged, so the snapshots written before load: the fields that moved into the parts are mapped there (Mains to lineBreaker, PipePress to brakePipe, BrakeCtrlPos to brakes, dizel_* to diesel, hydro_* to torqueConverter and retarder, eimv to inductionMotor.state in the order of the old table, EngDmgFlag to equipmentFaults, ...) - TDynamicObject: the machinery of a vehicle (sections, rail joints, the passenger exchange) is saved by members of its own, as these are private now; MED_oldFED is the last ED demand of the consist's brake blending (ConsistBrakeBlending::LastElectrodynamicDemand()) - TController: the driving flags are saved as the bits of iDrivigFlags they were, the running brake test as the number of its stage, the uphill start and the braking shortfall from their structs; StaticBrakeTest, which is gone, is written as 0 and not read - the couplings take Coupling, CouplingSet and VehicleEnd; orders are DriverOrders - the unit tests of the snapshot of a vehicle use the queries and the parts
28 lines
563 B
C++
28 lines
563 B
C++
/*
|
|
This Source Code Form is subject to the
|
|
terms of the Mozilla Public License, v.
|
|
2.0. If a copy of the MPL was not
|
|
distributed with this file, You can
|
|
obtain one at
|
|
http://mozilla.org/MPL/2.0/.
|
|
*/
|
|
|
|
#include "stdafx.h"
|
|
#include "simulation/simulationsnapshotmover.h"
|
|
|
|
#include "physics/vehicle.h"
|
|
|
|
namespace simulation::snapshot {
|
|
|
|
void capture_mover(record &Entry, physics::Vehicle const &Mover)
|
|
{
|
|
Mover.SnapshotSave(Entry);
|
|
}
|
|
|
|
void apply_mover(physics::Vehicle &Mover, record const &Entry)
|
|
{
|
|
Mover.SnapshotLoad(Entry);
|
|
}
|
|
|
|
} // namespace simulation::snapshot
|