Libraries
Trek

Classes

struct  trek::packet_identifier_struct
 Structure of information needed for identifier parameters. More...
 
class  trek::SwitchSet
 This class is the abstraction for sets of information that can be switched by the value of a parameter. More...
 

Typedefs

typedef enum identifier_types identifier_types
 Enumeration of types of identifiers.
 

Enumerations

enum  trek::limit_type {
  trek::DOUBLE_LIMITS,
  trek::INT_LIMITS,
  trek::UINT_LIMITS
}
 Enumeration of limit types allowed. More...
 
enum  trek::packet_zone_type {
  trek::HEADER_ZONE,
  trek::DATA_ZONE,
  trek::TRAILER_ZONE
}
 Enumeration of packet zones. More...
 
enum  trek::packet_checksum_point_type {
  trek::START_HEADER,
  trek::START_DATA,
  trek::END_DATA,
  trek::END_TRAILER
}
 Enumeration of start and end points for checksums. More...
 
enum  trek::packet_checksum_type {
  trek::CT_CRC32,
  trek::CT_MD5,
  trek::CT_SUM16
}
 Enumeration of checksum types allowed. More...
 
enum  trek::parameter_data_type {
  trek::DT_TWOS_COMPLEMENT,
  trek::DT_UNSIGNED_INTEGER,
  trek::DT_BINARY_CODED_DECIMAL,
  trek::DT_DISTENDED_SIGNED_INTEGER,
  trek::DT_SIGN_AND_MAGNITUDE_INTEGER,
  trek::DT_IEEE_FLOATING_POINT,
  trek::DT_NULL_TERMINATED_STRING,
  trek::DT_FIXED_LENGTH_STRING,
  trek::DT_BOOLEAN,
  trek::DT_UNSPECIFIED_BYTES,
  trek::DT_GPS_EPOCH_TIME,
  trek::DT_EHS_TIME,
  trek::DT_ISS_TIME,
  trek::DT_FASTSAT_TIME,
  trek::DT_DEM_TIME,
  trek::DT_UNIX_TIME,
  trek::DT_EHS_CONV_TIME,
  trek::DT_ISAT_TIME
}
 Enumeration of all valid data types for TReK. More...
 
enum  trek::parameter_data_format {
  trek::DF_ASCII,
  trek::DF_BINARY,
  trek::DF_DECIMAL,
  trek::DF_SCIENTIFIC,
  trek::DF_HEX,
  trek::DF_BOOLEAN,
  trek::DF_DATE_TIME
}
 Enumeration of all valid data formats for TReK values as strings. More...
 
enum  trek::switch_type {
  trek::RANGE_SWITCH,
  trek::ENUMERATION_SWITCH
}
 Enumeration of switch types. More...
 
enum  byte_order_type {
  BIG_ENDIAN_BYTE_ORDER = 0,
  LITTLE_ENDIAN_BYTE_ORDER,
  BYTE_SWAPPED_BYTE_ORDER,
  WORD_SWAPPED_BYTE_ORDER
}
 Byte order enumeration. More...
 
enum  identifier_types {
  FIXED_VALUE_IDENTIFIER,
  USER_SELECTABLE_IDENTIFIER,
  CONTENT_IDENTIFIER
}
 Enumeration of types of identifiers. More...
 

Functions

int32_t trek::SwitchSet::SetDefaultSetName (const char *name)
 Sets the default set name. More...
 
const char * trek::SwitchSet::GetDefaultSetName ()
 Gets the default set name. More...
 
int32_t trek::SwitchSet::SetSwitchParameterName (const char *name)
 Sets the name of the parameter to use as a switch. More...
 
const char * trek::SwitchSet::GetSwitchParameterName ()
 Gets the default set name. More...
 
void trek::SwitchSet::SetSwitchType (switch_type input)
 Sets the type of switch to use. More...
 
switch_type trek::SwitchSet::GetSwitchType ()
 Returns the current switch type. More...
 
int32_t trek::SwitchSet::SetSwitchParameter (Parameter *input_ptr)
 Sets the parameter to use for switching. More...
 
int32_t trek::SwitchSet::AddRangeSwitch (double low, double high, const char *name)
 Adds a range switch. More...
 
int32_t trek::SwitchSet::AddEnumerationSwitch (const char *enum_name, const char *name)
 Adds an enumeration switch. More...
 
int32_t trek::SwitchSet::DeleteRangeSwitch (double low)
 Deletes the specified range switch. More...
 
int32_t trek::SwitchSet::DeleteEnumerationSwitch (const char *enum_name)
 Deletes the specified enumeration switch. More...
 
int32_t trek::SwitchSet::GetRangeSwitches (double **input, uint32_t &array_size)
 Gets the low value for each range switch. More...
 
