Iomx 4/4-p-07-24 added, Itscreen stop before to scan added
This commit is contained in:
parent
62bf4122c4
commit
31c194978e
|
|
@ -0,0 +1,47 @@
|
|||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
BACKEND_FILE="$SCRIPT_DIR/console_core/backend/app.py"
|
||||
FRONTEND_FILE="$SCRIPT_DIR/console_core/frontend/console.js"
|
||||
|
||||
extract_version() {
|
||||
sed -n 's/.*V \([0-9][0-9.]*\).*/\1/p' "$1" | head -n 1
|
||||
}
|
||||
|
||||
current_version="$(extract_version "$BACKEND_FILE")"
|
||||
if [[ -z "$current_version" ]]; then
|
||||
echo "Failed to detect current UI version in $BACKEND_FILE" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ $# -gt 1 ]]; then
|
||||
echo "Usage: $0 [MAJOR.MINOR.PATCH]" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ $# -eq 1 ]]; then
|
||||
next_version="$1"
|
||||
else
|
||||
IFS='.' read -r major minor patch <<<"$current_version"
|
||||
if [[ -z "${major:-}" || -z "${minor:-}" || -z "${patch:-}" ]]; then
|
||||
echo "Current version must be in MAJOR.MINOR.PATCH format, got: $current_version" >&2
|
||||
exit 1
|
||||
fi
|
||||
next_version="${major}.${minor}.$((patch + 1))"
|
||||
fi
|
||||
|
||||
if [[ ! "$next_version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
||||
echo "Version must be in MAJOR.MINOR.PATCH format, got: $next_version" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
old_label="V $current_version"
|
||||
new_label="V $next_version"
|
||||
|
||||
sed -i "s/${old_label}/${new_label}/g" "$BACKEND_FILE" "$FRONTEND_FILE"
|
||||
|
||||
echo "UI version bumped: $old_label -> $new_label"
|
||||
echo "Updated files:"
|
||||
echo " $BACKEND_FILE"
|
||||
echo " $FRONTEND_FILE"
|
||||
|
|
@ -24,6 +24,8 @@ from modbus_backend import (
|
|||
ApiError as ModbusApiError,
|
||||
acquire_session as modbus_acquire_session,
|
||||
get_discovery_job as modbus_get_discovery_job,
|
||||
iomx04_apply_timed_relay as modbus_iomx04_apply_timed_relay,
|
||||
iomx04_set_relay as modbus_iomx04_set_relay,
|
||||
list_ports_payload as modbus_list_ports_payload,
|
||||
profiles_payload as modbus_profiles_payload,
|
||||
read_audit as modbus_read_audit,
|
||||
|
|
@ -39,7 +41,7 @@ APP_DIR = "/opt/iomatex-console"
|
|||
PUBLIC_DIR = os.path.join(APP_DIR, "public")
|
||||
PROVIDERS_DIR = os.path.join(APP_DIR, "providers.d")
|
||||
CONFIG_PATH = "/etc/iomatex/console.json"
|
||||
UI_VERSION = "V 2.2.36"
|
||||
UI_VERSION = "V 2.2.46"
|
||||
|
||||
DEFAULT_CONFIG = {
|
||||
"bind": "0.0.0.0",
|
||||
|
|
@ -3291,6 +3293,44 @@ class Handler(BaseHTTPRequestHandler):
|
|||
except Exception as exc:
|
||||
self.send_json({"ok": False, "error": str(exc)}, code=500)
|
||||
return
|
||||
if parsed.path == "/api/modbus/iomx04/relay":
|
||||
payload = self.read_json_body()
|
||||
if payload is None:
|
||||
self.send_json({"ok": False, "error": "Invalid JSON body"}, code=400)
|
||||
return
|
||||
try:
|
||||
self.send_json(modbus_iomx04_set_relay(
|
||||
port=str(payload.get("port", "")),
|
||||
slave=int(payload.get("slave", 1)),
|
||||
baud=int(payload.get("baud", 9600)),
|
||||
relay=int(payload.get("relay", 1)),
|
||||
enabled=bool(payload.get("enabled", False)),
|
||||
source="console_ui",
|
||||
))
|
||||
except ModbusApiError as exc:
|
||||
self.send_json({"ok": False, "error": exc.message, "details": exc.details}, code=exc.code)
|
||||
except Exception as exc:
|
||||
self.send_json({"ok": False, "error": str(exc)}, code=500)
|
||||
return
|
||||
if parsed.path == "/api/modbus/iomx04/timed-relay":
|
||||
payload = self.read_json_body()
|
||||
if payload is None:
|
||||
self.send_json({"ok": False, "error": "Invalid JSON body"}, code=400)
|
||||
return
|
||||
try:
|
||||
self.send_json(modbus_iomx04_apply_timed_relay(
|
||||
port=str(payload.get("port", "")),
|
||||
slave=int(payload.get("slave", 1)),
|
||||
baud=int(payload.get("baud", 9600)),
|
||||
relay=int(payload.get("relay", 1)),
|
||||
duration_ds=int(payload.get("duration_ds", 150)),
|
||||
source="console_ui",
|
||||
))
|
||||
except ModbusApiError as exc:
|
||||
self.send_json({"ok": False, "error": exc.message, "details": exc.details}, code=exc.code)
|
||||
except Exception as exc:
|
||||
self.send_json({"ok": False, "error": str(exc)}, code=500)
|
||||
return
|
||||
if parsed.path == "/api/actions/audio-test":
|
||||
payload = self.read_json_body()
|
||||
if payload is None:
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -32,6 +32,15 @@
|
|||
"Host / IP": "Хост / IP",
|
||||
"Updated": "Обновлено",
|
||||
"Primary navigation": "Основная навигация",
|
||||
"Stopping it-screen service before Modbus session": "Остановка сервиса it-screen перед Modbus-сеансом",
|
||||
"Starting it-screen service after Modbus session": "Запуск сервиса it-screen после Modbus-сеанса",
|
||||
"Stop it-screen while working with Modbus": "Останавливать it-screen во время работы с Modbus",
|
||||
"Restart it-screen on release": "Перезапускать it-screen после освобождения порта",
|
||||
"it-screen service was stopped temporarily for Modbus scanning and writing.": "Сервис it-screen был временно остановлен для сканирования и записи Modbus.",
|
||||
"it-screen service was restarted after the Modbus session.": "Сервис it-screen был перезапущен после Modbus-сеанса.",
|
||||
"it-screen is running on this serial path. {action} will stop it-screen temporarily because scan and write results are unreliable while it-screen is active.\n\nContinue?": "it-screen сейчас работает на этом последовательном порту. Для действия «{action}» сервис it-screen будет временно остановлен, потому что результаты сканирования и записи ненадёжны, пока it-screen активен.\n\nПродолжить?",
|
||||
"{action} was cancelled because it-screen is still running.": "Действие «{action}» отменено, потому что it-screen всё ещё запущен.",
|
||||
"it-screen did not stop in time for {action}.": "Сервис it-screen не остановился вовремя для действия «{action}».",
|
||||
"Not available": "Недоступно",
|
||||
"Not specified": "Не указано",
|
||||
"Unknown": "Неизвестно",
|
||||
|
|
@ -440,6 +449,15 @@
|
|||
"Host / IP": "Host / IP",
|
||||
"Updated": "Zaktualizowano",
|
||||
"Primary navigation": "Nawigacja główna",
|
||||
"Stopping it-screen service before Modbus session": "Zatrzymywanie usługi it-screen przed sesją Modbus",
|
||||
"Starting it-screen service after Modbus session": "Uruchamianie usługi it-screen po sesji Modbus",
|
||||
"Stop it-screen while working with Modbus": "Zatrzymaj it-screen podczas pracy z Modbus",
|
||||
"Restart it-screen on release": "Uruchom ponownie it-screen po zwolnieniu portu",
|
||||
"it-screen service was stopped temporarily for Modbus scanning and writing.": "Usługa it-screen została tymczasowo zatrzymana na czas skanowania i zapisu Modbus.",
|
||||
"it-screen service was restarted after the Modbus session.": "Usługa it-screen została ponownie uruchomiona po sesji Modbus.",
|
||||
"it-screen is running on this serial path. {action} will stop it-screen temporarily because scan and write results are unreliable while it-screen is active.\n\nContinue?": "it-screen działa obecnie na tej ścieżce szeregowej. Operacja „{action}” tymczasowo zatrzyma it-screen, ponieważ wyniki skanowania i zapisu są niewiarygodne, gdy it-screen jest aktywny.\n\nKontynuować?",
|
||||
"{action} was cancelled because it-screen is still running.": "Operacja „{action}” została anulowana, ponieważ it-screen nadal działa.",
|
||||
"it-screen did not stop in time for {action}.": "Usługa it-screen nie zatrzymała się na czas dla operacji „{action}”.",
|
||||
"Not available": "Niedostępne",
|
||||
"Not specified": "Nie podano",
|
||||
"Unknown": "Nieznane",
|
||||
|
|
@ -826,6 +844,15 @@
|
|||
"Host / IP": "المضيف / IP",
|
||||
"Updated": "آخر تحديث",
|
||||
"Primary navigation": "التنقل الرئيسي",
|
||||
"Stopping it-screen service before Modbus session": "إيقاف خدمة it-screen قبل جلسة Modbus",
|
||||
"Starting it-screen service after Modbus session": "تشغيل خدمة it-screen بعد جلسة Modbus",
|
||||
"Stop it-screen while working with Modbus": "أوقف it-screen أثناء العمل مع Modbus",
|
||||
"Restart it-screen on release": "أعد تشغيل it-screen بعد تحرير المنفذ",
|
||||
"it-screen service was stopped temporarily for Modbus scanning and writing.": "تم إيقاف خدمة it-screen مؤقتًا أثناء فحص وكتابة Modbus.",
|
||||
"it-screen service was restarted after the Modbus session.": "تمت إعادة تشغيل خدمة it-screen بعد جلسة Modbus.",
|
||||
"it-screen is running on this serial path. {action} will stop it-screen temporarily because scan and write results are unreliable while it-screen is active.\n\nContinue?": "خدمة it-screen تعمل حاليًا على هذا المسار التسلسلي. سيؤدي الإجراء \"{action}\" إلى إيقاف it-screen مؤقتًا لأن نتائج الفحص والكتابة تكون غير موثوقة أثناء نشاط it-screen.\n\nهل تريد المتابعة؟",
|
||||
"{action} was cancelled because it-screen is still running.": "تم إلغاء الإجراء \"{action}\" لأن خدمة it-screen ما زالت قيد التشغيل.",
|
||||
"it-screen did not stop in time for {action}.": "لم تتوقف خدمة it-screen في الوقت المناسب لتنفيذ الإجراء \"{action}\".",
|
||||
"Not available": "غير متاح",
|
||||
"Not specified": "غير محدد",
|
||||
"Unknown": "غير معروف",
|
||||
|
|
@ -1217,6 +1244,15 @@
|
|||
"Host / IP": "होस्ट / IP",
|
||||
"Updated": "अपडेट किया गया",
|
||||
"Primary navigation": "मुख्य नेविगेशन",
|
||||
"Stopping it-screen service before Modbus session": "Modbus सत्र से पहले it-screen सेवा रोकी जा रही है",
|
||||
"Starting it-screen service after Modbus session": "Modbus सत्र के बाद it-screen सेवा शुरू की जा रही है",
|
||||
"Stop it-screen while working with Modbus": "Modbus के साथ काम करते समय it-screen रोकें",
|
||||
"Restart it-screen on release": "रिलीज़ के बाद it-screen फिर से चालू करें",
|
||||
"it-screen service was stopped temporarily for Modbus scanning and writing.": "Modbus स्कैनिंग और लिखने के लिए it-screen सेवा अस्थायी रूप से रोकी गई थी।",
|
||||
"it-screen service was restarted after the Modbus session.": "Modbus सत्र के बाद it-screen सेवा फिर से शुरू की गई।",
|
||||
"it-screen is running on this serial path. {action} will stop it-screen temporarily because scan and write results are unreliable while it-screen is active.\n\nContinue?": "इस serial path पर it-screen अभी चल रहा है। \"{action}\" के लिए it-screen को अस्थायी रूप से रोका जाएगा, क्योंकि it-screen सक्रिय रहने पर scan और write के परिणाम भरोसेमंद नहीं होते।\n\nक्या जारी रखें?",
|
||||
"{action} was cancelled because it-screen is still running.": "\"{action}\" रद्द कर दिया गया क्योंकि it-screen अभी भी चल रहा है।",
|
||||
"it-screen did not stop in time for {action}.": "\"{action}\" के लिए it-screen सेवा समय पर बंद नहीं हुई।",
|
||||
"Not available": "उपलब्ध नहीं",
|
||||
"Not specified": "निर्दिष्ट नहीं",
|
||||
"Nothing to copy": "कॉपी करने के लिए कुछ नहीं",
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@
|
|||
{ mode: "test_by", label: "TEST BY", host: "rest.test.it-screen.by" },
|
||||
{ mode: "custom", label: "Custom", host: "" }
|
||||
];
|
||||
const UI_VERSION = "V 2.2.36";
|
||||
const UI_VERSION = "V 2.2.46";
|
||||
const ITSCREEN_LOG_INITIAL_LINES = 50;
|
||||
const ITSCREEN_LOG_BUFFER_LIMIT = 300;
|
||||
const ITSCREEN_LOG_BATCH_MS = 250;
|
||||
|
|
@ -243,6 +243,10 @@
|
|||
decodeMode: "uint16",
|
||||
value: "",
|
||||
lastResult: null
|
||||
},
|
||||
iomx04Control: {
|
||||
relay: "1",
|
||||
timedSeconds: "15"
|
||||
}
|
||||
},
|
||||
networkForm: {
|
||||
|
|
@ -2857,7 +2861,7 @@
|
|||
return entries.map((item) => ({
|
||||
timestamp: new Date().toISOString(),
|
||||
level: textValue(item.level, "info"),
|
||||
message: textValue(item.message, "")
|
||||
message: translateUiText(textValue(item.message, ""))
|
||||
})).filter((item) => item.message);
|
||||
}
|
||||
|
||||
|
|
@ -2936,6 +2940,11 @@
|
|||
return profile.family === "exbd_nano";
|
||||
}
|
||||
|
||||
function modbusIomx04FamilySelected() {
|
||||
const profile = modbusSelectedProfile() || {};
|
||||
return profile.family === "iomx_04_04_p_07_24";
|
||||
}
|
||||
|
||||
function modbusEm01BaudComment() {
|
||||
return t("Baud rate is not changeable on EM-01. Register 0x62 updates, but actual UART speed remains 9600.");
|
||||
}
|
||||
|
|
@ -3134,6 +3143,9 @@
|
|||
if (modbusEditorFamily() === "rs485_pt100_tzt") {
|
||||
log.writeForm.parity = "none";
|
||||
}
|
||||
if (modbusIomx04FamilySelected()) {
|
||||
log.writeForm.parity = "none";
|
||||
}
|
||||
if (modbusEm01FamilySelected()) {
|
||||
log.writeForm.baud = "9600";
|
||||
log.writeForm.parity = "none";
|
||||
|
|
@ -3258,22 +3270,88 @@
|
|||
const log = modbusState();
|
||||
const portInfo = modbusSelectedPortStatus() || {};
|
||||
const stopItscreen = options.stopItscreen !== undefined ? !!options.stopItscreen : !!log.stopItscreen;
|
||||
const confirmItscreenStop = options.confirmItscreenStop !== undefined ? !!options.confirmItscreenStop : !!stopItscreen;
|
||||
const actionLabel = textValue(options.actionLabel, t("Modbus operation"));
|
||||
let effectiveStopItscreen = stopItscreen;
|
||||
if (log.session || portInfo.locked) {
|
||||
return true;
|
||||
}
|
||||
if (confirmItscreenStop && stopItscreen) {
|
||||
const portsPayload = await fetchJson("/api/modbus/ports", { cache: "no-store" });
|
||||
log.ports = Array.isArray(portsPayload.ports) ? portsPayload.ports : [];
|
||||
const currentPortInfo = modbusSelectedPortStatus() || {};
|
||||
const itscreenConflict = !!(currentPortInfo.itscreen_running && String(log.port || "").endsWith("ttyS3"));
|
||||
if (itscreenConflict) {
|
||||
const confirmed = window.confirm(t("it-screen is running on this serial path. {action} will stop it-screen temporarily because scan and write results are unreliable while it-screen is active.\n\nContinue?", { action: actionLabel }));
|
||||
if (!confirmed) {
|
||||
appendModbusLog(t("{action} was cancelled because it-screen is still running.", { action: actionLabel }), "warn");
|
||||
return false;
|
||||
}
|
||||
const stopPayload = await fetchJson("/api/itscreen/service/stop", {
|
||||
method: "POST",
|
||||
cache: "no-store",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: "{}"
|
||||
});
|
||||
appendModbusLog(translateUiText(stopPayload.message || t("Service stopped")), "warn");
|
||||
showToast("warn", t("it-screen service was stopped temporarily for Modbus scanning and writing."));
|
||||
effectiveStopItscreen = false;
|
||||
await loadItscreenInitialData({ force: true, maxAgeMs: 0 });
|
||||
await loadModbus({ force: true, maxAgeMs: 0 });
|
||||
}
|
||||
}
|
||||
const payload = await fetchJson("/api/modbus/session/acquire", {
|
||||
method: "POST",
|
||||
cache: "no-store",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ port: log.port, stop_itscreen: stopItscreen })
|
||||
body: JSON.stringify({ port: log.port, stop_itscreen: effectiveStopItscreen })
|
||||
});
|
||||
log.session = payload.lock || null;
|
||||
ingestModbusPayload(payload);
|
||||
appendModbusLog(payload.message || t("Port acquired"), "success");
|
||||
appendModbusLog(translateUiText(payload.message || t("Port acquired")), "success");
|
||||
if (payload.itscreen_stopped) {
|
||||
appendModbusLog(t("it-screen service was stopped temporarily for Modbus scanning and writing."), "warn");
|
||||
showToast("warn", t("it-screen service was stopped temporarily for Modbus scanning and writing."));
|
||||
}
|
||||
await loadModbus({ force: true, maxAgeMs: 0 });
|
||||
return true;
|
||||
}
|
||||
|
||||
async function modbusStopItscreenIfNeeded(actionLabel) {
|
||||
const log = modbusState();
|
||||
if (!String(log.port || "").endsWith("ttyS3")) return true;
|
||||
const portsPayload = await fetchJson("/api/modbus/ports", { cache: "no-store" });
|
||||
log.ports = Array.isArray(portsPayload.ports) ? portsPayload.ports : [];
|
||||
const currentPortInfo = modbusSelectedPortStatus() || {};
|
||||
if (!currentPortInfo.itscreen_running) return true;
|
||||
const confirmed = window.confirm(t("it-screen is running on this serial path. {action} will stop it-screen temporarily because scan and write results are unreliable while it-screen is active.\n\nContinue?", { action: actionLabel }));
|
||||
if (!confirmed) {
|
||||
appendModbusLog(t("{action} was cancelled because it-screen is still running.", { action: actionLabel }), "warn");
|
||||
return false;
|
||||
}
|
||||
const stopPayload = await fetchJson("/api/itscreen/service/stop", {
|
||||
method: "POST",
|
||||
cache: "no-store",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: "{}"
|
||||
});
|
||||
appendModbusLog(translateUiText(stopPayload.message || t("Service stopped")), "warn");
|
||||
showToast("warn", t("it-screen service was stopped temporarily for Modbus scanning and writing."));
|
||||
await loadItscreenInitialData({ force: true, maxAgeMs: 0 });
|
||||
const deadline = Date.now() + 15000;
|
||||
while (Date.now() < deadline) {
|
||||
const verifyPortsPayload = await fetchJson("/api/modbus/ports", { cache: "no-store" });
|
||||
log.ports = Array.isArray(verifyPortsPayload.ports) ? verifyPortsPayload.ports : [];
|
||||
const verifyPortInfo = modbusSelectedPortStatus() || {};
|
||||
if (!verifyPortInfo.itscreen_running) {
|
||||
await loadModbus({ force: true, maxAgeMs: 0 });
|
||||
return true;
|
||||
}
|
||||
await new Promise((resolve) => window.setTimeout(resolve, 350));
|
||||
}
|
||||
throw new Error(t("it-screen did not stop in time for {action}.", { action: actionLabel }));
|
||||
}
|
||||
|
||||
function renderModbusLogPanel() {
|
||||
const entries = modbusState().operationLog || [];
|
||||
return `
|
||||
|
|
@ -3494,6 +3572,7 @@
|
|||
return `
|
||||
${summary.warning ? `<div class="banner warn">${esc(summary.warning)}</div>` : ""}
|
||||
<div class="meta compactMeta">${renderKeyValueRows(rows.concat(extraRows))}</div>
|
||||
${modbusIomx04FamilySelected() ? renderIomx04RelayControls() : ""}
|
||||
<details class="technicalDetails">
|
||||
<summary>${esc(t("Raw register details"))}</summary>
|
||||
<pre class="diagBlock">${esc(JSON.stringify(currentConfig.raw_values || {}, null, 2))}</pre>
|
||||
|
|
@ -3501,6 +3580,40 @@
|
|||
`;
|
||||
}
|
||||
|
||||
function renderIomx04RelayControls() {
|
||||
const control = modbusState().iomx04Control || {};
|
||||
return `
|
||||
<div class="writeConfigSection">
|
||||
<div class="sectionTitle">${esc(t("Relay control"))}</div>
|
||||
<div class="modbusGrid">
|
||||
<label class="field">
|
||||
<span>${esc(t("Relay"))}</span>
|
||||
<select onchange="window.__modbusSetIomx04Field('relay', this.value)">
|
||||
${[1, 2, 3, 4].map((item) => `<option value="${item}" ${String(control.relay || "1") === String(item) ? "selected" : ""}>${esc(`Relay ${item}`)}</option>`).join("")}
|
||||
</select>
|
||||
</label>
|
||||
<label class="field">
|
||||
<span>${esc(t("Timed ON seconds"))}</span>
|
||||
${renderNumberStepperInput({
|
||||
id: "iomx04TimedSecondsInput",
|
||||
value: control.timedSeconds || "15",
|
||||
min: 1,
|
||||
max: 600,
|
||||
step: 1,
|
||||
oninput: "window.__modbusSetIomx04Field('timedSeconds', this.value)"
|
||||
})}
|
||||
</label>
|
||||
</div>
|
||||
<div class="actionRow">
|
||||
<button class="actionBtn secondary" type="button" ${modbusBusy("iomx04_relay_on") ? "disabled" : ""} onclick="window.__modbusIomx04SetRelay(true)">${esc(modbusBusy("iomx04_relay_on") ? t("Applying...") : t("Relay ON"))}</button>
|
||||
<button class="actionBtn secondary" type="button" ${modbusBusy("iomx04_relay_off") ? "disabled" : ""} onclick="window.__modbusIomx04SetRelay(false)">${esc(modbusBusy("iomx04_relay_off") ? t("Applying...") : t("Relay OFF"))}</button>
|
||||
<button class="actionBtn" type="button" ${modbusBusy("iomx04_timed") ? "disabled" : ""} onclick="window.__modbusIomx04TimedRelay()">${esc(modbusBusy("iomx04_timed") ? t("Applying...") : t("Timed ON"))}</button>
|
||||
</div>
|
||||
<div class="formHint">${esc(t("Timed relay uses the hardware auto-off mode and is suitable for watchdog behavior."))}</div>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
function renderModbusReadConfigState() {
|
||||
const log = modbusState();
|
||||
if (log.readConfigStatus === "success" && log.readConfigMessage) {
|
||||
|
|
@ -3690,7 +3803,7 @@
|
|||
id: "modbusDiscoverySlaveFromInput",
|
||||
value: log.discovery.slaveFrom,
|
||||
min: 1,
|
||||
max: 247,
|
||||
max: 255,
|
||||
step: 1,
|
||||
oninput: "window.__modbusSetDiscovery('slaveFrom', this.value)"
|
||||
})}
|
||||
|
|
@ -3701,7 +3814,7 @@
|
|||
id: "modbusDiscoverySlaveToInput",
|
||||
value: log.discovery.slaveTo,
|
||||
min: 1,
|
||||
max: 247,
|
||||
max: 255,
|
||||
step: 1,
|
||||
oninput: "window.__modbusSetDiscovery('slaveTo', this.value)"
|
||||
})}
|
||||
|
|
@ -3800,12 +3913,12 @@
|
|||
</select>`
|
||||
}
|
||||
</label>
|
||||
${modbusEm01FamilySelected() ? `<div class="formHint">${esc(modbusEm01BaudComment())}</div>` : ((modbusExbdFamilySelected() || modbusEditorFamily() === "rs485_pt100_tzt") ? `
|
||||
${modbusEm01FamilySelected() ? `<div class="formHint">${esc(modbusEm01BaudComment())}</div>` : ((modbusExbdFamilySelected() || modbusEditorFamily() === "rs485_pt100_tzt" || modbusIomx04FamilySelected()) ? `
|
||||
<label class="field">
|
||||
<span>${esc(t("New Parity"))}</span>
|
||||
<input type="text" value="none" disabled readonly>
|
||||
</label>
|
||||
<div class="formHint">${esc(modbusEditorFamily() === "rs485_pt100_tzt" ? t("Parity is fixed to none on this PT100 sensor.") : modbusExbdParityComment())}</div>
|
||||
<div class="formHint">${esc(modbusEditorFamily() === "rs485_pt100_tzt" ? t("Parity is fixed to none on this PT100 sensor.") : (modbusIomx04FamilySelected() ? t("Parity is fixed to none on this IOMX-04 board.") : modbusExbdParityComment()))}</div>
|
||||
` : `
|
||||
<label class="field">
|
||||
<span>${esc(t("New Parity"))}</span>
|
||||
|
|
@ -5000,6 +5113,12 @@
|
|||
modbusState().registerForm[field] = value;
|
||||
};
|
||||
|
||||
window.__modbusSetIomx04Field = function (field, value) {
|
||||
if (field !== "relay" && field !== "timedSeconds") return;
|
||||
modbusState().iomx04Control[field] = String(value == null ? "" : value);
|
||||
if (state.activeTab === "modbus") renderActiveTab();
|
||||
};
|
||||
|
||||
window.__modbusSelectDevice = function (index) {
|
||||
const log = modbusState();
|
||||
const item = (log.discovery.devices || [])[index];
|
||||
|
|
@ -5049,9 +5168,13 @@
|
|||
});
|
||||
log.session = payload.lock || null;
|
||||
ingestModbusPayload(payload);
|
||||
appendModbusLog(payload.message || t("Port acquired"), "success");
|
||||
appendModbusLog(translateUiText(payload.message || t("Port acquired")), "success");
|
||||
if (payload.itscreen_stopped) {
|
||||
appendModbusLog(t("it-screen service was stopped temporarily for Modbus scanning and writing."), "warn");
|
||||
showToast("warn", t("it-screen service was stopped temporarily for Modbus scanning and writing."));
|
||||
}
|
||||
await loadModbus({ force: true, maxAgeMs: 0 });
|
||||
showToast("success", payload.message || t("Port acquired"));
|
||||
showToast("success", translateUiText(payload.message || t("Port acquired")));
|
||||
} catch (error) {
|
||||
log.error = error.message || t("Failed to acquire port");
|
||||
appendModbusLog(log.error, "error");
|
||||
|
|
@ -5076,9 +5199,13 @@
|
|||
});
|
||||
log.session = null;
|
||||
ingestModbusPayload(payload);
|
||||
appendModbusLog(payload.message || t("Port released"), "success");
|
||||
appendModbusLog(translateUiText(payload.message || t("Port released")), "success");
|
||||
if (payload.itscreen_restarted) {
|
||||
appendModbusLog(t("it-screen service was restarted after the Modbus session."), "success");
|
||||
showToast("success", t("it-screen service was restarted after the Modbus session."));
|
||||
}
|
||||
await loadModbus({ force: true, maxAgeMs: 0 });
|
||||
showToast("success", payload.message || t("Port released"));
|
||||
showToast("success", translateUiText(payload.message || t("Port released")));
|
||||
} catch (error) {
|
||||
log.error = error.message || t("Failed to release port");
|
||||
appendModbusLog(log.error, "error");
|
||||
|
|
@ -5105,10 +5232,14 @@
|
|||
log.discovery.followingBottom = true;
|
||||
log.discovery.viewportOffsetFromBottom = 0;
|
||||
log.discovery.forceScroll = true;
|
||||
appendModbusLog(mode === "deep" ? t("Deep scan started") : t("Quick scan started"), "info");
|
||||
if (state.activeTab === "modbus") renderActiveTab();
|
||||
try {
|
||||
await modbusEnsureSession();
|
||||
const actionLabel = mode === "deep" ? t("Deep scan") : t("Quick scan");
|
||||
const canProceed = await modbusStopItscreenIfNeeded(actionLabel);
|
||||
if (!canProceed) return;
|
||||
appendModbusLog(mode === "deep" ? t("Deep scan started") : t("Quick scan started"), "info");
|
||||
const acquired = await modbusEnsureSession({ actionLabel, stopItscreen: false, confirmItscreenStop: false });
|
||||
if (!acquired) return;
|
||||
const payload = await fetchJson("/api/modbus/discover", {
|
||||
method: "POST",
|
||||
cache: "no-store",
|
||||
|
|
@ -5270,7 +5401,8 @@
|
|||
appendModbusLog(t("Write started; backend validation will confirm the final device state"), "info");
|
||||
if (state.activeTab === "modbus") renderActiveTab();
|
||||
try {
|
||||
await modbusEnsureSession();
|
||||
const acquired = await modbusEnsureSession({ actionLabel: t("Configuration write"), stopItscreen: true });
|
||||
if (!acquired) return;
|
||||
const current = modbusCurrentConnection();
|
||||
if (!log.writeForm.slave) {
|
||||
log.writeForm.slave = modbusCurrentSlaveFallback();
|
||||
|
|
@ -5338,7 +5470,8 @@
|
|||
log.busyAction = "register_read";
|
||||
log.error = "";
|
||||
try {
|
||||
await modbusEnsureSession();
|
||||
const acquired = await modbusEnsureSession({ actionLabel: t("Register read"), confirmItscreenStop: false });
|
||||
if (!acquired) return;
|
||||
const payload = await fetchJson("/api/modbus/register/read", {
|
||||
method: "POST",
|
||||
cache: "no-store",
|
||||
|
|
@ -5373,7 +5506,8 @@
|
|||
log.busyAction = "register_write";
|
||||
log.error = "";
|
||||
try {
|
||||
await modbusEnsureSession();
|
||||
const acquired = await modbusEnsureSession({ actionLabel: t("Register write"), stopItscreen: true });
|
||||
if (!acquired) return;
|
||||
const payload = await fetchJson("/api/modbus/register/write", {
|
||||
method: "POST",
|
||||
cache: "no-store",
|
||||
|
|
@ -5400,6 +5534,69 @@
|
|||
}
|
||||
};
|
||||
|
||||
window.__modbusIomx04SetRelay = async function (enabled) {
|
||||
const log = modbusState();
|
||||
const current = modbusCurrentConnection();
|
||||
log.busyAction = enabled ? "iomx04_relay_on" : "iomx04_relay_off";
|
||||
log.error = "";
|
||||
try {
|
||||
const acquired = await modbusEnsureSession({ actionLabel: enabled ? t("Relay ON") : t("Relay OFF"), stopItscreen: true });
|
||||
if (!acquired) return;
|
||||
const payload = await fetchJson("/api/modbus/iomx04/relay", {
|
||||
method: "POST",
|
||||
cache: "no-store",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({
|
||||
port: log.port,
|
||||
slave: Number(current.slave),
|
||||
baud: Number(current.baud),
|
||||
relay: Number(log.iomx04Control && log.iomx04Control.relay || 1),
|
||||
enabled: !!enabled
|
||||
})
|
||||
});
|
||||
appendModbusLog(payload.message || t("Relay state updated"), "success");
|
||||
await window.__modbusReadConfig();
|
||||
} catch (error) {
|
||||
log.error = error.message || t("Relay write failed");
|
||||
appendModbusLog(log.error, "error");
|
||||
} finally {
|
||||
log.busyAction = "";
|
||||
if (state.activeTab === "modbus") renderActiveTab();
|
||||
}
|
||||
};
|
||||
|
||||
window.__modbusIomx04TimedRelay = async function () {
|
||||
const log = modbusState();
|
||||
const current = modbusCurrentConnection();
|
||||
log.busyAction = "iomx04_timed";
|
||||
log.error = "";
|
||||
try {
|
||||
const acquired = await modbusEnsureSession({ actionLabel: t("Timed ON"), stopItscreen: true });
|
||||
if (!acquired) return;
|
||||
const seconds = Math.max(1, Number(log.iomx04Control && log.iomx04Control.timedSeconds || 15));
|
||||
const payload = await fetchJson("/api/modbus/iomx04/timed-relay", {
|
||||
method: "POST",
|
||||
cache: "no-store",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({
|
||||
port: log.port,
|
||||
slave: Number(current.slave),
|
||||
baud: Number(current.baud),
|
||||
relay: Number(log.iomx04Control && log.iomx04Control.relay || 1),
|
||||
duration_ds: Math.round(seconds * 10)
|
||||
})
|
||||
});
|
||||
appendModbusLog(payload.message || t("Timed relay started"), "success");
|
||||
await window.__modbusReadConfig();
|
||||
} catch (error) {
|
||||
log.error = error.message || t("Timed relay write failed");
|
||||
appendModbusLog(log.error, "error");
|
||||
} finally {
|
||||
log.busyAction = "";
|
||||
if (state.activeTab === "modbus") renderActiveTab();
|
||||
}
|
||||
};
|
||||
|
||||
window.__authSetField = function (field, value) {
|
||||
if (field !== "username" && field !== "password") return;
|
||||
state.auth[field] = (value ?? "").toString();
|
||||
|
|
|
|||
|
|
@ -0,0 +1,51 @@
|
|||
{
|
||||
"family": "iomx_04_04_p_07_24",
|
||||
"title": "IOMATEX IOMX-04/04-P-07-24",
|
||||
"display_name": "IOMATEX IOMX-04/04-P-07-24",
|
||||
"discovery_enabled": false,
|
||||
"transport": {
|
||||
"protocol": "modbus_rtu",
|
||||
"default_port": "/dev/ttyS3",
|
||||
"default_baud": 9600,
|
||||
"default_parity": "none",
|
||||
"default_databits": 8,
|
||||
"default_stopbits": 1,
|
||||
"scan_baud": [4800, 9600, 19200],
|
||||
"scan_parity": ["none"],
|
||||
"zero_based": true
|
||||
},
|
||||
"detection": {
|
||||
"type": "u16",
|
||||
"function": "holding",
|
||||
"start": 1000,
|
||||
"count": 1,
|
||||
"label": "0x03E8 (baud_code)",
|
||||
"match": ["__iomx04_raw_detect__"],
|
||||
"timeout_quick": 1.8,
|
||||
"timeout_deep": 3.2
|
||||
},
|
||||
"registers": {
|
||||
"test_read": {
|
||||
"address": 1000,
|
||||
"count": 1,
|
||||
"type": "holding"
|
||||
},
|
||||
"slave_id": {
|
||||
"address": 0,
|
||||
"count": 1,
|
||||
"type": "holding",
|
||||
"rw": true
|
||||
},
|
||||
"comm_profile": {
|
||||
"address": 1001,
|
||||
"count": 1,
|
||||
"type": "holding",
|
||||
"rw": true
|
||||
}
|
||||
},
|
||||
"comm_profiles": [
|
||||
{ "register_value": 2, "baud": 4800, "parity": "none", "label": "4800" },
|
||||
{ "register_value": 3, "baud": 9600, "parity": "none", "label": "9600" },
|
||||
{ "register_value": 4, "baud": 19200, "parity": "none", "label": "19200" }
|
||||
]
|
||||
}
|
||||
Loading…
Reference in New Issue