mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-12-02 22:25:23 +01:00
fbb9dc1e89
end and side were unscoped enums: front, rear, left and right sat in the
global namespace (the test PCH had to leave mover.h out for it), and an end
went into any int, a side into an end, without a word from the compiler. They
become enum class VehicleEnd and VehicleSide (physics/vehicletypes.h); the
names follow the rule for types, and leave "end" and "side" to the many
locals of that name. The numbers stay: front 0, rear 1, right 0, left 1.
- ByEnd<T> / BySide<T>: two values indexed by the enum, and by a number
where a loop or a format counts them. The arrays of the ends and the sides
are these now: Couplers, Neighbours, Pantographs, MotorBlowers, Lights,
iLights, Doors.instances, pVehicles, IsAnyDoor*, m_lighthints, vCoulpler,
m_couplersounds, m_mirrormotion, iInventory, and the voltages of the
couplers
- VehicleEnds / VehicleSides to go through them, Opposite() in place of
1 - end, NumberOf() where a number is needed
- the couplers and the collisions take the ends they work on as VehicleEnd:
CouplerForce, CouplerVelocityDifference, CollisionDetect, crush_hit,
CompatibleCoupling and the rest of their family, DirF, DirPatch, and of
the vehicle couple, uncouple, the adapters, off_track_gap, has_signal_on;
Attach, Dettach and DettachStatus have overloads by the ends
- neighbour_data::FacingEnd() and TCoupling::ConnectedEnd() give the end of
the other vehicle as VehicleEnd; the fields stay numbers, as they hold -1
and 2 for "none" in places
The walks along the consist (FirstFind, Neighbour, the AI's coupling and
uncoupling) still carry the ends as numbers; where one of them meets a typed
end, NumberOf() and EndOf() say so, and keep the number as it was.
Kept as it was, and worth a look: TDynamicObject::SetLights() switches the
headlights A/B off by CabActive with the cases end::front and end::rear, that
is CabActive 0 and 1, while CabActive is 1 or -1 for the cabs; the cases are
NumberOf(VehicleEnd::front / rear) now, the same numbers.
No change in behaviour: 1144/1144 tests, golden traces exact against staging
62f7a29b. betterRenderer/, not built, has had only end:: and side:: renamed.
64 lines
2.3 KiB
C++
64 lines
2.3 KiB
C++
#pragma once
|
|
|
|
#include <memory>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include "consist.h"
|
|
#include "drive.h"
|
|
#include "golden.h"
|
|
|
|
namespace test {
|
|
|
|
// a scenario of a test: a train of real vehicles (one vehicle is a train too), a driver in the front one,
|
|
// and a golden trace for each vehicle (data/golden/<Name>/<number of the vehicle>.csv) with the events of
|
|
// the scenario in them:
|
|
// test::scenario scenario{"doors/elf", test::channels::motion() + test::channels::doors()};
|
|
// scenario.add("elf_v1/21we-a", 1).add("elf_v1/21we-b").add("elf_v1/21we-c");
|
|
// scenario.start_up();
|
|
// scenario.act("open left");
|
|
// scenario.cab().OperateDoors(VehicleSide::left, true);
|
|
// scenario.wait(10.0);
|
|
// scenario.check();
|
|
class scenario {
|
|
public:
|
|
scenario(std::string Name, std::vector<channel> Channels, track const &Track = {0.15, 0.0, catenary_3kv});
|
|
|
|
// adds a real vehicle at the back, see consist::add()
|
|
scenario &add(std::string const &Path, int Cab = 0, CouplingSet couplings = consist::full_coupling, double Velocity = 0.0, double Gap = 0.0);
|
|
|
|
consist &train() { return m_train; }
|
|
TMoverParameters &vehicle(std::size_t Index) { return m_train[Index].mover(); }
|
|
TMoverParameters &cab() { return m_train[0].mover(); }
|
|
driven driver() { return driving(m_train); }
|
|
track &line() { return m_track; }
|
|
|
|
// marks the event in the traces, the action follows it
|
|
void act(std::string const &Event);
|
|
// runs the train with the driver attending to it
|
|
void wait(double Seconds);
|
|
// gets the train ready to run, see test::start_up(); returns whether it did
|
|
bool start_up();
|
|
// releases the brakes and sets the direction forward, for a train to move off
|
|
void get_going();
|
|
// the main controller up to its full power position, a notch a second, and Seconds more there. the line
|
|
// contactors close at the first position, after their delay (InitialCtrlDelay) and once the pressure switch
|
|
// lets them (the cylinders under 2 bar, the pipe over 3.6), so it waits there for them, as the AI does
|
|
void full_power(double Seconds);
|
|
// the main controller back to the given position, a notch a second
|
|
void notch_back(int Position);
|
|
// checks the traces
|
|
void check() const;
|
|
|
|
private:
|
|
void record();
|
|
|
|
std::string m_name;
|
|
std::vector<channel> m_channels;
|
|
track m_track;
|
|
consist m_train;
|
|
std::vector<std::unique_ptr<trace>> m_traces;
|
|
};
|
|
|
|
} // namespace test
|