void trek::SwitchSet::GetEnumerationSwitches (StringArray &input)
 Gets the enumeration values for the switch. More...
 
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. More...
 
int32_t trek::SwitchSet::GetEnumerationInfo (const char *enum_name, char **name)
 Gets the name for a switch based on its enumerated value. More...
 
int32_t trek::SwitchSet::Validate ()
 Determines if it is safe to use the switched set. More...
 
const char * trek::SwitchSet::GetValidationErrors ()
 Gets a string of the last validation errors. More...
 
void trek::SwitchSet::GetItemNames (StringArray &input)
 Retrieves an array of the (e.g., calibrator) names from the set. More...
 

Constructors, Destructor, and Other Basic Methods

 trek::SwitchSet::SwitchSet ()
 Default constructor of the class.
 
 trek::SwitchSet::SwitchSet (SwitchSet &input)
 Copy constructor of the class.
 
virtual trek::SwitchSet::~SwitchSet ()
 Class destructor. More...
 
void trek::SwitchSet::operator= (SwitchSet &right_side)
 Provides the equal operator.
 
virtual void trek::SwitchSet::Init ()
 Initializes the object.
 

Detailed Description

Enumeration Type Documentation

◆ byte_order_type

Byte order enumeration.

Enumerator
BIG_ENDIAN_BYTE_ORDER 

Also known as network byte order. Most significant byte is first.

LITTLE_ENDIAN_BYTE_ORDER 

Least significant byte is first.

BYTE_SWAPPED_BYTE_ORDER 

Each byte in a 16-bit word is swapped.

WORD_SWAPPED_BYTE_ORDER 

Each 16-bit word in a 32-bit word is swapped.

◆ identifier_types

Enumeration of types of identifiers.

Enumerator
FIXED_VALUE_IDENTIFIER 

must always be a value (important enough to check)

USER_SELECTABLE_IDENTIFIER 

used to identify packet, but must be set at 'run time'

CONTENT_IDENTIFIER 

used to determine content of packet

◆ limit_type

Enumeration of limit types allowed.

Enumerator
DOUBLE_LIMITS 

Double limits (used for floating point numbers and calibrated data)

INT_LIMITS 

Integer limits (used for data converted to signed integers that are not calibrated)

UINT_LIMITS 

Unsigned limits (used for data converted to unsigned integers that are not calibrated)

◆ packet_checksum_point_type

Enumeration of start and end points for checksums.

Enumerator
START_HEADER 

Start of header (beginning of packet)

START_DATA 

Start of data (or end of header if you prefer)

END_DATA 

End of data (or start of trailer if you prefer)

END_TRAILER 

End of trailer (end of packet)

◆ packet_checksum_type

Enumeration of checksum types allowed.

Enumerator
CT_CRC32 

32-bit Cyclic redundance check (see ???)

CT_MD5 

MD5 sum (see ???)

CT_SUM16 

sum of 16-bit words ignoring overflow

◆ packet_zone_type

Enumeration of packet zones.

Enumerator
HEADER_ZONE 

Header (first) zone in packet.

DATA_ZONE 

Data (second) zone in packet.

TRAILER_ZONE 

Trailer (last) zone in packet.

◆ parameter_data_format

Enumeration of all valid data formats for TReK values as strings.

Enumerator
DF_ASCII 

ASCII string data.

DF_BINARY 

All characters must be either 0 or 1.

DF_DECIMAL 

Characters must be 0-9. A period ('.') is allowed for floating point data.

DF_SCIENTIFIC 

Currently not supported.

DF_HEX 

All characters must be 0-9, a-f, or A-F.

DF_BOOLEAN 

Valid values are 'true' and 'false'. Capitalization does not matter.

DF_DATE_TIME 

Valid values are of the form: YYYY-MM-DD HH:MM:SS.SSS where the .SSS is optional.

◆ parameter_data_type

Enumeration of all valid data types for TReK.

Enumerator
DT_TWOS_COMPLEMENT 

Two's complement integer value ranging from 2 to 64 bits in length.

DT_UNSIGNED_INTEGER 

Unsigned integer value ranging from 1 to 64 bits in length.

DT_BINARY_CODED_DECIMAL 

Binary coded decimal from 1 to 4 digits (4 to 16 bits)

DT_DISTENDED_SIGNED_INTEGER 

Lowest 12 bits contain the magnitude and the most significant bit is the sign. All other bits ignored.

DT_SIGN_AND_MAGNITUDE_INTEGER 

Most significant bit is sign all others are magnitude. 2 to 32 bits in length.

DT_IEEE_FLOATING_POINT 

IEEE floating point value. Single precision is 32 bits. Double precision is 64 bits.

DT_NULL_TERMINATED_STRING 

ASCII string terminated by a NULL (0x00) character.

DT_FIXED_LENGTH_STRING 

ASCII string of fixed length that may or may not contain a terminating character.

