1
0
mirror of https://github.com/metrostroi-repo/MetrostroiAddon.git synced 2026-05-02 00:42:29 +00:00

Almost victory but still need testing and adjusting

This commit is contained in:
Moon Horse
2024-07-04 16:29:41 +03:00
parent ef4a9ff3f2
commit 14310e2cfe
5 changed files with 15 additions and 24 deletions

View File

@@ -385,7 +385,7 @@ function ENT:Think()
self.PowerSupply:TriggerInput("3x2",self.pcrlxtimer and 1 or 0) --BPSN overheat protection in case of RZP button is being pressed constantly self.PowerSupply:TriggerInput("3x2",self.pcrlxtimer and 1 or 0) --BPSN overheat protection in case of RZP button is being pressed constantly
----------------------------------*****************************-------------------------------- ----------------------------------*****************************--------------------------------
self:SetPackedRatio("BatteryVoltage",(self.eds_eq)/150.0) self:SetPackedRatio("BatteryVoltage",(self.Battery.eds_eq)/150.0)
self:SetPackedRatio("BatteryCurrent",self.BattCurrent/1000) self:SetPackedRatio("BatteryCurrent",self.BattCurrent/1000)
self:SetPackedRatio("EnginesCurrent", 0.5 + 0.5*(self.Electric.I24/500.0)) self:SetPackedRatio("EnginesCurrent", 0.5 + 0.5*(self.Electric.I24/500.0))

View File

@@ -713,7 +713,7 @@ function ENT:Think()
self.PowerSupply:TriggerInput("3x2",self.pcrlxtimer and 1 or 0) --BPSN overheat protection in case of RZP button is being pressed constantly self.PowerSupply:TriggerInput("3x2",self.pcrlxtimer and 1 or 0) --BPSN overheat protection in case of RZP button is being pressed constantly
----------------------------------*****************************-------------------------------- ----------------------------------*****************************--------------------------------
self:SetPackedRatio("BatteryVoltage",(self.eds_eq)/150.0) self:SetPackedRatio("BatteryVoltage",(self.Battery.eds_eq)/150.0)
self:SetPackedBool("Compressor",Pneumatic.Compressor > 0) self:SetPackedBool("Compressor",Pneumatic.Compressor > 0)
self:SetPackedBool("Buzzer",Panel.Ring >= 1) self:SetPackedBool("Buzzer",Panel.Ring >= 1)

View File

