фикс некорректного ограничения центральной частоты
This commit is contained in:
@@ -22,7 +22,7 @@
|
||||
"values": [{"label": "Нормальный", "value": "false"}, {"label": "Тест (CW)", "value": "true"}]
|
||||
},
|
||||
{"widget": "number", "label": "Центральная частота, КГц", "name": "txCentralFreq", "min": 900000, "step": 0.01, "v_show": "paramRxtx.txModulatorIsTest"},
|
||||
{"widget": "number", "label": "Ослабление, дБ", "name": "txAttenuation", "min": 0, "step": 1}
|
||||
{"widget": "number", "label": "Ослабление, дБ", "name": "txAttenuation", "max": 0, "min": -40, "step": 1}
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -154,7 +154,7 @@
|
||||
"values": [{"label": "Ethernet", "value": "false"}, {"label": "Тест", "value": "true"}]
|
||||
},
|
||||
{"widget": "h3", "label": "Параметры передачи"},
|
||||
{"widget": "number-int", "label": "Центральная частота, КГц", "name": "txCentralFreq", "min": 950000, "max": 6000000},
|
||||
{"widget": "number-int", "label": "Центральная частота, КГц", "name": "txCentralFreq", "min": 950000, "max": 6000000, "step": 0.01},
|
||||
{"widget": "number-int", "label": "Символьная скорость, Бод", "name": "txBaudrate", "min": 200000, "max": 54000000},
|
||||
{
|
||||
"widget": "select", "label": "Roll-off", "name": "txRolloff",
|
||||
@@ -164,7 +164,7 @@
|
||||
"widget": "select", "label": "Номер последовательности Голда", "name": "txGoldan",
|
||||
"values": [{"label": "0", "value": "0"}, {"label": "1", "value": "1"}]
|
||||
},
|
||||
{"widget": "number", "label": "Ослабление, дБ", "name": "txAttenuation", "min": 0, "step": 1}
|
||||
{"widget": "number", "label": "Ослабление, дБ", "name": "txAttenuation", "max": 0, "min": -40, "step": 0.25}
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -198,8 +198,8 @@
|
||||
"childs": [
|
||||
{"widget": "h3", "label": "Авто-регулировка мощности"},
|
||||
{"widget": "checkbox", "label": "Авто-регулировка мощности", "name": "aupcEn"},
|
||||
{"widget": "number", "label": "Минимальное ослабление, дБ", "name": "aupcMinAttenuation", "min": 0, "step": 0.01, "max": 10},
|
||||
{"widget": "number", "label": "Максимальное ослабление, дБ", "name": "aupcMaxAttenuation", "min": 0, "step": 0.01, "max": 10},
|
||||
{"widget": "number", "label": "Минимальное ослабление, дБ", "name": "aupcMinAttenuation", "min": 0, "step": 0.1, "max": 10},
|
||||
{"widget": "number", "label": "Максимальное ослабление, дБ", "name": "aupcMaxAttenuation", "min": 0, "step": 0.1, "max": 10},
|
||||
{"widget": "number", "label": "Требуемое ОСШ", "name": "aupcRequiredSnr", "min": 0, "step": 0.01, "max": 10}
|
||||
]
|
||||
},
|
||||
@@ -214,7 +214,7 @@
|
||||
{"widget": "number", "label": "Усиление, дБ", "name": "rxManualGain", "min": -40, "step": 0.01, "max": 40, "v_show": "paramRxtx.rxAgcEn === false"},
|
||||
{"widget": "watch-expr", "label": "Текущее усиление", "expr": "paramRxtx.rxManualGain", "v_show": "paramRxtx.rxAgcEn === true"},
|
||||
{"widget": "checkbox", "label": "Инверсия спектра", "name": "rxSpectrumInversion"},
|
||||
{"widget": "number-int", "label": "Центральная частота, КГц", "name": "rxCentralFreq", "min": 950000, "max": 6000000},
|
||||
{"widget": "number-int", "label": "Центральная частота, КГц", "name": "rxCentralFreq", "min": 950000, "max": 6000000, "step": 0.01},
|
||||
{"widget": "number-int", "label": "Символьная скорость, Бод", "name": "rxBaudrate", "min": 200000, "max": 54000000},
|
||||
{
|
||||
"widget": "select", "label": "Roll-off", "name": "rxRolloff",
|
||||
|
@@ -22,6 +22,8 @@ def extract_param_names(mc):
|
||||
copy_fields['min'] = widget['min']
|
||||
if 'max' in widget:
|
||||
copy_fields['max'] = widget['max']
|
||||
if 'step' in widget:
|
||||
copy_fields['step'] = widget['step']
|
||||
|
||||
match widget['widget']:
|
||||
case 'select': return [{"initValue": widget['values'][0]['value']} | copy_fields]
|
||||
|
@@ -6,11 +6,11 @@
|
||||
{# https://ru.stackoverflow.com/questions/1241064 #}
|
||||
{% macro build_widget_number(param_group, widget) %}<label{% if widget.v_show %} v-show="{{ widget.v_show }}"{% endif %}><span>{{ widget.label }}</span><input type="number" v-model="param{{ param_group | title }}.{{ widget.name }}"{% if widget['min'] %} min="{{ widget['min'] }}"{% endif %}{% if widget['max'] %} max="{{ widget['max'] }}"{% endif %}{% if widget['step'] %} step="{{ widget['step'] }}"{% endif %}/></label>{% endmacro %}
|
||||
|
||||
{% macro js_build_number_int_validator(widget) %}{{ '{' }}{% if widget['min'] %}min:{{ widget['min'] }},{% endif %}{% if widget['max'] %}max:{{ widget['max'] }}{% endif %}{{ '}' }}{% endmacro %}
|
||||
{% macro js_build_number_number_validator(widget) %}{{ '{' }}{% if widget['min'] %}min:{{ widget['min'] }},{% endif %}{% if widget['max'] %}max:{{ widget['max'] }},{% endif %}{% if widget['step'] %}step:{{ widget['step'] }}{% endif %}{{ '}' }}{% endmacro %}
|
||||
|
||||
{% macro build_widget_number_int(param_group, widget) %}<label{% if widget.v_show %} v-show="{{ widget.v_show }}"{% endif %}>
|
||||
<span>{{ widget.label }}</span>
|
||||
<input type="text" v-model.lazy="param{{ param_group | title }}.{{ widget.name }}" @change="e => {{ build_setter(param_group, widget, "inputFormatInt(e.target.value, " ~ js_build_number_int_validator(widget) ~ ")") }}"/>
|
||||
<input type="text" v-model.lazy="param{{ param_group | title }}.{{ widget.name }}" @change="e => {{ build_setter(param_group, widget, "inputFormatNumber(e.target.value, " ~ js_build_number_number_validator(widget) ~ ")") }}"/>
|
||||
</label>{% endmacro %}
|
||||
|
||||
|
||||
@@ -79,15 +79,15 @@
|
||||
|
||||
{% macro build_getter_js(param_group, widget) %}{% if widget.widget in ['flex-container', 'settings-container', 'h2', 'h3', 'submit', 'watch', 'watch-expr'] %}null{%
|
||||
elif widget.widget in ['checkbox', 'number', 'select', 'ip-address', 'modulation-modcod', 'modulation-speed'] %}this.param{{ param_group | title }}.{{ widget.name }}{%
|
||||
elif widget.widget == 'number-int' %}parseInt(this.param{{ param_group | title }}.{{ widget.name }}.replace(/[^0-9]/g, '')){%
|
||||
elif widget.widget == 'number-int' %}parseFloat(this.param{{ param_group | title }}.{{ widget.name }}.replace(/[^0-9,.]/g, '').replace(',', '.')){%
|
||||
else %}<p>Widget '{{ widget.widget }}' not defined!</p><p>{{ widget }}</p>{% endif %}{% endmacro %}
|
||||
|
||||
{% macro build_setter_js(param_group, widget, expr) %}{% if widget.widget in ['flex-container', 'settings-container', 'h2', 'h3', 'submit', 'watch', 'watch-expr'] %}null{%
|
||||
elif widget.widget in ['checkbox', 'number', 'select', 'ip-address', 'modulation-modcod', 'modulation-speed'] %}this.param{{ param_group | title }}.{{ widget.name }} = {{ expr }}{%
|
||||
elif widget.widget == 'number-int' %}this.param{{ param_group | title }}.{{ widget.name }} = this.inputFormatInt({{ expr }}, {{ js_build_number_int_validator(widget) }}){%
|
||||
elif widget.widget == 'number-int' %}this.param{{ param_group | title }}.{{ widget.name }} = this.inputFormatNumber({{ expr }}, {{ js_build_number_number_validator(widget) }}){%
|
||||
else %}<p>Widget '{{ widget.widget }}' not defined!</p><p>{{ widget }}</p>{% endif %}{% endmacro %}
|
||||
|
||||
{% macro build_setter(param_group, widget, expr) %}{% if widget.widget in ['flex-container', 'settings-container', 'h2', 'h3', 'submit', 'watch', 'watch-expr'] %}null{%
|
||||
elif widget.widget in ['checkbox', 'number', 'select', 'ip-address', 'modulation-modcod', 'modulation-speed'] %}param{{ param_group | title }}.{{ widget.name }} = {{ expr }}{%
|
||||
elif widget.widget == 'number-int' %}param{{ param_group | title }}.{{ widget.name }} = ({{ expr }}).toString(){%
|
||||
elif widget.widget == 'number-int' %}param{{ param_group | title }}.{{ widget.name }} = inputFormatNumber({{ expr }}, {{ js_build_number_number_validator(widget) }}){%
|
||||
else %}<p>Widget '{{ widget.widget }}' not defined!</p><p>{{ widget }}</p>{% endif %}{% endmacro %}
|
||||
|
@@ -153,10 +153,12 @@
|
||||
return []
|
||||
}
|
||||
},
|
||||
inputFormatInt(src, validation) {
|
||||
inputFormatNumber(src, validation) {
|
||||
if (validation === null || validation === undefined) { validation = {} }
|
||||
const rawVal = src.toString().replace(/[^0-9]/g, '')
|
||||
let result = rawVal === '' ? 0 : parseInt(rawVal)
|
||||
const rawVal = src.toString().replace(/[^0-9.,]/g, '').replace(',', '.')
|
||||
let result = rawVal === '' ? 0 : parseFloat(rawVal)
|
||||
const step = 'step' in validation ? validation['step']: 1.0
|
||||
result = Math.round(result / step) * step
|
||||
if ('min' in validation) { if (result <= validation['min']) { result = validation['min'] } }
|
||||
if ('max' in validation) { if (result >= validation['max']) { result = validation['max'] } }
|
||||
return result.toLocaleString()
|
||||
|
Reference in New Issue
Block a user