COMMS
Template library intended to help with implementation of communication protocols.
comms::option::def::ScalingRatio< TNum, TDenom > Struct Template Reference

#include "comms/options.h"

Detailed Description

template<std::intmax_t TNum, std::intmax_t TDenom>
struct comms::option::def::ScalingRatio< TNum, TDenom >

Option to specify scaling ratio.

Applicable only to comms::field::IntValue. Sometimes the protocol specifies values being transmitted in one units while when handling the message they are better to be handled in another. For example, some distance information is transmitted as integer value of millimetres, but while processing it should be handled as floating point value of meters. Such field is defined as:

using MyField =
MyFieldBase,
std::int32_t,
>;
Base class to all the field classes.
Definition: Field.h:33
Field that represent integral value.
Definition: IntValue.h:72
Option to specify scaling ratio.
Definition: options.h:410

Then, to accessed the scaled value of the field use scaleAs() or setScaled() methods of comms::field::IntValue field:

void processField(const MyField& field)
{
auto distInMillimetres = field.value();
auto distInMeters = field.scaleAs<double>();
}
Template Parameters
TNumNumerator of the scaling ratio.
TDenomDenominator of the scaling ratio.

The documentation for this struct was generated from the following file: