1
0
mirror of https://github.com/metrostroi-repo/MetrostroiAddon.git synced 2026-05-02 00:42:29 +00:00
Перенос логики кнопок дверей в Panel для электрики
Триггеры для БМЦИКа от БУКП
Поправлена логика 15 провода
Фикс работы дверей от резервного управления
This commit is contained in:
kosmik641
2023-02-23 23:40:42 +03:00
parent 86e009748b
commit c06ccbe776
4 changed files with 63 additions and 26 deletions

View File

@@ -72,6 +72,7 @@ function TRAIN_SYSTEM:CStateTarget(name,targetname,targetsys,targetid,value)
end end
function TRAIN_SYSTEM:Think(dT) function TRAIN_SYSTEM:Think(dT)
local Train = self.Train local Train = self.Train
local Panel = Train.Panel
local Electric = Train.Electric local Electric = Train.Electric
local BUKV = Train.BUKV local BUKV = Train.BUKV
self.Power = Train.SF19.Value*Train.Electric.Power self.Power = Train.SF19.Value*Train.Electric.Power
@@ -194,6 +195,7 @@ function TRAIN_SYSTEM:Think(dT)
local RR = Train.KRO.Value~=1 local RR = Train.KRO.Value~=1
if self.Prepared==true and Electric.CabActive>0 and Electric.Emer == 0 then if self.Prepared==true and Electric.CabActive>0 and Electric.Emer == 0 then
local MFDU = Train.MFDU local MFDU = Train.MFDU
local BMCIK = Train.BMCIK
local TrainCount = #self.Trains local TrainCount = #self.Trains
local TrainCHalf = TrainCount/2 local TrainCHalf = TrainCount/2
if not self.PVU.Sync then if not self.PVU.Sync then
@@ -325,7 +327,11 @@ function TRAIN_SYSTEM:Think(dT)
else else
self.PowerCommand = 0 self.PowerCommand = 0
end end
self.DoorsClosed = Train.Electric.LSD>0 and self.LSD and (self.DoorsClosed or pos<=0) 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 (pos>0 or MFDU:ErrorGet("64_1")))
--MFDU:Error(64,1,Train.Electric.LSD==0 and self.States.CloseDoors,4) --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"))) MFDU:Error(5,1,not self.LSD and self.States.CloseDoors and (pos>0 or MFDU:ErrorGet("5_1")))
@@ -358,11 +364,18 @@ function TRAIN_SYSTEM:Think(dT)
self:CState("Brake",self.PowerCommand < 0 or Command~=nil) self:CState("Brake",self.PowerCommand < 0 or Command~=nil)
self:CState("ARSBrake",Train.BARS.T1 > 0) self:CState("ARSBrake",Train.BARS.T1 > 0)
--Door controls --Door controls
self.DoorLeft = (RR and Train.DoorSelect.Value==0 and Train.DoorClose.Value==1 and self.Speed<3) and 1 or 0 local allowOpenDoors = RR and Panel.DoorClose==0 and Panel.DoorCloseAVT==0 and self.Speed<3
self.DoorRight = (RR and Train.DoorSelect.Value==1 and Train.DoorClose.Value==1 and self.Speed<3) and 1 or 0 self.DoorLeft = (allowOpenDoors and Panel.DoorSelect==0) 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.DoorRight = (allowOpenDoors and Panel.DoorSelect==1) and 1 or 0
self.OpenLeft = not self.States.CloseDoors and (Train.DoorLeft1.Value > 0 or Train.DoorLeft2.Value > 0) and self.DoorLeft > 0 MFDU:Error(61,1,(Panel.DoorLeft1 > 0 or Panel.DoorLeft2 > 0) and self.DoorLeft == 0 or Panel.DoorRight > 0 and self.DoorRight == 0)
self.OpenRight = not self.States.CloseDoors and Train.DoorRight.Value > 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("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)) 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 if MFDU:ErrorGet("49_1") and MFDU:ErrorGet("49_1")[4] then
@@ -374,17 +387,21 @@ function TRAIN_SYSTEM:Think(dT)
else else
self.BackDoors = nil self.BackDoors = nil
end 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) 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 if self.CloseDoorsDelay then
if self.DoorsClosed or (Panel.DoorCloseAVT==0 and (self.OpenLeft or self.OpenRight)) then
self.CloseDoorsDelay = nil 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)
end end
self:CState("CloseDoors",RR and Train.SF7.Value>0 and (Train.DoorClose.Value == 0 or self.CloseDoorsDelay and CurTime()>self.CloseDoorsDelay)) 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 (Panel.DoorClose>0 or self.CloseDoorsDelay and CurTime()>self.CloseDoorsDelay))
self:CState("PassLight",Train.PassLight.Value>0) self:CState("PassLight",Train.PassLight.Value>0)
self:CState("PassVent",Train.PassVent.Value-1) 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 if BARSPower and Train.BARS.V2 > 0 or not BARSPower and math.abs(self.Speed) < 0.5 and self.PowerCommand < 0 then

