Beispiel #1
0
    def atwptStack(self, idx, *args):  # args: all arguments of addwpt

        # AT acid, wpinroute [DEL] ALT/SPD spd/alt"
        # args = wpname,SPD/ALT, spd/alt(string)

        if len(args) < 1:
            return False, "AT needs at least an aicraft id and a waypoint name"

        else:
            name = args[0]
            if name in self.wpname:
                wpidx = self.wpname.index(name)

                # acid AT wpinroute: show alt & spd constraints at this waypoint
                # acid AT wpinroute SPD: show spd constraint at this waypoint
                # acid AT wpinroute ALT: show alt constraint at this waypoint

                if len(args) == 1 or \
                        (len(args) == 2 and not args[1].count("/") == 1):

                    txt = name + " : "

                    # Select what to show
                    if len(args)==1:
                        swalt = True
                        swspd = True
                    else:
                        swalt = args[1].upper()=="ALT"
                        swspd = args[1].upper() in ("SPD","SPEED")

                        # To be safe show both when we do not know what
                        if not (swalt or swspd):
                            swalt = True
                            swspd = True

                    # Show altitude
                    if swalt:
                        if self.wpalt[wpidx] < 0:
                            txt += "-----"

                        elif self.wpalt[wpidx] > 4500 * ft:
                            fl = int(round((self.wpalt[wpidx] / (100. * ft))))
                            txt += "FL" + str(fl)

                        else:
                            txt += str(int(round(self.wpalt[wpidx] / ft)))

                        if swspd:
                            txt += "/"

                    # Show speed
                    if swspd:
                        if self.wpspd[wpidx] < 0:
                            txt += "---"
                        else:
                            txt += str(int(round(self.wpspd[wpidx] / kts)))

                    # Type
                    if swalt and swspd:
                        if self.wptype[wpidx] == Route.orig:
                            txt += "[orig]"
                        elif self.wptype[wpidx] == Route.dest:
                            txt += "[dest]"

                    return True, txt

                elif args[1].count("/")==1:
                    # acid AT wpinroute alt"/"spd
                    success = True

                    # Use parse from stack.py to interpret alt & speed
                    alttxt, spdtxt = args[1].split('/')

                    # Edit waypoint altitude constraint
                    if alttxt.count('-') > 1: # "----" = delete
                        self.wpalt[wpidx]  = -999.
                    else:
                        parser = Argparser(['alt'], [False], alttxt)
                        if parser.parse():
                            self.wpalt[wpidx] = parser.arglist[0]
                        else:
                            success = False

                    # Edit waypoint speed constraint
                    if spdtxt.count('-') > 1: # "----" = delete
                        self.wpspd[wpidx]  = -999.
                    else:
                        parser = Argparser(['spd'], [False], spdtxt)
                        if parser.parse():
                            self.wpspd[wpidx] = parser.arglist[0]
                        else:
                            success = False

                    if not success:
                        return False,"Could not parse "+args[1]+" as alt / spd"

                    # If success: update flight plan and guidance
                    self.calcfp()
                    self.direct(idx, self.wpname[self.iactwp])


                #acid AT wpinroute ALT/SPD alt/spd
                elif len(args)==3 :
                    swalt = args[1].upper()=="ALT"
                    swspd = args[1].upper() in ("SPD","SPEED")

                    # Use parse from stack.py to interpret alt & speed

                    # Edit waypoint altitude constraint
                    if swalt:
                        parser = Argparser(['alt'], [False], args[2])
                        if parser.parse():
                            self.wpalt[wpidx] = parser.arglist[0]
                        else:
                            return False,'Could not parse "' + args[2] + '" as altitude'

                    # Edit waypoint speed constraint
                    elif swspd:
                        parser = Argparser(['spd'], [False], args[2])
                        if parser.parse():
                            self.wpspd[wpidx] = parser.arglist[0]
                        else:
                            return False,'Could not parse "' + args[2] + '" as speed'

                    # Delete a constraint (or both) at this waypoint
                    elif args[1]=="DEL" or args[1]=="DELETE":
                        swalt = args[2].upper()=="ALT"
                        swspd = args[2].upper() in ("SPD","SPEED")
                        both  = args[2].upper() in ("ALL","BOTH")

                        if swspd or both:
                            self.wpspd[wpidx]  = -999.

                        if swalt or both:
                            self.wpalt[wpidx]  = -999.

                    else:
                        return False,"No "+args[1]+" at ",name


                    # If success: update flight plan and guidance
                    self.calcfp()
                    self.direct(idx, self.wpname[self.iactwp])

            # Waypoint not found in route
            else:
                return False, name + " not found in route " + bs.traf.id[idx]

        return True
