* @brief constructor for a MonoFlopImplementation
* @param rIsDominant boolean flag to signal if RESET shall be dominant (true) or SET shall be dominant (false)
*/
- MonoFlopImplementation( bool rIsDominant = true ) : JKFlipFlopImplementation( rIsDominant ) {}
+ MonoFlopImplementation( bool rIsDominant = true ) : JKFlipFlopImplementation( rIsDominant ), _t(0.0) {}
/**
* @brief evaluates the output state from the input lines and returns to the stable state
* after expiry of the internal timer
if(_debug) {
cout << "updating flip-flop \"" << get_name() << "\"" << endl;
cout << "prev. Output:" << q0 << endl;
- for( InputMap::const_iterator it = _input.begin(); it != _input.end(); it++ )
+ for( InputMap::const_iterator it = _input.begin(); it != _input.end(); ++it )
cout << "Input \"" << (*it).first << "\":" << (*it).second->test() << endl;
cout << "new Output:" << q << endl;
}
if( _inverted ) value = !value;
// set all outputs to the given value
- for( OutputMap::iterator it = _output.begin(); it != _output.end(); it++ )
+ for( OutputMap::iterator it = _output.begin(); it != _output.end(); ++it )
(*it).second->setValue( value );
}
void PIDController::update( bool firstTime, double dt )
{
double edf_n = 0.0;
- double delta_u_n = 0.0; // incremental output
double u_n = 0.0; // absolute output
double u_min = _minInput.get_value();
// Calculates the incremental output:
double ti = Ti.get_value();
+ double delta_u_n = 0.0; // incremental output
if ( ti > 0.0 ) {
delta_u_n = Kp.get_value() * ( (ep_n - ep_n_1)
+ ((Ts/ti) * e_n)
FGRouteMgr::FGRouteMgr() :
_currentIndex(0),
input(fgGetNode( RM "input", true )),
- mirror(fgGetNode( RM "route", true ))
+ mirror(fgGetNode( RM "route", true )),
+ _departureWatcher(NULL),
+ _arrivalWatcher(NULL)
{
listener = new InputListener(this);
input->setStringValue("");
{
input->removeChangeListener(listener);
delete listener;
+ delete _departureWatcher;
+ delete _arrivalWatcher;
}
&FGRouteMgr::getDepartureName, NULL));
departure->setStringValue("runway", "");
+ delete _departureWatcher;
_departureWatcher = createWatcher(this, &FGRouteMgr::departureChanged);
_departureWatcher->watch(departure->getChild("runway"));
destination->tie("name", SGRawValueMethods<FGRouteMgr, const char*>(*this,
&FGRouteMgr::getDestinationName, NULL));
+ delete _arrivalWatcher;
_arrivalWatcher = createWatcher(this, &FGRouteMgr::arrivalChanged);
_arrivalWatcher->watch(destination->getChild("runway", 0, true));
wind_from_down_fps = env.wind_from_down_fps;
turbulence_magnitude_norm = env.turbulence_magnitude_norm;
turbulence_rate_hz = env.turbulence_rate_hz;
+ pressure_inhg = env.pressure_inhg;
+ density_slugft3 = env.density_slugft3;
+ density_tropo_avg_kgm3 = env.density_tropo_avg_kgm3;
+ relative_humidity = env.relative_humidity;
+ altitude_half_to_sun_m = env.altitude_half_to_sun_m;
+ altitude_tropo_top_m = env.altitude_tropo_top_m;
+ live_update = env.live_update;
}
static inline bool
_min_visibility.set(12000.0);
vector<SGMetarCloud> cv = _clouds;;
- if (!cv.size()) {
+ if (cv.empty()) {
SGMetarCloud cl;
cl.set(5500 * SG_FEET_TO_METER, SGMetarCloud::COVERAGE_SCATTERED);
_clouds.push_back(cl);
_magneticVariation(new MagneticVariation())
{
// Hack to avoid static initialization order problems on OSX
- if( coverage_string.size() == 0 ) {
+ if( coverage_string.empty() ) {
coverage_string.push_back(SGCloudLayer::SG_CLOUD_CLEAR_STRING);
coverage_string.push_back(SGCloudLayer::SG_CLOUD_FEW_STRING);
coverage_string.push_back(SGCloudLayer::SG_CLOUD_SCATTERED_STRING);
_decoded.clear();
const vector<string> weather = m->getWeather();
- for( vector<string>::const_iterator it = weather.begin(); it != weather.end(); it++ ) {
+ for( vector<string>::const_iterator it = weather.begin(); it != weather.end(); ++it ) {
if( false == _decoded.empty() ) _decoded.append(", ");
_decoded.append(*it);
}
{
int i;
int max;
- double elev;
float result;
SGPropertyNode *boundaryNode, *boundaryEntry;
// For each boundary layers
while ( ( boundaryEntry = boundaryNode->getNode( "entry", i ) ) != NULL ) {
- elev = boundaryEntry->getDoubleValue( "elevation-ft" );
+ double elev = boundaryEntry->getDoubleValue( "elevation-ft" );
if (elev > result)
result = elev;
}
}
- bool fromMetarProxy() const
- { return _fromProxy; }
+// bool fromMetarProxy() const
+// { return _fromProxy; }
private:
string _metar;
bool _fromProxy;
};
//constructor
-FGRidgeLift::FGRidgeLift ()
+FGRidgeLift::FGRidgeLift () :
+ lift_factor(0.0)
{
strength = 0.0;
timer = 0.0;
}
-void FGButton::init( const SGPropertyNode * node, const std::string name, std::string & module )
+void FGButton::init( const SGPropertyNode * node, const std::string & name, std::string & module )
{
if (node == 0) {
SG_LOG(SG_INPUT, SG_DEBUG, "No bindings for button " << name);
public:
FGButton();
virtual ~FGButton();
- void init( const SGPropertyNode * node, const std::string name, std::string & module );
+ void init( const SGPropertyNode * node, const std::string & name, std::string & module );
void update( int modifiers, bool pressed, int x = -1, int y = -1);
bool is_repeatable;
float interval_sec;
read_bindings( node, bindings, KEYMOD_NONE, device->GetNasalModule() );
PropertyList settingNodes = node->getChildren("setting");
- for( PropertyList::iterator it = settingNodes.begin(); it != settingNodes.end(); it++ )
+ for( PropertyList::iterator it = settingNodes.begin(); it != settingNodes.end(); ++it )
settings.push_back( new FGEventSetting( *it ) );
}
void FGInputEvent::update( double dt )
{
- for( setting_list_t::iterator it = settings.begin(); it != settings.end(); it++ ) {
+ for( setting_list_t::iterator it = settings.begin(); it != settings.end(); ++it ) {
if( (*it)->Test() ) {
double value = (*it)->GetValue();
if( value != lastSettingValue ) {
lastDt += eventData.dt;
if( lastDt >= intervalSec ) {
- for( binding_list_t::iterator it = bindings[eventData.modifiers].begin(); it != bindings[eventData.modifiers].end(); it++ )
+ for( binding_list_t::iterator it = bindings[eventData.modifiers].begin(); it != bindings[eventData.modifiers].end(); ++it )
fire( *it, eventData );
lastDt -= intervalSec;
nasalModule = string("__event:") + GetName();
PropertyList eventNodes = deviceNode->getChildren( "event" );
- for( PropertyList::iterator it = eventNodes.begin(); it != eventNodes.end(); it++ )
+ for( PropertyList::iterator it = eventNodes.begin(); it != eventNodes.end(); ++it )
AddHandledEvent( FGInputEvent::NewObject( this, *it ) );
debugEvents = deviceNode->getBoolValue("debug-events", debugEvents );
FGEventInput::~FGEventInput()
{
- for( map<int,FGInputDevice*>::iterator it = input_devices.begin(); it != input_devices.end(); it++ )
+ for( map<int,FGInputDevice*>::iterator it = input_devices.begin(); it != input_devices.end(); ++it )
delete (*it).second;
input_devices.clear();
}
void FGEventInput::update( double dt )
{
// call each associated device's update() method
- for( map<int,FGInputDevice*>::iterator it = input_devices.begin(); it != input_devices.end(); it++ )
+ for( map<int,FGInputDevice*>::iterator it = input_devices.begin(); it != input_devices.end(); ++it )
(*it).second->update( dt );
}
class FGInputDevice : public SGReferenced {
public:
FGInputDevice() : debugEvents(false), grab(false) {}
- FGInputDevice( std::string aName ) : name(aName) {}
+ FGInputDevice( std::string aName ) : name(aName), debugEvents(false), grab(false) {}
virtual ~FGInputDevice();
#include "FGDeviceConfigurationMap.hxx"
#include <Main/fg_props.hxx>
#include <Scripting/NasalSys.hxx>
+#include <boost/foreach.hpp>
using simgear::PropertyList;
// Initialize the buttons.
//
PropertyList buttons = js_node->getChildren("button");
- char buf[32];
- for (j = 0; j < buttons.size() && j < nbuttons; j++) {
- const SGPropertyNode * button_node = buttons[j];
- const SGPropertyNode * num_node = button_node->getChild("number");
+ BOOST_FOREACH( SGPropertyNode * button_node, buttons ) {
size_t n_but = button_node->getIndex();
- if (num_node != 0) {
+
+ const SGPropertyNode * num_node = button_node->getChild("number");
+ if (NULL != num_node)
n_but = num_node->getIntValue(TGT_PLATFORM,n_but);
- }
if (n_but >= nbuttons) {
SG_LOG(SG_INPUT, SG_DEBUG, "Dropping bindings for button " << n_but);
continue;
}
- sprintf(buf, "%u", (unsigned)n_but);
- SG_LOG(SG_INPUT, SG_DEBUG, "Initializing button " << n_but);
- bindings[i].buttons[n_but].init(button_node, buf, module );
+ std::ostringstream buf;
+ buf << (unsigned)n_but;
- // get interval-sec property
+ SG_LOG(SG_INPUT, SG_DEBUG, "Initializing button " << buf.str());
FGButton &b = bindings[i].buttons[n_but];
- if (button_node != 0) {
- b.interval_sec = button_node->getDoubleValue("interval-sec",0.0);
- b.last_dt = 0.0;
- }
+ b.init(button_node, buf.str(), module );
+ // get interval-sec property
+ b.interval_sec = button_node->getDoubleValue("interval-sec",0.0);
+ b.last_dt = 0.0;
}
js->setMinRange(minRange);
FGKeyboardInput * FGKeyboardInput::keyboardInput = NULL;
FGKeyboardInput::FGKeyboardInput() :
- _key_event(fgGetNode("/devices/status/keyboard/event", true))
+ _key_event(fgGetNode("/devices/status/keyboard/event", true)),
+ _key_code(0),
+ _key_modifiers(0),
+ _key_pressed(0),
+ _key_shift(0),
+ _key_ctrl(0),
+ _key_alt(0),
+ _key_meta(0),
+ _key_super(0),
+ _key_hyper(0)
{
if( keyboardInput == NULL )
keyboardInput = this;
return (unsigned long)type << 16 | (unsigned long)code;
}
- bool operator < ( const TypeCode other) const {
+ bool operator < ( const TypeCode & other) const {
return hashCode() < other.hashCode();
}
};
return EVENT_NAME_BY_TYPE[typeCode];
}
-void FGLinuxInputDevice::SetDevname( std::string name )
+void FGLinuxInputDevice::SetDevname( const std::string & name )
{
this->devname = name;
}
virtual void Send( const char * eventName, double value );
virtual const char * TranslateEventName( FGEventData & eventData );
- void SetDevname( const std::string name );
+ void SetDevname( const std::string & name );
std::string GetDevname() const { return devname; }
int GetFd() { return fd; }
SGPropertyNode *templatetree = new SGPropertyNode();
try {
readProperties(templatefile.str().c_str(), templatetree);
- } catch (sg_io_exception e) {
+ } catch (sg_io_exception & e) {
cout << e.getFormattedMessage ();
}
PropertyList axes = templatetree->getChildren("axis");
- for(PropertyList::iterator iter = axes.begin(); iter != axes.end(); iter++) {
+ for(PropertyList::iterator iter = axes.begin(); iter != axes.end(); ++iter) {
cout << "Move the control you wish to use for " << (*iter)->getStringValue("desc")
<< " " << (*iter)->getStringValue("direction") << endl;
cout << "Pressing a button skips this axis" << endl;
->getDeadBand(jsi->getInputAxis()));
axis->setDoubleValue("binding/factor", jsi->getInputAxisPositive() ? 1.0 : -1.0);
} else {
- iter--;
+ --iter;
}
} else {
cout << "Skipping control" << endl;
if ( ! confirmAnswer() )
- iter--;
+ --iter;
}
cout << endl;
}
PropertyList buttons = templatetree->getChildren("button");
- for(PropertyList::iterator iter = buttons.begin(); iter != buttons.end(); iter++) {
+ for(PropertyList::iterator iter = buttons.begin(); iter != buttons.end(); ++iter) {
cout << "Press the button you wish to use for " << (*iter)->getStringValue("desc") << endl;
cout << "Moving a joystick axis skips this button" << endl;
fflush( stdout );
SGPropertyNode *button = jstree[ jsi->getInputJoystick() ]->getChild("button", jsi->getInputButton(), true);
copyProperties(*iter, button);
} else {
- iter--;
+ --iter;
}
} else {
cout << "Skipping control" << endl;
if (! confirmAnswer())
- iter--;
+ --iter;
}
cout << endl;
}
jstree[i]->setStringValue("name", jss->getJoystick(i)->getName());
writeProperties(xfs[i], jstree[i], true);
- } catch (sg_io_exception e) {
+ } catch (sg_io_exception & e) {
cout << e.getFormattedMessage ();
}
xfs[i].close();