From e9cc545f73215b40d5c147d8ef1a5eda9cf1ba0f Mon Sep 17 00:00:00 2001 From: Moon Horse Date: Sat, 27 Apr 2024 11:00:16 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=BE=D1=87=D1=82=D0=B8=20=D0=B2=D1=81?= =?UTF-8?q?=D0=B5=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=D0=B5=D1=82,=20?= =?UTF-8?q?=D0=BA=D1=80=D0=BE=D0=BC=D0=B5=20=D0=BA=D0=BE=D0=BD=D1=82=D1=80?= =?UTF-8?q?=D0=BE=D0=BB=D1=8F=20=D0=B4=D0=B2=D0=B5=D1=80=D0=B5=D0=B9=20?= =?UTF-8?q?=D0=BF=D1=80=D0=B8=20=D1=81=D0=B1=D0=BE=D1=80=D0=B5=20=D0=BD?= =?UTF-8?q?=D0=B0=20=D1=85=D0=BE=D0=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/entities/gmod_subway_81-717_mvm/init.lua | 11 +- .../systems/sys_81_714_electric.lua | 6 +- .../systems/sys_81_717_electric.lua | 7 +- .../systems/sys_81_717_pneumatic.lua | 10 +- lua/metrostroi/systems/sys_als_ars_dnepr.lua | 24 ++-- lua/metrostroi/systems/sys_battery.lua | 22 +++- lua/metrostroi/systems/sys_pr_14x_panels.lua | 18 +-- lua/metrostroi/systems/sys_relay.lua | 103 +++++++----------- lua/metrostroi/systems/sys_yar_13b.lua | 29 ++--- lua/metrostroi/systems/sys_yar_27.lua | 10 +- 10 files changed, 118 insertions(+), 122 deletions(-) diff --git a/lua/entities/gmod_subway_81-717_mvm/init.lua b/lua/entities/gmod_subway_81-717_mvm/init.lua index 6ac28d1..885764f 100644 --- a/lua/entities/gmod_subway_81-717_mvm/init.lua +++ b/lua/entities/gmod_subway_81-717_mvm/init.lua @@ -27,6 +27,7 @@ ENT.SyncFunctions = { "" } function ENT:Initialize() + self.consLogged = 0 self.Plombs = { VAH = true, VP = true, @@ -391,7 +392,9 @@ function ENT:TrainSpawnerUpdate() for k,v in ipairs(self.WagonList) do if v.AR63 and v.ComputerCar then ccc = ccc + 1; break end end - if ccc == 0 then self.ComputerCar = true end + if ccc == 0 then + self.ComputerCar = true + end math.randomseed(num+817171) if self.CustomSettings then --{"Type","Spawner.717.Type","List",{"Spawner.717.Type.717","Spawner.717.Type.7175"}}, @@ -559,7 +562,6 @@ function ENT:TrainSpawnerUpdate() end self.Pneumatic.VDLoud = math.random()<0.06 and 0.9+math.random()*0.2 if self.Pneumatic.VDLoud then self.Pneumatic.VDLoudID = math.random(1,5) end - print("KD.trigger_level = "..tostring(self.KD.trigger_level)) self:SetNW2Bool("SecondKV",math.random()>0.7) math.randomseed(os.time()) end @@ -567,7 +569,10 @@ end -------------------------------------------------------------------------------- function ENT:Think() self.RetVal = self.BaseClass.Think(self) - + --[[if self.Battery.Consumers[self.RD] then + print("RD.pickup_current = "..tostring(self.RD.pickup_current),"RD current = "..self.Battery.Consumers[self.RD][3]) + end]] + --print("Entity RD = ",self.RD.Value) local Panel = self.Panel local Pneumatic = self.Pneumatic local power = Panel.V1 > -1.5 diff --git a/lua/metrostroi/systems/sys_81_714_electric.lua b/lua/metrostroi/systems/sys_81_714_electric.lua index a85a7cf..ce168ea 100644 --- a/lua/metrostroi/systems/sys_81_714_electric.lua +++ b/lua/metrostroi/systems/sys_81_714_electric.lua @@ -61,7 +61,7 @@ function TRAIN_SYSTEM:SolveAllInternalCircuits(Train,dT,firstIter) local RK = RheostatController.SelectedPosition --local B = (Train.Battery.Voltage >= 60) and 1 or (Train.Battery.Voltage >= Train.Battery.CutoffVoltage) and 0.5 or 0 --local B = linearity*(Train.Battery.Voltage - Train.Battery.CutoffVoltage)/(Train.Battery.StartVoltage - Train.Battery.CutoffVoltage) - local B = math.min(1,(Train.Battery.CCcurrent_sigma - Train.PowerSupply.car_control_load + Train.Battery.Ibatt_sigma)*-1/80) + local B = Train.Battery.Voltage > Train.Battery.CutoffVoltage and 1 or 0 local BO = B*Train.VB.Value*(1-Train.PA1.Value) local BO2 = B*Train.VB.Value*(1-Train.PA2.Value) local T = Train.SolverTemporaryVariables @@ -344,9 +344,7 @@ function TRAIN_SYSTEM:SolveRKInternalCircuits(Train,dT,firstIter) local P = Train.PositionSwitch local RheostatController = Train.RheostatController local RK = RheostatController.SelectedPosition - --local B = (Train.Battery.Voltage >= 60) and 1 or (Train.Battery.Voltage >= Train.Battery.CutoffVoltage) and 0.5 or 0 - --local B = linearity*(Train.Battery.Voltage - Train.Battery.CutoffVoltage)/(Train.Battery.StartVoltage - Train.Battery.CutoffVoltage) - local B = math.min(1,(Train.Battery.CCcurrent_sigma - Train.PowerSupply.car_control_load + Train.Battery.Ibatt_sigma)*-1/80) + local B = Train.Battery.Voltage > Train.Battery.CutoffVoltage and 1 or 0 local BO = B*Train.VB.Value*(1-Train.PA1.Value) local T = Train.SolverTemporaryVariables diff --git a/lua/metrostroi/systems/sys_81_717_electric.lua b/lua/metrostroi/systems/sys_81_717_electric.lua index d702884..24ea6f2 100644 --- a/lua/metrostroi/systems/sys_81_717_electric.lua +++ b/lua/metrostroi/systems/sys_81_717_electric.lua @@ -59,7 +59,6 @@ function TRAIN_SYSTEM:SolveAllInternalCircuits(Train,dT,firstIter) local RK = RheostatController.SelectedPosition --local B = (Train.Battery.Voltage >= 60) and 1 or (Train.Battery.Voltage >= Train.Battery.CutoffVoltage) and 0.5 or 0 --local B = math.min(1,linearity*(Train.Battery.Voltage - Train.Battery.CutoffVoltage)/(Train.Battery.StartVoltage - Train.Battery.CutoffVoltage)) - -- TODO: вычисление B пересмотреть. Полностью пересмотреть принцип включения (триггера) реле local B = Train.Battery.Voltage > Train.Battery.CutoffVoltage and 1 or 0 local BO = B*Train.VB.Value*(1-Train.PA1.Value) local BO2 = B*Train.VB.Value*(1-Train.PA2.Value) @@ -82,7 +81,6 @@ function TRAIN_SYSTEM:SolveAllInternalCircuits(Train,dT,firstIter) S["10AK"] = T[10]*Train.A54.Value*Train.A84.Value S["U2"] = S["10AK"]*KV["U2-10AK"] --10AK-KV-U2 - --print(Train.Battery.CutoffVoltage) --Reverser S["7D"] = T[10]*Train.A48.Value @@ -887,9 +885,7 @@ function TRAIN_SYSTEM:SolveRKInternalCircuits(Train,dT,firstIter) local P = Train.PositionSwitch local RheostatController = Train.RheostatController local RK = RheostatController.SelectedPosition - --local B = (Train.Battery.Voltage >= 60) and 1 or (Train.Battery.Voltage >= Train.Battery.CutoffVoltage) and 0.5 or 0 - --local B = math.min(1,linearity*(Train.Battery.Voltage - Train.Battery.CutoffVoltage)/(Train.Battery.StartVoltage - Train.Battery.CutoffVoltage)) - local B = math.min(1,(Train.Battery.CCcurrent_sigma - Train.PowerSupply.car_control_load + Train.Battery.Ibatt_sigma)*-1/80) + local B = Train.Battery.Voltage > Train.Battery.CutoffVoltage and 1 or 0 local BO = B*Train.VB.Value*(1-Train.PA1.Value) local T = Train.SolverTemporaryVariables @@ -1145,7 +1141,6 @@ function TRAIN_SYSTEM:SolveThyristorController(Train, dT) end --print(self.ThyristorState) - --print(self.ThyristorState) -- Generate resistance local keypoints = {0.10, 0.008, 0.20, 0.018, 0.30, 0.030, 0.40, 0.047, 0.50, 0.070, 0.60, 0.105, 0.70, 0.165, 0.80, 0.280, 0.90, 0.650, 1.00, 15.00} local TargetField = 0.48 + 0.52 * self.ThyristorState diff --git a/lua/metrostroi/systems/sys_81_717_pneumatic.lua b/lua/metrostroi/systems/sys_81_717_pneumatic.lua index 049f35e..054ed56 100644 --- a/lua/metrostroi/systems/sys_81_717_pneumatic.lua +++ b/lua/metrostroi/systems/sys_81_717_pneumatic.lua @@ -55,9 +55,9 @@ function TRAIN_SYSTEM:Initialize(parameters) --DKPT self.Train:LoadSystem("DKPT","Relay","R-52B") -- -- Valve #1 - self.Train:LoadSystem("PneumaticNo1","Relay") + self.Train:LoadSystem("PneumaticNo1","Relay","", {hasCoil = true}) -- Valve #2 - self.Train:LoadSystem("PneumaticNo2","Relay") + self.Train:LoadSystem("PneumaticNo2","Relay","", {hasCoil = true}) -- Автоматический выключатель торможения (АВТ) self.Train:LoadSystem("AVT","Relay","AVT-325") -- Регулятор давления (АК) @@ -69,9 +69,9 @@ function TRAIN_SYSTEM:Initialize(parameters) -- Блокировка дверей self.Train:LoadSystem("BD","Relay","") -- Вентили дверного воздухораспределителя (ВДОЛ, ВДОП, ВДЗ) - self.Train:LoadSystem("VDOL","Relay","", {bass = true, coil_res = 175}) - self.Train:LoadSystem("VDOP","Relay","", {bass = true, coil_res = 175}) - self.Train:LoadSystem("VDZ","Relay","", {bass = true, coil_res = 175}) + self.Train:LoadSystem("VDOL","Relay","", {bass = true, coil_res = 175, hasCoil = true}) + self.Train:LoadSystem("VDOP","Relay","", {bass = true, coil_res = 175, hasCoil = true}) + self.Train:LoadSystem("VDZ","Relay","", {bass = true, coil_res = 175, hasCoil = true}) -- Разобщение клапана машиниста self.Train:LoadSystem("DriverValveDisconnect","Relay","Switch", {bass = true}) diff --git a/lua/metrostroi/systems/sys_als_ars_dnepr.lua b/lua/metrostroi/systems/sys_als_ars_dnepr.lua index 7aa32e6..96879f0 100644 --- a/lua/metrostroi/systems/sys_als_ars_dnepr.lua +++ b/lua/metrostroi/systems/sys_als_ars_dnepr.lua @@ -29,21 +29,21 @@ function TRAIN_SYSTEM:Initialize() self.Train:LoadSystem("BSM","ALS_ARS_BSM") self.Train:LoadSystem("BUM","ALS_ARS_BUM") - self.Train:LoadSystem("ROT1","Relay","",{bass=true, trigger_level = 0.1*math.random() + 0.4}) - self.Train:LoadSystem("ROT2","Relay","",{bass=true, trigger_level = 0.1*math.random() + 0.4}) + self.Train:LoadSystem("ROT1","Relay","",{bass=true, pickup_current = 0.1*math.random() + 0.4, hasCoil = true}) + self.Train:LoadSystem("ROT2","Relay","",{bass=true, pickup_current = 0.1*math.random() + 0.4, hasCoil = true}) self.Train:LoadSystem("EPKC","Relay") - self.Train:LoadSystem("KPK1","Relay","",{bass=true,bass_separate=true, trigger_level = 0.1*math.random() + 0.4}) --Коммутация ПК - self.Train:LoadSystem("KPK2","Relay","",{bass=true,bass_separate=true, trigger_level = 0.1*math.random() + 0.4}) --Коммутация ПК - self.Train:LoadSystem("FMM1","Relay","",{bass=true,bass_separate=true, trigger_level = 0.1*math.random() + 0.4}) --Фиксация местонахождения машиниста - self.Train:LoadSystem("FMM2","Relay","",{bass=true,bass_separate=true, trigger_level = 0.1*math.random() + 0.4}) --Фиксация местонахождения машиниста - self.Train:LoadSystem("PD1","Relay","",{bass=true,bass_separate=true, trigger_level = 0.1*math.random() + 0.4}) --Переключение дешифратора - self.Train:LoadSystem("PD2","Relay","",{bass=true,bass_separate=true, trigger_level = 0.1*math.random() + 0.4}) --Переключение дешифратора - self.Train:LoadSystem("ARS_VP","Relay","",{bass=true,bass_separate=true, trigger_level = 0.1*math.random() + 0.4}) --Режим ВП - self.Train:LoadSystem("ARS_RT","Relay","",{bass=true,bass_separate=true, trigger_level = 0.1*math.random() + 0.4}) --Реле торможения от АРС-Р - self.Train:LoadSystem("NG","Relay","",{bass=true,bass_separate=true, trigger_level = 0.1*math.random() + 0.4}) - self.Train:LoadSystem("NH","Relay","",{bass=true,bass_separate=true, trigger_level = 0.1*math.random() + 0.4}) + self.Train:LoadSystem("KPK1","Relay","",{bass=true,bass_separate=true, pickup_current = 0.1*math.random() + 0.4, hasCoil = true}) --Коммутация ПК + self.Train:LoadSystem("KPK2","Relay","",{bass=true,bass_separate=true, pickup_current = 0.1*math.random() + 0.4, hasCoil = true}) --Коммутация ПК + self.Train:LoadSystem("FMM1","Relay","",{bass=true,bass_separate=true, pickup_current = 0.1*math.random() + 0.4, hasCoil = true}) --Фиксация местонахождения машиниста + self.Train:LoadSystem("FMM2","Relay","",{bass=true,bass_separate=true, pickup_current = 0.1*math.random() + 0.4, hasCoil = true}) --Фиксация местонахождения машиниста + self.Train:LoadSystem("PD1","Relay","",{bass=true,bass_separate=true, pickup_current = 0.1*math.random() + 0.4, hasCoil = true}) --Переключение дешифратора + self.Train:LoadSystem("PD2","Relay","",{bass=true,bass_separate=true, pickup_current = 0.1*math.random() + 0.4, hasCoil = true}) --Переключение дешифратора + self.Train:LoadSystem("ARS_VP","Relay","",{bass=true,bass_separate=true, pickup_current = 0.1*math.random() + 0.4, hasCoil = true}) --Режим ВП + self.Train:LoadSystem("ARS_RT","Relay","",{bass=true,bass_separate=true, pickup_current = 0.1*math.random() + 0.4, hasCoil = true}) --Реле торможения от АРС-Р + self.Train:LoadSystem("NG","Relay","",{bass=true,bass_separate=true, pickup_current = 0.1*math.random() + 0.4, hasCoil = true}) + self.Train:LoadSystem("NH","Relay","",{bass=true,bass_separate=true, pickup_current = 0.1*math.random() + 0.4, hasCoil = true}) -- ARS wires self["33D"] = 0 diff --git a/lua/metrostroi/systems/sys_battery.lua b/lua/metrostroi/systems/sys_battery.lua index cba1dd9..f3c2ebe 100644 --- a/lua/metrostroi/systems/sys_battery.lua +++ b/lua/metrostroi/systems/sys_battery.lua @@ -34,16 +34,27 @@ function TRAIN_SYSTEM:Initialize() self.CCcurrent_sigma = 0 self.Dischar = false self.ComputerCar = false + + for k,v in pairs(self.Train.Systems) do + if v.hasCoil and not self.Consumers[v] then + print("Registering relay",v.Name, "Train: ", self.Train) + self.Consumers[v] = {0,v.coil_res,0} + end + end + print "------------------\n" end +-- TODO: - разобраться, почему при сборе схемы на ход пропадает контроль дверей +-- - расставить параметры для всех оставшихся реле + -- self.Consumers is a table of relays with the next structure: -- [] = {, , } function TRAIN_SYSTEM:Inputs() - return { "Charge", "Dischargeable", "InitialVoltage", "CarType" } + return { "Charge", "Dischargeable", "InitialVoltage", "CarType", "Computer" } end function TRAIN_SYSTEM:Outputs() - return { "Capacity", "Charge", "Voltage" } + return { "Capacity", "Charge", "Voltage", "eds_eq" } end function TRAIN_SYSTEM:TriggerInput(name,value) if name == "Charge" then self.Charging = value end @@ -72,6 +83,11 @@ function TRAIN_SYSTEM:Think(dT) end self.IResistance = self.IResistance * self.ElementCount + for k,v in pairs(self.Consumers) do + v[1] = k.Value + v[3] = k.Current + end + if self.Train.ComputerCar then local nodecurr_sum, branchcond_sum = 0, 0 local eds_eq = 0 @@ -121,7 +137,9 @@ function TRAIN_SYSTEM:Think(dT) v.Battery.Ibatt_sigma = self.Ibatt_sigma v.Battery.CCcurrent_sigma = self.CCcurrent_sigma end + --print("БД = ", self.Train.BD.Value) end + --print("Battery RD = ",self.Train.RD.Value) -- Calculate discharge if self.Dischar then self.Train.BattCurrent = self.Ibatt*self.Train.A24.Value diff --git a/lua/metrostroi/systems/sys_pr_14x_panels.lua b/lua/metrostroi/systems/sys_pr_14x_panels.lua index 226f6c5..7d7a38b 100644 --- a/lua/metrostroi/systems/sys_pr_14x_panels.lua +++ b/lua/metrostroi/systems/sys_pr_14x_panels.lua @@ -11,15 +11,15 @@ function TRAIN_SYSTEM:Initialize() -- ПР-143 ---------------------------------------------------------------------------- -- Контактор включения провода 1 (Р1-Р5) - self.Train:LoadSystem("R1_5","Relay","KPD-110E",{ bass = true }) + self.Train:LoadSystem("R1_5","Relay","KPD-110E",{ bass = true, hasCoil = true }) -- Контактор 6-ого провода (К6) - self.Train:LoadSystem("K6","Relay","KPD-110E",{ bass = true, close_time = 0.12}) + self.Train:LoadSystem("K6","Relay","KPD-110E",{ bass = true, close_time = 0.12, hasCoil = true }) -- Реле времени торможения (РВТ) - self.Train:LoadSystem("RVT","Relay","REV-811T", { bass = true, open_time = 0.5, close_time = 0.12})--(self.Train.Electric.TrainSolver:find("81-") and 0.3 or 0.7) + self.Train:LoadSystem("RVT","Relay","REV-811T", { bass = true, open_time = 0.5, close_time = 0.12, hasCoil = true })--(self.Train.Electric.TrainSolver:find("81-") and 0.3 or 0.7) -- Реле педали бдительности (РПБ) - self.Train:LoadSystem("RPB","Relay","REV-813T", { bass = true, open_time = 2.5,}) + self.Train:LoadSystem("RPB","Relay","REV-813T", { bass = true, open_time = 2.5, hasCoil = true }) -- РВ-2 - self.Train:LoadSystem("RV_2","Relay","REV-813T",{ open_time = 0.2, close_time = 0.6 }) + self.Train:LoadSystem("RV_2","Relay","REV-813T",{ open_time = 0.2, close_time = 0.6, hasCoil = true }) @@ -27,13 +27,13 @@ function TRAIN_SYSTEM:Initialize() -- ПР-144 ---------------------------------------------------------------------------- -- Контактор 25ого провода (К25) - self.Train:LoadSystem("K25","Relay","PR-143",{bass = true}) + self.Train:LoadSystem("K25","Relay","PR-143",{bass = true, hasCoil = true }) -- Реле-повторитель провода 8 (РП8) - self.Train:LoadSystem("Rp8","Relay","REV-811T",{open_time = 0.2,bass = true }) + self.Train:LoadSystem("Rp8","Relay","REV-811T",{open_time = 0.2,bass = true, hasCoil = true }) -- Контактор дверей (КД) - self.Train:LoadSystem("KD","Relay","REV-811T",{ bass = true, trigger_level = 0.04*math.random() + 0.46 }) + self.Train:LoadSystem("KD","Relay","REV-811T",{ bass = true, pickup_current = 0.04*math.random() + 0.46, hasCoil = true }) -- Реле остановки (РО) - self.Train:LoadSystem("RO","Relay","KPD-110E",{ bass = true, close_time = 0--[[ , close_time = 0.1--]] }) + self.Train:LoadSystem("RO","Relay","KPD-110E",{ bass = true, close_time = 0, hasCoil = true--[[ , close_time = 0.1--]] }) end function TRAIN_SYSTEM:Think() diff --git a/lua/metrostroi/systems/sys_relay.lua b/lua/metrostroi/systems/sys_relay.lua index 51f2ad8..d5168ad 100644 --- a/lua/metrostroi/systems/sys_relay.lua +++ b/lua/metrostroi/systems/sys_relay.lua @@ -74,12 +74,16 @@ function TRAIN_SYSTEM:Initialize(parameters,extra_parameters) parameters.latched = parameters.latched or false -- Should relay be spring-returned to initial position parameters.returns = parameters.returns or (not parameters.latched) + -- Relay has coil (no by default) + parameters.hasCoil = parameters.hasCoil -- Trigger level for the relay parameters.trigger_level = parameters.trigger_level or 0.5 - -- Relay pickup current - parameters.pickup_current = parameters.pickup_current or 0.002*math.random() + 0.001 -- 100–300 mA in percentage of 80 A (coil hold current) - -- relay coil resistance, Ohm - parameters.coil_res = parameters.coil_res or math.random(100,300) + -- Relay pickup current, A + parameters.pickup_current = parameters.pickup_current or 0.008*math.random() + 0.03 + -- Relay holding current, A + parameters.holding_current = parameters.holding_current or 0.002*math.random() + 0.01 + -- Relay coil resistance, Ohm + parameters.coil_res = parameters.coil_res or parameters.hasCoil and math.random(100,300) or 1e12 for k,v in pairs(parameters) do self[k] = v end @@ -148,6 +152,8 @@ function TRAIN_SYSTEM:Initialize(parameters,extra_parameters) self.Time = 0 self.ChangeTime = nil self.Blocked = 0 + -- Extra fields for current sim + self.Current = 0 -- This increases precision at cost of perfomance self.SubIterations = parameters.iterations or 1--relay end @@ -157,7 +163,7 @@ function TRAIN_SYSTEM:Inputs() end function TRAIN_SYSTEM:Outputs() - return { "Value" , "Blocked","TargetValue"} + return { "Value" , "Blocked", "TargetValue", "pickup_current" , "holding_current" , "Current" , "hasCoil" } end @@ -208,7 +214,9 @@ function TRAIN_SYSTEM:TriggerInput(name,value) if (name == "Block") then self.Blocked = value elseif (name == "Close") and (value > self.trigger_level) and (self.Value ~= 1.0 or self.TargetValue ~= 1.0) then --(self.TargetValue ~= 1.0 and self.rpb)) - if self.pneumatic and self.Train.Pneumatic.TrainLinePressure < 3 then return end + if self.Name:find("PA") then print "Сгорел предохранитель!" end + --if self.Name:find("RD") then print "Попытка включить РД!" end + if self.pneumatic and self.Train.Pneumatic.TrainLinePressure < 3 then return end if (not self.ChangeTime) or (self.TargetValue ~= 1.0) then self.ChangeTime = self.Time + FailSim.Value(self,"CloseTime") end @@ -291,69 +299,40 @@ function TRAIN_SYSTEM:Think(dT) self.Value = self.TargetValue self.SpuriousTripTimer = nil end - -- Register new relay as current consumer - if self.Train.Battery and self.Train.Battery.Consumers and not self.Train.Battery.Consumers[self] then - --print("Registering relay",self, "Train: ", self.Train) - self.Train.Battery.Consumers[self] = {0,self.coil_res,0} + + -- Should move this chunk outside of turbostroi + ---------********************************************---------- + ---------********************************************---------- + + --print("РД = ",self.Train.Battery.Consumers[self.Train.RD]) + if self.hasCoil then + self.Current = self.TargetValue*self.Train.Battery.eds_eq/self.coil_res end - if self.ChangeTime and self.TargetValue == 1.0 then - self.Train.Battery.Consumers[self][3] = self.Train.Battery.eds_eq/self.coil_res + + if self.hasCoil and self.Value > 0.5 and self.Current < self.holding_current then + self:TriggerInput("Open",1) end -- Switch relay if self.ChangeTime and (self.Time > self.ChangeTime) and not self.SpuriousTripTimer then - -- Electropneumatic relays make this sound - if self.bass and self.Value ~= self.TargetValue then - --[[ - if self.Value ~= 0.0 and self.maxvalue ~= 2 or self.Value ~= 1.0 and self.maxvalue == 2 then - if self.av3 then self.Train:PlayOnce("vu22b_on","cabin") end - if self.igla then self.Train:PlayOnce("igla_on","cabin") end - if self.button then self.Train:PlayOnce("button_press","cabin",0.51) end - if self.vud then self.Train:PlayOnce("vu22_on","cabin") end - if self.uava then self.Train:PlayOnce("uava_on","cabin") end - if self.pb then self.Train:PlayOnce("switch6","cabin") end - if self.programm then self.Train:PlayOnce("inf_on","cabin") end - if self.programm1 then self.Train:PlayOnce("triple_up-0","cabin") end - if self.programm2 then self.Train:PlayOnce("triple_down-0","cabin") end - if self.av then self.Train:PlayOnce("auto_on","cabin") end - if self.mainav then self.Train:PlayOnce("mainauto_on","cabin") end - if self.krishka then self.Train:PlayOnce("kr_close","cabin") end - if self.paketnik then self.Train:PlayOnce("pak_on","cabin") end - if self.switch then self.Train:PlayOnce("switch_on","cabin") end - if self.rcr then self.Train:PlayOnce("rcr_on","cabin") end - end - if self.Value == 0.0 and self.maxvalue ~= 2 or self.Value == 1.0 and self.maxvalue == 2 then - if self.av3 then self.Train:PlayOnce("vu22b_off","cabin") end - if self.igla then self.Train:PlayOnce("igla_off","cabin") end - if self.button then self.Train:PlayOnce("button_release","cabin",0.56) end - if self.vud then self.Train:PlayOnce("vu22_off","cabin") end - if self.uava then self.Train:PlayOnce("uava_off","cabin") end - if self.pb then self.Train:PlayOnce("switch6_off","cabin") end - if self.programm then self.Train:PlayOnce("inf_off","cabin") end - if self.programm1 then self.Train:PlayOnce("triple_0-up","cabin") end - if self.programm2 then self.Train:PlayOnce("triple_0-down","cabin") end - if self.av then self.Train:PlayOnce("auto_off","cabin") end - if self.mainav then self.Train:PlayOnce("mainauto_off","cabin") end - if self.krishka then self.Train:PlayOnce("kr_open","cabin") end - if self.paketnik then self.Train:PlayOnce("pak_off","cabin") end - if self.switch then self.Train:PlayOnce("switch_off","cabin") end - if self.rcr then self.Train:PlayOnce("rcr_off","cabin") end - end - ]] - if self.bass_separate then - if self.TargetValue > 0 then - self.Train:PlayOnce(self.Name.."_on","bass",1) + if self.TargetValue > 0.5 and self.Current >= self.pickup_current or self.TargetValue < 0.5 and self.Current < self.holding_current or not self.hasCoil then + -- Electropneumatic relays make this sound + if self.bass and self.Value ~= self.TargetValue then + if self.bass_separate then + if self.TargetValue > 0 then + self.Train:PlayOnce(self.Name.."_on","bass",1) + else + self.Train:PlayOnce(self.Name.."_off","bass",1) + end else - self.Train:PlayOnce(self.Name.."_off","bass",1) + self.Train:PlayOnce(self.Name,"bass",self.TargetValue) end - else - self.Train:PlayOnce(self.Name,"bass",self.TargetValue) end - end - self.Value = self.TargetValue - self.Train.Battery.Consumers[self][1] = self.Value - self.ChangeTime = nil + self.Value = self.TargetValue + --self.Train.Battery.Consumers[self][1] = self.Value + self.ChangeTime = nil - -- Age relay a little - FailSim.Age(self,1) + -- Age relay a little + FailSim.Age(self,1) + end end end diff --git a/lua/metrostroi/systems/sys_yar_13b.lua b/lua/metrostroi/systems/sys_yar_13b.lua index 7714f72..00d43d4 100644 --- a/lua/metrostroi/systems/sys_yar_13b.lua +++ b/lua/metrostroi/systems/sys_yar_13b.lua @@ -8,7 +8,7 @@ Metrostroi.DefineSystem("YAR_13B") function TRAIN_SYSTEM:Initialize() -- Реле перегрузки (РПЛ) - self.Train:LoadSystem("RPL","Relay","RM3001", {coil_res = 73, trigger_level = 0.012})--, { trigger_level = 1300 }) + self.Train:LoadSystem("RPL","Relay","RM3001", {coil_res = 73, pickup_current = 0.012, hasCoil = true})--, { trigger_level = 1300 }) -- Групповое реле перегрузки 1-3 (РП1-3) self.Train:LoadSystem("RP1_3","Relay","RM3001",{ trigger_level = 760 }) --630 }) -- Групповое реле перегрузки 2-4 (РП2-4) @@ -16,14 +16,14 @@ function TRAIN_SYSTEM:Initialize() -- Нулевое реле (НР) -- Does not use any power source defined, as the operation is calculated from bus voltage - self.Train:LoadSystem("NR","Relay","R3150", { power_source = "None", coil_res = 690,trigger_level = 0.001 }) + self.Train:LoadSystem("NR","Relay","R3150", { power_source = "None", coil_res = 690,pickup_current = 0.001, hasCoil = true }) -- Реле системы управления - self.Train:LoadSystem("RSU","Relay","R3100", {coil_res = 275,trigger_level = 0.003}) + self.Train:LoadSystem("RSU","Relay","R3100", {coil_res = 275,pickup_current = 0.003, hasCoil = true}) self.Train:LoadSystem("RU","Relay","R3100") -- Реле заземления (РЗ-1, РЗ-2, РЗ-3) - self.Train:LoadSystem("RZ_1","Relay","RM3001", {coil_res = 338,trigger_level = 0.003}) - self.Train:LoadSystem("RZ_2","Relay","RM3001", {coil_res = 73,trigger_level = 0.012}) + self.Train:LoadSystem("RZ_1","Relay","RM3001", {coil_res = 338,pickup_current = 0.003, hasCoil = true}) + self.Train:LoadSystem("RZ_2","Relay","RM3001", {coil_res = 73,pickup_current = 0.012, hasCoil = true}) self.Train:LoadSystem("RZ_3","Relay","RM3001") -- Возврат реле перегрузки (РПвозврат) self.Train:LoadSystem("RPvozvrat","Relay","RM3001",{ @@ -31,25 +31,26 @@ function TRAIN_SYSTEM:Initialize() power_open = "None", -- Power source for the open signal power_close = "Mechanical", -- Power source for the close signal coil_res = 73, - trigger_level = 0.012, + pickup_current = 0.012, + hasCoil = true }) -- Реле времени РВ1 - self.Train:LoadSystem("RV1","Relay","RM3100",{ open_time = 0.7, coil_res = 31.7,trigger_level = 0.004 }) --указаны сопротивления обмоток СДРК + self.Train:LoadSystem("RV1","Relay","RM3100",{ open_time = 0.7, coil_res = 31.7,pickup_current = 0.004, hasCoil = true }) --указаны сопротивления обмоток СДРК -- Реле времени РВ2 (задерживает отключение ЛК2) - self.Train:LoadSystem("RV2","Relay","RM3100",{ open_time = 0.7, coil_res = 200,trigger_level = 0.004 }) - self.Train:LoadSystem("RR","Relay","RPU-116T", { coil_res = 160, trigger_level = 0.005 }) + self.Train:LoadSystem("RV2","Relay","RM3100",{ open_time = 0.7, coil_res = 200,pickup_current = 0.004, hasCoil = true }) + self.Train:LoadSystem("RR","Relay","RPU-116T", { coil_res = 160, pickup_current = 0.005, hasCoil = true }) -- Реле ручного тормоза (РРТ) - self.Train:LoadSystem("RRT","Relay", {coil_res = 28}) + self.Train:LoadSystem("RRT","Relay", {coil_res = 28, hasCoil = true}) -- Реле резервного пуска (РРП) - self.Train:LoadSystem("RRP","Relay", {coil_res = 162,trigger_level = 0.005}) + self.Train:LoadSystem("RRP","Relay", {coil_res = 162,pickup_current = 0.005, hasCoil = true}) -- Стоп-реле (СР1) - self.Train:LoadSystem("SR1","Relay","RM3000",{ iterations=16,open_time=0,coil_res=3.34,trigger_level = 0.003 }) --указаны сопротивления обмоток СДРК + self.Train:LoadSystem("SR1","Relay","RM3000",{ iterations=16,open_time=0,coil_res=3.34,pickup_current = 0.003, hasCoil = true }) --указаны сопротивления обмоток СДРК -- Реле контроля реверсоров - self.Train:LoadSystem("RKR","Relay","RM3000", {coil_res = 372,trigger_level = 0.003}) + self.Train:LoadSystem("RKR","Relay","RM3000", {coil_res = 372,pickup_current = 0.003, hasCoil = true}) -- Реле ускорения, торможения (РУТ) - self.Train:LoadSystem("RUT","Relay","R-52B", {coil_res = 25}) + self.Train:LoadSystem("RUT","Relay","R-52B", {coil_res = 25, hasCoil = true}) -- Only in Ezh diff --git a/lua/metrostroi/systems/sys_yar_27.lua b/lua/metrostroi/systems/sys_yar_27.lua index d7e89f8..58cc240 100644 --- a/lua/metrostroi/systems/sys_yar_27.lua +++ b/lua/metrostroi/systems/sys_yar_27.lua @@ -8,16 +8,16 @@ Metrostroi.DefineSystem("YAR_27") function TRAIN_SYSTEM:Initialize(parameters) -- Реле дверей (РД) - self.Train:LoadSystem("RD","Relay","REV-821",{ close_time = 0.1, coil_res = 448, trigger_level = 0.002 }) + self.Train:LoadSystem("RD","Relay","REV-821",{ close_time = 0.1, coil_res = 448, pickup_current = 0.002, hasCoil = true }) -- Реле включения освещения (РВО) - self.Train:LoadSystem("RVO","Relay","REV-814T",{ open_time = 4.0, coil_res = 21, trigger_level = 0.042 }) + self.Train:LoadSystem("RVO","Relay","REV-814T",{ open_time = 4.0, coil_res = 21, pickup_current = 0.042, hasCoil = true }) -- Реле времени торможения (РВ3) - self.Train:LoadSystem("RV3","Relay","REV-813T",{ open_time = 2.3, coil_res = 244, trigger_level = 0.004 }) + self.Train:LoadSystem("RV3","Relay","REV-813T",{ open_time = 2.3, coil_res = 244, pickup_current = 0.004, hasCoil = true }) -- Реле тока (РТ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.6}) --UNREALISTIC Repeater for RT2 for MSK trains + self.Train:LoadSystem("RT2r","Relay","REV-830",{ close_time = 0, open_time = 0.6, hasCoil = true}) --UNREALISTIC Repeater for RT2 for MSK trains -- Реле контроля тормозного тока (РКТТ) - self.Train:LoadSystem("RKTT","Relay","R-52B", { coil_res = 129, trigger_level = 0.008 }) + self.Train:LoadSystem("RKTT","Relay","R-52B", { coil_res = 129, pickup_current = 0.008, hasCoil = true }) self.Train.RKTTsh = 1 end