From 35abb41e8e578c96d9e34e4507abb47585770b89 Mon Sep 17 00:00:00 2001 From: Jason Watkins Date: Fri, 1 May 2015 15:13:27 -0700 Subject: [PATCH] Updated Python client to support "switch" argument in SIMU command. --- Python/src/xplaneConnect.py | 8 ++++---- TestScripts/Python Tests/Tests.py | 10 ++++++++++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/Python/src/xplaneConnect.py b/Python/src/xplaneConnect.py index 69ab40b..9a38c82 100644 --- a/Python/src/xplaneConnect.py +++ b/Python/src/xplaneConnect.py @@ -81,11 +81,11 @@ class XPlaneConnect(object): Args: pause: True to pause the simulation; False to resume. ''' - pause_val = 0 - if pause: - pause_val = 1 + pause = int(pause) + if pause < 0 or pause > 2: + raise ValueError("Invalid argument for pause command.") - buffer = struct.pack("<4sxB", "SIMU", pause_val) + buffer = struct.pack("<4sxB", "SIMU", pause) self.sendUDP(buffer) # X-Plane UDP Data diff --git a/TestScripts/Python Tests/Tests.py b/TestScripts/Python Tests/Tests.py index a3ea597..78c6e32 100644 --- a/TestScripts/Python Tests/Tests.py +++ b/TestScripts/Python Tests/Tests.py @@ -161,6 +161,16 @@ class XPCTests(unittest.TestCase): expected = 0.0 do_test() + # Test 3 + value = 1 + expected = 1.0 + do_test() + + # Test 4 + value = 2 + expected = 0.0 + do_test() + def test_sendCTRL(self): # Setup