1
0
mirror of https://github.com/metrostroi-repo/MetrostroiAddon.git synced 2026-05-02 00:42:29 +00:00

KM334 and door pneumatics fix

This commit is contained in:
Moon Horse
2025-01-05 18:40:40 +03:00
parent 677f007e73
commit 9ef57da851
2 changed files with 35 additions and 31 deletions

View File

@@ -407,15 +407,16 @@ function TRAIN_SYSTEM:Think(dT)
if self.ValveType == 1 then
self.BLDisconnect = Train.DriverValveBLDisconnect.Value > 0
self.TLDisconnect = Train.DriverValveTLDisconnect.Value > 0 and self.RealDriverValvePosition ~= 3
pr_speed = 1*wagc--*((self.BrakeLinePressure-self.ReservoirPressure)/0.6) --2
pr_speed = 1*6--wagc--*((self.BrakeLinePressure-self.ReservoirPressure)/0.6) --2
if self.TLDisconnect then self.TLDisconnectPressure = self.TrainLinePressure end
if self.Leak or self.BrakeLineOpen then pr_speed = pr_speed*0.3 end
-- 334: 1 Fill reservoir from train line, fill brake line from train line
if (self.RealDriverValvePosition == 1) then
if self.TLDisconnect or self.ReservoirPressure ~= self.TLDisconnectPressure then
if self.BLDisconnect then
self.ReservoirPressure = self.BrakeLinePressure
self:equalizePressure(dT,"BrakeLinePressure", self.TLDisconnectPressure, pr_speed*(pr_speed < wagc and 1 or 1.35),nil,nil,2)--0.7
self:equalizePressure(dT,"ReservoirPressure", self.TLDisconnectPressure, 1.4,nil,nil,2)
self:equalizePressure(dT,"ReservoirPressure", self.BrakeLinePressure, 0,1.2,nil,2)
self:equalizePressure(dT,"BrakeLinePressure", self.TLDisconnectPressure, 6.0,nil,nil,0.2)
else
self:equalizePressure(dT,"ReservoirPressure", self.TLDisconnectPressure, 3.55,nil,nil,2)
end
@@ -428,7 +429,7 @@ function TRAIN_SYSTEM:Think(dT)
local a = 1
if --[[self.EmergencyValve or ]]Train.EmergencyBrakeValve.Value > 0.5 then a = 1.85 end
if self.BLDisconnect then
self.ReservoirPressure = self.BrakeLinePressure
self:equalizePressure(dT,"ReservoirPressure", self.BrakeLinePressure,6,nil,nil,2)
self:equalizePressure(dT,"BrakeLinePressure", self.TrainToBrakeReducedPressure, pr_speed*0, pr_speed*0.6*a, nil, 1.6)
self.ReservoirPressure_dPdT = self.BrakeLinePressure_dPdT*0.8
else
@@ -453,7 +454,7 @@ function TRAIN_SYSTEM:Think(dT)
-- 334: 5 Reservoir and brake line open to atmosphere
if (self.RealDriverValvePosition == 5) then
self:equalizePressure(dT,"ReservoirPressure", 0.0, res_dischrg_rate5)--,nil,nil,2)--1.70
local pr_speed = 1.25*wagc
local pr_speed = 1.25*6--wagc
if self.Leak or self.BrakeLineOpen then pr_speed = pr_speed*0.3 end
if self.BLDisconnect then
if self.Leak then pr_speed = pr_speed*6.2 end
@@ -463,7 +464,7 @@ function TRAIN_SYSTEM:Think(dT)
-- утечка через неплотность уравнительного поршня
if self.BLDisconnect then self:equalizePressure(dT, "ReservoirPressure", self.BrakeLinePressure, 0.06, 0) end
if (self.RealDriverValvePosition > 2) and (self.RealDriverValvePosition < 5) then
local pr_speed = 1.25*wagc
local pr_speed = 1.25*6--wagc
if self.Leak or self.BrakeLineOpen then pr_speed = pr_speed*0.3 end
local _a = 0
for _i = 1, #Train.WagonList do
@@ -677,7 +678,7 @@ function TRAIN_SYSTEM:Think(dT)
-- Simulate doors opening, closing
local LeftRelease = Train.DoorReleaseLeft.Value == 0
local RightRelease = Train.DoorReleaseRight.Value == 0
if self.DoorLinePressure >= 1.9 then --was > 2.6
if self.DoorLinePressure >= 1.4 then --was > 2.6
-- Simulate DVR engage lag
if Train.VDOL.Value == 1.0 and not Train.VDOLEnergized then
Train.VDOLEnergized = true
@@ -737,17 +738,17 @@ function TRAIN_SYSTEM:Think(dT)
self:equalizePressure(dT,"RightDoorCloseCylPressure", not self.DoorRight and RightRelease and self.DoorLinePressure or 0.0, 2.2, 10)
self:equalizePressure(dT,"LeftDoorOpenCylPressure", self.DoorLeft and self.DoorLinePressure or 0.0, 2.2, 10)
self:equalizePressure(dT,"LeftDoorCloseCylPressure", not self.DoorLeft and LeftRelease and self.DoorLinePressure or 0.0, 2.2, 10)
self.DoorLinePressure = self.DoorLinePressure-math.max(0,self.RightDoorOpenCylPressure_dPdT*0.005)
self.DoorLinePressure = self.DoorLinePressure-math.max(0,self.LeftDoorOpenCylPressure_dPdT*0.005)
self.DoorLinePressure = self.DoorLinePressure-math.max(0,self.RightDoorCloseCylPressure_dPdT*0.005)
self.DoorLinePressure = self.DoorLinePressure-math.max(0,self.LeftDoorCloseCylPressure_dPdT*0.005)
self.DoorLinePressure = self.DoorLinePressure-math.max(0,self.RightDoorOpenCylPressure_dPdT*0.01)
self.DoorLinePressure = self.DoorLinePressure-math.max(0,self.LeftDoorOpenCylPressure_dPdT*0.01)
self.DoorLinePressure = self.DoorLinePressure-math.max(0,self.RightDoorCloseCylPressure_dPdT*0.01)
self.DoorLinePressure = self.DoorLinePressure-math.max(0,self.LeftDoorCloseCylPressure_dPdT*0.01)
Train:SetPackedRatio("RightDoorCloseCylPressure_dPdT",not RightRelease and self.RightDoorCloseCylPressure_dPdT or 0)
Train:SetPackedRatio("LeftDoorCloseCylPressure_dPdT",not LeftRelease and self.LeftDoorCloseCylPressure_dPdT or 0)
if self.DoorReleaseRightPrevious ~= Train.DoorReleaseRight.Value then
self.DoorReleaseRightPrevious = Train.DoorReleaseRight.Value
---[[
if not self.DoorRight and self.DoorReleaseRightPrevious == 1 then
self:equalizePressure(dT,"RightDoorCloseCylPressure", 0, 3) --was DoorLinePressure
self:equalizePressure(dT,"RightDoorCloseCylPressure", 0, 6) --was DoorLinePressure
end--]]
end
if self.DoorReleaseLeftPrevious ~= Train.DoorReleaseLeft.Value then
@@ -806,8 +807,8 @@ function TRAIN_SYSTEM:Think(dT)
lmClose = Train[n..tostring(9-i)].Value > 0
--self.LeftDoorState[i] = math.Clamp(self.LeftDoorState[i] + (not llocked and ((lmOpen and 1.5 or lmClose and -1.5 or 0) + (self.DoorLinePressure > 1.0 and (math.Round(self.LeftDoorOpenCylPressure - self.LeftDoorCloseCylPressure,1))*0.36*(not (lmOpen or lmClose) and self.LeftDoorSpeed[i] or 1) or 0))*dT or 0),self.LeftDoorStuck[i] and 0.3 or 0,1)
--self.RightDoorState[i] = math.Clamp(self.RightDoorState[i] + (not rlocked and ((rmOpen and 1.5 or rmClose and -1.5 or 0) + (self.DoorLinePressure > 1.0 and (math.Round(self.RightDoorOpenCylPressure - self.RightDoorCloseCylPressure,1))*0.36*(not (rmOpen or rmClose) and self.RightDoorSpeed[i] or 1) or 0))*dT or 0),self.RightDoorStuck[i] and 0.3 or 0,1)
self.LeftDoorState[i] = math.Clamp(self.LeftDoorState[i] + (not llocked and ((lmOpen and 1.5 or lmClose and -1.5 or 0) + (self.DoorLinePressure > 1.0 and (self.LeftDoorOpenCylPressure - self.LeftDoorCloseCylPressure)*0.36*(not (lmOpen or lmClose) and self.LeftDoorSpeed[i] or 1) or 0))*dT or 0),self.LeftDoorStuck[i] and 0.3 or 0,1)
self.RightDoorState[i] = math.Clamp(self.RightDoorState[i] + (not rlocked and ((rmOpen and 1.5 or rmClose and -1.5 or 0) + (self.DoorLinePressure > 1.0 and (self.RightDoorOpenCylPressure - self.RightDoorCloseCylPressure)*0.36*(not (rmOpen or rmClose) and self.RightDoorSpeed[i] or 1) or 0))*dT or 0),self.RightDoorStuck[i] and 0.3 or 0,1)
self.LeftDoorState[i] = math.Clamp(self.LeftDoorState[i] + (not llocked and ((lmOpen and 1.5 or lmClose and -1.5 or 0) + (self.DoorLinePressure > 1.4 and (self.LeftDoorOpenCylPressure - self.LeftDoorCloseCylPressure)*0.36*(not (lmOpen or lmClose) and self.LeftDoorSpeed[i] or 1) or 0))*dT or 0),self.LeftDoorStuck[i] and 0.3 or 0,1)
self.RightDoorState[i] = math.Clamp(self.RightDoorState[i] + (not rlocked and ((rmOpen and 1.5 or rmClose and -1.5 or 0) + (self.DoorLinePressure > 1.4 and (self.RightDoorOpenCylPressure - self.RightDoorCloseCylPressure)*0.36*(not (rmOpen or rmClose) and self.RightDoorSpeed[i] or 1) or 0))*dT or 0),self.RightDoorStuck[i] and 0.3 or 0,1)
if not Train.LeftDoorsOpen and self.LeftDoorState[i] > 0.02 then --was 0.06
Train.LeftDoorsOpen = true
end