TReK C++
5.3.3
Telemetry/Command API
|
This class is the abstraction for sets of information that can be switch by the value of a parameter. More...
#include <switch_set.h>
Inherits trek::NamedItem.
Inherited by trek::CalibratorSwitchSet, trek::EnumeratorSwitchSet, trek::ExpectedStateAlarmSwitchSet, and trek::LimitAlarmSwitchSet.
Public Member Functions | |
int32_t | SetDefaultSetName (const char *name) |
Sets the default set name. More... | |
const char * | GetDefaultSetName () |
Gets the default set name. More... | |
int32_t | SetSwitchParameterName (const char *name) |
Sets the name of the parameter to use as a switch. More... | |
const char * | GetSwitchParameterName () |
Gets the parameter name for the switch. More... | |
void | SetSwitchType (switch_type input) |
Sets the type of switch to use. More... | |
switch_type | GetSwitchType () |
Returns the current switch type. More... | |
int32_t | SetSwitchParameter (Parameter *input_ptr) |
Sets the parameter to use for switching. More... | |
int32_t | AddRangeSwitch (double low, double high, const char *name) |
Adds a range switch. More... | |
int32_t | AddEnumerationSwitch (const char *enum_name, const char *name) |
Adds an enumeration switch. More... | |
int32_t | DeleteRangeSwitch (double low) |
Deletes the specified range switch. More... | |
int32_t | DeleteEnumerationSwitch (const char *enum_name) |
Deletes the specified enumeration switch. More... | |
int32_t | GetRangeSwitches (double **input, uint32_t &array_size) |
Gets the low value for each range switch. More... | |
void | GetEnumerationSwitches (StringArray &input) |
Gets the enumeration values for the switch. More... | |
int32_t | GetRangeSwitchInfo (double low, double &high, char **name) |
Gets the high value and name for a range switch based on its low value. More... | |
int32_t | GetEnumerationInfo (const char *enum_name, char **name) |
Gets the name for a switch based on its enumerated value. More... | |
int32_t | Validate () |
Determines if it is safe to use the switch set. More... | |
const char * | GetValidationErrors () |
Gets a string of the last validation errors. More... | |
uint32_t | GetEnumerationInfoLength (const char *enum_name) |
Gets the length for returned info of input parameter. Does not include space for the NULL termination character. More... | |
int32_t | GetEnumerationInfo (const char *enum_name, char *name, uint16_t &name_size) |
Gets the name for a switch based on its enumerated value. More... | |
uint32_t | GetRangeSwitchInfoLength (double low) |
Gets the length for returned info of input parameter. Does not include space for the NULL termination character. More... | |
int32_t | GetRangeSwitchInfo (double low, double &high, char *name, uint16_t &name_size) |
Gets the high value and name for a range switch based on its low value. More... | |
uint32_t | GetNumberOfRangeSwitches () |
Returns the number of range switches available. More... | |
int32_t | GetRangeSwitches (double *low_values, uint32_t low_value_size) |
Gets the low value for each range switch. More... | |
void | GetItemNames (StringArray &input) |
Retrieves an array of the (e.g., calibrator) names from the set. More... | |
Constructors, Destructor, and Other Basic Methods | |
SwitchSet () | |
Default constructor of the class. | |
SwitchSet (SwitchSet &input) | |
Copy constructor of the class. | |
virtual | ~SwitchSet () |
Class destructor. More... | |
void | operator= (SwitchSet &right_side) |
Provides the equal operator. | |
virtual void | Init () |
Initializes the object. | |
Public Member Functions inherited from trek::NamedItem | |
void | SetName (const char *input_ptr) |
Sets the name of the item. More... | |
void | SetAlias (const char *input) |
Sets the alias of the item. More... | |
void | SetShortDescription (const char *input_ptr) |
Sets the short description of the item. More... | |
void | SetLongDescription (const char *input_ptr) |
Sets the long description of the item. More... | |
void | SetUserDescription (const char *input_ptr) |
Sets the user description of the item. More... | |
void | SetOwner (const char *input_ptr) |
Sets the owner of the item. More... | |
const char * | GetName () |
Returns the name of the item. | |
const char * | GetAlias () |
Returns the alias of the item. | |
const char * | GetShortDescription () |
Returns the short description of the item. | |
const char * | GetLongDescription () |
Returns the long description of the item. | |
const char * | GetUserDescription () |
Returns the user description of the item. | |
const char * | GetOwner () |
Returns the owner of the item. | |
NamedItem () | |
Default constructor of the class. | |
NamedItem (NamedItem &input) | |
Copy constructor of the class. | |
virtual | ~NamedItem () |
Class destructor. More... | |
void | operator= (NamedItem &right_side) |
Provides the equal operator. | |
bool | operator== (NamedItem &right_side) |
Provides the == operator. | |
This class is the abstraction for sets of information that can be switch by the value of a parameter.
The switch parameter can be used to determine which set of information to use. Used for enumeration, calbiration, limits, and expected states. Two types of switching are supported: range switching and enumeration switching.
|
virtual |
Class destructor.
Removes all resources created with this instance of the class.
int32_t trek::SwitchSet::AddEnumerationSwitch | ( | const char * | enum_name, |
const char * | name | ||
) |
Adds an enumeration switch.
Adds the specified enumeration switch. Checks are performed to make sure the specified enumeration does not already exist.
[in] | enum_name | The enumerated value to use for switching. |
[in] | name | The name of the item to switch to when the switch parameter has the specified enumeration. |
Example:
int32_t trek::SwitchSet::AddRangeSwitch | ( | double | low, |
double | high, | ||
const char * | name | ||
) |
Adds a range switch.
Adds the specified range switch. Checks are performed to make sure the specified range does not overlap with a current range. Ranges are evaluated by low < value <= high.
[in] | low | The low value for the range. |
[in] | high | The high value for the range. |
[in] | name | The name of the item to switch to when the switch parameter falls within the range. |
Example:
int32_t trek::SwitchSet::DeleteEnumerationSwitch | ( | const char * | enum_name | ) |
Deletes the specified enumeration switch.
[in] | enum_name | The enumerated value to delete. |
Example:
int32_t trek::SwitchSet::DeleteRangeSwitch | ( | double | low | ) |
Deletes the specified range switch.
Only need to specify the low range as ranges are not allowed to overlap.
[in] | low | The low range of the switch to delete. |
Example:
const char * trek::SwitchSet::GetDefaultSetName | ( | ) |
Gets the default set name.
Example:
int32_t trek::SwitchSet::GetEnumerationInfo | ( | const char * | enum_name, |
char ** | name | ||
) |
Gets the name for a switch based on its enumerated value.
All of the enumerations can be found by calling GetEnumerationSwitches. The caller of the function is responsible for deleting the memory that is created.
[in] | enum_name | The enumerated value to search for |
[out] | name | The name of the item when switch is valid. |
Example:
int32_t trek::SwitchSet::GetEnumerationInfo | ( | const char * | enum_name, |
char * | name, | ||
uint16_t & | name_size | ||
) |
Gets the name for a switch based on its enumerated value.
All of the enumerations can be found by calling GetEnumerationSwitches. The caller of the function is responsible for allocating the memory needed for the returned data by calling GetEnumerationInfoLength.
[in] | enum_name | The enumerated value to search for |
[out] | name | The name of the item when switch is valid. |
[in] | name_size | The size of the data allocated for name. |
Example:
uint32_t trek::SwitchSet::GetEnumerationInfoLength | ( | const char * | enum_name | ) |
Gets the length for returned info of input parameter. Does not include space for the NULL termination character.
If the input does not exist, zero is returned.
[in] | enum_name | The enumerated value to search for |
Example:
void trek::SwitchSet::GetEnumerationSwitches | ( | StringArray & | input | ) |
Gets the enumeration values for the switch.
The input array will be cleared prior to values being added.
[out] | input | Will contain all of the enumerated values for the switch. |
Example:
void trek::SwitchSet::GetItemNames | ( | StringArray & | input | ) |
Retrieves an array of the (e.g., calibrator) names from the set.
[in] | input | The array to set. Previous items will be cleared. |
Example:
uint32_t trek::SwitchSet::GetNumberOfRangeSwitches | ( | ) |
Returns the number of range switches available.
int32_t trek::SwitchSet::GetRangeSwitches | ( | double ** | input, |
uint32_t & | array_size | ||
) |
Gets the low value for each range switch.
The low range returned can be used to access details about each range by calling GetRangeSwitchInfo. The caller of the function is responsible for deleting the memory that is created.
[out] | input | This value will contain an array of doubles that are the low value. |
[out] | array_size | The number of values returned. |
Example:
int32_t trek::SwitchSet::GetRangeSwitches | ( | double * | low_values, |
uint32_t | low_value_size | ||
) |
Gets the low value for each range switch.
The low range returned can be used to access details about each range by calling GetRangeSwitchInfo. The caller of the function is responsible for allocating the memory that is needed. The size of memory needed can be found by calling GetNumberOfRangeSwitches.
[out] | input | This value will contain an array of doubles that are the low value. |
[in] | array_size | The size of the array. |
Example:
int32_t trek::SwitchSet::GetRangeSwitchInfo | ( | double | low, |
double & | high, | ||
char ** | name | ||
) |
Gets the high value and name for a range switch based on its low value.
All of the low ranges can be found by calling GetRangeSwitches. The caller of the function is responsible for deleting the memory that is created.
[in] | low | The low value to search for |
[out] | high | The corresponding low value. |
[out] | name | The name of the item when switch is valid. |
Example:
int32_t trek::SwitchSet::GetRangeSwitchInfo | ( | double | low, |
double & | high, | ||
char * | name, | ||
uint16_t & | name_size | ||
) |
Gets the high value and name for a range switch based on its low value.
All of the low ranges can be found by calling GetRangeSwitches. The caller of the function is responsible for allocating the memory that is needed. The size of data that will be returned can be found by calling GetRangeSwitchInfoLength.
[in] | low | The low value to search for |
[out] | high | The corresponding low value. |
[out] | name | The name of the item when switch is valid. |
[in] | name_size | The size of data allocated for name. |
Example:
uint32_t trek::SwitchSet::GetRangeSwitchInfoLength | ( | double | low | ) |
Gets the length for returned info of input parameter. Does not include space for the NULL termination character.
If the input does not exist, zero is returned.
[in] | low | The value to search for |
Example:
const char * trek::SwitchSet::GetSwitchParameterName | ( | ) |
Gets the parameter name for the switch.
Example:
switch_type trek::SwitchSet::GetSwitchType | ( | ) |
Returns the current switch type.
Example:
const char * trek::SwitchSet::GetValidationErrors | ( | ) |
Gets a string of the last validation errors.
int32_t trek::SwitchSet::SetDefaultSetName | ( | const char * | name | ) |
Sets the default set name.
The name of the item (e.g., calibrator) to use if no other set can be identified by switching.
[in] | name | The name of the set. |
Example:
int32_t trek::SwitchSet::SetSwitchParameter | ( | Parameter * | input_ptr | ) |
Sets the parameter to use for switching.
[in] | input_ptr | A valid reference to a parameter in a packet. |
int32_t trek::SwitchSet::SetSwitchParameterName | ( | const char * | name | ) |
Sets the name of the parameter to use as a switch.
[in] | name | The name of the switch parameter. |
Example:
void trek::SwitchSet::SetSwitchType | ( | switch_type | input | ) |
Sets the type of switch to use.
input | The new switch type |
Example:
int32_t trek::SwitchSet::Validate | ( | ) |
Determines if it is safe to use the switch set.
Insures that class is properly configured. Safe to use if 0 is returned.
Example: