globals->add_subsystem( "xml-autopilot", new FGXMLAutopilot );
globals->add_subsystem( "route-manager", new FGRouteMgr );
-
////////////////////////////////////////////////////////////////////
// Initialize the view manager subsystem.
////////////////////////////////////////////////////////////////////
fgInitView();
+ ////////////////////////////////////////////////////////////////////
+ // Initialize the Input-Output subsystem
+ ////////////////////////////////////////////////////////////////////
+ globals->add_subsystem( "io", new FGIO );
+
////////////////////////////////////////////////////////////////////
// Create and register the logger.
////////////////////////////////////////////////////////////////////
}
- ////////////////////////////////////////////////////////////////////
- // Initialize I/O subsystem.
- ////////////////////////////////////////////////////////////////////
-
- globals->get_io()->init();
- globals->get_io()->bind();
-
-
////////////////////////////////////////////////////////////////////
// Add a new 2D panel.
////////////////////////////////////////////////////////////////////
}
}
+void
+FGIO::reinit()
+{
+}
+
// process any IO channel work
void
~FGIO();
void init();
+ void reinit();
void bind();
void unbind();
void update( double dt );
initial_waypoints( NULL ),
scenery( NULL ),
tile_mgr( NULL ),
- io( new FGIO ),
fontcache ( new FGFontCache ),
navlist( NULL ),
loclist( NULL ),
delete initial_waypoints;
delete tile_mgr;
delete scenery;
- delete io;
delete fontcache;
delete navlist;
class FGAircraftModel;
class FGControls;
class FGFlightPlanDispatcher;
-class FGIO;
class FGNavList;
class FGAirwayNetwork;
class FGTACANList;
// Tile manager
FGTileMgr *tile_mgr;
- // Input/Ouput subsystem
- FGIO *io;
-
FGFontCache *fontcache;
// Navigational Aids
inline FGTileMgr * get_tile_mgr () const { return tile_mgr; }
inline void set_tile_mgr ( FGTileMgr *t ) { tile_mgr = t; }
- inline FGIO* get_io() const { return io; }
inline FGFontCache *get_fontcache() const { return fontcache; }
inline FGNavList *get_navlist() const { return navlist; }
// update the view angle as late as possible, but before sound calculations
globals->get_viewmgr()->update(real_delta_time_sec);
- // Do any I/O channel work that might need to be done (must come after viewmgr)
- globals->get_io()->update(real_delta_time_sec);
-
#ifdef ENABLE_AUDIO_SUPPORT
// Right now we make a simplifying assumption that the primary
// aircraft is the source of all sounds and that all sounds are
}
string config = tokens[ configToken ];
- string file = config+".xml";
+ file_name = config+".xml";
- SGPath path( globals->get_fg_root() );
- path.append("Protocol");
- path.append(file.c_str());
- SG_LOG(SG_GENERAL, SG_INFO, "Reading communication protocol from "
- << path.str());
-
- SGPropertyNode root;
- try {
- readProperties(path.str(), &root);
- } catch (const sg_exception &) {
- SG_LOG(SG_GENERAL, SG_ALERT,
- "Unable to load the protocol configuration file");
- return;
- }
-
- if (tokens[2] == "out") {
- SGPropertyNode *output = root.getNode("generic/output");
- if (output) {
- read_config(output, _out_message);
- }
- } else if (tokens[2] == "in") {
- SGPropertyNode *input = root.getNode("generic/input");
- if (input) {
- read_config(input, _in_message);
- }
- } else {
+ if (tokens[2] != "in" && tokens[2] != "out") {
SG_LOG(SG_GENERAL, SG_ALERT, "Unsuported protocol direction: "
<< tokens[2]);
}
+
+ reinit();
}
FGGeneric::~FGGeneric() {
}
+void
+FGGeneric::reinit()
+{
+ SGPath path( globals->get_fg_root() );
+ path.append("Protocol");
+ path.append(file_name.c_str());
+
+ SG_LOG(SG_GENERAL, SG_INFO, "Reading communication protocol from "
+ << path.str());
+
+ SGPropertyNode root;
+ try {
+ readProperties(path.str(), &root);
+ } catch (const sg_exception &) {
+ SG_LOG(SG_GENERAL, SG_ALERT,
+ "Unable to load the protocol configuration file");
+ return;
+ }
+
+ SGPropertyNode *output = root.getNode("generic/output");
+ if (output) {
+ read_config(output, _out_message);
+ }
+
+ SGPropertyNode *input = root.getNode("generic/input");
+ if (input) {
+ read_config(input, _in_message);
+ }
+}
+
+
void
FGGeneric::read_config(SGPropertyNode *root, vector<_serial_prot> &msg)
{
// open hailing frequencies
bool open();
+ void reinit();
+
// process work for this port
bool process();
private:
+ string file_name;
+
int length;
char buf[ FG_MAX_MSG_SIZE ];