Package: Graph Tools and Data Collection

Author: HCA Central
Version: 2
Added to Library: 02-Jan-24
HCAVersion needed: 18.0.11
Keywords: Utility

Package Description:
Tools for collecting data over 24 hours and displaying that by HCA generated bar charts

Program: Cell Set

Program Description:
Sets the cell - a tile - of a graph display. the row numbers are 1 to 8, and the column numbers are 1 to 24.

Parameters:

Name Type Description Default
DisplayName Value Name of the tiled display used for this graph  
Row Value Row. First row is 1 1
Col Value Column, First column is 1 1
Color Value Color of the any cells that comprise the value part of the bar red

Program: Colors

Program Description:
Returns the rgb value - as a single number - for a color. the color can be supplied as a name or a 3-number set.

The color names are defined in tags on this program. You can edit, remove, or add new colors as needed. See the tags tab of this program's properties.

Example:
rgb = _startprogram("graph tools - colors", "blue");

rgb = _startprogram("graph tools - colors", "128,34,12");

Parameters:

Name Type Description Default
Name Value Name of the color. Could be a color name - defined in tags on this program, or a rgb value given as r,g,b  

Program: Create 24 Hours Graph

Program Description:
Displays data in a bar chart.

You provide to this program the name of the display which contains all the tiles in the template display provided in this package.

You also supply the data to be shown as a csv text string with 24 data values and the color to be used for the bars.

Two sets of data can be provided which are merged together. The idea here is you have data representing "today" and "yesterday". Since you may view the graph at any time, if it only showed the data from today you probably wouldn't see all the data unless you happened to look just before midnight. To make this a more useful interface, the merged display uses today's data if available and yesterday's if it isn't. You can tell which is which by the colors.

Parameters:

Name Type Description Default
DisplayName Value Name of the tiled display used for this graph  
data Value CSV format 24 values for current time period. Any values which are "x" don't draw the bar.  
dataColor Value Color of the boxes used current time period bars. blue
dataBack Value CSV format 24 values for current time period. Any values which are "x" show as zero values  
dataBackColor Value Color of the boxes used previous time period bars. grey
Weekday Value Weekday (1= Sunday, ..., 7 = Saturday)  
Title Value Graph Title  

Program: Get Hour Data

Program Description:
Called by the "Hour Collection" program to retrieve any data you want to sample each hour.

----> This program you are expected to modify! <----

The 1st argument is a code from 1 to 4. Return any data you want based upon that code. If you have no data for that code, then return as the result an empty string ("").

This program's return result is a 2-element csv. The first element is the name of the data item - your choice of name - and the second item is the value.

For example:

temperature,65

Note: You could use this to save sensor data - like temperature or illumination, action counts, number of devices on or off, power consumption, etc. Anything where you want to know what happens each hour over a day.

Parameters:

Name Type Description Default
Code Value Code saying what data to get. Values will be 1 - 4. What they mean is up to you.  

Program: Graph Collected Data

Program Description:
Construct a graph from data that the program "hour collection" has gathered.

Thisis a paramaterized program so you need another program to staret it. See the program "Graph Tools - Test Graph"

Parameters:

Name Type Description Default
DisplayName Value Name of the display for the graph  
ItemName Value Name of the item being graphed. This is the name that GetHourData returns as the 1st item in its result  
ForDay Value Day of the week. Sun=1, Sat=7  
ColorDay Value Color for today's data  
ColorPrevDay Value Color for the previous day's data  
Title Value Graph title  

Program: Hour Collection

Program Description:
Program that runs every minute. At the first minute of an hour, starts the "get hour data" program and saves the data it retrieves in a weekday tag on this program.

The "get hour data" program is started repeatedly, with argument (1, 2, 3, ...) to retrieve different data values.

See the "get hour data" program for a description of how this works.

Because each data item is saved for a week (needing 7 tags) you can have from 1 to 4 data items.

Program: Show Bar

Program Description:
Draws one bar of the bar chart.

The display name is the display with the graph layout. Also provided is the number of the bar - which column - the value, and the bar color.

Parameters:

Name Type Description Default
DisplayName Value Name of the display used for this graph  
col Value Column for this bar  
value Value Value for this bar  
color Value Color used for the value part of this bar  
label Value Label text for this bar  

Program: Show Weekday Data

Program Description:
Program that is started by a click on the weekday tiles in the graph. Redisplays the data for a different weekday.

Parameters:

Name Type Description Default
Name Value Tile name  
Label Value Tile Label  
Action Value short or long  
DisplayName Value Name of the display the tile is on Graph1

Program: Test Graph

Program Description:
Test program!

Simple program to use the graph tools to update the [Graph1] display showing programs executed per hour for today.