Spaces:
Running
Running
Update nutri_call.html
Browse files- nutri_call.html +30 -0
nutri_call.html
CHANGED
@@ -823,7 +823,37 @@ function data_out(response) {
|
|
823 |
|
824 |
|
825 |
|
|
|
|
|
|
|
826 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
827 |
|
828 |
|
829 |
function calculateEC(data, temperature) {
|
|
|
823 |
|
824 |
|
825 |
|
826 |
+
// Функция для расчета соотношения NPK
|
827 |
+
function updateNPK(data) {
|
828 |
+
console.log("=== РАСЧЕТ СООТНОШЕНИЯ NPK ===");
|
829 |
|
830 |
+
// Извлекаем значения из actual_profile
|
831 |
+
const nValue = data.actual_profile["N (NH4+)"] + data.actual_profile["N (NO3-)"];
|
832 |
+
const pValue = data.actual_profile["P"];
|
833 |
+
const kValue = data.actual_profile["K"];
|
834 |
+
|
835 |
+
// Проверяем, что значения существуют
|
836 |
+
if (nValue !== undefined && pValue !== undefined && kValue !== undefined) {
|
837 |
+
console.log(`Значения NPK: N=${nValue}, P=${pValue}, K=${kValue}`);
|
838 |
+
|
839 |
+
// Находим минимальное значение
|
840 |
+
const minValue = Math.min(nValue, pValue, kValue);
|
841 |
+
|
842 |
+
// Рассчитываем соотношение
|
843 |
+
const nRatio = Math.round(nValue / minValue);
|
844 |
+
const pRatio = Math.round(pValue / minValue);
|
845 |
+
const kRatio = Math.round(kValue / minValue);
|
846 |
+
|
847 |
+
console.log(`Соотношение NPK: ${nRatio}:${pRatio}:${kRatio}`);
|
848 |
+
|
849 |
+
// Обновляем поля на странице
|
850 |
+
document.getElementById("npk-n-value").textContent = nRatio;
|
851 |
+
document.getElementById("npk-p-value").textContent = pRatio;
|
852 |
+
document.getElementById("npk-k-value").textContent = kRatio;
|
853 |
+
} else {
|
854 |
+
console.error("Ошибка: Значения NPK не найдены в ответе сервера.");
|
855 |
+
}
|
856 |
+
}
|
857 |
|
858 |
|
859 |
function calculateEC(data, temperature) {
|