maya
.public
Tables
(current)
Columns
Constraints
Relationships
Orphan Tables
Anomalies
Routines
ot_ro_overspeed(real[], integer)
Parameters
Name
Type
Mode
matrix
ARRAY
IN
speed_limit
integer
IN
Definition
/* Returns the sum of time a unit has spent speeding, out of a speedrpm matrix */ /* V20141018*/ DECLARE lower_bound int; speed_range int := 20; i int := 0; total_time real :=0; aux_array real[]; /*to hold the matrix as a simple array*/ BEGIN aux_array := (WITH q as (SELECT unnest(matrix) as a) SELECT array_agg(a) from q); lower_bound := ((speed_limit / speed_range) + 1)*5; FOR i in lower_bound..36 LOOP total_time = total_time + aux_array[i]; END LOOP; RETURN total_time; END;