@@ -97,33 +97,21 @@ function TRAIN_SYSTEM:Think(dT)
--self.Ibatt_sigma = 0 --self.Ibatt_sigma = 0
--self.CCcurrent_sigma = 0 --self.CCcurrent_sigma = 0
for k,v in ipairs(self.Train.WagonList) do
if v.PowerSupply.X2_2 > 0 and v.A24.Value > 0 then
hvcounter = hvcounter + 1
end
end
--a "two-node method" of 10's wire voltage computing --a "two-node method" of 10's wire voltage computing
-- разобраться с принципом подзаряда АКБ в момент отключения тумблера
for k,v in ipairs(self.Train.WagonList) do for k,v in ipairs(self.Train.WagonList) do
nodecurr_sum = nodecurr_sum + v.A56.Value*(v.VB.Value*v.Battery.Voltage/v.Battery.IResistance + v.PowerSupply.X2_1*v.A24.Value*v.PowerSupply.VoltageOut/v.PowerSupply.IResistance) nodecurr_sum = nodecurr_sum + v.A56.Value*(v.VB.Value*v.Battery.Voltage/v.Battery.IResistance + v.PowerSupply.X2_1*v.A24.Value*v.PowerSupply.VoltageOut/v.PowerSupply.IResistance)
--+ 1/((1 - v.VB.Value*v.A49.Value)*1e12 + 1e3) --+ 1/((1 - v.VB.Value*v.A49.Value)*1e12 + 1e3)
branchcond_sum = branchcond_sum + GetBranchCondSum(v.Battery.Consumers) + v.A56.Value*(v.VB.Value/v.Battery.IResistance + v.PowerSupply.X2_1*v.A24.Value/v.PowerSupply.IResistance) branchcond_sum = branchcond_sum + GetBranchCondSum(v.Battery.Consumers) + v.A56.Value*(v.VB.Value/v.Battery.IResistance + v.PowerSupply.X2_1*v.A24.Value/v.PowerSupply.IResistance)-- + (1-v.PowerSupply.X2_1*v.A24.Value)/1e9)
-- let's try to do this in one cycle (not quite sure if it won't create any issues)
--[[branchcond_sum = branchcond_sum + 1/(v.LK4.Value > 0 and 20 or 1e12) + 1/(v.RV1.Value > 0 and 10 or 1e12) if v.PowerSupply.X2_2 > 0 and v.A24.Value > 0 then
+ 1/(v.KK.Value > 0 and 24 or 1e12) + 1/(1e3) hvcounter = hvcounter + 1
+ 1/(v.RC1 and v.RC1.Value > 0 and 32 or 1e12) end
+ 1/(v.Panel.Headlights1 and v.Panel.Headlights1 > 0 and 38 or 1e12)
+ 1/(v.Panel.Headlights2 and v.Panel.Headlights2 > 0 and 38 or 1e12)
+ v.A56.Value*(v.VB.Value/v.Battery.IResistance + v.PowerSupply.X2_1*v.A24.Value/v.PowerSupply.IResistance)]]
end end
eds_eq = nodecurr_sum/branchcond_sum eds_eq = nodecurr_sum/branchcond_sum
--print(eds_eq, nodecurr_sum, branchcond_sum) --print(eds_eq, nodecurr_sum, branchcond_sum)
for k,v in ipairs(self.Train.WagonList) do for k,v in ipairs(self.Train.WagonList) do
v.PowerSupply.car_control_load = eds_eq*GetBranchCondSum(v.Battery.Consumers) v.PowerSupply.car_control_load = eds_eq*GetBranchCondSum(v.Battery.Consumers)
--[[v.PowerSupply.car_control_load = eds_eq*(1/(v.LK4.Value > 0 and 20 or 1e12) + 1/(v.RV1.Value > 0 and 10 or 1e12)
+ 1/(v.RC1 and v.RC1.Value > 0 and 32 or 1e12)
+ 1/(v.Panel.Headlights1 and v.Panel.Headlights1 > 0 and 38 or 1e12)
+ 1/(v.Panel.Headlights2 and v.Panel.Headlights2 > 0 and 38 or 1e12)
+ 1/(v.KK.Value > 0 and 24 or 1e12))]]
v.Battery.Ibatt = math.min(1,(2-self.Train.PA1.Value-self.Train.PA2.Value)) v.Battery.Ibatt = math.min(1,(2-self.Train.PA1.Value-self.Train.PA2.Value))
*(math.min(1,(v.VB.Value*v.A56.Value+v.A24.Value))*v.VB.Value*((v.A56.Value*(eds_eq - v.Battery.Voltage) *(math.min(1,(v.VB.Value*v.A56.Value+v.A24.Value))*v.VB.Value*((v.A56.Value*(eds_eq - v.Battery.Voltage)
+ v.PowerSupply.X2_1*(1-v.A56.Value)*(v.PowerSupply.VoltageOut*v.A24.Value - v.Battery.Voltage))))/v.Battery.IResistance -- math.max(0,(2.4*(v.Battery.Voltage/v.Battery.StartVoltage)-2.39)) + v.PowerSupply.X2_1*(1-v.A56.Value)*(v.PowerSupply.VoltageOut*v.A24.Value - v.Battery.Voltage))))/v.Battery.IResistance -- math.max(0,(2.4*(v.Battery.Voltage/v.Battery.StartVoltage)-2.39))

View File

@@ -20,8 +20,8 @@ function TRAIN_SYSTEM:Initialize()
self.X6_2 = 0 self.X6_2 = 0
self.X2_1 = 0 self.X2_1 = 0
self.OutputVoltage = math.random(78,82) -- volts self.OutputVoltage = 76--math.random(78,82) -- volts
self.IResistance = 0.01 --Ohm (сам выдумал, примерно на порядок ниже, чем у АКБ) self.IResistance = 0.01 --Ohm (сам выдумал, примерно на полтора порядка ниже, чем у АКБ)
self.car_control_load= 0 --Amp self.car_control_load= 0 --Amp
self.VoltageOut = 0 self.VoltageOut = 0
@@ -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", "VoltageOut" } return { "X2_2", "X6_2", "car_control_load", "VoltageOut", "OutputVoltage" }
end end
@@ -61,5 +61,6 @@ function TRAIN_SYSTEM:Think()
self.X2_2 = Train.Electric.Aux750V*self.Active self.X2_2 = Train.Electric.Aux750V*self.Active
self.X6_2 = self.Active self.X6_2 = self.Active
self.VoltageOut = self.X2_1*((self.OutputVoltage - self.car_control_load*self.IResistance) + (Train.Electric.Aux750V - 600)*2/375) --self.VoltageOut = self.X2_1*((self.OutputVoltage - self.car_control_load*self.IResistance) + (Train.Electric.Aux750V - 600)*2/375)
self.VoltageOut = self.X2_1*(self.OutputVoltage + (Train.Electric.Aux750V - 600)*8/375)
end end

View File

@@ -62,9 +62,11 @@ local relay_types = {
}, },
["KPP-113"] = { ["KPP-113"] = {
hasCoil = true, hasCoil = true,
coil_res = 156,
}, },
["KPD-110"] = { ["KPD-110"] = {
hasCoil = true, hasCoil = true,
coil_res = math.random(247,273),
}, },
["KPP-110"] = { ["KPP-110"] = {
hasCoil = true, hasCoil = true,