TReK C++  5.3.3
Telemetry/Command API
trek::LimitAlarm Class Reference

This class checks a value for violation of defined limits. More...

#include <limit_alarm.h>

Inherits trek::NamedItem.

Public Member Functions

Constructors, Destructor, and Other Basic Methods
 LimitAlarm ()
 Default constructor of the class.
 
virtual ~LimitAlarm ()
 Class destructor. More...
 
LimitAlarmClone ()
 Creates and returns an extact copy of the object.
 
void operator= (LimitAlarm &right_side)
 Provides the equal operator.
 
virtual void Init ()
 Initializes the object.
 
Configuration Methods
void SetLimitType (limit_type type)
 Sets the limit type. More...
 
int32_t SetLimitName (uint32_t level, const char *name)
 Sets the name for the limit level. More...
 
int32_t SetHighLimit (uint32_t level, double value)
 Sets the high limit for the specified level. More...
 
int32_t SetHighLimit (uint32_t level, int64_t value)
 Sets the high limit for the specified level. More...
 
int32_t SetHighLimit (uint32_t level, uint64_t value)
 Sets the high limit for the specified level. More...
 
int32_t SetLowLimit (uint32_t level, double value)
 Sets the low limit for the specified level. More...
 
int32_t SetLowLimit (uint32_t level, int64_t value)
 Sets the low limit for the specified level. More...
 
int32_t SetLowLimit (uint32_t level, uint64_t value)
 Sets the low limit for the specified level. More...
 
int32_t ClearHighLimit (uint32_t level)
 Clears the high limit for the specified level. More...
 
int32_t ClearLowLimit (uint32_t level)
 Clears the low limit for the specified level. More...
 
bool GetHighLevelInUse (uint32_t level)
 Determines if a high limit is being used. More...
 
bool GetLowLevelInUse (uint32_t level)
 Determines if a low limit is being used. More...
 
Get Methods
limit_type GetLimitType ()
 Gets the limit type for the alarm. More...
 
int32_t GetLimitName (uint32_t level, char *name, uint32_t *size_of_output)
 Gets the name of the limit for the specified level. More...
 
const char * GetLimitName (uint32_t level)
 Gets the name of the limit for the specified level. More...
 
int32_t GetHighLimit (uint32_t level, double &value)
 Gets the value of the high limit for the specified level. More...
 
int32_t GetHighLimit (uint32_t level, int64_t &value)
 Gets the value of the high limit for the specified level. More...
 
int32_t GetHighLimit (uint32_t level, uint64_t &value)
 Gets the value of the high limit for the specified level. More...
 
int32_t GetLowLimit (uint32_t level, double &value)
 Gets the value of the low limit for the specified level. More...
 
int32_t GetLowLimit (uint32_t level, int64_t &value)
 Gets the value of the low limit for the specified level. More...
 
int32_t GetLowLimit (uint32_t level, uint64_t &value)
 Gets the value of the low limit for the specified level. More...
 
Methods to Check for Violations
int32_t Check (double value, ParameterStatus &status)
 Checks the supplied double value for violations of any limits. More...
 
int32_t Check (int64_t value, ParameterStatus &status)
 Checks the supplied integer value for violations of any limits. More...
 
int32_t Check (uint64_t value, ParameterStatus &status)
 Checks the supplied unsigned integer value for violations of any limits. More...
 
Serialization Methods

These methods help read and write the class to disk or memory. Most users will not be interested in these. Those that are can continue reading.

int32_t LoadFile (const char *filename)
 Loads the LimitAlarm definition from the specified file. More...
 
int32_t SaveFile (const char *filename)
 Saves the LimitAlarm definition to the specified file. More...
 
- 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.
 

Detailed Description

This class checks a value for violation of defined limits.

If a limit violation occurs, the parameter status is updated.

Constructor & Destructor Documentation

◆ ~LimitAlarm()

trek::LimitAlarm::~LimitAlarm ( )
virtual

Class destructor.

Removes all resources created with this instance of the class.

Member Function Documentation

◆ Check() [1/3]

int32_t trek::LimitAlarm::Check ( double  value,
ParameterStatus status 
)

Checks the supplied double value for violations of any limits.

If any limit is violated, the parameter status is updated to reflect the violation. If no limit violations are found, the corresponding status is cleared.

Parameters
[in]valueThe value to check for limit violations
[out]statusThe parameter status associated with the Parameter
Returns
SUCCESS
TREK_DATA_INCORRECT_LIMIT_TYPE

◆ Check() [2/3]

int32_t trek::LimitAlarm::Check ( int64_t  value,
ParameterStatus status 
)

Checks the supplied integer value for violations of any limits.

If any limit is violated, the parameter status is updated to reflect the violation. If no limit violations are found, the corresponding status is cleared.

Parameters
[in]valueThe value to check for limit violations
[out]statusThe parameter status associated with the Parameter
Returns
SUCCESS
TREK_DATA_INCORRECT_LIMIT_TYPE

◆ Check() [3/3]

int32_t trek::LimitAlarm::Check ( uint64_t  value,
ParameterStatus status 
)

Checks the supplied unsigned integer value for violations of any limits.

If any limit is violated, the parameter status is updated to reflect the violation. If no limit violations are found, the corresponding status is cleared.

Parameters
[in]valueThe value to check for limit violations
[out]statusThe parameter status associated with the Parameter
Returns
SUCCESS
TREK_DATA_INCORRECT_LIMIT_TYPE

◆ ClearHighLimit()

int32_t trek::LimitAlarm::ClearHighLimit ( uint32_t  level)

Clears the high limit for the specified level.

The level is marked as not in use.

Parameters
[in]levelThe level to clear the limit for
Returns
SUCCESS
TREK_DATA_LIMIT_LEVEL_ERROR

Example:

if( la.ClearHighLimit( 3 ) )
{
// invalid level (must be 1-5).
}
This class checks a value for violation of defined limits.
Definition: limit_alarm.h:37
int32_t ClearHighLimit(uint32_t level)
Clears the high limit for the specified level.
Definition: limit_alarm.cpp:1810

◆ ClearLowLimit()

int32_t trek::LimitAlarm::ClearLowLimit ( uint32_t  level)

Clears the low limit for the specified level.

The level is marked as not in use.

Parameters
[in]levelThe level to clear the limit for
Returns
SUCCESS
TREK_DATA_LIMIT_LEVEL_ERROR

Example:

if( la.ClearLowLimit( 3 ) )
{
// invalid level (must be 1-5).
}
int32_t ClearLowLimit(uint32_t level)
Clears the low limit for the specified level.
Definition: limit_alarm.cpp:1837

◆ GetHighLevelInUse()

bool trek::LimitAlarm::GetHighLevelInUse ( uint32_t  level)

Determines if a high limit is being used.

Parameters
[in]levelThe level to query
Returns
true If limit is in use for the high level specified
false If the limit is not in use or does not exist

Example:

if( la.GetHighLevelInUse( 1 ) )
{
// it's being used
}
bool GetHighLevelInUse(uint32_t level)
Determines if a high limit is being used.
Definition: limit_alarm.cpp:1862

◆ GetHighLimit() [1/3]

int32_t trek::LimitAlarm::GetHighLimit ( uint32_t  level,
double &  value 
)

Gets the value of the high limit for the specified level.

Parameters
[in]levelThe level to get the limit for
[out]valueThe value for the level
Returns
SUCCESS
TREK_DATA_INCORRECT_LIMIT_TYPE
TREK_DATA_LIMIT_LEVEL_ERROR

Example:

double value;
if( la.GetHighLimit( 3, value ) == SUCCESS )
{
// got the value
}
int32_t GetHighLimit(uint32_t level, double &value)
Gets the value of the high limit for the specified level.
Definition: limit_alarm.cpp:2026
#define SUCCESS
The function completed successfully.
Definition: trek_error.h:8

◆ GetHighLimit() [2/3]

int32_t trek::LimitAlarm::GetHighLimit ( uint32_t  level,
int64_t &  value 
)

Gets the value of the high limit for the specified level.

Parameters
[in]levelThe level to get the limit for
[out]valueThe value for the level
Returns
SUCCESS
TREK_DATA_INCORRECT_LIMIT_TYPE
TREK_DATA_LIMIT_LEVEL_ERROR

Example:

int64_t value;
if( la.GetHighLimit( 3, value ) == SUCCESS )
{
// got the value
}

◆ GetHighLimit() [3/3]

int32_t trek::LimitAlarm::GetHighLimit ( uint32_t  level,
uint64_t &  value 
)

Gets the value of the high limit for the specified level.

Parameters
[in]levelThe level to get the limit for
[out]valueThe value for the level
Returns
SUCCESS
TREK_DATA_INCORRECT_LIMIT_TYPE
TREK_DATA_LIMIT_LEVEL_ERROR

Example:

uint64_t value;
if( la.GetHighLimit( 3, value ) == SUCCESS )
{
// got the value
}

◆ GetLimitName() [1/2]

const char * trek::LimitAlarm::GetLimitName ( uint32_t  level)

Gets the name of the limit for the specified level.

Parameters
[in]levelThe level to get the name for
Returns
The name of the level. If the level does not exist, an empty string is returned

Example:

printf( "My name is %s\n", la.GetLimitName( 3 ) );
int32_t GetLimitName(uint32_t level, char *name, uint32_t *size_of_output)
Gets the name of the limit for the specified level.
Definition: limit_alarm.cpp:1964

◆ GetLimitName() [2/2]

int32_t trek::LimitAlarm::GetLimitName ( uint32_t  level,
char *  name,
uint32_t *  size_of_output 
)

Gets the name of the limit for the specified level.

Parameters
[in]levelThe level to get the name for
[out]nameThe name for the level
[in,out]size_of_outputThe number of bytes allocated for the buffer on input. If return code is set to TREK_DATA_NOT_ENOUGH_SPACE, then the value is reset to the number of bytes required for the data to be copied.
Returns
SUCCESS
TREK_DATA_LIMIT_LEVEL_ERROR
TREK_DATA_NOT_ENOUGH_SPACE
TREK_DATA_NULL_PTR

Example:

char name[10];
uint32_t size_of_output = 10;
int32_t ret_value;
ret_value = la.GetLimtName( 3, name, &size_of_output ) );
if( ret_value )
{
// process return value
}
else
printf( "Level name is: %s\n", name );

◆ GetLimitType()

limit_type trek::LimitAlarm::GetLimitType ( )

Gets the limit type for the alarm.

Returns
The limit type

◆ GetLowLevelInUse()

bool trek::LimitAlarm::GetLowLevelInUse ( uint32_t  level)

Determines if a low limit is being used.

Parameters
[in]levelThe level to query
Returns
true If limit is in use for the low level specified
false If the limit is not in use or does not exist

Example:

if( la.GetLowLevelInUse( 1 ) )
{
// it's being used
}
bool GetLowLevelInUse(uint32_t level)
Determines if a low limit is being used.
Definition: limit_alarm.cpp:1886

◆ GetLowLimit() [1/3]

int32_t trek::LimitAlarm::GetLowLimit ( uint32_t  level,
double &  value 
)

Gets the value of the low limit for the specified level.

Parameters
[in]levelThe level to get the limit for
[out]valueThe value for the level
Returns
SUCCESS
TREK_DATA_INCORRECT_LIMIT_TYPE
TREK_DATA_LIMIT_LEVEL_ERROR

Example:

double value;
if( la.GetLowLimit( 3, value ) == SUCCESS )
{
// got the value
}
int32_t GetLowLimit(uint32_t level, double &value)
Gets the value of the low limit for the specified level.
Definition: limit_alarm.cpp:2131

◆ GetLowLimit() [2/3]

int32_t trek::LimitAlarm::GetLowLimit ( uint32_t  level,
int64_t &  value 
)

Gets the value of the low limit for the specified level.

Parameters
[in]levelThe level to get the limit for
[out]valueThe value for the level
Returns
SUCCESS
TREK_DATA_INCORRECT_LIMIT_TYPE
TREK_DATA_LIMIT_LEVEL_ERROR

Example:

int64_t value;
if( la.GetLowLimit( 3, value ) == SUCCESS )
{
// got the value
}

◆ GetLowLimit() [3/3]

int32_t trek::LimitAlarm::GetLowLimit ( uint32_t  level,
uint64_t &  value 
)

Gets the value of the low limit for the specified level.

Parameters
[in]levelThe level to get the limit for
[out]valueThe value for the level
Returns
SUCCESS
TREK_DATA_INCORRECT_LIMIT_TYPE
TREK_DATA_LIMIT_LEVEL_ERROR

Example:

uint64_t value;
if( la.GetLowLimit( 3, value ) == SUCCESS )
{
// got the value
}

◆ LoadFile()

int32_t trek::LimitAlarm::LoadFile ( const char *  filename)

Loads the LimitAlarm definition from the specified file.

Reads an XML format for the LimitAlarm. It can be written in with SaveFile.

Parameters
[in]filenameThe file to load the limit alarm object from.
Returns
SUCCESS
TREK_DATA_NULL_PTR
Other return codes

Example:

char *filename = "my_file.xml";
ret_value = la.LoadFile( filename );
int32_t LoadFile(const char *filename)
Loads the LimitAlarm definition from the specified file.
Definition: limit_alarm.cpp:146

◆ SaveFile()

int32_t trek::LimitAlarm::SaveFile ( const char *  filename)

Saves the LimitAlarm definition to the specified file.

Writes an XML format for the LimitAlarm. It can be read in with LoadFile.

Parameters
[in]filenameThe file to save the limit alarm object to.
Returns
SUCCESS
TREK_DATA_NULL_PTR
Other return codes

Example:

char *filename = "my_file.xml";
ret_value = la.SaveFile( filename );
int32_t SaveFile(const char *filename)
Saves the LimitAlarm definition to the specified file.
Definition: limit_alarm.cpp:181

◆ SetHighLimit() [1/3]

int32_t trek::LimitAlarm::SetHighLimit ( uint32_t  level,
double  value 
)

Sets the high limit for the specified level.

The input value is checked to ensure that it is the correct limit type and also would not violate any other limits previously set.

Parameters
[in]levelThe level to set the limit for
[in]valueThe value for the alarm level
Returns
SUCCESS
TREK_DATA_LIMIT_LEVEL_ERROR
TREK_DATA_INCORRECT_LIMIT_TYPE
TREK_DATA_LIMIT_VALUE_TOO_SMALL
TREK_DATA_LIMIT_VALUE_TOO_LARGE

Example:

std::string name;
double value;
// Set the level 3 limit value
value = 1000.0;
if( la.SetHighLimit( 3, value ) )
{
// error.
}
int32_t SetHighLimit(uint32_t level, double value)
Sets the high limit for the specified level.
Definition: limit_alarm.cpp:1170

◆ SetHighLimit() [2/3]

int32_t trek::LimitAlarm::SetHighLimit ( uint32_t  level,
int64_t  value 
)

Sets the high limit for the specified level.

The input value is checked to ensure that it is the correct limit type and also would not violate any other limits previously set.

Parameters
[in]levelThe level to set the limit for
[in]valueThe value for the alarm level
Returns
SUCCESS
TREK_DATA_LIMIT_LEVEL_ERROR
TREK_DATA_INCORRECT_LIMIT_TYPE
TREK_DATA_LIMIT_VALUE_TOO_SMALL
TREK_DATA_LIMIT_VALUE_TOO_LARGE

Example:

std::string name;
int64_t value;
// Set the level 3 limit value
value = 1000;
if( la.SetHighLimit( 3, value ) )
{
// error.
}

◆ SetHighLimit() [3/3]

int32_t trek::LimitAlarm::SetHighLimit ( uint32_t  level,
uint64_t  value 
)

Sets the high limit for the specified level.

The input value is checked to ensure that it is the correct limit type and also would not violate any other limits previously set.

