From 61952affe86dfde5add090f9d93c54a9f7780f6a Mon Sep 17 00:00:00 2001 From: Moon Horse Date: Thu, 18 Apr 2024 19:49:19 +0300 Subject: [PATCH] Temporary commit just to switch to the base branch --- lua/entities/gmod_subway_81-717_mvm/init.lua | 1 + .../systems/sys_81_714_electric.lua | 9 ++- .../systems/sys_81_717_electric.lua | 10 ++- .../systems/sys_81_717_pneumatic.lua | 6 +- lua/metrostroi/systems/sys_als_ars_dnepr.lua | 24 +++---- lua/metrostroi/systems/sys_battery.lua | 65 +++++++++++++++---- lua/metrostroi/systems/sys_bpsn.lua | 2 +- lua/metrostroi/systems/sys_lk_755a.lua | 10 +-- lua/metrostroi/systems/sys_pr_14x_panels.lua | 2 +- lua/metrostroi/systems/sys_relay.lua | 13 +++- lua/metrostroi/systems/sys_yar_13b.lua | 28 ++++---- lua/metrostroi/systems/sys_yar_27.lua | 10 +-- 12 files changed, 119 insertions(+), 61 deletions(-) diff --git a/lua/entities/gmod_subway_81-717_mvm/init.lua b/lua/entities/gmod_subway_81-717_mvm/init.lua index f71aad0..6ac28d1 100644 --- a/lua/entities/gmod_subway_81-717_mvm/init.lua +++ b/lua/entities/gmod_subway_81-717_mvm/init.lua @@ -559,6 +559,7 @@ 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 diff --git a/lua/metrostroi/systems/sys_81_714_electric.lua b/lua/metrostroi/systems/sys_81_714_electric.lua index 615cc9f..a85a7cf 100644 --- a/lua/metrostroi/systems/sys_81_714_electric.lua +++ b/lua/metrostroi/systems/sys_81_714_electric.lua @@ -53,12 +53,15 @@ local function C(x) return x and 1 or 0 end local min = math.min local max = math.max +local linearity = 1.2 function TRAIN_SYSTEM:SolveAllInternalCircuits(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 = (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 BO = B*Train.VB.Value*(1-Train.PA1.Value) local BO2 = B*Train.VB.Value*(1-Train.PA2.Value) local T = Train.SolverTemporaryVariables @@ -341,7 +344,9 @@ 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 = (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 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 0c8f1b4..c8c8638 100644 --- a/lua/metrostroi/systems/sys_81_717_electric.lua +++ b/lua/metrostroi/systems/sys_81_717_electric.lua @@ -51,12 +51,16 @@ local function C(x) return x and 1 or 0 end local min = math.min local max = math.max +local linearity = 1.2 function TRAIN_SYSTEM:SolveAllInternalCircuits(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 = (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 = math.min(1,(Train.Battery.CCcurrent_sigma - Train.PowerSupply.car_control_load + Train.Battery.Ibatt_sigma)*-1/80) local BO = B*Train.VB.Value*(1-Train.PA1.Value) local BO2 = B*Train.VB.Value*(1-Train.PA2.Value) local T = Train.SolverTemporaryVariables @@ -883,7 +887,9 @@ 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 = (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 BO = B*Train.VB.Value*(1-Train.PA1.Value) local T = Train.SolverTemporaryVariables diff --git a/lua/metrostroi/systems/sys_81_717_pneumatic.lua b/lua/metrostroi/systems/sys_81_717_pneumatic.lua index b60877a..049f35e 100644 --- a/lua/metrostroi/systems/sys_81_717_pneumatic.lua +++ b/lua/metrostroi/systems/sys_81_717_pneumatic.lua @@ -69,9 +69,9 @@ function TRAIN_SYSTEM:Initialize(parameters) -- Блокировка дверей self.Train:LoadSystem("BD","Relay","") -- Вентили дверного воздухораспределителя (ВДОЛ, ВДОП, ВДЗ) - self.Train:LoadSystem("VDOL","Relay","", {bass = true}) - self.Train:LoadSystem("VDOP","Relay","", {bass = true}) - self.Train:LoadSystem("VDZ","Relay","", {bass = true}) + 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("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 14ccb51..7aa32e6 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}) - self.Train:LoadSystem("ROT2","Relay","",{bass=true}) + 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("EPKC","Relay") - self.Train:LoadSystem("KPK1","Relay","",{bass=true,bass_separate=true}) --Коммутация ПК - self.Train:LoadSystem("KPK2","Relay","",{bass=true,bass_separate=true}) --Коммутация ПК - self.Train:LoadSystem("FMM1","Relay","",{bass=true,bass_separate=true}) --Фиксация местонахождения машиниста - self.Train:LoadSystem("FMM2","Relay","",{bass=true,bass_separate=true}) --Фиксация местонахождения машиниста - self.Train:LoadSystem("PD1","Relay","",{bass=true,bass_separate=true}) --Переключение дешифратора - self.Train:LoadSystem("PD2","Relay","",{bass=true,bass_separate=true}) --Переключение дешифратора - self.Train:LoadSystem("ARS_VP","Relay","",{bass=true,bass_separate=true}) --Режим ВП - self.Train:LoadSystem("ARS_RT","Relay","",{bass=true,bass_separate=true}) --Реле торможения от АРС-Р - self.Train:LoadSystem("NG","Relay","",{bass=true,bass_separate=true}) - self.Train:LoadSystem("NH","Relay","",{bass=true,bass_separate=true}) + 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}) -- ARS wires self["33D"] = 0 diff --git a/lua/metrostroi/systems/sys_battery.lua b/lua/metrostroi/systems/sys_battery.lua index 7b5ec1b..04e690a 100644 --- a/lua/metrostroi/systems/sys_battery.lua +++ b/lua/metrostroi/systems/sys_battery.lua @@ -25,10 +25,13 @@ function TRAIN_SYSTEM:Initialize() self.IResistance = 0.018*52 -- 0.018 Ohm is a standard internal resistance of a fully-charged and rested new 80 Ah NiCd-cell self.SoC0v = 52 -- 52 volts at 0% state of charge assuming 1.0 volt per fully discharged cell self.SoC = 100 -- fully charged - self.CutoffVoltage = 54.7 -- 52 Volts actually, but due to lack of CC's current simulation train devices won't ever be shut down with this value + self.CutoffVoltage = 52--54.7 -- 52 Volts actually, but due to lack of CC's current simulation train devices won't ever be shut down with this value self.Ibatt = 0 self.eds_eq = 0 self.hvcounter = 0 + self.Consumers = {} + self.Ibatt_sigma = 0 + self.CCcurrent_sigma = 0 self.Dischar = false self.ComputerCar = false end @@ -45,22 +48,34 @@ function TRAIN_SYSTEM:TriggerInput(name,value) if name == "InitialVoltage" then self.StartVoltage = value end if name == "CarType" then self.CarType = value end end + +local function GetBranchCondSum(consumers) + local br = 1e-12 + for m,n in pairs(consumers) do + br = br + 1/(n[1] > 0 and n[2] or 1e12) + end + return br +end + function TRAIN_SYSTEM:Think(dT) if self.CarType == 1 then self.SoC = 100 * (self.Voltage - self.SoC0v)/(75 - self.SoC0v) if self.SoC > 60 then self.IResistance = 1e-4 * self.SoC + 0.012 - elseif 20 <= self.SoC and self.SoC <= 60 then + elseif 28 <= self.SoC and self.SoC <= 60 then --(20 — 60) self.IResistance = 0.018 - elseif self.SoC < 20 then - self.IResistance = math.min(1.1, 0.018 + 1.56^(12-1.48*self.SoC)) -- just made it up by myself >_> + elseif self.SoC < 28 then --1.1 + self.IResistance = math.min(0.32, 0.018 + 1.56^(12-1.48*self.SoC)) -- just made it up by myself >_> end self.IResistance = self.IResistance * self.ElementCount - + if self.Train.ComputerCar then local nodecurr_sum, branchcond_sum = 0, 0 local eds_eq = 0 local hvcounter = 0 + self.Ibatt_sigma = 0 + self.CCcurrent_sigma = 0 + for k,v in ipairs(self.Train.WagonList) do if v.PowerSupply.X2_2 > 0 and v.A24.Value > 0 then hvcounter = hvcounter + 1 @@ -70,29 +85,51 @@ function TRAIN_SYSTEM:Think(dT) for k,v in ipairs(self.Train.WagonList) do nodecurr_sum = nodecurr_sum + v.A56.Value*(v.VB.Value*v.Battery.Voltage/v.Battery.IResistance + v.PowerSupply.X2_1*v.A24.Value*v.PowerSupply.VoltageOut/v.PowerSupply.IResistance) --+ 1/((1 - v.VB.Value*v.A49.Value)*1e12 + 1e3) - branchcond_sum = branchcond_sum + 1/(v.LK4.Value > 0 and 20 or 1e12) + 1/(v.RV1.Value > 0 and 10 or 1e12) + 1/(v.KK.Value > 0 and 24 or 1e12) + 1/(1e3) + v.A56.Value*(v.VB.Value/v.Battery.IResistance + v.PowerSupply.X2_1*v.A24.Value/v.PowerSupply.IResistance) + branchcond_sum = branchcond_sum + GetBranchCondSum(v.Battery.Consumers) + v.A56.Value*(v.VB.Value/v.Battery.IResistance + v.PowerSupply.X2_1*v.A24.Value/v.PowerSupply.IResistance) + + --[[branchcond_sum = branchcond_sum + 1/(v.LK4.Value > 0 and 20 or 1e12) + 1/(v.RV1.Value > 0 and 10 or 1e12) + + 1/(v.KK.Value > 0 and 24 or 1e12) + 1/(1e3) + + 1/(v.RC1 and v.RC1.Value > 0 and 32 or 1e12) + + 1/(v.Panel.Headlights1 and v.Panel.Headlights1 > 0 and 38 or 1e12) + + 1/(v.Panel.Headlights2 and v.Panel.Headlights2 > 0 and 38 or 1e12) + + v.A56.Value*(v.VB.Value/v.Battery.IResistance + v.PowerSupply.X2_1*v.A24.Value/v.PowerSupply.IResistance)]] end eds_eq = nodecurr_sum/branchcond_sum + --print(eds_eq, nodecurr_sum, branchcond_sum) for k,v in ipairs(self.Train.WagonList) do - v.PowerSupply.car_control_load = eds_eq*(1/(v.LK4.Value > 0 and 20 or 1e12) + 1/(v.RV1.Value > 0 and 10 or 1e12) + 1/(v.KK.Value > 0 and 24 or 1e12)) - v.Battery.Ibatt = math.min(60,(math.min(1,(v.VB.Value*v.A56.Value+v.A24.Value))*v.VB.Value*((v.A56.Value*(eds_eq - v.Battery.Voltage) + v.PowerSupply.X2_1*(1-v.A56.Value)*(v.PowerSupply.VoltageOut*v.A24.Value - v.Battery.Voltage))))/v.Battery.IResistance) -- math.max(0,(2.4*(v.Battery.Voltage/v.Battery.StartVoltage)-2.39)) + v.PowerSupply.car_control_load = eds_eq*GetBranchCondSum(v.Battery.Consumers) + --[[v.PowerSupply.car_control_load = eds_eq*(1/(v.LK4.Value > 0 and 20 or 1e12) + 1/(v.RV1.Value > 0 and 10 or 1e12) + + 1/(v.RC1 and v.RC1.Value > 0 and 32 or 1e12) + + 1/(v.Panel.Headlights1 and v.Panel.Headlights1 > 0 and 38 or 1e12) + + 1/(v.Panel.Headlights2 and v.Panel.Headlights2 > 0 and 38 or 1e12) + + 1/(v.KK.Value > 0 and 24 or 1e12))]] + v.Battery.Ibatt = math.min(1,(2-self.Train.PA1.Value-self.Train.PA2.Value)) + *(math.min(1,(v.VB.Value*v.A56.Value+v.A24.Value))*v.VB.Value*((v.A56.Value*(eds_eq - v.Battery.Voltage) + + v.PowerSupply.X2_1*(1-v.A56.Value)*(v.PowerSupply.VoltageOut*v.A24.Value - v.Battery.Voltage))))/v.Battery.IResistance -- math.max(0,(2.4*(v.Battery.Voltage/v.Battery.StartVoltage)-2.39)) + self.Ibatt_sigma = self.Ibatt_sigma + v.Battery.Ibatt + self.CCcurrent_sigma = self.CCcurrent_sigma + v.PowerSupply.car_control_load v.Battery.eds_eq = eds_eq v.Battery.hvcounter = hvcounter v.eds_eq = v.Battery.eds_eq + --print(v.eds_eq, branchcond_sum) --print(v.PowerSupply.car_control_load,v.Battery.Ibatt,v.Battery.IResistance) end + for k,v in ipairs(self.Train.WagonList) do + v.Battery.Ibatt_sigma = self.Ibatt_sigma + v.Battery.CCcurrent_sigma = self.CCcurrent_sigma + end end -- Calculate discharge if self.Dischar then self.Train.BattCurrent = self.Ibatt*self.Train.A24.Value - self.Train.PA1:TriggerInput("Close",self.Ibatt) - self.Train.PA2:TriggerInput("Close",self.Ibatt) - self.Charge = math.min(self.Capacity,self.Charge + self.Ibatt * (self.Ibatt < 0 and 1000/self.SoC0v or 500/self.SoC0v)* dT)--1.33*Capacity + self.Train.PA1:TriggerInput("Close",math.abs(self.Ibatt)/2) -- Это неправильно, но я уже заебалась + self.Train.PA2:TriggerInput("Close",math.abs(self.Ibatt)/2) + self.Charge = math.max(0,math.min(self.Capacity,self.Charge + self.Ibatt * (self.Ibatt < 0 and 1000/self.SoC0v or 500/self.SoC0v)* dT))--1.33*Capacity end -- Calculate battery voltage - local batt_calc_voltage = math.max(self.StartVoltage,self.eds_eq*self.Train.VB.Value*self.Train.A56.Value,self.Train.PowerSupply.VoltageOut*self.Train.VB.Value*self.Train.A24.Value*self.Train.PowerSupply.X2_1) - self.Voltage = batt_calc_voltage*(self.Charge/self.Capacity) - --self.Voltage = self.StartVoltage*(self.Charge/self.Capacity) + --local batt_calc_voltage = math.max(self.StartVoltage,self.eds_eq*self.Train.VB.Value*self.Train.A56.Value,self.Train.PowerSupply.VoltageOut*self.Train.VB.Value*self.Train.A24.Value*self.Train.PowerSupply.X2_1) + --self.Voltage = batt_calc_voltage*(self.Charge/self.Capacity) + self.Voltage = self.StartVoltage*(self.Charge/self.Capacity) else -- Calculate discharge self.Current = 0--self.Train.KVC.Value*90*(self.Train.PowerSupply.XT3_1 > 0 and 3 or -1 + 4*self.Train:ReadTrainWire(27))*50*self.Train.Panel["V1"] diff --git a/lua/metrostroi/systems/sys_bpsn.lua b/lua/metrostroi/systems/sys_bpsn.lua index 1d399bc..b1a5122 100644 --- a/lua/metrostroi/systems/sys_bpsn.lua +++ b/lua/metrostroi/systems/sys_bpsn.lua @@ -34,7 +34,7 @@ function TRAIN_SYSTEM:Inputs() end function TRAIN_SYSTEM:Outputs() - return { "X2_2", "X6_2" } + return { "X2_2", "X6_2", "car_control_load" } end diff --git a/lua/metrostroi/systems/sys_lk_755a.lua b/lua/metrostroi/systems/sys_lk_755a.lua index 5f63453..4b6de4b 100644 --- a/lua/metrostroi/systems/sys_lk_755a.lua +++ b/lua/metrostroi/systems/sys_lk_755a.lua @@ -8,13 +8,13 @@ Metrostroi.DefineSystem("LK_755A") function TRAIN_SYSTEM:Initialize() -- Линейный контактор (ЛК1) - self.Train:LoadSystem("LK1","Relay","PK-162",{bass = true,close_time=0.1}) + self.Train:LoadSystem("LK1","Relay","PK-162",{bass = true,close_time=0.1, coil_res = 273.6}) -- Линейный контактор (ЛК2) - self.Train:LoadSystem("LK2","Relay","PK-162",{bass = true,close_time=0.1}) + self.Train:LoadSystem("LK2","Relay","PK-162",{bass = true,close_time=0.1, coil_res = 262.1}) -- Линейный контактор (ЛК3) - self.Train:LoadSystem("LK3","Relay","PK-162",{bass = true,close_time=0.1}) + self.Train:LoadSystem("LK3","Relay","PK-162",{bass = true,close_time=0.1, coil_res = 273.6}) -- Линейный контактор (ЛК4) - self.Train:LoadSystem("LK4","Relay","PK-162",{bass = true,close_time=0.1}) + self.Train:LoadSystem("LK4","Relay","PK-162",{bass = true,close_time=0.1, coil_res = 273.6}) -- Линейный контактор (ЛК5) - self.Train:LoadSystem("LK5","Relay","PK-162",{bass = true,close_time=0.1}) + self.Train:LoadSystem("LK5","Relay","PK-162",{bass = true,close_time=0.1, coil_res = 273.6}) end \ No newline at end of file diff --git a/lua/metrostroi/systems/sys_pr_14x_panels.lua b/lua/metrostroi/systems/sys_pr_14x_panels.lua index 9ed0e8e..226f6c5 100644 --- a/lua/metrostroi/systems/sys_pr_14x_panels.lua +++ b/lua/metrostroi/systems/sys_pr_14x_panels.lua @@ -31,7 +31,7 @@ function TRAIN_SYSTEM:Initialize() -- Реле-повторитель провода 8 (РП8) self.Train:LoadSystem("Rp8","Relay","REV-811T",{open_time = 0.2,bass = true }) -- Контактор дверей (КД) - self.Train:LoadSystem("KD","Relay","REV-811T",{ bass = true }) + self.Train:LoadSystem("KD","Relay","REV-811T",{ bass = true, trigger_level = 0.04*math.random() + 0.46 }) -- Реле остановки (РО) self.Train:LoadSystem("RO","Relay","KPD-110E",{ bass = true, close_time = 0--[[ , close_time = 0.1--]] }) end diff --git a/lua/metrostroi/systems/sys_relay.lua b/lua/metrostroi/systems/sys_relay.lua index eb1a542..e8ef39e 100644 --- a/lua/metrostroi/systems/sys_relay.lua +++ b/lua/metrostroi/systems/sys_relay.lua @@ -75,13 +75,14 @@ function TRAIN_SYSTEM:Initialize(parameters,extra_parameters) -- Should relay be spring-returned to initial position parameters.returns = parameters.returns or (not parameters.latched) -- Trigger level for the relay - parameters.trigger_level = parameters.trigger_level or 0.2*math.random() + 0.4 + --parameters.trigger_level = parameters.trigger_level or 0.15*math.random() + 0.2 + parameters.trigger_level = parameters.trigger_level 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) for k,v in pairs(parameters) do self[k] = v end - - ---------------------------------------------------------------------------- -- Relay parameters if self.close_time == 0 then @@ -289,6 +290,11 @@ 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} + end -- Switch relay if self.ChangeTime and (self.Time > self.ChangeTime) and not self.SpuriousTripTimer then -- Electropneumatic relays make this sound @@ -340,6 +346,7 @@ function TRAIN_SYSTEM:Think(dT) end end self.Value = self.TargetValue + self.Train.Battery.Consumers[self][1] = self.Value self.ChangeTime = nil -- Age relay a little diff --git a/lua/metrostroi/systems/sys_yar_13b.lua b/lua/metrostroi/systems/sys_yar_13b.lua index 883e424..7714f72 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")--, { trigger_level = 1300 }) + self.Train:LoadSystem("RPL","Relay","RM3001", {coil_res = 73, trigger_level = 0.012})--, { trigger_level = 1300 }) -- Групповое реле перегрузки 1-3 (РП1-3) self.Train:LoadSystem("RP1_3","Relay","RM3001",{ trigger_level = 760 }) --630 }) -- Групповое реле перегрузки 2-4 (РП2-4) @@ -16,38 +16,40 @@ 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" }) + self.Train:LoadSystem("NR","Relay","R3150", { power_source = "None", coil_res = 690,trigger_level = 0.001 }) -- Реле системы управления - self.Train:LoadSystem("RSU","Relay","R3100") + self.Train:LoadSystem("RSU","Relay","R3100", {coil_res = 275,trigger_level = 0.003}) self.Train:LoadSystem("RU","Relay","R3100") -- Реле заземления (РЗ-1, РЗ-2, РЗ-3) - self.Train:LoadSystem("RZ_1","Relay","RM3001") - self.Train:LoadSystem("RZ_2","Relay","RM3001") + 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_3","Relay","RM3001") -- Возврат реле перегрузки (РПвозврат) self.Train:LoadSystem("RPvozvrat","Relay","RM3001",{ latched = true, -- RPvozvrat latches into place 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, }) -- Реле времени РВ1 - self.Train:LoadSystem("RV1","Relay","RM3100",{ open_time = 0.7 }) + self.Train:LoadSystem("RV1","Relay","RM3100",{ open_time = 0.7, coil_res = 31.7,trigger_level = 0.004 }) --указаны сопротивления обмоток СДРК -- Реле времени РВ2 (задерживает отключение ЛК2) - self.Train:LoadSystem("RV2","Relay","RM3100",{ open_time = 0.7 }) - self.Train:LoadSystem("RR","Relay","RPU-116T") + 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("RRT","Relay") + self.Train:LoadSystem("RRT","Relay", {coil_res = 28}) -- Реле резервного пуска (РРП) - self.Train:LoadSystem("RRP","Relay") + self.Train:LoadSystem("RRP","Relay", {coil_res = 162,trigger_level = 0.005}) -- Стоп-реле (СР1) - self.Train:LoadSystem("SR1","Relay","RM3000",{ iterations=16,open_time=0 }) + self.Train:LoadSystem("SR1","Relay","RM3000",{ iterations=16,open_time=0,coil_res=3.34,trigger_level = 0.003 }) --указаны сопротивления обмоток СДРК -- Реле контроля реверсоров - self.Train:LoadSystem("RKR","Relay","RM3000") + self.Train:LoadSystem("RKR","Relay","RM3000", {coil_res = 372,trigger_level = 0.003}) -- Реле ускорения, торможения (РУТ) - self.Train:LoadSystem("RUT","Relay","R-52B") + self.Train:LoadSystem("RUT","Relay","R-52B", {coil_res = 25}) -- Only in Ezh diff --git a/lua/metrostroi/systems/sys_yar_27.lua b/lua/metrostroi/systems/sys_yar_27.lua index 198f659..d7e89f8 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 }) + self.Train:LoadSystem("RD","Relay","REV-821",{ close_time = 0.1, coil_res = 448, trigger_level = 0.002 }) -- Реле включения освещения (РВО) - self.Train:LoadSystem("RVO","Relay","REV-814T",{ open_time = 4.0 }) + self.Train:LoadSystem("RVO","Relay","REV-814T",{ open_time = 4.0, coil_res = 21, trigger_level = 0.042 }) -- Реле времени торможения (РВ3) - self.Train:LoadSystem("RV3","Relay","REV-813T",{ open_time = 2.3 }) + self.Train:LoadSystem("RV3","Relay","REV-813T",{ open_time = 2.3, coil_res = 244, trigger_level = 0.004 }) -- Реле тока (РТ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}) --UNREALISTIC Repeater for RT2 for MSK trains -- Реле контроля тормозного тока (РКТТ) - self.Train:LoadSystem("RKTT","Relay","R-52B") + self.Train:LoadSystem("RKTT","Relay","R-52B", { coil_res = 129, trigger_level = 0.008 }) self.Train.RKTTsh = 1 end