Exemplo n.º 1
0
    def _on_command(self,mgr, event):

        command = event.command

        ## Start Scan and goto Settings Mode
        if command == FSCommand.SCAN:
            if self._state is FSState.IDLE:
                self.set_state(FSState.SETTINGS)
                self.hardwareController.settings_mode_on()

        ## Update Settings in Settings Mode
        elif command == FSCommand.UPDATE_SETTINGS:
            if self._state is FSState.SETTINGS:
                try:
                    #self._logger.info(event.settings)
                    self.settings.update(event.settings)
                    self.hardwareController.led.on(self.settings.led.red,self.settings.led.green,self.settings.led.blue)
                except:
                    pass

        ## Start Scan Process
        elif command == FSCommand.START:
            if self._state is FSState.SETTINGS:
                self._logger.debug("Start command received...")
                self.set_state(FSState.SCANNING)
                self.hardwareController.settings_mode_off()
                self.scanProcessor = FSScanProcessor.start()
                self.scanProcessor.tell({FSEvents.COMMAND:FSCommand.START})

        ## Stop Scan Process or Stop Settings Mode
        elif command == FSCommand.STOP:
            if self._state is FSState.SCANNING:
                self.scanProcessor.ask({FSEvents.COMMAND:FSCommand.STOP})
                self.scanProcessor.stop()
                #self.set_state(FSState.IDLE)

            if self._state is FSState.SETTINGS:
                self.hardwareController.settings_mode_off()

            self.set_state(FSState.IDLE)

        elif command == FSCommand._COMPLETE:
            self.set_state(FSState.IDLE)
            self._logger.info("Scan complete")

        elif command == FSCommand._LASER_DETECTION_FAILED:
            #self.scanProcessor.ask({FSEvents.COMMAND:FSCommand.STOP})
            self._logger.info("No Laser detected, returning to settings dialog.")
            #self.scanProcessor.ask({FSEvents.COMMAND:FSCommand.STOP})
            #self.scanProcessor.stop()

            self.set_state(FSState.SETTINGS)
            self.hardwareController.settings_mode_on()
Exemplo n.º 2
0
    def __init__(self):
        threading.Thread.__init__(self)
        self._state = FSState.IDLE
        self._logger = logging.getLogger(__name__)
        self._logger.setLevel(logging.DEBUG)
        self.settings = Settings.instance()
        self.daemon = True
        self._exit_requested = False
        self.meshingTaskRunning = False

        self.scanProcessor = FSScanProcessor.start()
        self._logger.debug("Number of cpu cores: " + str(multiprocessing.cpu_count()))

        self.eventManager = FSEventManager.instance()
        self.eventManager.subscribe(FSEvents.ON_CLIENT_CONNECTED, self.on_client_connected)
        self.eventManager.subscribe(FSEvents.COMMAND, self.on_command)
