X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FSystems%2Felectrical.hxx;h=1a04342227caebe4485ccbc14c215707b5e88ae4;hb=a739fad66484506ebb71fc802bf8f1a0c2ab4c6c;hp=30c3cc33ce753436900491d3757793f73b591ee4;hpb=9e35d336572e876e3a9ef6f9378f2038d98e4d07;p=flightgear.git diff --git a/src/Systems/electrical.hxx b/src/Systems/electrical.hxx index 30c3cc33c..1a0434222 100644 --- a/src/Systems/electrical.hxx +++ b/src/Systems/electrical.hxx @@ -38,8 +38,8 @@ SG_USING_STD(string); SG_USING_STD(vector); -#include -#include
+#include +#include // Forward declaration @@ -62,7 +62,8 @@ protected: int kind; string name; - double value; + float volts; + float load_amps; comp_list inputs; comp_list outputs; @@ -76,8 +77,12 @@ public: inline string get_name() { return name; } inline int get_kind() const { return kind; } - inline double get_value() const { return value; } - inline void set_value( double val ) { value = val; } + + inline float get_volts() const { return volts; } + inline void set_volts( float val ) { volts = val; } + + inline float get_load_amps() const { return load_amps; } + inline void set_load_amps( float val ) { load_amps = val; } inline int get_num_inputs() const { return outputs.size(); } inline FGElectricalComponent *get_input( const int i ) { @@ -117,6 +122,7 @@ class FGElectricalSupplier : public FGElectricalComponent { FG_EXTERNAL = 2 }; + string rpm_src; int model; double volts; double amps; @@ -145,10 +151,39 @@ public: // flexibility class FGElectricalOutput : public FGElectricalComponent { +private: + + // number of amps drawn by this output + float output_amps; + public: FGElectricalOutput ( SGPropertyNode *node ); ~FGElectricalOutput () {} + + inline float get_output_amps() const { return output_amps; } + inline void set_output_amps( float val ) { output_amps = val; } +}; + + +// Model an electrical switch. If the rating_amps > 0 then this +// becomes a circuit breaker type switch that can trip +class FGElectricalSwitch { + +private: + + SGPropertyNode *switch_node; + float rating_amps; + bool circuit_breaker; + +public: + + FGElectricalSwitch( SGPropertyNode *node ); + + ~FGElectricalSwitch() { }; + + inline bool get_state() const { return switch_node->getBoolValue(); } + void set_state( bool val ) { switch_node->setBoolValue( val ); } }; @@ -158,7 +193,7 @@ class FGElectricalConnector : public FGElectricalComponent { comp_list inputs; comp_list outputs; - typedef vector switch_list; + typedef vector< FGElectricalSwitch> switch_list; switch_list switches; public: @@ -166,8 +201,8 @@ public: FGElectricalConnector ( SGPropertyNode *node, FGElectricalSystem *es ); ~FGElectricalConnector () {} - void add_switch( SGPropertyNode *node ) { - switches.push_back( node ); + void add_switch( FGElectricalSwitch s ) { + switches.push_back( s ); } // set all switches to the specified state @@ -178,19 +213,11 @@ public: /** - * 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 * */ -class FGElectricalSystem : public FGSubsystem +class FGElectricalSystem : public SGSubsystem { public: @@ -204,7 +231,7 @@ public: virtual void update (double dt); bool build (); - void propogate( FGElectricalComponent *node, double val, string s = "" ); + float propagate( FGElectricalComponent *node, double val, string s = "" ); FGElectricalComponent *find ( const string &name ); protected: @@ -221,6 +248,9 @@ private: comp_list buses; comp_list outputs; comp_list connectors; + + SGPropertyNode *_volts_out; + SGPropertyNode *_amps_out; };