Difference between revisions of "Data Loggers"

From HSYCO
Jump to navigation Jump to search
Line 84: Line 84:
 
It is therefore advised to provide the data logger with periodical values so to have a correct calculation.
 
It is therefore advised to provide the data logger with periodical values so to have a correct calculation.
  
Now, we set the data logger to follow the temperature measured by a probe identified by the I/O server “temp”.
+
Now, we set the data logger to follow the temperature measured by a probe identified by the I/O datapoint “termo.temp”.
  
 
We specify in events that every minute it must be updated, plus we log the measured value in the file “temp.csv”:
 
We specify in events that every minute it must be updated, plus we log the measured value in the file “temp.csv”:
TIME : DATALOGGER temperature = IO temp, DATALOGGER temperature = FILE LOG temp.csv
 
  
The created charts will automatically be scaled to range from the lowest measured value to the highest and charts belonging to the same period will be aligned. If for instance we only want to show the chart showing the lowest values, it might be better not to have this chart aligned to the others.
+
TIME : DATALOGGER temperature = IO termo.temp, DATALOGGER temperature = FILE LOG temp.csv
  
To do this, we can specify in hsyco.ini to scale the charts of the same period independently:
+
The created charts will automatically be scaled to range from the lowest measured value to the highest and charts belonging to the same period will be aligned.
DataLoggers.temperature.PeriodAlign = false
 
  
Further, by default, the origin of the charts is set to correspond to the lowest measured value.
+
By default, the origin of the charts is set to correspond to the lowest measured value.
  
 
One might prefer to set the origin to a specified value (for instance zero) so to highlight the difference between values below and above it.
 
One might prefer to set the origin to a specified value (for instance zero) so to highlight the difference between values below and above it.
  
We can achieve this by setting the Origin option:
+
We can achieve this by setting the Origin option in the data logger settings:
DataLoggers.temperature.Origin = 0
 
  
Finally, in order to display the data logger’s charts, we should use the (datalogger) object, for example:
+
[[File:Data_Loggers_Origin.png]]
(datalogger temperature; x80y60; 820; 500; C;)
+
 
 +
Finally, in order to display the data logger’s charts, we should add the Datalogger object to our interface.

Revision as of 10:31, 19 March 2014

Error creating thumbnail: Unable to save thumbnail to destination
Error creating thumbnail: Unable to save thumbnail to destination
Error creating thumbnail: Unable to save thumbnail to destination

Data loggers allow to gather, process and visualize statistical data on the variations of a data set.

They can be used to automatically generate periodic charts of its trend and/or to log data as CSV files.

Data loggers collect data and group them in order to visualize the trends in charts for each hour (or group of hours) of the current and past day, each day of the current and past month, and each month of the current and past year. It is also possible to have an higher resolution of a single minute, but this implies a notably higher disk space usage.

Further, they allows for the logging of every processed value.

There are two types of data logger:

  • counter: suitable for the creation of statistics of an incremental value (e.g. energy consumption or production). It calculates the variation (delta) of the value for each time interval with respect to the previous one. Further, it is possible to specify time slots and the relative rates to calculate for instance the costs for energy consumption.
  • range: aimed at the computation of the maximum, minimum, and average of a fluctuating value (e.g. a measured temperature or humidity) for each time interval.

Once a data logger is defined in HSYCO's Settings, you can easily pass data to it using a simple action in EVENTS, a JavaScript function or Java method, and display statistical data using the Datalogger UI object.

Counter Data Loggers

The first step to create a counter data logger is to define it in the HSYCO configuration.

Refer to the Data Loggers section in the configuration chapter for a complete description of all the available parameters and options.

In the following examples we have defined a counter data logger named “energy” with default parameters.

Now, we need to provide the data logger with the incremental value we want to process.

Assuming we have an I/O datapoint named “elektro.kwh” which provides the energy consumption value, we write the following lines in events.txt:

IO elektro.kwh : DATALOGGER energy = IO elektro.kwh, DATALOGGER energy = FILE LOG energy.csv

Whenever the I/O datapoint will provide a new value, the data logger will be updated and a log entry will be added to the file “energy.csv”.

Finally, in order to display the data logger’s charts, we should use the Datalogger object and set its ID to "energy"

For a complete reference of all the available actions on data loggers refer to the relative section in the Events programming chapter.

The same actions can be performed using JavaScript or Java code.

We could also create a data logger to monitor the expenses relative to energy consumption, initializing a new counter data logger and declaring the time slot rates in the file dataloggers.ini located in HSYCO's root folder.

We add a new data logger with ID "cost" in Settings, then, we set the "elektro.kwh" I/O datapoint to update the data logger. In events.txt we add this line:

IO elektro.kwh OR TIME : DATALOGGER cost = IO elektro.kwh

Note that this time we are updating the data logger not only when a new value is available, but also every minute. This is necessary to have an accurate calculation of the expenses.

Now we need to declare our time slots in the file dataloggers.ini, for instance:

cost; 0; 00:00-11:59; *; *; 0.3
cost; 1; 12:00-16:59; *; *; 1.4
cost; 2; 17:00-23:59; *; *; 0.8

These rules state that every day from midnight to 11:59:59 we are in slot 0 and the rate to be applied is 0.3, from 12:00:00 until 16:59:59 we are in slot 1 and the applicable rate is 1.4, later on slot 2 applies with a rate of 0.8.

We can include some exceptions by adding some lines before these rules:

cost; 0; *; *; 2000/12/10-2000/12/31; 0.3
cost; 2; *; 67; *; 0.8
cost; 0; 00:00-11:59; *; *; 0.3
cost; 1; 12:00-16:59; *; *; 1.4
cost; 2; 17:00-23:59; *; *; 0.8

The previous rules will still apply, except on Saturdays (6) and Sundays (7) when during all day slot 2 will apply.

Further, during the period between December 10th and December 31st of 2000, slot 0 will always apply despite the day of the week or the time.

Refer to the section about the dataloggers.ini file for a complete reference on how to write time slots rules.

At this point we should add the Datalogger object to the user interface to display the charts. The user interface also allows you to filter data by rate.

Further, we can have a detailed report of all the processed data by specifying the path of a log file using the "Rates Log File" option in the data logger's settings:

Data Loggers Rates Log File.png

This will create a CSV file listing a row for each update of the data logger divided in the following columns:

data_logger_name, update_time, provided_value, calculated_cost, slot_id, applied_rate

Range Data Loggers

In the following examples we define a range data logger, named “temperature”, with default parameters.

Note that the average is calculated as the sum of the values divided by the number of records.

It is therefore advised to provide the data logger with periodical values so to have a correct calculation.

Now, we set the data logger to follow the temperature measured by a probe identified by the I/O datapoint “termo.temp”.

We specify in events that every minute it must be updated, plus we log the measured value in the file “temp.csv”:

TIME : DATALOGGER temperature = IO termo.temp, DATALOGGER temperature = FILE LOG temp.csv

The created charts will automatically be scaled to range from the lowest measured value to the highest and charts belonging to the same period will be aligned.

By default, the origin of the charts is set to correspond to the lowest measured value.

One might prefer to set the origin to a specified value (for instance zero) so to highlight the difference between values below and above it.

We can achieve this by setting the Origin option in the data logger settings:

Data Loggers Origin.png

Finally, in order to display the data logger’s charts, we should add the Datalogger object to our interface.