DmitrMakeev commited on
Commit
73bfb21
·
verified ·
1 Parent(s): b105546

Update nutri_call.html

Browse files
Files changed (1) hide show
  1. nutri_call.html +12 -45
nutri_call.html CHANGED
@@ -815,11 +815,7 @@ function data_out(response) {
815
  }
816
  }
817
 
818
- // Обновляем EC если есть
819
- const ecInput = document.getElementById('profile_ec');
820
- if (ecInput && response.total_ppm) {
821
- ecInput.value = (response.total_ppm / 700).toFixed(2); // Пример конвертации ppm в EC
822
- }
823
 
824
  console.log("Данные успешно обновлены");
825
  }
@@ -836,59 +832,30 @@ function calculateEC(data, temperature) {
836
  const profile = data.actual_profile;
837
  let totalEC = 0;
838
 
839
- // Суммируем EC для каждого элемента
840
- for (const [element, ppm] of Object.entries(profile)) {
841
- if (ecConstants[element]) {
 
 
 
 
842
  const elementEC = ppm * ecConstants[element];
843
  totalEC += elementEC;
844
- console.log(`EC для ${element}: ${elementEC.toFixed(3)} (ppm=${ppm}, const=${ecConstants[element]})`);
845
  } else {
846
- console.warn(`Константа для элемента ${element} не найдена.`);
847
  }
848
  }
849
 
850
- console.log(`Общая EC без компенсации: ${totalEC.toFixed(3)}`);
851
 
852
  // Применяем температурную компенсацию
853
  const compensatedEC = totalEC * (1 + 0.02 * (temperature - 25));
854
- console.log(`Компенсированная EC: ${compensatedEC.toFixed(3)} (при температуре ${temperature}°C)`);
855
 
856
  return compensatedEC;
857
  }
858
 
859
- // Функция для расчета соотношения NPK
860
- function updateNPK(data) {
861
- console.log("=== РАСЧЕТ СООТНОШЕНИЯ NPK ===");
862
-
863
- // Извлекаем значения из actual_profile
864
- const nValue = data.actual_profile["N (NH4+)"] + data.actual_profile["N (NO3-)"];
865
- const pValue = data.actual_profile["P"];
866
- const kValue = data.actual_profile["K"];
867
-
868
- // Проверяем, что значения существуют
869
- if (nValue !== undefined && pValue !== undefined && kValue !== undefined) {
870
- console.log(`Значения NPK: N=${nValue}, P=${pValue}, K=${kValue}`);
871
-
872
- // Находим минимальное значение
873
- const minValue = Math.min(nValue, pValue, kValue);
874
-
875
- // Рассчитываем соотношение
876
- const nRatio = Math.round(nValue / minValue);
877
- const pRatio = Math.round(pValue / minValue);
878
- const kRatio = Math.round(kValue / minValue);
879
-
880
- console.log(`Соотношение NPK: ${nRatio}:${pRatio}:${kRatio}`);
881
-
882
- // Обновляем поля на странице
883
- document.getElementById("npk-n-value").textContent = nRatio;
884
- document.getElementById("npk-p-value").textContent = pRatio;
885
- document.getElementById("npk-k-value").textContent = kRatio;
886
- } else {
887
- console.error("Ошибка: Значения NPK не найдены в ответе сервера.");
888
- }
889
- }
890
-
891
-
892
 
893
 
894
 
 
815
  }
816
  }
817
 
818
+
 
 
 
 
819
 
820
  console.log("Данные успешно обновлены");
821
  }
 
832
  const profile = data.actual_profile;
833
  let totalEC = 0;
834
 
835
+ // Список значимых элементов для расчета EC
836
+ const significantElements = ["P", "K", "Mg", "Ca", "S", "N (NO3-)", "N (NH4+)"];
837
+
838
+ // Суммируем EC для каждого значимого элемента
839
+ for (const element of significantElements) {
840
+ if (profile[element] && ecConstants[element]) {
841
+ const ppm = profile[element]; // Уже в г/л
842
  const elementEC = ppm * ecConstants[element];
843
  totalEC += elementEC;
844
+ console.log(`EC для ${element}: ${elementEC.toFixed(5)} (ppm=${ppm}, const=${ecConstants[element]})`);
845
  } else {
846
+ console.warn(`Пропущен элемент: ${element}`);
847
  }
848
  }
849
 
850
+ console.log(`Общая EC без компенсации: ${totalEC.toFixed(5)}`);
851
 
852
  // Применяем температурную компенсацию
853
  const compensatedEC = totalEC * (1 + 0.02 * (temperature - 25));
854
+ console.log(`Компенсированная EC: ${compensatedEC.toFixed(5)} (при температуре ${temperature}°C)`);
855
 
856
  return compensatedEC;
857
  }
858
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
859
 
860
 
861