Skip to content

Commit

Permalink
Merge pull request #1540 from OpenC3/line_delay
Browse files Browse the repository at this point in the history
SR line delay menu option and log line delay changes
  • Loading branch information
ryanmelt authored Sep 18, 2024
2 parents a467d70 + 676b2df commit b6e77d0
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,27 @@ export default {
this.editor.execCommand('replace')
},
},
{
label: 'Set Line Delay',
icon: 'mdi-invoice-text-clock',
disabled: this.scriptId,
command: () => {
this.$dialog.open({
title: 'Info',
text:
'You can set the line delay in seconds using the api method set_line_delay().<br/><br/>' +
'The default line delay is 0.1 seconds between lines. ' +
'Adding set_line_delay(0) to the top of your script will execute the script at maximum speed. ' +
'However, this can make it difficult to see and pause the script. ' +
'Executing set_line_delay(1) will cause a 1 second delay between lines.',
okText: 'OK',
okClass: 'primary',
validateText: null,
cancelText: null,
html: true,
})
},
},
],
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,9 @@ export default {
(this.valueId.includes('PACKET_TIMEFORMATTED') ||
this.valueId.includes('RECEIVED_TIMEFORMATTED'))
) {
// Our dates have / rather than - which results in an invalid date on old browsers
// when they call new Date(value)
value = value.replaceAll('/', '-')
return this.formatUtcToLocal(new Date(value), this.timeZone)
}
// Convert json raw strings into the raw bytes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1107,6 +1107,7 @@ def run_text(text,
unless close_on_complete
output = "Starting script: #{File.basename(@filename)}"
output += " in DISCONNECT mode" if $disconnect
output += ", line_delay = #{@@line_delay}"
scriptrunner_puts(output)
end
handle_output_io()
Expand Down
1 change: 1 addition & 0 deletions openc3-cosmos-script-runner-api/scripts/running_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -953,6 +953,7 @@ def run_thread_body(
output = f"Starting script: {os.path.basename(self.filename)}"
if RunningScript.disconnect:
output += " in DISCONNECT mode"
output += f", line_delay = {RunningScript.line_delay}"
self.scriptrunner_puts(output)
self.handle_output_io()

Expand Down
5 changes: 3 additions & 2 deletions openc3/lib/openc3/script/api_shared.rb
Original file line number Diff line number Diff line change
Expand Up @@ -461,8 +461,9 @@ def disable_instrumentation
end

def set_line_delay(delay)
if defined? RunningScript
RunningScript.line_delay = delay if delay >= 0.0
if defined? RunningScript and delay >= 0.0
RunningScript.line_delay = delay
puts "set_line_delay(#{delay})"
end
end

Expand Down
1 change: 1 addition & 0 deletions openc3/python/openc3/script/api_shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,7 @@ def disable_instrumentation():
def set_line_delay(delay):
if openc3.script.RUNNING_SCRIPT and delay >= 0.0:
openc3.script.RUNNING_SCRIPT.line_delay = delay
print(f"set_line_delay({delay})")


def get_line_delay():
Expand Down

0 comments on commit b6e77d0

Please sign in to comment.