From a806be8f32460d82bc079a27ef1a4ea699c513eb Mon Sep 17 00:00:00 2001 From: Moon Horse Date: Fri, 19 Apr 2024 19:07:28 +0300 Subject: [PATCH] Another temporarily commit --- lua/metrostroi/systems/sys_81_717_electric.lua | 2 +- lua/metrostroi/systems/sys_battery.lua | 3 +++ lua/metrostroi/systems/sys_relay.lua | 10 +++++++--- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/lua/metrostroi/systems/sys_81_717_electric.lua b/lua/metrostroi/systems/sys_81_717_electric.lua index c8c8638..d702884 100644 --- a/lua/metrostroi/systems/sys_81_717_electric.lua +++ b/lua/metrostroi/systems/sys_81_717_electric.lua @@ -60,7 +60,7 @@ function TRAIN_SYSTEM:SolveAllInternalCircuits(Train,dT,firstIter) --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 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 diff --git a/lua/metrostroi/systems/sys_battery.lua b/lua/metrostroi/systems/sys_battery.lua index 04e690a..cba1dd9 100644 --- a/lua/metrostroi/systems/sys_battery.lua +++ b/lua/metrostroi/systems/sys_battery.lua @@ -36,6 +36,9 @@ function TRAIN_SYSTEM:Initialize() self.ComputerCar = false end +-- self.Consumers is a table of relays with the next structure: +-- [] = {, , } + function TRAIN_SYSTEM:Inputs() return { "Charge", "Dischargeable", "InitialVoltage", "CarType" } end diff --git a/lua/metrostroi/systems/sys_relay.lua b/lua/metrostroi/systems/sys_relay.lua index e8ef39e..51f2ad8 100644 --- a/lua/metrostroi/systems/sys_relay.lua +++ b/lua/metrostroi/systems/sys_relay.lua @@ -75,8 +75,9 @@ 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.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) + 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) for k,v in pairs(parameters) do @@ -293,7 +294,10 @@ function TRAIN_SYSTEM:Think(dT) -- 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} + self.Train.Battery.Consumers[self] = {0,self.coil_res,0} + end + if self.ChangeTime and self.TargetValue == 1.0 then + self.Train.Battery.Consumers[self][3] = self.Train.Battery.eds_eq/self.coil_res end -- Switch relay if self.ChangeTime and (self.Time > self.ChangeTime) and not self.SpuriousTripTimer then