drbitboy
Lifetime Supporting Member
Here is a snippet implementing the same algorithm in ST. How you work this into the SigmaTek/Lasal Class environment is on you. There are some video tutorials that might help; they talk about Servers and Clients, but those seem to be about declaring variables.
// Inputs:
// - current_count (UDINT; current running total of hardware sets completed)
// - current_minute (UDINT; range 0-59; minute of hour)
// - This could also be a local, temporary variable,
// - with a value obtained from .wMinute attribute of SysTimeDate
// Static (internal data, retains values from scan cycle to scan cycle):
// - last_minute (UDINT; range 0-59; minute of hour the last time this function was called)
// - oldest_count (UDINT; running total of hardware sets one hour ago)
// - count_array (Array[0..59] of UDINT; array of past sixty minutes of running totals
// Outputs:
// - last_hour_average (count of hardware sets completed in the last hour)
IF current_minute <> last_minute THEN
last_minute := current_minute;
oldest_count := count_array[last_minute];
count_array[last_minute] := current_count;
END_IF;
last_hour_average := count_array[current_minut] - oldest_count;