DT_BOOLEAN 

Single bit value where 1 indicates true and 0 indicates false.

DT_UNSPECIFIED_BYTES 

Binary data that has no type. From 1 to 65,000 bytes.

DT_GPS_EPOCH_TIME 

32 bit seconds since midnight January 6, 1980

DT_EHS_TIME 

48, 52, or 56 bit time found in the EHS Primary Protocol Header. 52 and 56 bit versions have resolution to one tenth of a second.

DT_ISS_TIME 

40 bits (32-bit seconds since GPS plus 8 bit fractional time...1 bit = ~4ms)

DT_FASTSAT_TIME 

32 bit GPS plus 16 bit fractional milliseconds (max value 999).

DT_DEM_TIME 

32 bit GPS plus 10 bit fractional milliseconds (max value 999).

DT_UNIX_TIME 

32 bits seconds since midnight January 1, 1970

DT_EHS_CONV_TIME 

320 bit time used exclusively for 'converted' time data in EHS GSE Packets.

DT_ISAT_TIME 

32 bits seconds since midnight January 1, 1970 plus 16 bit milliseconds

◆ switch_type

Enumeration of switch types.

Enumerator
RANGE_SWITCH 

Range switch (low < value <= high)

ENUMERATION_SWITCH 

Enumerator switch (value == "string")

Function Documentation

◆ AddEnumerationSwitch()

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.

Parameters
[in]enum_nameThe enumerated value to use for switching.
[in]nameThe name of the item to switch to when the switch parameter has the specified enumeration.
Returns
SUCCESS
TREK_DATA_NULL_PTR
TREK_DATA_INCORRECT_SWITCH_TYPE
TREK_DATA_ALREADY_EXISTS

Example:

CalibratorSwitchSet css;
int32_t ret_value;
ret_value = css.AddEnumerationSwitch( "On", "one" );
ret_value = css.AddEnumerationSwitch( "OFF", "two" );

◆ AddRangeSwitch()

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.

Parameters
[in]lowThe low value for the range.
[in]highThe high value for the range.
[in]nameThe name of the item to switch to when the switch parameter falls within the range.
Returns
SUCCESS
TREK_DATA_NULL_PTR
TREK_DATA_INCORRECT_SWITCH_TYPE
TREK_DATA_LOW_TO_HIGH
TREK_DATA_NEED_UNIQUE_RANGE

Example:

CalibratorSwitchSet css;
int32_t ret_value;
ret_value = css.AddRangeSwitch( 0, 10, "one" );
ret_value = css.AddRangeSwitch( 10, 100, "two" );

◆ DeleteEnumerationSwitch()

int32_t trek::SwitchSet::DeleteEnumerationSwitch ( const char *  enum_name)

Deletes the specified enumeration switch.

Parameters
[in]enum_nameThe enumerated value to delete.
Returns
SUCCESS
TREK_DATA_NULL_PTR
TREK_DATA_DOES_NOT_EXIST

Example:

CalibratorSwitchSet css;
int32_t ret_value;
ret_value = css.AddRangeSwitch( "first", "one" );
ret_value = css.DeleteEnumerationSwitch( "first" );

◆ DeleteRangeSwitch()

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.

Parameters
[in]lowThe low range of the switch to delete.
Returns
SUCCESS
TREK_DATA_DOES_NOT_EXIST

Example:

CalibratorSwitchSet css;
int32_t ret_value;
ret_value = css.AddRangeSwitch( 0, 10, "one" );
ret_value = css.DeleteRangeSwitch( 0 );

◆ GetDefaultSetName()

const char * trek::SwitchSet::GetDefaultSetName ( )

Gets the default set name.

Returns
The default set name (returns empty string if not set)

Example:

