Example #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.scanProcessor.tell({FSEvents.COMMAND: FSScanProcessorCommand.SETTINGS_MODE_ON})

        ## Update Settings in Settings Mode
        elif command == FSCommand.UPDATE_SETTINGS:
            if self._state is FSState.SETTINGS:
                self.scanProcessor.tell(
                        {FSEvents.COMMAND: FSScanProcessorCommand.UPDATE_SETTINGS, 'SETTINGS': event.settings})

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

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

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

            if self._state is FSState.SETTINGS:
                self._logger.debug("Close Settings")
                self.scanProcessor.tell({FSEvents.COMMAND: FSScanProcessorCommand.SETTINGS_MODE_OFF})

            self.set_state(FSState.IDLE)

        elif command == FSCommand.CALIBRATE:
           self._logger.debug("Calibration started....")
           self.scanProcessor.tell({FSEvents.COMMAND: FSScanProcessorCommand.CALIBRATE_SCANNER})

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

        # Internal error occured
        elif command == FSCommand.SCANNER_ERROR:
            self._logger.info("Internal Scanner Error.")
            self.set_state(FSState.SETTINGS)

        # Meshing
        elif command == FSCommand.MESHING:
            meshlab_task = FSMeshlabTask(event.scan_id, event.filter, event.format)
            meshlab_task.start()
Example #2
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)
Example #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, 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)
Example #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.scanProcessor.tell({
                    FSEvents.COMMAND:
                    FSScanProcessorCommand.SETTINGS_MODE_ON
                })

        ## Update Settings in Settings Mode
        elif command == FSCommand.UPDATE_SETTINGS:
            if self._state is FSState.SETTINGS:
                self.scanProcessor.tell({
                    FSEvents.COMMAND:
                    FSScanProcessorCommand.UPDATE_SETTINGS,
                    'SETTINGS':
                    event.settings
                })

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

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

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

            if self._state is FSState.SETTINGS:
                self._logger.debug("Close Settings")
                self.scanProcessor.tell({
                    FSEvents.COMMAND:
                    FSScanProcessorCommand.SETTINGS_MODE_OFF
                })

            self.set_state(FSState.IDLE)

        elif command == FSCommand.CALIBRATE:
            self._logger.debug("Calibration started....")
            self.scanProcessor.tell(
                {FSEvents.COMMAND: FSScanProcessorCommand.CALIBRATE_SCANNER})

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

        # Internal error occured
        elif command == FSCommand.SCANNER_ERROR:
            self._logger.info("Internal Scanner Error.")
            self.set_state(FSState.SETTINGS)

        # Meshing
        elif command == FSCommand.MESHING:
            meshlab_task = FSMeshlabTask(event.scan_id, event.filter,
                                         event.format)
            meshlab_task.start()
Example #5
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.scanProcessor.tell({FSEvents.COMMAND: FSScanProcessorCommand.SETTINGS_MODE_ON})

        ## Update Settings in Settings Mode
        elif command == FSCommand.UPDATE_SETTINGS:
            if self._state is FSState.SETTINGS:
                self.scanProcessor.tell(
                        {FSEvents.COMMAND: FSScanProcessorCommand.UPDATE_SETTINGS, 'SETTINGS': event.settings})

        ## Start Scan Process
        elif command == FSCommand.START:
            if self._state is FSState.SETTINGS:
                self._logger.info("Start command received...")
                # FIXME: ( or find better solution )
                # needed to be done here, cause raspberry has not a real time clock,
                # when no internet connection is availabale on the fabscan the time
                # will be set (default) to 1970, this leads to a wrong calculation
                self.settings.startTime = event.startTime

                self.set_state(FSState.SCANNING)
                self.scanProcessor.tell({FSEvents.COMMAND: FSScanProcessorCommand.START})

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

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

            if self._state is FSState.SETTINGS:
                self._logger.debug("Close Settings")
                self.scanProcessor.tell({FSEvents.COMMAND: FSScanProcessorCommand.SETTINGS_MODE_OFF})

            if self._state is FSState.CALIBRATING:
                self.scanProcessor.ask({FSEvents.COMMAND: FSScanProcessorCommand.STOP_CALIBRATION})

            self.set_state(FSState.IDLE)

        # Start calibration
        elif command == FSCommand.CALIBRATE:
            self._logger.debug("Calibration started....")
            self.settings.startTime = event.startTime
            self.set_state(FSState.CALIBRATING)
            self.scanProcessor.tell({FSEvents.COMMAND: FSScanProcessorCommand.START_CALIBRATION})

        elif command == FSCommand.CALIBRATION_COMPLETE:
            self.set_state(FSState.IDLE)

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

        # Internal error occured
        elif command == FSCommand.SCANNER_ERROR:
            self._logger.info("Internal Scanner Error.")
            self.set_state(FSState.SETTINGS)

        # Meshing
        elif command == FSCommand.MESHING:
            meshlab_task = FSMeshlabTask(event.scan_id, event.filter, event.format)
            meshlab_task.start()

        # Upgrade server
        elif command == FSCommand.UPGRADE_SERVER:
            if self._upgrade_available:
                self._logger.info("Upgrade server")
                self.set_state(FSState.UPGRADING)