From 94b16c3ab8fe9e5bb0a14a7c921113749d1ac1aa Mon Sep 17 00:00:00 2001 From: cobra18t Date: Mon, 3 Jul 2023 12:04:43 -0700 Subject: [PATCH 1/5] Update config_spec.yaml for dynamic spped in show_player --- mpf/config_spec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mpf/config_spec.yaml b/mpf/config_spec.yaml index 58265e27d..5dba0768c 100644 --- a/mpf/config_spec.yaml +++ b/mpf/config_spec.yaml @@ -1543,7 +1543,7 @@ show_player: action: single|enum(play,stop,pause,resume,advance,step_back,update,queue)|play show: single|str|None priority: single|int_or_token|0 - speed: single|float_or_token|1 + speed: single|template_float_or_token|1 block_queue: single|bool|false start_step: single|template_int|1 start_running: single|template_bool|True From fb7891cce7da3a97fcb4a97cccfa8b667a638c31 Mon Sep 17 00:00:00 2001 From: cobra18t Date: Mon, 3 Jul 2023 12:06:04 -0700 Subject: [PATCH 2/5] Update config_validator.py adding template_float_or_token type --- mpf/core/config_validator.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mpf/core/config_validator.py b/mpf/core/config_validator.py index e933f1aa0..0879cdacc 100644 --- a/mpf/core/config_validator.py +++ b/mpf/core/config_validator.py @@ -56,6 +56,7 @@ def __init__(self, machine, config_spec): "lstr": self._validate_type_lstr, "float": self._validate_type_float, "float_or_token": self._validate_type_or_token(self._validate_type_float), + "template_float_or_token": self._validate_type_or_token(self._validate_type_template_float), "int": self._validate_type_int, "int_or_token": self._validate_type_or_token(self._validate_type_int), "num": self._validate_type_num, @@ -454,7 +455,7 @@ def _validate_type_template_str(self, item, validation_failure_info): return self.machine.placeholder_manager.build_quoted_string_template(item) - def _validate_type_template_float(self, item, validation_failure_info): + def _validate_type_template_float(self, item, validation_failure_info, param=None): if item is None: return None if not isinstance(item, (str, float, int)): From cc39edd79c674369f3943461dd197b5c489d3a61 Mon Sep 17 00:00:00 2001 From: cobra18t Date: Mon, 3 Jul 2023 12:07:59 -0700 Subject: [PATCH 3/5] Update sequence_shot.py to record elapsed time to completion --- mpf/devices/sequence_shot.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/mpf/devices/sequence_shot.py b/mpf/devices/sequence_shot.py index ec8380092..f9c8093ad 100644 --- a/mpf/devices/sequence_shot.py +++ b/mpf/devices/sequence_shot.py @@ -21,7 +21,7 @@ class SequenceShot(SystemWideDevice, ModeDevice): collection = 'sequence_shots' class_label = 'sequence_shot' - __slots__ = ["delay", "active_sequences", "active_delays", "_sequence_events", "_delay_events"] + __slots__ = ["delay", "active_sequences", "active_delays", "_sequence_events", "_delay_events", "_start_time"] def __init__(self, machine, name): """Initialise sequence shot.""" @@ -33,6 +33,7 @@ def __init__(self, machine, name): self._sequence_events = [] # type: List[str] self._delay_events = {} # type: Dict[str, int] + self._start_time = None @property def can_exist_outside_of_game(self): @@ -131,6 +132,9 @@ def _start_new_sequence(self): self.active_delays) return + #record start time + self._start_time = self.machine.clock.get_time() + # create a new sequence seq_id = uuid.uuid4() next_event = self._sequence_events[1] @@ -169,8 +173,11 @@ def _advance_sequence(self, sequence: ActiveSequence): self.active_sequences.append(ActiveSequence(sequence.id, current_position_index, next_event)) def _completed(self): - """Post sequence complete event.""" - self.machine.events.post("{}_hit".format(self.name)) + #measure the elapsed time between start and completion of the sequence + elapsed = self.machine.clock.get_time() - self._start_time + + """Post sequence complete event including its elapsed time to complete.""" + self.machine.events.post("{}_hit".format(self.name),elapsed=elapsed) '''event: (name)_hit desc: The sequence_shot called (name) was just completed. ''' From a174df4f94a1f958e9bda36c65b1ee9879ccb4a6 Mon Sep 17 00:00:00 2001 From: cobra18t Date: Tue, 4 Jul 2023 10:16:26 -0700 Subject: [PATCH 4/5] Update show_player.py for template_float --- mpf/config_players/show_player.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mpf/config_players/show_player.py b/mpf/config_players/show_player.py index ed1693453..3137ffb6d 100644 --- a/mpf/config_players/show_player.py +++ b/mpf/config_players/show_player.py @@ -102,9 +102,10 @@ def _play(self, key, instance_dict, show, show_settings, queue, start_time, plac start_step = show_settings['start_step'].evaluate(placeholder_args) start_running = show_settings['start_running'].evaluate(placeholder_args) show_tokens = {k: v.evaluate(placeholder_args) for k, v in show_settings['show_tokens'].items()} + speed = show_settings['speed'].evaluate(placeholder_args) show_config = self.machine.show_controller.create_show_config( - show, show_settings['priority'], show_settings['speed'], show_settings['loops'], show_settings['sync_ms'], + show, show_settings['priority'], speed, show_settings['loops'], show_settings['sync_ms'], show_settings['manual_advance'], show_tokens, show_settings['events_when_played'], show_settings['events_when_stopped'], show_settings['events_when_looped'], show_settings['events_when_paused'], show_settings['events_when_resumed'], @@ -128,9 +129,10 @@ def _queue(self, key, instance_dict, show, show_settings, queue, start_time, pla start_step = show_settings['start_step'].evaluate(placeholder_args) show_tokens = {k: v.evaluate(placeholder_args) for k, v in show_settings['show_tokens'].items()} + speed = show_settings['speed'].evaluate(placeholder_args) show_config = self.machine.show_controller.create_show_config( - show, show_settings['priority'], show_settings['speed'], show_settings['loops'], show_settings['sync_ms'], + show, show_settings['priority'], speed, show_settings['loops'], show_settings['sync_ms'], show_settings['manual_advance'], show_tokens, show_settings['events_when_played'], show_settings['events_when_stopped'], show_settings['events_when_looped'], show_settings['events_when_paused'], show_settings['events_when_resumed'], From d1c3ff77d1be7f64463c567df6fd0182ad7bb5b6 Mon Sep 17 00:00:00 2001 From: cobra18t Date: Tue, 4 Jul 2023 10:33:27 -0700 Subject: [PATCH 5/5] Update sequence_shot.py to handle a single step sequence --- mpf/devices/sequence_shot.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mpf/devices/sequence_shot.py b/mpf/devices/sequence_shot.py index f9c8093ad..d7a554df1 100644 --- a/mpf/devices/sequence_shot.py +++ b/mpf/devices/sequence_shot.py @@ -174,7 +174,10 @@ def _advance_sequence(self, sequence: ActiveSequence): def _completed(self): #measure the elapsed time between start and completion of the sequence - elapsed = self.machine.clock.get_time() - self._start_time + if self._start_time is not None: + elapsed = self.machine.clock.get_time() - self._start_time + else: + elapsed = 0 """Post sequence complete event including its elapsed time to complete.""" self.machine.events.post("{}_hit".format(self.name),elapsed=elapsed)