Module: Qcmd::Commands
- Defined in:
- lib/qcmd/commands.rb
Constant Summary collapse
- MACHINE_RESPONSE =
Commands that expect reponses
%w(workspaces)
- WORKSPACE_RESPONSE =
%w( cueLists selectedCues runningCues runningOrPausedCues connect thump )
- CUE_RESPONSE =
commands that always expect a response
%w( uniqueID hasFileTargets hasCueTargets allowsEditingDuration isLoaded isRunning isPaused isBroken preWaitElapsed actionElapsed postWaitElapsed percentPreWaitElapsed percentActionElapsed percentPostWaitElapsed type sliderLevels basics children )
- NO_ARG_CUE_RESPONSE =
commands that expect a response if given without args
%w( number name notes cueTargetNumber cueTargetId preWait duration postWait continueMode flagged armed colorName sliderLevel )
Class Method Summary collapse
- .cue_no_arg_response_match(command) ⇒ Object
- .cue_no_arg_response_matcher ⇒ Object
- .cue_response_match(command) ⇒ Object
- .cue_response_matcher ⇒ Object
- .expects_reply?(osc_message) ⇒ Boolean
- .is_cue_command?(address) ⇒ Boolean
- .is_workspace_command?(address) ⇒ Boolean
- .machine_response_match(command) ⇒ Object
- .machine_response_matcher ⇒ Object
- .workspace_response_match(command) ⇒ Object
- .workspace_response_matcher ⇒ Object
Class Method Details
.cue_no_arg_response_match(command) ⇒ Object
51 52 53 |
# File 'lib/qcmd/commands.rb', line 51 def cue_no_arg_response_match command !!(cue_no_arg_response_matcher =~ command) end |
.cue_no_arg_response_matcher ⇒ Object
48 49 50 |
# File 'lib/qcmd/commands.rb', line 48 def cue_no_arg_response_matcher @cue_no_arg_response_matcher ||= %r[(#{NO_ARG_CUE_RESPONSE.join('|') })] end |
.cue_response_match(command) ⇒ Object
44 45 46 |
# File 'lib/qcmd/commands.rb', line 44 def cue_response_match command !!(cue_response_matcher =~ command) end |
.cue_response_matcher ⇒ Object
41 42 43 |
# File 'lib/qcmd/commands.rb', line 41 def cue_response_matcher @cue_response_matcher ||= %r[(#{CUE_RESPONSE.join('|') })] end |
.expects_reply?(osc_message) ⇒ Boolean
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/qcmd/commands.rb', line 55 def expects_reply? address = .address Qcmd.debug "(check #{address} for reply expectation in connection state #{Qcmd.context.connection_state})" # debugger case Qcmd.context.connection_state when :none # shouldn't be dealing with OSC messages when unconnected to # machine or workspace response = false when :machine # could be workspace or machine command response = machine_response_match(address) || workspace_response_match(address) when :workspace if is_cue_command?(address) Qcmd.debug "- (checking cue command)" if .has_arguments? Qcmd.debug "- (with arguments)" response = cue_response_match address else Qcmd.debug "- (without arguments)" response = cue_no_arg_response_match(address) || cue_response_match(address) end else Qcmd.debug "- (checking workspace command)" response = workspace_response_match(address) || machine_response_match(address) end end response.tap {|value| msg = value ? "EXPECT REPLY" : "do not expect reply" Qcmd.debug "- (#{ msg })" } end |
.is_cue_command?(address) ⇒ Boolean
95 96 97 |
# File 'lib/qcmd/commands.rb', line 95 def is_cue_command? address /cue/ =~ address && !(/Lists/ =~ address || /Cues/ =~ address) end |
.is_workspace_command?(address) ⇒ Boolean
99 100 101 |
# File 'lib/qcmd/commands.rb', line 99 def is_workspace_command? address /workspace/ =~ address && !(%r[cue/] =~ address || %r[cue_id/] =~ address) end |
.machine_response_match(command) ⇒ Object
30 31 32 |
# File 'lib/qcmd/commands.rb', line 30 def machine_response_match command !!(machine_response_matcher =~ command) end |
.machine_response_matcher ⇒ Object
27 28 29 |
# File 'lib/qcmd/commands.rb', line 27 def machine_response_matcher @machine_response_matcher ||= %r[(#{MACHINE_RESPONSE.join('|')})] end |
.workspace_response_match(command) ⇒ Object
37 38 39 |
# File 'lib/qcmd/commands.rb', line 37 def workspace_response_match command !!(workspace_response_matcher =~ command) end |
.workspace_response_matcher ⇒ Object
34 35 36 |
# File 'lib/qcmd/commands.rb', line 34 def workspace_response_matcher @workspace_response_matcher ||= %r[(#{WORKSPACE_RESPONSE.join('|')})] end |