# # # # build_special_chrono_data() # # # Builds a chronological data node # # # subroutine(build_special_chrono_data( node chrono_graph_query_header, table working_table, int total_rows, string main_field_report_field_name, string main_field_report_field_type, int main_field_ssql_column_number, int chrono_start_in_epoc, int chrono_end_in_epoc, string chrono_type, int number_of_variables_in_graph, int seconds_per_variable, int x_axis_length, node chrono_query_data, bool is_date_time_in_epoc), ( debug_message("\n\n#### build_special_chrono_data() START \n\n"); debug_message("#### number_of_variables_in_graph: " . number_of_variables_in_graph . "\n"); # # # In special_chrono_data the graph_type is hour, minute or second and the variables # are greater than the available x_length. # # node column; int ssql_column_number; string report_field_name; # # # Create a draft chrono_query_data node # # # node graph_field; # string field_name; int chrono_date_in_epoc = chrono_start_in_epoc; string chrono_date; for (int i = 0; i < number_of_variables_in_graph; i++) ( # # Add the main_field to the chronological_query_data # # Note, we must set the date_time value now because else any gap # wouldn't get a date_time value chrono_date = epoc_to_date_time(chrono_date_in_epoc); chrono_query_data . "." . i . "." . main_field_report_field_name = chrono_date; chrono_date_in_epoc = chrono_date_in_epoc + seconds_per_variable; # # create a single chronological_query_data entry, set each graph field value to 0 # # foreach column chrono_graph_query_header ( report_field_name = @column{"report_field_name"}; chrono_query_data . "." . i . "." . report_field_name = 0.0; ); ); # # # Write the ssql table values to chrono_query_data # # # node query_item; string date_time_value; int date_time_in_epoc; int seconds_relative_to_start_date; int relevant_chrono_node_name; node chrono_item_node; float ssql_table_item_value; float chrono_item_value; for (int row_number = 0; row_number < total_rows; row_number++) ( date_time_value = table_get_cell_string_value(working_table, row_number, main_field_ssql_column_number); if (!is_date_time_in_epoc) then ( date_time_in_epoc = date_time_to_epoc(date_time_value); ) else ( # date_time_value is already in EPOC date_time_in_epoc = date_time_value; ); seconds_relative_to_start_date = date_time_in_epoc - chrono_start_in_epoc; relevant_chrono_node_name = seconds_relative_to_start_date / seconds_per_variable; if ((seconds_relative_to_start_date % seconds_per_variable == 0) and (relevant_chrono_node_name > 0)) then ( relevant_chrono_node_name = relevant_chrono_node_name - 1; ); # debug_message("#### relevant_chrono_node_name: $relevant_chrono_node_name \n"); chrono_item_node = chrono_query_data . "." . relevant_chrono_node_name; # # # Set aggregating field values # # foreach column chrono_graph_query_header ( ssql_column_number = node_name(column); report_field_name = @column{"report_field_name"}; ssql_table_item_value = table_get_cell_value(working_table, row_number, ssql_column_number); chrono_item_value = @chrono_item_node{report_field_name}; # # Override the chrono item value if table item value is greater than chrono item value # if (ssql_table_item_value > chrono_item_value) then ( set_subnode_value(chrono_item_node, report_field_name, ssql_table_item_value); ); ); ); debug_message("\n" . node_as_string(chrono_query_data) . "\n"); ));