slaver_message telnet_connection
API Reference Manual  /  7 Simulator-to-Simulator Interfaces  / 

table

Description
The table interface can be implemented by objects holding data which can be presented in a table by the user interface (through Simics CLI command outputs, Eclipse etc.)

By properly implementing the table interface, less object specific code is needed to provide the data to the user. Generic Simics commands (associated with the table interface) allows the data to sorted on the desired column and printed in a uniform way. Similarly, the data can be exported to a comma separated value (.csv) file, making it possible to process the result in a spreadsheet program.

The data() method returns the data as an attr_value_t array where the outer list contains each row and the inner list contains the columns for that row. The number of columns in each row must be exactly the same. The data only holds the actual data, not the headers for each column, which instead is specified in the properties() method. The data can be unsorted, it is up to the user of the interface to sort it in a suitable way.

The data itself is sufficient for producing a table, but to customize the table layout the properties method can return hints on how the table should be presented more in detail. For example, specifying which column the table should be sorted on by default, or if a column preferably should be printed with hexadecimal numbers instead of decimals. In addition, the properties also contains the name of the columns as well as additional meta-data such as what each column represents, or what the entire table represents.

The properties also returns an attr_value_t type as a list of key/value pairs. Thus, each list-entry should be exactly two elements long, but the value part can itself be a new list of key/value pairs for some keys.

The table property keys are of table_key_t type:

typedef enum {
        /* Table property keys */
        Table_Key_Name = 1,
        Table_Key_Description,
        Table_Key_Default_Sort_Column,
        Table_Key_Columns,
        Table_Key_Extra_Headers,
        Table_Key_Stream_Header_Repeat,
        /* Additional properties might be added in the future.
           Thus, unknown values should be silently ignored. */
} table_key_t;

This is the definition for each table property:

Table_Key_Name String
A short description of what the table represents.
Table_Key_Description String
A longer description what the table represents.
Table_Key_Default_Sort_Column String
References the Column_Key_Name (inside the Table_Key_Columns) to tell which column that should be used when sorting the table by default. If the Column_Key_Name contains new-line characters, replace those with spaces. If not specified, the table will be unsorted by default.
Table_Key_Extra_Headers List of additional header rows
In addition to the column-headers printed, this property allows additional header rows to be presented before the column headers. These additional header rows can span over multiple columns, providing additional explanation and grouping of columns.

The format is: list of additional header rows, each identified as a Extra_Header_Key_Row. Each row is defined by a list of the header-elements where each element is a list of the header's key/value pair properties.

The header property keys are of extra_header_key_t type, this is the definition for each extra header property:

typedef enum {
        /* Header property keys */
        Extra_Header_Key_Row = 2000,
        Extra_Header_Key_Name,
        Extra_Header_Key_Description,
        Extra_Header_Key_First_Column,
        Extra_Header_Key_Last_Column,
} extra_header_key_t;

Extra_Header_Key_Row List of header elements
Identifies a new header row.
Extra_Header_Key_Name String
The name printed for the extra header element.
Extra_Header_Key_Description String
Optional additional text describing the header.
Extra_Header_Key_First_Column String
A reference to the column the additional header spans from.
Extra_Header_Key_Last_Column String
A reference to the column the additional header spans to.

If there is only one header element on a row, and neither Extra_Header_Key_First_Column and Extra_Header_Key_Last_Column are set, the header will span the entire table, even if additional columns has been added by the system. In all other cases first/last column always needs to be specified.
Table_Key_Columns List of columns, with key/value pairs
A list of the columns, where each element consists of key/value pairs defining each column with various properties. The column properties are named with Column_Key_* which are listed below. The list size should match the number of columns in the data. List item 1, represents key/value definitions for column 1 etc.

The column property keys are of column_key_t type:

typedef enum {                
        /* Column property keys */
        Column_Key_Name = 1000,       /* Other number series than table-keys */
        Column_Key_Description,
        Column_Key_Alignment,
        Column_Key_Int_Radix,
        Column_Key_Float_Percent,
        Column_Key_Float_Decimals,
        Column_Key_Sort_Descending,
        Column_Key_Hide_Homogeneous,
        Column_Key_Generate_Percent_Column,
        Column_Key_Generate_Acc_Percent_Column,
        Column_Key_Footer_Sum,
        Column_Key_Footer_Mean,
        Column_Key_Int_Grouping,
        Column_Key_Int_Pad_Width,
        Column_Key_Metric_Prefix,
        Column_Key_Binary_Prefix,
        Column_Key_Time_Format,
        Column_Key_Unique_Id,
        Column_Key_Width,
        Column_Key_Word_Delimiters,
        /* Additional properties might be added in the future.
           Thus, unknown values should be silently ignored. */        
} column_key_t;