Beispiel #2
0
    def atwptStack(self, idx, *args):  # args: all arguments of addwpt

        # AT acid, wpinroute [DEL] ALT/SPD spd/alt"
        # args = wpname,SPD/ALT, spd/alt(string)

        if len(args) < 1:
            return False, "AT needs at least an aicraft id and a waypoint name"

        else:
            name = args[0]
            if name in self.wpname:
                wpidx = self.wpname.index(name)

                # acid AT wpinroute: show alt & spd constraints at this waypoint
                # acid AT wpinroute SPD: show spd constraint at this waypoint
                # acid AT wpinroute ALT: show alt constraint at this waypoint

                if len(args) == 1 or \
                        (len(args) == 2 and not args[1].count("/") == 1):

                    txt = name + " : "

                    # Select what to show
                    if len(args) == 1:
                        swalt = True
                        swspd = True
                    else:
                        swalt = args[1].upper() == "ALT"
                        swspd = args[1].upper() in ("SPD", "SPEED")

                        # To be safe show both when we do not know what
                        if not (swalt or swspd):
                            swalt = True
                            swspd = True

                    # Show altitude
                    if swalt:
                        if self.wpalt[wpidx] < 0:
                            txt += "-----"

                        elif self.wpalt[wpidx] > 4500 * ft:
                            fl = int(round((self.wpalt[wpidx] / (100. * ft))))
                            txt += "FL" + str(fl)

                        else:
                            txt += str(int(round(self.wpalt[wpidx] / ft)))

                        if swspd:
                            txt += "/"

                    # Show speed
                    if swspd:
                        if self.wpspd[wpidx] < 0:
                            txt += "---"
                        else:
                            txt += str(int(round(self.wpspd[wpidx] / kts)))

                    # Type
                    if swalt and swspd:
                        if self.wptype[wpidx] == Route.orig:
                            txt += "[orig]"
                        elif self.wptype[wpidx] == Route.dest:
                            txt += "[dest]"

                    return True, txt

                elif args[1].count("/") == 1:
                    # acid AT wpinroute alt"/"spd
                    success = True

                    # Use parse from stack.py to interpret alt & speed
                    alttxt, spdtxt = args[1].split('/')

                    # Edit waypoint altitude constraint
                    if alttxt.count('-') > 1:  # "----" = delete
                        self.wpalt[wpidx] = -999.
                    else:
                        parser = Argparser(['alt'], [False], alttxt)
                        if parser.parse():
                            self.wpalt[wpidx] = parser.arglist[0]
                        else:
                            success = False

                    # Edit waypoint speed constraint
                    if spdtxt.count('-') > 1:  # "----" = delete
                        self.wpspd[wpidx] = -999.
                    else:
                        parser = Argparser(['spd'], [False], spdtxt)
                        if parser.parse():
                            self.wpspd[wpidx] = parser.arglist[0]
                        else:
                            success = False

                    if not success:
                        return False, "Could not parse " + args[
                            1] + " as alt / spd"

                    # If success: update flight plan and guidance
                    self.calcfp()
                    self.direct(idx, self.wpname[self.iactwp])

                #acid AT wpinroute ALT/SPD alt/spd
                elif len(args) == 3:
                    swalt = args[1].upper() == "ALT"
                    swspd = args[1].upper() in ("SPD", "SPEED")

                    # Use parse from stack.py to interpret alt & speed

                    # Edit waypoint altitude constraint
                    if swalt:
                        parser = Argparser(['alt'], [False], args[2])
                        if parser.parse():
                            self.wpalt[wpidx] = parser.arglist[0]
                        else:
                            return False, 'Could not parse "' + args[
                                2] + '" as altitude'

                    # Edit waypoint speed constraint
                    elif swspd:
                        parser = Argparser(['spd'], [False], args[2])
                        if parser.parse():
                            self.wpspd[wpidx] = parser.arglist[0]
                        else:
                            return False, 'Could not parse "' + args[
                                2] + '" as speed'

                    # Delete a constraint (or both) at this waypoint
                    elif args[1] == "DEL" or args[1] == "DELETE":
                        swalt = args[2].upper() == "ALT"
                        swspd = args[2].upper() in ("SPD", "SPEED")
                        both = args[2].upper() in ("ALL", "BOTH")

                        if swspd or both:
                            self.wpspd[wpidx] = -999.

                        if swalt or both:
                            self.wpalt[wpidx] = -999.

                    else:
                        return False, "No " + args[1] + " at ", name

                    # If success: update flight plan and guidance
                    self.calcfp()
                    self.direct(idx, self.wpname[self.iactwp])

            # Waypoint not found in route
            else:
                return False, name + " not found in route " + bs.traf.id[idx]

        return True
