1 // electrical.hxx - a flexible, generic electrical system model.
3 // Written by Curtis Olson, started September 2002.
5 // Copyright (C) 2002 Curtis L. Olson - curt@flightgear.org
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 // General Public License for more details.
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 #ifndef _SYSTEMS_ELECTRICAL_HXX
25 #define _SYSTEMS_ELECTRICAL_HXX 1
28 # error This library requires C++
41 #include <simgear/misc/props.hxx>
42 #include <Main/fgfs.hxx>
49 #define FG_CONNECTOR 3
51 // Base class for other electrical components
52 class FGElectricalComponent {
54 typedef vector<FGElectricalComponent *> comp_list;
55 typedef vector<string> string_list;
59 FGElectricalComponent() {}
60 virtual ~FGElectricalComponent() {}
62 virtual string get_name() { return ""; }
65 inline int get_kind() { return kind; }
69 // Electrical supplier
70 class FGElectricalSupplier : public FGElectricalComponent {
87 FGElectricalSupplier ( string _name, string _model,
88 double _volts, double _amps );
89 ~FGElectricalSupplier () {}
91 void add_output( FGElectricalComponent *c ) {
92 outputs.push_back( c );
95 string get_name() const { return name; }
99 // Electrical bus (can take multiple inputs and provide multiple
101 class FGElectricalBus : public FGElectricalComponent {
109 FGElectricalBus ( string _name );
110 ~FGElectricalBus () {}
112 void add_input( FGElectricalComponent *c ) {
113 inputs.push_back( c );
116 void add_output( FGElectricalComponent *c ) {
117 outputs.push_back( c );
120 string get_name() const { return name; }
124 // A lot like an FGElectricalBus, but here for convenience and future
126 class FGElectricalOutput : public FGElectricalComponent {
133 FGElectricalOutput ( string _name );
134 ~FGElectricalOutput () {}
136 void add_input( FGElectricalComponent *c ) {
137 inputs.push_back( c );
140 string get_name() const { return name; }
144 // Connects multiple sources to multiple destinations with optional
145 // switches/fuses/circuit breakers inline
146 class FGElectricalConnector : public FGElectricalComponent {
150 string_list switches;
154 FGElectricalConnector ();
155 ~FGElectricalConnector () {}
157 void add_input( FGElectricalComponent *c ) {
158 inputs.push_back( c );
161 void add_output( FGElectricalComponent *c ) {
162 outputs.push_back( c );
165 void add_switch( const string &s ) {
166 switches.push_back( s );
169 string get_name() const { return ""; }
174 * Model an electrical system. This is a simple system with the
175 * alternator hardwired to engine[0]/rpm
179 * /engines/engine[0]/rpm
186 class FGElectricalSystem : public FGSubsystem
191 FGElectricalSystem ();
192 virtual ~FGElectricalSystem ();
194 virtual void init ();
195 virtual void bind ();
196 virtual void unbind ();
197 virtual void update (double dt);
200 FGElectricalComponent *find ( const string &name );
204 SGPropertyNode *config_props;
205 // SGPropertyNode_ptr _serviceable_node;
209 typedef vector<FGElectricalComponent *> comp_list;
214 comp_list connectors;
218 #endif // _SYSTEMS_ELECTRICAL_HXX