This is the definition for each column property:

Column_Key_Name String
The name for the column, displayed on the first row of the table. Preferably these should be as short as possible while still being descriptive. It is possible to break longer strings with a newline character (\n)
Column_Key_Description String
A longer descriptive text describing the column content.
Column_Key_Alignment String: ["left", "right", "center"]
Specifies if the column data should be aligned to the left, right or centered for the entire table data. If not specified strings are left-aligned and numbers right-aligned.
Column_Key_Word_Delimiters String
Overrides the default set of character that will be used for word wrapping of long lines. Default is " -_:,.".
Column_Key_Int_Radix Integer: [2,10,16]]
Specifies the default radix which should be used for when displaying integers numbers, 2 means binary, 10 decimal and 16 hexadecimal. If not specified, the integers will be displayed in the default radix, selectable by the output-radix command.
Column_Key_Int_Grouping Boolean
If False, the current user preferences for integer grouping will be ignored. For example, instead of 12_345 the output will read 12345. If not specified, default grouping is respected. Grouping is set by the output-radix command.
Column_Key_Pad_Width Integer
Zero-extends values up to N characters. This allows similar width of the column data regardless of the value in each cell. For example, with hexadecimal output and 64-bits value printed, the column might be easier to read with a pad-width of 16. If not specified, the default size used 1 (no-padding).
Column_Key_Float_Percent Boolean
If True, any float data in the column will be printed as a percent value. For example, 0.1234 will be printed as 12.34%.
Column_Key_Float_Decimals Integer
Specifies how many decimal digit that should be printed for any floating point values in the column. If not specified 2 decimals are printed by default.
Column_Key_Metric_Prefix String
A metric prefix (m, ยต, n, p, f, a, z, y, k, M, G, T, P, E, Z, Y) will be added to the value and the value will be adjusted accordingly. If the string is non-empty the string will be interpreted as a unit that will be added after the prefix for each value.
Column_Key_Binary_Prefix String
A binary prefix (ki, Mi, Gi, Ti, Pi, Ei, Zi, Yi) will be added to the value and the value will be adjusted accordingly. If the string is non-empty the string will be interpreted as a unit that will be added after the prefix for each value.
Column_Key_Time_Format Boolean
If True the value (in seconds) will be formatted as HH:MM:SS.ss, where only the used parts are shown. The number of seconds decimals formatted is can be controlled by Column_Key_Float_Decimals property. To compact the width, decimals are dropped when hours are displayed.
Column_Key_Unique_Id String
If the same name is set for multiple columns in a table, this property sets a unique name for a specific column, needed when referencing the column from extra headers.
Column_Key_Sort_Descending Boolean
If True, specifies if a column should be sorted with the highest values first. If not specified, this is automatically set to True for any numbers and False for other types.
Column_Key_Hide_Homogeneous Integer/Float/String
If this property is specified and the column consists entirely of the given data, the column will not be shown. For example, if the table has a column which only consists of empty strings (""), the column can be discarded from the resulting table.
If True, all columns values are summed up and displayed in a footer row, below the actual table.
If True, an arithmetic mean of the column values are calculated and displayed in a footer row, below the actual table.
Column_Key_Generate_Percent_Column List of key/value pairs for new column.
If this property is set, an additional column will be created (to the right of this column) showing the percent values for each row. The list of key/value pairs allows to the created column to be customized, however just giving an empty list should give understandable default values.
Column_Key_Generate_Acc_Percent_Column List of key/value pairs for new column.
If this property is set, an additional column will be created (to the right of this column) showing the accumulated percent values for each row. The list of key/value pairs allows to the created column to be customized, however just giving an empty list should give understandable default values.

SIM_INTERFACE(table) {
        /* Returns all rows and columns in the following format:
           [[[i|f|s|o|n*]*]] where the outer list is the row
           and the inner list is the data for each column. */
        attr_value_t (*data)(conf_object_t *obj);
        
        /* Defines the table structure and meta-data for the table
           using a list of key/value pairs.
           [[[ia]*]*] where the integer is the key taken from the
           table_properties_t. The value is key-specific. */
        attr_value_t (*properties)(conf_object_t *obj);

};
#define TABLE_INTERFACE "table"

Execution Context
Global Context for all methods.

slaver_message telnet_connection