Tutorial 3: Adding data logging

In this tutorial we will add logging of data.

The below illustration shows what you will build in this tutorial. The red dots indicate tutorial steps.


Now - lets get started.

Data logging.

In VIGO6 it is very easy to add logging of data. All you need is a register that holds the data.

Logging is performed when "Log" is called in the Register Set-method. Log commands that are entered other places than in the register set-method are ignored. The value held in the register at the time of the call of the log-command is stored as a separate log-entry.

Log entries are stored in flash memory locally in a device, in a "ring buffer". Hence the local lifetime of logs depends on the size of the ring buffer (device dependent) and on the number, frequency and size of logs.

Normally, local logs are transferred to a remote database. The register variable "Log_Lifetime" is used to indicate how long logged data is intended to be preserved in the remote database.

For example "One month" means, the log is intended to stay in the remote database for 1 month.

"None" means, the log is never transferred to remote database. Data is still logged locally.

"Permanent" means the log is intended never to be deleted from the remote database.

"No_logging" means the data is not logged locally, and thus not transferred to the remote database either.


Step 1: Enabling logging

We will reuse our component from tutorial 1 and our assembly, main assembly, project and test bed from tutorial 2.

Open XX-Temperature_regulator_simple.

In the subcomponent section, find the register "Set point"  and set Log_Lifetime to "One_week". Find the set-method of the register and press override. After inherited, call the log method

This is what your code should look like:

Perform the same operation for register "Actual_temperature"

Step 2: Writing log data.

As mentioned, data are logged when the register set-method is called or when the get/set handler is activated.

We are already writing data (ie. set) to the temperature register (the first line in the regulate-method).

The set point is updated through the visualisation which activates the get/set-handler. 

Hence we do not need to add any additional code.

Step 3: Adding visualisation.

VIGO6 visualisation of a register contains a window that displays log data. The window is opened when pressing the left mouse button for 2-3 seconds. So there is no need for any adjustments of the already created visualisation.

Step 4: Adjusting your test bed.

Replace the  input (a 4-20mA slider) with a temperature regulator simulator.  Orange wire to terminal 01, red wire to terminal 10 and black wire to terminal 30(GND).

The temperature regulator simulator adjusts itself to the set point.

Step 5: Downloading your code and testing your regulator.

Save, build project and download it to the test bed. 
Now your display PC will show you the visualisation and you can change the set point and see how the temperature adjusts. Try to open the temperature logging by holding down the mouse button over the temperature field.

Now let us move to the next tutorial where you learn how to use the supervisor/servant notification model.