Class: Stb

Inherits:
Platform show all
Includes:
RoiHelper
Defined in:
lib/platform/stb/stb.rb

Overview

Stb adds to or modifies a Platform with STB-specific functionality

Direct Known Subclasses

Iguide, Odn, Spectrum

Instance Attribute Summary

Attributes inherited from Platform

#id, #keys, #remotes, #roi, #screens

Instance Method Summary collapse

Methods included from RoiHelper

#roi_resolution

Methods inherited from Platform

#alt_parental_controls_pin, #app_version, #audio_level, #audio_level_left, #audio_level_right, #audio_present?, #capture_audio, #capture_frames, #capture_screen, #device_type_is?, #device_type_not?, #entitlements, #has_power?, #height, #high_def?, #ip_address, #is_generic?, #lock, #mac_address, #model, #name, #parental_controls_pin, #platform, #power_cycle, #power_off, #power_on, #press_key, #record_audio, #record_video, #remote_type=, #remote_type_is?, #reset_video, #resolution, #save_last_screen_captured, #slot, #snmp_get, #snmp_set, #software_version, #stop_audio, #stop_video, #upload_screenshot, #width

Constructor Details

#initialize(*args) ⇒ Stb

Public: Initializes an Stb.



12
13
14
15
16
# File 'lib/platform/stb/stb.rb', line 12

def initialize(*args)
  super(*args)
  @screens = StbScreens.new(self)
  @roi = StbRois.new(self)
end

Instance Method Details

#in_standby?(args = {}) ⇒ Boolean

Public: Checks if the device is in standby.

timeout - Integer time in milliseconds to check before timing out (default: 10.sec).

Returns a Boolean true if the device is in standby, otherwise false. Raises an Exception with a “Not implemented!” message if it is not implemented by this platform.



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/platform/stb/stb.rb', line 70

def in_standby?(args={})
  logger.info('Checking if STB is in standby')
  timeout = args.fetch(:timeout, 10.sec)
  start_time = Time.now
  loop do
    elapsed_s = Time.now - start_time
    # HD devices displaying "No Input Signal" are in standby

    standby = false
    # account for all 3 resolutions.

    no_input_roi = roi_resolution(self.roi.text.no_input_signal, self.height, self.width)      
    standby = no_input_roi.displayed?(timeout: 5000)
    unless standby
      elapsed_s = Time.now - start_time
      # Any device with a black screen is in standby

      standby = self.roi.black.new(x: 0, y: 0, width: self.width, height: self.height).displayed?
    end
    logger.debug("Device#{standby ? '' : ' not'} in standby after #{elapsed_s.round} s")
    return false unless standby
    break if elapsed_s * 1.sec > timeout
  end
  true
end

#init?Boolean

Public: Initializes the STB and brings it to the Live TV screen.

Returns a Boolean true if the device was initialized, otherwise false.



21
22
23
24
25
26
27
28
29
30
# File 'lib/platform/stb/stb.rb', line 21

def init?
  super do
    if power_on?  # assume this brings the device to the Guide screen

      self.press_key.EXIT(:sleep_time => 3.sec)  # exit the Guide to the Live TV screen

      true
    else
      false
    end
  end
end

#passwordObject

Public: Gets the device password.

Returns the password String.



42
43
44
# File 'lib/platform/stb/stb.rb', line 42

def password
  super || '1ctgtest01'
end

#power_on?Boolean

Public: Powers on the device.

Returns a Boolean true if the device powered on successfully, otherwise false. Raises an Exception with a “Not implemented!” message if it is not implemented by this platform.



50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/platform/stb/stb.rb', line 50

def power_on?
  logger.info('Ensuring STB has soft power')
  # Navigate to the guide to ensure a non-black screen

  self.press_key.EXIT(:sleep_time => 1.sec)
  self.press_key.EXIT(:sleep_time => 1.sec)
  self.press_key.GUIDE
  if self.in_standby?
    # The device is in standby

    self.press_key.POWER
    return !self.in_standby?(:timeout => 30.sec)
  end
  true
end

#usernameObject

Public: Gets the device username.

Returns the username String.



35
36
37
# File 'lib/platform/stb/stb.rb', line 35

def username
  super || 'system1'
end