mirror of
https://github.com/metrostroi-repo/MetrostroiAddon.git
synced 2026-05-02 00:42:29 +00:00
Another temporarily commit
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -36,6 +36,9 @@ function TRAIN_SYSTEM:Initialize()
|
||||
self.ComputerCar = false
|
||||
end
|
||||
|
||||
-- self.Consumers is a table of relays with the next structure:
|
||||
-- [<relay>] = {<relay.Value>, <relay.coil_res>, <relay.current>}
|
||||
|
||||
function TRAIN_SYSTEM:Inputs()
|
||||
return { "Charge", "Dischargeable", "InitialVoltage", "CarType" }
|
||||
end
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user