Module: Frypan

Defined in:
lib/frypan.rb,
lib/frypan/node.rb,
lib/frypan/tuner.rb,
lib/frypan/version.rb,
lib/frypan/epg_parser.rb,
lib/frypan/database_sync_list.rb

Defined Under Namespace

Modules: Node Classes: DBSyncList, EpgParser, Tuner

Constant Summary collapse

VERSION =
"0.0.1"

Class Method Summary collapse

Class Method Details

.main_signal(db, tuner_config = nil) ⇒ Object

TODO

imp APIServer
imp EpgParser


8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/frypan.rb', line 8

def self.main_signal(db, tuner_config=nil)
  dbsync_ui_res        = DBSyncList.new("ui_response",   db)
  dbsync_recording_log = DBSyncList.new("recording_log", db)
  dbsync_program       = DBSyncList.new("program",       db)
  dbsync_recorded      = DBSyncList.new("recorded",      db)

  dbsync_reserve1 = DBSyncList.new("reserve1", db)
  dbsync_reserve2 = DBSyncList.new("reserve2", db)
  dbsync_reserve3 = DBSyncList.new("reserve3", db)
  dbsync_reserve4 = DBSyncList.new("reserve4", db)

  api_server = APIServer.new(db) # fork webrick. only op-command throw.

  command = TinyFRP.lift{ api_server.get_next_command } # one-unit-command OR nil
  #com = {
  #  command_id: 1024,
  #  target_tuner: 1
  #  operations: [
  #               {:kind => :remove, ::target => {reserve data (something including start_time)}},
  #               {:kind => :add,    :target => {reserve data}}
  #              ]
  #}
    
  current_time = TinyFRP.lift{ Time.now.strftime("%Y%m%d%H%M%S") }

  s1 = TinyFRP.bundle(command, current_time) >> Node.ReserveListFoldp("tuner1", dbsync_reserve1.to_a)
  s2 = TinyFRP.bundle(command, current_time) >> Node.ReserveListFoldp("tuner2", dbsync_reserve2.to_a)
  s3 = TinyFRP.bundle(command, current_time) >> Node.ReserveListFoldp("tuner3", dbsync_reserve3.to_a)
  s4 = TinyFRP.bundle(command, current_time) >> Node.ReserveListFoldp("tuner4", dbsync_reserve4.to_a)

  ui_res = Node.UIresponseFoldp(dbsync_ui_res) <<  TinyFRP.bundle(s1, s2, s3, s4)

  ps1 = s1 >> Node.PersistantReserveListFoldp("tuner1", dbsync_reserve1)
  ps2 = s2 >> Node.PersistantReserveListFoldp("tuner2", dbsync_reserve2)
  ps3 = s3 >> Node.PersistantReserveListFoldp("tuner3", dbsync_reserve3)
  ps4 = s4 >> Node.PersistantReserveListFoldp("tuner4", dbsync_reserve4)

  t1 = s1 >> Node.RecordingAsyncFoldp(Tuner.new("fmt1"))
  t2 = s2 >> Node.RecordingAsyncFoldp(Tuner.new("fmt2"))
  t3 = s3 >> Node.RecordingAsyncFoldp(Tuner.new("fmt2"))
  t4 = s4 >> Node.RecordingAsyncFoldp(Tuner.new("fmt2"))

  recording_log = TinyFRP.bundle(t1, t2, t3, t4) >> Node.RecordingLogFoldp(dbsync_recording_log)
  epg_extract   = recording_log >> Node.EpgExtractAsyncFoldp(EpgParser.new)
  program_list  = epg_extract >> Node.ProgramListFoldp(dbsync_program)
  recorded_list = recording_log >> Node.RecordedListFoldp(dbsync_recorded)

  return TinyFRP.bundle(ui_res, ps1, ps2, ps3, ps4, program_list, recorded_list) >> TinyFRP.bottom
end