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] =
|
||||
{
|
||||
{ "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),
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -745,23 +745,20 @@ 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 );
|
||||
}
|
||||
} 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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -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,23 +786,20 @@ 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 );
|
||||
}
|
||||
} 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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -519,23 +519,20 @@ 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 );
|
||||
}
|
||||
} 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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue