diff --git a/front-generator/render-params.json b/front-generator/render-params.json index 83dd6bf..ea710c2 100644 --- a/front-generator/render-params.json +++ b/front-generator/render-params.json @@ -1,41 +1,32 @@ { - "monitoring-params": {}, "modem_types": { "tdma": { "modem_name": "RCSM-101 TDMA", + "dangerousParamGroups": { + "buclnb": "Применение неправильных настроек может вывести из строя оборудование! Продолжить?", + "network": "Применение этих настроек может сделать модем недоступным! Продолжить?" + }, "params": { "rxtx": [ - { - "widget": "h2", - "label": "Настройки приема/передачи" - }, + {"widget": "h2", "label": "Настройки приема/передачи"}, { "widget": "flex-container", "childs": [ { "widget": "settings-container", "childs": [ - { "widget": "h3", "label": "Настройки передатчика" }, + {"widget": "h3", "label": "Настройки передатчика"}, + {"widget": "checkbox", "label": "Включить передатчик", "name": "txEn"}, { - "widget": "checkbox", - "label": "Включить передатчик", - "name": "txEn" - }, - { - "widget": "select", - "label": "Входные данные", - "name": "txIsTestInput", + "widget": "select", "label": "Входные данные", "name": "txIsTestInput", "values": [ - { - "label": "Тест", - "value": "true" - }, - { - "label": "SCPC", - "value": "false" - } + {"label": "SCPC", "value": "false"}, + {"label": "Тест", "value": "true"} ] - } + }, + {"widget": "number", "label": "Центральная частота, КГц", "name": "txCentralFreq", "min": 900000, "step": 1}, + {"widget": "number", "label": "Символьная скорость, Бод", "name": "txBaudrate", "min": 0, "step": 1}, + {"widget": "number", "label": "Ослабление, дБ", "name": "txAttenuation", "min": 0, "step": 1} ] }, { @@ -43,29 +34,77 @@ "childs": [ { "widget": "h3", "label": "Настройки приемника" }, { - "widget": "select", - "label": "Режим управления усилением", - "name": "rxAgcEn", + "widget": "select", "label": "Режим управления усилением", "name": "rxAgcEn", "values": [ - { - "label": "АРУ", - "value": "true" - }, - { - "label": "РРУ", - "value": "false" - } + {"label": "АРУ", "value": "true"}, + {"label": "РРУ", "value": "false"} ] }, + {"widget": "checkbox", "label": "Инверсия спектра", "name": "rxSpectrumInversion"}, + {"widget": "number", "label": "Ручное усиление, дБ", "name": "rxManualGain", "v_show": "!paramRxtx.rxAgcEn", "min": -40}, + {"widget": "number", "label": "Центральная частота, КГц", "name": "rxCentralFreq", "min": 900000, "step": 1}, + {"widget": "number", "label": "Символьная скорость, Бод", "name": "rxBaudrate", "min": 0, "step": 1}, { - "widget": "checkbox", - "label": "Инверсия спектра", - "name": "rxSpectrumInversion" + "widget": "select", "label": "Roll-off", "name": "rxRolloff", + "values": [ + {"label": "0.02", "value": "2"}, + {"label": "0.05", "value": "5"}, + {"label": "0.10", "value": "10"}, + {"label": "0.15", "value": "15"}, + {"label": "0.20", "value": "20"}, + {"label": "0.25", "value": "25"} + ] } ] } ] } + ], + "buclnb": [ + {"widget": "h2", "label": "Настройки питания и опорного генератора"}, + { + "widget": "flex-container", + "childs": [ + { + "widget": "settings-container", + "childs": [ + {"widget": "h3", "label": "Настройки BUC"}, + {"widget": "checkbox", "label": "Подача опоры 10МГц", "name": "bucRefClk10M"}, + { + "widget": "select", "label": "Питание BUC", "name": "bucPowering", + "values": [ + {"label": "Выкл", "value": "0"}, + {"label": "24В", "value": "24"} + ] + } + ] + }, + { + "widget": "settings-container", + "childs": [ + {"widget": "h3", "label": "Настройки LNB"}, + {"widget": "checkbox", "label": "Подача опоры 10МГц", "name": "lnbRefClk10M"}, + { + "widget": "select", "label": "Питание LNB", "name": "lnbPowering", + "values": [ + {"label": "Выкл", "value": "0"}, + {"label": "13В", "value": "13"}, + {"label": "18В", "value": "18"}, + {"label": "24В", "value": "24"} + ] + } + ] + }, + { + "widget": "settings-container", + "childs": [ + {"widget": "h3", "label": "Сервисные настройки"}, + {"widget": "checkbox", "label": "Подача опоры 10МГц на 'Выход 10МГц'", "name": "srvRefClk10M"}, + {"widget": "checkbox", "label": "Автозапуск BUC и LNB при включении", "name": "bucLnbAutoStart"} + ] + } + ] + } ] }, "tabs": [ @@ -87,10 +126,7 @@ "modem_name": "RCSM-101", "params": { "rxtx": [ - { - "widget": "h2", - "label": "Настройки приема/передачи" - }, + {"widget": "h2", "label": "Настройки приема/передачи"}, { "widget": "settings-container", "childs": [ @@ -99,13 +135,13 @@ "label": "Режим работы", "name": "isCinC", "values": [ - { - "label": "CinC", - "value": "true" - }, { "label": "SCPC", "value": "false" + }, + { + "label": "CinC", + "value": "true" } ] } @@ -137,6 +173,70 @@ } ] } + ], + "cinc": [ + {"widget": "h2", "label": "Настройки режима CinC", "v_show": "paramRxtx.isCinC"}, + { + "widget": "settings-container", "v_show": "paramRxtx.isCinC", + "childs": [ + { + "widget": "select", "label": "Метод расчета задержки", "name": "cincIsPositional", + "values": [ + {"label": "Позиционированием", "value": "true"}, + {"label": "Окном задержки", "value": "false"} + ] + }, + {"widget": "number", "label": "Полоса поиска, КГц ±", "name": "cincSearchBandwidth", "min": 0, "step": 1, "max": 100} + + ] + } + ], + "buclnb": [ + {"widget": "h2", "label": "Настройки питания и опорного генератора"}, + { + "widget": "flex-container", + "childs": [ + { + "widget": "settings-container", + "childs": [ + {"widget": "h3", "label": "Настройки BUC"}, + {"widget": "checkbox", "label": "Подача опоры 10МГц", "name": "bucRefClk10M"}, + { + "widget": "select", "label": "Питание BUC", "name": "bucPowering", + "values": [ + {"label": "Выкл", "value": "0"}, + {"label": "24В", "value": "24"}, + {"label": "48В", "value": "48"} + ] + } + ] + }, + { + "widget": "settings-container", + "childs": [ + {"widget": "h3", "label": "Настройки LNB"}, + {"widget": "checkbox", "label": "Подача опоры 10МГц", "name": "lnbRefClk10M"}, + { + "widget": "select", "label": "Питание LNB", "name": "lnbPowering", + "values": [ + {"label": "Выкл", "value": "0"}, + {"label": "13В", "value": "13"}, + {"label": "18В", "value": "18"}, + {"label": "24В", "value": "24"} + ] + } + ] + }, + { + "widget": "settings-container", + "childs": [ + {"widget": "h3", "label": "Сервисные настройки"}, + {"widget": "checkbox", "label": "Подача опоры 10МГц на 'Выход 10МГц'", "name": "srvRefClk10M"}, + {"widget": "checkbox", "label": "Автозапуск BUC и LNB при включении", "name": "bucLnbAutoStart"} + ] + } + ] + } ] }, "tabs": [ diff --git a/front-generator/render.py b/front-generator/render.py index d1f3881..1990b70 100644 --- a/front-generator/render.py +++ b/front-generator/render.py @@ -5,7 +5,34 @@ import os def extract_param_names(mc): - result = {} + result = [] + + def helper_extract(widget): + if 'childs' in widget: + r = [] + for child in widget['childs']: + r += helper_extract(child) + return r + elif 'name' in widget: + match widget['widget']: + case 'select': return [{"name": widget['name'], "initValue": widget['values'][0]['value']}] + case 'checkbox': return [{"name": widget['name'], "initValue": 'false'}] + case 'number': return [{"name": widget['name'], "initValue": widget['min'] if widget['min'] else '0'}] + + return [{"name": widget['name'], "initValue": 'null'}] + return [] + + for cat in mc['params']: + ws = [] + for w in mc['params'][cat]: + ws += helper_extract(w) + ws.sort(key=lambda k: k['name']) + result.append({ + "group": cat, + "params": ws + }) + + return result @@ -27,7 +54,8 @@ def build_modem_env(modem): "header_tabs": mc['tabs'], "tab_names_array": [t['name'] for t in mc['tabs']], "params": mc["params"], - "paramGroupsWithNames": extract_param_names(mc), + "dangerousParamGroups": mc["dangerousParamGroups"] if 'dangerousParamGroups' in mc else {}, + "paramGroups": extract_param_names(mc), "paramGroupsList": extract_param_groups(mc), } diff --git a/front-generator/template/common/all-params-data.js.j2 b/front-generator/template/common/all-params-data.js.j2 new file mode 100644 index 0000000..02445a9 --- /dev/null +++ b/front-generator/template/common/all-params-data.js.j2 @@ -0,0 +1,7 @@ +{% for g in paramGroups %} + param{{ g['group'] | title }}: { + {% for p in g['params'] %} + {{ p['name'] }}: {{ p['initValue'] }}, + {% endfor %} + }, +{% endfor %} \ No newline at end of file diff --git a/front-generator/template/common/all-params-methods.js.j2 b/front-generator/template/common/all-params-methods.js.j2 new file mode 100644 index 0000000..82d61cd --- /dev/null +++ b/front-generator/template/common/all-params-methods.js.j2 @@ -0,0 +1,29 @@ + {% for g in paramGroups %} + settingsSubmit{{ g['group'] | title }}() { + if (this.submitStatus.{{ g['group'] }}) { return } + {% if g['group'] in dangerousParamGroups %} + { if (!confirm("{{ dangerousParamGroups[g['group']] }}")) return } + {% endif %} + + let query = { + {% for p in g['params'] %} + "{{ p['name'] }}": this.param{{ g['group'] | title }}.{{ p['name'] }}, + {% endfor %} + } + + this.submitStatus.{{ g['group'] }} = true + fetch('/api/set/{{ g["group"] }}', {method: 'POST', headers: {'Content-Type': 'application/json'}, body: JSON.stringify(query) }) + .then(async (resp) => { this.update{{ g['group'] | title }}Settings(await resp.json()) }) + .catch((reason) => { alert(`Ошибка при применении настроек: ${reason}`) }) + .finally(() => { this.submitStatus.{{ g['group'] }} = false }) + }, + {% endfor %} + + {% for g in paramGroups %} + update{{ g['group'] | title }}Settings(vals) { + this.submitStatus.{{ g['group'] }} = false + {% for p in g['params'] %} + this.param{{ g['group'] | title }}.{{ p['name'] }} = vals["settings"]["{{ p['name'] }}"] + {% endfor %} + }, + {% endfor %} \ No newline at end of file diff --git a/front-generator/template/common/setup-data.js.j2 b/front-generator/template/common/setup-data.js.j2 deleted file mode 100644 index e978c42..0000000 --- a/front-generator/template/common/setup-data.js.j2 +++ /dev/null @@ -1,55 +0,0 @@ -{% if 'rxtx' in params.paramGroupsList %} -paramsRxtx: { - isCinC: Boolean, - txEn: Boolean, // включен/выключен - modulatorMode: 'normal', // режим работы модулятора - autoStartTx: Boolean, // было "режим работы передатчика" - isTestInputData: Boolean, // входные данные: eth или test - txAttenuation: Number, // ослабление - txRolloff: Number, - txCymRate: Number, - txCenterFreq: Number, - txMode: null, // ccm/acm - txFrameSizeNormal: null, // 'normal' / 'short' - txIsPilots: false, - txCcmModulation: null, - txCcmSpeed: null, - txAcmMaxModulation: null, - txAcmMaxSpeed: null, - txAcmMinModulation: null, - txAcmMinSpeed: null, - txSnrReserve: null, - txServicePacketPeriod: null, - txAcmEn: false, - txAcmMaxAttenuation: null, - txAcmMinAttenuation: null, - txAcmRequiredSnr: null, - - rxGainMode: null, // 'auto'/'manual' режим управления усилением - rxManualGain: 0, // усиление, только для ручного режима - rxSpectrumInversion: false, - rxRolloff: 0, - rxCymRate: 100000, - rxCenterFreq: 1200000.0, -}, -{% endif %} -{% if 'cinc' in params.paramGroupsList %} -paramsCinc: { - cincMode: null, // 'positional' | 'delay' - cincSearchBandwidth: 0, // полоса поиска в кГц - cincPosition: {station: {latitude: 0, longitude: 0}, satelliteLongitude: 0}, - cincDelayMin: 0, - cincDelayMax: 0 -}, -{% endif %} -{% if 'buclnb' in params.paramGroupsList %} -paramsBuclnb: { - bucRefClk10M: false, // подача опоры 10MHz - bucPowering: 0, // 0, 24, 48 - lnbRefclk10m: false, // подача опоры 10MHz - lnbPowering: 0 // 0, 13, 18, 24 - sysRefClk10M: false, // подача опоры 10MHz - sysAutoStart: false -}, -{% endif %} - diff --git a/front-generator/template/common/setup-methods.js.j2 b/front-generator/template/common/setup-methods.js.j2 deleted file mode 100644 index 3ae6070..0000000 --- a/front-generator/template/common/setup-methods.js.j2 +++ /dev/null @@ -1,180 +0,0 @@ - {% if 'rxtx' in params.paramGroupsList %} - settingsSubmitRxtx() { - if (this.submitStatus.rxTx) { return } - // потом добавить: "dvbs2.isPilots": this.param.dvbs2.isPilots - let query = { - "general.isCinC": this.param.general.isCinC, - "general.txEn": this.param.general.txEn, - "general.modulatorMode": this.param.general.modulatorMode, - "general.autoStartTx": this.param.general.autoStartTx, - "general.isTestInputData": this.param.general.isTestInputData, - "tx.attenuation": this.param.tx.attenuation, - "tx.rolloff": this.param.tx.rolloff, - "tx.cymRate": this.param.tx.cymRate, - "tx.centerFreq": this.param.tx.centerFreq, - "dvbs2.isAcm": this.param.dvbs2.mode === 'acm', - "dvbs2.frameSizeNormal": this.param.dvbs2.frameSizeNormal, - "dvbs2.ccm_modcod": toModcod(this.param.dvbs2.ccm_modulation, this.param.dvbs2.ccm_speed), - "dvbs2.acm_minModcod": toModcod(this.param.dvbs2.acm_minModulation, this.param.dvbs2.acm_minSpeed), - "dvbs2.acm_maxModcod": toModcod(this.param.dvbs2.acm_maxModulation, this.param.dvbs2.acm_maxSpeed), - "dvbs2.snrReserve": this.param.dvbs2.snrReserve, - "dvbs2.servicePacketPeriod": this.param.dvbs2.servicePacketPeriod, - "acm.en": this.param.acm.en, - "acm.maxAttenuation": this.param.acm.maxAttenuation, - "acm.minAttenuation": this.param.acm.minAttenuation, - "acm.requiredSnr": this.param.acm.requiredSnr, - "rx.gainMode": this.param.rx.gainMode, - "rx.manualGain": this.param.rx.manualGain, - "rx.spectrumInversion": this.param.rx.spectrumInversion, - "rx.rolloff": this.param.rx.rolloff, - "rx.cymRate": this.param.rx.cymRate, - "rx.centerFreq": this.param.rx.centerFreq - } - - this.submitStatus.rxTx = true - fetch('/api/set/rxtx', { - method: 'POST', - headers: { - 'Content-Type': 'application/json' - }, - body: JSON.stringify(query) - }).then(async (resp) => { - this.submitStatus.rxTx = false - this.updateRxTxSettings(await resp.json()) - }).catch((reason) => { - this.submitStatus.rxTx = false - alert(`Ошибка при применении настроек: ${reason}`) - }) - }, - updateRxtxSettings(vals) { - this.submitStatus.rxTx = false - this.param.general.isCinC = vals["settings"]["general.isCinC"] - this.param.general.txEn = vals["settings"]["general.txEn"] - this.param.general.modulatorMode = vals["settings"]["general.modulatorMode"] - this.param.general.autoStartTx = vals["settings"]["general.autoStartTx"] - this.param.general.isTestInputData = vals["settings"]["general.isTestInputData"] - - this.param.tx.attenuation = vals["settings"]["tx.attenuation"] - this.param.tx.rolloff = vals["settings"]["tx.rolloff"] - this.param.tx.cymRate = vals["settings"]["tx.cymRate"] - this.param.tx.centerFreq = vals["settings"]["tx.centerFreq"] - - this.param.dvbs2.mode = (vals["settings"]["dvbs2.isAcm"] ? 'acm' : 'ccm') - this.param.dvbs2.frameSizeNormal = vals["settings"]["dvbs2.frameSizeNormal"] - // this.param.dvbs2.isPilots = vals["settings"]["dvbs2.isPilots"] - - let m = extractModulationAndSpeedFromModcod(vals["settings"]["dvbs2.ccm_modcod"]) - this.param.dvbs2.ccm_modulation = m.modulation - this.param.dvbs2.ccm_speed = m.speed - m = extractModulationAndSpeedFromModcod(vals["settings"]["dvbs2.acm_maxModcod"]) - this.param.dvbs2.acm_maxModulation = m.modulation - this.param.dvbs2.acm_maxSpeed = m.speed - m = extractModulationAndSpeedFromModcod(vals["settings"]["dvbs2.acm_minModcod"]) - this.param.dvbs2.acm_minModulation = m.modulation - this.param.dvbs2.acm_minSpeed = m.speed - - this.param.dvbs2.snrReserve = vals["settings"]["dvbs2.snrReserve"] - this.param.dvbs2.servicePacketPeriod = vals["settings"]["dvbs2.servicePacketPeriod"] - - this.param.acm.en = vals["settings"]["acm.en"] - this.param.acm.maxAttenuation = vals["settings"]["acm.maxAttenuation"] - this.param.acm.minAttenuation = vals["settings"]["acm.minAttenuation"] - this.param.acm.requiredSnr = vals["settings"]["acm.requiredSnr"] - - this.param.rx.gainMode = vals["settings"]["rx.gainMode"] - this.param.rx.manualGain = vals["settings"]["rx.manualGain"] - this.param.rx.spectrumInversion = vals["settings"]["rx.spectrumInversion"] - this.param.rx.rolloff = vals["settings"]["rx.rolloff"] - this.param.rx.cymRate = vals["settings"]["rx.cymRate"] - this.param.rx.centerFreq = vals["settings"]["rx.centerFreq"] - }, - {% endif %} - - settingsSubmitCinC() { - if (this.submitStatus.cinc) { return } - - let query = { - "cinc.mode": this.param.cinc.mode, - "cinc.searchBandwidth": this.param.cinc.searchBandwidth, - "cinc.position.station.latitude": this.param.cinc.position.station.latitude, - "cinc.position.station.longitude": this.param.cinc.position.station.longitude, - "cinc.position.satelliteLongitude": this.param.cinc.position.satelliteLongitude, - "cinc.delayMin": this.param.cinc.delayMin, - "cinc.delayMax": this.param.cinc.delayMax - } - this.submitStatus.cinc = true - fetch('/api/set/cinc', { - method: 'POST', - headers: { - 'Content-Type': 'application/json' - }, - body: JSON.stringify(query) - }).then(async (resp) => { - this.submitStatus.cinc = false - this.updateCincSettings(await resp.json()) - }).catch((reason) => { - this.submitStatus.cinc = false - alert(`Ошибка при применении настроек: ${reason}`) - }) - }, - - settingsSubmitBucLnb() { - if (this.submitStatus.bucLnb) { return } - let query = { - "buc.refClk10M": this.param.buc.refClk10M, - "buc.powering": parseInt(this.param.buc.powering), - "lnb.refClk10M": this.param.lnb.refClk10M, - "lnb.powering": parseInt(this.param.lnb.powering), - "serviceSettings.refClk10M": this.param.serviceSettings.refClk10M, - "serviceSettings.autoStart": this.param.serviceSettings.autoStart - } - if (confirm('Вы уверены, что хотите сохранить настройки BUC и LNB?')) { - this.submitStatus.bucLnb = true - fetch('/api/set/bucLnb', { - method: 'POST', - headers: { - 'Content-Type': 'application/json' - }, - body: JSON.stringify(query) - }).then(async (resp) => { - this.submitStatus.bucLnb = false - this.updateBucLnbSettings(await resp.json()) - }).catch((reason) => { - this.submitStatus.bucLnb = false - alert(`Ошибка при применении настроек: ${reason}`) - }) - } - }, - - - - updateCincSettings(vals) { - this.submitStatus.cinc = false - this.param.cinc.mode = vals["settings"]["cinc.mode"] - this.param.cinc.searchBandwidth = vals["settings"]["cinc.searchBandwidth"] - this.param.cinc.position.station.latitude = vals["settings"]["cinc.position.station.latitude"] - this.param.cinc.position.station.longitude = vals["settings"]["cinc.position.station.longitude"] - this.param.cinc.position.satelliteLongitude = vals["settings"]["cinc.position.satelliteLongitude"] - this.param.cinc.delayMin = vals["settings"]["cinc.delayMin"] - this.param.cinc.delayMax = vals["settings"]["cinc.delayMax"] - }, - - updateBucLnbSettings(vals) { - this.submitStatus.bucLnb = false - this.param.buc.refClk10M = vals["settings"]["buc.refClk10M"] - this.param.buc.powering = vals["settings"]["buc.powering"] - this.param.lnb.refClk10M = vals["settings"]["lnb.refClk10M"] - this.param.lnb.powering = vals["settings"]["lnb.powering"] - this.param.serviceSettings.refClk10M = vals["settings"]["serviceSettings.refClk10M"] - this.param.serviceSettings.autoStart = vals["settings"]["serviceSettings.autoStart"] - }, - - updateSettings(vals) { - this.settingFetchComplete = true - this.updateRxTxSettings(vals) - this.updateCincSettings(vals) - this.updateBucLnbSettings(vals) - this.updateQosSettings(vals) - this.updateNetworkSettings(vals) - this.updateDebugSendSettings(vals) - }, \ No newline at end of file diff --git a/front-generator/template/common/setup.html.j2 b/front-generator/template/common/setup.html.j2 index 8a1b2af..4cd0ecb 100644 --- a/front-generator/template/common/setup.html.j2 +++ b/front-generator/template/common/setup.html.j2 @@ -2,8 +2,8 @@