Module: Qcmd::Commands

Defined in:
lib/qcmd/commands.rb

Defined Under Namespace

Modules: Help

Constant Summary collapse

NO_MACHINE_RESPONSE =

All Commands

*_RESPONSE lists are commands that expect responses

%w(connect)
MACHINE_RESPONSE =
%w(workspaces)
WORKSPACE_RESPONSE =
%w(
  cueLists selectedCues runningCues runningOrPausedCues thump
)
WORKSPACE_NO_RESPONSE =
%w(
  go stop pause resume reset panic
)
ALL_WORKSPACE_COMMANDS =
[WORKSPACE_RESPONSE + WORKSPACE_NO_RESPONSE]
CUE_NO_RESPONSE =

commands that take no args and do not respond

%w(
  start stop pause resume load preview reset panic
)
CUE_ARG_NO_RESPONSE =

commands that take args but do not respond

%w(
  loadAt
)
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 take args but expect a response if given without args

%w(
  number name notes cueTargetNumber cueTargetId preWait duration
  postWait continueMode flagged armed colorName
  sliderLevel
)
CUE_ARG =

all cue commands that take arguments

CUE_ARG_NO_RESPONSE + NO_ARG_CUE_RESPONSE
ALL_CUE_COMMANDS =
CUE_NO_RESPONSE +
CUE_ARG_NO_RESPONSE +
CUE_RESPONSE +
NO_ARG_CUE_RESPONSE

Class Method Summary collapse

Class Method Details

.cue_no_arg_response_match(command) ⇒ Object



90
91
92
# File 'lib/qcmd/commands.rb', line 90

def cue_no_arg_response_match command
  !!(cue_no_arg_response_matcher =~ command)
end

.cue_no_arg_response_matcherObject



87
88
89
# File 'lib/qcmd/commands.rb', line 87

def cue_no_arg_response_matcher
  @cue_no_arg_response_matcher ||= %r[(#{NO_ARG_CUE_RESPONSE.join('|') })]
end

.cue_response_match(command) ⇒ Object



83
84
85
# File 'lib/qcmd/commands.rb', line 83

def cue_response_match command
  !!(cue_response_matcher =~ command)
end

.cue_response_matcherObject



80
81
82
# File 'lib/qcmd/commands.rb', line 80

def cue_response_matcher
  @cue_response_matcher ||= %r[(#{CUE_RESPONSE.join('|') })]
end

.expects_reply?(osc_message) ⇒ Boolean

Returns:

  • (Boolean)


94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# File 'lib/qcmd/commands.rb', line 94

def expects_reply? osc_message
  address = osc_message.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 = no_machine_response_match(address)
  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 osc_message.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

Returns:

  • (Boolean)


134
135
136
# File 'lib/qcmd/commands.rb', line 134

def is_cue_command? address
  /cue/ =~ address && !(/Lists/ =~ address || /Cues/ =~ address)
end

.is_workspace_command?(address) ⇒ Boolean

Returns:

  • (Boolean)


138
139
140
# File 'lib/qcmd/commands.rb', line 138

def is_workspace_command? address
  /workspace/ =~ address && !(%r[cue/] =~ address || %r[cue_id/] =~ address)
end

.machine_response_match(command) ⇒ Object



69
70
71
# File 'lib/qcmd/commands.rb', line 69

def machine_response_match command
  !!(machine_response_matcher =~ command)
end

.machine_response_matcherObject



66
67
68
# File 'lib/qcmd/commands.rb', line 66

def machine_response_matcher
  @machine_response_matcher ||= %r[(#{MACHINE_RESPONSE.join('|')})]
end

.no_machine_response_match(command) ⇒ Object



62
63
64
# File 'lib/qcmd/commands.rb', line 62

def no_machine_response_match command
  !!(no_machine_response_matcher =~ command)
end

.no_machine_response_matcherObject



59
60
61
# File 'lib/qcmd/commands.rb', line 59

def no_machine_response_matcher
  @no_machine_response_matcher ||= %r[(#{NO_MACHINE_RESPONSE.join('|')})]
end

.workspace_response_match(command) ⇒ Object



76
77
78
# File 'lib/qcmd/commands.rb', line 76

def workspace_response_match command
  !!(workspace_response_matcher =~ command)
end

.workspace_response_matcherObject



73
74
75
# File 'lib/qcmd/commands.rb', line 73

def workspace_response_matcher
  @workspace_response_matcher ||= %r[(#{WORKSPACE_RESPONSE.join('|')})]
end