Exemplo n.º 3
0
    def _on_command(self,mgr, event):

        command = event.command

        ## Start Scan and goto Settings Mode
        if command == FSCommand.SCAN:
            if self._state is FSState.IDLE:
                self.set_state(FSState.SETTINGS)
                self.hardwareController.settings_mode_on()

        ## Update Settings in Settings Mode
        elif command == FSCommand.UPDATE_SETTINGS:
            if self._state is FSState.SETTINGS:
                try:
                    #self._logger.info(event.settings)
                    self.settings.update(event.settings)
                    self.hardwareController.led.on(self.settings.led.red,self.settings.led.green,self.settings.led.blue)
                except:
                    pass

        ## Start Scan Process
        elif command == FSCommand.START:
            if self._state is FSState.SETTINGS:
                self._logger.debug("Start command received...")
                self.set_state(FSState.SCANNING)
                self.hardwareController.settings_mode_off()
                self.scanProcessor = FSScanProcessor.start()
                self.scanProcessor.tell({FSEvents.COMMAND:FSCommand.START})

        ## Stop Scan Process or Stop Settings Mode
        elif command == FSCommand.STOP:

            if self._state is FSState.SCANNING:
                self.scanProcessor.ask({FSEvents.COMMAND:FSCommand.STOP})
                self.scanProcessor.stop()

            if self._state is FSState.SETTINGS:
                self.hardwareController.settings_mode_off()
                #self.scanProcessor.stop()

            self.hardwareController.camera.device.stopStream()
            self.set_state(FSState.IDLE)


        elif command == FSCommand._COMPLETE:
            self.set_state(FSState.IDLE)
            self.hardwareController.camera.device.stopStream()
            #self.scanProcessor.stop()
            self._logger.info("Scan complete")

        elif command == FSCommand._LASER_DETECTION_FAILED:
            #self.scanProcessor.ask({FSEvents.COMMAND:FSCommand.STOP})
            self._logger.info("No Laser detected, returning to settings dialog.")
            #self.scanProcessor.ask({FSEvents.COMMAND:FSCommand.STOP})
            #self.scanProcessor.stop()

            self.set_state(FSState.SETTINGS)
            self.hardwareController.settings_mode_on()

        elif command == FSCommand.MESHING:
            _meshlabTask = FSMeshlabTask(event.scan_id)
            _meshlabTask.start()
            message = FSUtil.new_message()
            message['type'] = FSEvents.ON_INFO_MESSAGE
            message['data']['message'] = "MESHING_STARTED"
            message['data']['level'] = "info"
            self.eventManager.publish(FSEvents.ON_SOCKET_BROADCAST,message)
Exemplo n.º 4
0
    def _on_command(self,mgr, event):

        command = event.command

        ## Start Scan and goto Settings Mode
        if command == FSCommand.SCAN:
            if self._state is FSState.IDLE:
                self.set_state(FSState.SETTINGS)
                self.hardwareController.settings_mode_on()

        ## Update Settings in Settings Mode
        elif command == FSCommand.UPDATE_SETTINGS:
            if self._state is FSState.SETTINGS:
                try:
                    #self._logger.info(event.settings)
                    self.settings.update(event.settings)
                    self.hardwareController.led.on(self.settings.led.red,self.settings.led.green,self.settings.led.blue)
                except:
                    pass

        ## Start Scan Process
        elif command == FSCommand.START:
            if self._state is FSState.SETTINGS:
                self._logger.debug("Start command received...")
                self.set_state(FSState.SCANNING)
                self.hardwareController.settings_mode_off()
                self.scanProcessor = FSScanProcessor.start()
                self.scanProcessor.tell({FSEvents.COMMAND:FSCommand.START})

        ## Stop Scan Process or Stop Settings Mode
        elif command == FSCommand.STOP:

            if self._state is FSState.SCANNING:
                self.scanProcessor.ask({FSEvents.COMMAND:FSCommand.STOP})
                self.scanProcessor.stop()

            if self._state is FSState.SETTINGS:
                self.hardwareController.settings_mode_off()
                #self.scanProcessor.stop()

            self.hardwareController.camera.device.stopStream()
            self.set_state(FSState.IDLE)


        elif command == FSCommand._COMPLETE:
            self.set_state(FSState.IDLE)
            self.hardwareController.camera.device.stopStream()
            #self.scanProcessor.stop()
            self._logger.info("Scan complete")

        elif command == FSCommand._LASER_DETECTION_FAILED:
            #self.scanProcessor.ask({FSEvents.COMMAND:FSCommand.STOP})
            self._logger.info("No Laser detected, returning to settings dialog.")
            #self.scanProcessor.ask({FSEvents.COMMAND:FSCommand.STOP})
            #self.scanProcessor.stop()

            self.set_state(FSState.SETTINGS)
            self.hardwareController.settings_mode_on()

        elif command == FSCommand.MESHING:
            _meshlabTask = FSMeshlabTask(event.scan_id, event.filter, event.format)
            _meshlabTask.start()
            message = FSUtil.new_message()
            message['type'] = FSEvents.ON_INFO_MESSAGE
            message['data']['message'] = "MESHING_STARTED"
            message['data']['level'] = "info"
            self.eventManager.publish(FSEvents.ON_SOCKET_BROADCAST,message)