mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-12-03 08:55:22 +01:00
ed8708c5e2
* feat(simulation): text format of simulation snapshots
A snapshot of a running simulation is a text file in the syntax of the scenery
files: entries of the form <type> <name> <key> <value> ... end<type>, the first
one a header which names the scenery. This is the text alone: entries, writer,
reader, the names of the things of a scenery, the plan of coupling changes and
the command line switches (--load-snapshot, --snapshot-at), in the core library
with unit tests. Nothing reads or writes a snapshot yet.
* feat(simulation): snapshot of time, weather, cells, switches and events (L1)
--snapshot-at <seconds> <file> writes a snapshot when the simulation has run
that long, --load-snapshot <file> puts one over the scenery once it has loaded,
before the first frame. This layer keeps the clock and the simulation timer,
the weather with the wind, the random engine, the memory cells, the switches,
the tracks an event can change and the ones made on the run, the traction
power sources, the event queue, the timers of the launchers and the lamps of
the signals.
While a snapshot is put back the event manager is suspended, so nothing in the
scenery reacts to it. Existing classes only get accessors for what was private
(the fraction of the second, launcher timers, the speed limit of a track, the
wind, the state of a power source, the event queue). Without the switches
nothing changes.
* feat(simulation): state of a vehicle's physics for snapshots (L3, core)
What TMoverParameters holds of a running vehicle, to and from an entry of a
snapshot: speed, load, controls, switches and relays, pantographs, doors,
engine and its cooling, the air of the pipes, of every reservoir of the brake
valve (with the flow it has yet to take in) and of the chambers of the driver's
valves, the vigilance device, the power circuits. In the core library, tested
on the real vehicle definitions: a
vehicle restored on a fresh one saves the same, and runs on next to the one it
was saved from.
The brake valves, the driver's valves and the vigilance device get accessors
for their private state (reservoirs(), latches(), pressures(), state()), a
reservoir one for the flow it has yet to take in; nothing else in the physics
changes. This comes before the vehicles of the scenery (L2), whose
speed and load are kept by it.
* feat(simulation): snapshot of vehicles and consists (L2)
Every vehicle is kept with the place of both its axles (track, distance,
direction, path of a switch, events still to set off), the way it faces, its
couplings with their flags, destination and, through its physics, speed and
load. Loaded, the vehicles are put straight where they were
(TTrackFollower::Place(), which trails no switch and fires no event), then
parted and joined until they are coupled as saved, whatever trainsets the
scenery made of them.
A vehicle of the snapshot the scenery does not have is skipped and reported,
one the snapshot does not know stays as the scenery made it, one which had left
the simulation is taken out again.
* feat(simulation): pantographs and passenger exchange in snapshots (L3)
What a vehicle keeps of its machinery beside its physics: the arms of the
pantographs as they stand under the wire, the time without voltage, the
passengers getting on and off, the lighting of the compartments, the headlight
toggles, the last force asked of the electrodynamic brake.
* feat(simulation): snapshot of the drivers and of the player's vehicle (L4)
A driver is kept with its orders and the one it is on, the name of its
timetable and its place in it, the consist it has, what it holds to (speeds of
signals and limits, the reason it stands, its timers and flags), its table of
what is ahead on the track with the point limits it has latched, its tables of
what the brake of the consist gives, and whether the AI drives. A driver who
had moved to another vehicle of its train is moved there.
A run loaded in ghost view (the test mode) is ready before its first frame, as
the run it goes on from was.
The snapshot also names the vehicle the player was in, which --load-snapshot
starts in unless -v says otherwise.
* feat(simulation): snapshotsave command, on [Ctrl]+[Shift]+[F9]
Writes a snapshot of the simulation to snapshots/<scenery>_<date>_<time>.snapshot
in the game folder. The command is the last one of the list, so the numbers of
the others stay.
* test: scenario cases which load a simulation snapshot and compare the run
A case with a "snapshot" section runs its scenery to a time, taking snapshots
on the way and at the end, then again from the first snapshot, and compares the
two ends: positions, speeds, pressures, couplings, cells, switches, drivers.
The snapshot saved right after loading has to be the one loaded.
tests/scenarios/snapshots.py reads the format and tells two snapshots apart.
The switches and the format are described in tests/scenarios/README.md.
* fix(simulation): a vehicle gone in the snapshot leaves its isolated sections
The scenery counts the axles of every vehicle in the isolated sections of
the tracks it puts it on. A vehicle the snapshot has as removed was only
taken off the list of its track, so its two axles stayed counted there and
the section never went free again: the next train on it went 4-6-4 axles
instead of 0-2-0, and its busy and free events never fired.
- A removed vehicle counts both axles out of the sections of their tracks,
is taken off the list of its track only if it's on it, and has no owner.
- The drivers a snapshot doesn't have are deleted as before, and no
vehicle keeps its owner pointing at one of them.
- The snapshot keeps the count of every isolated section and sets it after
the vehicles are placed: the vehicles a consist leaves behind as it goes
through a portal stay counted where they were, in the game too. A count
the placing gives other than the snapshot has is told in the log.
- A vehicle with two entries is placed once.
- TIsolated::axles() reads and sets the count.
- The harness compares the counts of the sections; a new case,
snapshot_td_portal_isolated, has a train leave through a portal from the
track of a section before the snapshot.
* fix(simulation): every value of a snapshot file is checked before it's used
A damaged or edited snapshot could put an index past a table, a count
which takes forever or a number out of the range of its type into the
simulation, and a file cut short was put back half way.
- Reading a value: a whole number has to be whole and fit its type (an
enum its underlying one), a float can't be past its largest value; what
doesn't fit is refused. Every refusal names the entry, the key and the
value, and goes to the log (errors.txt), up to 100 lines and a count.
- Ranges: coupler ends 0 or 1 and the flags of a coupling; couplings which
would close a ring of vehicles; the count of the points of a driver's
table and of its point limits (not past the keys of the entry), the
indices into the table (tablelast, semnext, semnextstop); the order
stack and its position, the timetable station, the driver's enums and
directions; the path, events and distance of an axle, facing and first
axle; the date and time; switch states, made track ends, crossing
segments, event siblings and times, launcher timers, the weather; the
load (amount, and a name which isn't a path); the whole numbers inside
number lists (flags of a table point, the stop of a coupler pair, the
track flags under a vehicle, the fuse count of a power source, the cab
of the vigilance device).
- The positions of the controllers are brought within the ranges of the
vehicle: master and secondary controller (set and actual), reverser,
cabs, light, compressor and wiper switches, brake handle, hand brake,
dimmer.
- A document with problems isn't loaded unless --load-snapshot-force says
so; a test run ends with the error code then. The header counts the
entries, so a file cut between two entries is found too. A file of a
newer version is a warning, not a problem.
- A snapshot is written to <file>.tmp and renamed over the file only when
the stream didn't fail.
- Unit tests of the reader on damaged input.
* feat(simulation): the pullee mode and the holding brake timer in snapshots
Of what #419 and #424 added to TMoverParameters, two are state: PulleeMode
(prepared for being hauled dead; the scenery sets it, PulleeModeSwitch()
can change it) and StopBrakeReleaseTimer (how long power has been asked
for, which lets the holding brake of a unit go after its delay). Both are
kept now, as "pulleemode" and "stopbrakereleasetimer". The others
(PressureSwitchBrakeCylinder, EmergencyBrakeMainOffPressure,
StopBrakeReleaseDelay) come from the vehicle definition and aren't.
* fix(simulation): the snapshot code without Sonar issues
No declaration shadows an enumerator, the variables used only by a
condition are declared in it, write_file takes its writer as a template,
the temporary file is a std::filesystem::path, the isolated sections are
looked up by a transparent hash, apply_couplings is split into helpers,
and the copies of the simulation's random engine are marked NOSONAR.
The test data has no http:// in it. No snapshot key or format changes.
* fix(brakes): TSt113 lists the control pressure once
TSt113::pressures() added CP on top of TH14K1::pressures(), which
already has it since #366 removed the CP of TSt113 that hid it. A
snapshot held the St113's control chamber twice. The second entry is
removed.
Tests: every driver's handle lists each pressure once, and the St113
pressures of an EN57 saved through a snapshot come back on a fresh one.
* fix(simulation): snapshots skip road traffic, refuse changed sceneries, keep misplaced vehicles apart
Cars of the road spawn points which a snapshot has on the road are no longer put back: the spawn point owns
them and the snapshot would leave them frozen on the track. They're counted in the log. The pooled cars keep
their AI drivers, which the snapshot used to delete.
A snapshot whose scenery fingerprint differs is refused unless --load-snapshot-force is given: tracks named
"#N" shift when a track is added. Each vehicle is checked against the x/y/z of its entry after placing. One
more than 1 m off, or one which can't be placed, goes back where the scenery put it, isn't coupled to the
placed vehicles, and keeps its scenery state and driver.
Couplings set from a snapshot keep to CompatibleCoupling, so no MU control between an electric and a diesel
loco (#520).
The snapshotsave key writes to snapshotsdir of eu07.ini (snapshots by default, ini only like screenshotsdir),
adds _2, _3... to a name that is taken, and shows where the file went.
* refactor(simulation): the snapshot reads and writes the private state of the vehicles through their own members
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
* fix(simulation): carry the driver's coupling set in the snapshot as the bits of the set
iCoupler is a CouplingSet since 2098614f, which record::set()/get() can't take. It goes
through the converted values as a whole number, as the driving flags do: Bits() on save,
CouplingSet::FromBits() on load. The key and its values are the same as before.
* fix(simulation): a loaded snapshot counts the vehicles it left where they stand
apply_isolated() set every isolated section to the count of the snapshot, also where a
vehicle the load left at its scenery place (misplaced, forced load, road traffic not put
back) stands, or where the snapshot had it. The axles of those vehicles are now counted in
the sections they stand in and out of the ones the snapshot has them in, and the memory
cells of those sections say whether they are taken by that count.
An AI consist doesn't end on a vehicle the load left: the ends are then found along what is
coupled now, as CheckVehicles() finds them.
The player entry no longer writes the cab, which nothing read: the cab is the one the
vehicle has occupied (caboccupied of its entry).
* feat(simulation): the snapshot keeps a derailment and the brakes of a sleeping vehicle
A derailed vehicle came back on the rails. Its entry now keeps what derailed it (outcome,
cause, speed, the cause and side of the motion off the track, the acceleration, the
collision derailment) and the distance its criteria were last checked over; the
derailment the scenery and the test mode were told of (new_derailment()), so it isn't told
again; and with physics.derailment new the motion of the body off the track
(derail_motion::body::state()) with the timers of the vehicle off the track. The terrain
under it is gathered anew around it when it loads.
sleep_brakes, what a sleeping vehicle's brake force came from, is kept too.
All keys are new: an entry without them leaves the vehicle as the scenery made it, so files
written before still load. New scenario case snapshot_td_off_track.
* fix(simulation): the snapshot keeps the sanded start of an AI driver
#494 (in staging since the last runs of the snapshot cases) made a driver whose start
slipped keep sanding under power until the train is under way, and take the power down a
step at a time. Neither the flag nor the time of the last step down was kept, so on
linia61 the loaded run sanded one frame later than the run which went on and parted from
it 0.06 s after loading (suwnica2, 9 mm and 0.08 km/h at 600 s). Both are kept now
(sandedstart, sandedstarttime); an entry without them leaves the driver as it is.
* fix(simulation): the snapshot keeps a train running forked on a switch thrown under it
Staging's switch fork running (#496) gave the axles and the vehicles state of their own: the way of a
switch an axle ran onto (TTrackFollower::iPath, which it leaves the switch by after a throw), the ways it
remembers of the switches behind it (path_memory, read when the axle behind it comes onto one of them),
and per vehicle the switch its bogies or its coupled ends run forked on with whether that was told
(m_forkbogies, m_forkends). None of it was in a snapshot: a loaded train on a switch thrown under it
would have left it by the way it is set now and never derailed running forked.
- Place() sets the way of the switch from the path the axle is put on, as SetCurrentTrack() does, and
clears the facing entry the vehicle hasn't looked at (there is none between frames).
- A vehicle entry has the remembered ways of each axle, oldest first (axle0switch0, axle0way0...),
recorded again into an empty memory on load (path_memory::entries()), and the forked watches
(forkbogies, fork0, fork1 with their "told"). A name which isn't a switch is refused.
- New case snapshot_td_switch_thrown: the snapshot is taken while the second coach of
eu07_td_switch_thrown_facing_behind_derails runs forked and hasn't derailed yet; the loaded run derails
it the same way and the two files at 150 s are identical.
4840 lines
131 KiB
C++
4840 lines
131 KiB
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/.
|
|
*/
|
|
/*
|
|
MaSzyna EU07 - SPKS
|
|
Brakes. Oerlikon ESt.
|
|
Copyright (C) 2007-2014 Maciej Cierniak
|
|
*/
|
|
|
|
#include "stdafx.h"
|
|
#include "physics/brakes.h"
|
|
#include <typeinfo>
|
|
#include "physics/vehicle.h"
|
|
#include "utilities/utilities.h"
|
|
|
|
//---FUNKCJE OGOLNE---
|
|
|
|
static double const DPL = 0.25;
|
|
double const TFV4aM::pos_table[11] = {-2, 6, -1, 0, -2, 1, 4, 6, 0, 0, 0};
|
|
double const TMHZ_EN57::pos_table[11] = {-1, 10, -1, 0, 0, 2, 9, 10, 0, 0, 0};
|
|
double const TMHZ_K5P::pos_table[11] = {-1, 3, -1, 0, 1, 1, 2, 3, 0, 0, 0};
|
|
double const TMHZ_6P::pos_table[11] = {-1, 4, -1, 0, 2, 2, 3, 4, 0, 0, 0};
|
|
double const TM394::pos_table[11] = {-1, 5, -1, 0, 1, 2, 4, 5, 0, 0, 0};
|
|
double const TH14K1::BPT_K[6][2] = {{10, 0}, {4, 1}, {0, 1}, {4, 0}, {4, -1}, {15, -1}};
|
|
double const TH14K1::pos_table[11] = {-1, 4, -1, 0, 1, 2, 3, 4, 0, 0, 0};
|
|
double const TSt113::BPT_K[6][2] = {{10, 0}, {4, 1}, {0, 1}, {4, 0}, {4, -1}, {15, -1}};
|
|
double const TSt113::BEP_K[7] = {0, -1, 1, 0, 0, 0, 0};
|
|
double const TSt113::pos_table[11] = {-1, 5, -1, 0, 2, 3, 4, 5, 0, 0, 1};
|
|
double const TFVel6::pos_table[11] = {-1, 6, -1, 0, 6, 4, 4.7, 5, -1, 0, 1};
|
|
double const TFVE408::pos_table[11] = {0, 10, 0, 0, 10, 7, 8, 9, 0, 1, 5};
|
|
|
|
/// <summary>
|
|
/// Pressure-ratio helper used by reservoir filling/emptying integrators.
|
|
/// Returns the dimensionless driving term (P2 - P1) / (1.13 * PH - PL),
|
|
/// where PH/PL are the absolute high/low pressures (with a small safety margin),
|
|
/// signed in the direction of P1 -> P2.
|
|
/// </summary>
|
|
/// <param name="P1">Source pressure [bar].</param>
|
|
/// <param name="P2">Destination pressure [bar].</param>
|
|
/// <returns>Dimensionless flow driver (positive when P2 > P1).</returns>
|
|
double PR(double P1, double P2)
|
|
{
|
|
double PH = std::max(P1, P2) + 0.1;
|
|
double PL = P1 + P2 - PH + 0.2;
|
|
return (P2 - P1) / (1.13 * PH - PL);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Legacy pneumatic flow function. Kept for reference; superseded by <see cref="PF"/>.
|
|
/// </summary>
|
|
/// <param name="P1">Source pressure [bar].</param>
|
|
/// <param name="P2">Destination pressure [bar].</param>
|
|
/// <param name="S">Effective orifice cross-section.</param>
|
|
/// <returns>Volumetric flow rate (signed).</returns>
|
|
double PF_old(double P1, double P2, double S)
|
|
{
|
|
double PH = std::max(P1, P2) + 1;
|
|
double PL = P1 + P2 - PH + 2;
|
|
if (PH - PL < 0.0001)
|
|
return 0;
|
|
else if (PH - PL < 0.05)
|
|
return 20 * (PH - PL) * (PH + 1) * 222 * S * (P2 - P1) / (1.13 * PH - PL);
|
|
else
|
|
return (PH + 1) * 222 * S * (P2 - P1) / (1.13 * PH - PL);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Pneumatic flow rate from one pressure to another through an orifice of area S.
|
|
/// Distinguishes choked (PL/PH below 0.5) from subsonic flow and softens the
|
|
/// curve near zero pressure delta using a DP-wide ramp to keep the integrator stable.
|
|
/// </summary>
|
|
/// <param name="P1">Source pressure [bar].</param>
|
|
/// <param name="P2">Destination pressure [bar].</param>
|
|
/// <param name="S">Effective orifice cross-section.</param>
|
|
/// <param name="DP">Soft-clip pressure delta — softens the response for tiny PH-PL differences (default 0.25).</param>
|
|
/// <returns>Volumetric flow rate (signed; positive when P2 > P1).</returns>
|
|
double PF(double const P1, double const P2, double const S, double const DP)
|
|
{
|
|
double const PH = std::max(P1, P2) + 1.0; // wyzsze cisnienie absolutne
|
|
double const PL = P1 + P2 - PH + 2.0; // nizsze cisnienie absolutne
|
|
double const sg = PL / PH; // bezwymiarowy stosunek cisnien
|
|
double const FM = PH * 197.0 * S * Sign(P2 - P1); // najwyzszy mozliwy przeplyw, wraz z kierunkiem
|
|
if (sg > 0.5) // jesli ponizej stosunku krytycznego
|
|
if (PH - PL < DP) // niewielka roznica cisnien
|
|
return (1.0 - sg) / DPL * FM * 2.0 * std::sqrt(DP * (PH - DP));
|
|
// return 1/DPL*(PH-PL)*fm*2*SQRT((sg)*(1-sg));
|
|
else
|
|
return FM * 2.0 * std::sqrt(sg * (1.0 - sg));
|
|
else // powyzej stosunku krytycznego
|
|
return FM;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Variant of <see cref="PF"/> that uses the dimensionless pressure ratio (sg)
|
|
/// for the soft-clip threshold instead of an absolute pressure delta.
|
|
/// </summary>
|
|
/// <param name="P1">Source pressure [bar].</param>
|
|
/// <param name="P2">Destination pressure [bar].</param>
|
|
/// <param name="S">Effective orifice cross-section.</param>
|
|
/// <returns>Volumetric flow rate (signed).</returns>
|
|
double PF1(double const P1, double const P2, double const S)
|
|
{
|
|
static double const DPS = 0.001;
|
|
|
|
double const PH = std::max(P1, P2) + 1.0; // wyzsze cisnienie absolutne
|
|
double const PL = P1 + P2 - PH + 2.0; // nizsze cisnienie absolutne
|
|
double const sg = PL / PH; // bezwymiarowy stosunek cisnien
|
|
double const FM = PH * 197.0 * S * Sign(P2 - P1); // najwyzszy mozliwy przeplyw, wraz z kierunkiem
|
|
if (sg > 0.5) // jesli ponizej stosunku krytycznego
|
|
if (sg < DPS) // niewielka roznica cisnien
|
|
return (1.0 - sg) / DPS * FM * 2.0 * std::sqrt(DPS * (1.0 - DPS));
|
|
else
|
|
return FM * 2.0 * std::sqrt(sg * (1.0 - sg));
|
|
else // powyzej stosunku krytycznego
|
|
return FM;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Filling valve flow: flows from PH to PL until PL reaches LIM. The valve
|
|
/// throttles smoothly as PL approaches LIM (within DP of the target).
|
|
/// Returns 0 once PL is already >= LIM.
|
|
/// </summary>
|
|
/// <param name="PH">High-pressure source [bar].</param>
|
|
/// <param name="PL">Low-pressure side that is being filled [bar].</param>
|
|
/// <param name="S">Effective orifice cross-section.</param>
|
|
/// <param name="LIM">Target pressure for PL [bar] — flow stops once PL reaches LIM.</param>
|
|
/// <param name="DP">Throttling distance from LIM (default 0.1).</param>
|
|
/// <returns>Flow rate from PH to PL (positive into PL).</returns>
|
|
double PFVa(double PH, double PL, double const S, double LIM, double const DP)
|
|
// zawor napelniajacy z PH do PL, PL do LIM
|
|
{
|
|
if (LIM > PL)
|
|
{
|
|
LIM = LIM + 1;
|
|
PH = PH + 1; // wyzsze cisnienie absolutne
|
|
PL = PL + 1; // nizsze cisnienie absolutne
|
|
double sg = std::min(1.0, PL / PH); // bezwymiarowy stosunek cisnien. NOTE: sg is capped at 1 to prevent calculations from going awry. TODO, TBD: log these as errors?
|
|
double FM = PH * 197 * S; // najwyzszy mozliwy przeplyw, wraz z kierunkiem
|
|
if (LIM - PL < DP)
|
|
FM = FM * (LIM - PL) / DP; // jesli jestesmy przy nastawieniu, to zawor sie przymyka
|
|
if (sg > 0.5) // jesli ponizej stosunku krytycznego
|
|
if (PH - PL < DPL) // niewielka roznica cisnien
|
|
return (PH - PL) / DPL * FM * 2 * std::sqrt(sg * (1 - sg)); // BUG: (1-sg) can be < 0, leading to sqrt(-x)
|
|
else
|
|
return FM * 2 * std::sqrt(sg * (1 - sg)); // BUG: (1-sg) can be < 0, leading to sqrt(-x)
|
|
else // powyzej stosunku krytycznego
|
|
return FM;
|
|
}
|
|
else
|
|
return 0;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Venting valve flow: flows from PH to PL until PH falls to LIM. The valve
|
|
/// throttles smoothly as PH approaches LIM. Returns 0 once PH <= LIM.
|
|
/// </summary>
|
|
/// <param name="PH">High-pressure side that is being vented [bar].</param>
|
|
/// <param name="PL">Low-pressure destination [bar].</param>
|
|
/// <param name="S">Effective orifice cross-section.</param>
|
|
/// <param name="LIM">Lower bound for PH [bar] — flow stops once PH falls to LIM.</param>
|
|
/// <param name="DP">Throttling distance from LIM (default 0.1).</param>
|
|
/// <returns>Flow rate from PH to PL.</returns>
|
|
double PFVd(double PH, double PL, double const S, double LIM, double const DP)
|
|
// zawor wypuszczajacy z PH do PL, PH do LIM
|
|
{
|
|
if (LIM < PH)
|
|
{
|
|
LIM = LIM + 1;
|
|
PH = PH + 1.0; // wyzsze cisnienie absolutne
|
|
PL = PL + 1.0; // nizsze cisnienie absolutne
|
|
double sg = std::min(1.0, PL / PH); // bezwymiarowy stosunek cisnien
|
|
double FM = PH * 197.0 * S; // najwyzszy mozliwy przeplyw, wraz z kierunkiem
|
|
if (PH - LIM < 0.1)
|
|
FM = FM * (PH - LIM) / DP; // jesli jestesmy przy nastawieniu, to zawor sie przymyka
|
|
if (sg > 0.5) // jesli ponizej stosunku krytycznego
|
|
if (PH - PL < DPL) // niewielka roznica cisnien
|
|
return (PH - PL) / DPL * FM * 2.0 * std::sqrt(sg * (1.0 - sg));
|
|
else
|
|
return FM * 2.0 * std::sqrt(sg * (1.0 - sg));
|
|
else // powyzej stosunku krytycznego
|
|
return FM;
|
|
}
|
|
else
|
|
return 0;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Returns true when a continuous handle position falls into a unit-wide
|
|
/// detent centred on i_pos (i.e. pos is in (i_pos - 0.5, i_pos + 0.5]).
|
|
/// </summary>
|
|
/// <param name="pos">Continuous handle position.</param>
|
|
/// <param name="i_pos">Detent centre to compare against.</param>
|
|
/// <returns>True if pos is within ±0.5 of i_pos.</returns>
|
|
bool is_EQ(double pos, double i_pos)
|
|
{
|
|
return pos <= i_pos + 0.5 && pos > i_pos - 0.5;
|
|
}
|
|
|
|
//---ZBIORNIKI---
|
|
|
|
/// <summary>
|
|
/// Returns absolute (atmospheric) pressure inside the reservoir as 0.1 * Vol / Cap.
|
|
/// </summary>
|
|
/// <returns>Absolute pressure value.</returns>
|
|
double TReservoir::pa()
|
|
{
|
|
return 0.1 * Vol / Cap;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Returns gauge pressure inside the reservoir as Vol / Cap.
|
|
/// </summary>
|
|
/// <returns>Pressure in bar.</returns>
|
|
double TReservoir::P()
|
|
{
|
|
return Vol / Cap;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Accumulates a flow delta into the pending volume change for the current step.
|
|
/// The change is applied to <c>Vol</c> on the next call to <see cref="Act"/>.
|
|
/// </summary>
|
|
/// <param name="dv">Flow delta (positive = into reservoir, negative = out).</param>
|
|
void TReservoir::Flow(double dv)
|
|
{
|
|
dVol = dVol + dv;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Commits the pending flow accumulated by <see cref="Flow"/> to <c>Vol</c>
|
|
/// (clamping it to non-negative) and resets the pending delta to zero.
|
|
/// </summary>
|
|
void TReservoir::Act()
|
|
{
|
|
Vol = std::max(0.0, Vol + dVol);
|
|
dVol = 0;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Sets the reservoir capacity in liters.
|
|
/// </summary>
|
|
/// <param name="Capacity">Capacity in liters.</param>
|
|
void TReservoir::CreateCap(double Capacity)
|
|
{
|
|
Cap = Capacity;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Initialises the reservoir to a given pressure (Vol = Cap * Press)
|
|
/// and clears any pending flow.
|
|
/// </summary>
|
|
/// <param name="Press">Initial pressure in bar.</param>
|
|
void TReservoir::CreatePress(double Press)
|
|
{
|
|
Vol = Cap * Press;
|
|
dVol = 0;
|
|
}
|
|
|
|
//---SILOWNIK---
|
|
/// <summary>
|
|
/// Returns the absolute pressure inside the brake cylinder
|
|
/// (gauge pressure from <see cref="P"/> scaled to atm).
|
|
/// </summary>
|
|
/// <returns>Absolute brake-cylinder pressure.</returns>
|
|
double TBrakeCyl::pa()
|
|
// var VtoC: real;
|
|
{
|
|
// VtoC:=Vol/Cap;
|
|
return P() * 0.1;
|
|
}
|
|
|
|
/* NOWSZA WERSJA - maksymalne ciśnienie to ok. 4,75 bar, co powoduje
|
|
// problemy przy rapidzie w lokomotywach, gdyz jest3
|
|
// osiagany wierzcholek paraboli
|
|
function TBrakeCyl.P:real;
|
|
var VtoC: real;
|
|
begin
|
|
VtoC:=Vol/Cap;
|
|
if VtoC<0.06 then P:=VtoC/4
|
|
else if VtoC>0.88 then P:=0.5+(VtoC-0.88)*1.043-0.064*(VtoC-0.88)*(VtoC-0.88)
|
|
else P:=0.15+0.35/0.82*(VtoC-0.06);
|
|
end; */
|
|
|
|
//(* STARA WERSJA
|
|
/// <summary>
|
|
/// Returns the gauge pressure inside the brake cylinder using the legacy
|
|
/// piston-stroke pressure curve: a low-pressure dead-volume region (VtoC < VS),
|
|
/// a linear stroke region, and a saturated region once the piston is fully extended.
|
|
/// Includes a div-by-zero guard for vehicles with incomplete definitions.
|
|
/// </summary>
|
|
/// <returns>Cylinder pressure in bar.</returns>
|
|
double TBrakeCyl::P()
|
|
{
|
|
static double const VS = 0.005;
|
|
static double const pS = 0.05;
|
|
static double const VD = 1.10;
|
|
static double const cD = 1;
|
|
static double const pD = VD - cD;
|
|
|
|
double VtoC = Cap > 0.0 ? Vol / Cap : 0.0; // stosunek cisnienia do objetosci.
|
|
// Added div/0 trap for vehicles with incomplete definitions (cars etc)
|
|
// P:=VtoC;
|
|
if (VtoC < VS)
|
|
return VtoC * pS / VS; // objetosc szkodliwa
|
|
else if (VtoC > VD)
|
|
return VtoC - cD; // caly silownik;
|
|
else
|
|
return pS + (VtoC - VS) / (VD - VS) * (pD - pS); // wysuwanie tloka
|
|
} //*)
|
|
|
|
//---HAMULEC---
|
|
/*
|
|
constructor TBrake.Create(i_mbp, i_bcr, i_bcd, i_brc: real; i_bcn, i_BD, i_mat, i_ba, i_nbpa: int);
|
|
begin
|
|
inherited Create;
|
|
MaxBP:=i_mbp;
|
|
BCN:=i_bcn;
|
|
BCA:=i_bcn*i_bcr*i_bcr*pi;
|
|
BA:=i_ba;
|
|
NBpA:=i_nbpa;
|
|
BrakeDelays:=i_BD;
|
|
|
|
//tworzenie zbiornikow
|
|
BrakeCyl.CreateCap(i_bcd*BCA*1000);
|
|
BrakeRes.CreateCap(i_brc);
|
|
ValveRes.CreateCap(0.2);
|
|
|
|
// FM.Free;
|
|
//materialy cierne
|
|
case i_mat of
|
|
bp_P10Bg: FM:=TP10Bg.Create;
|
|
bp_P10Bgu: FM:=TP10Bgu.Create;
|
|
else //domyslnie
|
|
FM:=TP10.Create;
|
|
end;
|
|
|
|
|
|
end ; */
|
|
|
|
/// <summary>
|
|
/// Constructs the brake unit: stores parameters, creates the cylinder /
|
|
/// auxiliary reservoir / valve pre-chamber, sizes them for the requested
|
|
/// 14"-relative scale, and instantiates the friction-material model based on
|
|
/// the friction-pair id (with the magnetic-rail flag bp_MHS masked off).
|
|
/// </summary>
|
|
/// <param name="i_mbp">Maximum brake cylinder pressure [bar].</param>
|
|
/// <param name="i_bcr">Brake cylinder radius [m].</param>
|
|
/// <param name="i_bcd">Brake cylinder working stroke [m].</param>
|
|
/// <param name="i_brc">Auxiliary reservoir capacity [l].</param>
|
|
/// <param name="i_bcn">Number of brake cylinders.</param>
|
|
/// <param name="i_BD">Available brake delay positions (bdelay_* bitmask).</param>
|
|
/// <param name="i_mat">Friction material id (bp_* constant, optionally OR'ed with bp_MHS).</param>
|
|
/// <param name="i_ba">Number of braked axles.</param>
|
|
/// <param name="i_nbpa">Number of blocks per axle.</param>
|
|
TBrake::TBrake(double i_mbp, double i_bcr, double i_bcd, double i_brc, int i_bcn, int i_BD, int i_mat, int i_ba, int i_nbpa) :
|
|
BCN(i_bcn), BCM(1), BCA(i_bcn * i_bcr * i_bcr * M_PI), BrakeDelays(i_BD), MaxBP(i_mbp), BA(i_ba), NBpA(i_nbpa), SizeBR(i_brc * 0.0128)
|
|
{
|
|
// inherited:: Create;
|
|
BrakeDelayFlag = bdelay_P;
|
|
// 210.88
|
|
// SizeBR:=i_bcn*i_bcr*i_bcr*i_bcd*40.17*MaxBP/(5-MaxBP); //objetosc ZP w stosunku do cylindra
|
|
// 14" i cisnienia 4.2 atm
|
|
SizeBC = i_bcn * i_bcr * i_bcr * i_bcd * 210.88 * MaxBP / 4.2; // objetosc CH w stosunku do cylindra 14" i cisnienia 4.2 atm
|
|
|
|
BrakeCyl = std::make_shared<TBrakeCyl>();
|
|
BrakeRes = std::make_shared<TReservoir>();
|
|
ValveRes = std::make_shared<TReservoir>();
|
|
|
|
// tworzenie zbiornikow
|
|
BrakeCyl->CreateCap(i_bcd * BCA * 1000);
|
|
BrakeRes->CreateCap(i_brc);
|
|
ValveRes->CreateCap(0.25);
|
|
|
|
// materialy cierne
|
|
i_mat = i_mat & 255 - bp_MHS;
|
|
switch (i_mat)
|
|
{
|
|
case bp_P10Bg:
|
|
FM = std::make_shared<TP10Bg>();
|
|
break;
|
|
case bp_P10Bgu:
|
|
FM = std::make_shared<TP10Bgu>();
|
|
break;
|
|
case bp_FR513:
|
|
FM = std::make_shared<TFR513>();
|
|
break;
|
|
case bp_FR510:
|
|
FM = std::make_shared<TFR510>();
|
|
break;
|
|
case bp_Cosid:
|
|
FM = std::make_shared<TCosid>();
|
|
break;
|
|
case bp_P10yBg:
|
|
FM = std::make_shared<TP10yBg>();
|
|
break;
|
|
case bp_P10yBgu:
|
|
FM = std::make_shared<TP10yBgu>();
|
|
break;
|
|
case bp_D1:
|
|
FM = std::make_shared<TDisk1>();
|
|
break;
|
|
case bp_D2:
|
|
FM = std::make_shared<TDisk2>();
|
|
break;
|
|
default: // domyslnie
|
|
FM = std::make_shared<TP10>();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Default brake initialisation — only stores the requested delay flag.
|
|
/// Derived classes typically override to also pre-charge the reservoirs.
|
|
/// </summary>
|
|
/// <param name="PP">Brake pipe pressure [bar].</param>
|
|
/// <param name="HPP">High (control) pressure [bar].</param>
|
|
/// <param name="LPP">Low pressure threshold [bar].</param>
|
|
/// <param name="BP">Initial brake cylinder pressure [bar].</param>
|
|
/// <param name="BDF">Initial brake delay flag.</param>
|
|
// inicjalizacja hamulca (stan poczatkowy)
|
|
void TBrake::Init(double const PP, double const HPP, double const LPP, double const BP, int const BDF)
|
|
{
|
|
BrakeDelayFlag = BDF;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Returns the friction coefficient between the blocks and the wheel/disc by
|
|
/// delegating to the friction-material model (note: arguments are forwarded
|
|
/// in (N, Vel) order to match the friction-material API).
|
|
/// </summary>
|
|
/// <param name="Vel">Vehicle velocity.</param>
|
|
/// <param name="N">Normal force on the block.</param>
|
|
/// <returns>Friction coefficient.</returns>
|
|
// pobranie wspolczynnika tarcia materialu
|
|
double TBrake::GetFC(double const Vel, double const N)
|
|
{
|
|
return FM->GetFC(N, Vel);
|
|
}
|
|
|
|
/// <summary>Returns the gauge pressure inside the brake cylinder.</summary>
|
|
// cisnienie cylindra hamulcowego
|
|
double TBrake::GetBCP() const
|
|
{
|
|
return BrakeCyl->P();
|
|
}
|
|
|
|
/// <summary>Default ED reference pressure — 0 unless overridden by EP09-style distributors.</summary>
|
|
// ciśnienie sterujące hamowaniem elektro-dynamicznym
|
|
double TBrake::GetEDBCP()
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
/// <summary>Returns the auxiliary reservoir (ZP) pressure.</summary>
|
|
// cisnienie zbiornika pomocniczego
|
|
double TBrake::GetBRP() const
|
|
{
|
|
return BrakeRes->P();
|
|
}
|
|
|
|
/// <summary>Returns the valve pre-chamber pressure.</summary>
|
|
// cisnienie komory wstepnej
|
|
double TBrake::GetVRP() const
|
|
{
|
|
return ValveRes->P();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Default control-reservoir pressure: forwards to the auxiliary reservoir.
|
|
/// Distributors with a real ZS override this to return CntrlRes->P().
|
|
/// </summary>
|
|
// cisnienie zbiornika sterujacego
|
|
double TBrake::GetCRP()
|
|
{
|
|
return GetBRP();
|
|
}
|
|
|
|
/// <summary>
|
|
/// The reservoirs every valve has. The kinds of valve with more reservoirs add theirs after these.
|
|
/// </summary>
|
|
std::vector<TReservoir *> TBrake::reservoirs() const
|
|
{
|
|
return {BrakeCyl.get(), BrakeRes.get(), ValveRes.get()};
|
|
}
|
|
|
|
/// <summary>
|
|
/// What every valve keeps: whether the double check valve is over to the auxiliary brake, the anti-slip pressure.
|
|
/// </summary>
|
|
std::vector<double> TBrake::latches() const
|
|
{
|
|
return {DCV ? 1.0 : 0.0, ASBP};
|
|
}
|
|
|
|
void TBrake::latches(std::vector<double> const &State)
|
|
{
|
|
if (State.size() < 2)
|
|
return;
|
|
DCV = State[0] != 0.0;
|
|
ASBP = State[1];
|
|
}
|
|
|
|
std::vector<double> TWest::latches() const
|
|
{
|
|
auto state{TBrake::latches()};
|
|
state.emplace_back(LBP);
|
|
state.emplace_back(dVP);
|
|
state.emplace_back(EPS);
|
|
state.emplace_back(LoadC);
|
|
return state;
|
|
}
|
|
|
|
void TWest::latches(std::vector<double> const &State)
|
|
{
|
|
auto const first{TBrake::latches().size()};
|
|
if (State.size() < first + 4)
|
|
return;
|
|
TBrake::latches(State);
|
|
LBP = State[first + 0];
|
|
dVP = State[first + 1];
|
|
EPS = State[first + 2];
|
|
LoadC = State[first + 3];
|
|
}
|
|
|
|
std::vector<double> TESt3AL2::latches() const
|
|
{
|
|
auto state{TESt3::latches()};
|
|
state.emplace_back(LoadC);
|
|
return state;
|
|
}
|
|
|
|
void TESt3AL2::latches(std::vector<double> const &State)
|
|
{
|
|
auto const first{TESt3::latches().size()};
|
|
if (State.size() < first + 1)
|
|
return;
|
|
TESt3::latches(State);
|
|
LoadC = State[first + 0];
|
|
}
|
|
|
|
std::vector<double> TESt4R::latches() const
|
|
{
|
|
auto state{TESt::latches()};
|
|
state.emplace_back(RapidStatus ? 1.0 : 0.0);
|
|
state.emplace_back(RapidTemp);
|
|
return state;
|
|
}
|
|
|
|
void TESt4R::latches(std::vector<double> const &State)
|
|
{
|
|
auto const first{TESt::latches().size()};
|
|
if (State.size() < first + 2)
|
|
return;
|
|
TESt::latches(State);
|
|
RapidStatus = State[first + 0] != 0.0;
|
|
RapidTemp = State[first + 1];
|
|
}
|
|
|
|
std::vector<double> TLSt::latches() const
|
|
{
|
|
auto state{TESt4R::latches()};
|
|
state.emplace_back(LBP);
|
|
state.emplace_back(EDFlag);
|
|
return state;
|
|
}
|
|
|
|
void TLSt::latches(std::vector<double> const &State)
|
|
{
|
|
auto const first{TESt4R::latches().size()};
|
|
if (State.size() < first + 2)
|
|
return;
|
|
TESt4R::latches(State);
|
|
LBP = State[first + 0];
|
|
EDFlag = State[first + 1];
|
|
}
|
|
|
|
std::vector<double> TEStED::latches() const
|
|
{
|
|
auto state{TLSt::latches()};
|
|
state.emplace_back(Zamykajacy ? 1.0 : 0.0);
|
|
state.emplace_back(Przys_blok ? 1.0 : 0.0);
|
|
state.emplace_back(LoadC);
|
|
return state;
|
|
}
|
|
|
|
void TEStED::latches(std::vector<double> const &State)
|
|
{
|
|
auto const first{TLSt::latches().size()};
|
|
if (State.size() < first + 3)
|
|
return;
|
|
TLSt::latches(State);
|
|
Zamykajacy = State[first + 0] != 0.0;
|
|
Przys_blok = State[first + 1] != 0.0;
|
|
LoadC = State[first + 2];
|
|
}
|
|
|
|
std::vector<double> TEStEP2::latches() const
|
|
{
|
|
auto state{TLSt::latches()};
|
|
state.emplace_back(LoadC);
|
|
state.emplace_back(EPS);
|
|
return state;
|
|
}
|
|
|
|
void TEStEP2::latches(std::vector<double> const &State)
|
|
{
|
|
auto const first{TLSt::latches().size()};
|
|
if (State.size() < first + 2)
|
|
return;
|
|
TLSt::latches(State);
|
|
LoadC = State[first + 0];
|
|
EPS = State[first + 1];
|
|
}
|
|
|
|
std::vector<double> TCV1L_TR::latches() const
|
|
{
|
|
auto state{TCV1::latches()};
|
|
state.emplace_back(LBP);
|
|
return state;
|
|
}
|
|
|
|
void TCV1L_TR::latches(std::vector<double> const &State)
|
|
{
|
|
auto const first{TCV1::latches().size()};
|
|
if (State.size() < first + 1)
|
|
return;
|
|
TCV1::latches(State);
|
|
LBP = State[first + 0];
|
|
}
|
|
|
|
std::vector<double> TKE::latches() const
|
|
{
|
|
auto state{TBrake::latches()};
|
|
state.emplace_back(RapidStatus ? 1.0 : 0.0);
|
|
state.emplace_back(LoadC);
|
|
state.emplace_back(LBP);
|
|
return state;
|
|
}
|
|
|
|
void TKE::latches(std::vector<double> const &State)
|
|
{
|
|
auto const first{TBrake::latches().size()};
|
|
if (State.size() < first + 3)
|
|
return;
|
|
TBrake::latches(State);
|
|
RapidStatus = State[first + 0] != 0.0;
|
|
LoadC = State[first + 1];
|
|
LBP = State[first + 2];
|
|
}
|
|
|
|
std::vector<TReservoir *> TESt::reservoirs() const
|
|
{
|
|
auto list{TBrake::reservoirs()};
|
|
list.emplace_back(CntrlRes.get());
|
|
return list;
|
|
}
|
|
|
|
std::vector<TReservoir *> TESt3AL2::reservoirs() const
|
|
{
|
|
auto list{TESt::reservoirs()};
|
|
list.emplace_back(ImplsRes.get());
|
|
return list;
|
|
}
|
|
|
|
std::vector<TReservoir *> TESt4R::reservoirs() const
|
|
{
|
|
auto list{TESt::reservoirs()};
|
|
list.emplace_back(ImplsRes.get());
|
|
return list;
|
|
}
|
|
|
|
std::vector<TReservoir *> TEStED::reservoirs() const
|
|
{
|
|
auto list{TLSt::reservoirs()};
|
|
list.emplace_back(Miedzypoj.get());
|
|
return list;
|
|
}
|
|
|
|
std::vector<TReservoir *> TCV1::reservoirs() const
|
|
{
|
|
auto list{TBrake::reservoirs()};
|
|
list.emplace_back(CntrlRes.get());
|
|
return list;
|
|
}
|
|
|
|
std::vector<TReservoir *> TCV1L_TR::reservoirs() const
|
|
{
|
|
auto list{TCV1::reservoirs()};
|
|
list.emplace_back(ImplsRes.get());
|
|
return list;
|
|
}
|
|
|
|
std::vector<TReservoir *> TKE::reservoirs() const
|
|
{
|
|
auto list{TBrake::reservoirs()};
|
|
list.emplace_back(CntrlRes.get());
|
|
list.emplace_back(ImplsRes.get());
|
|
list.emplace_back(Brak2Res.get());
|
|
return list;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Default per-step distributor advance — commits any pending flows on the
|
|
/// reservoirs and reports zero brake-pipe exchange. Concrete distributors override.
|
|
/// </summary>
|
|
/// <param name="PP">Brake pipe pressure [bar].</param>
|
|
/// <param name="dt">Time step [s].</param>
|
|
/// <param name="Vel">Vehicle velocity [m/s].</param>
|
|
/// <returns>0 in the default implementation.</returns>
|
|
// przeplyw z przewodu glowneg
|
|
double TBrake::GetPF(double const PP, double const dt, double const Vel)
|
|
{
|
|
ValveRes->Act();
|
|
BrakeCyl->Act();
|
|
BrakeRes->Act();
|
|
return 0;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Default high-pressure inflow — 0 (no replenishment from the main line).
|
|
/// Distributors with a high-pressure feed override this.
|
|
/// </summary>
|
|
// przeplyw z przewodu zasilajacego
|
|
double TBrake::GetHPFlow(double const HP, double const dt)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Returns the piston force from the cylinder pressure (BCA * 100 * P).
|
|
/// </summary>
|
|
double TBrake::GetBCF() const
|
|
{
|
|
return BCA * 100 * BrakeCyl->P();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Sets the brake delay flag (G/P/R/M) only if the requested mode is
|
|
/// supported by the vehicle (bit set in BrakeDelays) and differs from the
|
|
/// current setting.
|
|
/// </summary>
|
|
/// <param name="nBDF">Requested delay flag (bdelay_*).</param>
|
|
/// <returns>True on accepted change, false otherwise.</returns>
|
|
bool TBrake::SetBDF(int const nBDF)
|
|
{
|
|
if ((nBDF & BrakeDelays) == nBDF && nBDF != BrakeDelayFlag)
|
|
{
|
|
BrakeDelayFlag = nBDF;
|
|
return true;
|
|
}
|
|
else
|
|
return false;
|
|
}
|
|
|
|
/// <summary>Sets or clears the releaser flag in BrakeStatus.</summary>
|
|
/// <param name="state">1 to engage, 0 to disengage.</param>
|
|
void TBrake::Releaser(int const state)
|
|
{
|
|
BrakeStatus = BrakeStatus & ~b_rls | state * b_rls;
|
|
}
|
|
|
|
/// <summary>Returns true if the releaser flag is currently set in BrakeStatus.</summary>
|
|
bool TBrake::Releaser() const
|
|
{
|
|
|
|
return (BrakeStatus & b_rls) == b_rls;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Default EP-state setter — no-op. Overridden by distributors that
|
|
/// support the EP brake (TWest, TEStEP1/2, ...).
|
|
/// </summary>
|
|
/// <param name="nEPS">EP intensity.</param>
|
|
void TBrake::SetEPS(double const nEPS) { /* no effect for this device type */ }
|
|
|
|
/// <summary>
|
|
/// Sets the anti-slip brake state flags. Bit 1 of <paramref name="state"/>
|
|
/// drives <c>b_asb</c> (hold), bit 0 drives <c>b_asb_unbrake</c> (release).
|
|
/// </summary>
|
|
/// <param name="state">Two-bit ASB request.</param>
|
|
void TBrake::ASB(int const state)
|
|
{ // 255-b_asb(32)
|
|
BrakeStatus = BrakeStatus & ~b_asb | state / 2 * b_asb;
|
|
BrakeStatus = BrakeStatus & ~b_asb_unbrake | state % 2 * b_asb_unbrake;
|
|
}
|
|
|
|
/// <summary>Returns the raw BrakeStatus bitfield.</summary>
|
|
int TBrake::GetStatus() const
|
|
{
|
|
return BrakeStatus;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Returns the accumulated SoundFlag bitfield and clears it,
|
|
/// so that each event is reported only once.
|
|
/// </summary>
|
|
int TBrake::GetSoundFlag()
|
|
{
|
|
int result = SoundFlag;
|
|
SoundFlag = 0;
|
|
return result;
|
|
}
|
|
|
|
/// <summary>Sets the anti-slip brake target pressure.</summary>
|
|
/// <param name="Press">Pressure [bar].</param>
|
|
void TBrake::SetASBP(double const Press)
|
|
{
|
|
ASBP = Press;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Vents the valve pre-chamber and the auxiliary reservoir to zero
|
|
/// (for vehicle reset / decoupling). Derived classes also clear their extra reservoirs.
|
|
/// </summary>
|
|
void TBrake::ForceEmptiness()
|
|
{
|
|
ValveRes->CreatePress(0);
|
|
BrakeRes->CreatePress(0);
|
|
|
|
ValveRes->Act();
|
|
BrakeRes->Act();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Bleeds a fraction of the air from the auxiliary reservoir and a tiny
|
|
/// fraction from the valve pre-chamber to simulate distributed leaks.
|
|
/// Note: experimental — currently limited to these two reservoirs.
|
|
/// </summary>
|
|
/// <param name="Amount">Fraction of pressure to bleed (0..1).</param>
|
|
// removes specified amount of air from the reservoirs
|
|
// NOTE: experimental feature, for now limited only to brake reservoir
|
|
void TBrake::ForceLeak(double const Amount)
|
|
{
|
|
|
|
BrakeRes->Flow(-Amount * BrakeRes->P());
|
|
ValveRes->Flow(-Amount * ValveRes->P() * 0.01); // this reservoir has hard coded, tiny capacity compared to other parts
|
|
|
|
BrakeRes->Act();
|
|
ValveRes->Act();
|
|
}
|
|
|
|
//---WESTINGHOUSE---
|
|
|
|
/// <summary>
|
|
/// Initialises the Westinghouse distributor: pre-charges the valve pre-chamber
|
|
/// to PP, the brake cylinder to BP, and the auxiliary reservoir to a midpoint
|
|
/// between PP and HPP.
|
|
/// </summary>
|
|
/// <param name="PP">Brake pipe pressure [bar].</param>
|
|
/// <param name="HPP">High (control) pressure [bar].</param>
|
|
/// <param name="LPP">Low pressure threshold [bar].</param>
|
|
/// <param name="BP">Initial cylinder pressure [bar].</param>
|
|
/// <param name="BDF">Initial brake delay flag.</param>
|
|
void TWest::Init(double const PP, double const HPP, double const LPP, double const BP, int const BDF)
|
|
{
|
|
TBrake::Init(PP, HPP, LPP, BP, BDF);
|
|
ValveRes->CreatePress(PP);
|
|
BrakeCyl->CreatePress(BP);
|
|
BrakeRes->CreatePress(PP / 2 + HPP / 2);
|
|
// BrakeStatus:=3*int(BP>0.1);
|
|
}
|
|
|
|
/// <summary>
|
|
/// One-step Westinghouse distributor advance. Drives the b_on/b_hld state
|
|
/// machine from the auxiliary-reservoir vs. valve-pre-chamber differential,
|
|
/// integrates the auxiliary brake (DCV) and the EP brake against LBP, and
|
|
/// computes the resulting flows between brake pipe / pre-chamber / auxiliary
|
|
/// reservoir / brake cylinder.
|
|
/// </summary>
|
|
/// <param name="PP">Brake pipe pressure [bar].</param>
|
|
/// <param name="dt">Time step [s].</param>
|
|
/// <param name="Vel">Vehicle velocity [m/s].</param>
|
|
/// <returns>Net volume exchanged with the brake pipe.</returns>
|
|
double TWest::GetPF(double const PP, double const dt, double const Vel)
|
|
{
|
|
double dv;
|
|
double dV1;
|
|
double VVP;
|
|
double BVP;
|
|
double CVP;
|
|
double BCP;
|
|
double temp;
|
|
|
|
BVP = BrakeRes->P();
|
|
VVP = ValveRes->P();
|
|
CVP = BrakeCyl->P();
|
|
BCP = BrakeCyl->P();
|
|
|
|
if ((BrakeStatus & b_hld) == b_hld)
|
|
{
|
|
if (VVP + 0.03 < BVP)
|
|
BrakeStatus |= b_on;
|
|
else if (VVP > BVP + 0.1)
|
|
BrakeStatus &= ~(b_on | b_hld);
|
|
else if (VVP > BVP)
|
|
BrakeStatus &= ~b_on;
|
|
}
|
|
else if (VVP + 0.25 < BVP)
|
|
BrakeStatus |= b_on | b_hld;
|
|
|
|
if ((BrakeStatus & b_hld) == b_off && !DCV)
|
|
dv = PF(0, CVP, 0.0068 * SizeBC) * dt;
|
|
else
|
|
dv = 0;
|
|
BrakeCyl->Flow(-dv);
|
|
|
|
if (BCP > LBP + 0.01 && DCV)
|
|
dv = PF(0, CVP, 0.1 * SizeBC) * dt;
|
|
else
|
|
dv = 0;
|
|
BrakeCyl->Flow(-dv);
|
|
|
|
if ((BrakeStatus & b_rls) == b_rls) // odluzniacz
|
|
dv = PF(0, CVP, 0.1 * SizeBC) * dt;
|
|
else
|
|
dv = 0;
|
|
BrakeCyl->Flow(-dv);
|
|
|
|
// hamulec EP
|
|
temp = BVP * int(EPS > 0);
|
|
dv = PF(temp, LBP, 0.0015) * dt * EPS * EPS * int(LBP * EPS < MaxBP * LoadC);
|
|
LBP = LBP - dv;
|
|
|
|
// przeplyw ZP <-> silowniki
|
|
if ((BrakeStatus & b_on) == b_on && (TareBP < 0.1 || BCP < MaxBP * LoadC))
|
|
if (BVP > LBP)
|
|
{
|
|
DCV = false;
|
|
dv = PF(BVP, CVP, 0.017 * SizeBC) * dt;
|
|
}
|
|
else
|
|
dv = 0;
|
|
else
|
|
dv = 0;
|
|
BrakeRes->Flow(dv);
|
|
BrakeCyl->Flow(-dv);
|
|
if (DCV)
|
|
dVP = PF(LBP, BCP, 0.01 * SizeBC) * dt;
|
|
else
|
|
dVP = 0;
|
|
BrakeCyl->Flow(-dVP);
|
|
if (dVP > 0)
|
|
dVP = 0;
|
|
// przeplyw ZP <-> rozdzielacz
|
|
if ((BrakeStatus & b_hld) == b_off)
|
|
dv = PF(BVP, VVP, 0.0011 * SizeBR) * dt;
|
|
else
|
|
dv = 0;
|
|
BrakeRes->Flow(dv);
|
|
dV1 = dv * 0.95;
|
|
ValveRes->Flow(-0.05 * dv);
|
|
// przeplyw PG <-> rozdzielacz
|
|
dv = PF(PP, VVP, 0.01 * SizeBR) * dt;
|
|
ValveRes->Flow(-dv);
|
|
|
|
ValveRes->Act();
|
|
BrakeCyl->Act();
|
|
BrakeRes->Act();
|
|
return dv - dV1;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Returns the high-pressure inflow accumulated by the previous GetPF call
|
|
/// (the dVP variable) — used by the host to bookkeep main-reservoir consumption.
|
|
/// </summary>
|
|
double TWest::GetHPFlow(double const HP, double const dt)
|
|
{
|
|
return dVP;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Sets the auxiliary brake target pressure. If P exceeds the current
|
|
/// cylinder pressure, the double check valve (DCV) is engaged so that LBP
|
|
/// drives the cylinder.
|
|
/// </summary>
|
|
/// <param name="P">Auxiliary brake pressure [bar].</param>
|
|
void TWest::SetLBP(double const P)
|
|
{
|
|
LBP = P;
|
|
if (P > BrakeCyl->P())
|
|
// begin
|
|
DCV = true;
|
|
// end
|
|
// else
|
|
// LBP:=P;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Sets the EP intensity. A positive value engages the DCV; a zero value
|
|
/// while the previous EPS was non-zero latches LBP from the cylinder
|
|
/// (or clears it when below a threshold), modelling EP-release hysteresis.
|
|
/// </summary>
|
|
/// <param name="nEPS">New EP intensity.</param>
|
|
void TWest::SetEPS(double const nEPS)
|
|
{
|
|
|
|
if (nEPS > 0)
|
|
DCV = true;
|
|
else if (nEPS == 0 && EPS != 0)
|
|
{
|
|
if (LBP > 0.4)
|
|
LBP = BrakeCyl->P();
|
|
if (LBP < 0.15)
|
|
LBP = 0;
|
|
}
|
|
EPS = nEPS;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Recomputes the load-weighing coefficient LoadC from the current vehicle
|
|
/// mass: linear interpolation between TareBP/MaxBP for masses in [TareM, LoadM],
|
|
/// and 1.0 for masses at or above LoadM.
|
|
/// </summary>
|
|
/// <param name="mass">Current vehicle mass.</param>
|
|
void TWest::PLC(double const mass)
|
|
{
|
|
LoadC = 1 + int(mass < LoadM) * ((TareBP + (MaxBP - TareBP) * (mass - TareM) / (LoadM - TareM)) / MaxBP - 1);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Stores the load-weighing parameters: tare mass, loaded mass and the
|
|
/// cylinder pressure that should be reached for the tare mass.
|
|
/// </summary>
|
|
/// <param name="TM">Tare (empty) mass.</param>
|
|
/// <param name="LM">Loaded mass.</param>
|
|
/// <param name="TBP">Tare-mass cylinder pressure.</param>
|
|
void TWest::SetLP(double const TM, double const LM, double const TBP)
|
|
{
|
|
TareM = TM;
|
|
LoadM = LM;
|
|
TareBP = TBP;
|
|
}
|
|
|
|
//---OERLIKON EST4---
|
|
/// <summary>
|
|
/// Implements the releaser logic: while engaged, vents the control reservoir
|
|
/// (CntrlRes) toward the lower of valve pre-chamber / auxiliary reservoir
|
|
/// (with a 0.05 bar margin); disengages once CntrlRes has fallen below VVP.
|
|
/// </summary>
|
|
/// <param name="dt">Time step [s].</param>
|
|
void TESt::CheckReleaser(double const dt)
|
|
{
|
|
double VVP = std::min(ValveRes->P(), BrakeRes->P() + 0.05);
|
|
double CVP = CntrlRes->P() - 0.0;
|
|
|
|
// odluzniacz
|
|
if ((BrakeStatus & b_rls) == b_rls)
|
|
{
|
|
if (CVP - VVP < 0)
|
|
BrakeStatus &= ~b_rls;
|
|
else
|
|
{
|
|
CntrlRes->Flow(+PF(CVP, 0, 0.1) * dt);
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Drives the BrakeStatus state machine (b_on / b_hld) of the ESt main slide
|
|
/// valve from the current valve pre-chamber, brake cylinder and control
|
|
/// reservoir pressures. Triggers the accelerator (sf_Acc) at the start of
|
|
/// braking and the cylinder-vent sound flag (sf_CylU) on release.
|
|
/// </summary>
|
|
/// <param name="BCP">Brake cylinder (or impulse-chamber) pressure.</param>
|
|
/// <param name="dV1">In/out brake-pipe flow correction (unused in this base impl).</param>
|
|
void TESt::CheckState(double const BCP, double & /*dV1*/)
|
|
{
|
|
|
|
double const VVP{ValveRes->P()};
|
|
double const CVP{CntrlRes->P()};
|
|
|
|
// sprawdzanie stanu
|
|
if (BCP > 0.25)
|
|
{
|
|
|
|
if ((BrakeStatus & b_hld) == b_hld)
|
|
{
|
|
CheckStateHeld(BCP, VVP, CVP);
|
|
}
|
|
else
|
|
{
|
|
|
|
if (VVP + BCP / BVM < CVP && (CVP - VVP) * BVM > 0.25)
|
|
{
|
|
// zatrzymanie luzowanie
|
|
BrakeStatus |= b_hld;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
|
|
if (VVP + 0.1 < CVP)
|
|
{
|
|
// poczatek hamowania
|
|
if ((BrakeStatus & b_hld) == 0)
|
|
{
|
|
// przyspieszacz
|
|
ValveRes->CreatePress(0.02 * VVP);
|
|
SoundFlag |= sf_Acc;
|
|
ValveRes->Act();
|
|
}
|
|
BrakeStatus |= b_on | b_hld;
|
|
}
|
|
}
|
|
|
|
if ((BrakeStatus & b_hld) == 0)
|
|
{
|
|
SoundFlag |= sf_CylU;
|
|
}
|
|
}
|
|
|
|
// the state of a valve holding: braking on in steps, the filling stopped, or released
|
|
void TESt::CheckStateHeld(double const BCP, double const VVP, double const CVP)
|
|
{
|
|
if (VVP + 0.003 + BCP / BVM < CVP)
|
|
{
|
|
// hamowanie stopniowe
|
|
BrakeStatus |= b_on;
|
|
}
|
|
else
|
|
{
|
|
if (VVP + BCP / BVM > CVP)
|
|
{
|
|
// zatrzymanie napelaniania
|
|
BrakeStatus &= ~b_on;
|
|
}
|
|
if (VVP - 0.003 + (BCP - 0.1) / BVM > CVP)
|
|
{
|
|
// luzowanie
|
|
BrakeStatus &= ~(b_on | b_hld);
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Returns the dimensionless opening factor of the ZS-filling slide valve
|
|
/// (control reservoir <-> brake pipe) for the current pre-chamber/auxiliary
|
|
/// reservoir state and brake-cylinder pressure.
|
|
/// </summary>
|
|
/// <param name="BP">Brake cylinder (or impulse) pressure.</param>
|
|
/// <returns>Opening coefficient (0 closed, 1 fully open).</returns>
|
|
double TESt::CVs(double const BP) const
|
|
{
|
|
double VVP;
|
|
double BVP;
|
|
double CVP;
|
|
|
|
BVP = BrakeRes->P();
|
|
CVP = CntrlRes->P();
|
|
VVP = ValveRes->P();
|
|
|
|
// przeplyw ZS <-> PG
|
|
if (VVP < CVP - 0.12 || BVP < CVP - 0.3 || BP > 0.4)
|
|
return 0;
|
|
else if (VVP > CVP + 0.4)
|
|
if (BVP > CVP + 0.2)
|
|
return 0.23;
|
|
else
|
|
return 0.05;
|
|
else if (BVP > CVP - 0.1)
|
|
return 1;
|
|
else
|
|
return 0.3;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Returns the dimensionless opening factor of the ZP-filling slide valve
|
|
/// (auxiliary reservoir <-> valve pre-chamber) as a function of brake
|
|
/// cylinder pressure, distinguishing initial filling, lap and full-pressure regions.
|
|
/// </summary>
|
|
/// <param name="BCP">Brake cylinder pressure.</param>
|
|
/// <returns>Opening coefficient.</returns>
|
|
double TESt::BVs(double const BCP) const
|
|
{
|
|
double VVP;
|
|
double BVP;
|
|
double CVP;
|
|
|
|
BVP = BrakeRes->P();
|
|
CVP = CntrlRes->P();
|
|
VVP = ValveRes->P();
|
|
|
|
// przeplyw ZP <-> rozdzielacz
|
|
if (BVP < CVP - 0.3)
|
|
return 0.6;
|
|
else if (BCP < 0.5)
|
|
if (VVP > CVP + 0.4)
|
|
return 0.1;
|
|
else
|
|
return 0.3;
|
|
else
|
|
return 0;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Refills the auxiliary reservoir (ZP) from the valve pre-chamber through the
|
|
/// check valve of the slide valve, opened as far as <see cref="BVs"/> says for the
|
|
/// given cylinder (or impulse-chamber) pressure, while the pre-chamber is more
|
|
/// than 0.05 bar above the reservoir. The flows wait for the caller's Act().
|
|
/// </summary>
|
|
/// <param name="BCP">Brake cylinder (or impulse-chamber) pressure.</param>
|
|
/// <param name="dt">Time step [s].</param>
|
|
/// <returns>Volume taken into the auxiliary reservoir, 0.96 of it drawn from the brake pipe.</returns>
|
|
double TESt::FillBrakeRes(double const BCP, double const dt) const
|
|
{
|
|
double const BVP{BrakeRes->P()};
|
|
double const VVP{ValveRes->P()};
|
|
double const temp{BVs(BCP)};
|
|
double dv{0.0};
|
|
if (VVP - 0.05 > BVP)
|
|
dv = PF(BVP, VVP, 0.02 * SizeBR * temp / 1.87) * dt;
|
|
BrakeRes->Flow(dv);
|
|
ValveRes->Flow(-0.04 * dv);
|
|
return dv;
|
|
}
|
|
|
|
/// <summary>
|
|
/// One-step Oerlikon ESt distributor advance: runs CheckState/CheckReleaser,
|
|
/// integrates the ZS <-> PG, ZP <-> cylinder, ZP <-> pre-chamber and
|
|
/// PG <-> pre-chamber flows, and returns the net brake-pipe exchange.
|
|
/// </summary>
|
|
/// <param name="PP">Brake pipe pressure [bar].</param>
|
|
/// <param name="dt">Time step [s].</param>
|
|
/// <param name="Vel">Vehicle velocity [m/s].</param>
|
|
/// <returns>Net volume exchanged with the brake pipe.</returns>
|
|
double TESt::GetPF(double const PP, double const dt, double const Vel)
|
|
{
|
|
double dv;
|
|
double dV1;
|
|
double temp;
|
|
double VVP;
|
|
double BVP;
|
|
double BCP;
|
|
double CVP;
|
|
|
|
BVP = BrakeRes->P();
|
|
BCP = BrakeCyl->P();
|
|
|
|
dV1 = 0;
|
|
|
|
// sprawdzanie stanu
|
|
CheckState(BCP, dV1);
|
|
CheckReleaser(dt);
|
|
|
|
CVP = CntrlRes->P();
|
|
VVP = ValveRes->P();
|
|
// przeplyw ZS <-> PG
|
|
temp = CVs(BCP);
|
|
dv = PF(CVP, VVP, 0.0015 * temp) * dt;
|
|
CntrlRes->Flow(+dv);
|
|
ValveRes->Flow(-0.04 * dv);
|
|
dV1 = dV1 - 0.96 * dv;
|
|
|
|
// luzowanie
|
|
if ((BrakeStatus & b_hld) == b_off)
|
|
dv = PF(0, BCP, 0.0058 * SizeBC) * dt;
|
|
else
|
|
dv = 0;
|
|
BrakeCyl->Flow(-dv);
|
|
|
|
// przeplyw ZP <-> silowniki
|
|
if ((BrakeStatus & b_on) == b_on)
|
|
dv = PF(BVP, BCP, 0.016 * SizeBC) * dt;
|
|
else
|
|
dv = 0;
|
|
BrakeRes->Flow(dv);
|
|
BrakeCyl->Flow(-dv);
|
|
|
|
// przeplyw ZP <-> rozdzielacz
|
|
dV1 = dV1 + FillBrakeRes(BCP, dt) * 0.96;
|
|
// przeplyw PG <-> rozdzielacz
|
|
dv = PF(PP, VVP, 0.01) * dt;
|
|
ValveRes->Flow(-dv);
|
|
|
|
ValveRes->Act();
|
|
BrakeCyl->Act();
|
|
BrakeRes->Act();
|
|
CntrlRes->Act();
|
|
return dv - dV1;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Initialises the ESt distributor: pre-charges valve / brake / control
|
|
/// reservoirs (the ZS is sized at 15 l), clears BrakeStatus and computes the
|
|
/// brake-pipe to brake-cylinder transmission ratio (BVM = MaxBP / (HPP-LPP)).
|
|
/// </summary>
|
|
/// <param name="PP">Brake pipe pressure [bar].</param>
|
|
/// <param name="HPP">High (control) pressure [bar].</param>
|
|
/// <param name="LPP">Low pressure threshold [bar].</param>
|
|
/// <param name="BP">Initial cylinder pressure [bar].</param>
|
|
/// <param name="BDF">Initial brake delay flag.</param>
|
|
void TESt::Init(double const PP, double const HPP, double const LPP, double const BP, int const BDF)
|
|
{
|
|
TBrake::Init(PP, HPP, LPP, BP, BDF);
|
|
ValveRes->CreatePress(PP);
|
|
BrakeCyl->CreatePress(BP);
|
|
BrakeRes->CreatePress(PP);
|
|
CntrlRes->CreateCap(15);
|
|
CntrlRes->CreatePress(HPP);
|
|
BrakeStatus = b_off;
|
|
|
|
BVM = 1.0 / (HPP - LPP) * MaxBP;
|
|
|
|
BrakeDelayFlag = BDF;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Stub for setting ESt-specific characteristic parameters; reserved for
|
|
/// derived variants and currently a no-op.
|
|
/// </summary>
|
|
/// <param name="i_crc">Characteristic value.</param>
|
|
void TESt::EStParams(double const /*i_crc*/) const { /* no effect for this device type */ }
|
|
|
|
/// <summary>Returns the control reservoir (ZS) pressure.</summary>
|
|
double TESt::GetCRP()
|
|
{
|
|
return CntrlRes->P();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Vents the valve, brake and control reservoirs to zero
|
|
/// (used on vehicle reset / decoupling).
|
|
/// </summary>
|
|
void TESt::ForceEmptiness()
|
|
{
|
|
|
|
ValveRes->CreatePress(0);
|
|
BrakeRes->CreatePress(0);
|
|
CntrlRes->CreatePress(0);
|
|
|
|
ValveRes->Act();
|
|
BrakeRes->Act();
|
|
CntrlRes->Act();
|
|
}
|
|
|
|
//---EP2---
|
|
|
|
/// <summary>
|
|
/// Initialises the EP2-equipped distributor: chains TLSt::Init, sizes the
|
|
/// 1-litre impulse chamber (ImplsRes), pre-charges it to BP, sets the
|
|
/// auxiliary reservoir to PP and locks the brake delay to P.
|
|
/// </summary>
|
|
/// <param name="PP">Brake pipe pressure [bar].</param>
|
|
/// <param name="HPP">High (control) pressure [bar].</param>
|
|
/// <param name="LPP">Low pressure threshold [bar].</param>
|
|
/// <param name="BP">Initial cylinder pressure [bar].</param>
|
|
/// <param name="BDF">Initial brake delay flag (overridden to P).</param>
|
|
void TEStEP2::Init(double const PP, double const HPP, double const LPP, double const BP, int const BDF)
|
|
{
|
|
TLSt::Init(PP, HPP, LPP, BP, BDF);
|
|
ImplsRes->CreateCap(1);
|
|
ImplsRes->CreatePress(BP);
|
|
|
|
BrakeRes->CreatePress(PP);
|
|
|
|
BrakeDelayFlag = bdelay_P;
|
|
BrakeDelays = bdelay_P;
|
|
}
|
|
|
|
/// <summary>
|
|
/// One-step distributor advance for the ESt + EP2 combination. Drives the
|
|
/// pneumatic state machine via the impulse chamber, runs the EP brake
|
|
/// integrator (<see cref="EPCalc"/>) and computes the cylinder fill/release
|
|
/// against the higher of the impulse-chamber and EP-driven LBP target.
|
|
/// </summary>
|
|
/// <param name="PP">Brake pipe pressure [bar].</param>
|
|
/// <param name="dt">Time step [s].</param>
|
|
/// <param name="Vel">Vehicle velocity [m/s].</param>
|
|
/// <returns>Net volume exchanged with the brake pipe.</returns>
|
|
double TEStEP2::GetPF(double const PP, double const dt, double const Vel)
|
|
{
|
|
double result;
|
|
double dv;
|
|
double dV1;
|
|
double temp;
|
|
double VVP;
|
|
double BVP;
|
|
double BCP;
|
|
double CVP;
|
|
|
|
BVP = BrakeRes->P();
|
|
VVP = ValveRes->P();
|
|
BCP = ImplsRes->P();
|
|
CVP = CntrlRes->P(); // 110115 - konsultacje warszawa1
|
|
|
|
dV1 = 0;
|
|
|
|
// odluzniacz
|
|
CheckReleaser(dt);
|
|
|
|
UpdateStatusEP2(BCP, VVP, CVP);
|
|
|
|
// przeplyw ZS <-> PG
|
|
if (BVP < CVP - 0.2 || BrakeStatus != b_off || BCP > 0.25)
|
|
temp = 0;
|
|
else if (VVP > CVP + 0.4)
|
|
temp = 0.1;
|
|
else
|
|
temp = 0.5;
|
|
|
|
dv = PF(CVP, VVP, 0.0015 * temp / 1.8) * dt;
|
|
CntrlRes->Flow(+dv);
|
|
ValveRes->Flow(-0.04 * dv);
|
|
dV1 = dV1 - 0.96 * dv;
|
|
|
|
// przeplyw ZP <-> rozdzielacz: as in every ESt, the auxiliary reservoir also charges from the brake pipe,
|
|
// not from the main reservoir pipe alone, so a unit hauled with the brake hose alone charges and brakes
|
|
dV1 = dV1 + FillBrakeRes(BCP, dt) * 0.96;
|
|
|
|
// hamulec EP
|
|
EPCalc(dt);
|
|
|
|
// luzowanie KI
|
|
if ((BrakeStatus & b_hld) == b_off)
|
|
dv = PF(0, BCP, 0.00083) * dt;
|
|
else
|
|
dv = 0;
|
|
ImplsRes->Flow(-dv);
|
|
// przeplyw ZP <-> KI
|
|
if ((BrakeStatus & b_on) == b_on && BCP < MaxBP * LoadC)
|
|
dv = PF(BVP, BCP, 0.0006) * dt;
|
|
else
|
|
dv = 0;
|
|
BrakeRes->Flow(dv);
|
|
ImplsRes->Flow(-dv);
|
|
// przeplyw PG <-> rozdzielacz
|
|
dv = PF(PP, VVP, 0.01 * SizeBR) * dt;
|
|
ValveRes->Flow(-dv);
|
|
|
|
result = dv - dV1;
|
|
|
|
temp = std::max(BCP, LBP);
|
|
|
|
if (ImplsRes->P() > LBP + 0.01)
|
|
LBP = 0;
|
|
|
|
// luzowanie CH
|
|
if (BrakeCyl->P() > temp + 0.005 || std::max(ImplsRes->P(), 8 * LBP) < 0.05)
|
|
dv = PF(0, BrakeCyl->P(), 0.25 * SizeBC * (0.01 + (BrakeCyl->P() - temp))) * dt;
|
|
else
|
|
dv = 0;
|
|
BrakeCyl->Flow(-dv);
|
|
// przeplyw ZP <-> CH
|
|
if (BrakeCyl->P() < temp - 0.005 && std::max(ImplsRes->P(), 8 * LBP) > 0.10 && std::max(BCP, LBP) < MaxBP * LoadC)
|
|
dv = PF(BVP, BrakeCyl->P(), 0.35 * SizeBC * (0.01 - (BrakeCyl->P() - temp))) * dt;
|
|
else
|
|
dv = 0;
|
|
BrakeRes->Flow(dv);
|
|
BrakeCyl->Flow(-dv);
|
|
|
|
ImplsRes->Act();
|
|
ValveRes->Act();
|
|
BrakeCyl->Act();
|
|
BrakeRes->Act();
|
|
CntrlRes->Act();
|
|
return result;
|
|
}
|
|
|
|
// the state of the valve: braking in steps, holding or releasing, the start of braking
|
|
void TEStEP2::UpdateStatusEP2(double const BCP, double const VVP, double const CVP)
|
|
{
|
|
// sprawdzanie stanu
|
|
if ((BrakeStatus & b_hld) == b_hld && BCP > 0.25)
|
|
{
|
|
if (VVP + 0.003 + BCP / BVM < CVP - 0.12)
|
|
BrakeStatus |= b_on; // hamowanie stopniowe;
|
|
else if (VVP - 0.003 + BCP / BVM > CVP - 0.12)
|
|
BrakeStatus &= ~(b_on | b_hld); // luzowanie;
|
|
else if (VVP + BCP / BVM > CVP - 0.12)
|
|
BrakeStatus &= ~b_on; // zatrzymanie napelaniania;
|
|
}
|
|
else if (VVP + 0.10 < CVP - 0.12 && BCP < 0.25) // poczatek hamowania
|
|
{
|
|
// if ((BrakeStatus & 1) == 0)
|
|
//{
|
|
// // ValveRes.CreatePress(0.5*VVP); //110115 - konsultacje warszawa1
|
|
// // SoundFlag:=SoundFlag or sf_Acc;
|
|
// // ValveRes.Act;
|
|
//}
|
|
BrakeStatus |= b_on | b_hld;
|
|
}
|
|
else if (VVP + BCP / BVM < CVP - 0.12 && BCP > 0.25) // zatrzymanie luzowanie
|
|
BrakeStatus |= b_hld;
|
|
|
|
if ((BrakeStatus & b_hld) == 0)
|
|
{
|
|
SoundFlag |= sf_CylU;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Recomputes the load-weighing coefficient LoadC for the current vehicle
|
|
/// mass (linear between TareBP/MaxBP for TareM..LoadM, capped at 1.0).
|
|
/// </summary>
|
|
/// <param name="mass">Current vehicle mass.</param>
|
|
void TEStEP2::PLC(double const mass)
|
|
{
|
|
LoadC = 1 + int(mass < LoadM) * ((TareBP + (MaxBP - TareBP) * (mass - TareM) / (LoadM - TareM)) / MaxBP - 1);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Sets the EP intensity. When the EP is energised and the pneumatic cylinder
|
|
/// pressure exceeds the EP target, latches the EP target up to the cylinder
|
|
/// pressure to avoid releasing the pneumatic brake while EP is active.
|
|
/// </summary>
|
|
/// <param name="nEPS">New EP intensity.</param>
|
|
void TEStEP2::SetEPS(double const nEPS)
|
|
{
|
|
EPS = nEPS;
|
|
if (EPS > 0 && LBP + 0.01 < BrakeCyl->P())
|
|
LBP = BrakeCyl->P();
|
|
}
|
|
|
|
/// <summary>Stores the load-weighing parameters.</summary>
|
|
/// <param name="TM">Tare (empty) mass.</param>
|
|
/// <param name="LM">Loaded mass.</param>
|
|
/// <param name="TBP">Tare-mass cylinder pressure.</param>
|
|
void TEStEP2::SetLP(double const TM, double const LM, double const TBP)
|
|
{
|
|
TareM = TM;
|
|
LoadM = LM;
|
|
TareBP = TBP;
|
|
}
|
|
|
|
/// <summary>
|
|
/// EP2 EP-flow integrator: drives LBP toward the auxiliary-reservoir pressure
|
|
/// when EPS > 0 (apply) or toward 0 when EPS < 0 (release), with a
|
|
/// quadratic-in-EPS rate and a load-weighing-aware ceiling at MaxBP * LoadC.
|
|
/// </summary>
|
|
/// <param name="dt">Time step [s].</param>
|
|
void TEStEP2::EPCalc(double dt)
|
|
{
|
|
double temp = BrakeRes->P() * int(EPS > 0);
|
|
double dv = PF(temp, LBP, 0.00053 + 0.00060 * int(EPS < 0)) * dt * EPS * EPS * int(LBP * EPS < MaxBP * LoadC);
|
|
LBP = LBP - dv;
|
|
}
|
|
|
|
/// <summary>
|
|
/// EP1 (proportional) EP-flow integrator: interprets the fractional part of
|
|
/// EPS as a continuous EP target and drives LBP toward MaxBP * LoadC * frac
|
|
/// (clamped to the auxiliary reservoir pressure), softening the valve
|
|
/// opening with a clamped error term S.
|
|
/// </summary>
|
|
/// <param name="dt">Time step [s].</param>
|
|
void TEStEP1::EPCalc(double dt)
|
|
{
|
|
double temp = EPS - std::floor(EPS); // część ułamkowa jest hamulcem EP
|
|
double LBPLim = std::min(MaxBP * LoadC * temp, BrakeRes->P()); // do czego dążymy
|
|
double S = 10 * std::clamp(LBPLim - LBP, -0.1, 0.1); // przymykanie zaworku
|
|
double dv = PF(S > 0 ? BrakeRes->P() : 0, LBP, abs(S) * (0.00053 + 0.00060 * int(S < 0))) * dt; // przepływ
|
|
LBP = LBP - dv;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Stores the EP intensity for the EP1 (proportional) variant.
|
|
/// The fractional part is read by <see cref="EPCalc"/> as the proportional set-point.
|
|
/// </summary>
|
|
/// <param name="nEPS">EP intensity.</param>
|
|
void TEStEP1::SetEPS(double const nEPS)
|
|
{
|
|
EPS = nEPS;
|
|
}
|
|
|
|
//---EST3--
|
|
|
|
/// <summary>
|
|
/// One-step distributor advance for ESt3. Identical structure to TESt::GetPF
|
|
/// but with G/P-dependent fill/release curves on the brake cylinder
|
|
/// (slower fill/faster release on the goods setting at low cylinder pressures).
|
|
/// </summary>
|
|
/// <param name="PP">Brake pipe pressure [bar].</param>
|
|
/// <param name="dt">Time step [s].</param>
|
|
/// <param name="Vel">Vehicle velocity [m/s].</param>
|
|
/// <returns>Net volume exchanged with the brake pipe.</returns>
|
|
double TESt3::GetPF(double const PP, double const dt, double const Vel)
|
|
{
|
|
double BVP{BrakeRes->P()};
|
|
double VVP;
|
|
double BCP{BrakeCyl->P()};
|
|
double CVP;
|
|
|
|
double dv{0.0};
|
|
double dV1{0.0};
|
|
|
|
// sprawdzanie stanu
|
|
CheckState(BCP, dV1);
|
|
CheckReleaser(dt);
|
|
|
|
CVP = CntrlRes->P();
|
|
VVP = ValveRes->P();
|
|
// przeplyw ZS <-> PG
|
|
double temp = CVs(BCP);
|
|
dv = PF(CVP, VVP, 0.0015 * temp) * dt;
|
|
CntrlRes->Flow(+dv);
|
|
ValveRes->Flow(-0.04 * dv);
|
|
dV1 = dV1 - 0.96 * dv;
|
|
|
|
// luzowanie
|
|
if ((BrakeStatus & b_hld) == b_off)
|
|
dv = PF(0, BCP, 0.0042 * (1.37 - (BrakeDelayFlag == bdelay_G ? 1.0 : 0.0)) * SizeBC) * dt;
|
|
else
|
|
dv = 0;
|
|
BrakeCyl->Flow(-dv);
|
|
// przeplyw ZP <-> silowniki
|
|
if ((BrakeStatus & b_on) == b_on)
|
|
dv = PF(BVP, BCP, 0.017 * (1.00 + (BCP < 0.58 && BrakeDelayFlag == bdelay_G ? 1.0 : 0.0)) * (1.13 - (BCP > 0.60 && BrakeDelayFlag == bdelay_G ? 1.0 : 0.0)) * SizeBC) * dt;
|
|
else
|
|
dv = 0;
|
|
BrakeRes->Flow(dv);
|
|
BrakeCyl->Flow(-dv);
|
|
// przeplyw ZP <-> rozdzielacz
|
|
temp = BVs(BCP);
|
|
if (VVP - 0.05 > BVP)
|
|
dv = PF(BVP, VVP, 0.02 * SizeBR * temp / 1.87) * dt;
|
|
else
|
|
dv = 0;
|
|
BrakeRes->Flow(dv);
|
|
dV1 += dv * 0.96;
|
|
ValveRes->Flow(-0.04 * dv);
|
|
// przeplyw PG <-> rozdzielacz
|
|
dv = PF(PP, VVP, 0.01) * dt;
|
|
ValveRes->Flow(-dv);
|
|
|
|
ValveRes->Act();
|
|
BrakeCyl->Act();
|
|
BrakeRes->Act();
|
|
CntrlRes->Act();
|
|
return dv - dV1;
|
|
}
|
|
|
|
//---EST4-RAPID---
|
|
|
|
/// <summary>
|
|
/// One-step distributor advance for ESt4 with the rapid (R) step. Updates the
|
|
/// hysteretic <c>RapidStatus</c> latch from speed (R bit set, > 70 km/h or
|
|
/// hysteresis above 55 km/h), smooths the rapid coefficient (RapidTemp) and
|
|
/// computes the cylinder fill/vent against the impulse-chamber pressure.
|
|
/// </summary>
|
|
/// <param name="PP">Brake pipe pressure [bar].</param>
|
|
/// <param name="dt">Time step [s].</param>
|
|
/// <param name="Vel">Vehicle velocity [m/s].</param>
|
|
/// <returns>Net volume exchanged with the brake pipe.</returns>
|
|
double TESt4R::GetPF(double const PP, double const dt, double const Vel)
|
|
{
|
|
double result;
|
|
double dv;
|
|
double dV1;
|
|
double temp;
|
|
double VVP;
|
|
double BVP;
|
|
double BCP;
|
|
double CVP;
|
|
|
|
BVP = BrakeRes->P();
|
|
BCP = ImplsRes->P();
|
|
|
|
dV1 = 0;
|
|
|
|
// sprawdzanie stanu
|
|
CheckState(BCP, dV1);
|
|
CheckReleaser(dt);
|
|
|
|
CVP = CntrlRes->P();
|
|
VVP = ValveRes->P();
|
|
// przeplyw ZS <-> PG
|
|
temp = CVs(BCP);
|
|
dv = PF(CVP, VVP, 0.0015 * temp / 1.8) * dt;
|
|
CntrlRes->Flow(+dv);
|
|
ValveRes->Flow(-0.04 * dv);
|
|
dV1 = dV1 - 0.96 * dv;
|
|
|
|
// luzowanie KI
|
|
if ((BrakeStatus & b_hld) == b_off)
|
|
dv = PF(0, BCP, 0.00037 * 1.14 * 15 / 19) * dt;
|
|
else
|
|
dv = 0;
|
|
ImplsRes->Flow(-dv);
|
|
// przeplyw ZP <-> KI
|
|
if ((BrakeStatus & b_on) == b_on)
|
|
dv = PF(BVP, BCP, 0.0014) * dt;
|
|
else
|
|
dv = 0;
|
|
// BrakeRes->Flow(dV);
|
|
ImplsRes->Flow(-dv);
|
|
// przeplyw ZP <-> rozdzielacz
|
|
temp = BVs(BCP);
|
|
if (BVP < VVP - 0.05) // or((PP<CVP)and(CVP<PP-0.1)
|
|
dv = PF(BVP, VVP, 0.02 * SizeBR * temp / 1.87) * dt;
|
|
else
|
|
dv = 0;
|
|
BrakeRes->Flow(dv);
|
|
dV1 = dV1 + dv * 0.96;
|
|
ValveRes->Flow(-0.04 * dv);
|
|
// przeplyw PG <-> rozdzielacz
|
|
dv = PF(PP, VVP, 0.01 * SizeBR) * dt;
|
|
ValveRes->Flow(-dv);
|
|
|
|
result = dv - dV1;
|
|
|
|
RapidStatus = (BrakeDelayFlag & bdelay_R) == bdelay_R && ((Vel > 55 && RapidStatus == true) || Vel > 70);
|
|
|
|
RapidTemp = RapidTemp + (0.9 * int(RapidStatus) - RapidTemp) * dt / 2;
|
|
temp = 1.9 - RapidTemp;
|
|
if ((BrakeStatus & b_asb) == b_asb)
|
|
temp = 1000;
|
|
// luzowanie CH
|
|
if (BrakeCyl->P() * temp > ImplsRes->P() + 0.005 || ImplsRes->P() < 0.25)
|
|
if ((BrakeStatus & b_asb) == b_asb)
|
|
dv = PFVd(BrakeCyl->P(), 0, 0.115 * SizeBC * 4, ImplsRes->P() / temp) * dt;
|
|
else
|
|
dv = PFVd(BrakeCyl->P(), 0, 0.115 * SizeBC, ImplsRes->P() / temp) * dt;
|
|
// dV:=PF(0,BrakeCyl.P,0.115*sizeBC/2)*dt
|
|
// dV:=PFVd(BrakeCyl.P,0,0.015*sizeBC/2,ImplsRes.P/temp)*dt
|
|
else
|
|
dv = 0;
|
|
BrakeCyl->Flow(-dv);
|
|
// przeplyw ZP <-> CH
|
|
if (BrakeCyl->P() * temp < ImplsRes->P() - 0.005 && ImplsRes->P() > 0.3)
|
|
// dV:=PFVa(BVP,BrakeCyl.P,0.020*sizeBC,ImplsRes.P/temp)*dt
|
|
dv = PFVa(BVP, BrakeCyl->P(), 0.60 * SizeBC, ImplsRes->P() / temp) * dt;
|
|
else
|
|
dv = 0;
|
|
BrakeRes->Flow(-dv);
|
|
BrakeCyl->Flow(+dv);
|
|
|
|
ImplsRes->Act();
|
|
ValveRes->Act();
|
|
BrakeCyl->Act();
|
|
BrakeRes->Act();
|
|
CntrlRes->Act();
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Initialises the ESt4R: chains TESt::Init, sizes the impulse chamber to 1 l
|
|
/// and pre-charges it to BP, then selects the rapid (R) brake delay.
|
|
/// </summary>
|
|
/// <param name="PP">Brake pipe pressure [bar].</param>
|
|
/// <param name="HPP">High (control) pressure [bar].</param>
|
|
/// <param name="LPP">Low pressure threshold [bar].</param>
|
|
/// <param name="BP">Initial cylinder pressure [bar].</param>
|
|
/// <param name="BDF">Initial brake delay flag (overridden to R).</param>
|
|
void TESt4R::Init(double const PP, double const HPP, double const LPP, double const BP, int const BDF)
|
|
{
|
|
TESt::Init(PP, HPP, LPP, BP, BDF);
|
|
ImplsRes->CreateCap(1);
|
|
ImplsRes->CreatePress(BP);
|
|
|
|
BrakeDelayFlag = bdelay_R;
|
|
}
|
|
|
|
//---EST3/AL2---
|
|
|
|
/// <summary>
|
|
/// One-step distributor advance for ESt3 with AL2 load-weighing equipment.
|
|
/// Drives the impulse chamber (KI) with G/P-dependent flow rates and feeds
|
|
/// the load relay output (BrakeCyl pressure scaled by LoadC) to the cylinder.
|
|
/// </summary>
|
|
/// <param name="PP">Brake pipe pressure [bar].</param>
|
|
/// <param name="dt">Time step [s].</param>
|
|
/// <param name="Vel">Vehicle velocity [m/s].</param>
|
|
/// <returns>Net volume exchanged with the brake pipe.</returns>
|
|
double TESt3AL2::GetPF(double const PP, double const dt, double const Vel)
|
|
{
|
|
double result;
|
|
double dv;
|
|
double dV1;
|
|
double temp;
|
|
double VVP;
|
|
double BVP;
|
|
double BCP;
|
|
double CVP;
|
|
|
|
BVP = BrakeRes->P();
|
|
BCP = ImplsRes->P();
|
|
CVP = CntrlRes->P() - 0.0;
|
|
|
|
dV1 = 0;
|
|
|
|
// sprawdzanie stanu
|
|
CheckState(BCP, dV1);
|
|
CheckReleaser(dt);
|
|
|
|
VVP = ValveRes->P();
|
|
// przeplyw ZS <-> PG
|
|
temp = CVs(BCP);
|
|
dv = PF(CVP, VVP, 0.0015 * temp) * dt;
|
|
CntrlRes->Flow(+dv);
|
|
ValveRes->Flow(-0.04 * dv);
|
|
dV1 = dV1 - 0.96 * dv;
|
|
|
|
// luzowanie KI
|
|
if ((BrakeStatus & b_hld) == b_off)
|
|
dv = PF(0, BCP, 0.00017 * (1.37 - int(BrakeDelayFlag == bdelay_G))) * dt;
|
|
else
|
|
dv = 0;
|
|
ImplsRes->Flow(-dv);
|
|
// przeplyw ZP <-> KI
|
|
if ((BrakeStatus & b_on) == b_on && BCP < MaxBP)
|
|
dv = PF(BVP, BCP, 0.0008 * (1 + int(BCP < 0.58 && BrakeDelayFlag == bdelay_G)) * (1.13 - int(BCP > 0.6 && BrakeDelayFlag == bdelay_G))) * dt;
|
|
else
|
|
dv = 0;
|
|
BrakeRes->Flow(dv);
|
|
ImplsRes->Flow(-dv);
|
|
// przeplyw ZP <-> rozdzielacz
|
|
temp = BVs(BCP);
|
|
if (VVP - 0.05 > BVP)
|
|
dv = PF(BVP, VVP, 0.02 * SizeBR * temp / 1.87) * dt;
|
|
else
|
|
dv = 0;
|
|
BrakeRes->Flow(dv);
|
|
dV1 = dV1 + dv * 0.96;
|
|
ValveRes->Flow(-0.04 * dv);
|
|
// przeplyw PG <-> rozdzielacz
|
|
dv = PF(PP, VVP, 0.01) * dt;
|
|
ValveRes->Flow(-dv);
|
|
result = dv - dV1;
|
|
|
|
// luzowanie CH
|
|
if (BrakeCyl->P() > ImplsRes->P() * LoadC + 0.005 || ImplsRes->P() < 0.15)
|
|
dv = PF(0, BrakeCyl->P(), 0.015 * SizeBC) * dt;
|
|
else
|
|
dv = 0;
|
|
BrakeCyl->Flow(-dv);
|
|
|
|
// przeplyw ZP <-> CH
|
|
if (BrakeCyl->P() < ImplsRes->P() * LoadC - 0.005 && ImplsRes->P() > 0.15)
|
|
dv = PF(BVP, BrakeCyl->P(), 0.020 * SizeBC) * dt;
|
|
else
|
|
dv = 0;
|
|
BrakeRes->Flow(dv);
|
|
BrakeCyl->Flow(-dv);
|
|
|
|
ImplsRes->Act();
|
|
ValveRes->Act();
|
|
BrakeCyl->Act();
|
|
BrakeRes->Act();
|
|
CntrlRes->Act();
|
|
return result;
|
|
}
|
|
|
|
/// <summary>Recomputes the load-weighing coefficient LoadC for the current mass.</summary>
|
|
/// <param name="mass">Current vehicle mass.</param>
|
|
void TESt3AL2::PLC(double const mass)
|
|
{
|
|
LoadC = 1 + int(mass < LoadM) * ((TareBP + (MaxBP - TareBP) * (mass - TareM) / (LoadM - TareM)) / MaxBP - 1);
|
|
}
|
|
|
|
/// <summary>Stores the load-weighing parameters (TareM, LoadM, TareBP).</summary>
|
|
/// <param name="TM">Tare (empty) mass.</param>
|
|
/// <param name="LM">Loaded mass.</param>
|
|
/// <param name="TBP">Tare-mass cylinder pressure.</param>
|
|
void TESt3AL2::SetLP(double const TM, double const LM, double const TBP)
|
|
{
|
|
TareM = TM;
|
|
LoadM = LM;
|
|
TareBP = TBP;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Initialises ESt3/AL2: chains TESt::Init and sizes the impulse chamber
|
|
/// (KI) to 1 l, pre-charging it to BP.
|
|
/// </summary>
|
|
/// <param name="PP">Brake pipe pressure [bar].</param>
|
|
/// <param name="HPP">High (control) pressure [bar].</param>
|
|
/// <param name="LPP">Low pressure threshold [bar].</param>
|
|
/// <param name="BP">Initial cylinder pressure [bar].</param>
|
|
/// <param name="BDF">Initial brake delay flag.</param>
|
|
void TESt3AL2::Init(double const PP, double const HPP, double const LPP, double const BP, int const BDF)
|
|
{
|
|
TESt::Init(PP, HPP, LPP, BP, BDF);
|
|
ImplsRes->CreateCap(1);
|
|
ImplsRes->CreatePress(BP);
|
|
}
|
|
|
|
//---LSt---
|
|
|
|
/// <summary>
|
|
/// One-step distributor advance for LSt: locomotive variant of ESt4R.
|
|
/// Re-implements the state machine inline (with the universal-button releaser),
|
|
/// drives the impulse chamber from CVP/VVP via PF1, applies a smoothed
|
|
/// rapid-step (RM) above a velocity threshold, factors in the ED brake
|
|
/// release (EDFlag) and the auxiliary brake LBP through a double check valve,
|
|
/// and supports the anti-slip release path (b_asb_unbrake / ASBP).
|
|
/// </summary>
|
|
/// <param name="PP">Brake pipe pressure [bar].</param>
|
|
/// <param name="dt">Time step [s].</param>
|
|
/// <param name="Vel">Vehicle velocity [m/s].</param>
|
|
/// <returns>Net volume exchanged with the brake pipe.</returns>
|
|
double TLSt::GetPF(double const PP, double const dt, double const Vel)
|
|
{
|
|
double result;
|
|
|
|
// ValveRes.CreatePress(LBP);
|
|
// LBP:=0;
|
|
|
|
double const BVP{BrakeRes->P()};
|
|
double const VVP{ValveRes->P()};
|
|
double const BCP{ImplsRes->P()};
|
|
double const CVP{CntrlRes->P()};
|
|
|
|
double dV{0.0};
|
|
double dV1{0.0};
|
|
|
|
UpdateStatusLSt(BCP, VVP, CVP);
|
|
ReleaserLSt(BCP, CVP, dt);
|
|
|
|
// przeplyw ZS <-> PG
|
|
double temp;
|
|
if ((CVP - BCP) * BVM > 0.5)
|
|
temp = 0.0;
|
|
else if (VVP > CVP + 0.4)
|
|
temp = 0.5;
|
|
else
|
|
temp = 0.5;
|
|
|
|
dV = PF1(CVP, VVP, 0.0015 * temp / 1.8 / 2) * dt;
|
|
CntrlRes->Flow(+dV);
|
|
ValveRes->Flow(-0.04 * dV);
|
|
dV1 = dV1 - 0.96 * dV;
|
|
|
|
// luzowanie KI {G}
|
|
// if VVP>BCP then
|
|
// dV:=PF(VVP,BCP,0.00004)*dt
|
|
// else if (CVP-BCP)<1.5 then
|
|
// dV:=PF(VVP,BCP,0.00020*(1.33-int((CVP-BCP)*BVM>0.65)))*dt
|
|
// else dV:=0; 0.00025 P
|
|
/*P*/
|
|
if (VVP > BCP)
|
|
{
|
|
dV = PF(VVP, BCP, 0.00043 * (1.5 - (true == ((CVP - BCP) * BVM > 1.0 && BrakeDelayFlag == bdelay_G) ? 1.0 : 0.0)), 0.1) * dt;
|
|
}
|
|
else if (CVP - BCP < 1.5)
|
|
{
|
|
dV = PF(VVP, BCP, 0.001472 * (1.36 - (true == ((CVP - BCP) * BVM > 1.0 && BrakeDelayFlag == bdelay_G) ? 1.0 : 0.0)), 0.1) * dt;
|
|
}
|
|
else
|
|
{
|
|
dV = 0;
|
|
}
|
|
|
|
ImplsRes->Flow(-dV);
|
|
ValveRes->Flow(+dV);
|
|
// przeplyw PG <-> rozdzielacz
|
|
dV = PF(PP, VVP, 0.01, 0.1) * dt;
|
|
ValveRes->Flow(-dV);
|
|
|
|
result = dV - dV1;
|
|
|
|
// if Vel>55 then temp:=0.72 else
|
|
// temp:=1;{R}
|
|
// cisnienie PP
|
|
CylinderFlowLSt(BCP, BVP, CVP, dt, Vel);
|
|
|
|
ImplsRes->Act();
|
|
ValveRes->Act();
|
|
BrakeCyl->Act();
|
|
BrakeRes->Act();
|
|
CntrlRes->Act();
|
|
// LBP:=ValveRes->P();
|
|
// ValveRes.CreatePress(ImplsRes->P());
|
|
return result;
|
|
}
|
|
|
|
// the state of the valve: braking in steps, holding or releasing, the start of braking
|
|
void TLSt::UpdateStatusLSt(double const BCP, double const VVP, double const CVP)
|
|
{
|
|
// sprawdzanie stanu
|
|
// NOTE: partial copypaste from checkstate() of base class
|
|
// TODO: clean inheritance for checkstate() and checkreleaser() and reuse these instead of manual copypaste
|
|
if ((BrakeStatus & b_hld) == b_hld && BCP > 0.25)
|
|
{
|
|
if (VVP + 0.003 + BCP / BVM < CVP)
|
|
{
|
|
// hamowanie stopniowe
|
|
BrakeStatus |= b_on;
|
|
}
|
|
else if (VVP - 0.003 + (BCP - 0.1) / BVM > CVP)
|
|
{
|
|
// luzowanie
|
|
BrakeStatus &= ~(b_on | b_hld);
|
|
}
|
|
else if (VVP + BCP / BVM > CVP)
|
|
{
|
|
// zatrzymanie napelaniania
|
|
BrakeStatus &= ~b_on;
|
|
}
|
|
}
|
|
else if (VVP + 0.10 < CVP && BCP < 0.25)
|
|
{
|
|
// poczatek hamowania
|
|
if ((BrakeStatus & b_hld) == b_off)
|
|
{
|
|
SoundFlag |= sf_Acc;
|
|
}
|
|
BrakeStatus |= b_on | b_hld;
|
|
}
|
|
else if (VVP + (BCP - 0.1) / BVM < CVP && (CVP - VVP) * BVM > 0.25 && BCP > 0.25)
|
|
{
|
|
// zatrzymanie luzowanie
|
|
BrakeStatus |= b_hld;
|
|
}
|
|
if ((BrakeStatus & b_hld) == 0)
|
|
{
|
|
SoundFlag |= sf_CylU;
|
|
}
|
|
}
|
|
|
|
// the releaser, or the universal button set to release, letting the control reservoir out into the impulse chamber
|
|
void TLSt::ReleaserLSt(double const BCP, double const CVP, double const dt)
|
|
{
|
|
double dV;
|
|
// equivalent of checkreleaser() in the base class?
|
|
if (bool is_releasing = BrakeStatus & b_rls || UniversalFlag & TUniversalBrake::ub_Release; is_releasing)
|
|
{
|
|
if (CVP < 0.0)
|
|
{
|
|
BrakeStatus &= ~b_rls;
|
|
}
|
|
else
|
|
{ // 008
|
|
dV = PF1(CVP, BCP, 0.024) * dt;
|
|
CntrlRes->Flow(dV);
|
|
}
|
|
}
|
|
}
|
|
|
|
// the cylinders filled from the auxiliary reservoir or let out to the pressure the relay is set to: by the pilot
|
|
// pressure, the anti-slip brake and the rapid setting, at least the local brake's
|
|
void TLSt::CylinderFlowLSt(double const BCP, double const BVP, double const CVP, double const dt, double const Vel)
|
|
{
|
|
double dV;
|
|
double temp;
|
|
RapidTemp = RapidTemp + (RM * int(Vel > 55 && (BrakeDelayFlag & bdelay_R) == bdelay_R) - RapidTemp) * dt / 2;
|
|
temp = 1 - RapidTemp;
|
|
if (EDFlag > 0.2)
|
|
temp = 10000;
|
|
double tempasb = 0;
|
|
if ((UniversalFlag & TUniversalBrake::ub_AntiSlipBrake) > 0 || (BrakeStatus & b_asb_unbrake) == b_asb_unbrake)
|
|
tempasb = ASBP;
|
|
// powtarzacz — podwojny zawor zwrotny
|
|
temp = std::max(((CVP - BCP) * BVM + tempasb) / temp, LBP);
|
|
// luzowanie CH
|
|
if (BrakeCyl->P() > temp + 0.005 || temp < 0.28)
|
|
// dV:=PF(0,BrakeCyl->P(),0.0015*3*sizeBC)*dt
|
|
// dV:=PF(0,BrakeCyl->P(),0.005*3*sizeBC)*dt
|
|
dV = PFVd(BrakeCyl->P(), 0, 0.005 * 7 * SizeBC, temp) * dt;
|
|
else
|
|
dV = 0;
|
|
BrakeCyl->Flow(-dV);
|
|
// przeplyw ZP <-> CH
|
|
if (BrakeCyl->P() < temp - 0.005 && temp > 0.29)
|
|
// dV:=PF(BVP,BrakeCyl->P(),0.002*3*sizeBC*2)*dt
|
|
dV = -PFVa(BVP, BrakeCyl->P(), 0.002 * 7 * SizeBC * 2, temp) * dt;
|
|
else
|
|
dV = 0;
|
|
BrakeRes->Flow(dV);
|
|
BrakeCyl->Flow(-dV);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Initialises the LSt: chains TESt4R::Init, resizes the valve pre-chamber
|
|
/// (1 l) and impulse chamber (8 l) for locomotive use, pre-charges
|
|
/// pressures, clears the ED-release flag.
|
|
/// </summary>
|
|
/// <param name="PP">Brake pipe pressure [bar].</param>
|
|
/// <param name="HPP">High (control) pressure [bar].</param>
|
|
/// <param name="LPP">Low pressure threshold [bar].</param>
|
|
/// <param name="BP">Initial cylinder pressure [bar].</param>
|
|
/// <param name="BDF">Initial brake delay flag.</param>
|
|
void TLSt::Init(double const PP, double const HPP, double const LPP, double const BP, int const BDF)
|
|
{
|
|
TESt4R::Init(PP, HPP, LPP, BP, BDF);
|
|
ValveRes->CreateCap(1);
|
|
ImplsRes->CreateCap(8);
|
|
ImplsRes->CreatePress(PP);
|
|
BrakeRes->CreatePress(8);
|
|
ValveRes->CreatePress(PP);
|
|
|
|
EDFlag = 0;
|
|
|
|
BrakeDelayFlag = BDF;
|
|
}
|
|
|
|
/// <summary>Sets the auxiliary (local) brake target pressure feeding the DCV.</summary>
|
|
/// <param name="P">Auxiliary brake pressure [bar].</param>
|
|
void TLSt::SetLBP(double const P)
|
|
{
|
|
LBP = P;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Returns the brake-cylinder reference pressure used by the ED brake
|
|
/// controller: (CVP - BCP) * BVM, where BCP is the impulse-chamber pressure.
|
|
/// </summary>
|
|
double TLSt::GetEDBCP()
|
|
{
|
|
double CVP;
|
|
double BCP;
|
|
|
|
CVP = CntrlRes->P();
|
|
BCP = ImplsRes->P();
|
|
return (CVP - BCP) * BVM;
|
|
}
|
|
|
|
/// <summary>Sets the ED brake state (intensity, 0..1) used to relax the pneumatic brake.</summary>
|
|
/// <param name="EDstate">ED intensity.</param>
|
|
void TLSt::SetED(double const EDstate)
|
|
{
|
|
EDFlag = EDstate;
|
|
}
|
|
|
|
/// <summary>Sets the rapid-step ratio. RM = 1 - RMR (so RMR=0 disables, RMR>0 enables).</summary>
|
|
/// <param name="RMR">Reduction ratio.</param>
|
|
void TLSt::SetRM(double const RMR)
|
|
{
|
|
RM = 1 - RMR;
|
|
}
|
|
|
|
/// <summary>
|
|
/// High-pressure replenishment: takes air only when the source pressure is
|
|
/// higher than the auxiliary reservoir, returning a non-positive flow that
|
|
/// is added back to BrakeRes.
|
|
/// </summary>
|
|
/// <param name="HP">High-pressure source [bar].</param>
|
|
/// <param name="dt">Time step [s] (folded into the orifice term in this implementation).</param>
|
|
/// <returns>Inflow into BrakeRes (negative).</returns>
|
|
double TLSt::GetHPFlow(double const HP, double const dt)
|
|
{
|
|
double dv;
|
|
|
|
dv = std::min(PF(HP, BrakeRes->P(), 0.01 * dt), 0.0);
|
|
BrakeRes->Flow(-dv);
|
|
return dv;
|
|
}
|
|
|
|
//---EStED---
|
|
|
|
/// <summary>
|
|
/// One-step distributor advance for EStED (the EP09 "ESt + ED" valve).
|
|
/// Adds the intermediate reservoir (Miedzypoj), the closing-valve memory
|
|
/// (Zamykajacy), the accelerator-block latch (Przys_blok), nozzle-tuned
|
|
/// flows for ZP/ZS filling and the rapid-step / ED-release / anti-slip
|
|
/// path on top of the ESt pneumatics.
|
|
/// </summary>
|
|
/// <param name="PP">Brake pipe pressure [bar].</param>
|
|
/// <param name="dt">Time step [s].</param>
|
|
/// <param name="Vel">Vehicle velocity [m/s].</param>
|
|
/// <returns>Net volume exchanged with the brake pipe.</returns>
|
|
double TEStED::GetPF(double const PP, double const dt, double const Vel)
|
|
{
|
|
double dv;
|
|
double dV1;
|
|
double temp;
|
|
double VVP;
|
|
double BVP;
|
|
double BCP;
|
|
double CVP;
|
|
double MPP;
|
|
double nastG;
|
|
|
|
BVP = BrakeRes->P();
|
|
VVP = ValveRes->P();
|
|
BCP = ImplsRes->P();
|
|
CVP = CntrlRes->P() - 0.0;
|
|
MPP = Miedzypoj->P();
|
|
dV1 = 0;
|
|
|
|
nastG = BrakeDelayFlag & bdelay_G;
|
|
|
|
UpdateStatus(BCP, VVP, CVP, MPP);
|
|
|
|
if ((BrakeStatus & b_rls) == b_rls)
|
|
{
|
|
dv = PF(CVP, BCP, 0.024) * dt;
|
|
CntrlRes->Flow(+dv);
|
|
}
|
|
|
|
// luzowanie
|
|
if ((BrakeStatus & b_hld) == b_off)
|
|
dv = PF(0, BCP, Nozzles[3] * nastG + (1 - nastG) * Nozzles[1]) * dt;
|
|
else
|
|
dv = 0;
|
|
ImplsRes->Flow(-dv);
|
|
if ((BrakeStatus & b_on) == b_on && BCP < MaxBP)
|
|
dv = PF(BVP, BCP, Nozzles[2] * (nastG + 2 * int(BCP < 0.8)) + Nozzles[0] * (1 - nastG)) * dt;
|
|
else
|
|
dv = 0;
|
|
ImplsRes->Flow(-dv);
|
|
BrakeRes->Flow(dv);
|
|
|
|
Miedzypoj->Flow(IntermediateFlow(BCP, VVP, CVP, MPP, BVP, nastG) * dt * 0.15);
|
|
|
|
CylinderFlow(BCP, BVP, dt, Vel);
|
|
|
|
// przeplyw ZS <-> PG
|
|
if (MPP < CVP - 0.17)
|
|
temp = 0;
|
|
else if (MPP > CVP - 0.08)
|
|
temp = Nozzles[5];
|
|
else
|
|
temp = Nozzles[6];
|
|
dv = PF(CVP, MPP, temp) * dt;
|
|
CntrlRes->Flow(+dv);
|
|
ValveRes->Flow(-0.02 * dv);
|
|
dV1 = dV1 + 0.98 * dv;
|
|
|
|
// przeplyw ZP <-> MPJ
|
|
if (MPP - 0.05 > BVP)
|
|
dv = PF(BVP, MPP - 0.05, Nozzles[10] * nastG + (1 - nastG) * Nozzles[9]) * dt;
|
|
else
|
|
dv = 0;
|
|
BrakeRes->Flow(dv);
|
|
dV1 = dV1 + dv * 0.98;
|
|
ValveRes->Flow(-0.02 * dv);
|
|
// przeplyw PG <-> rozdzielacz
|
|
dv = PF(PP, VVP, 0.005) * dt; // 0.01
|
|
ValveRes->Flow(-dv);
|
|
|
|
ValveRes->Act();
|
|
BrakeCyl->Act();
|
|
BrakeRes->Act();
|
|
CntrlRes->Act();
|
|
Miedzypoj->Act();
|
|
ImplsRes->Act();
|
|
return dv - dV1;
|
|
}
|
|
|
|
// the state of the valve: braking in steps, holding or releasing, the accelerator at the start of braking, and the
|
|
// closing valve
|
|
void TEStED::UpdateStatus(double const BCP, double const VVP, double const CVP, double const MPP)
|
|
{
|
|
// sprawdzanie stanu
|
|
if (BCP < 0.25 && VVP + 0.08 > CVP)
|
|
Przys_blok = false;
|
|
|
|
// sprawdzanie stanu
|
|
if (VVP + 0.002 + BCP / BVM < CVP - 0.05 && Przys_blok)
|
|
BrakeStatus |= b_on | b_hld; // hamowanie stopniowe;
|
|
else if (VVP - 0.002 + (BCP - 0.1) / BVM > CVP - 0.05)
|
|
BrakeStatus &= ~(b_on | b_hld); // luzowanie;
|
|
else if (VVP + BCP / BVM > CVP - 0.05)
|
|
BrakeStatus &= ~b_on; // zatrzymanie napelaniania;
|
|
else if (VVP + (BCP - 0.1) / BVM < CVP - 0.05 && BCP > 0.25) // zatrzymanie luzowania
|
|
BrakeStatus |= b_hld;
|
|
|
|
// poczatek hamowania
|
|
if (VVP + 0.10 < CVP && BCP < 0.25 && !Przys_blok)
|
|
{
|
|
ValveRes->CreatePress(0.75 * VVP);
|
|
SoundFlag |= sf_Acc;
|
|
ValveRes->Act();
|
|
Przys_blok = true;
|
|
}
|
|
|
|
if (BCP > 0.5)
|
|
Zamykajacy = true;
|
|
else if (VVP - 0.6 < MPP)
|
|
Zamykajacy = false;
|
|
}
|
|
|
|
// the flow into the intermediate reservoir from the pipe and the control reservoir, less the flow filling the auxiliary one
|
|
double TEStED::IntermediateFlow(double const BCP, double const VVP, double const CVP, double const MPP, double const BVP, double const nastG) const
|
|
{
|
|
double dv;
|
|
double temp;
|
|
// przeplyw testowy miedzypojemnosci
|
|
if (MPP < CVP - 0.3)
|
|
temp = Nozzles[4];
|
|
else if (BCP < 0.5)
|
|
if (Zamykajacy)
|
|
temp = Nozzles[8]; // 1.25;
|
|
else
|
|
temp = Nozzles[7];
|
|
else
|
|
temp = 0;
|
|
dv = PF(MPP, VVP, temp);
|
|
|
|
if (MPP < CVP - 0.17)
|
|
temp = 0;
|
|
else if (MPP > CVP - 0.08)
|
|
temp = Nozzles[5];
|
|
else
|
|
temp = Nozzles[6];
|
|
dv = dv + PF(MPP, CVP, temp);
|
|
|
|
if (MPP - 0.05 > BVP)
|
|
dv = dv + PF(MPP - 0.05, BVP, Nozzles[10] * nastG + (1 - nastG) * Nozzles[9]);
|
|
if (MPP > VVP)
|
|
dv = dv + PF(MPP, VVP, 0.02);
|
|
return dv;
|
|
}
|
|
|
|
// the cylinders filled or let out to the pressure the relay is set to: by the pilot pressure and the load, at least the
|
|
// local brake's, the anti-slip brake's, faster at the rapid setting
|
|
void TEStED::CylinderFlow(double const BCP, double const BVP, double const dt, double const Vel)
|
|
{
|
|
double dv;
|
|
double temp;
|
|
RapidTemp = RapidTemp + (RM * int(Vel > RV && (BrakeDelayFlag & bdelay_R) == bdelay_R) - RapidTemp) * dt / 2;
|
|
temp = std::max(1 - RapidTemp, 0.001);
|
|
// if EDFlag then temp:=1000;
|
|
// temp:=temp/(1-);
|
|
|
|
// powtarzacz — podwojny zawor zwrotny
|
|
temp = std::max(LoadC * BCP / temp * std::clamp(1 - EDFlag, 0., 1.), LBP);
|
|
|
|
if ((UniversalFlag & TUniversalBrake::ub_AntiSlipBrake) > 0)
|
|
temp = std::max(temp, ASBP);
|
|
|
|
double speed = 1;
|
|
if (ASBP < 0.1 && (BrakeStatus & b_asb_unbrake) == b_asb_unbrake)
|
|
{
|
|
temp = 0;
|
|
speed = 3;
|
|
}
|
|
|
|
if (BrakeCyl->P() > temp)
|
|
dv = -PFVd(BrakeCyl->P(), 0, 0.05 * SizeBC * speed, temp) * dt;
|
|
else if (BrakeCyl->P() < temp && (BrakeStatus & b_asb) == 0)
|
|
dv = PFVa(BVP, BrakeCyl->P(), 0.05 * SizeBC, temp) * dt;
|
|
else
|
|
dv = 0;
|
|
|
|
BrakeCyl->Flow(dv);
|
|
if (dv > 0)
|
|
BrakeRes->Flow(-dv);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Initialises the EStED: chains TLSt::Init, sizes Miedzypoj (5 l), pre-charges
|
|
/// pressures, computes BVM with a 0.05 bar offset on HPP, configures the
|
|
/// 11 internal nozzle cross-sections (squared and scaled to the engine's
|
|
/// flow units) and clears the latches.
|
|
/// </summary>
|
|
/// <param name="PP">Brake pipe pressure [bar].</param>
|
|
/// <param name="HPP">High (control) pressure [bar].</param>
|
|
/// <param name="LPP">Low pressure threshold [bar].</param>
|
|
/// <param name="BP">Initial cylinder pressure [bar].</param>
|
|
/// <param name="BDF">Initial brake delay flag.</param>
|
|
void TEStED::Init(double const PP, double const HPP, double const LPP, double const BP, int const BDF)
|
|
{
|
|
TLSt::Init(PP, HPP, LPP, BP, BDF);
|
|
|
|
ValveRes->CreatePress(PP);
|
|
BrakeCyl->CreatePress(BP);
|
|
|
|
// CntrlRes:=TReservoir.Create;
|
|
// CntrlRes.CreateCap(15);
|
|
// CntrlRes.CreatePress(1*HPP);
|
|
|
|
BrakeStatus = BP > 1.0 ? 1 : 0;
|
|
Miedzypoj->CreateCap(5);
|
|
Miedzypoj->CreatePress(PP);
|
|
|
|
ImplsRes->CreateCap(1);
|
|
ImplsRes->CreatePress(BP);
|
|
|
|
BVM = 1.0 / (HPP - 0.05 - LPP) * MaxBP;
|
|
|
|
BrakeDelayFlag = BDF;
|
|
Zamykajacy = false;
|
|
EDFlag = 0;
|
|
|
|
Nozzles[0] = 1.250 / 1.7;
|
|
Nozzles[1] = 0.907;
|
|
Nozzles[2] = 0.510 / 1.7;
|
|
Nozzles[3] = 0.524 / 1.17;
|
|
Nozzles[4] = 7.4;
|
|
Nozzles[7] = 5.3;
|
|
Nozzles[8] = 2.5;
|
|
Nozzles[9] = 7.28;
|
|
Nozzles[10] = 2.96;
|
|
Nozzles[5] = 1.1;
|
|
Nozzles[6] = 0.9;
|
|
|
|
{
|
|
for (int i = 0; i < 11; ++i)
|
|
{
|
|
Nozzles[i] = Nozzles[i] * Nozzles[i] * 3.14159 / 4000;
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Returns the ED reference pressure for EStED — impulse chamber pressure
|
|
/// scaled by the load-weighing coefficient.
|
|
/// </summary>
|
|
double TEStED::GetEDBCP()
|
|
{
|
|
return ImplsRes->P() * LoadC;
|
|
}
|
|
|
|
/// <summary>Recomputes the load-weighing coefficient LoadC for the current mass.</summary>
|
|
/// <param name="mass">Current vehicle mass.</param>
|
|
void TEStED::PLC(double const mass)
|
|
{
|
|
LoadC = 1 + int(mass < LoadM) * ((TareBP + (MaxBP - TareBP) * (mass - TareM) / (LoadM - TareM)) / MaxBP - 1);
|
|
}
|
|
|
|
/// <summary>Stores the load-weighing parameters.</summary>
|
|
/// <param name="TM">Tare (empty) mass.</param>
|
|
/// <param name="LM">Loaded mass.</param>
|
|
/// <param name="TBP">Tare-mass cylinder pressure.</param>
|
|
void TEStED::SetLP(double const TM, double const LM, double const TBP)
|
|
{
|
|
TareM = TM;
|
|
LoadM = LM;
|
|
TareBP = TBP;
|
|
}
|
|
|
|
//---DAKO CV1---
|
|
|
|
/// <summary>
|
|
/// Drives the BrakeStatus state machine for CV1: handles the releaser
|
|
/// auto-disengage (when CVP <= VVP) and the b_on/b_hld transitions
|
|
/// from the relations between pre-chamber, cylinder and control reservoir.
|
|
/// On the start of braking it returns dV1=1.25 to feed the brake-pipe
|
|
/// flow correction.
|
|
/// </summary>
|
|
/// <param name="BCP">Cylinder pressure.</param>
|
|
/// <param name="dV1">In/out brake-pipe flow correction.</param>
|
|
void TCV1::CheckState(double const BCP, double &dV1)
|
|
{
|
|
double VVP;
|
|
double BVP;
|
|
double CVP;
|
|
|
|
BVP = BrakeRes->P();
|
|
VVP = std::min(ValveRes->P(), BVP + 0.05);
|
|
CVP = CntrlRes->P();
|
|
|
|
// odluzniacz
|
|
if ((BrakeStatus & b_rls) == b_rls && CVP - VVP < 0)
|
|
BrakeStatus &= ~b_rls;
|
|
|
|
// sprawdzanie stanu
|
|
if ((BrakeStatus & b_hld) == b_hld)
|
|
{
|
|
if (VVP + 0.003 + BCP / BVM < CVP)
|
|
BrakeStatus |= b_on; // hamowanie stopniowe;
|
|
else if (VVP - 0.003 + BCP * 1.0 / BVM > CVP)
|
|
BrakeStatus &= ~(b_on | b_hld); // luzowanie;
|
|
else if (VVP + BCP * 1.0 / BVM > CVP)
|
|
BrakeStatus &= ~b_on; // zatrzymanie napelaniania;
|
|
}
|
|
else if (VVP + 0.10 < CVP && BCP < 0.1) // poczatek hamowania
|
|
{
|
|
BrakeStatus |= b_on | b_hld;
|
|
dV1 = 1.25;
|
|
}
|
|
else if (VVP + BCP / BVM < CVP && BCP > 0.25) // zatrzymanie luzowanie
|
|
BrakeStatus |= b_hld;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Returns the CV1 ZS-filling slide valve opening factor: closed once any
|
|
/// pneumatic braking has been requested (BP > 0.05), otherwise a constant 0.23.
|
|
/// </summary>
|
|
/// <param name="BP">Cylinder pressure.</param>
|
|
/// <returns>Opening coefficient.</returns>
|
|
double TCV1::CVs(double const BP) const
|
|
{
|
|
// przeplyw ZS <-> PG
|
|
if (BP > 0.05)
|
|
return 0;
|
|
else
|
|
return 0.23;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Returns the CV1 ZP-filling slide valve opening factor: 1 while the
|
|
/// auxiliary reservoir is below the control reservoir (refill), 0 once the
|
|
/// brake has been applied, and a small charging value otherwise.
|
|
/// </summary>
|
|
/// <param name="BCP">Cylinder pressure.</param>
|
|
/// <returns>Opening coefficient.</returns>
|
|
double TCV1::BVs(double const BCP) const
|
|
{
|
|
double VVP;
|
|
double BVP;
|
|
double CVP;
|
|
|
|
BVP = BrakeRes->P();
|
|
CVP = CntrlRes->P();
|
|
VVP = ValveRes->P();
|
|
|
|
// przeplyw ZP <-> rozdzielacz
|
|
if (BVP < CVP - 0.1)
|
|
return 1;
|
|
else if (BCP > 0.05)
|
|
return 0;
|
|
else
|
|
return 0.2 * (1.5 - int(BVP > VVP));
|
|
}
|
|
|
|
/// <summary>
|
|
/// One-step distributor advance for the DAKO CV1: runs CheckState, integrates
|
|
/// ZS <-> PG, ZP <-> cylinder (with G/P-dependent fill rates), ZP <->
|
|
/// pre-chamber and PG <-> pre-chamber flows.
|
|
/// </summary>
|
|
/// <param name="PP">Brake pipe pressure [bar].</param>
|
|
/// <param name="dt">Time step [s].</param>
|
|
/// <param name="Vel">Vehicle velocity [m/s].</param>
|
|
/// <returns>Net volume exchanged with the brake pipe.</returns>
|
|
double TCV1::GetPF(double const PP, double const dt, double const Vel)
|
|
{
|
|
double dv;
|
|
double dV1;
|
|
double temp;
|
|
double VVP;
|
|
double BVP;
|
|
double BCP;
|
|
double CVP;
|
|
|
|
BVP = BrakeRes->P();
|
|
BCP = BrakeCyl->P();
|
|
CVP = CntrlRes->P();
|
|
|
|
dV1 = 0;
|
|
|
|
// sprawdzanie stanu
|
|
CheckState(BCP, dV1);
|
|
|
|
VVP = ValveRes->P();
|
|
// przeplyw ZS <-> PG
|
|
temp = CVs(BCP);
|
|
dv = PF(CVP, VVP, 0.0015 * temp) * dt;
|
|
CntrlRes->Flow(+dv);
|
|
ValveRes->Flow(-0.04 * dv);
|
|
dV1 = dV1 - 0.96 * dv;
|
|
|
|
// luzowanie
|
|
if ((BrakeStatus & b_hld) == b_off)
|
|
dv = PF(0, BCP, 0.0042 * (1.37 - int(BrakeDelayFlag == bdelay_G)) * SizeBC) * dt;
|
|
else
|
|
dv = 0;
|
|
BrakeCyl->Flow(-dv);
|
|
|
|
// przeplyw ZP <-> silowniki
|
|
if ((BrakeStatus & b_on) == b_on)
|
|
dv = PF(BVP, BCP, 0.017 * (1 + int(BCP < 0.58 && BrakeDelayFlag == bdelay_G)) * (1.13 - int(BCP > 0.6 && BrakeDelayFlag == bdelay_G)) * SizeBC) * dt;
|
|
else
|
|
dv = 0;
|
|
BrakeRes->Flow(dv);
|
|
BrakeCyl->Flow(-dv);
|
|
|
|
// przeplyw ZP <-> rozdzielacz
|
|
temp = BVs(BCP);
|
|
if (VVP + 0.05 > BVP)
|
|
dv = PF(BVP, VVP, 0.02 * SizeBR * temp / 1.87) * dt;
|
|
else
|
|
dv = 0;
|
|
BrakeRes->Flow(dv);
|
|
dV1 = dV1 + dv * 0.96;
|
|
ValveRes->Flow(-0.04 * dv);
|
|
// przeplyw PG <-> rozdzielacz
|
|
dv = PF(PP, VVP, 0.01) * dt;
|
|
ValveRes->Flow(-dv);
|
|
|
|
ValveRes->Act();
|
|
BrakeCyl->Act();
|
|
BrakeRes->Act();
|
|
CntrlRes->Act();
|
|
return dv - dV1;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Initialises the CV1: pre-charges valve / brake / control reservoirs (ZS = 15 l),
|
|
/// clears BrakeStatus and computes BVM (= MaxBP / (HPP-LPP)).
|
|
/// </summary>
|
|
/// <param name="PP">Brake pipe pressure [bar].</param>
|
|
/// <param name="HPP">High (control) pressure [bar].</param>
|
|
/// <param name="LPP">Low pressure threshold [bar].</param>
|
|
/// <param name="BP">Initial cylinder pressure [bar].</param>
|
|
/// <param name="BDF">Initial brake delay flag.</param>
|
|
void TCV1::Init(double const PP, double const HPP, double const LPP, double const BP, int const BDF)
|
|
{
|
|
TBrake::Init(PP, HPP, LPP, BP, BDF);
|
|
ValveRes->CreatePress(PP);
|
|
BrakeCyl->CreatePress(BP);
|
|
BrakeRes->CreatePress(PP);
|
|
CntrlRes->CreateCap(15);
|
|
CntrlRes->CreatePress(HPP);
|
|
BrakeStatus = b_off;
|
|
|
|
BVM = 1.0 / (HPP - LPP) * MaxBP;
|
|
|
|
BrakeDelayFlag = BDF;
|
|
}
|
|
|
|
/// <summary>Returns the control reservoir (ZS) pressure.</summary>
|
|
double TCV1::GetCRP()
|
|
{
|
|
return CntrlRes->P();
|
|
}
|
|
|
|
/// <summary>Vents valve, brake and control reservoirs to zero.</summary>
|
|
void TCV1::ForceEmptiness()
|
|
{
|
|
|
|
ValveRes->CreatePress(0);
|
|
BrakeRes->CreatePress(0);
|
|
CntrlRes->CreatePress(0);
|
|
|
|
ValveRes->Act();
|
|
BrakeRes->Act();
|
|
CntrlRes->Act();
|
|
}
|
|
|
|
//---CV1-L-TR---
|
|
|
|
/// <summary>Sets the auxiliary (local) brake target pressure feeding the DCV.</summary>
|
|
/// <param name="P">Auxiliary brake pressure [bar].</param>
|
|
void TCV1L_TR::SetLBP(double const P)
|
|
{
|
|
LBP = P;
|
|
}
|
|
|
|
/// <summary>
|
|
/// High-pressure replenishment for CV1-L-TR: pulls air into the auxiliary
|
|
/// reservoir whenever the source is higher (returns a non-positive flow).
|
|
/// </summary>
|
|
/// <param name="HP">High-pressure source [bar].</param>
|
|
/// <param name="dt">Time step [s].</param>
|
|
/// <returns>Inflow into BrakeRes (negative on intake).</returns>
|
|
double TCV1L_TR::GetHPFlow(double const HP, double const dt)
|
|
{
|
|
double dv;
|
|
|
|
dv = PF(HP, BrakeRes->P(), 0.01) * dt;
|
|
dv = std::min(0., dv);
|
|
BrakeRes->Flow(-dv);
|
|
return dv;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Initialises CV1-L-TR: chains TCV1::Init and sizes the impulse chamber to
|
|
/// 2.5 l, pre-charging it to BP.
|
|
/// </summary>
|
|
/// <param name="PP">Brake pipe pressure [bar].</param>
|
|
/// <param name="HPP">High (control) pressure [bar].</param>
|
|
/// <param name="LPP">Low pressure threshold [bar].</param>
|
|
/// <param name="BP">Initial cylinder pressure [bar].</param>
|
|
/// <param name="BDF">Initial brake delay flag.</param>
|
|
void TCV1L_TR::Init(double const PP, double const HPP, double const LPP, double const BP, int const BDF)
|
|
{
|
|
TCV1::Init(PP, HPP, LPP, BP, BDF);
|
|
ImplsRes->CreateCap(2.5);
|
|
ImplsRes->CreatePress(BP);
|
|
}
|
|
|
|
/// <summary>
|
|
/// One-step distributor advance for CV1-L-TR. Drives the impulse chamber (KI)
|
|
/// from the CV1 state machine, then computes cylinder fill/release against
|
|
/// the higher of the impulse-chamber and auxiliary-brake (LBP) pressure.
|
|
/// </summary>
|
|
/// <param name="PP">Brake pipe pressure [bar].</param>
|
|
/// <param name="dt">Time step [s].</param>
|
|
/// <param name="Vel">Vehicle velocity [m/s].</param>
|
|
/// <returns>Net volume exchanged with the brake pipe.</returns>
|
|
double TCV1L_TR::GetPF(double const PP, double const dt, double const Vel)
|
|
{
|
|
double result;
|
|
double dv;
|
|
double dV1;
|
|
double temp;
|
|
double VVP;
|
|
double BVP;
|
|
double BCP;
|
|
double CVP;
|
|
|
|
BVP = BrakeRes->P();
|
|
BCP = ImplsRes->P();
|
|
CVP = CntrlRes->P();
|
|
|
|
dV1 = 0;
|
|
|
|
// sprawdzanie stanu
|
|
CheckState(BCP, dV1);
|
|
|
|
VVP = ValveRes->P();
|
|
// przeplyw ZS <-> PG
|
|
temp = CVs(BCP);
|
|
dv = PF(CVP, VVP, 0.0015 * temp) * dt;
|
|
CntrlRes->Flow(+dv);
|
|
ValveRes->Flow(-0.04 * dv);
|
|
dV1 = dV1 - 0.96 * dv;
|
|
|
|
// luzowanie KI
|
|
if ((BrakeStatus & b_hld) == b_off)
|
|
dv = PF(0, BCP, 0.000425 * (1.37 - int(BrakeDelayFlag == bdelay_G))) * dt;
|
|
else
|
|
dv = 0;
|
|
ImplsRes->Flow(-dv);
|
|
// przeplyw ZP <-> KI
|
|
if ((BrakeStatus & b_on) == b_on && BCP < MaxBP)
|
|
dv = PF(BVP, BCP, 0.002 * (1 + int(BCP < 0.58 && BrakeDelayFlag == bdelay_G)) * (1.13 - int(BCP > 0.6 && BrakeDelayFlag == bdelay_G))) * dt;
|
|
else
|
|
dv = 0;
|
|
BrakeRes->Flow(dv);
|
|
ImplsRes->Flow(-dv);
|
|
|
|
// przeplyw ZP <-> rozdzielacz
|
|
temp = BVs(BCP);
|
|
if (VVP + 0.05 > BVP)
|
|
dv = PF(BVP, VVP, 0.02 * SizeBR * temp / 1.87) * dt;
|
|
else
|
|
dv = 0;
|
|
BrakeRes->Flow(dv);
|
|
dV1 = dV1 + dv * 0.96;
|
|
ValveRes->Flow(-0.04 * dv);
|
|
// przeplyw PG <-> rozdzielacz
|
|
dv = PF(PP, VVP, 0.01) * dt;
|
|
result = dv - dV1;
|
|
|
|
temp = std::max(BCP, LBP);
|
|
|
|
// luzowanie CH
|
|
if (BrakeCyl->P() > temp + 0.005 || std::max(ImplsRes->P(), 8 * LBP) < 0.25)
|
|
dv = PF(0, BrakeCyl->P(), 0.015 * SizeBC) * dt;
|
|
else
|
|
dv = 0;
|
|
BrakeCyl->Flow(-dv);
|
|
|
|
// przeplyw ZP <-> CH
|
|
if (BrakeCyl->P() < temp - 0.005 && std::max(ImplsRes->P(), 8 * LBP) > 0.3 && std::max(BCP, LBP) < MaxBP)
|
|
dv = PF(BVP, BrakeCyl->P(), 0.020 * SizeBC) * dt;
|
|
else
|
|
dv = 0;
|
|
BrakeRes->Flow(dv);
|
|
BrakeCyl->Flow(-dv);
|
|
|
|
ImplsRes->Act();
|
|
ValveRes->Act();
|
|
BrakeCyl->Act();
|
|
BrakeRes->Act();
|
|
CntrlRes->Act();
|
|
return result;
|
|
}
|
|
|
|
//--- KNORR KE ---
|
|
/// <summary>
|
|
/// Implements the KE releaser logic: while engaged, vents the control
|
|
/// reservoir to zero via a 0.1-area orifice; auto-disengages once CVP <= VVP.
|
|
/// </summary>
|
|
/// <param name="dt">Time step [s].</param>
|
|
void TKE::CheckReleaser(double const dt)
|
|
{
|
|
double VVP;
|
|
double CVP;
|
|
|
|
VVP = ValveRes->P();
|
|
CVP = CntrlRes->P();
|
|
|
|
// odluzniacz
|
|
if (true == ((BrakeStatus & b_rls) == b_rls))
|
|
{
|
|
if (CVP - VVP < 0)
|
|
BrakeStatus &= ~b_rls;
|
|
else
|
|
CntrlRes->Flow(+PF(CVP, 0, 0.1) * dt);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Drives the KE BrakeStatus state machine from the relations between
|
|
/// pre-chamber, impulse-chamber and control reservoir pressures (KE-specific
|
|
/// thresholds — pulse on the pre-chamber down to 0.8*VVP and 0.1 bar
|
|
/// initial-step). Triggers sf_Acc and sf_CylU sound flags.
|
|
/// </summary>
|
|
/// <param name="BCP">Cylinder (or impulse-chamber) pressure.</param>
|
|
/// <param name="dV1">In/out brake-pipe flow correction (unused here).</param>
|
|
void TKE::CheckState(double const BCP, double & /*dV1*/)
|
|
{
|
|
double VVP;
|
|
double CVP;
|
|
|
|
VVP = ValveRes->P();
|
|
CVP = CntrlRes->P();
|
|
|
|
// sprawdzanie stanu
|
|
if (BCP > 0.1)
|
|
{
|
|
|
|
if ((BrakeStatus & b_hld) == b_hld)
|
|
{
|
|
CheckStateHeld(BCP, VVP, CVP);
|
|
}
|
|
else
|
|
{
|
|
|
|
if (VVP + BCP / BVM < CVP && (CVP - VVP) * BVM > 0.25)
|
|
{
|
|
// zatrzymanie luzowanie
|
|
BrakeStatus |= b_hld;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
|
|
if (VVP + 0.1 < CVP)
|
|
{
|
|
// poczatek hamowania
|
|
if ((BrakeStatus & b_hld) == 0)
|
|
{
|
|
// przyspieszacz
|
|
ValveRes->CreatePress(0.8 * VVP);
|
|
SoundFlag |= sf_Acc;
|
|
ValveRes->Act();
|
|
}
|
|
BrakeStatus |= b_on | b_hld;
|
|
}
|
|
}
|
|
|
|
if ((BrakeStatus & b_hld) == 0)
|
|
{
|
|
SoundFlag |= sf_CylU;
|
|
}
|
|
}
|
|
|
|
// the state of a valve holding: braking on in steps, the filling stopped, or released
|
|
void TKE::CheckStateHeld(double const BCP, double const VVP, double const CVP)
|
|
{
|
|
if (VVP + 0.003 + BCP / BVM < CVP)
|
|
{
|
|
// hamowanie stopniowe;
|
|
BrakeStatus |= b_on;
|
|
}
|
|
else
|
|
{
|
|
if (VVP + BCP / BVM > CVP)
|
|
{
|
|
// zatrzymanie napelaniania;
|
|
BrakeStatus &= ~b_on;
|
|
}
|
|
if (VVP - 0.003 + BCP / BVM > CVP)
|
|
{
|
|
// luzowanie;
|
|
BrakeStatus &= ~(b_on | b_hld);
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Returns the KE ZS-filling slide valve opening factor: closed once
|
|
/// any pneumatic braking is requested, slightly attenuated when the
|
|
/// pre-chamber is over-pressurised, and a constant 0.23 otherwise.
|
|
/// </summary>
|
|
/// <param name="BP">Cylinder (or impulse) pressure.</param>
|
|
/// <returns>Opening coefficient.</returns>
|
|
double TKE::CVs(double const BP) const
|
|
{
|
|
double VVP;
|
|
double CVP;
|
|
|
|
CVP = CntrlRes->P();
|
|
VVP = ValveRes->P();
|
|
|
|
// przeplyw ZS <-> PG
|
|
if (BP > 0.2)
|
|
return 0;
|
|
else if (VVP > CVP + 0.4)
|
|
return 0.05;
|
|
else
|
|
return 0.23;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Returns the KE ZP-filling slide valve opening factor: closed when ZP
|
|
/// is already above the pre-chamber, fully open when ZP is well below the
|
|
/// control reservoir, otherwise a low refill rate (0.13).
|
|
/// </summary>
|
|
/// <param name="BCP">Impulse-chamber pressure.</param>
|
|
/// <returns>Opening coefficient.</returns>
|
|
double TKE::BVs(double const /*BCP*/) const
|
|
{
|
|
double VVP;
|
|
double BVP;
|
|
double CVP;
|
|
|
|
BVP = BrakeRes->P();
|
|
CVP = CntrlRes->P();
|
|
VVP = ValveRes->P();
|
|
|
|
// przeplyw ZP <-> rozdzielacz
|
|
if (BVP > VVP)
|
|
return 0;
|
|
else if (BVP < CVP - 0.3)
|
|
return 0.6;
|
|
else
|
|
return 0.13;
|
|
}
|
|
|
|
/// <summary>
|
|
/// One-step distributor advance for the Knorr KE. Drives CheckState/CheckReleaser,
|
|
/// integrates ZS <-> PG, ZP <-> impulse chamber and ZP <-> pre-chamber,
|
|
/// applies the velocity- and friction-pair-aware rapid step (RM, RV) and
|
|
/// the load-relay output to the brake cylinder, including the auxiliary
|
|
/// brake (LBP) and anti-slip path (ASBP).
|
|
/// </summary>
|
|
/// <param name="PP">Brake pipe pressure [bar].</param>
|
|
/// <param name="dt">Time step [s].</param>
|
|
/// <param name="Vel">Vehicle velocity [m/s].</param>
|
|
/// <returns>Net volume exchanged with the brake pipe.</returns>
|
|
double TKE::GetPF(double const PP, double const dt, double const Vel)
|
|
{
|
|
double dv;
|
|
double dV1;
|
|
double temp;
|
|
double VVP;
|
|
double BVP;
|
|
double BCP;
|
|
double IMP;
|
|
double CVP;
|
|
|
|
BVP = BrakeRes->P();
|
|
VVP = ValveRes->P();
|
|
BCP = BrakeCyl->P();
|
|
IMP = ImplsRes->P();
|
|
CVP = CntrlRes->P();
|
|
|
|
dV1 = 0;
|
|
|
|
// sprawdzanie stanu
|
|
CheckState(IMP, dV1);
|
|
CheckReleaser(dt);
|
|
|
|
// przeplyw ZS <-> PG
|
|
temp = CVs(IMP);
|
|
dv = PF(CVP, VVP, 0.0015 * temp) * dt;
|
|
CntrlRes->Flow(+dv);
|
|
ValveRes->Flow(-0.04 * dv);
|
|
dV1 = dV1 - 0.96 * dv;
|
|
|
|
// luzowanie
|
|
if ((BrakeStatus & b_hld) == b_off)
|
|
{
|
|
if ((BrakeDelayFlag & bdelay_G) == 0)
|
|
temp = 0.283 + 0.139;
|
|
else
|
|
temp = 0.139;
|
|
dv = PF(0, IMP, 0.001 * temp) * dt;
|
|
}
|
|
else
|
|
dv = 0;
|
|
ImplsRes->Flow(-dv);
|
|
|
|
// przeplyw ZP <-> silowniki
|
|
if ((BrakeStatus & b_on) == b_on && IMP < MaxBP)
|
|
{
|
|
temp = 0.113;
|
|
if ((BrakeDelayFlag & bdelay_G) == 0)
|
|
temp = temp + 0.636;
|
|
if (BCP < 0.5)
|
|
temp = temp + 0.785;
|
|
dv = PF(BVP, IMP, 0.001 * temp) * dt;
|
|
}
|
|
else
|
|
dv = 0;
|
|
BrakeRes->Flow(dv);
|
|
ImplsRes->Flow(-dv);
|
|
|
|
IMP = CylinderFlowKE(IMP, BCP, BVP, Vel, dt);
|
|
|
|
// przeplyw ZP <-> rozdzielacz
|
|
temp = BVs(IMP);
|
|
// if(BrakeStatus and b_hld)=b_off then
|
|
if (IMP < 0.25 || VVP + 0.05 > BVP)
|
|
dv = PF(BVP, VVP, 0.02 * SizeBR * temp / 1.87) * dt;
|
|
else
|
|
dv = 0;
|
|
BrakeRes->Flow(dv);
|
|
dV1 = dV1 + dv * 0.96;
|
|
ValveRes->Flow(-0.04 * dv);
|
|
// przeplyw PG <-> rozdzielacz
|
|
dv = PF(PP, VVP, 0.01) * dt;
|
|
ValveRes->Flow(-dv);
|
|
|
|
ValveRes->Act();
|
|
BrakeCyl->Act();
|
|
BrakeRes->Act();
|
|
CntrlRes->Act();
|
|
ImplsRes->Act();
|
|
return dv - dV1;
|
|
}
|
|
|
|
// the cylinders filled from the auxiliary reservoir or let out to the pressure of the impulse chamber IMP, by the load
|
|
// and the rapid setting, at least the local brake's and the anti-slip brake's; returns that pressure
|
|
double TKE::CylinderFlowKE(double IMP, double const BCP, double const BVP, double const Vel, double const dt)
|
|
{
|
|
double dv;
|
|
double temp;
|
|
// rapid
|
|
auto const &frictionmaterial{*FM};
|
|
if (auto const &frictionmaterialtype{typeid(frictionmaterial)}; !(frictionmaterialtype == typeid(TDisk1) || frictionmaterialtype == typeid(TDisk2))) // jesli zeliwo to schodz
|
|
RapidStatus = (BrakeDelayFlag & bdelay_R) == bdelay_R && (RV < 0 || (Vel > RV && RapidStatus) || Vel > RV + 20);
|
|
else // jesli tarczowki, to zostan
|
|
RapidStatus = (BrakeDelayFlag & bdelay_R) == bdelay_R;
|
|
|
|
// temp:=1.9-0.9*int(RapidStatus);
|
|
|
|
if (RM * RM > 0.001) // jesli jest rapid
|
|
if (RM > 0) // jesli dodatni (naddatek);
|
|
temp = 1 - RM * int(RapidStatus);
|
|
else
|
|
temp = 1 - RM * (1 - int(RapidStatus));
|
|
else
|
|
temp = 1;
|
|
temp = temp / LoadC;
|
|
// luzowanie CH
|
|
// temp:=std::max(BCP,LBP);
|
|
IMP = std::max(IMP / temp, std::max(LBP, ASBP * int((BrakeStatus & b_asb) == b_asb)));
|
|
if (ASBP < 0.1 && (BrakeStatus & b_asb) == b_asb)
|
|
IMP = 0;
|
|
// luzowanie CH
|
|
if (BCP > IMP + 0.005 || std::max(ImplsRes->P(), 8 * LBP) < 0.25)
|
|
dv = PFVd(BCP, 0, 0.05, IMP) * dt;
|
|
else
|
|
dv = 0;
|
|
BrakeCyl->Flow(-dv);
|
|
if (BCP < IMP - 0.005 && std::max(ImplsRes->P(), 8 * LBP) > 0.3)
|
|
dv = PFVa(BVP, BCP, 0.05, IMP) * dt;
|
|
else
|
|
dv = 0;
|
|
BrakeRes->Flow(-dv);
|
|
BrakeCyl->Flow(+dv);
|
|
return IMP;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Initialises the KE distributor: pre-charges valve / brake / control /
|
|
/// impulse reservoirs (ZS = 5 l, KI = 1 l), clears BrakeStatus and computes
|
|
/// BVM (= MaxBP / (HPP-LPP)).
|
|
/// </summary>
|
|
/// <param name="PP">Brake pipe pressure [bar].</param>
|
|
/// <param name="HPP">High (control) pressure [bar].</param>
|
|
/// <param name="LPP">Low pressure threshold [bar].</param>
|
|
/// <param name="BP">Initial cylinder pressure [bar].</param>
|
|
/// <param name="BDF">Initial brake delay flag.</param>
|
|
void TKE::Init(double const PP, double const HPP, double const LPP, double const BP, int const BDF)
|
|
{
|
|
TBrake::Init(PP, HPP, LPP, BP, BDF);
|
|
ValveRes->CreatePress(PP);
|
|
BrakeCyl->CreatePress(BP);
|
|
BrakeRes->CreatePress(PP);
|
|
|
|
CntrlRes->CreateCap(5);
|
|
CntrlRes->CreatePress(HPP);
|
|
|
|
ImplsRes->CreateCap(1);
|
|
ImplsRes->CreatePress(BP);
|
|
|
|
BrakeStatus = b_off;
|
|
|
|
BVM = 1.0 / (HPP - LPP) * MaxBP;
|
|
|
|
BrakeDelayFlag = BDF;
|
|
}
|
|
|
|
/// <summary>Returns the control reservoir (ZS) pressure.</summary>
|
|
double TKE::GetCRP()
|
|
{
|
|
return CntrlRes->P();
|
|
}
|
|
|
|
/// <summary>
|
|
/// High-pressure replenishment for KE: pulls air into the auxiliary
|
|
/// reservoir from the main reservoir whenever the source is higher.
|
|
/// </summary>
|
|
/// <param name="HP">High-pressure source [bar].</param>
|
|
/// <param name="dt">Time step [s].</param>
|
|
/// <returns>Inflow into BrakeRes (negative on intake).</returns>
|
|
double TKE::GetHPFlow(double const HP, double const dt)
|
|
{
|
|
double dv;
|
|
|
|
dv = PF(HP, BrakeRes->P(), 0.01) * dt;
|
|
dv = std::min(0., dv);
|
|
BrakeRes->Flow(-dv);
|
|
return dv;
|
|
}
|
|
|
|
/// <summary>Recomputes the load-weighing coefficient LoadC for the current mass.</summary>
|
|
/// <param name="mass">Current vehicle mass.</param>
|
|
void TKE::PLC(double const mass)
|
|
{
|
|
LoadC = 1 + int(mass < LoadM) * ((TareBP + (MaxBP - TareBP) * (mass - TareM) / (LoadM - TareM)) / MaxBP - 1);
|
|
}
|
|
|
|
/// <summary>Stores the load-weighing parameters.</summary>
|
|
/// <param name="TM">Tare (empty) mass.</param>
|
|
/// <param name="LM">Loaded mass.</param>
|
|
/// <param name="TBP">Tare-mass cylinder pressure.</param>
|
|
void TKE::SetLP(double const TM, double const LM, double const TBP)
|
|
{
|
|
TareM = TM;
|
|
LoadM = LM;
|
|
TareBP = TBP;
|
|
}
|
|
|
|
/// <summary>Sets the rapid-step ratio. RM = 1 - RMR.</summary>
|
|
/// <param name="RMR">Reduction ratio.</param>
|
|
void TKE::SetRM(double const RMR)
|
|
{
|
|
RM = 1.0 - RMR;
|
|
}
|
|
|
|
/// <summary>Sets the auxiliary (local) brake target pressure.</summary>
|
|
/// <param name="P">Auxiliary brake pressure [bar].</param>
|
|
void TKE::SetLBP(double const P)
|
|
{
|
|
LBP = P;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Vents valve, brake, control, impulse and secondary auxiliary reservoirs
|
|
/// to zero pressure (used on vehicle reset / decoupling).
|
|
/// </summary>
|
|
void TKE::ForceEmptiness()
|
|
{
|
|
|
|
ValveRes->CreatePress(0);
|
|
BrakeRes->CreatePress(0);
|
|
CntrlRes->CreatePress(0);
|
|
ImplsRes->CreatePress(0);
|
|
Brak2Res->CreatePress(0);
|
|
|
|
ValveRes->Act();
|
|
BrakeRes->Act();
|
|
CntrlRes->Act();
|
|
ImplsRes->Act();
|
|
Brak2Res->Act();
|
|
}
|
|
|
|
//---KRANY---
|
|
|
|
/// <summary>Default brake-pipe flow — 0. Concrete handles override.</summary>
|
|
double TDriverHandle::GetPF(double const i_bcp, double PP, double HP, double dt, double ep)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
/// <summary>Default initialisation — disables the time / EP-time chambers.</summary>
|
|
/// <param name="Press">Initial pressure (unused in the base implementation).</param>
|
|
void TDriverHandle::Init(double Press)
|
|
{
|
|
Time = false;
|
|
TimeEP = false;
|
|
}
|
|
|
|
/// <summary>Default reductor adjustment — no-op.</summary>
|
|
/// <param name="nAdj">Pressure correction.</param>
|
|
void TDriverHandle::SetReductor(double nAdj) { /* no effect for this device type */ }
|
|
|
|
/// <summary>Default cab-gauge pressure — 0.</summary>
|
|
double TDriverHandle::GetCP()
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
/// <summary>A valve with no pressures of its own.</summary>
|
|
std::vector<double *> TDriverHandle::pressures()
|
|
{
|
|
return {};
|
|
}
|
|
|
|
std::vector<double *> TFV4a::pressures()
|
|
{
|
|
return {&CP, &TP, &RP};
|
|
}
|
|
|
|
std::vector<double *> TFV4aM::pressures()
|
|
{
|
|
return {&CP, &TP, &RP, &XP, &RedAdj};
|
|
}
|
|
|
|
std::vector<double *> TMHZ_EN57::pressures()
|
|
{
|
|
return {&CP, &TP, &RP, &RedAdj, &UnbrakeOverPressure};
|
|
}
|
|
|
|
std::vector<double *> TMHZ_K5P::pressures()
|
|
{
|
|
return {&CP, &TP, &RedAdj, &UnbrakeOverPressure};
|
|
}
|
|
|
|
std::vector<double *> TMHZ_6P::pressures()
|
|
{
|
|
return {&CP, &TP, &RedAdj, &UnbrakeOverPressure};
|
|
}
|
|
|
|
std::vector<double *> TM394::pressures()
|
|
{
|
|
return {&CP, &RedAdj};
|
|
}
|
|
|
|
std::vector<double *> TH14K1::pressures()
|
|
{
|
|
return {&CP, &RedAdj};
|
|
}
|
|
|
|
std::vector<double *> TSt113::pressures()
|
|
{
|
|
auto list{TH14K1::pressures()}; // the control chamber and the reductor are inherited
|
|
list.emplace_back(&EPS);
|
|
return list;
|
|
}
|
|
|
|
std::vector<double *> Ttest::pressures()
|
|
{
|
|
return {&CP};
|
|
}
|
|
|
|
std::vector<double *> TFD1::pressures()
|
|
{
|
|
return {&BP};
|
|
}
|
|
|
|
std::vector<double *> TH1405::pressures()
|
|
{
|
|
return {&BP};
|
|
}
|
|
|
|
std::vector<double *> TFVel6::pressures()
|
|
{
|
|
return {&CP, &EPS};
|
|
}
|
|
|
|
std::vector<double *> TFVE408::pressures()
|
|
{
|
|
return {&CP, &EPS};
|
|
}
|
|
|
|
/// <summary>Default EP intensity — 0.</summary>
|
|
double TDriverHandle::GetEP()
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
/// <summary>Default regulator pressure — 0.</summary>
|
|
double TDriverHandle::GetRP()
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
/// <summary>Default per-channel sound magnitude — 0.</summary>
|
|
/// <param name="i">Sound channel index.</param>
|
|
double TDriverHandle::GetSound(int i)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
/// <summary>Default position lookup — 0 (i.e. unknown).</summary>
|
|
/// <param name="i">Function code (bh_*).</param>
|
|
double TDriverHandle::GetPos(int i)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
/// <summary>Default EP intensity for a handle position — 0.</summary>
|
|
/// <param name="pos">Handle position.</param>
|
|
double TDriverHandle::GetEP(double pos)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Latches the manual overcharge / assimilation button state.
|
|
/// </summary>
|
|
/// <param name="Active">True while the button is pressed.</param>
|
|
void TDriverHandle::OvrldButton(bool Active)
|
|
{
|
|
ManualOvrldActive = Active;
|
|
}
|
|
|
|
/// <summary>Stores the universal-button flags (combined ub_* values).</summary>
|
|
/// <param name="flag">Universal-button bitfield.</param>
|
|
void TDriverHandle::SetUniversalFlag(int flag)
|
|
{
|
|
UniversalFlag = flag;
|
|
}
|
|
//---FV4a---
|
|
|
|
/// <summary>
|
|
/// Computes brake-pipe flow for the classic FV4a handle. Reads target pipe
|
|
/// pressure and flow speed from the BPT[] table for the current detent,
|
|
/// integrates the control (CP) and reductor (RP) reservoirs, and selects
|
|
/// the main-valve flow path based on the handle position (charge stroke at
|
|
/// -1, running-position bias at 0, full vent at the maximum detent).
|
|
/// </summary>
|
|
/// <param name="i_bcp">Continuous handle position.</param>
|
|
/// <param name="PP">Brake pipe pressure [bar].</param>
|
|
/// <param name="HP">High-pressure source [bar].</param>
|
|
/// <param name="dt">Time step [s].</param>
|
|
/// <param name="ep">EP / equalising input [bar].</param>
|
|
/// <returns>Brake pipe volume change for this step.</returns>
|
|
double TFV4a::GetPF(double i_bcp, double PP, double HP, double dt, double ep)
|
|
{
|
|
static int const LBDelay = 100;
|
|
|
|
ep = PP; // SPKS!!
|
|
double LimPP = std::min(BPT[std::lround(i_bcp) + 2][1], HP);
|
|
double ActFlowSpeed = BPT[std::lround(i_bcp) + 2][0];
|
|
|
|
if (i_bcp == i_bcpno)
|
|
LimPP = 2.9;
|
|
|
|
CP = CP + 20 * std::min(std::abs(LimPP - CP), 0.05) * PR(CP, LimPP) * dt / 1;
|
|
RP = RP + 20 * std::min(std::abs(ep - RP), 0.05) * PR(RP, ep) * dt / 2.5;
|
|
|
|
LimPP = CP;
|
|
double dpPipe = std::min(HP, LimPP);
|
|
|
|
double dpMainValve = PF(dpPipe, PP, ActFlowSpeed / LBDelay) * dt;
|
|
if (CP > RP + 0.05)
|
|
dpMainValve = PF(std::min(CP + 0.1, HP), PP, 1.1 * ActFlowSpeed / LBDelay) * dt;
|
|
if (CP < RP - 0.05)
|
|
dpMainValve = PF(CP - 0.1, PP, 1.1 * ActFlowSpeed / LBDelay) * dt;
|
|
|
|
if (lround(i_bcp) == -1)
|
|
{
|
|
CP = CP + 5 * std::min(std::abs(LimPP - CP), 0.2) * PR(CP, LimPP) * dt / 2;
|
|
if (CP < RP + 0.03 && TP < 5)
|
|
TP = TP + dt;
|
|
// if(cp+0.03<5.4)then
|
|
if (RP + 0.03 < 5.4 || CP + 0.03 < 5.4) // fala
|
|
dpMainValve = PF(std::min(HP, 17.1), PP, ActFlowSpeed / LBDelay) * dt;
|
|
// dpMainValve:=20*std::min(abs(ep-7.1),0.05)*PF(HP,pp,ActFlowSpeed/LBDelay)*dt;
|
|
else
|
|
{
|
|
RP = 5.45;
|
|
if (CP < PP - 0.01) //: /34*9
|
|
dpMainValve = PF(dpPipe, PP, ActFlowSpeed / 34 * 9 / LBDelay) * dt;
|
|
else
|
|
dpMainValve = PF(dpPipe, PP, ActFlowSpeed / LBDelay) * dt;
|
|
}
|
|
}
|
|
|
|
if (lround(i_bcp) == 0)
|
|
{
|
|
if (TP > 0.1)
|
|
{
|
|
CP = 5 + (TP - 0.1) * 0.08;
|
|
TP = TP - dt / 12 / 2;
|
|
}
|
|
if (CP > RP + 0.1 && CP <= 5)
|
|
dpMainValve = PF(std::min(CP + 0.25, HP), PP, 2 * ActFlowSpeed / LBDelay) * dt;
|
|
else if (CP > 5)
|
|
dpMainValve = PF(std::min(CP, HP), PP, 2 * ActFlowSpeed / LBDelay) * dt;
|
|
else
|
|
dpMainValve = PF(dpPipe, PP, ActFlowSpeed / LBDelay) * dt;
|
|
}
|
|
|
|
if (lround(i_bcp) == i_bcpno)
|
|
{
|
|
dpMainValve = PF(0, PP, ActFlowSpeed / LBDelay) * dt;
|
|
}
|
|
|
|
return dpMainValve;
|
|
}
|
|
|
|
/// <summary>Initialises CP and RP to the supplied pressure.</summary>
|
|
/// <param name="Press">Initial pressure [bar].</param>
|
|
void TFV4a::Init(double Press)
|
|
{
|
|
CP = Press;
|
|
RP = Press;
|
|
}
|
|
|
|
//---FV4a/M--- nowonapisany kran bez poprawki IC
|
|
|
|
/// <summary>
|
|
/// Computes brake-pipe flow for the FV4a/M handle. Adds a release pressure
|
|
/// wave (XP/Fala) and a time-chamber driven overcharge stroke on top of the
|
|
/// FV4a logic; clamps i_bcp to the supported range, integrates CP/RP/TP/XP
|
|
/// and updates the Sounds[] channels for braking / release / wave / time
|
|
/// outflow / emergency.
|
|
/// </summary>
|
|
/// <param name="i_bcp">Continuous handle position.</param>
|
|
/// <param name="PP">Brake pipe pressure [bar].</param>
|
|
/// <param name="HP">High-pressure source [bar].</param>
|
|
/// <param name="dt">Time step [s].</param>
|
|
/// <param name="ep">EP / equalising input [bar].</param>
|
|
/// <returns>Brake pipe volume change for this step.</returns>
|
|
double TFV4aM::GetPF(double i_bcp, double PP, double HP, double dt, double ep)
|
|
{
|
|
int const LBDelay{100};
|
|
double const xpM{0.3}; // mnoznik membrany komory pod
|
|
|
|
|
|
for (auto &soundvalue : Sounds)
|
|
{
|
|
soundvalue = 0;
|
|
}
|
|
|
|
// na wszelki wypadek, zeby nie wyszlo poza zakres
|
|
i_bcp = std::clamp(i_bcp, -1.999, 5.999);
|
|
|
|
DischargeChambers(dt);
|
|
|
|
double pom;
|
|
if (EQ(i_bcp, -1.0))
|
|
{
|
|
pom = std::min(HP, 5.4 + RedAdj);
|
|
}
|
|
else
|
|
{
|
|
pom = std::min(CP, HP);
|
|
}
|
|
|
|
UpdateWave(pom, dt);
|
|
|
|
double LimPP = std::min(LPP_RP(i_bcp) + TP * 0.08 + RedAdj,
|
|
HP); // pozycja + czasowy lub zasilanie
|
|
|
|
// zbiornik sterujacy
|
|
if (LimPP > CP)
|
|
{
|
|
// podwyzszanie szybkie
|
|
CP += 5.0 * 60.0 * std::min(std::abs(LimPP - CP), 0.05) * PR(CP, LimPP) * dt;
|
|
}
|
|
else
|
|
{
|
|
CP += 13 * std::min(std::abs(LimPP - CP), 0.05) * PR(CP, LimPP) * dt;
|
|
}
|
|
|
|
LimPP = pom; // cp
|
|
double const dpPipe = std::min(HP, LimPP + XP * xpM);
|
|
|
|
double const ActFlowSpeed = BPT[std::lround(i_bcp) + 2][0];
|
|
|
|
double dpMainValve = dpPipe > PP ? -PFVa(HP, PP, ActFlowSpeed / LBDelay, dpPipe, 0.4) : PFVd(PP, 0, ActFlowSpeed / LBDelay, dpPipe, 0.4);
|
|
|
|
if (EQ(i_bcp, -1))
|
|
{
|
|
|
|
if (TP < 5)
|
|
{
|
|
TP += dt;
|
|
}
|
|
if (TP < 1)
|
|
{
|
|
TP -= 0.5 * dt;
|
|
}
|
|
}
|
|
|
|
if (EQ(i_bcp, 0) && TP > 2)
|
|
{
|
|
dpMainValve *= 1.5;
|
|
}
|
|
|
|
ep = dpPipe;
|
|
UpdateReductor(i_bcp, ep, dt);
|
|
|
|
if (EQ(i_bcp, i_bcpno) || EQ(i_bcp, -2))
|
|
{
|
|
|
|
auto const DP{PF(0.0, PP, ActFlowSpeed / LBDelay)};
|
|
dpMainValve = DP;
|
|
Sounds[s_fv4a_e] = DP;
|
|
Sounds[s_fv4a_u] = 0.0;
|
|
Sounds[s_fv4a_b] = 0.0;
|
|
Sounds[s_fv4a_x] = 0.0;
|
|
}
|
|
else
|
|
{
|
|
|
|
if (dpMainValve > 0.0)
|
|
{
|
|
Sounds[s_fv4a_b] = dpMainValve;
|
|
}
|
|
else
|
|
{
|
|
Sounds[s_fv4a_u] = -dpMainValve;
|
|
}
|
|
}
|
|
|
|
return dpMainValve * dt;
|
|
}
|
|
|
|
// the time reservoir and the reductor's air chamber let out, and their sounds
|
|
void TFV4aM::DischargeChambers(double const dt)
|
|
{
|
|
double DP{0.0};
|
|
if (TP > 0.0)
|
|
{
|
|
// jesli czasowy jest niepusty
|
|
DP = 0.045; // 2.5 w 55 sekund (5,35->5,15 w PG)
|
|
TP -= DP * dt;
|
|
Sounds[s_fv4a_t] = DP;
|
|
}
|
|
else
|
|
{
|
|
//.08
|
|
TP = 0.0;
|
|
}
|
|
|
|
if (XP > 0)
|
|
{
|
|
// jesli komora pod niepusta jest niepusty
|
|
DP = 2.5;
|
|
Sounds[s_fv4a_x] = DP * XP;
|
|
XP -= dt * DP * 2.0; // od cisnienia 5 do 0 w 10 sekund ((5-0)*dt/10)
|
|
}
|
|
else
|
|
{
|
|
// jak pusty, to pusty
|
|
XP = 0.0;
|
|
}
|
|
}
|
|
|
|
// the release pressure wave: on while the supply is well over the reductor's pressure, its chamber filled meanwhile
|
|
void TFV4aM::UpdateWave(double const pom, double const dt)
|
|
{
|
|
if (pom > RP + 0.25)
|
|
{
|
|
Fala = true;
|
|
}
|
|
if (Fala)
|
|
{
|
|
if (pom > RP + 0.3)
|
|
{
|
|
XP = XP - 20.0 * PR(pom, XP) * dt;
|
|
}
|
|
else
|
|
{
|
|
Fala = false;
|
|
}
|
|
}
|
|
}
|
|
|
|
// the reductor reservoir following the pressure ep the pipe is driven to, slowly, faster at running, and filled from
|
|
// the control reservoir under the lowest pressure of the handle
|
|
void TFV4aM::UpdateReductor(double const i_bcp, double const ep, double const dt)
|
|
{
|
|
if (EQ(i_bcp, 0) || RP > ep)
|
|
{
|
|
// powolne wzrastanie, ale szybsze na jezdzie;
|
|
RP += PF(RP, ep, 0.0007) * dt;
|
|
}
|
|
else
|
|
{
|
|
// powolne wzrastanie i to bardzo
|
|
RP += PF(RP, ep, 0.000093 / 2 * 2) * dt;
|
|
}
|
|
// jednak trzeba wydluzyc, bo obecnie zle dziala
|
|
if (RP < ep && RP < BPT[std::lround(i_bcpno) + 2][1])
|
|
{
|
|
// jesli jestesmy ponizej cisnienia w sterujacym (2.9 bar)
|
|
// przypisz cisnienie w PG - wydluzanie napelniania o czas potrzebny do napelnienia PG
|
|
RP += PF(RP, CP, 0.005) * dt;
|
|
}
|
|
}
|
|
|
|
/// <summary>Initialises CP and RP to the supplied pressure.</summary>
|
|
/// <param name="Press">Initial pressure [bar].</param>
|
|
void TFV4aM::Init(double Press)
|
|
{
|
|
CP = Press;
|
|
RP = Press;
|
|
}
|
|
|
|
/// <summary>Sets the reductor adjustment offset (turning the reductor cap).</summary>
|
|
/// <param name="nAdj">Pressure correction [bar].</param>
|
|
void TFV4aM::SetReductor(double nAdj)
|
|
{
|
|
RedAdj = nAdj;
|
|
}
|
|
|
|
/// <summary>Returns Sounds[i] for valid indices, 0 otherwise.</summary>
|
|
/// <param name="i">Sound channel index (s_fv4a_*).</param>
|
|
double TFV4aM::GetSound(int i)
|
|
{
|
|
if (i > 4)
|
|
return 0;
|
|
else
|
|
return Sounds[i];
|
|
}
|
|
|
|
/// <summary>Returns pos_table[i] (handle position for the requested function code).</summary>
|
|
/// <param name="i">Function code (bh_*).</param>
|
|
double TFV4aM::GetPos(int i)
|
|
{
|
|
return pos_table[i];
|
|
}
|
|
|
|
/// <summary>Returns the time-chamber pressure (TP).</summary>
|
|
double TFV4aM::GetCP()
|
|
{
|
|
return TP;
|
|
}
|
|
|
|
/// <summary>Returns the regulator target — 5 bar nominal plus TP * 0.08 plus RedAdj.</summary>
|
|
double TFV4aM::GetRP()
|
|
{
|
|
return 5.0 + TP * 0.08 + RedAdj;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Returns the target brake-pipe pressure for a continuous handle position
|
|
/// by linearly interpolating column 1 of BPT[] between the two surrounding
|
|
/// detents.
|
|
/// </summary>
|
|
/// <param name="pos">Continuous handle position.</param>
|
|
/// <returns>Interpolated target pressure [bar].</returns>
|
|
double TFV4aM::LPP_RP(double pos) const // cisnienie z zaokraglonej pozycji;
|
|
{
|
|
auto const i_pos = static_cast<int>(2 + std::floor(pos)); // zaokraglone w dol
|
|
|
|
return BPT[i_pos][1] + (BPT[i_pos + 1][1] - BPT[i_pos][1]) * (pos + 2 - i_pos); // interpolacja liniowa
|
|
}
|
|
/// <summary>Returns true if pos is within ±0.5 of i_pos (detent test).</summary>
|
|
/// <param name="pos">Continuous handle position.</param>
|
|
/// <param name="i_pos">Detent centre.</param>
|
|
bool TFV4aM::EQ(double pos, double i_pos) const
|
|
{
|
|
return pos <= i_pos + 0.5 && pos > i_pos - 0.5;
|
|
}
|
|
|
|
//---MHZ_EN57--- manipulator hamulca zespolonego do EN57
|
|
|
|
/// <summary>
|
|
/// Computes brake-pipe flow for the MHZ_EN57 combined handle. Drives CP/TP
|
|
/// based on the position via <see cref="LPP_RP"/>, supports auto/manual
|
|
/// overcharge (Auto/ManualOvrld and ub_HighPressure / ub_Overload buttons),
|
|
/// emits emergency-vent flow at the extreme detents, and exposes EP intensity
|
|
/// via the position-encoded RP value.
|
|
/// </summary>
|
|
/// <param name="i_bcp">Continuous handle position.</param>
|
|
/// <param name="PP">Brake pipe pressure [bar].</param>
|
|
/// <param name="HP">High-pressure source [bar].</param>
|
|
/// <param name="dt">Time step [s].</param>
|
|
/// <param name="ep">EP / equalising input [bar].</param>
|
|
/// <returns>Brake pipe volume change for this step.</returns>
|
|
double TMHZ_EN57::GetPF(double i_bcp, double PP, double HP, double dt, double ep)
|
|
{
|
|
static int const LBDelay = 100;
|
|
|
|
double LimPP;
|
|
double dpPipe;
|
|
double dpMainValve;
|
|
double ActFlowSpeed;
|
|
double pom;
|
|
|
|
for (auto &soundvalue : Sounds)
|
|
{
|
|
soundvalue = 0;
|
|
}
|
|
|
|
|
|
i_bcp = std::clamp(i_bcp, -0.999, 9.999); // na wszelki wypadek, zeby nie wyszlo poza zakres
|
|
|
|
DischargeTimedReservoir(i_bcp, dt);
|
|
|
|
LimPP = std::min(LPP_RP(i_bcp) + TP * 0.08 + RedAdj, HP); // pozycja + czasowy lub zasilanie
|
|
ActFlowSpeed = 4;
|
|
|
|
pom = SupplyPressure(i_bcp, HP);
|
|
|
|
if (LimPP > CP) // podwyzszanie szybkie
|
|
CP = CP + 60 * std::min(abs(LimPP - CP), 0.05) * PR(CP, LimPP) * dt; // zbiornik sterujacy;
|
|
else
|
|
CP = CP + 13 * std::min(abs(LimPP - CP), 0.05) * PR(CP, LimPP) * dt; // zbiornik sterujacy
|
|
|
|
LimPP = pom; // cp
|
|
// if (EQ(i_bcp, -1))
|
|
// dpPipe = HP;
|
|
// else
|
|
dpPipe = std::min(HP, LimPP);
|
|
|
|
if (dpPipe > PP)
|
|
dpMainValve = -PFVa(HP, PP, ActFlowSpeed / LBDelay, dpPipe, 0.4);
|
|
else
|
|
dpMainValve = PFVd(PP, 0, ActFlowSpeed / LBDelay, dpPipe, 0.4);
|
|
|
|
if ((EQ(i_bcp, -1) && AutoOvrld) || (i_bcp < 0.5 && UniversalFlag & TUniversalBrake::ub_Overload))
|
|
{
|
|
ChargeTimedReservoir(dt);
|
|
}
|
|
|
|
if (EQ(i_bcp, 10) || EQ(i_bcp, -2))
|
|
{
|
|
auto const DP{PF(0, PP, 2 * ActFlowSpeed / LBDelay)};
|
|
dpMainValve = DP;
|
|
Sounds[s_fv4a_e] = DP;
|
|
Sounds[s_fv4a_u] = 0;
|
|
Sounds[s_fv4a_b] = 0;
|
|
Sounds[s_fv4a_x] = 0;
|
|
}
|
|
else
|
|
{
|
|
if (dpMainValve > 0)
|
|
Sounds[s_fv4a_b] = dpMainValve;
|
|
else
|
|
Sounds[s_fv4a_u] = -dpMainValve;
|
|
}
|
|
|
|
if (i_bcp < 1.5)
|
|
RP = std::max(0., 0.125 * i_bcp);
|
|
else
|
|
RP = std::min(1., 0.125 * i_bcp - 0.125);
|
|
|
|
return dpMainValve * dt;
|
|
}
|
|
|
|
// the time reservoir let out of the overload, at the running position, while the control reservoir is charged
|
|
void TMHZ_EN57::DischargeTimedReservoir(double const i_bcp, double const dt)
|
|
{
|
|
if (TP > 0 && CP > 4.9)
|
|
{
|
|
auto const DP{OverloadPressureDecrease};
|
|
if (EQ(i_bcp, 0))
|
|
TP = TP - DP * dt;
|
|
Sounds[s_fv4a_t] = DP;
|
|
}
|
|
else
|
|
{
|
|
TP = 0;
|
|
}
|
|
}
|
|
|
|
// the time reservoir charged by the overload, up to its highest pressure
|
|
void TMHZ_EN57::ChargeTimedReservoir(double const dt)
|
|
{
|
|
if (TP < 5)
|
|
TP = TP + dt; // 5/10
|
|
if (TP < OverloadMaxPressure)
|
|
TP = TP - 0.5 * dt; // 5/10
|
|
}
|
|
|
|
// the pressure the handle feeds the pipe from: the supply's over the running pressure at the filling stroke, where the
|
|
// handle has the overpressure (with its button pressed, for a button worked one), the control reservoir's otherwise
|
|
double TMHZ_EN57::SupplyPressure(double const i_bcp, double const HP)
|
|
{
|
|
double uop = UnbrakeOverPressure; // unbrake over pressure in actual state
|
|
ManualOvrldActive = UniversalFlag & TUniversalBrake::ub_HighPressure; // button is pressed
|
|
if (ManualOvrld && !ManualOvrldActive) // no overpressure for not pressed button if it does not exists
|
|
uop = 0;
|
|
|
|
if (EQ(i_bcp, -1) && uop > 0)
|
|
return std::min(HP, 5.4 + RedAdj + uop);
|
|
return std::min(CP, HP);
|
|
}
|
|
|
|
/// <summary>Initialises CP to the supplied pressure.</summary>
|
|
/// <param name="Press">Initial pressure [bar].</param>
|
|
void TMHZ_EN57::Init(double Press)
|
|
{
|
|
CP = Press;
|
|
}
|
|
|
|
/// <summary>Sets the reductor adjustment offset.</summary>
|
|
/// <param name="nAdj">Pressure correction [bar].</param>
|
|
void TMHZ_EN57::SetReductor(double nAdj)
|
|
{
|
|
RedAdj = nAdj;
|
|
}
|
|
|
|
/// <summary>Returns Sounds[i] for valid indices, 0 otherwise.</summary>
|
|
/// <param name="i">Sound channel index.</param>
|
|
double TMHZ_EN57::GetSound(int i)
|
|
{
|
|
if (i > 4)
|
|
return 0;
|
|
else
|
|
return Sounds[i];
|
|
}
|
|
|
|
/// <summary>Returns pos_table[i].</summary>
|
|
/// <param name="i">Function code (bh_*).</param>
|
|
double TMHZ_EN57::GetPos(int i)
|
|
{
|
|
return pos_table[i];
|
|
}
|
|
|
|
/// <summary>Returns RP — the regulator-target value computed during the last GetPF call.</summary>
|
|
double TMHZ_EN57::GetCP()
|
|
{
|
|
return RP;
|
|
}
|
|
|
|
/// <summary>Returns the regulator target (5 + RedAdj).</summary>
|
|
double TMHZ_EN57::GetRP()
|
|
{
|
|
return 5.0 + RedAdj;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Returns the EP brake intensity for a given handle position
|
|
/// (linear ramp 0..1 between positions 0 and 8, zero above 9.5).
|
|
/// </summary>
|
|
/// <param name="pos">Handle position.</param>
|
|
double TMHZ_EN57::GetEP(double pos)
|
|
{
|
|
if (pos < 9.5)
|
|
return std::clamp(0.125 * pos, 0., 1.);
|
|
else
|
|
return 0;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Returns the target brake-pipe pressure for a given handle position
|
|
/// (5 bar at running, gentle pressure reduction past position 0.5, steeper
|
|
/// reduction past position 8.5 toward emergency).
|
|
/// </summary>
|
|
/// <param name="pos">Continuous handle position.</param>
|
|
/// <returns>Target brake-pipe pressure [bar].</returns>
|
|
double TMHZ_EN57::LPP_RP(double pos) const // cisnienie z zaokraglonej pozycji;
|
|
{
|
|
if (pos > 8.5)
|
|
return 5.0 - 0.15 * pos - 0.35;
|
|
else if (pos > 0.5)
|
|
return 5.0 - 0.15 * pos - 0.1;
|
|
else
|
|
return 5.0;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Configures handle parameters: auto / manual overcharge support, the
|
|
/// unbrake over-pressure value (also enables the wave latch), the maximum
|
|
/// overcharge pressure and the overcharge decay rate.
|
|
/// </summary>
|
|
/// <param name="AO">Auto-overcharge enabled.</param>
|
|
/// <param name="MO">Manual-overcharge enabled.</param>
|
|
/// <param name="OverP">Unbrake over-pressure [bar].</param>
|
|
/// <param name="OMP">Overload (assimilation) max pressure.</param>
|
|
/// <param name="OPD">Overload pressure decay rate.</param>
|
|
void TMHZ_EN57::SetParams(bool AO, bool MO, double OverP, double, double OMP, double OPD)
|
|
{
|
|
AutoOvrld = AO;
|
|
ManualOvrld = MO;
|
|
UnbrakeOverPressure = std::max(0.0, OverP);
|
|
Fala = OverP > 0.01;
|
|
OverloadMaxPressure = OMP;
|
|
OverloadPressureDecrease = OPD;
|
|
}
|
|
|
|
/// <summary>Returns true if pos is within ±0.5 of i_pos (detent test).</summary>
|
|
bool TMHZ_EN57::EQ(double pos, double i_pos) const
|
|
{
|
|
return pos <= i_pos + 0.5 && pos > i_pos - 0.5;
|
|
}
|
|
|
|
//---MHZ_K5P--- manipulator hamulca zespolonego Knorr 5-ciopozycyjny
|
|
|
|
/// <summary>
|
|
/// Computes brake-pipe flow for the Knorr 5-position MHZ_K5P handle
|
|
/// (release / cut-off / brake / emergency layout). Handles auto / manual
|
|
/// overcharge, the optional release wave (Fala) with FillingStrokeFactor,
|
|
/// and the emergency vent at position 3.
|
|
/// </summary>
|
|
/// <param name="i_bcp">Continuous handle position.</param>
|
|
/// <param name="PP">Brake pipe pressure [bar].</param>
|
|
/// <param name="HP">High-pressure source [bar].</param>
|
|
/// <param name="dt">Time step [s].</param>
|
|
/// <param name="ep">EP / equalising input [bar].</param>
|
|
/// <returns>Brake pipe volume change for this step.</returns>
|
|
double TMHZ_K5P::GetPF(double i_bcp, double PP, double HP, double dt, double ep)
|
|
{
|
|
static int const LBDelay = 100;
|
|
|
|
double LimCP;
|
|
double dpPipe;
|
|
double dpMainValve;
|
|
double ActFlowSpeed;
|
|
double DP;
|
|
|
|
for (auto &soundvalue : Sounds)
|
|
{
|
|
soundvalue = 0;
|
|
}
|
|
|
|
|
|
i_bcp = std::clamp(i_bcp, -0.999, 2.999); // na wszelki wypadek, zeby nie wyszlo poza zakres
|
|
|
|
if (TP > 0 && CP > 4.9)
|
|
{
|
|
DP = OverloadPressureDecrease;
|
|
TP = TP - DP * dt;
|
|
Sounds[s_fv4a_t] = DP;
|
|
}
|
|
else
|
|
{
|
|
// TP = 0; //tu nie powinno być nic, ciśnienie zostaje jak było
|
|
}
|
|
|
|
if (EQ(i_bcp, 1)) // odcięcie - nie rób nic
|
|
LimCP = CP;
|
|
else if (i_bcp > 1) // hamowanie
|
|
LimCP = 3.4;
|
|
else // luzowanie
|
|
LimCP = 5.0;
|
|
LimCP = std::min(LimCP, HP); // pozycja + czasowy lub zasilanie
|
|
ActFlowSpeed = 4;
|
|
|
|
CP = CP + 9 * std::min(abs(LimCP - CP), 0.05) * PR(CP, LimCP) * dt; // zbiornik sterujacy
|
|
|
|
double uop = UnbrakeOverPressure; // unbrake over pressure in actual state
|
|
ManualOvrldActive = UniversalFlag & TUniversalBrake::ub_HighPressure; // button is pressed
|
|
if (ManualOvrld && !ManualOvrldActive) // no overpressure for not pressed button if it does not exists
|
|
uop = 0;
|
|
|
|
dpPipe = std::min(HP, CP + TP + RedAdj);
|
|
|
|
if (EQ(i_bcp, -1))
|
|
{
|
|
if (Fala)
|
|
{
|
|
dpPipe = 5.0 + TP + RedAdj + uop;
|
|
ActFlowSpeed = 12;
|
|
}
|
|
else
|
|
{
|
|
ActFlowSpeed *= FillingStrokeFactor;
|
|
}
|
|
}
|
|
|
|
if (dpPipe > PP)
|
|
dpMainValve = -PFVa(HP, PP, ActFlowSpeed / LBDelay, dpPipe, 0.4);
|
|
else
|
|
dpMainValve = PFVd(PP, 0, ActFlowSpeed / LBDelay, dpPipe, 0.4);
|
|
|
|
if (((EQ(i_bcp, -1) && AutoOvrld) || (i_bcp < 0.5 && UniversalFlag & TUniversalBrake::ub_Overload)) && TP < OverloadMaxPressure)
|
|
{
|
|
TP = TP + 0.03 * dt;
|
|
}
|
|
|
|
if (EQ(i_bcp, 3))
|
|
{
|
|
DP = PF(0, PP, 2 * ActFlowSpeed / LBDelay);
|
|
dpMainValve = DP;
|
|
Sounds[s_fv4a_e] = DP;
|
|
Sounds[s_fv4a_u] = 0;
|
|
Sounds[s_fv4a_b] = 0;
|
|
Sounds[s_fv4a_x] = 0;
|
|
}
|
|
else
|
|
{
|
|
if (dpMainValve > 0)
|
|
Sounds[s_fv4a_b] = dpMainValve;
|
|
else
|
|
Sounds[s_fv4a_u] = -dpMainValve;
|
|
}
|
|
|
|
return dpMainValve * dt;
|
|
}
|
|
|
|
/// <summary>Initialises CP and enables the time / EP-time chambers.</summary>
|
|
/// <param name="Press">Initial pressure [bar].</param>
|
|
void TMHZ_K5P::Init(double Press)
|
|
{
|
|
CP = Press;
|
|
Time = true;
|
|
TimeEP = true;
|
|
}
|
|
|
|
/// <summary>Sets the reductor adjustment offset.</summary>
|
|
/// <param name="nAdj">Pressure correction [bar].</param>
|
|
void TMHZ_K5P::SetReductor(double nAdj)
|
|
{
|
|
RedAdj = nAdj;
|
|
}
|
|
|
|
/// <summary>Returns Sounds[i] for valid indices, 0 otherwise.</summary>
|
|
/// <param name="i">Sound channel index.</param>
|
|
double TMHZ_K5P::GetSound(int i)
|
|
{
|
|
if (i > 4)
|
|
return 0;
|
|
else
|
|
return Sounds[i];
|
|
}
|
|
|
|
/// <summary>Returns pos_table[i].</summary>
|
|
/// <param name="i">Function code (bh_*).</param>
|
|
double TMHZ_K5P::GetPos(int i)
|
|
{
|
|
return pos_table[i];
|
|
}
|
|
|
|
/// <summary>Returns CP.</summary>
|
|
double TMHZ_K5P::GetCP()
|
|
{
|
|
return CP;
|
|
}
|
|
|
|
/// <summary>Returns the regulator target (5 + TP + RedAdj).</summary>
|
|
double TMHZ_K5P::GetRP()
|
|
{
|
|
return 5.0 + TP + RedAdj;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Configures handle parameters: auto/manual overcharge, unbrake over-pressure
|
|
/// (also drives the Fala latch), filling-stroke factor (FSF + 1) and the
|
|
/// overcharge max pressure / decay rate.
|
|
/// </summary>
|
|
/// <param name="AO">Auto-overcharge enabled.</param>
|
|
/// <param name="MO">Manual-overcharge enabled.</param>
|
|
/// <param name="OverP">Unbrake over-pressure [bar].</param>
|
|
/// <param name="FSF">Filling-stroke factor offset (FillingStrokeFactor = 1 + FSF).</param>
|
|
/// <param name="OMP">Overload max pressure.</param>
|
|
/// <param name="OPD">Overload pressure decay rate.</param>
|
|
void TMHZ_K5P::SetParams(bool AO, bool MO, double OverP, double FSF, double OMP, double OPD)
|
|
{
|
|
AutoOvrld = AO;
|
|
ManualOvrld = MO;
|
|
UnbrakeOverPressure = std::max(0.0, OverP);
|
|
Fala = OverP > 0.01;
|
|
OverloadMaxPressure = OMP;
|
|
OverloadPressureDecrease = OPD;
|
|
FillingStrokeFactor = 1 + FSF;
|
|
}
|
|
|
|
/// <summary>Returns true if pos is within ±0.5 of i_pos (detent test).</summary>
|
|
bool TMHZ_K5P::EQ(double pos, double i_pos) const
|
|
{
|
|
return pos <= i_pos + 0.5 && pos > i_pos - 0.5;
|
|
}
|
|
|
|
//---MHZ_6P--- manipulator hamulca zespolonego 6-ciopozycyjny
|
|
|
|
/// <summary>
|
|
/// Computes brake-pipe flow for the 6-position MHZ_6P handle. Variant of K5P
|
|
/// with one additional detent — detent 4 triggers the emergency vent, detent 2
|
|
/// is the cut-off (lap), positions > 2.5 brake, positions < 2 release.
|
|
/// </summary>
|
|
/// <param name="i_bcp">Continuous handle position.</param>
|
|
/// <param name="PP">Brake pipe pressure [bar].</param>
|
|
/// <param name="HP">High-pressure source [bar].</param>
|
|
/// <param name="dt">Time step [s].</param>
|
|
/// <param name="ep">EP / equalising input [bar].</param>
|
|
/// <returns>Brake pipe volume change for this step.</returns>
|
|
double TMHZ_6P::GetPF(double i_bcp, double PP, double HP, double dt, double ep)
|
|
{
|
|
static int const LBDelay = 100;
|
|
|
|
double LimCP;
|
|
double dpPipe;
|
|
double dpMainValve;
|
|
double ActFlowSpeed;
|
|
double DP;
|
|
|
|
for (auto &soundvalue : Sounds)
|
|
{
|
|
soundvalue = 0;
|
|
}
|
|
|
|
|
|
i_bcp = std::clamp(i_bcp, -0.999, 3.999); // na wszelki wypadek, zeby nie wyszlo poza zakres
|
|
|
|
if (TP > 0 && CP > 4.9)
|
|
{
|
|
DP = OverloadPressureDecrease;
|
|
TP = TP - DP * dt;
|
|
Sounds[s_fv4a_t] = DP;
|
|
}
|
|
else
|
|
{
|
|
// TP = 0; //tu nie powinno być nic, ciśnienie zostaje jak było
|
|
}
|
|
|
|
if (EQ(i_bcp, 2)) // odcięcie - nie rób nic
|
|
LimCP = CP;
|
|
else if (i_bcp > 2.5) // hamowanie
|
|
LimCP = 3.4;
|
|
else // luzowanie
|
|
LimCP = 5.0;
|
|
LimCP = std::min(LimCP, HP); // pozycja + czasowy lub zasilanie
|
|
ActFlowSpeed = 4;
|
|
|
|
CP = CP + 9 * std::min(abs(LimCP - CP), 0.05) * PR(CP, LimCP) * dt; // zbiornik sterujacy
|
|
|
|
dpPipe = std::min(HP, CP + TP + RedAdj);
|
|
|
|
double uop = UnbrakeOverPressure; // unbrake over pressure in actual state
|
|
ManualOvrldActive = UniversalFlag & TUniversalBrake::ub_HighPressure; // button is pressed
|
|
if (ManualOvrld && !ManualOvrldActive) // no overpressure for not pressed button if it does not exists
|
|
uop = 0;
|
|
|
|
if (EQ(i_bcp, -1))
|
|
{
|
|
if (Fala)
|
|
{
|
|
dpPipe = 5.0 + TP + RedAdj + uop;
|
|
ActFlowSpeed = 12;
|
|
}
|
|
else
|
|
{
|
|
ActFlowSpeed *= FillingStrokeFactor;
|
|
}
|
|
}
|
|
|
|
if (dpPipe > PP)
|
|
dpMainValve = -PFVa(HP, PP, ActFlowSpeed / LBDelay, dpPipe, 0.4);
|
|
else
|
|
dpMainValve = PFVd(PP, 0, ActFlowSpeed / LBDelay, dpPipe, 0.4);
|
|
|
|
if (((EQ(i_bcp, -1) && AutoOvrld) || (i_bcp < 0.5 && UniversalFlag & TUniversalBrake::ub_Overload)) && TP < OverloadMaxPressure)
|
|
{
|
|
TP = TP + 0.03 * dt;
|
|
}
|
|
|
|
if (EQ(i_bcp, 4))
|
|
{
|
|
DP = PF(0, PP, 2 * ActFlowSpeed / LBDelay);
|
|
dpMainValve = DP;
|
|
Sounds[s_fv4a_e] = DP;
|
|
Sounds[s_fv4a_u] = 0;
|
|
Sounds[s_fv4a_b] = 0;
|
|
Sounds[s_fv4a_x] = 0;
|
|
}
|
|
else
|
|
{
|
|
if (dpMainValve > 0)
|
|
Sounds[s_fv4a_b] = dpMainValve;
|
|
else
|
|
Sounds[s_fv4a_u] = -dpMainValve;
|
|
}
|
|
|
|
return dpMainValve * dt;
|
|
}
|
|
|
|
/// <summary>Initialises CP and enables the time / EP-time chambers.</summary>
|
|
/// <param name="Press">Initial pressure [bar].</param>
|
|
void TMHZ_6P::Init(double Press)
|
|
{
|
|
CP = Press;
|
|
Time = true;
|
|
TimeEP = true;
|
|
}
|
|
|
|
/// <summary>Sets the reductor adjustment offset.</summary>
|
|
/// <param name="nAdj">Pressure correction [bar].</param>
|
|
void TMHZ_6P::SetReductor(double nAdj)
|
|
{
|
|
RedAdj = nAdj;
|
|
}
|
|
|
|
/// <summary>Returns Sounds[i] for valid indices, 0 otherwise.</summary>
|
|
/// <param name="i">Sound channel index.</param>
|
|
double TMHZ_6P::GetSound(int i)
|
|
{
|
|
if (i > 4)
|
|
return 0;
|
|
else
|
|
return Sounds[i];
|
|
}
|
|
|
|
/// <summary>Returns pos_table[i].</summary>
|
|
/// <param name="i">Function code (bh_*).</param>
|
|
double TMHZ_6P::GetPos(int i)
|
|
{
|
|
return pos_table[i];
|
|
}
|
|
|
|
/// <summary>Returns CP.</summary>
|
|
double TMHZ_6P::GetCP()
|
|
{
|
|
return CP;
|
|
}
|
|
|
|
/// <summary>Returns the regulator target (5 + TP + RedAdj).</summary>
|
|
double TMHZ_6P::GetRP()
|
|
{
|
|
return 5.0 + TP + RedAdj;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Configures handle parameters: auto/manual overcharge, unbrake over-pressure
|
|
/// (also drives the Fala latch), filling-stroke factor (FSF + 1) and the
|
|
/// overcharge max pressure / decay rate.
|
|
/// </summary>
|
|
/// <param name="AO">Auto-overcharge enabled.</param>
|
|
/// <param name="MO">Manual-overcharge enabled.</param>
|
|
/// <param name="OverP">Unbrake over-pressure [bar].</param>
|
|
/// <param name="FSF">Filling-stroke factor offset.</param>
|
|
/// <param name="OMP">Overload max pressure.</param>
|
|
/// <param name="OPD">Overload pressure decay rate.</param>
|
|
void TMHZ_6P::SetParams(bool AO, bool MO, double OverP, double FSF, double OMP, double OPD)
|
|
{
|
|
AutoOvrld = AO;
|
|
ManualOvrld = MO;
|
|
UnbrakeOverPressure = std::max(0.0, OverP);
|
|
Fala = OverP > 0.01;
|
|
OverloadMaxPressure = OMP;
|
|
OverloadPressureDecrease = OPD;
|
|
FillingStrokeFactor = 1 + FSF;
|
|
}
|
|
|
|
/// <summary>Returns true if pos is within ±0.5 of i_pos (detent test).</summary>
|
|
bool TMHZ_6P::EQ(double pos, double i_pos) const
|
|
{
|
|
return pos <= i_pos + 0.5 && pos > i_pos - 0.5;
|
|
}
|
|
|
|
//---M394--- Matrosow
|
|
|
|
/// <summary>
|
|
/// Computes brake-pipe flow for the Matrosow 394 handle. Reads target pipe
|
|
/// pressure and flow speed from BPT_394[] for the current detent (with
|
|
/// special handling at the running and emergency positions) and integrates
|
|
/// the control reservoir CP at a position-dependent rate.
|
|
/// </summary>
|
|
/// <param name="i_bcp">Continuous handle position.</param>
|
|
/// <param name="PP">Brake pipe pressure [bar].</param>
|
|
/// <param name="HP">High-pressure source [bar].</param>
|
|
/// <param name="dt">Time step [s].</param>
|
|
/// <param name="ep">EP / equalising input [bar].</param>
|
|
/// <returns>Brake pipe volume change for this step.</returns>
|
|
double TM394::GetPF(double i_bcp, double PP, double HP, double dt, double ep)
|
|
{
|
|
static int const LBDelay = 65;
|
|
|
|
double LimPP;
|
|
double dpPipe;
|
|
double dpMainValve;
|
|
double ActFlowSpeed;
|
|
int BCP;
|
|
|
|
BCP = static_cast<int>(lround(i_bcp));
|
|
if (BCP < -1)
|
|
BCP = 1;
|
|
|
|
LimPP = std::min(BPT_394[BCP + 1][1], HP);
|
|
ActFlowSpeed = BPT_394[BCP + 1][0];
|
|
if (BCP == 1 || BCP == i_bcpno)
|
|
LimPP = PP;
|
|
if (BCP == 0)
|
|
LimPP = LimPP + RedAdj;
|
|
if (BCP != 2)
|
|
{
|
|
if (CP < LimPP)
|
|
CP = CP + 4 * std::min(abs(LimPP - CP), 0.05) * PR(CP, LimPP) * dt; // zbiornik sterujacy
|
|
// cp:=cp+6*(2+int(bcp<0))*std::min(abs(Limpp-cp),0.05)*PR(cp,Limpp)*dt //zbiornik
|
|
// sterujacy;
|
|
else if (BCP == 0)
|
|
CP = CP - 0.2 * dt / 100;
|
|
else
|
|
CP = CP + 4 * (1 + int(BCP != 3) + int(BCP > 4)) * std::min(abs(LimPP - CP), 0.05) * PR(CP, LimPP) * dt; // zbiornik sterujacy
|
|
}
|
|
|
|
LimPP = CP;
|
|
dpPipe = std::min(HP, LimPP);
|
|
|
|
// if(dpPipe>pp)then //napelnianie
|
|
// dpMainValve:=PF(dpPipe,pp,ActFlowSpeed/LBDelay)*dt
|
|
// else //spuszczanie
|
|
dpMainValve = PF(dpPipe, PP, ActFlowSpeed / LBDelay) * dt;
|
|
|
|
if (BCP == -1)
|
|
dpMainValve = PF(HP, PP, ActFlowSpeed / LBDelay) * dt;
|
|
|
|
if (BCP == i_bcpno)
|
|
dpMainValve = PF(0, PP, ActFlowSpeed / LBDelay) * dt;
|
|
|
|
return dpMainValve;
|
|
}
|
|
|
|
/// <summary>Initialises CP and enables the time chamber.</summary>
|
|
/// <param name="Press">Initial pressure [bar].</param>
|
|
void TM394::Init(double Press)
|
|
{
|
|
CP = Press;
|
|
Time = true;
|
|
}
|
|
|
|
/// <summary>Sets the reductor adjustment offset.</summary>
|
|
/// <param name="nAdj">Pressure correction [bar].</param>
|
|
void TM394::SetReductor(double nAdj)
|
|
{
|
|
RedAdj = nAdj;
|
|
}
|
|
|
|
/// <summary>Returns CP.</summary>
|
|
double TM394::GetCP()
|
|
{
|
|
return CP;
|
|
}
|
|
|
|
/// <summary>Returns max(5, CP) + RedAdj as the regulator target.</summary>
|
|
double TM394::GetRP()
|
|
{
|
|
return std::max(5.0, CP) + RedAdj;
|
|
}
|
|
|
|
/// <summary>Returns pos_table[i].</summary>
|
|
/// <param name="i">Function code (bh_*).</param>
|
|
double TM394::GetPos(int i)
|
|
{
|
|
return pos_table[i];
|
|
}
|
|
|
|
//---H14K1-- Knorr
|
|
|
|
/// <summary>
|
|
/// Computes brake-pipe flow for the Knorr H14K1 auxiliary handle.
|
|
/// Picks a target pressure level (high/low/lap) from BPT_K[] depending on the
|
|
/// detent, integrates CP toward it and dispatches the resulting flow path
|
|
/// (charge / fill toward nominal / vent toward CP / emergency vent at
|
|
/// the maximum detent).
|
|
/// </summary>
|
|
/// <param name="i_bcp">Continuous handle position.</param>
|
|
/// <param name="PP">Brake pipe pressure [bar].</param>
|
|
/// <param name="HP">High-pressure source [bar].</param>
|
|
/// <param name="dt">Time step [s].</param>
|
|
/// <param name="ep">EP / equalising input [bar].</param>
|
|
/// <returns>Brake pipe volume change for this step.</returns>
|
|
double TH14K1::GetPF(double i_bcp, double PP, double HP, double dt, double ep)
|
|
{
|
|
int const LBDelay = 100; // szybkosc + zasilanie sterujacego
|
|
// static double const BPT_K[/*?*/ /*-1..4*/ (4) - (-1) + 1][2] =
|
|
//{ (10, 0), (4, 1), (0, 1), (4, 0), (4, -1), (15, -1) };
|
|
double const NomPress = 5.0;
|
|
|
|
auto BCP = static_cast<int>(std::lround(i_bcp));
|
|
if (i_bcp < -1)
|
|
{
|
|
BCP = 1;
|
|
}
|
|
|
|
double LimPP = BPT_K[BCP + 1][1];
|
|
if (LimPP < 0.0)
|
|
{
|
|
LimPP = 0.5 * PP;
|
|
}
|
|
else if (LimPP > 0.0)
|
|
{
|
|
LimPP = PP;
|
|
}
|
|
else
|
|
{
|
|
LimPP = CP;
|
|
}
|
|
double ActFlowSpeed = BPT_K[BCP + 1][0];
|
|
|
|
CP = CP + 6 * std::min(std::abs(LimPP - CP), 0.05) * PR(CP, LimPP) * dt; // zbiornik sterujacy
|
|
|
|
double dpMainValve = 0.0;
|
|
|
|
if (BCP == -1)
|
|
dpMainValve = PF(HP, PP, ActFlowSpeed / LBDelay) * dt;
|
|
if (BCP == 0)
|
|
dpMainValve = -PFVa(HP, PP, ActFlowSpeed / LBDelay, NomPress + RedAdj) * dt;
|
|
if (BCP > 1 && PP > CP)
|
|
dpMainValve = PFVd(PP, 0, ActFlowSpeed / LBDelay, CP) * dt;
|
|
if (BCP == i_bcpno)
|
|
dpMainValve = PF(0, PP, ActFlowSpeed / LBDelay) * dt;
|
|
|
|
return dpMainValve;
|
|
}
|
|
|
|
/// <summary>Initialises CP and enables the time / EP-time chambers.</summary>
|
|
/// <param name="Press">Initial pressure [bar].</param>
|
|
void TH14K1::Init(double Press)
|
|
{
|
|
CP = Press;
|
|
Time = true;
|
|
TimeEP = true;
|
|
}
|
|
|
|
/// <summary>Sets the reductor adjustment offset.</summary>
|
|
/// <param name="nAdj">Pressure correction [bar].</param>
|
|
void TH14K1::SetReductor(double nAdj)
|
|
{
|
|
RedAdj = nAdj;
|
|
}
|
|
|
|
/// <summary>Returns CP.</summary>
|
|
double TH14K1::GetCP()
|
|
{
|
|
return CP;
|
|
}
|
|
|
|
/// <summary>Returns the regulator target (5 + RedAdj).</summary>
|
|
double TH14K1::GetRP()
|
|
{
|
|
return 5.0 + RedAdj;
|
|
}
|
|
|
|
/// <summary>Returns pos_table[i].</summary>
|
|
/// <param name="i">Function code (bh_*).</param>
|
|
double TH14K1::GetPos(int i)
|
|
{
|
|
return pos_table[i];
|
|
}
|
|
|
|
//---St113-- Knorr EP
|
|
|
|
/// <summary>
|
|
/// Computes brake-pipe flow for the Knorr St113 EP-equipped handle.
|
|
/// Reuses the H14K1 flow paths (after collapsing position 1 into the cut-off
|
|
/// region) and additionally publishes the EP intensity from BEP_K[].
|
|
/// </summary>
|
|
/// <param name="i_bcp">Continuous handle position.</param>
|
|
/// <param name="PP">Brake pipe pressure [bar].</param>
|
|
/// <param name="HP">High-pressure source [bar].</param>
|
|
/// <param name="dt">Time step [s].</param>
|
|
/// <param name="ep">EP / equalising input [bar].</param>
|
|
/// <returns>Brake pipe volume change for this step.</returns>
|
|
double TSt113::GetPF(double i_bcp, double PP, double HP, double dt, double ep)
|
|
{
|
|
static int const LBDelay = 100; // szybkosc + zasilanie sterujacego
|
|
static double const NomPress = 5.0;
|
|
|
|
double LimPP;
|
|
double dpMainValve;
|
|
double ActFlowSpeed;
|
|
int BCP;
|
|
|
|
CP = PP;
|
|
|
|
BCP = static_cast<int>(lround(i_bcp));
|
|
|
|
EPS = BEP_K[BCP + 1];
|
|
|
|
if (BCP > 0)
|
|
BCP = BCP - 1;
|
|
|
|
if (BCP < -1)
|
|
BCP = 1;
|
|
LimPP = BPT_K[BCP + 1][1];
|
|
if (LimPP < 0)
|
|
LimPP = 0.5 * PP;
|
|
else if (LimPP > 0)
|
|
LimPP = PP;
|
|
else
|
|
LimPP = CP;
|
|
ActFlowSpeed = BPT_K[BCP + 1][0];
|
|
|
|
CP = CP + 6 * std::min(abs(LimPP - CP), 0.05) * PR(CP, LimPP) * dt; // zbiornik sterujacy
|
|
|
|
dpMainValve = 0;
|
|
|
|
if (BCP == -1)
|
|
dpMainValve = PF(HP, PP, ActFlowSpeed / LBDelay) * dt;
|
|
if (BCP == 0)
|
|
dpMainValve = -PFVa(HP, PP, ActFlowSpeed / LBDelay, NomPress + RedAdj) * dt;
|
|
if (BCP > 1 && PP > CP)
|
|
dpMainValve = PFVd(PP, 0, ActFlowSpeed / LBDelay, CP) * dt;
|
|
if (BCP == i_bcpno)
|
|
dpMainValve = PF(0, PP, ActFlowSpeed / LBDelay) * dt;
|
|
|
|
return dpMainValve;
|
|
}
|
|
|
|
/// <summary>Returns CP.</summary>
|
|
double TSt113::GetCP()
|
|
{
|
|
return CP;
|
|
}
|
|
|
|
/// <summary>Returns the regulator target (5 + RedAdj).</summary>
|
|
double TSt113::GetRP()
|
|
{
|
|
return 5.0 + RedAdj;
|
|
}
|
|
|
|
/// <summary>Returns the current EP intensity (read from BEP_K via the last GetPF call).</summary>
|
|
double TSt113::GetEP()
|
|
{
|
|
return EPS;
|
|
}
|
|
|
|
/// <summary>Returns pos_table[i].</summary>
|
|
/// <param name="i">Function code (bh_*).</param>
|
|
double TSt113::GetPos(int i)
|
|
{
|
|
return pos_table[i];
|
|
}
|
|
|
|
/// <summary>Enables the time / EP-time chambers (no pressure init needed).</summary>
|
|
/// <param name="Press">Initial pressure (unused).</param>
|
|
void TSt113::Init(double Press)
|
|
{
|
|
Time = true;
|
|
TimeEP = true;
|
|
}
|
|
|
|
//--- test ---
|
|
|
|
/// <summary>
|
|
/// Computes brake-pipe flow for the test-only handle. Uses BPT[] but
|
|
/// overrides the limit pressure for the highest detent (full vent) and
|
|
/// for position -1 (raises target to 7 bar).
|
|
/// </summary>
|
|
/// <param name="i_bcp">Continuous handle position.</param>
|
|
/// <param name="PP">Brake pipe pressure [bar].</param>
|
|
/// <param name="HP">High-pressure source [bar].</param>
|
|
/// <param name="dt">Time step [s].</param>
|
|
/// <param name="ep">EP / equalising input [bar].</param>
|
|
/// <returns>Brake pipe volume change for this step.</returns>
|
|
double Ttest::GetPF(double i_bcp, double PP, double HP, double dt, double ep)
|
|
{
|
|
static int const LBDelay = 100;
|
|
|
|
double LimPP;
|
|
double dpPipe;
|
|
double dpMainValve;
|
|
double ActFlowSpeed;
|
|
|
|
LimPP = BPT[lround(i_bcp) + 2][1];
|
|
ActFlowSpeed = BPT[lround(i_bcp) + 2][0];
|
|
|
|
if (i_bcp == i_bcpno)
|
|
LimPP = 0.0;
|
|
|
|
if (i_bcp == -1)
|
|
LimPP = 7;
|
|
|
|
CP = CP + 20 * std::min(abs(LimPP - CP), 0.05) * PR(CP, LimPP) * dt / 1;
|
|
|
|
LimPP = CP;
|
|
dpPipe = std::min(HP, LimPP);
|
|
|
|
dpMainValve = PF(dpPipe, PP, ActFlowSpeed / LBDelay) * dt;
|
|
|
|
if (lround(i_bcp) == i_bcpno)
|
|
{
|
|
dpMainValve = PF(0, PP, ActFlowSpeed / LBDelay) * dt;
|
|
}
|
|
|
|
return dpMainValve;
|
|
}
|
|
|
|
/// <summary>Initialises CP to the supplied pressure.</summary>
|
|
/// <param name="Press">Initial pressure [bar].</param>
|
|
void Ttest::Init(double Press)
|
|
{
|
|
CP = Press;
|
|
}
|
|
|
|
//---FD1---
|
|
|
|
/// <summary>
|
|
/// Computes the auxiliary-brake outflow for the FD1 handle: drives the
|
|
/// cylinder pressure BP toward i_bcp * MaxBP at a configurable Speed,
|
|
/// using a soft-clamped PF flow with asymmetric fill/release rates.
|
|
/// </summary>
|
|
/// <param name="i_bcp">Continuous handle position (0..1).</param>
|
|
/// <param name="PP">Brake pipe pressure (unused).</param>
|
|
/// <param name="HP">High-pressure source [bar].</param>
|
|
/// <param name="dt">Time step [s].</param>
|
|
/// <param name="ep">EP / equalising input (unused).</param>
|
|
/// <returns>Negated cylinder pressure delta for this step.</returns>
|
|
double TFD1::GetPF(double i_bcp, double PP, double HP, double dt, double ep)
|
|
{
|
|
double DP;
|
|
double temp;
|
|
|
|
// MaxBP:=4;
|
|
// temp:=std::min(i_bcp*MaxBP,std::min(5.0,HP));
|
|
temp = std::min(i_bcp * MaxBP, HP); // 0011
|
|
DP = 10.0 * std::min(std::abs(temp - BP), 0.1) * PF(temp, BP, 0.0006 * (temp > BP ? 3.0 : 2.0)) * dt * Speed;
|
|
BP = BP - DP;
|
|
return -DP;
|
|
}
|
|
|
|
/// <summary>Initialises MaxBP and the action speed (defaults to 1.0).</summary>
|
|
/// <param name="Press">Maximum cylinder pressure [bar].</param>
|
|
void TFD1::Init(double Press)
|
|
{
|
|
MaxBP = Press;
|
|
Speed = 1.0;
|
|
}
|
|
|
|
/// <summary>Returns the currently commanded cylinder pressure (BP).</summary>
|
|
double TFD1::GetCP()
|
|
{
|
|
return BP;
|
|
}
|
|
|
|
/// <summary>Sets the action speed multiplier (scales the response time).</summary>
|
|
/// <param name="nSpeed">Speed multiplier.</param>
|
|
void TFD1::SetSpeed(double nSpeed)
|
|
{
|
|
Speed = nSpeed;
|
|
}
|
|
|
|
//---KNORR---
|
|
|
|
/// <summary>
|
|
/// Computes the auxiliary-brake outflow for the Knorr H1405 handle.
|
|
/// Above 0.5 the handle drives the cylinder up toward MaxBP (apply); below
|
|
/// it the cylinder is vented toward zero. The orifice area depends linearly
|
|
/// on the deflection from the lap point.
|
|
/// </summary>
|
|
/// <param name="i_bcp">Continuous handle position.</param>
|
|
/// <param name="PP">Brake pipe pressure clamped to MaxBP.</param>
|
|
/// <param name="HP">High-pressure source [bar].</param>
|
|
/// <param name="dt">Time step [s].</param>
|
|
/// <param name="ep">EP / equalising input (unused).</param>
|
|
/// <returns>Negated cylinder pressure delta for this step.</returns>
|
|
double TH1405::GetPF(double i_bcp, double PP, double HP, double dt, double ep)
|
|
{
|
|
double DP;
|
|
double temp;
|
|
double A;
|
|
|
|
PP = std::min(PP, MaxBP);
|
|
if (i_bcp > 0.5)
|
|
{
|
|
temp = std::min(MaxBP, HP);
|
|
A = 2 * (i_bcp - 0.5) * 0.0011;
|
|
BP = std::max(BP, PP);
|
|
}
|
|
else
|
|
{
|
|
temp = 0;
|
|
A = 0.2 * (0.5 - i_bcp) * 0.0033;
|
|
BP = std::min(BP, PP);
|
|
}
|
|
DP = PF(temp, BP, A) * dt;
|
|
BP = BP - DP;
|
|
return -DP;
|
|
}
|
|
|
|
/// <summary>Initialises MaxBP and enables the time chamber.</summary>
|
|
/// <param name="Press">Maximum cylinder pressure [bar].</param>
|
|
void TH1405::Init(double Press)
|
|
{
|
|
MaxBP = Press;
|
|
Time = true;
|
|
}
|
|
|
|
/// <summary>Returns the currently commanded cylinder pressure (BP).</summary>
|
|
double TH1405::GetCP()
|
|
{
|
|
return BP;
|
|
}
|
|
|
|
//---FVel6---
|
|
|
|
/// <summary>
|
|
/// Computes brake-pipe flow for the FVel6 combined handle. Position-dependent
|
|
/// flow speed selects between full release, lap, brake (positions 4.3..4.8)
|
|
/// and emergency (above 5.5). Also publishes EP intensity (-1, 0 or 1) and
|
|
/// the corresponding sound channels.
|
|
/// </summary>
|
|
/// <param name="i_bcp">Continuous handle position.</param>
|
|
/// <param name="PP">Brake pipe pressure [bar].</param>
|
|
/// <param name="HP">High-pressure source [bar].</param>
|
|
/// <param name="dt">Time step [s].</param>
|
|
/// <param name="ep">EP / equalising input (unused).</param>
|
|
/// <returns>Brake pipe volume change for this step.</returns>
|
|
double TFVel6::GetPF(double i_bcp, double PP, double HP, double dt, double ep)
|
|
{
|
|
static int const LBDelay = 100;
|
|
|
|
double LimPP;
|
|
double dpMainValve;
|
|
double ActFlowSpeed;
|
|
|
|
CP = PP;
|
|
|
|
LimPP = std::min(5. * int(i_bcp < 3.5), HP);
|
|
if (i_bcp >= 3.5 && (i_bcp < 4.3 || i_bcp > 5.5))
|
|
ActFlowSpeed = 0;
|
|
else if (i_bcp > 4.3 && i_bcp < 4.8)
|
|
ActFlowSpeed = 4 * (i_bcp - 4.3); // konsultacje wawa1 - bylo 8;
|
|
else if (i_bcp < 4)
|
|
ActFlowSpeed = 2;
|
|
else
|
|
ActFlowSpeed = 4;
|
|
dpMainValve = PF(LimPP, PP, ActFlowSpeed / LBDelay) * dt;
|
|
|
|
Sounds[s_fv4a_e] = 0;
|
|
Sounds[s_fv4a_u] = 0;
|
|
Sounds[s_fv4a_b] = 0;
|
|
if (i_bcp < 3.5)
|
|
Sounds[s_fv4a_u] = -dpMainValve;
|
|
else if (i_bcp < 4.8)
|
|
Sounds[s_fv4a_b] = dpMainValve;
|
|
else if (i_bcp < 5.5)
|
|
Sounds[s_fv4a_e] = dpMainValve;
|
|
|
|
if (i_bcp < -0.5)
|
|
EPS = -1;
|
|
else if (i_bcp > 0.5 && i_bcp < 4.7)
|
|
EPS = 1;
|
|
else
|
|
EPS = 0;
|
|
// EPS:=i_bcp*int(i_bcp<2)
|
|
return dpMainValve;
|
|
}
|
|
|
|
/// <summary>Returns CP.</summary>
|
|
double TFVel6::GetCP()
|
|
{
|
|
return CP;
|
|
}
|
|
|
|
/// <summary>Returns the constant 5 bar regulator target.</summary>
|
|
double TFVel6::GetRP()
|
|
{
|
|
return 5.0;
|
|
}
|
|
|
|
/// <summary>Returns the current EP intensity.</summary>
|
|
double TFVel6::GetEP()
|
|
{
|
|
return EPS;
|
|
}
|
|
|
|
/// <summary>Returns pos_table[i].</summary>
|
|
/// <param name="i">Function code (bh_*).</param>
|
|
double TFVel6::GetPos(int i)
|
|
{
|
|
return pos_table[i];
|
|
}
|
|
|
|
/// <summary>Returns Sounds[i] for valid indices, 0 otherwise.</summary>
|
|
/// <param name="i">Sound channel index (0..2).</param>
|
|
double TFVel6::GetSound(int i)
|
|
{
|
|
if (i > 2)
|
|
return 0;
|
|
else
|
|
return Sounds[i];
|
|
}
|
|
|
|
/// <summary>Enables the time and EP-time chambers (no pressure init).</summary>
|
|
/// <param name="Press">Initial pressure (unused).</param>
|
|
void TFVel6::Init(double Press)
|
|
{
|
|
Time = true;
|
|
TimeEP = true;
|
|
}
|
|
|
|
//---FVE408---
|
|
|
|
/// <summary>
|
|
/// Computes brake-pipe flow for the FVE408 combined handle. Splits the flow
|
|
/// behaviour into release (positions < 6.5), brake (7.5..8.5), emergency
|
|
/// (8.5..9.5) and locked positions; sets EPS to fixed steps at detents 1..5.
|
|
/// </summary>
|
|
/// <param name="i_bcp">Continuous handle position.</param>
|
|
/// <param name="PP">Brake pipe pressure [bar].</param>
|
|
/// <param name="HP">High-pressure source [bar].</param>
|
|
/// <param name="dt">Time step [s].</param>
|
|
/// <param name="ep">EP / equalising input (unused).</param>
|
|
/// <returns>Brake pipe volume change for this step.</returns>
|
|
double TFVE408::GetPF(double i_bcp, double PP, double HP, double dt, double ep)
|
|
{
|
|
static int const LBDelay = 100;
|
|
|
|
double LimPP;
|
|
double dpMainValve;
|
|
double ActFlowSpeed;
|
|
|
|
CP = PP;
|
|
|
|
LimPP = std::min(5. * int(i_bcp < 6.5), HP);
|
|
if (i_bcp >= 6.5 && (i_bcp < 7.5 || i_bcp > 9.5))
|
|
ActFlowSpeed = 0;
|
|
else if (i_bcp > 7.5 && i_bcp < 8.5)
|
|
ActFlowSpeed = 2; // konsultacje wawa1 - bylo 8;
|
|
else if (i_bcp < 6.5)
|
|
ActFlowSpeed = 2;
|
|
else
|
|
ActFlowSpeed = 4;
|
|
dpMainValve = PF(LimPP, PP, ActFlowSpeed / LBDelay) * dt;
|
|
|
|
Sounds[s_fv4a_e] = 0;
|
|
Sounds[s_fv4a_u] = 0;
|
|
Sounds[s_fv4a_b] = 0;
|
|
if (i_bcp < 6.5)
|
|
Sounds[s_fv4a_u] = -dpMainValve;
|
|
else if (i_bcp < 8.5)
|
|
Sounds[s_fv4a_b] = dpMainValve;
|
|
else if (i_bcp < 9.5)
|
|
Sounds[s_fv4a_e] = dpMainValve;
|
|
|
|
if (is_EQ(i_bcp, 1))
|
|
EPS = 1.15;
|
|
else if (is_EQ(i_bcp, 2))
|
|
EPS = 1.40;
|
|
else if (is_EQ(i_bcp, 3))
|
|
EPS = 2.64;
|
|
else if (is_EQ(i_bcp, 4))
|
|
EPS = 3.84;
|
|
else if (is_EQ(i_bcp, 5))
|
|
EPS = 3.99;
|
|
else
|
|
EPS = 0;
|
|
|
|
return dpMainValve;
|
|
}
|
|
|
|
/// <summary>Returns CP.</summary>
|
|
double TFVE408::GetCP()
|
|
{
|
|
return CP;
|
|
}
|
|
|
|
/// <summary>Returns the current EP intensity.</summary>
|
|
double TFVE408::GetEP()
|
|
{
|
|
return EPS;
|
|
}
|
|
|
|
/// <summary>Returns the constant 5 bar regulator target.</summary>
|
|
double TFVE408::GetRP()
|
|
{
|
|
return 5.0;
|
|
}
|
|
|
|
/// <summary>Returns pos_table[i].</summary>
|
|
/// <param name="i">Function code (bh_*).</param>
|
|
double TFVE408::GetPos(int i)
|
|
{
|
|
return pos_table[i];
|
|
}
|
|
|
|
/// <summary>Returns Sounds[i] for valid indices, 0 otherwise.</summary>
|
|
/// <param name="i">Sound channel index (0..2).</param>
|
|
double TFVE408::GetSound(int i)
|
|
{
|
|
if (i > 2)
|
|
return 0;
|
|
else
|
|
return Sounds[i];
|
|
}
|
|
|
|
/// <summary>Enables the time chamber, disables the EP-time chamber.</summary>
|
|
/// <param name="Press">Initial pressure (unused).</param>
|
|
void TFVE408::Init(double Press)
|
|
{
|
|
Time = true;
|
|
TimeEP = false;
|
|
}
|
|
|
|
// END
|