mirror of
https://github.com/metrostroi-repo/MetrostroiAddon.git
synced 2026-05-02 00:42:29 +00:00
Merge pull request #408 from metrostroi-repo/##386,387,388,243
##386,387,388,243
This commit is contained in:
@@ -2043,6 +2043,21 @@ ENT.ButtonMap["AirDistributor"] = {
|
||||
}
|
||||
}
|
||||
|
||||
ENT.ButtonMap["AutostopValve"] = {
|
||||
pos = Vector(365.8,-67.6,-56),
|
||||
ang = Angle(0,0,90),
|
||||
width = 130,
|
||||
height = 40,
|
||||
scale = 0.1,
|
||||
hideseat=0.1,
|
||||
hide=true,
|
||||
screenHide = true,
|
||||
|
||||
buttons = {
|
||||
{ID = "AutostopValveSet",x=0,y=0,w= 130,h = 40,tooltip="Сорвать срывной клапан"},
|
||||
}
|
||||
}
|
||||
|
||||
for i=0,4 do
|
||||
ENT.ClientProps["TrainNumberL"..i] = {
|
||||
model = "models/metrostroi_train/common/bort_numbers.mdl",
|
||||
@@ -3130,8 +3145,8 @@ function ENT:Think()
|
||||
--self:SetSoundState("rolling_medium1",0 or rol40*rollings,rol40p) --57
|
||||
self:SetSoundState("rolling_high2" ,rol70*rollings,rol70p) --70
|
||||
|
||||
self.ReleasedPdT = math.Clamp(self.ReleasedPdT + 2*(-self:GetPackedRatio("BrakeCylinderPressure_dPdT",0)-self.ReleasedPdT)*dT,0,1)
|
||||
local release1 = math.Clamp((self.ReleasedPdT-0.1)/0.8,0,1)^2
|
||||
self.ReleasedPdT = math.Clamp(self.ReleasedPdT + 2*(-self:GetPackedRatio("BrakeCylinderPressure_dPdT",0)-0.8*self.ReleasedPdT)*dT,0,1)
|
||||
local release1 = math.Clamp((1.1*self.ReleasedPdT-0.1)/0.48,0,8)^2
|
||||
self:SetSoundState("release1",release1,1)
|
||||
self:SetSoundState("release2",(math.Clamp(0.3-release1,0,0.3)/0.3)*(release1/0.3),1.0)
|
||||
local parking_brake = self:GetPackedRatio("ParkingBrakePressure_dPdT",0)
|
||||
@@ -3194,9 +3209,9 @@ function ENT:Think()
|
||||
self:SetSoundState("crane334_release",math.Clamp(self.CraneRamp,0,1)^2,1.0)
|
||||
end
|
||||
local emergencyValveEPK = self:GetPackedRatio("EmergencyValveEPK_dPdT",0)
|
||||
self.EmergencyValveEPKRamp = math.Clamp(self.EmergencyValveEPKRamp + 1.0*((0.5*emergencyValveEPK)-self.EmergencyValveEPKRamp)*dT,0,1)
|
||||
self.EmergencyValveEPKRamp = math.Clamp(self.EmergencyValveEPKRamp + 1.0*((0.5*emergencyValveEPK)-self.EmergencyValveEPKRamp)*12*dT,0,1)
|
||||
if self.EmergencyValveEPKRamp < 0.01 then self.EmergencyValveEPKRamp = 0 end
|
||||
self:SetSoundState("epk_brake",self.EmergencyValveEPKRamp,1.0)
|
||||
self:SetSoundState("epk_brake",self.EmergencyValveEPKRamp,2.8)
|
||||
|
||||
--[[
|
||||
local emergencyBrakeValve = self:GetPackedRatio("EmergencyBrakeValve_dPdT", 0)
|
||||
@@ -3352,6 +3367,9 @@ function ENT:DrawPost()
|
||||
self:DrawOnPanel("AirDistributor",function()
|
||||
draw.DrawText(self:GetNW2Bool("AD") and "Air Distributor ON" or "Air Distributor OFF","Trebuchet24",0,0,Color(0,0,0,255))
|
||||
end)
|
||||
self:DrawOnPanel("AutostopValve",function()
|
||||
draw.DrawText("Autostop Valve", "Trebuchet24",0,6,Color(0,0,0,255))
|
||||
end)
|
||||
end
|
||||
|
||||
function ENT:OnButtonPressed(button)
|
||||
|
||||
@@ -200,6 +200,10 @@ function ENT:Initialize()
|
||||
ID = "AirDistributorDisconnectToggle",
|
||||
Pos = Vector(-177, -66, -50), Radius = 20,
|
||||
},
|
||||
{
|
||||
ID = "AutostopValveToggle",
|
||||
Pos = Vector(377, -66, -50), Radius = 20,
|
||||
},
|
||||
}
|
||||
|
||||
local vX = Angle(0,-90-0.2,56.3):Forward() -- For ARS panel
|
||||
@@ -557,7 +561,7 @@ function ENT:Think()
|
||||
local power = Panel.V1 > -1.5
|
||||
local brightness = math.min(1,Panel.Headlights1)*0.60 +
|
||||
math.min(1,Panel.Headlights2)*0.40
|
||||
|
||||
--local T = {}
|
||||
|
||||
self:SetPackedBool("Headlights1",Panel.Headlights1 > 0)
|
||||
self:SetPackedBool("Headlights2",Panel.Headlights2 > 0)
|
||||
@@ -584,7 +588,10 @@ function ENT:Think()
|
||||
self:SetPackedBool("lightsActive"..i,false)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
if self:ReadTrainWire(4)*self:ReadTrainWire(5) > 0 then
|
||||
self.A54:TriggerInput("Set",0)
|
||||
end
|
||||
|
||||
-- Door button lights
|
||||
self:SetPackedBool("DoorsLeftL",Panel.DoorsLeft > 0.5)
|
||||
|
||||
@@ -441,11 +441,11 @@ function ENT:InitializeSounds()
|
||||
self.SoundPositions["rear_isolation"] = {300,1e9,Vector(-456, 0,-63),1}
|
||||
|
||||
self.SoundNames["crane013_brake"] = {loop=true,"subway_trains/common/pneumatic/release_2.wav"}
|
||||
self.SoundPositions["crane013_brake"] = {80,1e9,Vector(431.5,-20.3,-12),0.86}
|
||||
self.SoundPositions["crane013_brake"] = {400,1e9,Vector(431.5,-20.3,-12),0.86}
|
||||
self.SoundNames["crane013_brake2"] = {loop=true,"subway_trains/common/pneumatic/013_brake2.wav"}
|
||||
self.SoundPositions["crane013_brake2"] = {80,1e9,Vector(431.5,-20.3,-12),0.86}
|
||||
self.SoundPositions["crane013_brake2"] = {400,1e9,Vector(431.5,-20.3,-12),0.86}
|
||||
self.SoundNames["crane013_brake_l"] = {loop=true,"subway_trains/common/pneumatic/013_brake_loud2.wav"}
|
||||
self.SoundPositions["crane013_brake_l"] = {80,1e9,Vector(431.5,-20.3,-12),0.7}
|
||||
self.SoundPositions["crane013_brake_l"] = {400,1e9,Vector(431.5,-20.3,-12),0.7}
|
||||
self.SoundNames["crane013_release"] = {loop=true,"subway_trains/common/pneumatic/013_release.wav"}
|
||||
self.SoundPositions["crane013_release"] = {80,1e9,Vector(431.5,-20.3,-12),0.4}
|
||||
self.SoundNames["crane334_brake_high"] = {loop=true,"subway_trains/common/pneumatic/334_brake.wav"}
|
||||
@@ -975,9 +975,10 @@ ENT.Spawner = {
|
||||
ent.ARS:TriggerInput("Set",(ent.Plombs.RC1 and val==1 and first) and 1 or 0)
|
||||
ent.ALS:TriggerInput("Set",val==1 and 1 or 0)
|
||||
ent.L_1:TriggerInput("Set",val==1 and 1 or 0)
|
||||
ent.L_3:TriggerInput("Set",vall==1 and 1 or 0)
|
||||
ent.L_3:TriggerInput("Set",val==1 and 1 or 0)
|
||||
ent.L_4:TriggerInput("Set",val==1 and 1 or 0)
|
||||
ent.EPK:TriggerInput("Set",(ent.Plombs.RC1 and val==1) and 1 or 0)
|
||||
ent.DriverValveDisconnect:TriggerInput("Set",(val==4 and first) and 1 or 0)
|
||||
_LastSpawner=CurTime()
|
||||
ent.CabinDoor = val==4 and first
|
||||
ent.PassengerDoor = val==4
|
||||
@@ -996,6 +997,7 @@ ENT.Spawner = {
|
||||
ent._SpawnerStarted = val
|
||||
end
|
||||
ent.Pneumatic.TrainLinePressure = val==3 and math.random()*4 or val==2 and 4.5+math.random()*3 or 7.6+math.random()*0.6
|
||||
ent.Pneumatic.WorkingChamberPressure = val==3 and math.random()*1.0 or val==2 and 4.0+math.random()*1.0 or 5.2
|
||||
if val==4 then ent.Pneumatic.BrakeLinePressure = 5.2 end
|
||||
end},
|
||||
--{"Lighter","Spawner.717.Lighter","Boolean"},
|
||||
|
||||
@@ -89,9 +89,10 @@ ENT.Spawner = {
|
||||
ent.ARS:TriggerInput("Set",(ent.Plombs.RC1 and val==1 and first) and 1 or 0)
|
||||
ent.ALS:TriggerInput("Set",val==1 and 1 or 0)
|
||||
ent.L_1:TriggerInput("Set",val==1 and 1 or 0)
|
||||
ent.L_3:TriggerInput("Set",vall==1 and 1 or 0)
|
||||
ent.L_3:TriggerInput("Set",val==1 and 1 or 0)
|
||||
ent.L_4:TriggerInput("Set",val==1 and 1 or 0)
|
||||
ent.EPK:TriggerInput("Set",(ent.Plombs.RC1 and val==1) and 1 or 0)
|
||||
ent.DriverValveDisconnect:TriggerInput("Set",(val==4 and first) and 1 or 0)
|
||||
_LastSpawner=CurTime()
|
||||
ent.CabinDoor = val==4 and first
|
||||
ent.PassengerDoor = val==4
|
||||
@@ -110,6 +111,7 @@ ENT.Spawner = {
|
||||
ent._SpawnerStarted = val
|
||||
end
|
||||
ent.Pneumatic.TrainLinePressure = val==3 and math.random()*4 or val==2 and 4.5+math.random()*3 or 7.6+math.random()*0.6
|
||||
if val==4 then ent.Pneumatic.BrakeLinePressure = 5.2 end
|
||||
ent.Pneumatic.BrakeLinePressure = val == 4 and 5.2 or val == 1 and 2.3 or math.min(ent.Pneumatic.TrainLinePressure+0.25,math.random()*4)
|
||||
ent.Pneumatic.WorkingChamberPressure = val==3 and math.random()*1.0 or val==2 and 4.0+math.random()*1.0 or 5.2
|
||||
end},
|
||||
}
|
||||
|
||||
@@ -89,7 +89,6 @@ function TRAIN_SYSTEM:SolveAllInternalCircuits(Train,dT,firstIter)
|
||||
|
||||
Train:WriteTrainWire(5,S["10AK"]*KV["10AK-5"] + KRU["5/3-ZM31"]*-10)
|
||||
Train:WriteTrainWire(4,S["10AK"]*KV["10AK-4"] + --[[max(0,min(1,T[4])*KV["4-0"]*-10)]]KV["4-0"]*-10)
|
||||
--Train:WriteTrainWire(4,S["10AK"]*KV["10AK-4"]*(1-T[4]*KV["4-0"]*-10))
|
||||
|
||||
Panel.LST = T[6]*Train.A40.Value
|
||||
Panel.LhRK = (T[2]+T[-2])*Train.A57.Value
|
||||
|
||||
@@ -43,6 +43,15 @@ function TRAIN_SYSTEM:Initialize(parameters)
|
||||
self.OldBrakeLinePressure = 0.0
|
||||
self.BCPressure = 0
|
||||
|
||||
-- Air distrubutor part
|
||||
self.WorkingChamberPressure = 0.0
|
||||
--self.AirDistributorReady = false --заменено на локальные
|
||||
--self.OverchargeReleaseValve = false --переменные
|
||||
self.WCChargeValve = true
|
||||
self.PN1 = 0
|
||||
self.PN2 = 0
|
||||
self.cranPres = 0
|
||||
|
||||
--DKPT
|
||||
self.Train:LoadSystem("DKPT","Relay","R-52B") --
|
||||
-- Valve #1
|
||||
@@ -73,8 +82,11 @@ function TRAIN_SYSTEM:Initialize(parameters)
|
||||
self.Train:LoadSystem("EmergencyBrakeValve","Relay","Switch")
|
||||
-- Воздухораспределитель
|
||||
self.Train:LoadSystem("AirDistributorDisconnect","Relay","Switch")
|
||||
--Срывной клапан
|
||||
self.Train:LoadSystem("AutostopValve","Relay","Switch")
|
||||
--УАВА
|
||||
self.Train:LoadSystem("UAVA","Relay","Switch",{ bass = true})
|
||||
--self.Train:LoadSystem("UAVAContact","Relay","Switch")
|
||||
self.Train:LoadSystem("UAVAC","Relay","",{normally_closed=true,bass=true})
|
||||
--Стояночный тормоз
|
||||
self.Train:LoadSystem("ParkingBrake","Relay","Switch",{bass = true})
|
||||
@@ -143,7 +155,7 @@ end
|
||||
|
||||
function TRAIN_SYSTEM:Outputs()
|
||||
return { "BrakeLinePressure", "BrakeCylinderPressure", "DriverValvePosition",
|
||||
"ReservoirPressure", "TrainLinePressure", "DoorLinePressure", "WeightLoadRatio" }
|
||||
"ReservoirPressure", "TrainLinePressure", "DoorLinePressure", "WeightLoadRatio", "WorkingChamberPressure" }
|
||||
end
|
||||
|
||||
function TRAIN_SYSTEM:TriggerInput(name,value)
|
||||
@@ -166,8 +178,13 @@ function TRAIN_SYSTEM:TriggerInput(name,value)
|
||||
local HaveUAVA = not self.Train.SubwayTrain or not self.Train.SubwayTrain.ARS or not self.Train.SubwayTrain.ARS.NoUAVA
|
||||
if HaveUAVA and self.Train.UAVA.Value == 0 then
|
||||
self.EmergencyValve = true
|
||||
self.Train.UAVAC:TriggerInput("Set",0)
|
||||
if value > 0 then RunConsoleCommand("say","Autostop braking",self.Train:GetDriverName()) end
|
||||
if value ~= 2 then
|
||||
self.Train.UAVAC:TriggerInput("Set",0)
|
||||
if not self.Train.AutoStopNotify then
|
||||
self.Train.AutoStopNotify = true
|
||||
RunConsoleCommand("say","Autostop braking",self.Train:GetDriverName())
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -297,7 +314,7 @@ end
|
||||
function TRAIN_SYSTEM:Think(dT)
|
||||
local Train = self.Train
|
||||
self.WeightLoadRatio = math.max(0,math.min(1,(Train:GetNW2Float("PassengerCount")/200)))
|
||||
|
||||
--self.WeightLoadRatio = (Train.R_ZS and Train.R_ZS.Value > 0 and 0.5 or 0) + (Train.R_G and Train.R_G.Value > 0 and 0.5 or 0)
|
||||
----------------------------------------------------------------------------
|
||||
-- Accumulate derivatives
|
||||
self.TrainLinePressure_dPdT = 0.0
|
||||
@@ -306,9 +323,14 @@ function TRAIN_SYSTEM:Think(dT)
|
||||
self.ReservoirPressure_dPdT = 0.0
|
||||
self.BrakeCylinderPressure_dPdT = 0.0
|
||||
self.ParkingBrakePressure_dPdT = 0.0
|
||||
self.WorkingChamberPressure_dPdT = 0.0
|
||||
|
||||
local rnd = math.random(1,10)
|
||||
local offs = 0.1
|
||||
self.KM013offset = self.KM013offset or math.Clamp(5.1 + (rnd >= 3 and rnd <= 7 and offs or -offs),5.0,5.2)
|
||||
|
||||
-- Reduce pressure for brake line
|
||||
self.TrainToBrakeReducedPressure = math.min(5.1,self.TrainLinePressure) -- * 0.725)
|
||||
self.TrainToBrakeReducedPressure = math.min(self.KM013offset,self.TrainLinePressure) -- * 0.725)
|
||||
-- Feed pressure to door line
|
||||
self.DoorLinePressure = self.TrainToBrakeReducedPressure * 0.90
|
||||
local trainLineConsumption_dPdT = 0.0
|
||||
@@ -316,6 +338,11 @@ function TRAIN_SYSTEM:Think(dT)
|
||||
local HaveEPK = not Train.SubwayTrain or not Train.SubwayTrain.ARS or not Train.SubwayTrain.ARS.NoEPK
|
||||
|
||||
local BLDisconnect,pr_speed = true,1
|
||||
-- работа срывного клапана
|
||||
if Train.AutostopValve.Value > 0 then
|
||||
self:TriggerInput("Autostop",self.BrakeLinePressure > 1.86 and 1 or 2) --value == 2 — просто открыть срывной клапан без размыкания контактов УАВА
|
||||
end
|
||||
|
||||
if self.ValveType == 1 then
|
||||
BLDisconnect = Train.DriverValveBLDisconnect.Value > 0
|
||||
local TLDisconnect = Train.DriverValveTLDisconnect.Value > 0
|
||||
@@ -368,42 +395,42 @@ function TRAIN_SYSTEM:Think(dT)
|
||||
trainLineConsumption_dPdT = trainLineConsumption_dPdT + math.max(0,self.ReservoirPressure_dPdT)*0.05
|
||||
else
|
||||
pr_speed = 1.25*wagc --2
|
||||
if self.Leak or self.BraieLineOpen then pr_speed = pr_speed*0.7 end
|
||||
if self.Leak or self.BrakeLineOpen then pr_speed = pr_speed*0.7 end
|
||||
BLDisconnect = self.DisconnectType and Train.DriverValveBLDisconnect.Value > 0 or Train.DriverValveDisconnect.Value > 0
|
||||
local TLDisconnect = self.DisconnectType and Train.DriverValveTLDisconnect.Value > 0 or Train.DriverValveDisconnect.Value > 0
|
||||
-- 013: 1 Overcharge
|
||||
if (self.RealDriverValvePosition == 1) and BLDisconnect and (TLDisconnect or self.BrakeLinePressure > self.TrainLinePressure) then
|
||||
self:equalizePressure(dT,"BrakeLinePressure", math.min(6.0,self.TrainLinePressure), pr_speed)
|
||||
self:equalizePressure(dT,"BrakeLinePressure", math.min(6.4,self.TrainLinePressure), pr_speed,Train.EPKC.Value==0 and Train.EPK.Value > 0 and pr_speed*2.2 or pr_speed*0.35, nil, 1.0)
|
||||
end
|
||||
|
||||
-- 013: 2 Normal pressure
|
||||
if (self.RealDriverValvePosition == 2) and BLDisconnect and (TLDisconnect or self.BrakeLinePressure > 1.01*math.min(5.1,self.TrainToBrakeReducedPressure)) then
|
||||
self:equalizePressure(dT,"BrakeLinePressure", 1.01*math.min(5.1,self.TrainToBrakeReducedPressure), pr_speed,nil, nil, 1.0)-- nil, 1.0)
|
||||
if (self.RealDriverValvePosition == 2) and BLDisconnect and (TLDisconnect or self.BrakeLinePressure > 1.01*math.min(self.KM013offset,self.TrainToBrakeReducedPressure)) then
|
||||
self:equalizePressure(dT,"BrakeLinePressure", 1.01*math.min(self.KM013offset,self.TrainToBrakeReducedPressure), pr_speed,Train.EPKC.Value==0 and Train.EPK.Value > 0 and pr_speed*2 or pr_speed*0.35, nil, 1.0)-- nil, 1.0)
|
||||
end
|
||||
|
||||
-- 013: 3 4.3 Atm
|
||||
if (self.RealDriverValvePosition == 3) and BLDisconnect and (TLDisconnect or self.BrakeLinePressure > 1.01*math.min(4.3,self.TrainToBrakeReducedPressure)) then
|
||||
self:equalizePressure(dT,"BrakeLinePressure", 1.01*math.min(4.3,self.TrainToBrakeReducedPressure), pr_speed,nil, nil, 1.0)
|
||||
self:equalizePressure(dT,"BrakeLinePressure", 1.01*math.min(4.3,self.TrainToBrakeReducedPressure), pr_speed,pr_speed*0.35, nil, 1.0)
|
||||
end
|
||||
|
||||
-- 013: 4 4.0 Atm
|
||||
if (self.RealDriverValvePosition == 4) and BLDisconnect and (TLDisconnect or self.BrakeLinePressure > 1.01*math.min(4.0,self.TrainToBrakeReducedPressure)) then
|
||||
self:equalizePressure(dT,"BrakeLinePressure", 1.01*math.min(4.0,self.TrainToBrakeReducedPressure), pr_speed,nil, nil, 1.0)
|
||||
self:equalizePressure(dT,"BrakeLinePressure", 1.01*math.min(4.0,self.TrainToBrakeReducedPressure), pr_speed,pr_speed*0.35, nil, 1.0)
|
||||
end
|
||||
|
||||
-- 013: 5 3.7 Atm
|
||||
if (self.RealDriverValvePosition == 5) and BLDisconnect and (TLDisconnect or self.BrakeLinePressure > 1.01*math.min(3.7,self.TrainToBrakeReducedPressure)) then
|
||||
self:equalizePressure(dT,"BrakeLinePressure", 1.01*math.min(3.7,self.TrainToBrakeReducedPressure), pr_speed,nil, nil, 1.0)
|
||||
self:equalizePressure(dT,"BrakeLinePressure", 1.01*math.min(3.7,self.TrainToBrakeReducedPressure), pr_speed,pr_speed*0.35, nil, 1.0)
|
||||
end
|
||||
|
||||
-- 013: 6 3.0 Atm
|
||||
if (self.RealDriverValvePosition == 6) and BLDisconnect and (TLDisconnect or self.BrakeLinePressure > 1.01*math.min(3.0,self.TrainToBrakeReducedPressure)) then
|
||||
self:equalizePressure(dT,"BrakeLinePressure", 1.01*math.min(3.0,self.TrainToBrakeReducedPressure), pr_speed,nil, nil, 1.0)
|
||||
self:equalizePressure(dT,"BrakeLinePressure", 1.01*math.min(3.0,self.TrainToBrakeReducedPressure), pr_speed,pr_speed*0.35, nil, 1.0)
|
||||
end
|
||||
|
||||
-- 013: 7 0.0 Atm
|
||||
if (self.RealDriverValvePosition == 7) and BLDisconnect then
|
||||
self:equalizePressure(dT,"BrakeLinePressure", 0.0, pr_speed)
|
||||
if (self.RealDriverValvePosition == 7) and BLDisconnect and (TLDisconnect or self.BrakeLinePressure > 0.0) then
|
||||
self:equalizePressure(dT,"BrakeLinePressure", 0.0, 0.6 + pr_speed*math.exp(math.min(0,self.BrakeLinePressure - 2.8)*1.0),pr_speed*0.35, nil, 1.0)
|
||||
end
|
||||
trainLineConsumption_dPdT = trainLineConsumption_dPdT + math.max(0,self.BrakeLinePressure_dPdT)
|
||||
end
|
||||
@@ -415,10 +442,10 @@ function TRAIN_SYSTEM:Think(dT)
|
||||
local epkDiff = math.abs(self.EPKPressure-self.BrakeLinePressure)
|
||||
if BLDisconnect and Train.EPK.Value>0 then
|
||||
if Train.EPKC.Value>0 then
|
||||
self:equalizePressure(dT,"EPKPressure", self.BrakeLinePressure,math.min(1,epkDiff)*6--[[ pr_speed*math.min(1,epkDiff)*2--]] ,false,false,4*epkDiff*2)
|
||||
self:equalizePressure(dT,"EPKPressure", self.BrakeLinePressure,math.min(1,epkDiff)*6--[[ pr_speed*math.min(1,epkDiff)*2--]] ,math.min(1,epkDiff)*26,false,4*epkDiff*2)
|
||||
end
|
||||
if self.EPKPressure<self.BrakeLinePressure and math.abs(self.EPKPressure-self.BrakeLinePressure)>0.3 then
|
||||
leak = self:equalizePressure(dT,"BrakeLinePressure", self.EPKPressure,pr_speed*epkDiff/2,pr_speed*epkDiff/2)
|
||||
leak = self:equalizePressure(dT,"BrakeLinePressure", self.EPKPressure,pr_speed*epkDiff/1.28,pr_speed*epkDiff/1.28)
|
||||
--[[ if self.ValveType==1 then
|
||||
leak = self:equalizePressure(dT,"ReservoirPressure", self.EPKPressure,epkDiff/2,epkDiff/2)
|
||||
end--]]
|
||||
@@ -438,22 +465,23 @@ function TRAIN_SYSTEM:Think(dT)
|
||||
else
|
||||
Train:SetPackedRatio("Crane_dPdT", self.BrakeLinePressure_dPdT/wagc*3 )
|
||||
end
|
||||
if self.EmergencyValveDisable and (self.BrakeLinePressure-self.OldBrakeLinePressure)>0.01 then
|
||||
if self.EmergencyValveDisable then--and (self.BrakeLinePressure-self.OldBrakeLinePressure)>0.01 then
|
||||
self.EmergencyValveDisable=false
|
||||
self.EmergencyValve=false
|
||||
Train.AutoStopNotify=false
|
||||
end
|
||||
self.OldBrakeLinePressure = self.BrakeLinePressure
|
||||
local leak = 0
|
||||
if self.EmergencyValve then
|
||||
local leakst = 1.1*(Train:GetWagonCount())*math.Clamp(self.BrakeLinePressure/4,0,1)
|
||||
leak = self:equalizePressure(dT,"BrakeLinePressure", 0.0,leakst*2,false,false,0.4)
|
||||
if (leak >= -0.2*(Train:GetWagonCount()) or Train.UAVA.Value > 0) then
|
||||
local leakst = BLDisconnect and math.max(0.3,math.log(self.BrakeLinePressure,1.2) - 2.5) or math.max(1.6,math.log(0.63*self.BrakeLinePressure,1.15))
|
||||
leak = self:equalizePressure(dT,"BrakeLinePressure", 0.0,leakst*wagc/6)--,false,false,10)
|
||||
if Train.UAVA.Value > 0 or (self.BrakeLinePressure < 1.8 and Train.AutostopValve.Value == 0) then --пока держим ЛКМ нажатой, срывной клапан открыт
|
||||
self.EmergencyValveDisable = true
|
||||
end
|
||||
self.Leak = true
|
||||
end
|
||||
|
||||
local UAVABlocked = (self.BrakeLinePressure>3.5 and Train.UAVA.Value==0)
|
||||
local UAVABlocked = (self.BrakeLinePressure>1.8 and Train.UAVA.Value==0)
|
||||
if (Train.UAVA.Blocked>0) ~= UAVABlocked then
|
||||
Train.UAVA:TriggerInput("Block",UAVABlocked and 1 or 0)
|
||||
end
|
||||
@@ -463,48 +491,58 @@ function TRAIN_SYSTEM:Think(dT)
|
||||
Train.UAVAC:TriggerInput("Block",UAVACBlocked and 1 or 0)
|
||||
end
|
||||
|
||||
Train:SetPackedRatio("EmergencyValve_dPdT", -leak/wagc)
|
||||
Train:SetPackedRatio("EmergencyValve_dPdT", -1.8*leak/wagc) --Регулировка свиста срывного клапана
|
||||
|
||||
local leak = 0
|
||||
if Train.EmergencyBrakeValve and Train.EmergencyBrakeValve.Value > 0.5 then
|
||||
--local leakst = (1.6*(Train:GetWagonCount())*(self.BrakeLinePressure-math.min(2.5,self.TrainToBrakeReducedPressure))*0.9)
|
||||
leak = self:equalizePressure(dT,"BrakeLinePressure", 0.0,(1.1*wagc)*2,false,false,0.4)
|
||||
leak = self:equalizePressure(dT,"BrakeLinePressure", 0.0,(1.1*wagc)*2,false,false,1)
|
||||
self.Leak = true
|
||||
end
|
||||
Train:SetPackedRatio("EmergencyBrakeValve_dPdT", -leak/wagc)
|
||||
----------------------------------------------------------------------------
|
||||
-- Fill brake cylinders
|
||||
if Train.AirDistributorDisconnect.Value == 0 then
|
||||
if self.WCChargeValve == true then
|
||||
self:equalizePressure(dT,"WorkingChamberPressure",self.BrakeLinePressure,0.107,nil,nil,1.0) --simulate 0.8mm hole btw BL and working chambers
|
||||
end
|
||||
--self.AirDistributorReady = self.WorkingChamberPressure >= 2.2
|
||||
local aird_ready = self.WorkingChamberPressure >= 2.2
|
||||
self.WCChargeValve = not ((self.WorkingChamberPressure - self.BrakeLinePressure) > 0.2 and (self.WorkingChamberPressure - self.BrakeLinePressure) < 2.5)
|
||||
--self.OverchargeReleaseValve = self.WorkingChamberPressure > 5.2 and not self.WCChargeValve
|
||||
local KLSZ = self.WorkingChamberPressure > 5.2 and not self.WCChargeValve
|
||||
if KLSZ then
|
||||
self:equalizePressure(dT,"WorkingChamberPressure",0.0,0.22) -- КЛСЗ
|
||||
end
|
||||
|
||||
--trainLineConsumption_dPdT = trainLineConsumption_dPdT + math.max(0,self.WorkingChamberPressure_dPdT*0.2)
|
||||
local _offset2 = self.Train.AR63 and 2.5 or 2.4
|
||||
self.GN2Offset = self.GN2Offset or math.random(20,100)*0.002 + _offset2
|
||||
local _offset1 = self.Train.AR63 and 0.9 or 0.8
|
||||
self.GN1Offset = self.GN1Offset or math.random(20,100)*0.002 + _offset1
|
||||
self.BcBl = (self.GN2Offset + self.WeightLoadRatio*1.3)/1.93
|
||||
if Train.AirDistributorDisconnect.Value == 0 and aird_ready then
|
||||
-- Valve #1
|
||||
self.BrakeCylinderRegulationError = self.BrakeCylinderRegulationError or (math.random()*0.05 - 0.025)
|
||||
local error = self.BrakeCylinderRegulationError
|
||||
if (Train.PneumaticNo1.Value == 1.0) and (Train.PneumaticNo2.Value == 0.0) then
|
||||
if self.PN1 == 0 then
|
||||
--1,2
|
||||
self.PN1 = math.min(self.TrainLinePressure,(1.1 + error + self.WeightLoadRatio*0.6))
|
||||
if self.PN1 < self.GN1Offset then
|
||||
self.PN1 = math.min(self.TrainLinePressure,self.GN1Offset)
|
||||
end
|
||||
elseif self.PN1 ~= 0 then
|
||||
self.PN1 = 0
|
||||
elseif Train.PneumaticNo1.Value == 0 and self.PN1 > 0.0 then
|
||||
self.PN1 = math.max(0,self.PN1-math.exp(3.6*(self.BrakeCylinderPressure - self.GN1Offset))*1.7*dT)
|
||||
end
|
||||
-- Valve #2
|
||||
if Train.PneumaticNo2.Value == 1.0 then
|
||||
if self.PN2 == 0 then
|
||||
self.PN2 = math.min(self.TrainLinePressure,(2.7 + error + self.WeightLoadRatio*1.3))
|
||||
if self.BePN2 == false and self.BrakeCylinderPressure > 1.6 then
|
||||
Train:PlayOnce("PN2end","stop")
|
||||
end
|
||||
self.BePN2 = true
|
||||
self.PN2 = math.min(self.TrainLinePressure,(self.GN2Offset + self.WeightLoadRatio*1.3))
|
||||
if self.BePN2 == false and self.BrakeCylinderPressure > 1.6 then
|
||||
Train:PlayOnce("PN2end","stop")
|
||||
end
|
||||
elseif self.PN2 ~= 0 then
|
||||
self.PN2 = 0
|
||||
self.BePN2 = true
|
||||
elseif self.PN2 > 0.0 then
|
||||
self.PN2 = self.BrakeCylinderPressure > 0.4 and 0.2 or self.PN2 - 0.5*dT
|
||||
end
|
||||
local targetPres = math.max(0,math.min(5.2,--[[ 1.5--]] 1.35*(math.min(5.1,self.TrainToBrakeReducedPressure) - self.BrakeLinePressure)))
|
||||
if self.BCPressure < targetPres then
|
||||
self.BCPressure = math.min(targetPres,self.BCPressure+(0.5+math.max(0,(targetPres-self.BCPressure)-0.2)*0.6)*dT)
|
||||
elseif self.BCPressure > targetPres then
|
||||
self.BCPressure = math.max(targetPres,self.BCPressure-2*dT)
|
||||
end
|
||||
local targetPressure = self.PN1+self.PN2+self.BCPressure
|
||||
local WcBl = (self.BrakeLinePressure < 3.55 and 0.45*(self.WorkingChamberPressure - 2.2) or self.BrakeLinePressure > 3.65 and self.BrakeLinePressure*(self.BrakeLinePressure > 4.5 and self.BrakeLinePressure_dPdT > 0.02 and 1.06 or 1))
|
||||
--self.cranPres = WcBl and math.max(0,math.min(self.GN2Offset + self.WeightLoadRatio*1.3,self.BcBl*(self.WorkingChamberPressure - WcBl)*(self.BrakeLinePressure > self.KM013offset and 0.6 or 1))) or self.cranPres
|
||||
self.cranPres = WcBl and math.max(0,self.BcBl*(self.WorkingChamberPressure - WcBl)*(self.BrakeLinePressure > self.KM013offset and (0.56 + self.PN1*0.43) or 1)) or self.cranPres
|
||||
local targetPressure = math.max(0,math.min(self.GN2Offset + self.WeightLoadRatio*1.3, (self.cranPres < (self.PN1 + self.WeightLoadRatio*0.7) and (Train.PneumaticNo1.Value == 1.0) and (self.PN1 + self.WeightLoadRatio*0.7) or self.PN1) + self.PN2 + self.cranPres))
|
||||
if math.abs(self.BrakeCylinderPressure - targetPressure) > 0.150 then
|
||||
self.BrakeCylinderValve = 1
|
||||
end
|
||||
@@ -512,11 +550,13 @@ function TRAIN_SYSTEM:Think(dT)
|
||||
self.BrakeCylinderValve = 0
|
||||
end
|
||||
if self.BrakeCylinderValve == 1 then
|
||||
self:equalizePressure(dT,"BrakeCylinderPressure", math.min(2.7 + self.WeightLoadRatio*1.3,targetPressure), 1+math.Clamp((self.BrakeCylinderPressure-0.5)/2.8,0,0.7), 3.50, nil, 0.8+math.Clamp((self.BrakeCylinderPressure-0.75)/0.6,0,1)) --0.75, 1.25)
|
||||
--self:equalizePressure(dT,"BrakeCylinderPressure", math.min(self.GN2Offset + self.WeightLoadRatio*1.3,targetPressure), 1, 3.5, nil, (self.BrakeLinePressure_dPdT > 0.02) and (0.9+math.Clamp((1 - self.BrakeCylinderPressure)*0.9,0,1.8)) or 1)
|
||||
self:equalizePressure(dT,"BrakeCylinderPressure", math.min(self.GN2Offset + self.WeightLoadRatio*1.3,targetPressure), 1, 3.5, nil, 1)
|
||||
end
|
||||
trainLineConsumption_dPdT = trainLineConsumption_dPdT + math.max(0,self.BrakeCylinderPressure_dPdT*0.5)
|
||||
else
|
||||
elseif Train.AirDistributorDisconnect.Value ~= 0 then
|
||||
self:equalizePressure(dT,"BrakeCylinderPressure", 0.0, 2.00)
|
||||
self:equalizePressure(dT,"WorkingChamberPressure", 0.0, 2.00) --имитируем потягивание за тросик отпускного клапана
|
||||
end
|
||||
if (self.BrakeCylinderPressure > 0.2 and self.BrakeCylinderPressure_dPdT > 0.1 or self.BrakeCylinderPressure_dPdT > 1) and not self.BrakeEngaged then
|
||||
self.BrakeEngaged = true
|
||||
@@ -562,7 +602,7 @@ function TRAIN_SYSTEM:Think(dT)
|
||||
-- Overpressure
|
||||
if self.TrainLinePressure > 9.2 then self.TrainLineOverpressureValve = 1 end
|
||||
if self.TrainLineOverpressureValve == 1 then
|
||||
self:equalizePressure(dT,"TrainLinePressure", 0.0, 0.2)
|
||||
self:equalizePressure(dT,"TrainLinePressure", 0.0, (self.TrainLinePressure-(self.Compressor == 1 and 6.5 or 4))*0.6) --was 0.2
|
||||
self.TrainLineOpen = true
|
||||
if self.TrainLinePressure < 5.2 then self.TrainLineOverpressureValve = 0 end
|
||||
end
|
||||
|
||||
@@ -57,7 +57,6 @@ end
|
||||
function TRAIN_SYSTEM:Think(dT)
|
||||
local Train = self.Train
|
||||
local speed = Train.ALSCoil.Speed
|
||||
|
||||
--vv При торможении смещение на 2км\ч vv
|
||||
----[[
|
||||
if self.SpeedDec then
|
||||
|
||||
@@ -93,13 +93,14 @@ function TRAIN_SYSTEM:Think()
|
||||
end
|
||||
--self.RUTTarget = 250 + 150*self.Train.Pneumatic.WeightLoadRatio
|
||||
-- RPvozvrat operation
|
||||
Train.RPvozvrat:TriggerInput("Close",
|
||||
(Train.DR1.Value == 1.0) or
|
||||
--local A = Train.RPvozvrat.VozRpPressed ~= 0
|
||||
Train.RPvozvrat:TriggerInput("Close", Train:ReadTrainWire(17) == 0 and -- condition added to override the blocking action of the energized RP relays on RPVozvrat
|
||||
((Train.DR1.Value == 1.0) or
|
||||
(Train.DR2.Value == 1.0) or
|
||||
(Train.RPL.Value == 1.0) or
|
||||
(Train.RP1_3.Value == 1.0) or
|
||||
(Train.RP2_4.Value == 1.0) or
|
||||
(Train.RZ_1.Value == 1.0) or
|
||||
(Train.RZ_2.Value == 1.0) or
|
||||
(Train.RZ_3.Value == 1.0))
|
||||
(Train.RZ_3.Value == 1.0)))
|
||||
end
|
||||
|
||||
@@ -15,7 +15,7 @@ function TRAIN_SYSTEM:Initialize(parameters)
|
||||
self.Train:LoadSystem("RV3","Relay","REV-813T",{ open_time = 2.3 })
|
||||
-- Реле тока (РТ2)
|
||||
self.Train:LoadSystem("RT2","Relay","REV-830",{ trigger_level = 130 }) -- A
|
||||
self.Train:LoadSystem("RT2r","Relay","REV-830",{ close_time = 0, open_time = 0.2 }) --UNREALISTIC Repeater for RT2 for MSK trains
|
||||
self.Train:LoadSystem("RT2r","Relay","REV-830",{ close_time = 0, open_time = 0.6 }) --UNREALISTIC Repeater for RT2 for MSK trains
|
||||
-- Реле контроля тормозного тока (РКТТ)
|
||||
self.Train:LoadSystem("RKTT","Relay","R-52B")
|
||||
self.Train.RKTTsh = 1
|
||||
|
||||
Reference in New Issue
Block a user