View File

@@ -169,10 +169,16 @@ function TRAIN_SYSTEM:Think(dT)
Train:WriteTrainWire(24,BTB*S["NEmergencyBrake"]) Train:WriteTrainWire(24,BTB*S["NEmergencyBrake"])
Train:WriteTrainWire(25,BTB*self.BTB*(self.KTR==3 and 0 or 1)) 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) Panel.DoorLeft1 = Train.DoorLeft1.Value*Train.SF7.Value
Train:WriteTrainWire(38,(S["RU"]+Train.BUKP.DoorLeft)*Train.SF7.Value*(Train.DoorLeft1.Value+Train.DoorLeft2.Value)) Panel.DoorLeft2 = Train.DoorLeft2.Value*Train.SF7.Value
Train:WriteTrainWire(39,S["RU"]*Train.SF7.Value*C(Train.DoorClose.Value==0)) 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.BattOn = BO
Panel.BattOff = BO*Train.BatteryOff.Value 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.ALSPower = BO*(1-Train.BUKP.Back)*Train.ALS.Value
Panel.UPOPower = BO*S["RV"]*Train.BMCIK.UPOActive 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"] self.Emer = S["RU"]
end end

View File

@@ -135,9 +135,13 @@ function TRAIN_SYSTEM:Initialize()
self.EmergencyDriveL = 0 self.EmergencyDriveL = 0
self.EmergencyBrakeTPlusL = 0 self.EmergencyBrakeTPlusL = 0
self.DoorLeftL = 0 self.DoorLeft1 = 0
self.DoorRightL = 0 self.DoorLeft2 = 0
self.MFDUPowerL = 0 self.DoorRight = 0
self.DoorClose = 0
self.DoorCloseAVT = 0
self.DoorSelect = 0
self.DoorBack = 0
self.CabLights = 0 self.CabLights = 0
self.PanelLights = 0 self.PanelLights = 0
@@ -177,7 +181,7 @@ function TRAIN_SYSTEM:Inputs()
end end
function TRAIN_SYSTEM:Outputs() 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 end
--if not TURBOSTROI then return end --if not TURBOSTROI then return end
function TRAIN_SYSTEM:TriggerInput(name,value) function TRAIN_SYSTEM:TriggerInput(name,value)

View File

@@ -526,9 +526,19 @@ function TRAIN_SYSTEM:Think(dT)
self.DoorLeft = false self.DoorLeft = false
self.DoorRight = false self.DoorRight = false
end--]] 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 commandLeft,commandRight,commandClose
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 if Train:ReadTrainWire(34) > 0 then
local commandClose = Train.BUKV.CloseDoors and Train.SF43.Value > 0 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 if commandClose or commandLeft and commandRight then
self.DoorLeft = false self.DoorLeft = false
self.DoorRight = false self.DoorRight = false