1
0
Fork 0

Cleaner code by a clear separation between sgFileType, sgDDSType and the default sgSocketType

This commit is contained in:
Erik Hofman 2021-03-08 13:47:53 +01:00
parent ee5b49668a
commit c0bc09bf1a
5 changed files with 27 additions and 36 deletions

View file

@ -11,13 +11,13 @@
static const dds_key_descriptor_t FG_DDS_GUI_keys[1] =
{
{ "version", 2 }
{ "id", 0 }
};
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, version),
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, 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, latitude),
DDS_OP_ADR | DDS_OP_TYPE_4BY | DDS_OP_FLAG_FP, offsetof (FG_DDS_GUI, altitude),

View file

@ -49,7 +49,7 @@ struct DDS_GUI
float course_deviation_deg; // degrees off target course
float gs_deviation_deg; // degrees off target glide slope
};
#pragma keylist DDS_GUI version
#pragma keylist DDS_GUI id
}; // module FG

View file

@ -745,20 +745,17 @@ bool FGNativeCtrls::process() {
if ( io->get_type() == sgFileType ) {
if ( io->read( buf, length ) == length ) {
SG_LOG( SG_IO, SG_INFO, "Success reading data." );
if ( io->get_type() == sgDDSType ) {
FGCtrls2Props( &ctrls.dds, true, true );
} else {
FGCtrls2Props( &ctrls.net, true, true );
}
FGCtrls2Props( &ctrls.net, true, true );
}
} else if ( io->get_type() == sgDDSType ) {
while ( io->read( buf, length ) == length ) {
SG_LOG( SG_IO, SG_INFO, "Success reading data." );
FGCtrls2Props( &ctrls.dds, true, true );
}
} else {
while ( io->read( buf, length ) == length ) {
SG_LOG( SG_IO, SG_INFO, "Success reading data." );
if ( io->get_type() == sgDDSType ) {
FGCtrls2Props( &ctrls.dds, true, true );
} else {
FGCtrls2Props( &ctrls.net, true, true );
}
FGCtrls2Props( &ctrls.net, true, true );
}
}
}

View file

@ -482,7 +482,7 @@ void FGFDM2Props<FGNetFDM>( FGNetFDM *net, bool net_byte_order ) {
node->setDoubleValue("spoilers-pos-norm", net->spoilers);
} else {
SG_LOG( SG_IO, SG_ALERT,
"Error: version mismatch in FGNetFDM2Props()" );
"Error: version mismatch in Net FGFDM2Props()" );
SG_LOG( SG_IO, SG_ALERT,
"\tread " << net->version << " need " << FG_NET_FDM_VERSION );
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);
} else {
SG_LOG( SG_IO, SG_ALERT,
"Error: version mismatch in FGNetFDM2Props()" );
"Error: version mismatch in DDS FGFDM2Props()" );
SG_LOG( SG_IO, SG_ALERT,
"\tread " << dds->version << " need " << FG_DDS_FDM_VERSION );
SG_LOG( SG_IO, SG_ALERT,
@ -786,20 +786,17 @@ bool FGNativeFDM::process() {
if ( io->get_type() == sgFileType ) {
if ( io->read( buf, length ) == length ) {
SG_LOG( SG_IO, SG_INFO, "Success reading data." );
if ( io->get_type() == sgDDSType ) {
FGFDM2Props( &fdm.dds );
} else {
FGFDM2Props( &fdm.net );
}
FGFDM2Props( &fdm.net );
}
} else if ( io->get_type() == sgDDSType ) {
while ( io->read( buf, length ) == length ) {
SG_LOG( SG_IO, SG_INFO, " Success reading data." );
FGFDM2Props( &fdm.dds );
}
} else {
while ( io->read( buf, length ) == length ) {
SG_LOG( SG_IO, SG_INFO, " Success reading data." );
if ( io->get_type() == sgDDSType ) {
FGFDM2Props( &fdm.dds );
} else {
FGFDM2Props( &fdm.net );
}
FGFDM2Props( &fdm.net );
}
}
}

View file

@ -519,20 +519,17 @@ bool FGNativeGUI::process() {
if ( io->get_type() == sgFileType ) {
if ( io->read( buf, length ) == length ) {
SG_LOG( SG_IO, SG_DEBUG, "Success reading data." );
if ( io->get_type() == sgDDSType ) {
FGGUI2Props( &gui.dds );
} else {
FGGUI2Props( &gui.net );
}
FGGUI2Props( &gui.net );
}
} if ( io->get_type() == sgDDSType ) {
while ( io->read( buf, length ) == length ) {
SG_LOG( SG_IO, SG_DEBUG, "Success reading data." );
FGGUI2Props( &gui.dds );
}
} else {
while ( io->read( buf, length ) == length ) {
SG_LOG( SG_IO, SG_DEBUG, "Success reading data." );
if ( io->get_type() == sgDDSType ) {
FGGUI2Props( &gui.dds );
} else {
FGGUI2Props( &gui.net );
}
FGGUI2Props( &gui.net );
}
}
}