DanielKote / Foreman2

Visual planning tool for Factorio
Other
158 stars 14 forks source link

PY Electric Boiler issue #48

Closed mrozpara closed 1 year ago

mrozpara commented 1 year ago

PY Electric Boiler is causing error in EditRecipePanel.cs line: private void InitializeRates() { (...) FixedAssemblerInput.Value = Math.Min(FixedAssemblerInput.Maximum, (decimal)nodeData.ActualAssemblerCount); (...) }

Root cause: DCache.BoilerAdditionalProcessing: aEntity.Speed = (double)(aEntity.EnergyConsumption / ((temp - ingredient.DefaultTemperature) * ingredient.SpecificHeatCapacity * 60));

For Boilers Forman is trying to calculate production speed based on the difference of input/output temperatures and Energy from fuel.

For EnergySource 'Electric': case EnergySource.Electric: entity.EnergyDrain = (double)objJToken["drain"] * 60f; //seconds entity.EnergyConsumption = (double)objJToken["energy_usage"] * 60f; //seconds break;

... and LUA export for Electric_Boiler is returning Energy_Usage as "0"

I don't know if it's a bug in PY mod? Or in this particular case Foreman should calculate Electric Boiler in a different way? BTW. in case of SeaBlock Electric Boiler is set as "assembler" not boiler - therefore it's not causing an issue...

Any help on understanding logic behind Boilers and Energy_Usage will be appreciated...

gillett-hernandez commented 1 year ago

This issue is fixed on my fork I think. You can check the code or commit history to see how I fixed it.

On Thu, Nov 17, 2022, 08:00 Mirosław @.***> wrote:

PY Electric Boiler is causing error in EditRecipePanel.cs line: private void InitializeRates() { (...) FixedAssemblerInput.Value = Math.Min(FixedAssemblerInput.Maximum, (decimal)nodeData.ActualAssemblerCount); (...) }

Root cause: DCache.BoilerAdditionalProcessing: aEntity.Speed = (double)(aEntity.EnergyConsumption / ((temp - ingredient.DefaultTemperature) ingredient.SpecificHeatCapacity 60));

For Boilers Forman is trying to calculate production speed based on the difference of input/output temperatures and Energy from fuel.

For EnergySource 'Electric': case EnergySource.Electric: entity.EnergyDrain = (double)objJToken["drain"] 60f; //seconds entity.EnergyConsumption = (double)objJToken["energy_usage"] 60f; //seconds break;

... and LUA export for Electric_Boiler is returning Energy_Usage as "0"

I don't know if it's a bug in PY mod? Or in this particular case Foreman should calculate Electric Boiler in a different way? BTW. in case of SeaBlock Electric Boiler is set as "assembler" not boiler

  • therefore it's not causing an issue...

Any help on understanding logic behind Boilers and Energy_Usage will be appreciated...

— Reply to this email directly, view it on GitHub https://github.com/DanielKote/Foreman2/issues/48, or unsubscribe https://github.com/notifications/unsubscribe-auth/AALPKUTT3LUOUFLKGU27XPDWIZJCHANCNFSM6AAAAAASDREI5U . You are receiving this because you are subscribed to this thread.Message ID: @.***>

mrozpara commented 1 year ago

great!! now I remember where I have seen "NaN/boiler" words... I was not able to find it in yours release notes - but I can see it in commit comments ;) Thanks!! However - I'm not sure if it's proper solution... For PY there are 3 entities where energy_usage and max_energy_usage have different values - electric boiler (zero value), rocket silo (non-zero), automated smart factory (non-zero). For Seablock - only rocket silo... Maybe "if energy_usage equals zero use max_energy_usage" would be "safer"? But I don't know the real logic behind energy and max_energy...