From 62e17d90593992ec623d0c3676c59520ecf2ac48 Mon Sep 17 00:00:00 2001 From: Carl Laufer Date: Fri, 7 Jan 2022 05:09:27 +0000 Subject: change the way preconfig loading works to fix clientside nonexistent object js error --- _UI/_web_interface/kraken_web_interface.py | 120 ++++++++++++++++++++--------- 1 file changed, 85 insertions(+), 35 deletions(-) diff --git a/_UI/_web_interface/kraken_web_interface.py b/_UI/_web_interface/kraken_web_interface.py index 021fe26..eb9cd50 100755 --- a/_UI/_web_interface/kraken_web_interface.py +++ b/_UI/_web_interface/kraken_web_interface.py @@ -652,6 +652,9 @@ def generate_config_page_layout(webInterface_inst): html.Div([ html.Div("Preconfigured DAQ Files", className="field-label"), + #TEST + #dcc.Input(id='daq_cfg_files', value=cfg_data_block_len, type='number', debounce=True, className="field-body"), + dcc.Dropdown(id='daq_cfg_files', options=[ {'label': str(i[1]), 'value': i[0]} for i in preconfigs @@ -1212,7 +1215,7 @@ def display_page(pathname): elif pathname == "/spectrum": webInterface_inst.module_signal_processor.en_spectrum = True spectrum_fig = None # Force reload of graphs as axes may change etc - time.sleep(1) + #time.sleep(1) return [spectrum_page_layout, "header_inactive", "header_active", "header_inactive"] elif pathname == "/pr": webInterface_inst.module_signal_processor.en_spectrum = False @@ -1377,8 +1380,8 @@ def update_dsp_params(update_freq, en_pr, en_persist, persist_decay, max_bistati Input('cfg_daq_buffer_size' ,'value'), Input('cfg_sample_rate' ,'value'), Input('en_noise_source_ctr' ,'value'), - Input('en_squelch_mode' ,'value'), - Input('cfg_squelch_init_th' ,'value'), + #Input('en_squelch_mode' ,'value'), + #Input('cfg_squelch_init_th' ,'value'), Input('cfg_cpi_size' ,'value'), Input('cfg_decimation_ratio' ,'value'), Input('cfg_fir_bw' ,'value'), @@ -1399,16 +1402,20 @@ def update_dsp_params(update_freq, en_pr, en_persist, persist_decay, max_bistati Input('cfg_max_sync_fails' ,'value'), Input('cfg_data_block_len' ,'value'), Input('cfg_decimated_bw' ,'value'), - Input('cfg_recal_interval' ,'value')] + Input('cfg_recal_interval' ,'value'), + Input('daq_cfg_files' , 'value'), + +] ) def update_daq_ini_params( cfg_rx_channels,cfg_daq_buffer_size,cfg_sample_rate,en_noise_source_ctr, \ - en_squelch_mode,cfg_squelch_init_th,cfg_cpi_size,cfg_decimation_ratio, \ + #en_squelch_mode,cfg_squelch_init_th,cfg_cpi_size,cfg_decimation_ratio, \ + cfg_cpi_size,cfg_decimation_ratio, \ cfg_fir_bw,cfg_fir_tap_size,cfg_fir_window,en_filter_reset,cfg_corr_size, \ cfg_std_ch_ind,en_iq_cal,cfg_gain_lock,en_req_track_lock_intervention, \ cfg_cal_track_mode,cfg_amplitude_cal_mode,cfg_cal_frame_interval, \ cfg_cal_frame_burst_size, cfg_amplitude_tolerance,cfg_phase_tolerance, \ - cfg_max_sync_fails, cfg_data_block_len, cfg_decimated_bw, cfg_recal_interval): + cfg_max_sync_fails, cfg_data_block_len, cfg_decimated_bw, cfg_recal_interval, config_fname): # TODO: Use disctionarry instead of parameter list ctx = dash.callback_context @@ -1417,6 +1424,68 @@ def update_daq_ini_params( if len(ctx.triggered) == 1: # User manually changed one parameter webInterface_inst.tmp_daq_ini_cfg = "Custom" + # If is was the preconfig changed, just update the preconfig values + if component_id == 'daq_cfg_files': + webInterface_inst.daq_ini_cfg_params = read_config_file(config_fname) + webInterface_inst.tmp_daq_ini_cfg = webInterface_inst.daq_ini_cfg_params[0] + + daq_cfg_params = webInterface_inst.daq_ini_cfg_params + + if daq_cfg_params is not None: + en_noise_src_values =[1] if daq_cfg_params[4] else [] + en_squelch_values =[1] if daq_cfg_params[5] else [] + en_filter_rst_values =[1] if daq_cfg_params[12] else [] + en_iq_cal_values =[1] if daq_cfg_params[15] else [] + en_req_track_lock_values =[1] if daq_cfg_params[17] else [] + + + en_persist_values =[1] if webInterface_inst.en_persist else [] + en_pr_values =[1] if webInterface_inst.module_signal_processor.en_PR else [] + + en_advanced_daq_cfg =[1] if webInterface_inst.en_advanced_daq_cfg else [] + + cfg_decimated_bw = ((daq_cfg_params[3]) / daq_cfg_params[8]) / 10**3 + cfg_data_block_len = ( daq_cfg_params[7] / (cfg_decimated_bw) ) + cfg_recal_interval = (daq_cfg_params[20] * (cfg_data_block_len/10**3)) / 60 + + if daq_cfg_params[18] == 0: #If set to no tracking + cfg_recal_interval = 1 + + app.push_mods({ + 'cfg_data_block_len': {'value': cfg_data_block_len}, + 'cfg_decimated_bw': {'value': cfg_decimated_bw}, + 'cfg_recal_interval': {'value': cfg_recal_interval}, + + 'cfg_rx_channels': {'value': daq_cfg_params[1]}, + 'cfg_daq_buffer_size': {'value': daq_cfg_params[2]}, + 'cfg_sample_rate': {'value': daq_cfg_params[3]/10**6}, + 'en_noise_source_ctr': {'value': en_noise_src_values}, + 'cfg_cpi_size': {'value': daq_cfg_params[7]}, + 'cfg_decimation_ratio': {'value': daq_cfg_params[8]}, + 'cfg_fir_bw': {'value': daq_cfg_params[9]}, + 'cfg_fir_tap_size': {'value': daq_cfg_params[10]}, + 'cfg_fir_window': {'value': daq_cfg_params[11]}, + 'en_filter_reset': {'value': en_filter_rst_values}, + 'cfg_cal_frame_interval': {'value': daq_cfg_params[20]}, + 'cfg_corr_size': {'value': daq_cfg_params[13]}, + 'cfg_std_ch_ind': {'value': daq_cfg_params[14]}, + 'en_iq_cal': {'value': en_iq_cal_values}, + 'cfg_gain_lock': {'value': daq_cfg_params[16]}, + 'en_req_track_lock_intervention': {'value': en_req_track_lock_values}, + 'cfg_cal_track_mode': {'value': daq_cfg_params[18]}, + 'cfg_amplitude_cal_mode': {'value': daq_cfg_params[19]}, + 'cfg_cal_frame_interval': {'value': daq_cfg_params[20]}, + 'cfg_cal_frame_burst_size': {'value': daq_cfg_params[21]}, + 'cfg_amplitude_tolerance': {'value': daq_cfg_params[22]}, + 'cfg_phase_tolerance': {'value': daq_cfg_params[23]}, + 'cfg_max_sync_fails': {'value': daq_cfg_params[24]}, + }) + + return Output('dummy_output', 'children', '') #[no_update, no_update, no_update, no_update] + + + + # If the input was from basic DAQ config, update the actual DAQ params if component_id == "cfg_data_block_len" or component_id == "cfg_decimated_bw" or component_id == "cfg_recal_interval": if not cfg_data_block_len or not cfg_decimated_bw or not cfg_recal_interval: @@ -1438,19 +1507,6 @@ def update_daq_ini_params( cfg_phase_tolerance = 2 cfg_max_sync_fails = 10 - # Set sample rate to something sensible for the desired decimated_bw - """ - if cfg_decimated_bw < 3: - cfg_sample_rate = 0.25 - cfg_corr_size = 4096 - cfg_daq_buffer_size = 16384 - elif cfg_decimated_bw < 10: - cfg_sample_rate = 1.024 - cfg_corr_size = 16384 - else: - cfg_sample_rate = 2.4 - """ - cfg_decimation_ratio = round( (cfg_sample_rate*10**6) / (cfg_decimated_bw*10**3) ) cfg_cpi_size = round( (cfg_data_block_len / 10**3) * cfg_decimated_bw*10**3 ) @@ -1483,11 +1539,15 @@ def update_daq_ini_params( param_list.append(1) else: param_list.append(0) - if en_squelch_mode is not None and len(en_squelch_mode): - param_list.append(1) - else: - param_list.append(0) - param_list.append(cfg_squelch_init_th) + + #if en_squelch_mode is not None and len(en_squelch_mode): + # param_list.append(1) + #else: + param_list.append(0) #en_squelch placeholder + + #param_list.append(cfg_squelch_init_th) + param_list.append(0) #cfg_squelch_init_th placeholder + param_list.append(cfg_cpi_size) param_list.append(cfg_decimation_ratio) param_list.append(cfg_fir_bw) @@ -1544,7 +1604,7 @@ def update_daq_ini_params( 'cfg_daq_buffer_size': {'value': cfg_daq_buffer_size}, 'cfg_corr_size': {'value': cfg_corr_size}, 'en_noise_source_ctr': {'value': en_noise_source_ctr}, - 'en_squelch_mode': {'value': en_squelch_mode}, + #'en_squelch_mode': {'value': en_squelch_mode}, 'cfg_fir_bw': {'value': cfg_fir_bw}, 'cfg_fir_window': {'value': cfg_fir_window}, 'en_filter_reset': {'value': en_filter_reset}, @@ -1570,16 +1630,6 @@ def toggle_adv_daq(toggle_value): else: return {'display': 'none'} -@app.callback([Output("url" , "pathname")], - [ #Input("en_advanced_daq_cfg" , "value"), - Input("daq_cfg_files" , "value"), - Input("placeholder_recofnig_daq" , "children"), - Input("placeholder_update_rx" , "children")] -) -def reload_cfg_page(config_fname, dummy_0, dummy_1): - webInterface_inst.daq_ini_cfg_params = read_config_file(config_fname) - webInterface_inst.tmp_daq_ini_cfg = webInterface_inst.daq_ini_cfg_params[0] - return ["/config"] @app.callback( None, -- cgit v1.2.3