CalibratorSwitchSet css;
printf( "Default set name is '%s'\n", css.GetDefaultSetName();

◆ GetEnumerationInfo()

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.

Parameters
[in]enum_nameThe enumerated value to search for
[out]nameThe name of the item when switch is valid.
Returns
SUCCESS
TREK_DATA_NULL_PTR
TREK_DATA_DOES_NOT_EXIST

Example:

CalibratorSwitchSet css;
int32_t ret_value;
char *name;
ret_value = css.GetEnumerationInfo( "ON", &name );
if( ret_value == SUCCESS )
{
printf( "When ON use %s\n", name );
delete name;
}

◆ GetEnumerationSwitches()

void trek::SwitchSet::GetEnumerationSwitches ( StringArray input)

Gets the enumeration values for the switch.

The input array will be cleared prior to values being added.

Parameters
[out]inputWill contain all of the enumerated values for the switch.

Example:

CalibratorSwitchSet css;
StringArray enum_array;
css.GetEnumerationSwitches( enum_array );
for( uint32_t ii = 0; ii < enum_array.Size(); ii++ )
printf( "Enum value is %s\n", enum_array.GetAt(ii) );

◆ GetItemNames()

void trek::SwitchSet::GetItemNames ( StringArray input)

Retrieves an array of the (e.g., calibrator) names from the set.

Parameters
[in]inputThe array to set. Previous items will be cleared.

Example:

CalibratorSwitchSet css;
StringArray my_array;
//...
css.GetItemNames( my_array );

◆ GetRangeSwitches()

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.

Parameters
[out]inputThis value will contain an array of doubles that are the low value.
[out]array_sizeThe number of values returned.
Returns
SUCCESS
TREK_DATA_NULL_PTR

Example:

CalibratorSwitchSet css;
int32_t ret_value;
double *low_values;
uint32_t array_size;
ret_value = css.GetRangeSwitches( &low_values, array_size );
if( ret_value == SUCCESS )
{
for( uint32_t ii = 0; ii < array_size; ii++ )
printf( "Low value was %lf\n", low_values[ii] );
delete low_values;
}

◆ GetRangeSwitchInfo()

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.

Parameters
[in]lowThe low value to search for
[out]highThe corresponding low value.
[out]nameThe name of the item when switch is valid.
Returns
SUCCESS
TREK_DATA_NULL_PTR
TREK_DATA_DOES_NOT_EXIST

Example:

CalibratorSwitchSet css;
int32_t ret_value;
double high_value;
char *name;
ret_value = css.GetRangeSwitchInfo( 5, high_value, &name );
if( ret_value == SUCCESS )
{
printf( "5 < value <= %lf will use %s\n", high_value, name );
delete name;
}

◆ GetSwitchParameterName()

const char * trek::SwitchSet::GetSwitchParameterName ( )

Gets the default set name.

Returns
The switch parameter name (returns empty string if not set)

Example:

CalibratorSwitchSet css;
printf( "Switch parameter name is '%s'\n", css.GetSwitchParameterName();

◆ GetSwitchType()

switch_type trek::SwitchSet::GetSwitchType ( )

Returns the current switch type.

Returns
RANGE_SWITCH or ENUMERATION_SWITCH

Example:

CalibratorSwitchSet css;
if( css.GetSwitchType() == RANGE_SWITCH )
printf( "It's a range switch.\n" );
else
printf( "It's an enumeration switch.\n" );

◆ GetValidationErrors()

const char * trek::SwitchSet::GetValidationErrors ( )

Gets a string of the last validation errors.

Returns
A constant string of validation errors. Example:
LimitAlarmSwitchSet limit_set;
int32_t num_err;
// assuming that set has some data added already.
num_err = limit_set.Validate();
if( num_err )
{
printf( "%d validation errors found.\n", num_err );
printf( "%s\n", limit_set.GetValidationErrors() );
}
else
printf( "ok to use\n" );

◆ SetDefaultSetName()

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.

Parameters
[in]nameThe name of the set.
Returns
SUCCESS
TREK_DATA_NULL_PTR

Example:

CalibratorSwitchSet css;
ret_value = css.SetDefaultSetName( "CalSet1" );

◆ SetSwitchParameter()

int32_t trek::SwitchSet::SetSwitchParameter ( Parameter input_ptr)

Sets the parameter to use for switching.

Parameters
[in]input_ptrA valid reference to a parameter in a packet.
Returns
SUCCESS
TREK_DATA_NULL_PTR
Note
This function is only intended for use by internal TReK code.

◆ SetSwitchParameterName()

int32_t trek::SwitchSet::SetSwitchParameterName ( const char *  name)

Sets the name of the parameter to use as a switch.

Parameters
[in]nameThe name of the switch parameter.
Returns
SUCCESS
TREK_DATA_NULL_PTR

Example:

CalibratorSwitchSet css;
ret_value = css.SetSwitchParameterName( "SwitchParameter" );

◆ SetSwitchType()

void trek::SwitchSet::SetSwitchType ( switch_type  input)

Sets the type of switch to use.

Parameters
inputThe new switch type

Example:

CalibratorSwitchSet css;
css.SetSwitchType( ENUMERATION_SWITCH );

◆ Validate()

int32_t trek::SwitchSet::Validate ( )

Determines if it is safe to use the switched set.

Insures that class is properly configured. Safe to use if 0 is returned.

Returns
The number of errors found.

Example:

LimitAlarmSwitchSet limit_set;
int32_t num_err;
// assuming that set has some data added already.
num_err = limit_set.Validate();
if( num_err )
{
printf( "%d validation errors found.\n", num_err );
printf( "%s\n", limit_set.GetValidationErrors() );
}
else
printf( "ok to use\n" );

◆ ~SwitchSet()

trek::SwitchSet::~SwitchSet ( )
virtual

Class destructor.

Removes all resources created with this instance of the class.