SG_USING_STD(string);
SG_USING_STD(vector);
-#include <simgear/misc/props.hxx>
-#include <Main/fgfs.hxx>
+#include <simgear/props/props.hxx>
+#include <simgear/structure/subsystem_mgr.hxx>
+
+
+// Forward declaration
+class FGElectricalSystem;
#define FG_UNKNOWN -1
int kind;
string name;
- string prop;
- double value;
+ float volts;
+ float load_amps;
comp_list inputs;
comp_list outputs;
+ string_list props;
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 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 ) {
+ 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 ) {
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 );
}
+
};
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();
public:
- FGElectricalBus ( string _name, string _prop );
+ FGElectricalBus ( SGPropertyNode *node );
~FGElectricalBus () {}
};
// flexibility
class FGElectricalOutput : public FGElectricalComponent {
+private:
+
+ // number of amps drawn by this output
+ float output_amps;
+
public:
- FGElectricalOutput ( string _name, string _prop );
+ 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 ();
+ 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
+ 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
*
*/
-class FGElectricalSystem : public FGSubsystem
+class FGElectricalSystem : public SGSubsystem
{
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:
comp_list buses;
comp_list outputs;
comp_list connectors;
+
+ SGPropertyNode *_volts_out;
+ SGPropertyNode *_amps_out;
};