Sha256: e2fdba832db9343653ae9cf21016bdde58bcbda1487201f60516f9dc90e5fc14

Contents?: true

Size: 1.09 KB

Versions: 3

Compression:

Stored size: 1.09 KB

Contents

module Qcmd
  class Context
    attr_accessor :machine, :workspace, :workspace_connected, :cue, :cue_connected, :qlab

    def reset
      disconnect_machine
      disconnect_workspace
      disconnect_cue
    end

    def disconnect_machine
      self.qlab.close unless self.qlab.nil?
      self.machine = nil
    end

    def disconnect_workspace
      self.workspace = nil
      self.workspace_connected = false
    end

    def disconnect_cue
      self.cue = nil
      self.cue_connected = false
    end

    def machine_connected?
      !machine.nil?
    end

    def workspace_connected?
      !!workspace_connected
    end

    def cue_connected?
      !!cue_connected
    end

    def connection_state
      if !machine_connected?
        :none
      elsif !workspace_connected?
        :machine
      elsif !cue_connected?
        :workspace
      else
        :cue
      end
    end

    def connect_to_qlab handler=nil
      # get an open connection with the default handler
      handler ||= Qcmd::Handler
      self.qlab = OSC::TCP::Client.new(machine.address, machine.port, handler)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
qcmd-0.2.0 lib/qcmd/context.rb
qcmd-0.1.16 lib/qcmd/context.rb
qcmd-0.1.16.pre2 lib/qcmd/context.rb