# # # # set_report_progress_util.cfv # # # # get_report_progress_info_setup_for_export() # get_report_progress_info_setup() # # get_report_progress_substep_info() # increment_progress_substep() # set_progress_substep() # prepare_increment_iterative_progress_substep() # set_iterative_progress_substep() include "templates.util.base_util"; # # # # # get_report_progress_info_setup_for_export() # # # # #* DISABLED because we don't show progress in export for now. subroutine(get_report_progress_info_setup_for_export, ( # This creates the initial progress setup information for export only. int max_value = 10000; node progress_info = new_node(); # Set up the top-level progress information @progress_info{"label"} = lang_stats.progress.major_task.generating_report; @progress_info{"number_of_steps"} = 1; @progress_info{"current_step"} = 0; @progress_info{"max_value_per_step"} = max_value; # max_value_per_step is not required by the C++ but is used by Salang only # Set the step information @progress_info{"step"}{"0"} = ""; node the_step = progress_info{"step"}{"0"}; @ the_step{"operation"} = "0"; @ the_step{"label"} = ""; @ the_step{"value"} = 0; @ the_step{"max_value"} = max_value; progress_info; )); *# # # # # # get_report_progress_info_setup() # # # # subroutine(get_report_progress_info_setup( string report_label, node report_elements), ( debug_message("#### get_report_progress_info_setup() START \n"); # This creates the initial progress setup information, the progress_info node # which is used to initiate progress by the C++. # Each report element is presented by a single step node. # Set major progress label string major_label = lang_stats.progress.generating_report; node progress_info = new_node(); int step_count = 0; # Set up the top-level progress information @progress_info{"label"} = major_label; @progress_info{"number_of_steps"} = 0; @progress_info{"current_step"} = 0; @progress_info{"max_value_per_step"} = 0; # max_value_per_step is not required by the C++ but is used by Salang only node item; node the_step; string report_element_label; string step_label; int is_multiple_report_elements = (num_subnodes(report_elements) > 1); foreach item report_elements ( if (@item{"create_report_element"}) then ( report_element_label = get_expanded_label(@item{"label"}); # Set param1 for step_label if (is_multiple_report_elements and report_element_label ne "") then ( # volatile.param1 = report_label . ' - ' . report_element_label; step_label = report_label . ' - ' . report_element_label; ) else ( # volatile.param1 = report_label; step_label = report_label ); @progress_info{"step"}{step_count} = ""; the_step = progress_info{"step"}{step_count}; @ the_step{"operation"} = step_count; @ the_step{"label"} = step_label; @ the_step{"value"} = 0; @ the_step{"max_value"} = 0; # We set the final max_value later, depending on the number of report elements step_count++; ); ); # Set final number of steps @progress_info{"number_of_steps"} = step_count; # # # Set max_value per step (respectively per report element) # The sum of all max_value steps should be about 10000. # int max_value_per_step = 10000 / step_count; @progress_info{"max_value_per_step"} = max_value_per_step; node progress_info_steps = progress_info{"step"}; foreach item progress_info_steps ( @item{"max_value"} = max_value_per_step; ); debug_message("#### progress_info:\n" . node_as_string(progress_info) . "\n"); progress_info; debug_message("#### get_report_progress_info_setup() END \n"); )); # # # # get_report_progress_substep_info() # # # subroutine(get_report_progress_substep_info( int max_value_per_step), ( debug_message("#### get_report_progress_substep_info() START \n"); # Create a node like # progress_substep_info = { # max_points_per_step = max_value_per_step # substep_interval_points = 300 # substep_min_points = 0 # used_points = 0 # } node progress_substep_info = new_node(); @progress_substep_info{"max_points_per_step"} = max_value_per_step; @progress_substep_info{"substep_interval_points"} = 0; @progress_substep_info{"substep_interval_start_points"} = 0; @progress_substep_info{"used_points"} = 0; # debug_message("#### progress_substep_info:\n" . node_as_string(progress_substep_info) . "\n"); # Return progress_substep_info node progress_substep_info; debug_message("#### get_report_progress_substep_info() END \n"); )); # # # # increment_progress_substep() # # # subroutine(increment_progress_substep( node progress_substep_info), ( debug_message("#### increment_progress_substep() START \n"); # This increments the progress_substep depending on the current # substep points. We simply move one third of the remaining points forward. float max_points_per_step = @progress_substep_info{"max_points_per_step"}; float used_points = @progress_substep_info{"used_points"}; float remaining_points = max_points_per_step - used_points; float current_points; if (remaining_points > 1) then ( current_points = used_points + (remaining_points / 3); ) else ( current_points = max_points_per_step; ); # # Update progress_substep_info # @progress_substep_info{"used_points"} = current_points; # # Set value in C++ # set_progress_meter_position(current_points); debug_message("#### increment_progress_substep() END \n"); )); # # # # prepare_increment_iterative_progress_substep() # # # subroutine(prepare_increment_iterative_progress_substep( node progress_substep_info), ( # This sets the substep_interval_points and substep_interval_start_points # in progress_substep_info which is then used by increment_iterative_progress_substep() float max_points_per_step = @progress_substep_info{"max_points_per_step"}; float used_points = @progress_substep_info{"used_points"}; float remaining_points = max_points_per_step - used_points; float substep_interval_points = remaining_points / 3; @progress_substep_info{"substep_interval_points"} = substep_interval_points; @progress_substep_info{"substep_interval_start_points"} = used_points; )); # # # # set_iterative_progress_substep() # # # subroutine(increment_iterative_progress_substep( node progress_substep_info, float current_item_number, float total_items), ( debug_message("#### increment_iterative_progress_substep() START \n"); # This increments progress within an iteration when we loop over rows # or any other number of items. Before this function is called we apply # set_progress_substep_interval(), just before the loop starts, so that # we get a substep_interval, which are the maximum points we move forward # within the given loop. float substep_interval_points = @progress_substep_info{"substep_interval_points"}; # Get the points for the already done rows float rows_done_in_percent = (100 / total_items) * current_item_number; # Get the points we actually move forward float move_forward_points = (substep_interval_points / 100) * rows_done_in_percent; float min_points = @progress_substep_info{"substep_interval_start_points"}; float max_points = min_points + substep_interval_points; float current_points = min_points + move_forward_points; if (current_points < min_points) then ( max_points = min_points; ) else if (current_points > max_points) then ( current_points = max_points; ); # # Update progress_substep_info # @progress_substep_info{"used_points"} = current_points; # # Set value in C++ # set_progress_meter_position(current_points); # debug_message("#### current_points: " . current_points . "\n"); debug_message("#### increment_iterative_progress_substep() END \n"); ));