Remove unneeded function and add bool relative changes
This commit is contained in:
parent
3f133c014f
commit
ccf15ac97e
3 changed files with 19 additions and 29 deletions
|
@ -148,6 +148,9 @@ For input chunks there exist some more options:
|
||||||
(Usefull for eg. heading selector to start again with 1 for
|
(Usefull for eg. heading selector to start again with 1 for
|
||||||
values higher than 360)
|
values higher than 360)
|
||||||
|
|
||||||
|
<rel>, <min>, <max> and <wrap> are only used for numeric data types. <rel> can
|
||||||
|
additionally be used with type 'bool', where it toggles the value, if the received
|
||||||
|
value evaluates to 'true', otherwise the value is left unchanged.
|
||||||
|
|
||||||
Chunks can also consist of a single constant <format>, like in:
|
Chunks can also consist of a single constant <format>, like in:
|
||||||
<format>Data Section</format>
|
<format>Data Section</format>
|
||||||
|
|
|
@ -273,7 +273,6 @@ bool FGGeneric::gen_message() {
|
||||||
bool FGGeneric::parse_message_binary(int length) {
|
bool FGGeneric::parse_message_binary(int length) {
|
||||||
char *p2, *p1 = buf;
|
char *p2, *p1 = buf;
|
||||||
int32_t tmp32;
|
int32_t tmp32;
|
||||||
double val;
|
|
||||||
int i = -1;
|
int i = -1;
|
||||||
|
|
||||||
p2 = p1 + length;
|
p2 = p1 + length;
|
||||||
|
@ -291,7 +290,7 @@ bool FGGeneric::parse_message_binary(int length) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FG_BOOL:
|
case FG_BOOL:
|
||||||
_in_message[i].prop->setBoolValue( p1[0] != 0 );
|
updateValue(_in_message[i], p1[0] != 0);
|
||||||
p1 += 1;
|
p1 += 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -338,7 +337,6 @@ bool FGGeneric::parse_message_binary(int length) {
|
||||||
|
|
||||||
bool FGGeneric::parse_message_ascii(int length) {
|
bool FGGeneric::parse_message_ascii(int length) {
|
||||||
char *p2, *p1 = buf;
|
char *p2, *p1 = buf;
|
||||||
double val;
|
|
||||||
int i = -1;
|
int i = -1;
|
||||||
int chunks = _in_message.size();
|
int chunks = _in_message.size();
|
||||||
int line_separator_size = line_separator.size();
|
int line_separator_size = line_separator.size();
|
||||||
|
@ -365,7 +363,7 @@ bool FGGeneric::parse_message_ascii(int length) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FG_BOOL:
|
case FG_BOOL:
|
||||||
_in_message[i].prop->setBoolValue( atof(p1) != 0.0 );
|
updateValue(_in_message[i], atof(p1) != 0.0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FG_FIXED:
|
case FG_FIXED:
|
||||||
|
@ -712,23 +710,16 @@ FGGeneric::read_config(SGPropertyNode *root, vector<_serial_prot> &msg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
void FGGeneric::updateValue(FGGeneric::_serial_prot& prot, bool val)
|
||||||
set/getValue: Implementations for supported datatypes
|
{
|
||||||
*/
|
if( prot.rel )
|
||||||
#define DEF_DATA_ACCESS(type, method)\
|
{
|
||||||
template<>\
|
// value inverted if received true, otherwise leave unchanged
|
||||||
const type FGGeneric::getValue(SGPropertyNode_ptr& prop)\
|
if( val )
|
||||||
{\
|
setValue(prot.prop, !getValue<bool>(prot.prop));
|
||||||
return prop->get##method##Value();\
|
}
|
||||||
}\
|
else
|
||||||
\
|
{
|
||||||
template<>\
|
setValue(prot.prop, val);
|
||||||
void FGGeneric::setValue(SGPropertyNode_ptr& prop, const type& val)\
|
}
|
||||||
{\
|
|
||||||
prop->set##method##Value(val);\
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DEF_DATA_ACCESS(int, Int)
|
|
||||||
DEF_DATA_ACCESS(float, Float)
|
|
||||||
DEF_DATA_ACCESS(double, Double)
|
|
||||||
|
|
||||||
|
|
|
@ -130,12 +130,8 @@ private:
|
||||||
setValue(prot.prop, new_val);
|
setValue(prot.prop, new_val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Special handling for bool (relative change = toggle, no min/max, no wrap)
|
||||||
template<class T>
|
static void updateValue(_serial_prot& prot, bool val);
|
||||||
static const T getValue(SGPropertyNode_ptr& prop);
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
static void setValue(SGPropertyNode_ptr& prop, const T& val);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue