Documentation

This page hosts the documentation of the SmartCGMS software architecture and all of its components.

The documentation is being updated to acommodate the recent improvements. Please, be patient, we are working on it...


Model

A model is either a signal model or a discrete model. Both shares the same descriptor structure and library interface.

The main difference between a signal model and a discrete model is, that a signal model is stateless. The discrete model has a state and therefore requires an additional (constant) memory. As a result of this difference, a discrete model is purely of an incremental character - once the state is updated, the model is not able to produce past values. The signal model, having all required reference signal values, is able to produce values from any requested time. Both types are further described in their respective subpages.

Descriptor

Every model is described by its descriptor (scgms::TModel_Descriptor):

struct TModel_Descriptor {
	const GUID id;
	const NModel_Flags flags;
	const wchar_t *description;
	const wchar_t *db_table_name;
	const size_t number_of_parameters;
	const NModel_Parameter_Value *parameter_types;
	const wchar_t **parameter_ui_names;
	const wchar_t **parameter_db_column_names;
	const double *lower_bound;
	const double *default_values;
	const double *upper_bound;
	const size_t number_of_calculated_signals;
	const GUID* calculated_signal_ids;
	const GUID* reference_signal_ids;
};

  • id in an unique model GUID
  • flags represents a model feature flags, a value of NModel_Flags, see below
  • description is a string representing model name, displayed in user interface; it must not be nullptr and must contain a valid zero-terminated string
  • db_table_name (deprecated) identifies database table name used to store this model parameters
  • number_of_parameters is a number of model parameters (and a size of following 6 arrays), must be greater than 0
  • parameter_types is an array of size number_of_parameters, containing parameter types from NModel_Parameter_Value enumerator (see below)
  • parameter_ui_names is an array of size number_of_parameters, containing the human-readable parameter names of each parameter
  • parameter_db_column_names (deprecated) is an array of size number_of_parameters, containing the database table column names of each parameter
  • lower_bound is an array of size number_of_parameters, containing each parameter lower bound (for e.g. optimalization)
  • default_values is an array of size number_of_parameters, containing a default value of each parameter
  • upper_bound is an array of size number_of_parameters, containing each parameter upper bound (for e.g. optimalization)
  • number_of_calculated_signals is a number of signals this model may produce (and size of following 2 arrays)
  • calculated_signal_ids is an array of size number_of_calculated_signals, containing GUIDs of calculated signals (the signal GUIDs that this model may emit at any time)
  • reference_signal_ids is an array of size number_of_calculated_signals, containing GUIDs of reference signals for each calculated signal (to e.g. calculate signal errors by appropriate filters)

The NModel_Flags enumerator currently contains only two values: Signal_Model to identify a signal model and Discrete_Model to identify discrete model. The use of these two flags are not exclusive. Therefore, a model could be both signal model and discrete model, although it is not a common scenario.

The NModel_Parameter_Value enumerator values serve as a semantic marker for each parameter. All parameters are internally stored as double precision floating point values. This enumerator disambiguates between the following types:

  • mptDouble - an ordinary double-precision floating point number
  • mptTime - a double-precision floating point number representing rat time
  • mptBool - a boolean value; zero value is interpreted as false, any other value as true

As stated above, a model defines a set of signals it produces. The philosophy is different for each type of model. A signal model defines its distinct set of signals, which it must produce, and a discrete model defines a set of any signals (already existing or newly introduced ones) it may produce.