Parameters
[in]levelThe level to set the limit for
[in]valueThe value for the alarm level
Returns
SUCCESS
TREK_DATA_LIMIT_LEVEL_ERROR
TREK_DATA_INCORRECT_LIMIT_TYPE
TREK_DATA_LIMIT_VALUE_TOO_SMALL
TREK_DATA_LIMIT_VALUE_TOO_LARGE

Example:

std::string name;
uint64_t value;
// Set the level 3 limit value
value = 1000;
if( la.SetHighLimit( 3, value ) )
{
// error.
}

◆ SetLimitName()

int32_t trek::LimitAlarm::SetLimitName ( uint32_t  level,
const char *  name 
)

Sets the name for the limit level.

Parameters
[in]levelThe level to set the name for
[in]nameThe new name for the alarm level
Returns
SUCCESS
TREK_DATA_LIMIT_LEVEL_ERROR
TREK_DATA_NULL_PTR

Example:

if( la.SetLimitName( 3, "Caution" ) )
{
// invalid level number.
}
la.SetLimitName( 4, "Warning" );
int32_t SetLimitName(uint32_t level, const char *name)
Sets the name for the limit level.
Definition: limit_alarm.cpp:1128

◆ SetLimitType()

void trek::LimitAlarm::SetLimitType ( limit_type  type)

Sets the limit type.

The limit type should correspond to the data type for a parameter to allow all values to be represented.

Parameters
[in]typeThe type of limit (double, etc.) to use

◆ SetLowLimit() [1/3]

int32_t trek::LimitAlarm::SetLowLimit ( uint32_t  level,
double  value 
)

Sets the low limit for the specified level.

The input value is checked to ensure that it is the correct limit type and also would not violate any other limits previously set.

Parameters
[in]levelThe level to set the limit for
[in]valueThe value for the alarm level
Returns
SUCCESS
TREK_DATA_LIMIT_LEVEL_ERROR
TREK_DATA_INCORRECT_LIMIT_TYPE
TREK_DATA_LIMIT_VALUE_TOO_SMALL
TREK_DATA_LIMIT_VALUE_TOO_LARGE

Example:

std::string name;
double value;
// Set the level 3 limit value
value = 1000.0;
if( la.SetLowLimit( 3, value ) )
{
// error.
}
int32_t SetLowLimit(uint32_t level, double value)
Sets the low limit for the specified level.
Definition: limit_alarm.cpp:1393

◆ SetLowLimit() [2/3]

int32_t trek::LimitAlarm::SetLowLimit ( uint32_t  level,
int64_t  value 
)

Sets the low limit for the specified level.

The input value is checked to ensure that it is the correct limit type and also would not violate any other limits previously set.

Parameters
[in]levelThe level to set the limit for
[in]valueThe value for the alarm level
Returns
SUCCESS
TREK_DATA_LIMIT_LEVEL_ERROR
TREK_DATA_INCORRECT_LIMIT_TYPE
TREK_DATA_LIMIT_VALUE_TOO_SMALL
TREK_DATA_LIMIT_VALUE_TOO_LARGE

Example:

std::string name;
int64_t value;
// Set the level 3 limit value
value = 1000;
if( la.SetLowLimit( 3, value ) )
{
// error.
}

◆ SetLowLimit() [3/3]

int32_t trek::LimitAlarm::SetLowLimit ( uint32_t  level,
uint64_t  value 
)

Sets the low limit for the specified level.

The input value is checked to ensure that it is the correct limit type and also would not violate any other limits previously set.

Parameters
[in]levelThe level to set the limit for
[in]valueThe value for the alarm level
Returns
SUCCESS
TREK_DATA_LIMIT_LEVEL_ERROR
TREK_DATA_INCORRECT_LIMIT_TYPE
TREK_DATA_LIMIT_VALUE_TOO_SMALL
TREK_DATA_LIMIT_VALUE_TOO_LARGE

Example:

std::string name;
uint64_t value;
// Set the level 3 limit value
value = 1000;
if( la.SetLowLimit( 3, value ) )
{
// error.
}