Exemplo n.º 1
0
    def stability_message_callback(self):
        """
        Makes sure user wants to turn on/off stabilization
        :return: None
        """
        if self.stability:
            if messagebox.askyesno("Turn off Stabilization",
                                   "Do you want to turn off stabilization"):

                try:
                    c = Comm.get_instance(self)
                    if c.send("Stabilization off"):
                        self.stability_button.config(
                            text="Turn On Stabilization")
                        self.stability = not self.stability
                        self.packets_sent.set_count(c.get_packets_sent())
                        self.packets_received.set_count(
                            c.get_packets_received())
                        self.calc_received_percentage()
                    else:
                        self.quality_checks[4].set_quality(0)
                        messagebox.showerror("ERROR: Command Not Sent",
                                             "Command Not Sent")
                        c.packets_sent -= 1

                except Exception as e:
                    print("Stabilization Error")
                    print(e)

        else:
            if messagebox.askyesno("Turn on Stabilization",
                                   "Do you want to turn on stabilization"):

                try:
                    c = Comm.get_instance(self)
                    if c.send("Stabilization on"):
                        self.stability_button.config(
                            text="Turn Off Stabilization")
                        self.stability = not self.stability
                        self.packets_sent.set_count(c.get_packets_sent())
                        self.packets_received.set_count(
                            c.get_packets_received())
                        self.calc_received_percentage()
                    else:
                        self.quality_checks[4].set_quality(0)
                        messagebox.showerror("ERROR: Command Not Sent",
                                             "Command Not Sent")
                        c.packets_sent -= 1

                except Exception as e:
                    print("Stabilization Error")
                    print(e)
Exemplo n.º 2
0
    def select_qdm(self):
        """
        Method called sending a qdm command and logging the incident
        :return: None
        """

        print("QDM")
        # TODO Make Comms Global
        try:
            c = Comm.get_instance(self)
            c.flight()
            c.send("qdm")
            self.packets_sent.set_count(c.get_packets_sent())
            self.packets_received.set_count(c.get_packets_received())
            self.calc_received_percentage()
        except Exception as e:
            print(e)

        self.abort_method = "QDM"
        self.control.mission_status = Status.ABORT
        # self.timer.clock_run = False
        self.control.verify_button.config(text="VERIFY")
        self.control.verify_button.config(state='disabled')
        self.log(self.control.mission_status)
        self.control.change_status_display(self.control.mission_status)
        GPIO.output(self.gui_switch, GPIO.LOW)
Exemplo n.º 3
0
    def change_radio_address_callback(self):
        try:
            c = Comm.get_instance(self)
            a = simpledialog.askstring(
                "Change Radio Address",
                "Type a hex number (1 - 9, A - F) for the radio address of the recieving radio"
                + "\n\n" + "The current address is: " +
                str(c.get_remote_node_address()))

            if a is None:
                return

            # TODO: Probably a better way to check if it is hex
            is_hex = True
            hex_char_set = [
                '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B',
                'C', 'D', 'E', 'F'
            ]
            for char in a:
                if char not in hex_char_set:
                    is_hex = False

            if len(a) != 16 or not is_hex:
                messagebox.showerror(
                    "ERROR: Invalid Address",
                    "The provided hex number was invalid\n\n" +
                    "Reverting to initial address")
            else:
                c.set_remote_node_address(a)
        except Exception as e:
            messagebox.showerror(
                "ERROR: Something went wrong",
                "Something went wrong\n\nNot Changing the Address.")
            print(e)
Exemplo n.º 4
0
 def is_test_mode(self):
     try:
         c = Comm.get_instance(self)
         return c.get_mode() == Mode.TESTING
     except Exception as e:
         print("Test Mode Error")
         print(e)
Exemplo n.º 5
0
    def launch(self):
        """
        Method is called when GPIO Pin 11 gets a rising edge.
        Checks if that mission has not started and mission is verified
        Starts the flight clock
        Changes status to LAUNCHED
        :return: None
        """
        # Using self.timer.clock_run as a launched bool
        # Not sure if there is something more proper to use
        if not self.timer.clock_run and self.control.mission_status == Status.VERIFIED:
            c = Comm.get_instance(self)
            c.send("Ignition")

            # Kind of puts the whole thread to sleep for 5 secs
            # But I think this is what the issue is asking for
            # time.sleep(5)

            self.timer.start = time.time()
            self.timer.clock_run = True
            self.timer.delay_tick()

            self.control.mission_status = Status.LAUNCHED
            self.control.verify_button.config(text="VERIFY")
            self.control.verify_button.config(state='disabled')

            self.log(self.control.mission_status)
            self.control.change_status_display(self.control.mission_status)
Exemplo n.º 6
0
    def start_mission(self):
        """
        Method is called when start mission in tool bar is selected.
        Starts the mission clock, and enables verify and abort buttons
        Sends test command

        :return: None
        """
        if not self.start_timer.clock_run:
            self.start_timer.start = time.time()
            self.start_timer.clock_run = True
            self.start_timer.tick()

        self.control.verify_button.state(["!disabled"])
        self.control.abort_button.state(["!disabled"])

        Comm.get_instance(self).flight()

        self.shutdown_timer = ShutdownTimer(300, self.time_out)
Exemplo n.º 7
0
    def test_stability(self):
        try:
            c = Comm.get_instance(self)
            m = c.get_mode()

            c.testing()
            c.send("stability")
            self.packets_sent.set_count(c.get_packets_sent())
            self.packets_received.set_count(c.get_packets_received())
            self.calc_received_percentage()
            c.set_mode(m)
        except Exception as e:
            print("Test Stability Error")
            print(e)
Exemplo n.º 8
0
    def select_cdm(self):
        # TODO: Are we using CDM at all??? Get rid of?
        c = Comm.get_instance(self)
        c.flight()
        c.send("cdm")
        self.packets_sent.set_count(c.get_packets_sent())
        self.packets_received.set_count(c.get_packets_received())
        self.calc_received_percentage()

        self.abort_method = "CDM"
        self.control.mission_status = Status.ABORT
        self.log(self.control.mission_status)
        self.timer.clock_run = False
        self.control.verify_button.config(text="VERIFY")
        self.control.change_status_display(self.control.mission_status)
        GPIO.output(self.gui_switch, GPIO.LOW)
Exemplo n.º 9
0
    def alter_test_mode(self):

        # TODO use above mode defined in CommunicationDriver.py
        self.test_mode = not self.test_mode

        self.init_graph_stuff()
        self.dataBalloon.reset_variables()
        self.control.reset_status()
        self.timer.reset()
        self.start_timer.reset()
        self.packets_sent.reset()
        self.packets_received.reset()
        self.calc_received_percentage()
        c = Comm.get_instance(self)
        c.reset_counters()

        for check in self.quality_checks:
            check.reset_quality()

        if self.test_mode:
            self.name.rowconfigure(19, weight=2)
            self.warningLabel.grid(row=19,
                                   column=0,
                                   columnspan=11,
                                   sticky=N + S + E + W)

        else:
            self.name.rowconfigure(19, weight=2)
            self.warningLabel.grid_forget()

        if c.get_mode() == Mode.STANDBY:
            c.testing()

        elif c.get_mode() == Mode.TESTING:
            c.standby()

        else:
            print("\n*** CANNOT ENTER TEST MODE DURING FLIGHT ***")