}
volts = node->getDoubleValue("volts");
amps = node->getDoubleValue("amps");
+ rpm_src = node->getStringValue("rpm-source");
int i;
for ( i = 0; i < node->nChildren(); ++i ) {
}
}
- _rpm_node = fgGetNode("/engines/engine[0]/rpm", true);
+ _rpm_node = fgGetNode( rpm_src.c_str(), true);
}
add_switch( fgGetNode( child->getStringValue(), true ) );
}
}
+
+ // do a 2nd pass to pick up starting switch value if specified
+ for ( i = 0; i < node->nChildren(); ++i ) {
+ SGPropertyNode *child = node->getChild(i);
+ string cname = child->getName();
+ string cval = child->getStringValue();
+ // cout << " " << cname << " = " << cval << endl;
+ if ( cname == "initial-state" ) {
+ if ( cval == "off" ) {
+ set_switches( false );
+ } else {
+ set_switches( true );
+ }
+ }
+ }
}
+// set all switches to the specified state
+void FGElectricalConnector::set_switches( bool state ) {
+ // cout << "setting switch state to " << state << endl;
+ for ( unsigned int i = 0; i < switches.size(); ++i ) {
+ switches[i]->setBoolValue( state );
+ }
+}
+
+
// return true if all switches are true, false otherwise. A connector
// could have multiple switches, but they all need to be true(closed)
// for current to get through.
connectors[i]->set_value( 0.0 );
}
- // for each supplier, propogate the electrical current
+ // for each supplier, propagate the electrical current
for ( i = 0; i < suppliers.size(); ++i ) {
// cout << " Updating: " << suppliers[i]->get_name() << endl;
- propogate( suppliers[i], 0.0, " " );
+ propagate( suppliers[i], 0.0, " " );
}
}
}
-// propogate the electrical current through the network
-void FGElectricalSystem::propogate( FGElectricalComponent *node, double val,
+// propagate the electrical current through the network
+void FGElectricalSystem::propagate( FGElectricalComponent *node, double val,
string s ) {
s += " ";
}
// cout << s << node->get_name() << " -> " << node->get_value() << endl;
- // propogate to all children
+ // propagate to all children
for ( i = 0; i < node->get_num_outputs(); ++i ) {
- propogate( node->get_output(i), current, s );
+ propagate( node->get_output(i), current, s );
}
}