Sha256: faabde753f6deac5ca986226af90f59a99c6add34e01d3efe3c9d577b347b553

Contents?: true

Size: 1.09 KB

Versions: 9

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::TCPClient.new(machine.address, machine.port, handler)
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
qcmd-0.1.16.pre lib/qcmd/context.rb
qcmd-0.1.15 lib/qcmd/context.rb
qcmd-0.1.14 lib/qcmd/context.rb
qcmd-0.1.13 lib/qcmd/context.rb
qcmd-0.1.12 lib/qcmd/context.rb
qcmd-0.1.11 lib/qcmd/context.rb
qcmd-0.1.10 lib/qcmd/context.rb
qcmd-0.1.9 lib/qcmd/context.rb
qcmd-0.1.8 lib/qcmd/context.rb