diff --git a/lua/entities/gmod_subway_81-714_mvm/init.lua b/lua/entities/gmod_subway_81-714_mvm/init.lua index 95179eb..a562e82 100644 --- a/lua/entities/gmod_subway_81-714_mvm/init.lua +++ b/lua/entities/gmod_subway_81-714_mvm/init.lua @@ -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:SetPackedRatio("BatteryVoltage",(self.eds_eq)/150.0) + self:SetPackedRatio("BatteryVoltage",(self.Battery.eds_eq)/150.0) self:SetPackedRatio("BatteryCurrent",self.BattCurrent/1000) self:SetPackedRatio("EnginesCurrent", 0.5 + 0.5*(self.Electric.I24/500.0)) diff --git a/lua/entities/gmod_subway_81-717_mvm/init.lua b/lua/entities/gmod_subway_81-717_mvm/init.lua index acee3d9..9ca22ae 100644 --- a/lua/entities/gmod_subway_81-717_mvm/init.lua +++ b/lua/entities/gmod_subway_81-717_mvm/init.lua @@ -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:SetPackedRatio("BatteryVoltage",(self.eds_eq)/150.0) + self:SetPackedRatio("BatteryVoltage",(self.Battery.eds_eq)/150.0) self:SetPackedBool("Compressor",Pneumatic.Compressor > 0) self:SetPackedBool("Buzzer",Panel.Ring >= 1) diff --git a/lua/metrostroi/systems/sys_battery.lua b/lua/metrostroi/systems/sys_battery.lua index 1328747..ee4873a 100644 --- a/lua/metrostroi/systems/sys_battery.lua +++ b/lua/metrostroi/systems/sys_battery.lua @@ -97,33 +97,21 @@ function TRAIN_SYSTEM:Think(dT) --self.Ibatt_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 + -- разобраться с принципом подзаряда АКБ в момент отключения тумблера 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) --+ 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 + 1/(v.LK4.Value > 0 and 20 or 1e12) + 1/(v.RV1.Value > 0 and 10 or 1e12) - + 1/(v.KK.Value > 0 and 24 or 1e12) + 1/(1e3) - + 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) - + 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) + if v.PowerSupply.X2_2 > 0 and v.A24.Value > 0 then + hvcounter = hvcounter + 1 + end end eds_eq = nodecurr_sum/branchcond_sum --print(eds_eq, nodecurr_sum, branchcond_sum) 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*(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)) *(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)) diff --git a/lua/metrostroi/systems/sys_bpsn.lua b/lua/metrostroi/systems/sys_bpsn.lua index 2981853..7b1c6ce 100644 --- a/lua/metrostroi/systems/sys_bpsn.lua +++ b/lua/metrostroi/systems/sys_bpsn.lua @@ -20,8 +20,8 @@ function TRAIN_SYSTEM:Initialize() self.X6_2 = 0 self.X2_1 = 0 - self.OutputVoltage = math.random(78,82) -- volts - self.IResistance = 0.01 --Ohm (сам выдумал, примерно на порядок ниже, чем у АКБ) + self.OutputVoltage = 76--math.random(78,82) -- volts + self.IResistance = 0.01 --Ohm (сам выдумал, примерно на полтора порядка ниже, чем у АКБ) self.car_control_load= 0 --Amp self.VoltageOut = 0 @@ -34,7 +34,7 @@ function TRAIN_SYSTEM:Inputs() end function TRAIN_SYSTEM:Outputs() - return { "X2_2", "X6_2", "car_control_load", "VoltageOut" } + return { "X2_2", "X6_2", "car_control_load", "VoltageOut", "OutputVoltage" } end @@ -61,5 +61,6 @@ function TRAIN_SYSTEM:Think() self.X2_2 = Train.Electric.Aux750V*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 \ No newline at end of file diff --git a/lua/metrostroi/systems/sys_relay.lua b/lua/metrostroi/systems/sys_relay.lua index e52d96b..7241425 100644 --- a/lua/metrostroi/systems/sys_relay.lua +++ b/lua/metrostroi/systems/sys_relay.lua @@ -62,9 +62,11 @@ local relay_types = { }, ["KPP-113"] = { hasCoil = true, + coil_res = 156, }, ["KPD-110"] = { hasCoil = true, + coil_res = math.random(247,273), }, ["KPP-110"] = { hasCoil = true,