mirror of
https://github.com/metrostroi-repo/MetrostroiAddon.git
synced 2026-05-02 00:42:29 +00:00
81-722.
Перенос логики кнопок дверей в Panel для электрики Триггеры для БМЦИКа от БУКП Поправлена логика 15 провода Фикс работы дверей от резервного управления
This commit is contained in:
@@ -72,6 +72,7 @@ function TRAIN_SYSTEM:CStateTarget(name,targetname,targetsys,targetid,value)
|
||||
end
|
||||
function TRAIN_SYSTEM:Think(dT)
|
||||
local Train = self.Train
|
||||
local Panel = Train.Panel
|
||||
local Electric = Train.Electric
|
||||
local BUKV = Train.BUKV
|
||||
self.Power = Train.SF19.Value*Train.Electric.Power
|
||||
@@ -194,6 +195,7 @@ function TRAIN_SYSTEM:Think(dT)
|
||||
local RR = Train.KRO.Value~=1
|
||||
if self.Prepared==true and Electric.CabActive>0 and Electric.Emer == 0 then
|
||||
local MFDU = Train.MFDU
|
||||
local BMCIK = Train.BMCIK
|
||||
local TrainCount = #self.Trains
|
||||
local TrainCHalf = TrainCount/2
|
||||
if not self.PVU.Sync then
|
||||
@@ -325,7 +327,11 @@ function TRAIN_SYSTEM:Think(dT)
|
||||
else
|
||||
self.PowerCommand = 0
|
||||
end
|
||||
|
||||
self.DoorsClosed = Train.Electric.LSD>0 and self.LSD and (self.DoorsClosed or pos<=0)
|
||||
if (self.LSD and self.DoorsClosed ~= self.LSD) then
|
||||
BMCIK:TriggerInput("ClosedDoors")
|
||||
end
|
||||
MFDU:Error(64,1,Train.Electric.LSD==0 and (pos>0 or MFDU:ErrorGet("64_1")))
|
||||
--MFDU:Error(64,1,Train.Electric.LSD==0 and self.States.CloseDoors,4)
|
||||
MFDU:Error(5,1,not self.LSD and self.States.CloseDoors and (pos>0 or MFDU:ErrorGet("5_1")))
|
||||
@@ -338,7 +344,7 @@ function TRAIN_SYSTEM:Think(dT)
|
||||
end
|
||||
if not RR or back or Train.BKCU.Emergency>0 then
|
||||
self.PowerCommand = 0
|
||||
elseif self.PowerCommand>0 and (not self.DoorsClosed and Train.VAD.Value==0 or Train.BARS.MOT==0 and Train.RCARS.Value>0 or Train.RCARS.Value==0 and Train.PB.Value==0 and Train.VAH.Value==0 or self.Blocked) --[[or fault]] then
|
||||
elseif self.PowerCommand>0 and (not self.DoorsClosed and Train.VAD.Value==0 or Train.BARS.MOT==0 and Train.RCARS.Value>0 or Train.RCARS.Value==0 and Train.PB.Value==0 and Train.VAH.Value==0 or self.Blocked) --[[or fault]] then
|
||||
self.PowerCommand = 0
|
||||
self.Blocked = true
|
||||
else
|
||||
@@ -358,11 +364,18 @@ function TRAIN_SYSTEM:Think(dT)
|
||||
self:CState("Brake",self.PowerCommand < 0 or Command~=nil)
|
||||
self:CState("ARSBrake",Train.BARS.T1 > 0)
|
||||
--Door controls
|
||||
self.DoorLeft = (RR and Train.DoorSelect.Value==0 and Train.DoorClose.Value==1 and self.Speed<3) and 1 or 0
|
||||
self.DoorRight = (RR and Train.DoorSelect.Value==1 and Train.DoorClose.Value==1 and self.Speed<3) and 1 or 0
|
||||
MFDU:Error(61,1,(Train.DoorLeft1.Value > 0 or Train.DoorLeft2.Value > 0) and self.DoorLeft == 0 or Train.DoorRight.Value > 0 and self.DoorRight == 0)
|
||||
self.OpenLeft = not self.States.CloseDoors and (Train.DoorLeft1.Value > 0 or Train.DoorLeft2.Value > 0) and self.DoorLeft > 0
|
||||
self.OpenRight = not self.States.CloseDoors and Train.DoorRight.Value > 0 and self.DoorRight > 0
|
||||
local allowOpenDoors = RR and Panel.DoorClose==0 and Panel.DoorCloseAVT==0 and self.Speed<3
|
||||
self.DoorLeft = (allowOpenDoors and Panel.DoorSelect==0) and 1 or 0
|
||||
self.DoorRight = (allowOpenDoors and Panel.DoorSelect==1) and 1 or 0
|
||||
MFDU:Error(61,1,(Panel.DoorLeft1 > 0 or Panel.DoorLeft2 > 0) and self.DoorLeft == 0 or Panel.DoorRight > 0 and self.DoorRight == 0)
|
||||
local openLeft,openRight = self.OpenLeft,self.OpenRight
|
||||
self.OpenLeft = (Panel.DoorLeft1 > 0 or Panel.DoorLeft2 > 0) and self.DoorLeft > 0
|
||||
self.OpenRight = Panel.DoorRight > 0 and self.DoorRight > 0
|
||||
|
||||
if (self.OpenLeft and openLeft ~= self.OpenLeft) or (self.OpenRight and openRight ~= self.OpenRight) then
|
||||
BMCIK:TriggerInput("OpenDoors",self.OpenRight and 0x52 or 0x4C) -- 'L', 'R'
|
||||
end
|
||||
|
||||
self:CState("OpenLeft",not self.States.CloseDoors and (self.States.OpenLeft or self.OpenLeft))
|
||||
self:CState("OpenRight",not self.States.CloseDoors and (self.States.OpenRight or self.OpenRight))
|
||||
if MFDU:ErrorGet("49_1") and MFDU:ErrorGet("49_1")[4] then
|
||||
@@ -374,17 +387,21 @@ function TRAIN_SYSTEM:Think(dT)
|
||||
else
|
||||
self.BackDoors = nil
|
||||
end
|
||||
MFDU:Error(49,1,(Train.DoorBack.Value>0 and Train.DoorSelect.Value==1 or MFDU:ErrorGet("49_1") and self.BackDoors~=nil) and not self.States.CloseDoors)
|
||||
MFDU:Error(49,1,(Panel.DoorBack>0 and Panel.DoorSelect==1 or MFDU:ErrorGet("49_1") and self.BackDoors~=nil) and not self.States.CloseDoors)
|
||||
Train:CANWrite("BUKP",Train:GetWagonNumber(),"BUKV",self.Trains[#self.Trains].ID,"OpenRightBack",self.BackDoors and self.BackDoors~=true)
|
||||
|
||||
if self.CloseDoorsDelay and Train.DoorClose.Value~=2 and (Train.DoorLeft1.Value > 0 or Train.DoorLeft2.Value > 0 or Train.DoorRight.Value > 0 or self.LSD) then
|
||||
self.CloseDoorsDelay = nil
|
||||
Train.BMCIK:TriggerInput("CloseDoorsAVT",false)
|
||||
elseif not self.CloseDoorsDelay and Train.DoorClose.Value==2 and not self.LSD then
|
||||
self.CloseDoorsDelay = CurTime()+4
|
||||
Train.BMCIK:TriggerInput("CloseDoorsAVT",true)
|
||||
if self.CloseDoorsDelay then
|
||||
if self.DoorsClosed or (Panel.DoorCloseAVT==0 and (self.OpenLeft or self.OpenRight)) then
|
||||
self.CloseDoorsDelay = nil
|
||||
end
|
||||
else
|
||||
if RR and Panel.DoorCloseAVT>0 and not self.DoorsClosed then
|
||||
self.CloseDoorsDelay = CurTime()+4
|
||||
BMCIK:TriggerInput("CloseDoorsAVT")
|
||||
end
|
||||
end
|
||||
self:CState("CloseDoors",RR and Train.SF7.Value>0 and (Train.DoorClose.Value == 0 or self.CloseDoorsDelay and CurTime()>self.CloseDoorsDelay))
|
||||
|
||||
self:CState("CloseDoors",RR and (Panel.DoorClose>0 or self.CloseDoorsDelay and CurTime()>self.CloseDoorsDelay))
|
||||
self:CState("PassLight",Train.PassLight.Value>0)
|
||||
self:CState("PassVent",Train.PassVent.Value-1)
|
||||
if BARSPower and Train.BARS.V2 > 0 or not BARSPower and math.abs(self.Speed) < 0.5 and self.PowerCommand < 0 then
|
||||
|
||||
@@ -169,10 +169,16 @@ function TRAIN_SYSTEM:Think(dT)
|
||||
Train:WriteTrainWire(24,BTB*S["NEmergencyBrake"])
|
||||
Train:WriteTrainWire(25,BTB*self.BTB*(self.KTR==3 and 0 or 1))
|
||||
|
||||
Train:WriteTrainWire(37,(S["RU"]+Train.BUKP.DoorRight)*Train.SF7.Value*Train.DoorRight.Value)
|
||||
Train:WriteTrainWire(38,(S["RU"]+Train.BUKP.DoorLeft)*Train.SF7.Value*(Train.DoorLeft1.Value+Train.DoorLeft2.Value))
|
||||
Train:WriteTrainWire(39,S["RU"]*Train.SF7.Value*C(Train.DoorClose.Value==0))
|
||||
|
||||
Panel.DoorLeft1 = Train.DoorLeft1.Value*Train.SF7.Value
|
||||
Panel.DoorLeft2 = Train.DoorLeft2.Value*Train.SF7.Value
|
||||
Panel.DoorRight = Train.DoorRight.Value*Train.SF7.Value
|
||||
Panel.DoorClose = C(Train.DoorClose.Value==0)*Train.SF7.Value
|
||||
Panel.DoorCloseAVT = C(Train.DoorClose.Value==2)*Train.SF7.Value
|
||||
Panel.DoorSelect = Train.DoorSelect.Value*Train.SF7.Value
|
||||
Panel.DoorBack = Train.DoorBack.Value*Train.SF7.Value
|
||||
Train:WriteTrainWire(37,(S["RU"]+Train.BUKP.DoorRight)*Panel.DoorRight)
|
||||
Train:WriteTrainWire(38,(S["RU"]+Train.BUKP.DoorLeft)*(Panel.DoorLeft1+Panel.DoorLeft2))
|
||||
Train:WriteTrainWire(39,S["RU"]*C(Panel.DoorClose==0)*C(Panel.DoorCloseAVT==0))
|
||||
|
||||
Panel.BattOn = BO
|
||||
Panel.BattOff = BO*Train.BatteryOff.Value
|
||||
@@ -193,7 +199,7 @@ function TRAIN_SYSTEM:Think(dT)
|
||||
Panel.ALSPower = BO*(1-Train.BUKP.Back)*Train.ALS.Value
|
||||
|
||||
Panel.UPOPower = BO*S["RV"]*Train.BMCIK.UPOActive
|
||||
Train:WriteTrainWire(15,BO*(Train.BMCIK.LineOut + Train.BMCIK.LineOut))
|
||||
Train:WriteTrainWire(15,BO*(Train.BMCIK.LineOut + Train.UPO.LineOut))
|
||||
|
||||
self.Emer = S["RU"]
|
||||
end
|
||||
|
||||
@@ -135,9 +135,13 @@ function TRAIN_SYSTEM:Initialize()
|
||||
self.EmergencyDriveL = 0
|
||||
self.EmergencyBrakeTPlusL = 0
|
||||
|
||||
self.DoorLeftL = 0
|
||||
self.DoorRightL = 0
|
||||
self.MFDUPowerL = 0
|
||||
self.DoorLeft1 = 0
|
||||
self.DoorLeft2 = 0
|
||||
self.DoorRight = 0
|
||||
self.DoorClose = 0
|
||||
self.DoorCloseAVT = 0
|
||||
self.DoorSelect = 0
|
||||
self.DoorBack = 0
|
||||
|
||||
self.CabLights = 0
|
||||
self.PanelLights = 0
|
||||
@@ -177,7 +181,7 @@ function TRAIN_SYSTEM:Inputs()
|
||||
end
|
||||
|
||||
function TRAIN_SYSTEM:Outputs()
|
||||
return { "Controller","BattOn","BattOff","SOSDL","RS","AVS","LRU","EmergencyDriveL","EmergencyBrakeTPlusL","DoorLeftL","DoorRightL","MFDUPowerL","CabLights","PanelLights","Headlights1","Headlights2","RedLights","EmergencyLights","MainLights", "V4","SOSD","UPOPower","AnnouncerPlaying", "PassSchemePowerL", "PassSchemePowerR","DoorsW","BrW","GRP","RC","VPR1","VPR2","BARSPower","ARSPower","ALSPower"}
|
||||
return { "Controller","BattOn","BattOff","SOSDL","RS","AVS","LRU","EmergencyDriveL","EmergencyBrakeTPlusL","DoorLeft1","DoorLeft2","DoorRight","DoorClose","DoorCloseAVT","DoorSelect","DoorBack","CabLights","PanelLights","Headlights1","Headlights2","RedLights","EmergencyLights","MainLights", "V4","SOSD","UPOPower","AnnouncerPlaying", "PassSchemePowerL", "PassSchemePowerR","DoorsW","BrW","GRP","RC","VPR1","VPR2","BARSPower","ARSPower","ALSPower"}
|
||||
end
|
||||
--if not TURBOSTROI then return end
|
||||
function TRAIN_SYSTEM:TriggerInput(name,value)
|
||||
|
||||
@@ -526,9 +526,19 @@ function TRAIN_SYSTEM:Think(dT)
|
||||
self.DoorLeft = false
|
||||
self.DoorRight = false
|
||||
end--]]
|
||||
local commandLeft = (Train:ReadTrainWire(34) > 0 or Train.BUKV.OpenLeft) and (Train:ReadTrainWire(38) > 0 or Train:ReadTrainWire(39) > 0) and Train.SF41.Value > 0
|
||||
local commandRight = (Train.BUKV.OpenRightBack or (Train:ReadTrainWire(34) > 0 or Train.BUKV.OpenRight) and (Train:ReadTrainWire(37) > 0 or Train:ReadTrainWire(39) > 0)) and Train.SF42.Value > 0
|
||||
local commandClose = Train.BUKV.CloseDoors and Train.SF43.Value > 0
|
||||
local commandLeft,commandRight,commandClose
|
||||
if Train:ReadTrainWire(34) > 0 then
|
||||
commandLeft = Train:ReadTrainWire(38) > 0
|
||||
commandRight = Train:ReadTrainWire(37) > 0
|
||||
commandClose = Train:ReadTrainWire(39) < 1
|
||||
else
|
||||
commandLeft = Train.BUKV.OpenLeft
|
||||
commandRight = Train.BUKV.OpenRight or Train.BUKV.OpenRightBack
|
||||
commandClose = Train.BUKV.CloseDoors
|
||||
end
|
||||
commandLeft = commandLeft and Train.SF41.Value > 0
|
||||
commandRight = commandRight and Train.SF42.Value > 0
|
||||
commandClose = commandClose and Train.SF43.Value > 0
|
||||
if commandClose or commandLeft and commandRight then
|
||||
self.DoorLeft = false
|
||||
self.DoorRight = false
|
||||
|
||||
Reference in New Issue
Block a user