mirror of
https://github.com/metrostroi-repo/MetrostroiAddon.git
synced 2026-05-02 00:42:29 +00:00
Почти рабочий вариант, но батарея очень хреново заряжается
This commit is contained in:
@@ -569,10 +569,6 @@ end
|
|||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
function ENT:Think()
|
function ENT:Think()
|
||||||
self.RetVal = self.BaseClass.Think(self)
|
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 Panel = self.Panel
|
||||||
local Pneumatic = self.Pneumatic
|
local Pneumatic = self.Pneumatic
|
||||||
local power = Panel.V1 > -1.5
|
local power = Panel.V1 > -1.5
|
||||||
|
|||||||
@@ -53,11 +53,11 @@ function TRAIN_SYSTEM:Initialize(parameters)
|
|||||||
self.cranPres = 0
|
self.cranPres = 0
|
||||||
|
|
||||||
--DKPT
|
--DKPT
|
||||||
self.Train:LoadSystem("DKPT","Relay","R-52B") --
|
self.Train:LoadSystem("DKPT","Relay","") --
|
||||||
-- Valve #1
|
-- Valve #1
|
||||||
self.Train:LoadSystem("PneumaticNo1","Relay","", {hasCoil = true})
|
self.Train:LoadSystem("PneumaticNo1","Relay","", {coil_res = 200, hasCoil = true})
|
||||||
-- Valve #2
|
-- Valve #2
|
||||||
self.Train:LoadSystem("PneumaticNo2","Relay","", {hasCoil = true})
|
self.Train:LoadSystem("PneumaticNo2","Relay","", {coil_res = 200, hasCoil = true})
|
||||||
-- Автоматический выключатель торможения (АВТ)
|
-- Автоматический выключатель торможения (АВТ)
|
||||||
self.Train:LoadSystem("AVT","Relay","AVT-325")
|
self.Train:LoadSystem("AVT","Relay","AVT-325")
|
||||||
-- Регулятор давления (АК)
|
-- Регулятор давления (АК)
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ function TRAIN_SYSTEM:Initialize()
|
|||||||
|
|
||||||
self.Train:LoadSystem("ALSCoil")
|
self.Train:LoadSystem("ALSCoil")
|
||||||
|
|
||||||
self.Train:LoadSystem("BIS_R11","Relay","ARS",{bass=true,bass_separate=true})
|
self.Train:LoadSystem("BIS_R11","Relay","ARS",{bass=true, bass_separate=true})
|
||||||
self.Train:LoadSystem("BIS_R12","Relay","ARS",{bass=true,bass_separate=true,open_time=2.7})
|
self.Train:LoadSystem("BIS_R12","Relay","ARS",{bass=true, bass_separate=true, open_time=2.7})
|
||||||
self.R11 = 0
|
self.R11 = 0
|
||||||
self.R12 = 0
|
self.R12 = 0
|
||||||
self.KRH = 0
|
self.KRH = 0
|
||||||
@@ -29,21 +29,21 @@ function TRAIN_SYSTEM:Initialize()
|
|||||||
self.Train:LoadSystem("BSM","ALS_ARS_BSM")
|
self.Train:LoadSystem("BSM","ALS_ARS_BSM")
|
||||||
self.Train:LoadSystem("BUM","ALS_ARS_BUM")
|
self.Train:LoadSystem("BUM","ALS_ARS_BUM")
|
||||||
|
|
||||||
self.Train:LoadSystem("ROT1","Relay","",{bass=true, pickup_current = 0.1*math.random() + 0.4, hasCoil = true})
|
self.Train:LoadSystem("ROT1","Relay","ARS-DOP",{bass=true, hasCoil = true})
|
||||||
self.Train:LoadSystem("ROT2","Relay","",{bass=true, pickup_current = 0.1*math.random() + 0.4, hasCoil = true})
|
self.Train:LoadSystem("ROT2","Relay","ARS-DOP",{bass=true, hasCoil = true})
|
||||||
|
|
||||||
self.Train:LoadSystem("EPKC","Relay")
|
self.Train:LoadSystem("EPKC","Relay")
|
||||||
|
|
||||||
self.Train:LoadSystem("KPK1","Relay","",{bass=true,bass_separate=true, pickup_current = 0.1*math.random() + 0.4, hasCoil = true}) --Коммутация ПК
|
self.Train:LoadSystem("KPK1","Relay","ARS-DOP",{bass=true,bass_separate=true}) --Коммутация ПК
|
||||||
self.Train:LoadSystem("KPK2","Relay","",{bass=true,bass_separate=true, pickup_current = 0.1*math.random() + 0.4, hasCoil = true}) --Коммутация ПК
|
self.Train:LoadSystem("KPK2","Relay","ARS-DOP",{bass=true,bass_separate=true}) --Коммутация ПК
|
||||||
self.Train:LoadSystem("FMM1","Relay","",{bass=true,bass_separate=true, pickup_current = 0.1*math.random() + 0.4, hasCoil = true}) --Фиксация местонахождения машиниста
|
self.Train:LoadSystem("FMM1","Relay","ARS-DOP",{bass=true,bass_separate=true}) --Фиксация местонахождения машиниста
|
||||||
self.Train:LoadSystem("FMM2","Relay","",{bass=true,bass_separate=true, pickup_current = 0.1*math.random() + 0.4, hasCoil = true}) --Фиксация местонахождения машиниста
|
self.Train:LoadSystem("FMM2","Relay","ARS-DOP",{bass=true,bass_separate=true}) --Фиксация местонахождения машиниста
|
||||||
self.Train:LoadSystem("PD1","Relay","",{bass=true,bass_separate=true, pickup_current = 0.1*math.random() + 0.4, hasCoil = true}) --Переключение дешифратора
|
self.Train:LoadSystem("PD1","Relay","ARS-DOP",{bass=true,bass_separate=true}) --Переключение дешифратора
|
||||||
self.Train:LoadSystem("PD2","Relay","",{bass=true,bass_separate=true, pickup_current = 0.1*math.random() + 0.4, hasCoil = true}) --Переключение дешифратора
|
self.Train:LoadSystem("PD2","Relay","ARS-DOP",{bass=true,bass_separate=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_VP","Relay","ARS-DOP",{bass=true,bass_separate=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("ARS_RT","Relay","ARS-DOP",{bass=true,bass_separate=true}) --Реле торможения от АРС-Р
|
||||||
self.Train:LoadSystem("NG","Relay","",{bass=true,bass_separate=true, pickup_current = 0.1*math.random() + 0.4, hasCoil = true})
|
self.Train:LoadSystem("NG","Relay","ARS-DOP",{bass=true,bass_separate=true})
|
||||||
self.Train:LoadSystem("NH","Relay","",{bass=true,bass_separate=true, pickup_current = 0.1*math.random() + 0.4, hasCoil = true})
|
self.Train:LoadSystem("NH","Relay","ARS-DOP",{bass=true,bass_separate=true})
|
||||||
|
|
||||||
-- ARS wires
|
-- ARS wires
|
||||||
self["33D"] = 0
|
self["33D"] = 0
|
||||||
|
|||||||
@@ -24,8 +24,10 @@ function TRAIN_SYSTEM:Initialize()
|
|||||||
self.Voltage = self.StartVoltage
|
self.Voltage = self.StartVoltage
|
||||||
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.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.SoC0v = 52 -- 52 volts at 0% state of charge assuming 1.0 volt per fully discharged cell
|
||||||
self.SoC = 100 -- fully charged
|
self.SoC = 1.00 -- fully charged
|
||||||
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.CutoffVoltage = 40 -- we want deep discharge <_<
|
||||||
|
self.EthaCE0 = 0.94 -- Coulomb efficiency coeff
|
||||||
|
self.EthaCE = self.EthaCE0
|
||||||
self.Ibatt = 0
|
self.Ibatt = 0
|
||||||
self.eds_eq = 0
|
self.eds_eq = 0
|
||||||
self.hvcounter = 0
|
self.hvcounter = 0
|
||||||
@@ -44,8 +46,7 @@ function TRAIN_SYSTEM:Initialize()
|
|||||||
print "------------------\n"
|
print "------------------\n"
|
||||||
end
|
end
|
||||||
|
|
||||||
-- TODO: - разобраться, почему при сборе схемы на ход пропадает контроль дверей
|
-- TODO: - расставить параметры для всех оставшихся реле (убедиться, что подъемный ток ниже номинального)
|
||||||
-- - расставить параметры для всех оставшихся реле
|
|
||||||
|
|
||||||
-- self.Consumers is a table of relays with the next structure:
|
-- self.Consumers is a table of relays with the next structure:
|
||||||
-- [<relay>] = {<relay.Value>, <relay.coil_res>, <relay.current>}
|
-- [<relay>] = {<relay.Value>, <relay.coil_res>, <relay.current>}
|
||||||
@@ -73,15 +74,6 @@ end
|
|||||||
|
|
||||||
function TRAIN_SYSTEM:Think(dT)
|
function TRAIN_SYSTEM:Think(dT)
|
||||||
if self.CarType == 1 then
|
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 28 <= self.SoC and self.SoC <= 60 then --(20 — 60)
|
|
||||||
self.IResistance = 0.018
|
|
||||||
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
|
|
||||||
|
|
||||||
for k,v in pairs(self.Consumers) do
|
for k,v in pairs(self.Consumers) do
|
||||||
v[1] = k.Value
|
v[1] = k.Value
|
||||||
@@ -137,20 +129,92 @@ function TRAIN_SYSTEM:Think(dT)
|
|||||||
v.Battery.Ibatt_sigma = self.Ibatt_sigma
|
v.Battery.Ibatt_sigma = self.Ibatt_sigma
|
||||||
v.Battery.CCcurrent_sigma = self.CCcurrent_sigma
|
v.Battery.CCcurrent_sigma = self.CCcurrent_sigma
|
||||||
end
|
end
|
||||||
--print("БД = ", self.Train.BD.Value)
|
|
||||||
end
|
end
|
||||||
--print("Battery RD = ",self.Train.RD.Value)
|
-- Calculate state of charge and internal resistance
|
||||||
-- Calculate discharge
|
|
||||||
if self.Dischar then
|
if self.Dischar then
|
||||||
self.Train.BattCurrent = self.Ibatt*self.Train.A24.Value
|
--self.EthaCE0 = self.EthaCE0 - dT * 1.16e-7 -- ~ 1% per day
|
||||||
|
self.Capacity = self.Capacity - dT * 0.033 -- ~ 1% per day
|
||||||
|
if self.Ibatt > 0 then
|
||||||
|
if self.Ibatt >= 8 then
|
||||||
|
local kCE = (self.EthaCE0 - 0.5)/72
|
||||||
|
local aCE = kCE*80 + 0.5
|
||||||
|
self.EthaCE = aCE - kCE * math.abs(self.Ibatt)
|
||||||
|
else
|
||||||
|
-- низковат коэффициент; уже при 5 А всего 0.5, надо менять функцию, иначе выше 75 вольт батарею и за год не зарядишь
|
||||||
|
self.EthaCE = 0.1*math.exp(0.28*self.Ibatt)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if self.SoC <= 1.0 then
|
||||||
|
self.EthaCE = 1
|
||||||
|
else
|
||||||
|
self.EthaCE = 0.5*math.exp(2.6*self.SoC) - 5.73
|
||||||
|
end
|
||||||
|
end
|
||||||
|
-- Возможно, надо ввести ток саморазряда, а не ебаться с выдуманной зависимостью EthaCE от SoC выше 100%
|
||||||
|
self.SoC = self.SoC + self.EthaCE*self.Ibatt*dT/self.Capacity
|
||||||
|
local SoC = math.max(0,math.min(132,self.SoC*100))
|
||||||
|
if SoC > 100 then
|
||||||
|
self.IResistance = 3e-4 * (SoC-100) + 0.018 -- 132 % = 0.028 Ohm
|
||||||
|
elseif 10 <= SoC and SoC <= 100 then
|
||||||
|
self.IResistance = 0.018
|
||||||
|
elseif SoC < 10 then
|
||||||
|
self.IResistance = math.min(0.32, 0.018 + 1.28^-(6+1.48*SoC)) -- just made it up by myself >_>
|
||||||
|
end
|
||||||
|
self.IResistance = self.IResistance * self.ElementCount
|
||||||
|
--self.Train.BattCurrent = self.Ibatt*self.Train.A24.Value
|
||||||
self.Train.PA1:TriggerInput("Close",math.abs(self.Ibatt)/2) -- Это неправильно, но я уже заебалась
|
self.Train.PA1:TriggerInput("Close",math.abs(self.Ibatt)/2) -- Это неправильно, но я уже заебалась
|
||||||
self.Train.PA2: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
|
-- Supposed battery voltage range from 29 to 82 volts
|
||||||
|
--self.Charge = math.max(-self.Capacity,math.min(1.32*self.Capacity,self.Charge + self.Ibatt * --[[(self.Ibatt < 0 and 1000/self.SoC0v or 500/self.SoC0v)*]] dT))
|
||||||
|
end -- ^
|
||||||
|
-- Calculate battery voltage -- |
|
||||||
|
--self.Voltage = self.StartVoltage*(self.Charge/self.Capacity) -- симуляция потери емкости батареи (future feature) — хуюче
|
||||||
|
|
||||||
|
-- Polynomials for battery voltage calculation during charge and discharge (source: https://www.mdpi.com/1996-1073/16/21/7291)
|
||||||
|
-- Roughly, Vbatt_charge = EMF(SOC) + 𝑈ℎ(SOC), Vbatt_discharge = EMF(SOC) - 𝑈ℎ(SOC)
|
||||||
|
|
||||||
|
--EMF(SOC)=−0.68175SOC^8+8.82823SOC^7−24.43179SOC^6+31.87221SOC^5−23.97881SOC^4+11.24774SOC^3−3.40685SOC^2+0.74692SOC+1.22076
|
||||||
|
--𝑈ℎ(SOC)=2.62496SOC^8−12.77132SOC^7+22.37586SOC^6−18.04921SOC^5+6.14667SOC^4+0.26467SOC^3−0.82125SOC^2+0.21246SOC+0.02641
|
||||||
|
|
||||||
|
local TargVbatt, EMF_soc, Uh_soc
|
||||||
|
EMF_soc=-0.68175*self.SoC^8+8.82823*self.SoC^7-24.43179*self.SoC^6+31.87221*self.SoC^5-23.97881*self.SoC^4+11.24774*self.SoC^3-3.40685*self.SoC^2+0.74692*self.SoC+1.22076
|
||||||
|
Uh_soc=2.62496*self.SoC^8-12.77132*self.SoC^7+22.37586*self.SoC^6-18.04921*self.SoC^5+6.14667*self.SoC^4+0.26467*self.SoC^3-0.82125*self.SoC^2+0.21246*self.SoC+0.02641
|
||||||
|
|
||||||
|
if self.Ibatt < 0 then --Discharge
|
||||||
|
TargVbatt = EMF_soc - Uh_soc
|
||||||
|
--[[local i_bat = math.abs(self.Ibatt)
|
||||||
|
if self.SoC > 1.0 then
|
||||||
|
self.Voltage = 75 + math.exp(2-9*self.SoC)
|
||||||
|
elseif self.SoC > 0.2 then
|
||||||
|
local Kmin, Kmax = 3/0.8, 13/0.8
|
||||||
|
local KaCe = (Kmax - Kmin)/(63-8)
|
||||||
|
local Akc = Kmax-63*KaCe
|
||||||
|
local Kdis = Akc+KaCe*i_bat
|
||||||
|
local Avb = 75
|
||||||
|
TargVbatt = Avb - Kdis*self.SoC
|
||||||
|
else
|
||||||
|
local Ka = (75-68)/(64-8)
|
||||||
|
local Ai = (64-i_bat)*Ka+68
|
||||||
|
local Kb = (24-13)/(64-8)
|
||||||
|
local Bi = (i_bat-8)*Kb+13
|
||||||
|
TargVbatt = Ai - Bi*math.exp(-7*self.SoC)
|
||||||
|
end]]
|
||||||
|
else --Charge
|
||||||
|
TargVbatt = EMF_soc + Uh_soc
|
||||||
|
end
|
||||||
|
TargVbatt = TargVbatt*self.ElementCount
|
||||||
|
--print("Target Voltage = "..TargVbatt, self.Train)
|
||||||
|
|
||||||
|
self.Voltage = self.Voltage + (TargVbatt - self.Voltage)*dT*0.05
|
||||||
|
--self.Voltage = (75-self.SoC0v)*(self.Charge/self.Capacity)+self.SoC0v
|
||||||
|
|
||||||
|
-- DEBUG
|
||||||
|
if self.Train.R_VPR and self.Train.R_VPR.Value < 0.5 then
|
||||||
|
print("Target Voltage = "..TargVbatt, "self.Voltage = "..self.Voltage)
|
||||||
|
--print("self.SoC = "..self.SoC, "self.Ibatt = "..self.Ibatt)
|
||||||
|
--print("self.EthaCE = "..self.EthaCE, "self.IResistance = "..self.IResistance)
|
||||||
|
--print("self.Capacity = "..self.Capacity)
|
||||||
end
|
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)
|
|
||||||
else
|
else
|
||||||
-- Calculate discharge
|
-- 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"]
|
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"]
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ function TRAIN_SYSTEM:Inputs()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function TRAIN_SYSTEM:Outputs()
|
function TRAIN_SYSTEM:Outputs()
|
||||||
return { "X2_2", "X6_2", "car_control_load" }
|
return { "X2_2", "X6_2", "car_control_load", "VoltageOut" }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -11,15 +11,15 @@ function TRAIN_SYSTEM:Initialize()
|
|||||||
-- ПР-143
|
-- ПР-143
|
||||||
----------------------------------------------------------------------------
|
----------------------------------------------------------------------------
|
||||||
-- Контактор включения провода 1 (Р1-Р5)
|
-- Контактор включения провода 1 (Р1-Р5)
|
||||||
self.Train:LoadSystem("R1_5","Relay","KPD-110E",{ bass = true, hasCoil = true })
|
self.Train:LoadSystem("R1_5","Relay","KPD-110E",{ bass = true })
|
||||||
-- Контактор 6-ого провода (К6)
|
-- Контактор 6-ого провода (К6)
|
||||||
self.Train:LoadSystem("K6","Relay","KPD-110E",{ bass = true, close_time = 0.12, hasCoil = true })
|
self.Train:LoadSystem("K6","Relay","KPD-110E",{ bass = true, close_time = 0.12 })
|
||||||
-- Реле времени торможения (РВТ)
|
-- Реле времени торможения (РВТ)
|
||||||
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("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("RPB","Relay","REV-813T", { bass = true, open_time = 2.5, hasCoil = true })
|
self.Train:LoadSystem("RPB","Relay","REV-813T", { bass = true, open_time = 2.5 })
|
||||||
-- РВ-2
|
-- РВ-2
|
||||||
self.Train:LoadSystem("RV_2","Relay","REV-813T",{ open_time = 0.2, close_time = 0.6, hasCoil = true })
|
self.Train:LoadSystem("RV_2","Relay","REV-813T",{ open_time = 0.2, close_time = 0.6 })
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -27,13 +27,13 @@ function TRAIN_SYSTEM:Initialize()
|
|||||||
-- ПР-144
|
-- ПР-144
|
||||||
----------------------------------------------------------------------------
|
----------------------------------------------------------------------------
|
||||||
-- Контактор 25ого провода (К25)
|
-- Контактор 25ого провода (К25)
|
||||||
self.Train:LoadSystem("K25","Relay","PR-143",{bass = true, hasCoil = true })
|
self.Train:LoadSystem("K25","Relay","PR-143",{ bass = true })
|
||||||
-- Реле-повторитель провода 8 (РП8)
|
-- Реле-повторитель провода 8 (РП8)
|
||||||
self.Train:LoadSystem("Rp8","Relay","REV-811T",{open_time = 0.2,bass = true, hasCoil = true })
|
self.Train:LoadSystem("Rp8","Relay","REV-811T",{ open_time = 0.2, bass = true })
|
||||||
-- Контактор дверей (КД)
|
-- Контактор дверей (КД)
|
||||||
self.Train:LoadSystem("KD","Relay","REV-811T",{ bass = true, pickup_current = 0.04*math.random() + 0.46, hasCoil = true })
|
self.Train:LoadSystem("KD","Relay","REV-811T",{ bass = true, pickup_current = 0.04*math.random() + 0.16 })
|
||||||
-- Реле остановки (РО)
|
-- Реле остановки (РО)
|
||||||
self.Train:LoadSystem("RO","Relay","KPD-110E",{ bass = true, close_time = 0, hasCoil = true--[[ , close_time = 0.1--]] })
|
self.Train:LoadSystem("RO","Relay","KPD-110E",{ bass = true, close_time = 0--[[ , close_time = 0.1--]] })
|
||||||
end
|
end
|
||||||
|
|
||||||
function TRAIN_SYSTEM:Think()
|
function TRAIN_SYSTEM:Think()
|
||||||
|
|||||||
@@ -8,8 +8,10 @@ Metrostroi.DefineSystem("Relay")
|
|||||||
|
|
||||||
local relay_types = {
|
local relay_types = {
|
||||||
["PK-162"] = {
|
["PK-162"] = {
|
||||||
|
hasCoil = true,
|
||||||
pneumatic = true,
|
pneumatic = true,
|
||||||
contactor = true,
|
contactor = true,
|
||||||
|
pickup_current = 0.015*math.random() + 0.085,
|
||||||
},
|
},
|
||||||
["Switch"] = {
|
["Switch"] = {
|
||||||
contactor = true,
|
contactor = true,
|
||||||
@@ -31,9 +33,55 @@ local relay_types = {
|
|||||||
open_time = 0,
|
open_time = 0,
|
||||||
},
|
},
|
||||||
["ARS"] = {
|
["ARS"] = {
|
||||||
|
hasCoil = true,
|
||||||
close_time = 0,
|
close_time = 0,
|
||||||
open_time = 0,
|
open_time = 0,
|
||||||
}
|
},
|
||||||
|
["ARS-DOP"] = {
|
||||||
|
hasCoil = true,
|
||||||
|
pickup_current = 0.01*math.random() + 0.04,
|
||||||
|
},
|
||||||
|
["KPD-110E"] = {
|
||||||
|
hasCoil = true,
|
||||||
|
coil_res = 50,
|
||||||
|
},
|
||||||
|
["REV-813T"] = {
|
||||||
|
hasCoil = true,
|
||||||
|
},
|
||||||
|
["REV-814T"] = {
|
||||||
|
hasCoil = true,
|
||||||
|
},
|
||||||
|
["REV-811T"] = {
|
||||||
|
hasCoil = true,
|
||||||
|
},
|
||||||
|
["REV-821"] = {
|
||||||
|
hasCoil = true,
|
||||||
|
},
|
||||||
|
["PR-143"] = {
|
||||||
|
hasCoil = true,
|
||||||
|
},
|
||||||
|
["KPP-113"] = {
|
||||||
|
hasCoil = true,
|
||||||
|
},
|
||||||
|
["KPD-110"] = {
|
||||||
|
hasCoil = true,
|
||||||
|
},
|
||||||
|
["KPP-110"] = {
|
||||||
|
hasCoil = true,
|
||||||
|
coil_res = 85,
|
||||||
|
},
|
||||||
|
["REM-651D"] = {
|
||||||
|
hasCoil = true,
|
||||||
|
},
|
||||||
|
["R-52B"] = {
|
||||||
|
hasCoil = true,
|
||||||
|
},
|
||||||
|
["RPUZ-114-T-UHLZA"] = {
|
||||||
|
hasCoil = true,
|
||||||
|
},
|
||||||
|
["TRTP-115"] = {
|
||||||
|
hasCoil = true,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
function TRAIN_SYSTEM:Initialize(parameters,extra_parameters)
|
function TRAIN_SYSTEM:Initialize(parameters,extra_parameters)
|
||||||
@@ -45,7 +93,7 @@ function TRAIN_SYSTEM:Initialize(parameters,extra_parameters)
|
|||||||
if relay_types[relay_type] then
|
if relay_types[relay_type] then
|
||||||
parameters = relay_types[relay_type]
|
parameters = relay_types[relay_type]
|
||||||
else
|
else
|
||||||
--print("[sys_relay.lua] Unknown relay type: "..parameters)
|
print("[sys_relay.lua] Unknown relay type: "..parameters, self.Name)
|
||||||
parameters = {}
|
parameters = {}
|
||||||
end
|
end
|
||||||
parameters.relay_type = relay_type
|
parameters.relay_type = relay_type
|
||||||
@@ -74,14 +122,12 @@ function TRAIN_SYSTEM:Initialize(parameters,extra_parameters)
|
|||||||
parameters.latched = parameters.latched or false
|
parameters.latched = parameters.latched or false
|
||||||
-- Should relay be spring-returned to initial position
|
-- Should relay be spring-returned to initial position
|
||||||
parameters.returns = parameters.returns or (not parameters.latched)
|
parameters.returns = parameters.returns or (not parameters.latched)
|
||||||
-- Relay has coil (no by default)
|
|
||||||
parameters.hasCoil = parameters.hasCoil
|
|
||||||
-- Trigger level for the relay
|
-- Trigger level for the relay
|
||||||
parameters.trigger_level = parameters.trigger_level or 0.5
|
parameters.trigger_level = parameters.trigger_level or 0.5
|
||||||
-- Relay pickup current, A
|
-- Relay pickup current, A
|
||||||
parameters.pickup_current = parameters.pickup_current or 0.008*math.random() + 0.03
|
parameters.pickup_current = parameters.pickup_current or 0.008*math.random() + 0.028
|
||||||
-- Relay holding current, A
|
-- Relay holding current, A
|
||||||
parameters.holding_current = parameters.holding_current or 0.002*math.random() + 0.01
|
parameters.holding_current = parameters.holding_current or 0.006*math.random() + 0.011
|
||||||
-- Relay coil resistance, Ohm
|
-- Relay coil resistance, Ohm
|
||||||
parameters.coil_res = parameters.coil_res or parameters.hasCoil and math.random(100,300) or 1e12
|
parameters.coil_res = parameters.coil_res or parameters.hasCoil and math.random(100,300) or 1e12
|
||||||
for k,v in pairs(parameters) do
|
for k,v in pairs(parameters) do
|
||||||
@@ -298,7 +344,6 @@ function TRAIN_SYSTEM:Think(dT)
|
|||||||
self.SpuriousTripTimer = nil
|
self.SpuriousTripTimer = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
--print("РД = ",self.Train.Battery.Consumers[self.Train.RD])
|
|
||||||
if self.hasCoil then
|
if self.hasCoil then
|
||||||
self.Current = self.TargetValue*self.Train.Battery.eds_eq/self.coil_res
|
self.Current = self.TargetValue*self.Train.Battery.eds_eq/self.coil_res
|
||||||
end
|
end
|
||||||
@@ -309,7 +354,6 @@ function TRAIN_SYSTEM:Think(dT)
|
|||||||
-- Switch relay
|
-- Switch relay
|
||||||
if self.ChangeTime and (self.Time > self.ChangeTime) and not self.SpuriousTripTimer then
|
if self.ChangeTime and (self.Time > self.ChangeTime) and not self.SpuriousTripTimer then
|
||||||
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
|
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 and self.Value ~= self.TargetValue then
|
||||||
if self.bass_separate then
|
if self.bass_separate then
|
||||||
if self.TargetValue > 0 then
|
if self.TargetValue > 0 then
|
||||||
@@ -322,7 +366,6 @@ function TRAIN_SYSTEM:Think(dT)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
self.Value = self.TargetValue
|
self.Value = self.TargetValue
|
||||||
--self.Train.Battery.Consumers[self][1] = self.Value
|
|
||||||
self.ChangeTime = nil
|
self.ChangeTime = nil
|
||||||
|
|
||||||
-- Age relay a little
|
-- Age relay a little
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ Metrostroi.DefineSystem("YAR_13B")
|
|||||||
|
|
||||||
function TRAIN_SYSTEM:Initialize()
|
function TRAIN_SYSTEM:Initialize()
|
||||||
-- Реле перегрузки (РПЛ)
|
-- Реле перегрузки (РПЛ)
|
||||||
self.Train:LoadSystem("RPL","Relay","RM3001", {coil_res = 73, pickup_current = 0.012, hasCoil = true})--, { trigger_level = 1300 })
|
self.Train:LoadSystem("RPL","Relay","RM3001", {coil_res = 73, pickup_current = 0.02, hasCoil = true})--, { trigger_level = 1300 })
|
||||||
-- Групповое реле перегрузки 1-3 (РП1-3)
|
-- Групповое реле перегрузки 1-3 (РП1-3)
|
||||||
self.Train:LoadSystem("RP1_3","Relay","RM3001",{ trigger_level = 760 }) --630 })
|
self.Train:LoadSystem("RP1_3","Relay","RM3001",{ trigger_level = 760 }) --630 })
|
||||||
-- Групповое реле перегрузки 2-4 (РП2-4)
|
-- Групповое реле перегрузки 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
|
-- 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,pickup_current = 0.001, hasCoil = true })
|
self.Train:LoadSystem("NR","Relay","R3150", { power_source = "None", coil_res = 690,pickup_current = 0.03, hasCoil = true })
|
||||||
-- Реле системы управления
|
-- Реле системы управления
|
||||||
self.Train:LoadSystem("RSU","Relay","R3100", {coil_res = 275,pickup_current = 0.003, hasCoil = true})
|
self.Train:LoadSystem("RSU","Relay","R3100", {coil_res = 275,pickup_current = 0.03, hasCoil = true})
|
||||||
self.Train:LoadSystem("RU","Relay","R3100")
|
self.Train:LoadSystem("RU","Relay","R3100")
|
||||||
|
|
||||||
-- Реле заземления (РЗ-1, РЗ-2, РЗ-3)
|
-- Реле заземления (РЗ-1, РЗ-2, РЗ-3)
|
||||||
self.Train:LoadSystem("RZ_1","Relay","RM3001", {coil_res = 338,pickup_current = 0.003, hasCoil = true})
|
self.Train:LoadSystem("RZ_1","Relay","RM3001", {coil_res = 338,pickup_current = 0.03, hasCoil = true})
|
||||||
self.Train:LoadSystem("RZ_2","Relay","RM3001", {coil_res = 73,pickup_current = 0.012, hasCoil = true})
|
self.Train:LoadSystem("RZ_2","Relay","RM3001", {coil_res = 73,pickup_current = 0.03, hasCoil = true})
|
||||||
self.Train:LoadSystem("RZ_3","Relay","RM3001")
|
self.Train:LoadSystem("RZ_3","Relay","RM3001")
|
||||||
-- Возврат реле перегрузки (РПвозврат)
|
-- Возврат реле перегрузки (РПвозврат)
|
||||||
self.Train:LoadSystem("RPvozvrat","Relay","RM3001",{
|
self.Train:LoadSystem("RPvozvrat","Relay","RM3001",{
|
||||||
@@ -36,21 +36,21 @@ function TRAIN_SYSTEM:Initialize()
|
|||||||
})
|
})
|
||||||
|
|
||||||
-- Реле времени РВ1
|
-- Реле времени РВ1
|
||||||
self.Train:LoadSystem("RV1","Relay","RM3100",{ open_time = 0.7, coil_res = 31.7,pickup_current = 0.004, hasCoil = true }) --указаны сопротивления обмоток СДРК
|
self.Train:LoadSystem("RV1","Relay","RM3100",{ open_time = 0.7, coil_res = 31.7,pickup_current = 0.04, hasCoil = true }) --указаны сопротивления обмоток СДРК
|
||||||
-- Реле времени РВ2 (задерживает отключение ЛК2)
|
-- Реле времени РВ2 (задерживает отключение ЛК2)
|
||||||
self.Train:LoadSystem("RV2","Relay","RM3100",{ open_time = 0.7, coil_res = 200,pickup_current = 0.004, hasCoil = true })
|
self.Train:LoadSystem("RV2","Relay","RM3100",{ open_time = 0.7, coil_res = 200,pickup_current = 0.035, hasCoil = true })
|
||||||
self.Train:LoadSystem("RR","Relay","RPU-116T", { coil_res = 160, pickup_current = 0.005, hasCoil = true })
|
self.Train:LoadSystem("RR","Relay","RPU-116T", { coil_res = 160, pickup_current = 0.024, hasCoil = true })
|
||||||
|
|
||||||
-- Реле ручного тормоза (РРТ)
|
-- Реле ручного тормоза (РРТ)
|
||||||
self.Train:LoadSystem("RRT","Relay", {coil_res = 28, hasCoil = true})
|
self.Train:LoadSystem("RRT","Relay", {coil_res = 28, hasCoil = true})
|
||||||
-- Реле резервного пуска (РРП)
|
-- Реле резервного пуска (РРП)
|
||||||
self.Train:LoadSystem("RRP","Relay", {coil_res = 162,pickup_current = 0.005, hasCoil = true})
|
self.Train:LoadSystem("RRP","Relay", {coil_res = 162,pickup_current = 0.025, hasCoil = true})
|
||||||
-- Стоп-реле (СР1)
|
-- Стоп-реле (СР1)
|
||||||
self.Train:LoadSystem("SR1","Relay","RM3000",{ iterations=16,open_time=0,coil_res=3.34,pickup_current = 0.003, hasCoil = true }) --указаны сопротивления обмоток СДРК
|
self.Train:LoadSystem("SR1","Relay","RM3000",{ iterations=16,open_time=0,coil_res=3.34,pickup_current = 0.03, hasCoil = true }) --указаны сопротивления обмоток СДРК
|
||||||
-- Реле контроля реверсоров
|
-- Реле контроля реверсоров
|
||||||
self.Train:LoadSystem("RKR","Relay","RM3000", {coil_res = 372,pickup_current = 0.003, hasCoil = true})
|
self.Train:LoadSystem("RKR","Relay","RM3000", {coil_res = 372,pickup_current = 0.036, hasCoil = true})
|
||||||
-- Реле ускорения, торможения (РУТ)
|
-- Реле ускорения, торможения (РУТ)
|
||||||
self.Train:LoadSystem("RUT","Relay","R-52B", {coil_res = 25, hasCoil = true})
|
self.Train:LoadSystem("RUT","Relay","R-52B", {coil_res = 25})
|
||||||
|
|
||||||
|
|
||||||
-- Only in Ezh
|
-- Only in Ezh
|
||||||
|
|||||||
@@ -8,16 +8,16 @@ Metrostroi.DefineSystem("YAR_27")
|
|||||||
|
|
||||||
function TRAIN_SYSTEM:Initialize(parameters)
|
function TRAIN_SYSTEM:Initialize(parameters)
|
||||||
-- Реле дверей (РД)
|
-- Реле дверей (РД)
|
||||||
self.Train:LoadSystem("RD","Relay","REV-821",{ close_time = 0.1, coil_res = 448, pickup_current = 0.002, hasCoil = true })
|
self.Train:LoadSystem("RD","Relay","REV-821",{ close_time = 0.1, coil_res = 448, pickup_current = 0.022 })
|
||||||
-- Реле включения освещения (РВО)
|
-- Реле включения освещения (РВО)
|
||||||
self.Train:LoadSystem("RVO","Relay","REV-814T",{ open_time = 4.0, coil_res = 21, pickup_current = 0.042, hasCoil = true })
|
self.Train:LoadSystem("RVO","Relay","REV-814T",{ open_time = 4.0, coil_res = 21, pickup_current = 0.042 })
|
||||||
-- Реле времени торможения (РВ3)
|
-- Реле времени торможения (РВ3)
|
||||||
self.Train:LoadSystem("RV3","Relay","REV-813T",{ open_time = 2.3, coil_res = 244, pickup_current = 0.004, hasCoil = true })
|
self.Train:LoadSystem("RV3","Relay","REV-813T",{ open_time = 2.3, coil_res = 244, pickup_current = 0.032 })
|
||||||
-- Реле тока (РТ2)
|
-- Реле тока (РТ2)
|
||||||
self.Train:LoadSystem("RT2","Relay","REV-830",{ trigger_level = 130 }) -- A
|
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, hasCoil = true}) --UNREALISTIC Repeater for RT2 for MSK trains
|
self.Train:LoadSystem("RT2r","Relay","",{ close_time = 0, open_time = 0.6}) --UNREALISTIC Repeater for RT2 for MSK trains
|
||||||
-- Реле контроля тормозного тока (РКТТ)
|
-- Реле контроля тормозного тока (РКТТ)
|
||||||
self.Train:LoadSystem("RKTT","Relay","R-52B", { coil_res = 129, pickup_current = 0.008, hasCoil = true })
|
self.Train:LoadSystem("RKTT","Relay","R-52B", { coil_res = 129, pickup_current = 0.018 })
|
||||||
self.Train.RKTTsh = 1
|
self.Train.RKTTsh = 1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user