Class: Sappho::Heatmiser::Proxy::CommandQueue
- Inherits:
-
Object
- Object
- Sappho::Heatmiser::Proxy::CommandQueue
- Includes:
- LogUtilities, Singleton
- Defined in:
- lib/sappho-heatmiser-proxy/command_queue.rb
Instance Method Summary collapse
- #completed ⇒ Object
- #get ⇒ Object
-
#initialize ⇒ CommandQueue
constructor
A new instance of CommandQueue.
- #push(clientIP, command) ⇒ Object
- #refreshRequested? ⇒ Boolean
- #refreshStatus(clientIP) ⇒ Object
Constructor Details
#initialize ⇒ CommandQueue
Returns a new instance of CommandQueue.
18 19 20 21 22 23 |
# File 'lib/sappho-heatmiser-proxy/command_queue.rb', line 18 def initialize @refreshRequested = false @queue = [] @mutex = Mutex.new @log = Sappho::ApplicationAutoFlushLog.instance end |
Instance Method Details
#completed ⇒ Object
62 63 64 65 66 67 68 69 70 |
# File 'lib/sappho-heatmiser-proxy/command_queue.rb', line 62 def completed @mutex.synchronize do if @queue.size > 0 queue = @queue[0] @log.info "client #{queue[:clientIP]} command completed: #{hexString queue[:command]}" @queue.shift end end end |
#get ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/sappho-heatmiser-proxy/command_queue.rb', line 50 def get command = nil @mutex.synchronize do if @queue.size > 0 queue = @queue[0] command = queue[:command].dup @log.info "client #{queue[:clientIP]} command executing: #{hexString command}" end end command end |
#push(clientIP, command) ⇒ Object
40 41 42 43 44 45 46 47 48 |
# File 'lib/sappho-heatmiser-proxy/command_queue.rb', line 40 def push clientIP, command @log.info "client #{clientIP} requests command: #{hexString command}" @mutex.synchronize do @queue << { :clientIP => clientIP, :command => command.dup } end end |
#refreshRequested? ⇒ Boolean
32 33 34 35 36 37 38 |
# File 'lib/sappho-heatmiser-proxy/command_queue.rb', line 32 def refreshRequested? @mutex.synchronize do requested = @refreshRequested @refreshRequested = false requested end end |
#refreshStatus(clientIP) ⇒ Object
25 26 27 28 29 30 |
# File 'lib/sappho-heatmiser-proxy/command_queue.rb', line 25 def refreshStatus clientIP @log.info "client #{clientIP} requests status refresh" @mutex.synchronize do @refreshRequested = true end end |