]> git.mxchange.org Git - flightgear.git/blobdiff - src/Instrumentation/marker_beacon.cxx
Add a hardwired instrument approach for testing. This will be removed and read from...
[flightgear.git] / src / Instrumentation / marker_beacon.cxx
index 3662fcd1622f8b228310cce0c28b1380cc31f3ae..e1ca85e1208946a4fd32f8639c78df1f89ee8fd6 100644 (file)
@@ -63,8 +63,7 @@ FGMarkerBeacon::FGMarkerBeacon(SGPropertyNode *node) :
     low_tbl = new SGInterpTable( low.str() );
     high_tbl = new SGInterpTable( high.str() );
 
-    int i;
-    for ( i = 0; i < node->nChildren(); ++i ) {
+    for ( int i = 0; i < node->nChildren(); ++i ) {
         SGPropertyNode *child = node->getChild(i);
         string cname = child->getName();
         string cval = child->getStringValue();
@@ -110,9 +109,12 @@ FGMarkerBeacon::init ()
     audio_vol = node->getChild("volume", 0, true);
     serviceable = node->getChild("serviceable", 0, true);
 
-    power_btn->setBoolValue( true );
-    audio_btn->setBoolValue( true );
-    serviceable->setBoolValue( true );
+    if (power_btn->getType() == simgear::props::NONE)
+        power_btn->setBoolValue( true );
+    if (audio_btn->getType() == simgear::props::NONE)
+        audio_btn->setBoolValue( true );
+    if (serviceable->getType() == simgear::props::NONE)
+        serviceable->setBoolValue( true );
 
     morse.init();
     beacon.init();
@@ -165,7 +167,7 @@ FGMarkerBeacon::update(double dt)
 
     _time_before_search_sec -= dt;
     if ( _time_before_search_sec < 0 ) {
-       search();
+        search();
     }
 
     if ( has_power() && serviceable->getBoolValue()
@@ -173,15 +175,14 @@ FGMarkerBeacon::update(double dt)
 
         // marker beacon blinking
         bool light_on = ( outer_blink || middle_blink || inner_blink );
-        SGTimeStamp current;
-        current.stamp();
+        SGTimeStamp current = SGTimeStamp::now();
 
-        if ( light_on && (current - blink > 400000) ) {
+        if ( light_on && blink + SGTimeStamp::fromUSec(400000) < current ) {
             light_on = false;
-            blink.stamp();
-        } else if ( !light_on && (current - blink > 100000) ) {
+            blink = current;
+        } else if ( !light_on && blink + SGTimeStamp::fromUSec(100000) < current ) {
             light_on = true;
-            blink.stamp();
+            blink = current;
         }
 
         if ( outer_marker ) {
@@ -250,7 +251,7 @@ static bool check_beacon_range( const SGGeod& pos,
 
 class BeaconFilter : public FGPositioned::Filter
 {
-public:  
+public:
   virtual FGPositioned::Type minType() const {
     return FGPositioned::OM;
   }
@@ -280,7 +281,7 @@ void FGMarkerBeacon::search()
     // get closest marker beacon - within a 1nm cutoff
     BeaconFilter filter;
     FGPositionedRef b = FGPositioned::findClosest(pos, 1.0, &filter);
-     
+
     fgMkrBeacType beacon_type = NOBEACON;
     bool inrange = false;
     if ( b != NULL ) {