mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-12-01 08:17:09 +01:00
5e56a91515
The types of the devices nested in physics::Vehicle (basic_device, the pumps,
the fans, basic_valve, basic_pantograph, basic_door, door_data, water_heater,
genset_device) move out of it into physics/components/devices.h, namespace
physics, so the components of the vehicle can hold them.
The pantographs and their air become components, with English names
(physics/components/pantographs.h):
Pantographs pantographs (ByEnd<basic_pantograph>)
pantographCircuit PantFrontVolt / PantRearVolt frontVoltage /
rearVoltage, PantographVoltage supplyVoltage,
PantAllDown allDown, PantSwitchType switchType,
PantsPreset presets
pantographAir PantVolume volume, PantPress pressure,
PantCompFlag compressorRunning,
PantographCompressorStart compressorStart,
SmallCompressorPower compressorPower, PantsValve
valve, bPantKurek3 connectedToMainReservoir,
PantAutoValve autoValve, PantPressSwitchActive /
PantPressLockActive pressureSwitchActive /
pressureLockActive
No string literal changed (checked over all the changed files).
No change in behaviour: 1149/1149 tests, golden traces exact against staging
62f7a29b.
221 lines
7.7 KiB
C++
221 lines
7.7 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/.
|
|
*/
|
|
|
|
// the devices of a vehicle: pumps, fans, valves, pantographs, doors, the genset (nested in physics::Vehicle before)
|
|
|
|
#pragma once
|
|
|
|
#include <algorithm>
|
|
#include <vector>
|
|
|
|
#include "physics/vehicletypes.h"
|
|
|
|
namespace physics
|
|
{
|
|
|
|
/* TODO: implement
|
|
// communication cable, exchanging control signals with adjacent vehicle
|
|
struct jumper_cable {
|
|
// types
|
|
using flag_pair = std::pair<bool, bool>;
|
|
// members
|
|
// booleans
|
|
// std::array<bool, 1> flags {};
|
|
// boolean pairs, exchanged data is swapped when connected to a matching end (front to front or back to back)
|
|
// TBD, TODO: convert to regular bool array for efficiency once it's working?
|
|
std::array<flag_pair, 1> flag_pairs {};
|
|
// integers
|
|
// std::array<int, 1> values {};
|
|
};
|
|
*/
|
|
// basic approximation of a generic device
|
|
// TBD: inheritance or composition?
|
|
struct basic_device
|
|
{
|
|
// config
|
|
start_t start_type{start_t::manual};
|
|
// ld inputs
|
|
bool is_enabled{false}; // device is allowed/requested to operate
|
|
bool is_disabled{false}; // device is requested to stop
|
|
// TODO: add remaining inputs; start conditions and potential breakers
|
|
// ld outputs
|
|
bool is_active{false}; // device is working
|
|
};
|
|
|
|
struct basic_light : public basic_device
|
|
{
|
|
// config
|
|
float dimming{1.0f}; // light strength multiplier
|
|
// ld outputs
|
|
float intensity{0.0f}; // current light strength
|
|
};
|
|
|
|
struct cooling_fan : public basic_device
|
|
{
|
|
// config
|
|
float speed{0.f}; // cooling fan rpm; either fraction of parent rpm, or absolute value if negative
|
|
float sustain_time{0.f}; // time of sustaining work of cooling fans after stop
|
|
float min_start_velocity{-1.f}; // minimal velocity of vehicle, when cooling fans activate
|
|
// ld outputs
|
|
float revolutions{0.f}; // current fan rpm
|
|
float stop_timer{0.f}; // current time, when shut off condition is active
|
|
};
|
|
|
|
// basic approximation of a fuel pump
|
|
struct fuel_pump : public basic_device
|
|
{
|
|
// TODO: fuel consumption, optional automatic engine start after activation
|
|
};
|
|
|
|
// basic approximation of an oil pump
|
|
struct oil_pump : public basic_device
|
|
{
|
|
// config
|
|
float pressure_minimum{0.f}; // lowest acceptable working pressure
|
|
float pressure_maximum{0.65f}; // oil pressure at maximum engine revolutions
|
|
// ld inputs
|
|
float resource_amount{1.f}; // amount of affected resource, compared to nominal value
|
|
// internal data
|
|
float pressure_target{0.f};
|
|
// ld outputs
|
|
float pressure{0.f}; // current pressure
|
|
};
|
|
|
|
// the diesel generator set of a dual-mode vehicle: a second source of the traction circuit, next to the
|
|
// pantographs (eu07/maszyna#536). none unless the .fiz gives GensetPower
|
|
struct genset_device : public basic_device
|
|
{
|
|
// config (Power: Genset*), revolutions in rev/s, the .fiz gives rpm
|
|
double power{0.0}; // GensetPower, electric output at full revolutions [kW]; 0 = no genset
|
|
double voltage_nominal{0.0}; // GensetVoltage, regulated DC voltage from the idle revolutions up [V]
|
|
double revolutions_idle{0.0}; // GensetIdleRPM
|
|
double revolutions_max{0.0}; // GensetMaxRPM
|
|
double start_time{8.0}; // GensetStartTime, from the start request to running at idle [s]
|
|
double spinup_time{3.0}; // GensetSpinUpTime, time constant of the revolutions [s]
|
|
double traction_share{1.0}; // GensetPmaxRatio, part of the power the traction may take
|
|
// state
|
|
double timer{0.0}; // of the start [s]
|
|
bool is_cranking{false};
|
|
// ld outputs
|
|
double revolutions{0.0}; // [rev/s]
|
|
double voltage{0.0}; // [V]
|
|
bool fitted() const { return power > 0.0; }
|
|
// the power the genset gives at its present revolutions [kW]
|
|
double available_power() const { return revolutions_max > 0.0 ? power * std::clamp(revolutions / revolutions_max, 0.0, 1.0) : 0.0; }
|
|
};
|
|
// basic approximation of a water pump
|
|
struct water_pump : public basic_device
|
|
{
|
|
// ld inputs
|
|
// TODO: move to breaker list in the basic device once implemented
|
|
bool breaker{false}; // device is allowed to operate
|
|
};
|
|
|
|
// basic approximation of a solenoid valve
|
|
struct basic_valve : basic_device
|
|
{
|
|
// config
|
|
bool solenoid{true}; // requires electric power to operate
|
|
bool spring{true}; // spring return or double acting actuator
|
|
};
|
|
|
|
// basic approximation of a pantograph
|
|
struct basic_pantograph
|
|
{
|
|
// ld inputs
|
|
basic_valve valve; // associated pneumatic valve
|
|
// ld outputs
|
|
bool is_active{false}; // device is working
|
|
bool sound_event{false}; // indicates last state which generated sound event
|
|
double voltage{0.0};
|
|
};
|
|
|
|
// basic approximation of doors
|
|
struct basic_door
|
|
{
|
|
// config
|
|
// ld inputs
|
|
bool open_permit{false}; // door can be opened
|
|
bool local_open{false}; // local attempt to open the door
|
|
bool local_close{false}; // local attempt to close the door
|
|
bool remote_open{false}; // received remote signal to open the door
|
|
bool remote_close{false}; // received remote signal to close the door
|
|
// internal data
|
|
float auto_timer{-1.f}; // delay between activation of open state and closing state for automatic doors
|
|
float close_delay{0.f}; // delay between activation of closing state and actual closing
|
|
float open_delay{0.f}; // delay between activation of opening state and actual opening
|
|
float position{0.f}; // current shift of the door from the closed position
|
|
float step_position{0.f}; // current shift of the movable step from the retracted position
|
|
// ld outputs
|
|
bool is_closed{true}; // the door is fully closed
|
|
bool is_door_closed{true}; // the door is fully closed, step doesn't matter
|
|
bool is_closing{false}; // the door is currently closing
|
|
bool is_opening{false}; // the door is currently opening
|
|
bool is_open{false}; // the door is fully open
|
|
bool step_folding{false}; // the doorstep is currently closing
|
|
bool step_unfolding{false}; // the doorstep is currently opening
|
|
};
|
|
|
|
struct door_data
|
|
{
|
|
// config
|
|
control_t open_control{control_t::passenger};
|
|
float open_rate{1.f};
|
|
float open_delay{0.f};
|
|
control_t close_control{control_t::passenger};
|
|
float close_rate{1.f};
|
|
float close_delay{0.f};
|
|
int type{2};
|
|
float range{0.f}; // extent of primary move/rotation
|
|
float range_out{0.f}; // extent of shift outward, applicable for plug doors
|
|
int step_type{2};
|
|
float step_rate{0.5f};
|
|
float step_range{0.f};
|
|
bool has_lock{false};
|
|
bool has_warning{false};
|
|
bool has_autowarning{false};
|
|
float auto_duration{-1.f}; // automatic door closure delay period
|
|
float auto_velocity{-1.f}; // automatic door closure velocity threshold
|
|
bool auto_include_remote{false}; // automatic door closure applies also to remote control
|
|
bool permit_needed{false};
|
|
bool closure_signal{false}; // the door closure lamp (SOD) of the cab signals the doors of the whole consist in three states
|
|
std::vector<int> permit_presets; // permit presets selectable with preset switch
|
|
float voltage{0.f}; // power type required for door movement
|
|
// ld inputs
|
|
bool lock_enabled{true};
|
|
bool step_enabled{true};
|
|
bool remote_only{false}; // door ignores local control signals
|
|
// internal data
|
|
int permit_preset{-1}; // curent position of preset selection switch
|
|
// vehicle parts
|
|
BySide<basic_door> instances; // door on the right and left side of the vehicle
|
|
// ld outputs
|
|
bool is_locked{false};
|
|
double doorLockSpeed = 10.0; // predkosc przy ktorej wyzwalana jest blokada drzwi
|
|
};
|
|
|
|
struct water_heater
|
|
{
|
|
// config
|
|
struct heater_config_t
|
|
{
|
|
float temp_min{-1}; // lowest accepted temperature
|
|
float temp_max{-1}; // highest accepted temperature
|
|
};
|
|
heater_config_t config;
|
|
// ld inputs
|
|
bool breaker{false}; // device is allowed to operate
|
|
bool is_enabled{false}; // device is requested to operate
|
|
// ld outputs
|
|
bool is_active{false}; // device is working
|
|
bool is_damaged{false}; // device is damaged
|
|
};
|
|
|
|
} // namespace physics
|