]> git.mxchange.org Git - flightgear.git/commitdiff
George PATTERSON:
authormfranz <mfranz>
Sun, 29 Oct 2006 12:34:26 +0000 (12:34 +0000)
committermfranz <mfranz>
Sun, 29 Oct 2006 12:34:26 +0000 (12:34 +0000)
"Flightgear.py
- Added the procedures view_next and view_prev

demo.py
- altered the wait five seconds to the new property path and allowed for
the script to be started after five seconds of simulation file
(/sim/time/elapsed-sec).
- the section of code was changed to a pythonism as python does not
support do-while loops, instead you break out of a continuous loop.
- Commented out the fg.wait_for_prop_eq() method as I haven't rewritten
that part of the code yet. Not sure of the best way to do that. Those
lines may not be necessary any more."

mf: removed trailing spaces; I updated the pyc, too, but I really think
    it shouldn't be in CVS at all.(?)

scripts/python/FlightGear.py
scripts/python/FlightGear.pyc
scripts/python/demo.py

index 9b71d57da1616c7874271253757395b1c1383642..26afbe8046e736be2c738997fde0cb4102052e40 100644 (file)
@@ -100,7 +100,7 @@ class FlightGear:
         except socket.error, msg:
             self.telnet = None
             raise socket.error, msg
-        
+
     def __del__(self):
         # Ensure telnet connection is closed cleanly.
         self.quit();
@@ -130,7 +130,7 @@ class FlightGear:
                 return 0
         else:
             return value
-        
+
     def __setitem__(self, key, value):
         """Set a FlightGear property value."""
         self.telnet.set( key, value )
@@ -140,3 +140,12 @@ class FlightGear:
         if self.telnet:
             self.telnet.quit()
             self.telnet = None
+
+    def view_next(self):
+        #move to next view
+        self.telnet.set( "/command/view/next", "true")
+
+    def view_prev(self):
+        #move to next view
+        self.telnet.set( "/command/view/prev", "true")
+
index 65a976c2acce54c636d058f6af14588bb52937d9..c58cba9a3e7471e5a0c047c6cbe33c4649daf690 100644 (file)
Binary files a/scripts/python/FlightGear.pyc and b/scripts/python/FlightGear.pyc differ
index 8f32c823255f9044e5714aee89d34da626e5b831..a0e986c633f2a3cb098071ae85ad97908efcd109 100644 (file)
@@ -5,8 +5,12 @@ def main():
     fg = FlightGear('localhost', 5500)
 
     # Wait five seconds for simulator to settle down
-    while fg['/sim/time/elapsed-ms'] < 5000:
+    while 1:
+        if fg['/sim/time/elapsed-sec'] > 5:
+            break
         time.sleep(1.0)
+        print fg['/sim/time/elapsed-sec']
+
 
     # parking brake on
     fg['/controls/parking-brake'] = 1
@@ -17,14 +21,14 @@ def main():
     fg.view_next()
 
     fg['/sim/current-view/goal-heading-offset-deg'] = 180.0
-    fg.wait_for_prop_eq('/sim/current-view/heading-offset-deg', 180.0)
-        
+    #fg.wait_for_prop_eq('/sim/current-view/heading-offset-deg', 180.0)
+
     fg['/sim/current-view/goal-heading-offset-deg'] = 90.0
-    fg.wait_for_prop_eq('/sim/current-view/heading-offset-deg', 90.0)
-        
+    #fg.wait_for_prop_eq('/sim/current-view/heading-offset-deg', 90.0)
+
     fg['/sim/current-view/goal-heading-offset-deg'] = 0.0
-    fg.wait_for_prop_eq('/sim/current-view/heading-offset-deg', 0.0)
-    
+    #fg.wait_for_prop_eq('/sim/current-view/heading-offset-deg', 0.0)
+
     time.sleep(2.0)
 
     # Switch back to cockpit view
@@ -34,9 +38,9 @@ def main():
 
     # Flaps to take off position
     fg['/controls/flaps'] = 0.34
-    fg.wait_for_prop_eq('/surface-positions/flap-pos-norm', 0.34)
+    #fg.wait_for_prop_eq('/surface-positions/flap-pos-norm', 0.34)
 
     fg.quit()
-    
+
 if __name__ == '__main__':
     main()