def start(self, event=None):
     self.eyes = EnclosureEyes(self.ws, self.writer)
     self.mouth = EnclosureMouth(self.ws, self.writer)
     self.system = EnclosureArduino(self.ws, self.writer)
     self.weather = EnclosureWeather(self.ws, self.writer)
     self.__register_events()
     self.__reset()
     self.started = True
Example #2
0
 def __init__(self):
     self.__init_serial()
     self.client = WebsocketClient()
     self.reader = EnclosureReader(self.serial, self.client)
     self.writer = EnclosureWriter(self.serial, self.client)
     self.eyes = EnclosureEyes(self.client, self.writer)
     self.mouth = EnclosureMouth(self.client, self.writer)
     self.system = EnclosureArduino(self.client, self.writer)
     self.__init_events()
Example #3
0
    def __init__(self):
        resetSelf = False
        try:
            self.config = ConfigurationManager.get().get("enclosure")

            platform = self.config.get('platform')
            if platform is None:
                # Use the serial port to check if this is a Mycroft
                # Mark 1 unit.
                platform = self.detect_platform()
                if platform == 'unknown':
                    # Since this is a semi-permanent detection, be
                    # certain!  Sometimes noise on the serial line
                    # causes a faulty mis-detection on a real
                    # Mycroft Mark 1
                    platform = self.detect_platform()

                ConfigurationManager.set('enclosure', 'platform', platform)

                # After a platform detection, the system is usually
                # already active, so the message from the loop
                # has already gone by on the messagebus.  So self reset.
                resetSelf = True
        except Exception as e:
            self.disconnect()
            raise Exception("Exception: Unable to determine platform\n" +
                            str(e))

        LOGGER.info("Platform = '" + platform + "'")
        if platform == "mycroft_mark_1":
            # We are a mycroft_mark_1 unit, start up the
            # enclosure client to communicate over the
            # serial port
            self.__init_serial()
        else:
            self.disconnect()
            raise Exception("Exception: Not a Mycroft Mark 1, shutting down")

        self.client = WebsocketClient()
        self.reader = EnclosureReader(self.serial, self.client)
        self.writer = EnclosureWriter(self.serial, self.client)

        # Create helpers to handle the various parts of the enclosure
        self.eyes = EnclosureEyes(self.client, self.writer)
        self.mouth = EnclosureMouth(self.client, self.writer)
        self.system = EnclosureArduino(self.client, self.writer)

        # TODO: Remove EnclosureWeather once the Skill can send images
        #       directly to the EnclosureAPI.
        self.weather = EnclosureWeather(self.client, self.writer)
        self.__register_events()

        if resetSelf:
            self.__handle_reset(None)
    def on_arduino_responded(self, event=None):
        self.eyes = EnclosureEyes(self.ws, self.writer)
        self.mouth = EnclosureMouth(self.ws, self.writer)
        self.system = EnclosureArduino(self.ws, self.writer)
        self.weather = EnclosureWeather(self.ws, self.writer)
        self.__register_events()
        self.__reset()
        self.arduino_responded = True

        # verify internet connection and prompt user on bootup if needed
        if not connected():
            # We delay this for several seconds to ensure that the other
            # clients are up and connected to the messagebus in order to
            # receive the "speak".  This was sometimes happening too
            # quickly and the user wasn't notified what to do.
            Timer(5, self.on_no_internet).start()
Example #5
0
    def on_arduino_responded(self, event=None):
        self.eyes = EnclosureEyes(self.ws, self.writer)
        self.mouth = EnclosureMouth(self.ws, self.writer)
        self.system = EnclosureArduino(self.ws, self.writer)
        self.weather = EnclosureWeather(self.ws, self.writer)
        self.__register_events()
        self.__reset()
        self.arduino_responded = True

        # verify internet connection and prompt user on bootup if needed
        if not connected():
            # We delay this for several seconds to ensure that the other
            # clients are up and connected to the messagebus in order to
            # receive the "speak".  This was sometimes happening too
            # quickly and the user wasn't notified what to do.
            Timer(5, self._do_net_check).start()
        else:
            # Indicate we are checking for updates from the internet now...
            self.writer.write("mouth.text=< < < UPDATING < < < ")

        Timer(60, self._hack_check_for_duplicates).start()