]> git.mxchange.org Git - flightgear.git/blobdiff - src/Systems/electrical.hxx
Moved some of the low level scene graph construction code over to simgear.
[flightgear.git] / src / Systems / electrical.hxx
index 1e94f2fb754fdea0ac40f07a3abdb2a7c4d9c5f9..1668c917187d38da0f6ae0d4cf660ca71d73a504 100644 (file)
 SG_USING_STD(string);
 SG_USING_STD(vector);
 
-#include <simgear/misc/props.hxx>
+#include <simgear/props/props.hxx>
+
 #include <Main/fgfs.hxx>
 
 
+// Forward declaration
+class FGElectricalSystem;
+
+
 #define FG_UNKNOWN  -1
 #define FG_SUPPLIER  0
 #define FG_BUS       1
@@ -58,11 +63,11 @@ protected:
 
     int kind;
     string name;
-    string prop;
     double value;
 
     comp_list inputs;
     comp_list outputs;
+    string_list props;
 
 public:
 
@@ -70,12 +75,19 @@ public:
     virtual ~FGElectricalComponent() {}
 
     inline string get_name() { return name; }
-    inline string get_prop() { return prop; }
 
     inline int get_kind() const { return kind; }
     inline double get_value() const { return value; }
     inline void set_value( double val ) { value = val; }
 
+    inline int get_num_inputs() const { return outputs.size(); }
+    inline FGElectricalComponent *get_input( const int i ) {
+        return inputs[i];
+    }
+    inline void add_input( FGElectricalComponent *c ) {
+        inputs.push_back( c );
+    }
+
     inline int get_num_outputs() const { return outputs.size(); }
     inline FGElectricalComponent *get_output( const int i ) {
         return outputs[i];
@@ -84,13 +96,14 @@ public:
         outputs.push_back( c );
     }
 
-    inline int get_num_inputs() const { return outputs.size(); }
-    inline FGElectricalComponent *get_input( const int i ) {
-        return inputs[i];
+    inline int get_num_props() const { return props.size(); }
+    inline string get_prop( const int i ) {
+        return props[i];
     }
-    inline void add_input( FGElectricalComponent *c ) {
-        inputs.push_back( c );
+    inline void add_prop( const string &s ) {
+        props.push_back( s );
     }
+
 };
 
 
@@ -105,14 +118,14 @@ class FGElectricalSupplier : public FGElectricalComponent {
         FG_EXTERNAL = 2
     };
 
+    string rpm_src;
     int model;
     double volts;
     double amps;
 
 public:
 
-    FGElectricalSupplier ( string _name, string _prop, string _model,
-                           double _volts, double _amps );
+    FGElectricalSupplier ( SGPropertyNode *node );
     ~FGElectricalSupplier () {}
 
     double get_output();
@@ -125,7 +138,7 @@ class FGElectricalBus : public FGElectricalComponent {
 
 public:
 
-    FGElectricalBus ( string _name, string _prop );
+    FGElectricalBus ( SGPropertyNode *node );
     ~FGElectricalBus () {}
 };
 
@@ -136,7 +149,7 @@ class FGElectricalOutput : public FGElectricalComponent {
 
 public:
 
-    FGElectricalOutput ( string _name, string _prop );
+    FGElectricalOutput ( SGPropertyNode *node );
     ~FGElectricalOutput () {}
 };
 
@@ -152,27 +165,22 @@ class FGElectricalConnector : public FGElectricalComponent {
 
 public:
 
-    FGElectricalConnector ();
+    FGElectricalConnector ( SGPropertyNode *node, FGElectricalSystem *es );
     ~FGElectricalConnector () {}
 
     void add_switch( SGPropertyNode *node ) {
         switches.push_back( node );
     }
 
+    // set all switches to the specified state
+    void set_switches( bool state );
+
     bool get_state();
 };
 
 
 /**
- * Model an electrical system.  This is a simple system with the
- * alternator hardwired to engine[0]/rpm
- *
- * Input properties:
- *
- * /engines/engine[0]/rpm
- *
- * Output properties:
- *
+ * Model an electrical system.  This is a fairly simplistic system
  * 
  */
 
@@ -190,7 +198,7 @@ public:
     virtual void update (double dt);
 
     bool build ();
-    void propogate( FGElectricalComponent *node, double val, string s = "" );
+    void propagate( FGElectricalComponent *node, double val, string s = "" );
     FGElectricalComponent *find ( const string &name );
 
 protected: