Пример #1
0
 def prompt_delete_session(self):
     def _on_answer(instance, answer):
         if answer:
             self.dispatch('on_delete_session', self.session_id)
         popup.dismiss()
         
     popup = confirmPopup('Confirm', 'Delete Session {}?'.format(self.name), _on_answer)
Пример #2
0
 def on_delete_channel(self, instance, channel_index):
     popup = None
     def _on_answer(instance, answer):
         if answer:
             self._delete_can_channel(channel_index)
         popup.dismiss()
     popup = confirmPopup('Confirm', 'Delete CAN Channel?', _on_answer)
    def on_channel_selected(self, instance, channel_cfg):
        name = channel_cfg.name
        obd2_preset = self.obd2_preset_settings.obd2channelInfo.get(name)
        if obd2_preset is None:
            return

        # was the existing channel ever customized? this test will determine if the original channel
        # still matches the original preset
        matching_existing_preset = self.obd2_preset_settings.obd2channelInfo.get(self._current_channel_config.name)
        channel_was_customized = not self._current_channel_config.equals(matching_existing_preset)
        popup = None

        def _apply_preset():
            channel_cfg.__dict__.update(obd2_preset.__dict__)
            Clock.schedule_once(lambda dt: HelpInfo.help_popup('obdii_preset_help', self, arrow_pos='left_mid'), 1.0)
            self.load_tabs()

        def _on_answer(instance, answer):
            if answer:
                _apply_preset()
            popup.dismiss()

        if not self._is_new and channel_was_customized:
            popup = confirmPopup('Confirm', 'Apply pre-set values for {}?\n\nAny customizations made to this channel will be over-written.'.format(name), _on_answer)
        elif self._is_new:
            _apply_preset()
Пример #4
0
    def save(self, instance):
        def _do_save_config(filename):
            if not filename.endswith(RCP_CONFIG_FILE_EXTENSION):
                filename += RCP_CONFIG_FILE_EXTENSION
            with open(filename, 'w') as stream:
                configJson = self.rc_config.toJsonString()
                stream.write(configJson)

        self.set_config_file_path(instance.path)
        self.dismiss_popup()
        config_filename = instance.filename
        if len(config_filename):
            try:
                config_filename = os.path.join(instance.path, config_filename)
                if os.path.isfile(config_filename):

                    def _on_answer(instance, answer):
                        if answer:
                            _do_save_config(config_filename)
                        popup.dismiss()

                    popup = confirmPopup('Confirm', 'File Exists - overwrite?',
                                         _on_answer)
                else:
                    _do_save_config(config_filename)
            except Exception as detail:
                alertPopup('Error Saving', 'Failed to save:\n\n' + str(detail))
                Logger.exception('ConfigView: Error Saving config: ' +
                                 str(detail))
 def on_delete_channel(self, instance, channel_index):
     popup = None
     def _on_answer(instance, answer):
         if answer:
             self._delete_can_channel(channel_index)
         popup.dismiss()
     popup = confirmPopup('Confirm', 'Delete CAN Channel?', _on_answer)
Пример #6
0
    def on_channel_selected(self, instance, channel_cfg):
        name = channel_cfg.name
        obd2_preset = self.obd2_preset_settings.obd2channelInfo.get(name)
        if obd2_preset is None:
            return

        # was the existing channel ever customized? this test will determine if the original channel
        # still matches the original preset
        matching_existing_preset = self.obd2_preset_settings.obd2channelInfo.get(self._current_channel_config.name)
        channel_was_customized = not self._current_channel_config.equals(matching_existing_preset)
        popup = None

        def _apply_preset():
            channel_cfg.__dict__.update(obd2_preset.__dict__)
            Clock.schedule_once(lambda dt: HelpInfo.help_popup('obdii_preset_help', self, arrow_pos='left_mid'), 1.0)
            self.load_tabs()

        def _on_answer(instance, answer):
            if answer:
                _apply_preset()
            popup.dismiss()

        if not self._is_new and channel_was_customized:
            popup = confirmPopup('Confirm', 'Apply pre-set values for {}?\n\nAny customizations made to this channel will be over-written.'.format(name), _on_answer)
        else:
            _apply_preset()
Пример #7
0
    def prompt_delete_session(self):
        def _on_answer(instance, answer):
            if answer:
                self.dispatch('on_delete_session', self.session_id)
            popup.dismiss()

        popup = confirmPopup('Confirm', 'Delete Session {}?'.format(self.name),
                             _on_answer)
Пример #8
0
 def first_time_setup(self):
     popup = None 
     def _on_answer(instance, answer):
         popup.dismiss()
         if answer:
             self.showMainView('tracks')
             Clock.schedule_once(lambda dt: self.mainViews['tracks'].check_for_update(), 0.5)
     popup = confirmPopup('Race Tracks', 'Looks like this is your first time running.\n\nShould I update the Race Track database?', _on_answer)
     self.settings.userPrefs.set_pref('preferences', 'first_time_setup', False)
Пример #9
0
 def first_time_setup(self):
     popup = None 
     def _on_answer(instance, answer):
         popup.dismiss()
         if answer:
             self.showMainView('tracks')
             Clock.schedule_once(lambda dt: self.mainViews['tracks'].check_for_update(), 0.5)
     popup = confirmPopup('Race Tracks', 'Looks like this is your first time running.\n\nShould I update the Race Track database?', _on_answer)
     self.settings.userPrefs.set_pref('preferences', 'first_time_setup', False)
Пример #10
0
    def delete_session(self, *args):
        popup = None

        def confirm_delete(instance, delete):
            if delete:
                self.dispatch('on_delete')
            popup.dismiss()

        popup = confirmPopup("Delete", "Are you sure you sure you want to delete session '{}'?".format(self.session.name),
                             confirm_delete)
    def update_pre_check(self):

        popup = None
        def _on_answer(inst, answer):
            popup.dismiss()
            if answer == True:
                self._select_file()
        popup = confirmPopup('Ready to update firmware',
                             'Please ensure your configuration is saved before continuing\n',
                             _on_answer)
Пример #12
0
 def readConfig(self):
     if self.writeStale == True:
         popup = None
         def _on_answer(instance, answer):
             if answer:
                 self.dispatch('on_read_config', None)
             popup.dismiss()
         popup = confirmPopup('Confirm', 'Configuration Modified  - Continue Loading?', _on_answer)
     else:
         self.dispatch('on_read_config', None)
Пример #13
0
 def openConfig(self):
     if self.writeStale:
         popup = None
         def _on_answer(instance, answer):
             if answer:
                 self.doOpenConfig()
             popup.dismiss()
         popup = confirmPopup('Confirm', 'Configuration Modified  - Open Configuration?', _on_answer)
     else:
         self.doOpenConfig()
Пример #14
0
    def on_set_start_point(self, *args):
        popup = None
        def confirm_restart(instance, restart):
            if restart:
                self._start_new_track()
            popup.dismiss()

        if len(self._track.map_points) > 1 and self._track.start_finish_point is not None:
            popup = confirmPopup("Restart", "Restart Track Map?", confirm_restart)
        else:
            self._start_new_track()
Пример #15
0
    def delete_session(self, *args):
        popup = None

        def confirm_delete(instance, delete):
            if delete:
                self.dispatch('on_delete')
            popup.dismiss()

        popup = confirmPopup(
            "Delete",
            "Are you sure you sure you want to delete session '{}'?".format(
                self.session.name), confirm_delete)
Пример #16
0
    def _validate_finish(self):
        def confirm_minimal_track(instance, confirm):
            if confirm:
                self._process_finish(force=True)
            popup.dismiss()

        if (self._track_type == TrackTypeSelectorScreen.TRACK_TYPE_CIRCUIT and
                self.current_point.dist_pythag(self._track.start_finish_point) < TrackMapCreatorScreen.MINIMUM_TARGET_SEPARATION_METERS):
            popup = confirmPopup("Confirm", "There's no track map - create a minimal track with just start/finish defined?", confirm_minimal_track)
            return False

        return True
 def _prompt_manual_bootloader_mode(self, instance):
     popup = None
     def _on_answer(inst, answer):
         popup.dismiss()
         if answer == True:
             self._start_update_fw(instance)
         else:
             self._restart_json_serial()                
     popup = confirmPopup('Enable Bootloader Mode',
                          '1. Disconnect 12v power\n2. Unplug RaceCapture from USB\n' \
                          '3. Wait 3 seconds\n4. While holding front panel button, re-connect USB',
                          _on_answer)
Пример #18
0
        def _export_session(instance):

            def _do_export_session(filename):

                _do_export_session.cancelled = False

                def _progress_cb(pct):
                    if _do_export_session.cancelled == True:
                        return True
                    Clock.schedule_once(lambda dt: prog_popup.content.update_progress(pct))
                    return False

                def _progress_ok_cancel(instance, answer):
                    _do_export_session.cancelled = True
                    Clock.schedule_once(lambda dt: prog_popup.dismiss(), 2.0 if instance.progress < 100 else 0.0)

                def _export_complete(title, text):
                    progress = prog_popup.content
                    progress.title = title
                    progress.text = text
                    progress.progress = 100

                def _export_session_worker(filename, session_id, progress_cb):
                    try:
                        export_file = open(filename, 'w')
                        with export_file:
                            records = self._datastore.export_session(session_id, export_file, progress_cb)
                            Clock.schedule_once(lambda dt: _export_complete('Export complete', '{} samples exported'.format(records)))
                            Clock.schedule_once(lambda dt: self._settings.userPrefs.set_pref('preferences', 'export_file_dir', os.path.dirname(filename)))
                    except Exception as e:
                        Logger.error('AnalysisView: Error exporting: {}'.format(e))
                        Logger.error(traceback.format_exc())
                        Clock.schedule_once(lambda dt: _export_complete('Error Exporting',
                            "There was an error exporting the session. Please check the destination and file name\n\n{}".format(e)))

                export_popup.dismiss()

                prog_popup = progress_popup('Exporting session', 'Exporting Session', _progress_ok_cancel)
                t = Thread(target=_export_session_worker, args=(filename, session.session_id, _progress_cb))
                t.daemon = True
                t.start()

            filename = os.path.join(instance.path, instance.filename)
            if not filename.endswith(RC_LOG_FILE_EXTENSION): filename += RC_LOG_FILE_EXTENSION
            if os.path.isfile(filename):
                def _on_overwrite_answer(instance, answer):
                    if answer:
                        _do_export_session(filename)
                    ow_popup.dismiss()
                ow_popup = confirmPopup('Confirm', 'File Exists - overwrite?', _on_overwrite_answer)
            else:
                _do_export_session(filename)
    def update_pre_check(self):

        popup = None

        def _on_answer(inst, answer):
            popup.dismiss()
            if answer == True:
                self._select_file()

        popup = confirmPopup(
            'Ready to update firmware',
            'Please ensure your configuration is saved before continuing\n',
            _on_answer)
Пример #20
0
    def _on_delete_action(self, instance, action):
        popup = None

        def confirm_delete(instance, delete):
            if delete:
                actions = self.alertrule.alert_actions
                actions.remove(action)
                self.refresh_view()
            popup.dismiss()

        popup = confirmPopup('Delete',
                             'Delete Action {}?'.format(action.title),
                             confirm_delete)
    def _prompt_manual_bootloader_mode(self, instance):
        popup = None

        def _on_answer(inst, answer):
            popup.dismiss()
            if answer == True:
                self._start_update_fw(instance)
            else:
                self._restart_json_serial()
        popup = confirmPopup('Enable Bootloader Mode',
                             '1. Disconnect 12v power\n2. Unplug RaceCapture from USB\n' \
                             '3. Wait 3 seconds\n4. While holding front panel button, re-connect USB',
                             _on_answer)
Пример #22
0
    def on_set_start_point(self, *args):
        popup = None

        def confirm_restart(instance, restart):
            if restart:
                self._start_new_track()
            popup.dismiss()

        if len(self._track.map_points
               ) > 1 and self._track.start_finish_point is not None:
            popup = confirmPopup("Restart", "Restart Track Map?",
                                 confirm_restart)
        else:
            self._start_new_track()
Пример #23
0
    def _validate_finish(self):
        def confirm_minimal_track(instance, confirm):
            if confirm:
                self._process_finish(force=True)
            popup.dismiss()

        if (self._track_type == TrackTypeSelectorScreen.TRACK_TYPE_CIRCUIT and
                self.current_point.dist_pythag(self._track.start_finish_point)
                < TrackMapCreatorScreen.MINIMUM_TARGET_SEPARATION_METERS):
            popup = confirmPopup(
                "Confirm",
                "There's no track map - create a minimal track with just start/finish defined?",
                confirm_minimal_track)
            return False

        return True
Пример #24
0
    def _on_delete_rule(self, instance, value):

        popup = None

        def confirm_delete(instance, delete):
            if delete:
                rules = self.alertrule_collection.alert_rules
                rules.remove(value)
                self.refresh_view()
            popup.dismiss()

        high = value.high_threshold
        low = value.low_threshold
        symbol = '-' if high and low else '->'
        popup = confirmPopup(
            'Delete',
            'Delete Group {} {} {}?'.format('' if low is None else low, symbol,
                                            '' if high is None else high),
            confirm_delete)
Пример #25
0
    def save(self, instance):
        def _do_save_config(filename):
            if not filename.endswith(RCP_CONFIG_FILE_EXTENSION): filename += RCP_CONFIG_FILE_EXTENSION
            with open(filename, 'w') as stream:
                configJson = self.rc_config.toJsonString()
                stream.write(configJson)

        self.set_config_file_path(instance.path)
        self.dismiss_popup()
        config_filename = instance.filename
        if len(config_filename):
            try:
                config_filename = os.path.join(instance.path, config_filename)
                if os.path.isfile(config_filename):
                    def _on_answer(instance, answer):
                        if answer:
                            _do_save_config(config_filename)
                        popup.dismiss()
                    popup = confirmPopup('Confirm', 'File Exists - overwrite?', _on_answer)
                else:
                    _do_save_config(config_filename)
            except Exception as detail:
                alertPopup('Error Saving', 'Failed to save:\n\n' + str(detail))
                Logger.exception('ConfigView: Error Saving config: ' + str(detail))
Пример #26
0
 def _skip_request(self):
     def confirm_skip(instance, skip):
         popup.dismiss()
         self._setup_complete(skip)
     popup = confirmPopup('Skip', 'Continue setup next time?', confirm_skip)
Пример #27
0
 def _skip_request(self):
     def confirm_skip(instance, skip):
         popup.dismiss()
         self._setup_complete(skip)
     popup = confirmPopup('Skip', 'Continue setup next time?', confirm_skip)