From c06ccbe776460812d7bac3b20afc931edc21ffd1 Mon Sep 17 00:00:00 2001 From: kosmik641 Date: Thu, 23 Feb 2023 23:40:42 +0300 Subject: [PATCH] =?UTF-8?q?81-722.=20=D0=9F=D0=B5=D1=80=D0=B5=D0=BD=D0=BE?= =?UTF-8?q?=D1=81=20=D0=BB=D0=BE=D0=B3=D0=B8=D0=BA=D0=B8=20=D0=BA=D0=BD?= =?UTF-8?q?=D0=BE=D0=BF=D0=BE=D0=BA=20=D0=B4=D0=B2=D0=B5=D1=80=D0=B5=D0=B9?= =?UTF-8?q?=20=D0=B2=20Panel=20=D0=B4=D0=BB=D1=8F=20=D1=8D=D0=BB=D0=B5?= =?UTF-8?q?=D0=BA=D1=82=D1=80=D0=B8=D0=BA=D0=B8=20=D0=A2=D1=80=D0=B8=D0=B3?= =?UTF-8?q?=D0=B3=D0=B5=D1=80=D1=8B=20=D0=B4=D0=BB=D1=8F=20=D0=91=D0=9C?= =?UTF-8?q?=D0=A6=D0=98=D0=9A=D0=B0=20=D0=BE=D1=82=20=D0=91=D0=A3=D0=9A?= =?UTF-8?q?=D0=9F=20=D0=9F=D0=BE=D0=BF=D1=80=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD?= =?UTF-8?q?=D0=B0=20=D0=BB=D0=BE=D0=B3=D0=B8=D0=BA=D0=B0=2015=20=D0=BF?= =?UTF-8?q?=D1=80=D0=BE=D0=B2=D0=BE=D0=B4=D0=B0=20=D0=A4=D0=B8=D0=BA=D1=81?= =?UTF-8?q?=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D1=8B=20=D0=B4=D0=B2=D0=B5?= =?UTF-8?q?=D1=80=D0=B5=D0=B9=20=D0=BE=D1=82=20=D1=80=D0=B5=D0=B7=D0=B5?= =?UTF-8?q?=D1=80=D0=B2=D0=BD=D0=BE=D0=B3=D0=BE=20=D1=83=D0=BF=D1=80=D0=B0?= =?UTF-8?q?=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/metrostroi/systems/sys_81_722_bukp.lua | 45 +++++++++++++------ .../systems/sys_81_722_electric.lua | 16 ++++--- lua/metrostroi/systems/sys_81_722_panel.lua | 12 +++-- .../systems/sys_81_722_pneumatic.lua | 16 +++++-- 4 files changed, 63 insertions(+), 26 deletions(-) diff --git a/lua/metrostroi/systems/sys_81_722_bukp.lua b/lua/metrostroi/systems/sys_81_722_bukp.lua index 4cd545e..1ab89e1 100644 --- a/lua/metrostroi/systems/sys_81_722_bukp.lua +++ b/lua/metrostroi/systems/sys_81_722_bukp.lua @@ -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 diff --git a/lua/metrostroi/systems/sys_81_722_electric.lua b/lua/metrostroi/systems/sys_81_722_electric.lua index 7d797fb..aaf23e3 100644 --- a/lua/metrostroi/systems/sys_81_722_electric.lua +++ b/lua/metrostroi/systems/sys_81_722_electric.lua @@ -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 diff --git a/lua/metrostroi/systems/sys_81_722_panel.lua b/lua/metrostroi/systems/sys_81_722_panel.lua index 343cdbc..beabbfb 100644 --- a/lua/metrostroi/systems/sys_81_722_panel.lua +++ b/lua/metrostroi/systems/sys_81_722_panel.lua @@ -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) diff --git a/lua/metrostroi/systems/sys_81_722_pneumatic.lua b/lua/metrostroi/systems/sys_81_722_pneumatic.lua index 11a6c3b..8dcc6ff 100644 --- a/lua/metrostroi/systems/sys_81_722_pneumatic.lua +++ b/lua/metrostroi/systems/sys_81_722_pneumatic.lua @@ -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