SG_USING_STD(vector);
#include <simgear/props/props.hxx>
-
-#include <Main/fgfs.hxx>
+#include <simgear/structure/subsystem_mgr.hxx>
// Forward declaration
int kind;
string name;
- double value;
+ float volts;
+ float load_amps;
comp_list inputs;
comp_list outputs;
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 ) {
// 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 ); }
};
comp_list inputs;
comp_list outputs;
- typedef vector<SGPropertyNode *> switch_list;
+ typedef vector< FGElectricalSwitch> switch_list;
switch_list switches;
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
*
*/
-class FGElectricalSystem : public FGSubsystem
+class FGElectricalSystem : public SGSubsystem
{
public:
virtual void update (double dt);
bool build ();
- void propagate( FGElectricalComponent *node, double val, string s = "" );
+ float propagate( FGElectricalComponent *node, double val, string s = "" );
FGElectricalComponent *find ( const string &name );
protected:
comp_list buses;
comp_list outputs;
comp_list connectors;
+
+ SGPropertyNode *_volts_out;
+ SGPropertyNode *_amps_out;
};