alarm parameters
This commit is contained in:
@ -62,6 +62,44 @@ function fadeOut(element, callback) {
|
||||
|
||||
var givenData;
|
||||
|
||||
function encodeCHValue(channels) {
|
||||
let CH = 0;
|
||||
for (const channelNumber of channels) {
|
||||
if (channelNumber >= 1 && channelNumber <= 32) {
|
||||
const channelBit = 1 << (channelNumber - 1);
|
||||
CH |= channelBit;
|
||||
}
|
||||
}
|
||||
return CH;
|
||||
}
|
||||
|
||||
let selectedCameras;
|
||||
|
||||
function checkSelectedCameras() {
|
||||
const checkboxes = document.querySelectorAll('.checkbox-input');
|
||||
selectedCameras = [];
|
||||
|
||||
checkboxes.forEach((checkbox) => {
|
||||
if (checkbox.checked) {
|
||||
const cameraNumber = checkbox.id.replace('camera', '');
|
||||
selectedCameras.push(cameraNumber);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function decodeCHValue(CH) {
|
||||
const channels = [];
|
||||
for (let i = 0; i < 32; i++) {
|
||||
const channelBit = (CH >> i) & 1;
|
||||
if (channelBit === 1) {
|
||||
const channelNumber = i + 1;
|
||||
channels.push(channelNumber);
|
||||
}
|
||||
}
|
||||
return channels;
|
||||
}
|
||||
|
||||
for (let radioButton of radioButtons) {
|
||||
radioButton.addEventListener("change", () => {
|
||||
if (radioButton.value === "parameters") {
|
||||
@ -260,46 +298,6 @@ for (let radioButton of radioButtons) {
|
||||
console.log(data.DATA);
|
||||
givenData = data.DATA.DSM.DSMA;
|
||||
|
||||
console.log(givenData);
|
||||
|
||||
function encodeCHValue(channels) {
|
||||
let CH = 0;
|
||||
for (const channelNumber of channels) {
|
||||
if (channelNumber >= 1 && channelNumber <= 32) {
|
||||
const channelBit = 1 << (channelNumber - 1);
|
||||
CH |= channelBit;
|
||||
}
|
||||
}
|
||||
return CH;
|
||||
}
|
||||
|
||||
let selectedCameras;
|
||||
|
||||
function checkSelectedCameras() {
|
||||
const checkboxes = document.querySelectorAll('.checkbox-input');
|
||||
selectedCameras = [];
|
||||
|
||||
checkboxes.forEach((checkbox) => {
|
||||
if (checkbox.checked) {
|
||||
const cameraNumber = checkbox.id.replace('camera', '');
|
||||
selectedCameras.push(cameraNumber);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function decodeCHValue(CH) {
|
||||
const channels = [];
|
||||
for (let i = 0; i < 32; i++) {
|
||||
const channelBit = (CH >> i) & 1;
|
||||
if (channelBit === 1) {
|
||||
const channelNumber = i + 1;
|
||||
channels.push(channelNumber);
|
||||
}
|
||||
}
|
||||
return channels;
|
||||
}
|
||||
|
||||
var desiredCameras;
|
||||
|
||||
function updateCheckboxes() {
|
||||
@ -338,7 +336,6 @@ for (let radioButton of radioButtons) {
|
||||
|
||||
checkSelectedCameras();
|
||||
newCH = encodeCHValue(selectedCameras);
|
||||
console.log('Выбранные камеры:', newCH);
|
||||
}
|
||||
|
||||
document.getElementById("system-ai").addEventListener("change", function () {
|
||||
@ -349,28 +346,8 @@ for (let radioButton of radioButtons) {
|
||||
document.getElementById("checkboxContainer").addEventListener("change", function () {
|
||||
checkSelectedCameras();
|
||||
newCH = encodeCHValue(selectedCameras);
|
||||
console.log('Выбранные камеры:', newCH);
|
||||
});
|
||||
function updateDataInArray(selectedIndex) {
|
||||
const selectedDataRow = data.DATA.DSM.DSMA[selectedIndex];
|
||||
|
||||
selectedDataRow.EN = document.getElementById("system-ai-en1").value;
|
||||
selectedDataRow.AS = document.getElementById("system-ai-as1").value;
|
||||
selectedDataRow.APR.ENSP = document.getElementById("system-ai-ensp1").value;
|
||||
selectedDataRow.FGMS = document.getElementById("system-ai-fgms1").value;
|
||||
selectedDataRow.SGMS = document.getElementById("system-ai-sgms1").value;
|
||||
selectedDataRow.ESST = document.getElementById("system-ai-esst1").value;
|
||||
selectedDataRow.UDT = document.getElementById("system-ai-udt1").value;
|
||||
selectedDataRow.VT = document.getElementById("system-ai-vt1").value;
|
||||
selectedDataRow.SDT = document.getElementById("system-ai-sdt1").value;
|
||||
selectedDataRow.APR.ET = document.getElementById("system-ai-et1").value;
|
||||
selectedDataRow.APR.SS.EN = document.getElementById("system-ai-ss-en1").value;
|
||||
selectedDataRow.APR.AR.D = document.getElementById("system-ai-ar-d1").value;
|
||||
|
||||
selectedDataRow.APR.AR.CH = encodeCHValue(selectedCameras);
|
||||
|
||||
console.log(selectedDataRow);
|
||||
}
|
||||
|
||||
updateFields(0);
|
||||
|
||||
@ -389,3 +366,25 @@ function truncateText(select) {
|
||||
option.text = option.text.substring(0, maxLength) + "...";
|
||||
}
|
||||
}
|
||||
|
||||
function updateDataInArray() {
|
||||
const selectedIndex = parseInt(document.getElementById("system-ai").value);
|
||||
const selectedDataRow = givenData[selectedIndex];
|
||||
|
||||
selectedDataRow.EN = parseInt(document.getElementById("system-ai-en1").value);
|
||||
selectedDataRow.AS = parseInt(document.getElementById("system-ai-as1").value);
|
||||
selectedDataRow.APR.ENSP = parseInt(document.getElementById("system-ai-ensp1").value);
|
||||
selectedDataRow.FGMS = parseInt(document.getElementById("system-ai-fgms1").value);
|
||||
selectedDataRow.SGMS = parseInt(document.getElementById("system-ai-sgms1").value);
|
||||
selectedDataRow.ESST = parseInt(document.getElementById("system-ai-esst1").value);
|
||||
selectedDataRow.UDT = parseInt(document.getElementById("system-ai-udt1").value);
|
||||
selectedDataRow.VT = parseInt(document.getElementById("system-ai-vt1").value);
|
||||
selectedDataRow.SDT = parseInt(document.getElementById("system-ai-sdt1").value);
|
||||
selectedDataRow.APR.ET = parseInt(document.getElementById("system-ai-et1").value);
|
||||
selectedDataRow.APR.SS.EN = parseInt(document.getElementById("system-ai-ss-en1").value);
|
||||
selectedDataRow.APR.AR.D = parseInt(document.getElementById("system-ai-ar-d1").value);
|
||||
|
||||
selectedDataRow.APR.AR.CH = parseInt(encodeCHValue(selectedCameras));
|
||||
|
||||
givenData[selectedIndex] = selectedDataRow;
|
||||
}
|
||||
|
@ -131,17 +131,17 @@
|
||||
<section class="for-new">
|
||||
|
||||
<section class="stages">
|
||||
<input name="newStage" type="radio" value="parameters" id="stage-parameters" checked><label for="stage-parameters">Системные настройки</label>
|
||||
<input autocomplete="off" name="newStage" type="radio" value="parameters" id="stage-parameters" checked><label for="stage-parameters">Системные настройки</label>
|
||||
<div class="vertical-line" style="background: transparent;"></div>
|
||||
<input name="newStage" type="radio" value="ethernet" id="stage-ethernet"><label for="stage-ethernet">Сеть</label>
|
||||
<input autocomplete="off" name="newStage" type="radio" value="ethernet" id="stage-ethernet"><label for="stage-ethernet">Сеть</label>
|
||||
<div class="vertical-line"></div>
|
||||
<input name="newStage" type="radio" value="wifi" id="stage-wifi"><label for="stage-wifi">Wi-Fi</label>
|
||||
<input autocomplete="off" name="newStage" type="radio" value="wifi" id="stage-wifi"><label for="stage-wifi">Wi-Fi</label>
|
||||
<div class="vertical-line"></div>
|
||||
<input name="newStage" type="radio" value="communication" id="stage-communication"><label for="stage-communication">Коммуникации</label>
|
||||
<input autocomplete="off" name="newStage" type="radio" value="communication" id="stage-communication"><label for="stage-communication">Коммуникации</label>
|
||||
<div class="vertical-line" style="background: transparent;"></div>
|
||||
<input name="newStage" type="radio" value="install" id="stage-install"><label for="stage-install">Установка сервера</label>
|
||||
<input autocomplete="off" name="newStage" type="radio" value="install" id="stage-install"><label for="stage-install">Установка сервера</label>
|
||||
<div class="vertical-line" style="background: transparent;"></div>
|
||||
<input name="newStage" type="radio" value="ai" id="stage-ai"><label for="stage-ai">Тревоги</label>
|
||||
<input autocomplete="off" name="newStage" type="radio" value="ai" id="stage-ai"><label for="stage-ai">Тревоги</label>
|
||||
</section>
|
||||
</section>
|
||||
<section id="add-new-container" class="add-new">
|
||||
@ -476,17 +476,17 @@
|
||||
|
||||
<div class="parameters-inputs">
|
||||
<label for="system-ai">Статус</label>
|
||||
<select style="width: 100%;" name="AI" id="system-ai">
|
||||
<option value="0">0 - Физиологическая усталость</option>
|
||||
<option value="1">1 - Нет водителя</option>
|
||||
<option value="2">2 - Говорит по телефону</option>
|
||||
<option value="3">3 - Курение</option>
|
||||
<option value="4">4 - Отклекся</option>
|
||||
<option value="5">5 - Предупреждение о покидании полосы движения</option>
|
||||
<option value="6">6 - Предупреждение о столкновении</option>
|
||||
<option value="9">9 - Расстояние до машины слишком близко</option>
|
||||
<option value="10">10 - Зевание</option>
|
||||
<option value="11">11 - Столкновение с пешеходом</option>
|
||||
<select autocomplete="off" style="width: 100%;" name="AI" id="system-ai">
|
||||
<option value="0">Физиологическая усталость</option>
|
||||
<option value="1">Нет водителя</option>
|
||||
<option value="2">Говорит по телефону</option>
|
||||
<option value="3">Курение</option>
|
||||
<option value="4">Отвлекся</option>
|
||||
<option value="5">Предупреждение о покидании полосы движения</option>
|
||||
<option value="6">Предупреждение о столкновении</option>
|
||||
<option value="9">Расстояние до машины слишком близко</option>
|
||||
<option value="10">Зевание</option>
|
||||
<option value="11">Столкновение с пешеходом</option>
|
||||
</select>
|
||||
<div class="parameters-input">
|
||||
<label for="system-ai-en1">Статус</label>
|
||||
@ -565,7 +565,7 @@
|
||||
|
||||
<div class="horizontal-line"></div>
|
||||
|
||||
<button onclick="updateDataInArray(0);" type="button">Сохранить</button>
|
||||
<button onclick="sendPutRequest('ai');" type="button">Сохранить</button>
|
||||
|
||||
</div>
|
||||
|
||||
@ -1120,6 +1120,54 @@ const requestBody = {
|
||||
showMessage("Не удалось обновить данные", false);
|
||||
console.error('Произошла ошибка при отправке PUT запроса:', error);
|
||||
}
|
||||
}
|
||||
if (type === 'ai') {
|
||||
|
||||
const deleteConfirmation = document.getElementById("addInformation");
|
||||
const loader = document.getElementById("loader");
|
||||
const status = document.getElementById("status");
|
||||
const closeButton = document.getElementById("closeButton");
|
||||
const mark = document.getElementById("success-mark");
|
||||
|
||||
loader.style.display = "block";
|
||||
closeButton.style.display = "none";
|
||||
deleteConfirmation.style.display = "flex";
|
||||
mark.style.display = "none";
|
||||
|
||||
updateDataInArray();
|
||||
|
||||
const DSMA = givenData;
|
||||
console.log(DSMA);
|
||||
|
||||
const requestData = {
|
||||
DSMA
|
||||
};
|
||||
|
||||
try {
|
||||
const response = await fetch(`/ai-parameters?serial=${serial}`, {
|
||||
method: 'PUT',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(requestData),
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
var formContainer = $("#form-bg");
|
||||
var form = $("#form");
|
||||
formContainer.removeClass("active");
|
||||
form.removeClass("form-animation");
|
||||
$("body").css("overflow", "auto");
|
||||
showMessage("Данные успешно обновлены", true);
|
||||
console.log('PUT запрос выполнен успешно');
|
||||
} else {
|
||||
showMessage("Не удалось обновить данные", false);
|
||||
console.error('Ошибка при выполнении PUT запроса');
|
||||
}
|
||||
} catch (error) {
|
||||
showMessage("Не удалось обновить данные", false);
|
||||
console.error('Произошла ошибка при отправке PUT запроса:', error);
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@ -1197,7 +1245,7 @@ $(document).ready(function() {
|
||||
location.reload();
|
||||
const deleteConfirmation = document.getElementById("addInformation");
|
||||
deleteConfirmation.style.display = "none";
|
||||
}, 2000);
|
||||
}, 500);
|
||||
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user