Class: SimplePvr::HDHomeRun

Inherits:
Object
  • Object
show all
Defined in:
lib/simple_pvr/hdhomerun.rb

Overview

Encapsulates all the HDHomeRun-specific functionality. Do not initialize HDHomeRun objects yourself, but get the current instance through PvrInitializer.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeHDHomeRun

Returns a new instance of HDHomeRun.



18
19
20
21
22
23
# File 'lib/simple_pvr/hdhomerun.rb', line 18

def initialize
  @device_id = discover
  @tuner_pids = [nil, nil]
  FileUtils.rm(tuner_control_file(0)) if File.exists?(tuner_control_file(0))
  FileUtils.rm(tuner_control_file(1)) if File.exists?(tuner_control_file(1))
end

Instance Attribute Details

#device_idObject (readonly)

Returns the value of attribute device_id.



16
17
18
# File 'lib/simple_pvr/hdhomerun.rb', line 16

def device_id
  @device_id
end

Instance Method Details

#scan_for_channelsObject



25
26
27
28
29
30
# File 'lib/simple_pvr/hdhomerun.rb', line 25

def scan_for_channels
  file_name = 'channels.txt'
  scan_channels_with_tuner(file_name)
  Model::Channel.clear
  read_channels_file(file_name)
end

#start_recording(tuner, frequency, program_id, directory) ⇒ Object



32
33
34
35
36
37
# File 'lib/simple_pvr/hdhomerun.rb', line 32

def start_recording(tuner, frequency, program_id, directory)
  set_tuner_to_frequency(tuner, frequency)
  set_tuner_to_program(tuner, program_id)
  @tuner_pids[tuner] = spawn_recorder_process(tuner, directory)
  PvrLogger.info("Process ID for recording on tuner #{tuner}: #{@tuner_pids[tuner]}")
end

#stop_recording(tuner) ⇒ Object



39
40
41
42
43
44
45
# File 'lib/simple_pvr/hdhomerun.rb', line 39

def stop_recording(tuner)
  pid = @tuner_pids[tuner]
  PvrLogger.info("Stopping process #{pid} for tuner #{tuner}")
  send_control_c_to_process(tuner, pid)
  reset_tuner_frequency(tuner)
  @tuner_pids[tuner] = nil
end