The record table visualizer shows columns of data in a table. This page describes the methods implemented by the RecordTable
class in the MegunoLink Arduino library to send data and control the Record table visualizer from your Arduino sketch. Refer to Record table for documentation on the visualizer.
Methods
The RecordTable
can work with rows or individual cells in the table. AddRow*
methods append new rows to the end of the table while UpdateRow*
methods modify existing rows. The SetValue
method modifies an individual cell in the table. There are several variations of the *Row*
methods for flexibility.
Generally, you can send any printable value to a record table. Sending the special value SpecialParameters::CurrentTime
will have MegunoLink place the computer’s current time into the corresponding cell of the table. See record table visualizer for an example.
The following methods are available for a RecordTable
:
RecordTable()
,RecordTable(Channel)
,RecordTable(Destination)
,RecordTable(Channel, Destination)
AddRow(Values...)
AddRowWithIds(NumberOfIds, ArrayOfIds, Values...)
AddRowFromArray(NumberOfValues, ArrayOfValues)
AddRowFromArrayWithIds(NumberOfIds, ArrayOfIds, NumberOfValues, ArrayOfValues)
UpdateRow(RowNumber, Values...)
UpdateRowWithIds(RowNumber, NumberOfIds, ArrayOfIds, Values...)
UpdateRowFromArray(RowNumber, NumberOfValues, ArrayOfValues)
UpdateRowFromArrayWithIds(RowNumber, NumberOfIds, ArrayOfIds, NumberOfValues, ArrayOfValues)
SetValue(RowNumber, ColumnNumber, Value)
ClearAllRows()
ClearRow(RowNumber)
Method Descriptions
Record Table Constructor
Creates a RecordTable
variable, which can be used to send commands to MegunoLink to add data to and control a Record table visualizer.
RecordTable(const char *Channel = NULL, Print &Destination = Serial);
RecordTable(const __FlashStringHelper *Channel, Print &Destination = Serial);
RecordTable(Print& Destination);
Name | Type | Required? | Description |
---|---|---|---|
Channel | const char *, const __FlashStringHelper | No | The name of the destination channel for report table messages. Defaults to the broadcast channel (NULL ). |
Destination | Print & | No | Sets the serial connection to use for sending messages to MegunoLink. Defaults to Serial , the default Arduino RS232 port. |
1 2 3 4 5 6 |
#include "MegunoLink.h" RecordTable Records1; RecordTable Records2(Serial1); // send messages to Serial1 port. RecordTable Records3(F("Experiment")); // use the 'Experiment' channel for sending messages. RecordTable Records4("Log", Serial1); // send messages to the Serial1 port using the "Log" channel. |
AddRow
Adds a new row of data to a table filling in columns with the values supplied. You can supply as many values as you like to the AddRow
function (it is a variadic template). Values are added to columns in the new row in logical column order. Extra values are discarded if more values are supplied than there are columns in the visualizer table.
void AddRow(Type… Values);
Name | Type | Required? | Description |
---|---|---|---|
Values | Type… | Yes | The column values to send to the record table. Pass one value for each column. Any type supported by the Arduino print method is supported including int , String , const char* etc. |
1 2 3 4 5 6 7 |
// Put 'Text', 123, 'value', and 2.3 in columns 0 – 3 of a table. Records1.AddRow("Text", 123, F("value"), 2.3); float Value1 = 3.141; int Answer = 42; String MyLabel("Voltage"); Records.AddRow(MyLabel, Value1, Answer); |
AddRowWithIds
Adds a new row of data to a table. The target column for each new value is set by a matching entry in an array of column ids. The column ids supplied are matched to the id of a column set in MegunoLink. Values can be mixed types.
void AddRowWithIds(int NumberOfIds, const uint8_t *ColumnIds, Types... Values);
Name | Type | Required? | Description |
---|---|---|---|
NumberOfIds | int | Yes | The number of ids in ColumnIds and the number of Values to send to MegunoLink |
ColumnIds | const uint8_t * | Yes | Array of ids for the column in MegunoLink where the corresponding value should be placed |
Values | Types… | Yes | The column values to send to the record table. Pass at least NumberOfIds values. Each values is placed in the column with the matching column id from ColumnIds . Values may be any type supported by the Arduino print method including int , String , const char* etc. |
1 2 3 4 5 |
// Send an array of analog sensor measurements to a record table, specifying the columns to place them in. const int NumberOfSensors = 4; const uint8_t ColumnIds[NumberOfSensors] = {2, 1, 3, 0}; // Supports arbitrary column order. Records.AddRowWithIds(NumberOfSensors, ColumnIds, F("Hello"), 42, 3.141, "I am not a fish"); |
AddRowFromArray
Adds a new row of data to a table filling in columns, in logical column order, from values supplied in an array.
void AddRowFromArray(int NumberOfValues, TValue *Values);
Name | Type | Required? | Description |
---|---|---|---|
NumberOfValues | int | Yes | Number of values in the Values array to send to MegunoLink |
Values | TValue * | Yes | An array of (at least) NumberOfValues values to send to MegunoLink. The values from the array are added to columns of the table. The array type may be any type supported by the Arduino print method including int , String , const char* etc. |
1 2 3 4 5 6 7 8 9 10 |
// Send an array of analog sensor measurements to a record table. const int NumberOfSensors = 4; int SensorValues[NumberOfSensors]; SensorValues[0] = analogRead(A0); SensorValues[1] = analogRead(A1); SensorValues[2] = analogRead(A2); SensorValues[3] = analogRead(A3); Records.AddRowFromArray(NumberOfSensors, SensorValues); |
AddRowFromArrayWithIds
Adds a new row of data to a table. The target column for each new value is set by a matching entry in an array of column ids. The column ids supplied are matched to the id of a column set in MegunoLink.
void AddRowFromArrayWithIds(int NumberOfIds, const uint8_t *ColumnIds, TValue *Values);
Name | Type | Required? | Description |
---|---|---|---|
NumberOfIds | int | Yes | Number of column ids in the ColumnIds and Values arrays |
ColumnIds | const uint8_t * | Yes | Array of ids for the column in MegunoLink where the corresponding value should be placed |
Values | TValues | Yes | An array of NumberOfIds values for columns in the new row of the record table. Each values is placed in the column with the matching column id from ColumnIds . The array type may be type supported by the Arduino print method including int , String , const char* etc. |
1 2 3 4 5 6 7 8 9 10 11 |
// Send an array of analog sensor measurements to a record table, specifying the columns to place them in. const int NumberOfSensors = 4; const uint8_t ColumnIds[NumberOfSensors] = {2, 1, 3, 0}; // Supports arbitrary column order. int SensorValues[NumberOfSensors]; SensorValues[0] = analogRead(A0); SensorValues[1] = analogRead(A1); SensorValues[2] = analogRead(A2); SensorValues[3] = analogRead(A3); Records.AddRowFromArrayWithIds(NumberOfSensors, ColumnIds, SensorValues); |
UpdateRow
Updates an existing row of data in the table, replacing values in columns with the new values supplied. The row to update is identified by number, with the first row in the table as row 0.
You can supply as many values as you like to the UpdateRow
function (it is a variadic template). Values are added to columns in the new row in logical column order. If there are more values supplied than columns in the visualizer table, additional values are discarded.
void UpdateRow(int RowNumber, Types… Values);
Name | Type | Required? | Description |
---|---|---|---|
RowNumber | int | Yes | The number of the row to update in the table (counting from 0). Additional rows are added automatically if the table contains fewer rows. |
Values | Types… | Yes | The column values to send to the record table. Pass one value for each column. Any type supported by the Arduino print method is supported including int , String , const char* etc. |
1 2 3 4 5 6 7 |
// Update row 0, replacing columns 0 – 3 with 'Text', 123, 'value', and 2.3. Records1.UpdateRow(0, "Text", 123, F("value"), 2.3); float Value1 = 3.141; int Answer = 42; String MyLabel("Voltage"); Records1.UpdateRow(4, MyLabel, Value1, Answer); |
UpdateRowWithIds
Updates an existing row of data in the table, replacing values in columns with the new values supplied. The row to update is identified by number, with the first row of the table as row 0.
Values are mapped to columns by matching the corresponding id in the array of column ids to the id of the column set in MegunoLink. Columns not included in the array remain unchanged. Values can be mixed types.
void UpdateRowWithIds(int RowNumber, int NumberOfIds, const uint8_t *ColumnIds, Types... Values);
Name | Type | Required? | Description |
---|---|---|---|
RowNumber | int | Yes | The number of the row to update in the table (counting from 0). Additional rows are added automatically if the table contains fewer than RowNumber rows. |
NumberOfIds | int | Yes | The number of column ids in the ColumnIds array and values supplied. |
ColumnIds | const uint8_t * | Yes | Array of ids for the column in MegunoLink where the corresponding value should be placed |
Values | Types… | Yes | NumberOfIds column values to send to the record table. Each values is placed in the column with the matching column id from ColumnIds . Values may be type supported by the Arduino print method including int , String , const char* etc. |
1 2 3 4 5 |
// Send an array of analog sensor measurements to a record table, specifying the columns to place them in. const int NumberOfSensors = 4; const uint8_t ColumnIds[NumberOfSensors] = {2, 1, 3, 0}; // Supports arbitrary column order. Records.AddRowWithIds(NumberOfSensors, ColumnIds, F("Hello"), 42, 3.141, "I am not a fish"); |
UpdateRowFromArray
Updates an existing row of data in the table, replacing column values with the new values supplied in an array. Columns are filled in logical column order. The row to update is identified by row-number, counting from 0.
void UpdateRowFromArray(int RowNumber, int NumberOfValues, TValue *Values);
Name | Type | Required? | Description |
---|---|---|---|
RowNumber | int | Yes | The row-number to update (counting from 0). Rows are added automatically if the table contains fewer than RowNumber rows. |
NumberOfValues | int | Yes | Number of values in the Values array to send to MegunoLink |
Values | TValue * | Yes | An array of (at least) NumberOfValues values to send to MegunoLink. The values from the array replace data already in the table. The array type may be any type of values supported by the Arduino print method including int , String , const char* etc. |
1 2 3 4 5 6 7 8 9 10 11 12 |
// Send an array of analog sensor measurements to a record table. const int NumberOfSensors = 4; int SensorValues[NumberOfSensors]; SensorValues[0] = analogRead(A0); SensorValues[1] = analogRead(A1); SensorValues[2] = analogRead(A2); SensorValues[3] = analogRead(A3); int RowToUpdate = 3; Records.UpdateRowFromArray(RowToUpdate, NumberOfSensors, SensorValues); |
UpdateRowFromArrayWithIds
Updates an existing row of data in the table, replacing column values with the new values supplied. The row updated is identified by a number, with the first row in the table as row 0.
Values are mapped to columns by matching the corresponding id in the array of column ids to the id of the column set in MegunoLink.
void UpdateRowFromArrayWithIds(int RowNumber, int NumberOfIds, const uint8_t *ColumnIds, TValue *Values);
Name | Type | Required? | Description |
---|---|---|---|
RowNumber | int | Yes | The number of the row to update in the table (counting from 0). Additional rows are automatically added if the table contains fewer than RowNumber rows. |
NumberOfIds | int | Yes | Number of column ids in the ColumnIds and Values arrays |
ColumnIds | const uint8_t * | Yes | Array of NumberOfIds ids for the column in MegunoLink where the corresponding value should be placed |
Values | TValues | Yes | An array of NumberOfIds values for columns in the new row of the record table. Each value is placed in the column with the matching column id from ColumnIds . The array type may be any type supported by the Arduino print method including int , String , const char* etc. |
1 2 3 4 5 6 7 8 9 10 11 |
// Send an array of analog sensor measurements to a record table, specifying the columns to place them in. const int NumberOfSensors = 4; const uint8_t ColumnIds[NumberOfSensors] = {2, 1, 3, 0}; // Supports arbitrary column order. int SensorValues[NumberOfSensors]; SensorValues[0] = analogRead(A0); SensorValues[1] = analogRead(A1); SensorValues[2] = analogRead(A2); SensorValues[3] = analogRead(A3); Records.UpdateRowFromArrayWithIds(4, NumberOfSensors, ColumnIds, SensorValues); |
SetValue
Sets the value in a cell identified by a row, column index. Rows and columns are both counted from 0.
void SetValue(int RowNumber, int ColumnNumber, TValue Value);
Name | Type | Required? | Description |
---|---|---|---|
RowNumber | int | Yes | The number of the row to update in the table (counting from 0). Additional rows are automatically added if the table contains fewer than RowNumber rows. |
ColumnNumber | int | Yes | The number of the row to update in the table (counting from 0). Must be less than the number of columns present in the table; columns are not automatically added if the table contains fewer than ColumnNumber columns. |
Value | TValue | Yes | The value to place in cell (RowNumber , ColumnNumber ). Values may be any type supported by the Arduino print method including int , String , const char* etc. |
1 2 3 4 |
// Set the value in a cell. Records.SetValue(4, 3, 123); Records.SetValue(1, 2, "New value"); Records.SetValue(4, 2, F("Value from program memory")); |