示例#1
0
    def test_far_away_equal_priority(self):
        own_ship = get_own_ship(0.0, 0, 220)
        aircraft_a = Aircraft(100000, 0, 0, 270.0, 0, 220, 0, 1)
        aircraft_b = Aircraft(-100000, 0, 0, 90.0, 0, 220, 0, 2)

        result = do_compare_a_to_b(own_ship, aircraft_a, aircraft_b)
        self.assertEqual(0, result)
示例#2
0
    def test_equal_dist_equal_priority(self):
        own_ship = get_own_ship(0.0, 0, 220)
        aircraft_a = Aircraft(5280, 5280, 0, 180.0, 0, 220, 0, 1)
        aircraft_b = Aircraft(-5280, 5280, 0, 180.0, 0, 220, 0, 2)

        result = do_compare_a_to_b(own_ship, aircraft_a, aircraft_b)
        self.assertEqual(0, result)
示例#3
0
    def test_vert_closer_gt(self):
        own_ship = get_own_ship(0.0, 0, 220)
        v_closer = Aircraft(0, 5280, 0, 180.0, 0, 220, 0, 1)
        v_farther = Aircraft(0, 5280, 1000, 180.0, 0, 220, 0, 1)

        result = do_compare_a_to_b(own_ship, v_closer, v_farther)
        self.assertLess(result, 0)
示例#4
0
    def test_horiz_closer_gt(self):
        own_ship = get_own_ship(0.0, 0, 220)
        h_closer = Aircraft(0, 2000, 0, 180.0, 0, 220, 0, 1)
        h_farther = Aircraft(0, 20000, 0, 180.0, 0, 220, 0, 2)

        result = do_compare_a_to_b(own_ship, h_closer, h_farther)
        self.assertLess(result, 0)
 def test_doNothing(self):
     main = MainClass()
     main.setOwnShip(0, 0, 0, 50, 30, 40, 0, 1)
     main.aircraftQueue.put(
         Aircraft(0, 0, 0, 50, 30, 40, AlertLevel.AL_NoAlert, 2))
     main.aircraftQueue.put(
         Aircraft(1, 1, 1, 50, 30, 40, AlertLevel.AL_NoAlert, 3))
     main.aircraftQueue.put(
         Aircraft(2, 2, 2, 50, 30, 40, AlertLevel.AL_NoAlert, 4))
     main.aircraftQueue.put(
         Aircraft(3, 3, 3, 50, 30, 40, AlertLevel.AL_NoAlert, 5))
     testAction = main.determineAction
     self.assertEquals(0, testAction.getVSChange())
     self.assertLess(testAction.getUrgency(), 0)
 def test_normalAscend(self):
     main = MainClass()
     main.setOwnShip(0, 0, 11600, 50, 30, 40, 0, 1)
     main.aircraftQueue.put(
         Aircraft(0, 0, 0, 50, 30, 40, AlertLevel.AL_NoAlert, 2))
     main.aircraftQueue.put(
         Aircraft(1, 1, 1, 50, 30, 40, AlertLevel.AL_NoAlert, 3))
     main.aircraftQueue.put(
         Aircraft(2, 2, 2, 50, 30, 40, AlertLevel.AL_NoAlert, 4))
     main.aircraftQueue.put(
         Aircraft(20000, 20000, 10000, 50, 30, 40,
                  AlertLevel.AL_ResolAdvisoryMed, 5))
     testAction = main.determineAction
     self.assertGreater(testAction.getVSChange(), 0)
     self.assertEqual(testAction.getUrgency(), 0)
 def test_gentleDescend(self):
     main = MainClass()
     main.setOwnShip(0, 0, 10000, 50, 30, 40, 0, 1)
     main.aircraftQueue.put(
         Aircraft(0, 0, 0, 50, 30, 40, AlertLevel.AL_NoAlert, 2))
     main.aircraftQueue.put(
         Aircraft(1, 1, 1, 50, 30, 40, AlertLevel.AL_NoAlert, 3))
     main.aircraftQueue.put(
         Aircraft(2, 2, 2, 50, 30, 40, AlertLevel.AL_NoAlert, 4))
     main.aircraftQueue.put(
         Aircraft(25000, 25000, 12500, 50, 30, 40,
                  AlertLevel.AL_ResolAdvisoryLow, 5))
     testAction = main.determineAction
     self.assertLess(testAction.getVSChange(), 0)
     self.assertLess(testAction.getUrgency(), 0)
 def test_sharpDescendEqualZ(self):
     main = MainClass()
     main.setOwnShip(0, 14000, 11000, 50, 40, 40, 0, 1)
     main.aircraftQueue.put(
         Aircraft(0, 0, 0, 50, 30, 40, AlertLevel.AL_NoAlert, 2))
     main.aircraftQueue.put(
         Aircraft(1, 1, 1, 50, 30, 40, AlertLevel.AL_NoAlert, 3))
     main.aircraftQueue.put(
         Aircraft(2, 2, 2, 50, 30, 40, AlertLevel.AL_NoAlert, 4))
     main.aircraftQueue.put(
         Aircraft(15000, 15000, 11000, 50, 30, 40,
                  AlertLevel.AL_ResolAdvisoryHigh, 5))
     testAction = main.determineAction
     self.assertLess(testAction.getVSChange(), 0)
     self.assertGreater(testAction.getUrgency(), 0)
示例#9
0
 def __init__(self):
     self.ownShip = Aircraft(0, 0, 0, 0, 0, 0, 0, 0)
     self.aircraftQueue = PriorityQueue()
     self.myAction = Action(0, 0)
     self.ads_bInt = ADS_BDriver()
     self.display = Display()
     self.loudSpeaker = LoudSpeaker()
     self.panelBtns = FrontPanelButtons()
示例#10
0
def make_random_aircraft(id):
    rng = SystemRandom()
    alertLevels = list(AlertLevel)
    return Aircraft(
        rng.randint(-100000, 100000),
        rng.randint(-100000, 100000),
        rng.randint(-50000, 50000),
        rng.uniform(0.0, 360.0),
        rng.randint(0, 10000),
        rng.randint(0, 4400),
        rng.choice(alertLevels),
        id
    )
示例#11
0
 def setOwnShip(self, xInFeet: int, yInFeet: int, zInFeet: int,
                heading: float, vSpeedFPS: int, gSpeedFPS: int,
                alertLevel: AlertLevel, id: int):
     self.ownShip = Aircraft(xInFeet, yInFeet, zInFeet, heading, vSpeedFPS,
                             gSpeedFPS, alertLevel, id)
示例#12
0
 def test_alertLv1(self):
     main = MainClass()
     testAircraft = Aircraft(60000, 60000, 8000, 50, 30, 40, 0, 1)
     testAircraft.calcAlertLevel(main.ownShip)
     self.assertEquals(testAircraft.getAlertLevel(), 1)
示例#13
0
 def test_alertLv3(self):
     main = MainClass()
     testAircraft = Aircraft(0, 35000, 2500, 180, 0, 200, 0, 1)
     testAircraft.calcAlertLevel(main.ownShip)
     self.assertEquals(testAircraft.getAlertLevel(), 3)
示例#14
0
def get_own_ship(heading: float, v_speed_fps: int, g_speed_fps: int):
    return Aircraft(0, 0, 0, heading, v_speed_fps, g_speed_fps, 0, 0)