Beispiel #3
0
    def atwptStack(self, idx, *args):  # args: all arguments of addwpt

        # AT acid, wpinroute [DEL] ALT/SPD spd/alt"

        # args = wpname,SPD/ALT, spd/alt(string)
        if len(args) < 1:
            return False, "AT needs at least an aicraft id and a waypoint name"

        else:
            name = args[0]
            if name in self.wpname:
                wpidx = self.wpname.index(name)

                # acid AT wpinroute: show alt & spd constraints at this waypoint
                # acid AT wpinroute SPD: show spd constraint at this waypoint
                # acid AT wpinroute ALT: show alt constraint at this waypoint

                txt = name + " : "

                if len(args) == 1 or (len(args) == 2
                                      and not args[1].count("/") == 1):

                    txt = name + " : "

                    # Select what to show
                    if len(args) == 1:
                        swalt = True
                        swspd = True
                    else:
                        swalt = args[1].upper() == "ALT"
                        swspd = args[1].upper() in ("SPD", "SPEED")

                        # To be safe show both when we do not know what
                        if not (swalt or swspd):
                            swalt = True
                            swspd = True

                    # Show altitude
                    if swalt:
                        if self.wpalt[wpidx] < 0:
                            txt = txt + "-----"

                        elif self.wpalt[wpidx] > 4500 * ft:
                            FL = int(round((self.wpalt[wpidx] / (100. * ft))))
                            txt = txt + "FL" + str(FL)

                        else:
                            txt = txt + str(int(round(self.wpalt[wpidx] / ft)))

                        if swspd:
                            txt = txt + "/"

                    # Show speed
                    if swspd:
                        if self.wpspd[wpidx] < 0:
                            txt = txt + "---"
                        else:
                            txt = txt + str(int(round(
                                self.wpspd[wpidx] / kts)))

                    # Type
                    if swalt and swspd:
                        if self.wptype[wpidx] == self.orig:
                            txt = txt + "[orig]"
                        elif self.wptype[wpidx] == self.dest:
                            txt = txt + "[dest]"

                    return True, txt

                elif args[1].count("/") == 1:
                    # acid AT wpinroute alt"/"spd

                    # Use parse from stack.py to interpret alt & speed
                    parser = Argparser()
                    islash = args[1].index("/")
                    swalt = islash > 0
                    swspd = islash < len(
                        args[1]) - 2  #at keast one char after slash

                    # Edit waypoint altitude constraint
                    if swalt:
                        alttxt = [args[1][:islash]]
                        # Use argument parser from stack to parse speed
                        success = parser.parse("alt", 0, alttxt)

                        # Set new value if success, "---" etc ignored
                        if success and not (parser.result[0] == None):
                            self.wpalt[wpidx] = parser.result[0]
                        else:
                            if len(alttxt[0]) == alttxt[0].count(
                                    "-"):  # "----" = delete
                                self.wpalt[wpidx] = -999.
                            else:
                                swalt = False

                    # Edit waypoint speed constraint
                    if swspd:
                        spdtxt = [args[1][islash + 1:]]
                        # Use argument parser from stack to parse speed
                        success = parser.parse("spd", 0, spdtxt)

                        # Set new value if success, "---" etc ignored
                        if success and not (parser.result[0] == None):
                            self.wpspd[wpidx] = parser.result[0]
                        else:
                            if len(spdtxt[0]) == spdtxt[0].count(
                                    "-"):  # "----" = delete
                                self.wpspd[wpidx] = -999.
                            else:
                                swspd = False

                    del parser

                    if (not swspd) and (not swalt):
                        return False, "Could not parse " + args[
                            1] + " as alt / spd"

                    # If success: update flight plan and guidance
                    self.calcfp()
                    self.direct(idx, self.wpname[self.iactwp])

                #acid AT wpinroute ALT/SPD alt/spd
                elif len(args) == 3:
                    swalt = args[1].upper() == "ALT"
                    swspd = args[1].upper() in ("SPD", "SPEED")

                    # Use parse from stack.py to interpret alt & speed
                    parser = Argparser()

                    # Edit waypoint altitude constraint
                    if swalt:

                        # Use argument parser from stakc to parse speed
                        success = parser.parse("alt", 2, args)
                        if success:
                            alt = parser.result[0]
                        else:
                            del parser
                            return False, 'Could not parse "' + args[
                                2] + '" as altitude'

                        # Set new value
                        self.wpalt[wpidx] = alt

                    # Edit waypoint speed constraint
                    elif swspd:

                        # Use argument parser from stakc to parse speed
                        success = parser.parse("spd", 2, args)
                        if success:
                            spd = parser.result[0]
                        else:
                            del parser
                            return False, 'AT: Could not parse "' + args[
                                2] + '" as speed'

                        # Set new value
                        self.wpspd[wpidx] = spd

                    # Delete a constraint (or both) at this waypoint
                    elif args[1] == "DEL" or args[1] == "DELETE":
                        swalt = args[2].upper() == "ALT"
                        swspd = args[2].upper() in ("SPD", "SPEED")
                        both = args[2].upper() in ("ALL", "BOTH")

                        if swspd or both:
                            self.wpspd[wpidx] = -999.

                        if swalt or both:
                            self.wpalt[wpidx] = -999.

                    else:
                        del parser
                        return False, "No " + args[1] + " at ", name

                    # If success: update flight plan and guidance
                    self.calcfp()
                    self.direct(idx, self.wpname[self.iactwp])

                    del parser

            # Waypoint not found in route
            else:
                return False, name + " not found in route " + bs.traf.id[idx]

        return True