]> git.mxchange.org Git - flightgear.git/commitdiff
Make FGIO a proper subsystem and add a reinit method for the generic protocol. This...
authorehofman <ehofman>
Mon, 7 Sep 2009 07:27:38 +0000 (07:27 +0000)
committerTim Moore <timoore@redhat.com>
Wed, 9 Sep 2009 06:56:31 +0000 (08:56 +0200)
src/Main/fg_init.cxx
src/Main/fg_io.cxx
src/Main/fg_io.hxx
src/Main/globals.cxx
src/Main/globals.hxx
src/Main/main.cxx
src/Network/generic.cxx
src/Network/generic.hxx

index 7079f3d206fc8e95bd721d75ecf7afbffec93353..953e4a254a24c29c8cc0385b7cb49f81d22c6588 100644 (file)
@@ -1531,13 +1531,17 @@ bool fgInitSubsystems() {
     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.
     ////////////////////////////////////////////////////////////////////
@@ -1633,14 +1637,6 @@ bool fgInitSubsystems() {
     }
 
 
-    ////////////////////////////////////////////////////////////////////
-    // Initialize I/O subsystem.
-    ////////////////////////////////////////////////////////////////////
-
-    globals->get_io()->init();
-    globals->get_io()->bind();
-
-
     ////////////////////////////////////////////////////////////////////
     // Add a new 2D panel.
     ////////////////////////////////////////////////////////////////////
index 3ab62f82df4677929c166e9977ceb0a3ea64e0b0..36ca64433d3f6dc923acdfcdaa59374ea88856d7 100644 (file)
@@ -334,6 +334,11 @@ FGIO::init()
     }
 }
 
+void
+FGIO::reinit()
+{
+}
+
 
 // process any IO channel work
 void
index ca6f0f78bcae60be8ec0ff9b735aee116fc1f7c4..c4eff1b8b95850ffdd0ce10f73461dca7ca4ea47 100644 (file)
@@ -40,6 +40,7 @@ public:
     ~FGIO();
 
     void init();
+    void reinit();
     void bind();
     void unbind();
     void update( double dt );
index 2d00791a2a7ba7f9f469148808ed35f5b7a12782..262423c2aec68a5fec223e1e11c9e3731882c55f 100644 (file)
@@ -95,7 +95,6 @@ FGGlobals::FGGlobals() :
     initial_waypoints( NULL ),
     scenery( NULL ),
     tile_mgr( NULL ),
-    io( new FGIO ),
     fontcache ( new FGFontCache ),
     navlist( NULL ),
     loclist( NULL ),
@@ -150,7 +149,6 @@ FGGlobals::~FGGlobals()
     delete initial_waypoints;
     delete tile_mgr;
     delete scenery;
-    delete io;
     delete fontcache;
 
     delete navlist;
index d962bae2c2937bbc6e2f12de46e177e6ac6d0f53..a1c58797e8f1347b79e669ee15864bd2fdfe97f1 100644 (file)
@@ -59,7 +59,6 @@ class FGATCMgr;
 class FGAircraftModel;
 class FGControls;
 class FGFlightPlanDispatcher;
-class FGIO;
 class FGNavList;
 class FGAirwayNetwork;
 class FGTACANList;
@@ -169,9 +168,6 @@ private:
     // Tile manager
     FGTileMgr *tile_mgr;
 
-    // Input/Ouput subsystem
-    FGIO *io;
-
     FGFontCache *fontcache;
 
     // Navigational Aids
@@ -308,7 +304,6 @@ public:
     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; }
index 89756f3939d06797fc62f8984de16209c3ed2c0c..70e126983731c416f2a44bffe7980982e9f41a95 100644 (file)
@@ -484,9 +484,6 @@ static void fgMainLoop( void ) {
     // 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
index ad362e258005c0c730ba52e905e8f519b06e0fb9..0e01985e392bc5844bde15c1b31db2dc63346f02 100644 (file)
@@ -61,37 +61,14 @@ FGGeneric::FGGeneric(vector<string> tokens) : exitOnError(false)
     }
 
     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() {
@@ -537,6 +514,37 @@ bool FGGeneric::close() {
 }
 
 
+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)
 {
index 4d4ec7e43d80786dbfc5b9e8603604df22940535..efb223867b781b2db3e288ab8782884aee82a69c 100644 (file)
@@ -47,6 +47,8 @@ public:
     // open hailing frequencies
     bool open();
 
+    void reinit();
+
     // process work for this port
     bool process();
 
@@ -70,6 +72,8 @@ protected:
 
 private:
 
+    string file_name;
+
     int length;
     char buf[ FG_MAX_MSG_SIZE ];