Package: Fun With Statistics

Author: Mark Stayton
Version: 2
Added to Library: 11-Nov-23
HCAVersion needed: 16
Keywords: Utility

Package Description:
This package contains five programs that demonstrate the new statistics functions in HCA Version 15:

1. Device Statistics - reports the number of times a specific device is controlled.

2. Program Statistics - reports the number of times a specific program is activated.

3. Global Statistics - reports totals of the four HCA global statistics, for today and the previous day

4. Reset Global Statistics - resets today's global statistic values to zero

5. Object Counts - reports counts of the HCA objects in your configuration (devices, programs, groups, rooms, and variables)

See the Notes tab on each of the programs for additional information.

Program: Count HCA Objects

Program Description:
This program returns counts of the following objects in the system

1 - Devices

2 - Programs

3 - Groups

4 - Rooms

5 - Variables

The results are stored in the following global variables:

stats_num_Devices

stats_num_Programs

stats_num_Groups

stats_num_Rooms

stats_num_Variables

Written by Mark Stayton (mark@thestaytons.net) | Version 1 | 26-Jun-2018

Example:
Run the program to update the object counts

Return value: None

Program: Device Statistics

Program Description:
This program reports the total number of times a device is controlled. The value is stored in a dynamically created variable, "_stats_Room - Device Name", where "Room - Device Name" is the name of the device.

WHAT YOU NEED TO DO:

1. Add one or more triggers for each device you want to track.

2. Edit the "Dev" argument of the trigger, selecting the device name as the argument value.

Written by Mark Stayton (mark@thestaytons.net) | Version 1 | 26-Jun-2018

Return value: This program does not return a result.

Parameters:

Name Type Description Default
Dev Object Name of the device to generate a statistic for  

Program: Global Statistics

Program Description:
This program reports the following statistics in global variables for the current and previous day:

Total number of programs executed

Total number devices controlled

Total number of client connections

Total number of messages from all interfaces

See Global Variable Usage for variable names and descriptions.

At midnight, the program copies the current day's variables to the previous day's variables, then executes the program "Reset Global Variables" which resets the current day counts to zero.

Written by Mark Stayton (mark@thestaytons.net) | Version 1 | 26-Jun-2018

Example:
This program automatically executes in the first minute of every hour.

Return value: This program does not return a result.

Global Variable Use:

Name Description
stats_previous_Interfaces Total number of messages from all interfaces for the previous day.
stats_previous_Clients Total number of client connections for the previous day.
stats_previous_Devices Total number devices controlled for the previous day.
stats_previous_Programs Total number of programs executed for the previous day.
stats_today_Interfaces Total number of messages from all interfaces for the current day.
stats_today_Clients Total number of client connections for the current day.
stats_today_Programs Total number of programs executed for the current day.
stats_today_Devices Total number devices controlled for the current day.

Program: Program Statistics

Program Description:
This program reports the total number times a program was activated. The value is stored in a dynamically created variable, "_stats_Room - Program Name", where "Room - Program Name" is the name of the program.

WHAT YOU NEED TO DO:

1. Add one or more triggers for each program you want to track.

2. Edit the "Prog" argument of the trigger, selecting the program name as the argument value.

Written by Mark Stayton (mark@thestaytons.net) | Version 1 | 26-Jun-2018

Return value: This program does not return a result.

Parameters:

Name Type Description Default
Prog Object Name of the program to generate a statistic for  

Program: Reset Global Statistics

Program Description:
This program resets the current day variables.

See Global Variable Usage for variable names and descriptions.

Written by Mark Stayton (mark@thestaytons.net) | Version 1 | 26-Jun-2018

Example:
This program can be executed by the user as desired.

The program is also executed at midnight by the "Global Variables" program

Return value: This program does not return a result.

Global Variable Use:

Name Description
stats_today_Interfaces Total number of messages from all interfaces for the current day.
stats_today_Clients Total number of client connections for the current day.
stats_today_Programs Total number of programs executed for the current day.
stats_today_Devices Total number devices controlled for the current day.