1
0
mirror of https://github.com/metrostroi-repo/MetrostroiAddon.git synced 2026-05-02 00:42:29 +00:00
Files
MetrostroiAddon/lua/metrostroi/systems/sys_yar_27.lua
2024-07-09 17:17:47 +03:00

60 lines
2.9 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
--------------------------------------------------------------------------------
-- Box with relays (YaR-27)
--------------------------------------------------------------------------------
-- Copyright (C) 2013-2018 Metrostroi Team & FoxWorks Aerospace s.r.o.
-- Contains proprietary code. See license.txt for additional information.
--------------------------------------------------------------------------------
Metrostroi.DefineSystem("YAR_27")
function TRAIN_SYSTEM:Initialize(parameters)
-- Реле дверей (РД)
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.5, coil_res = 21, pickup_current = 0.042 })
-- Реле времени торможения (РВ3)
self.Train:LoadSystem("RV3","Relay","REV-813T",{ open_time = 2.3, coil_res = 244, pickup_current = 0.032 })
-- Реле тока (РТ2)
self.Train:LoadSystem("RT2","Relay","REV-830",{ trigger_level = 130 }) -- A
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.018 }]])
self.Train.RKTTsh = 1
end
function TRAIN_SYSTEM:Inputs()
return { "NoRKTT" }
end
function TRAIN_SYSTEM:Outputs()
--return { "RKTTClose" , "RKTTOpen", "RKTTCurrent"}
end
function TRAIN_SYSTEM:TriggerInput(name,value)
if name == "NoRKTT" then
self.NoRKTT = value > 0
end
end
function TRAIN_SYSTEM:Think()
local Train = self.Train
-- RT2 relay operation
Train.RT2:TriggerInput("Set",Train.Electric.IRT2)
if self.NoRKTT then return end
Train.RT2r:TriggerInput("Set",Train.RT2.Value)
--self.RUTTarget = 250 + 150*self.WeightLoadRatio
self.RKTTCurrent = Train.Electric.IRT2*Train.RKTTsh--(math.abs(Train.Electric.I13) + math.abs(Train.Electric.I24))*Train:ReadTrainWire(6)
--self.RKTTClose = 275 + 50*self.WeightLoadRatio --125
--self.RKTTOpen = 370 + 52*self.WeightLoadRatio --130
--self.RKTTClose = 240 + 100*self.Train.Pneumatic.WeightLoadRatio --125
--self.RKTTOpen = 335 + 130*self.Train.Pneumatic.WeightLoadRatio --130
--self.RKTTClose = 380 + 120*self.Train.Pneumatic.WeightLoadRatio*Train.RUTavt --125
--self.RKTTOpen = 460 + 120*self.Train.Pneumatic.WeightLoadRatio*Train.RUTavt --130
self.RKTTClose = 500 - 120*(1-self.Train.Pneumatic.WeightLoadRatio)*Train.RUTavt --125
self.RKTTOpen = 580 - 120*(1-self.Train.Pneumatic.WeightLoadRatio)*Train.RUTavt --130
if self.RKTTCurrent < self.RKTTClose then
Train.RKTT:TriggerInput("Set",false)
else
Train.RKTT:TriggerInput("Set",self.RKTTCurrent >= self.RKTTOpen)
end
end