Class: Cosmos::LincHandshakeCommand

Inherits:
Object
  • Object
show all
Defined in:
lib/cosmos/interfaces/linc_interface.rb

Overview

The LincHandshakeCommand class is used only by the LincInterface. It is the command with other required items that is passed to the telemetry thread so it can match it with the handshake.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(handshakes_mutex, cmd_guid) ⇒ LincHandshakeCommand

Returns a new instance of LincHandshakeCommand.



357
358
359
360
361
362
# File 'lib/cosmos/interfaces/linc_interface.rb', line 357

def initialize(handshakes_mutex, cmd_guid)
  @cmd_guid = cmd_guid
  @handshakes_mutex = handshakes_mutex
  @resource = ConditionVariable.new
  @handshake = nil
end

Instance Attribute Details

#handshakeObject

Returns the value of attribute handshake.



355
356
357
# File 'lib/cosmos/interfaces/linc_interface.rb', line 355

def handshake
  @handshake
end

Instance Method Details

#get_cmd_guidObject



383
384
385
# File 'lib/cosmos/interfaces/linc_interface.rb', line 383

def get_cmd_guid
  return @cmd_guid
end

#got_your_handshake(handshake) ⇒ Object



378
379
380
381
# File 'lib/cosmos/interfaces/linc_interface.rb', line 378

def got_your_handshake(handshake)
  @handshake = handshake
  @resource.signal
end

#wait_for_handshake(response_timeout) ⇒ Object



364
365
366
367
368
369
370
371
372
373
374
375
376
# File 'lib/cosmos/interfaces/linc_interface.rb', line 364

def wait_for_handshake(response_timeout)
  timed_out = false

  @resource.wait(@handshakes_mutex, response_timeout)
  if @handshake
    timed_out = false
  else
    Logger.warn "#{@name}: No handshake - must be timeout."
    timed_out = true
  end

  return timed_out
end