mirror of
https://github.com/metrostroi-repo/MetrostroiAddon.git
synced 2026-05-02 00:42:29 +00:00
Убраны отладочные сообщения
This commit is contained in:
@@ -387,14 +387,6 @@ function ENT:TrainSpawnerUpdate()
|
||||
self.Battery:TriggerInput("CarType",1)
|
||||
--self.Battery:TriggerInput("InitialVoltage",math.random(62,75))
|
||||
self.Battery:TriggerInput("Dischargeable",self:GetNW2Bool("BattCharge"))
|
||||
--[[local ccc = 0
|
||||
self.ComputerCar = false
|
||||
for k,v in ipairs(self.WagonList) do
|
||||
if v.AR63 and v.ComputerCar then ccc = ccc + 1; break end
|
||||
end
|
||||
if ccc == 0 then
|
||||
self.ComputerCar = true
|
||||
end]]
|
||||
math.randomseed(num+817171)
|
||||
if self.CustomSettings then
|
||||
--{"Type","Spawner.717.Type","List",{"Spawner.717.Type.717","Spawner.717.Type.7175"}},
|
||||
|
||||
@@ -100,7 +100,7 @@ function TRAIN_SYSTEM:Think(dT)
|
||||
local eds_eq = self.eds_eq
|
||||
|
||||
-- TODO: реализовать тепловую защиту БПСН от длительных токов свыше 60 А
|
||||
-- сделать возможность заменять сгоревшие предохранители АКБ (не более 10 шт. на состав)
|
||||
-- сделать возможность заменять сгоревшие предохранители АКБ
|
||||
|
||||
--a "two-node method" of 10's wire voltage computing
|
||||
for k,v in ipairs(self.Train.WagonList) do
|
||||
@@ -139,15 +139,15 @@ function TRAIN_SYSTEM:Think(dT)
|
||||
+ BPSN.X2_1*Train.A24.Value*(1-Train.A56.Value*Train.VB.Value)*self.Ibatt
|
||||
|
||||
-- DEBUG
|
||||
if self.Train.A49 and self.Train.A49.Value < 0.5 then
|
||||
--if self.Train.A49 and self.Train.A49.Value < 0.5 then
|
||||
--print(Format("self.nodecurr_sum = %.1f A,\tself.branchcond_sum = %.1f См,\tself.proximity = %.8f",self.nodecurr_sum, self.branchcond_sum,self.proximity))
|
||||
--print(iload_sum, ibatt_sum, isply_sum, isupply)
|
||||
print("BPSN.X2_1 = "..BPSN.X2_1,"R АКБ вн. = "..Train.Battery.IResistance.. " Ом","Счетный вагон: "..(Train.TrainWireLeader and "да" or "нет"))
|
||||
print(Format("БПСН, Iout = %.1f A,\tТок заряда батареи = %.1f A,\tU АКБ цель = %.1f B",BPSN.Iout,self.Ibatt,self.TargetVoltage))
|
||||
print(Format("БПСН, Vout = %.1f B,\tБПСН, ток потр. = %.1f A,\tU 10 пр. = %.1f B",BPSN.VoltageOut,BPSN.Icosume,self.eds_eq))
|
||||
--print(Train.PA1.Value,Train.PA2.Value)
|
||||
print(Format("U АКБ = %.1f B,\tSoC = %.2f %%,\tG load = %.1f См\tПА1, ПА2 = %d, %d\n",self.Voltage,self.SoC,self.sump_cond,Train.PA1.Value,Train.PA2.Value))
|
||||
end
|
||||
--print("BPSN.X2_1 = "..BPSN.X2_1,"R АКБ вн. = "..Train.Battery.IResistance.. " Ом","Счетный вагон: "..(Train.TrainWireLeader and "да" or "нет"))
|
||||
--print(Format("БПСН, Iout = %.1f A,\tТок заряда батареи = %.1f A,\tU АКБ цель = %.1f B",BPSN.Iout,self.Ibatt,self.TargetVoltage))
|
||||
--print(Format("БПСН, Vout = %.1f B,\tБПСН, ток потр. = %.1f A,\tU 10 пр. = %.1f B",BPSN.VoltageOut,BPSN.Icosume,self.eds_eq))
|
||||
--print(Format("Темп. БПСН = %.1f °C",BPSN.Temp))
|
||||
--print(Format("U АКБ = %.1f B,\tSoC = %.2f %%,\tG load = %.1f См\tПА1, ПА2 = %d, %d\n",self.Voltage,self.SoC,self.sump_cond,Train.PA1.Value,Train.PA2.Value))
|
||||
--end
|
||||
-- Calculate state of charge, internal resistance and battery voltage
|
||||
if self.Dischar then
|
||||
self.Capacity = self.Capacity - dT * (self.FullCapacity*0.1/86400) -- make capacity loss ~ 10% per day (just a game abstraction)
|
||||
@@ -230,13 +230,6 @@ function TRAIN_SYSTEM:Think(dT)
|
||||
-- /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
--if self.Train.A54 and self.Train.A54.Value > 0.5 then
|
||||
--local tval = 1
|
||||
--print("Target Voltage = "..self.TargetVoltage, "self.Voltage = "..self.Voltage, "train:",self)
|
||||
--print(self.Train.PowerSupply.car_control_load,self.Ibatt,self.IResistance,dT)
|
||||
--print("self.SoC = "..self.SoC, "self.Ibatt = "..self.Ibatt)
|
||||
--print("self.eds_eq = "..self.eds_eq)
|
||||
--print("self.EthaCE = "..self.EthaCE, "self.IResistance = "..self.IResistance)
|
||||
--print("self.Capacity = "..self.Capacity)
|
||||
--print("self.Train.PA2 = "..self.Train.PA2.Value)
|
||||
--[[
|
||||
EMF_soc=-0.68175*tval^8+8.82823*tval^7-24.43179*tval^6+31.87221*tval^5-23.97881*tval^4+11.24774*tval^3-3.40685*tval^2+0.74692*tval+1.22076
|
||||
Uh_soc=2.62496*tval^8-12.77132*tval^7+22.37586*tval^6-18.04921*tval^5+6.14667*tval^4+0.26467*tval^3-0.82125*tval^2+0.21246*tval+0.02641
|
||||
|
||||
@@ -20,14 +20,20 @@ function TRAIN_SYSTEM:Initialize()
|
||||
self.X6_2 = 0
|
||||
self.X2_1 = 0
|
||||
|
||||
self.OutputVoltage = 76 -- volts
|
||||
self.IResistance = 0.01 -- Ohm (сам выдумал, примерно на полтора порядка ниже, чем у АКБ)
|
||||
--self.car_control_load = 0 -- Amp
|
||||
--self.car_control_sigma = 0 -- Amp
|
||||
self.Icosume = 0 -- 3rd rail current consumption, amp
|
||||
self.Iout = 0 -- output current, amp
|
||||
self.OutputVoltage = 76 -- volts
|
||||
self.IResistance = 0.01 -- Ohm (сам выдумал, примерно на полтора порядка ниже, чем у АКБ)
|
||||
self.Icosume = 0 -- 3rd rail current consumption, amp
|
||||
self.Iout = 0 -- output current, amp
|
||||
self.VoltageOut = 0
|
||||
self.ISumpSetpoint = math.random(25,30) -- overload consumption current protection setpoint
|
||||
self.EnvTemp = 20 -- Celcius degree
|
||||
self.Temp = self.EnvTemp -- internal temperature
|
||||
self.TempThreshold = 90 -- overheat protection threshold
|
||||
self.TempHyst = 5 -- temperature threshold hysteresis
|
||||
|
||||
self.Q = 0
|
||||
self.Q_p = 0
|
||||
self.Q_i = 0
|
||||
|
||||
self.Active = 0
|
||||
self.Train:LoadSystem("ConverterProtection","Relay","Switch", {bass = true})
|
||||
@@ -38,7 +44,7 @@ function TRAIN_SYSTEM:Inputs()
|
||||
end
|
||||
|
||||
function TRAIN_SYSTEM:Outputs()
|
||||
return { "X2_2", "X6_2", "VoltageOut", "OutputVoltage", "Icosume", "Iout" }
|
||||
return { "X2_2", "X6_2", "VoltageOut", "OutputVoltage", "Icosume", "Iout", "Temp" }
|
||||
end
|
||||
|
||||
|
||||
@@ -60,26 +66,24 @@ function TRAIN_SYSTEM:Think()
|
||||
self.VoltageOut = math.max(0,self.X2_1*(Train.Electric.Aux750V - 300)*76/300)
|
||||
end
|
||||
|
||||
--[[if self.car_control_sigma > 0 then
|
||||
self.Iout = self.car_control_sigma
|
||||
for k,v in ipairs(Train.WagonList) do
|
||||
if v ~= Train then
|
||||
self.Iout = math.max(0,self.Iout - v.A24.Value*v.PowerSupply.X2_1*(v.PowerSupply.car_control_load + v.A56.Value*v.Battery.Ibatt))
|
||||
end
|
||||
end
|
||||
self.car_control_sigma = 0
|
||||
end]]
|
||||
self.Icosume = self.VoltageOut*self.Iout/(Train.Electric.Aux750V > 0 and Train.Electric.Aux750V or 1)
|
||||
|
||||
--self.Iout = self.car_control_load
|
||||
self.Icosume = --[[Train.NR.Value*]]self.VoltageOut*self.Iout/(Train.Electric.Aux750V > 0 and Train.Electric.Aux750V or 1)
|
||||
-- temperature calculations (ugly af)
|
||||
--local alpha_p = math.exp(-0.025*(self.Temp - self.EnvTemp)+1.2)
|
||||
--self.dQ = self.Icosume^2*self.IResistance*Train.DeltaTime
|
||||
----self.Q = self.Q + self.dQ
|
||||
--self.Q_i = 4*math.exp(0.04*(self.Temp - self.EnvTemp)-4.6)
|
||||
--self.Q_p = alpha_p*self.dQ
|
||||
--self.Temp = math.min(120, math.max(self.EnvTemp,self.Temp + self.Q_p - self.Q_i*Train.DeltaTime))
|
||||
--self.Temp = 20
|
||||
|
||||
-- Get battery input
|
||||
local XT3_1 = self.X2[5]*self.X2_1
|
||||
if Train.Electric.Aux750V*self.X2_1 > 975 or self.Icosume > self.ISumpSetpoint then
|
||||
Train.RZP:TriggerInput("Close",1)
|
||||
print "-------------------------------------------------------------------------------------------\n"
|
||||
print(Format("Сработала защита БПСН вагона %s:",Train.WagonNumber))
|
||||
print(Format("I потр = %.2f A\tI вых = %.2f A\tI уст = %.2f A\tU кс = %.1f B", self.Icosume, self.Iout, self.ISumpSetpoint, Train.Electric.Aux750V))
|
||||
--print "-------------------------------------------------------------------------------------------\n"
|
||||
--print(Format("Сработала защита БПСН вагона %s:",Train.WagonNumber))
|
||||
--print(Format("I потр = %.2f A\tI вых = %.2f A\tI уст = %.2f A\tU кс = %.1f B", self.Icosume, self.Iout, self.ISumpSetpoint, Train.Electric.Aux750V))
|
||||
--print("Train.Battery.eds_eq = "..Train.Battery.eds_eq, "self.VoltageOut = "..self.VoltageOut)
|
||||
self.X2_1 = 0
|
||||
XT3_1 = 0
|
||||
|
||||
Reference in New Issue
Block a user