Cleaner code by a clear separation between sgFileType, sgDDSType and the default sgSocketType
This commit is contained in:
parent
ee5b49668a
commit
c0bc09bf1a
5 changed files with 27 additions and 36 deletions
|
@ -11,13 +11,13 @@
|
||||||
|
|
||||||
static const dds_key_descriptor_t FG_DDS_GUI_keys[1] =
|
static const dds_key_descriptor_t FG_DDS_GUI_keys[1] =
|
||||||
{
|
{
|
||||||
{ "version", 2 }
|
{ "id", 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
static const uint32_t FG_DDS_GUI_ops [] =
|
static const uint32_t FG_DDS_GUI_ops [] =
|
||||||
{
|
{
|
||||||
DDS_OP_ADR | DDS_OP_TYPE_2BY | DDS_OP_FLAG_SGN, offsetof (FG_DDS_GUI, id),
|
DDS_OP_ADR | DDS_OP_TYPE_2BY | DDS_OP_FLAG_SGN | DDS_OP_FLAG_KEY, offsetof (FG_DDS_GUI, id),
|
||||||
DDS_OP_ADR | DDS_OP_TYPE_2BY | DDS_OP_FLAG_SGN | DDS_OP_FLAG_KEY, offsetof (FG_DDS_GUI, version),
|
DDS_OP_ADR | DDS_OP_TYPE_2BY | DDS_OP_FLAG_SGN, offsetof (FG_DDS_GUI, version),
|
||||||
DDS_OP_ADR | DDS_OP_TYPE_8BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_GUI, longitude),
|
DDS_OP_ADR | DDS_OP_TYPE_8BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_GUI, longitude),
|
||||||
DDS_OP_ADR | DDS_OP_TYPE_8BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_GUI, latitude),
|
DDS_OP_ADR | DDS_OP_TYPE_8BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_GUI, latitude),
|
||||||
DDS_OP_ADR | DDS_OP_TYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_GUI, altitude),
|
DDS_OP_ADR | DDS_OP_TYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_GUI, altitude),
|
||||||
|
|
|
@ -49,7 +49,7 @@ struct DDS_GUI
|
||||||
float course_deviation_deg; // degrees off target course
|
float course_deviation_deg; // degrees off target course
|
||||||
float gs_deviation_deg; // degrees off target glide slope
|
float gs_deviation_deg; // degrees off target glide slope
|
||||||
};
|
};
|
||||||
#pragma keylist DDS_GUI version
|
#pragma keylist DDS_GUI id
|
||||||
|
|
||||||
}; // module FG
|
}; // module FG
|
||||||
|
|
||||||
|
|
|
@ -745,20 +745,17 @@ bool FGNativeCtrls::process() {
|
||||||
if ( io->get_type() == sgFileType ) {
|
if ( io->get_type() == sgFileType ) {
|
||||||
if ( io->read( buf, length ) == length ) {
|
if ( io->read( buf, length ) == length ) {
|
||||||
SG_LOG( SG_IO, SG_INFO, "Success reading data." );
|
SG_LOG( SG_IO, SG_INFO, "Success reading data." );
|
||||||
if ( io->get_type() == sgDDSType ) {
|
FGCtrls2Props( &ctrls.net, true, true );
|
||||||
FGCtrls2Props( &ctrls.dds, true, true );
|
}
|
||||||
} else {
|
} else if ( io->get_type() == sgDDSType ) {
|
||||||
FGCtrls2Props( &ctrls.net, true, true );
|
while ( io->read( buf, length ) == length ) {
|
||||||
}
|
SG_LOG( SG_IO, SG_INFO, "Success reading data." );
|
||||||
|
FGCtrls2Props( &ctrls.dds, true, true );
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
while ( io->read( buf, length ) == length ) {
|
while ( io->read( buf, length ) == length ) {
|
||||||
SG_LOG( SG_IO, SG_INFO, "Success reading data." );
|
SG_LOG( SG_IO, SG_INFO, "Success reading data." );
|
||||||
if ( io->get_type() == sgDDSType ) {
|
FGCtrls2Props( &ctrls.net, true, true );
|
||||||
FGCtrls2Props( &ctrls.dds, true, true );
|
|
||||||
} else {
|
|
||||||
FGCtrls2Props( &ctrls.net, true, true );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -482,7 +482,7 @@ void FGFDM2Props<FGNetFDM>( FGNetFDM *net, bool net_byte_order ) {
|
||||||
node->setDoubleValue("spoilers-pos-norm", net->spoilers);
|
node->setDoubleValue("spoilers-pos-norm", net->spoilers);
|
||||||
} else {
|
} else {
|
||||||
SG_LOG( SG_IO, SG_ALERT,
|
SG_LOG( SG_IO, SG_ALERT,
|
||||||
"Error: version mismatch in FGNetFDM2Props()" );
|
"Error: version mismatch in Net FGFDM2Props()" );
|
||||||
SG_LOG( SG_IO, SG_ALERT,
|
SG_LOG( SG_IO, SG_ALERT,
|
||||||
"\tread " << net->version << " need " << FG_NET_FDM_VERSION );
|
"\tread " << net->version << " need " << FG_NET_FDM_VERSION );
|
||||||
SG_LOG( SG_IO, SG_ALERT,
|
SG_LOG( SG_IO, SG_ALERT,
|
||||||
|
@ -717,7 +717,7 @@ void FGFDM2Props<FG_DDS_FDM>( FG_DDS_FDM *dds, bool net_byte_order ) {
|
||||||
node->setDoubleValue("spoilers-pos-norm", dds->spoilers);
|
node->setDoubleValue("spoilers-pos-norm", dds->spoilers);
|
||||||
} else {
|
} else {
|
||||||
SG_LOG( SG_IO, SG_ALERT,
|
SG_LOG( SG_IO, SG_ALERT,
|
||||||
"Error: version mismatch in FGNetFDM2Props()" );
|
"Error: version mismatch in DDS FGFDM2Props()" );
|
||||||
SG_LOG( SG_IO, SG_ALERT,
|
SG_LOG( SG_IO, SG_ALERT,
|
||||||
"\tread " << dds->version << " need " << FG_DDS_FDM_VERSION );
|
"\tread " << dds->version << " need " << FG_DDS_FDM_VERSION );
|
||||||
SG_LOG( SG_IO, SG_ALERT,
|
SG_LOG( SG_IO, SG_ALERT,
|
||||||
|
@ -786,20 +786,17 @@ bool FGNativeFDM::process() {
|
||||||
if ( io->get_type() == sgFileType ) {
|
if ( io->get_type() == sgFileType ) {
|
||||||
if ( io->read( buf, length ) == length ) {
|
if ( io->read( buf, length ) == length ) {
|
||||||
SG_LOG( SG_IO, SG_INFO, "Success reading data." );
|
SG_LOG( SG_IO, SG_INFO, "Success reading data." );
|
||||||
if ( io->get_type() == sgDDSType ) {
|
FGFDM2Props( &fdm.net );
|
||||||
FGFDM2Props( &fdm.dds );
|
}
|
||||||
} else {
|
} else if ( io->get_type() == sgDDSType ) {
|
||||||
FGFDM2Props( &fdm.net );
|
while ( io->read( buf, length ) == length ) {
|
||||||
}
|
SG_LOG( SG_IO, SG_INFO, " Success reading data." );
|
||||||
|
FGFDM2Props( &fdm.dds );
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
while ( io->read( buf, length ) == length ) {
|
while ( io->read( buf, length ) == length ) {
|
||||||
SG_LOG( SG_IO, SG_INFO, " Success reading data." );
|
SG_LOG( SG_IO, SG_INFO, " Success reading data." );
|
||||||
if ( io->get_type() == sgDDSType ) {
|
FGFDM2Props( &fdm.net );
|
||||||
FGFDM2Props( &fdm.dds );
|
|
||||||
} else {
|
|
||||||
FGFDM2Props( &fdm.net );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -519,20 +519,17 @@ bool FGNativeGUI::process() {
|
||||||
if ( io->get_type() == sgFileType ) {
|
if ( io->get_type() == sgFileType ) {
|
||||||
if ( io->read( buf, length ) == length ) {
|
if ( io->read( buf, length ) == length ) {
|
||||||
SG_LOG( SG_IO, SG_DEBUG, "Success reading data." );
|
SG_LOG( SG_IO, SG_DEBUG, "Success reading data." );
|
||||||
if ( io->get_type() == sgDDSType ) {
|
FGGUI2Props( &gui.net );
|
||||||
FGGUI2Props( &gui.dds );
|
}
|
||||||
} else {
|
} if ( io->get_type() == sgDDSType ) {
|
||||||
FGGUI2Props( &gui.net );
|
while ( io->read( buf, length ) == length ) {
|
||||||
}
|
SG_LOG( SG_IO, SG_DEBUG, "Success reading data." );
|
||||||
|
FGGUI2Props( &gui.dds );
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
while ( io->read( buf, length ) == length ) {
|
while ( io->read( buf, length ) == length ) {
|
||||||
SG_LOG( SG_IO, SG_DEBUG, "Success reading data." );
|
SG_LOG( SG_IO, SG_DEBUG, "Success reading data." );
|
||||||
if ( io->get_type() == sgDDSType ) {
|
FGGUI2Props( &gui.net );
|
||||||
FGGUI2Props( &gui.dds );
|
|
||||||
} else {
|
|
||||||
FGGUI2Props( &gui.net );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue