root/trunk/install/perl/changestbch.pl

リビジョン 1, 2.5 kB (コミッタ: jplcom, コミット時期: 17 年 前)

initial import

  • svn:executable 属性の設定値:
Line 
1 #!/usr/bin/perl
2 #
3 # Anime recording system foltia
4 # http://www.dcc-jpl.com/soft/foltia/
5 #
6 #changestbch.pl
7 #
8 # リモコンユニットを操作して外部チューナの信号を切り替える。
9 #対応ユニット
10 # Tira-2.1: Remote Control Receiver/Transmitter
11 #http://www.home-electro.com/tira2.php
12 #
13 #usage :changestbch.pl  [PID]
14 #引数
15 #[PID]番組プログラムID
16 #
17 # チャンネル切り替えの流れ
18 # changestbch.pl :局から送出信号を調べて transfer.pl にチャンネル変更引き数を渡す。
19 # ↓
20 # transfer.pl 指定ファイルを送出 <http://www.geocities.jp/coffee_style/Tira-2-0.html>
21 #
22 #
23 # DCC-JPL Japan/foltia project
24 #
25
26 use DBI;
27 use DBD::Pg;
28
29 $path = $0;
30 $path =~ s/changestbch.pl$//i;
31 if ($pwd  ne "./"){
32 push( @INC, "$path");
33 }
34 require 'foltialib.pl';
35
36
37 #       &writelog("changestbch DEBUG START");
38
39
40 #引き数がアルか?
41 $pid = $ARGV[0] ;
42 if ($pid eq "" ){
43         #引き数なし出実行されたら、終了
44         print "usage :changestbch.pl  [PID]\n";
45         &writelog("changestbch ERR PID null");
46         exit;
47 }
48
49 # $haveirdaunit = 1;リモコンつないでるかどうか
50 if ($haveirdaunit == 1){
51 #デバイス見えるかどうか
52 if (-e "/dev/ttyUSB0"){
53
54 # pidから局(送出コマンド)調べる
55 #DB初期化
56         my $data_source = sprintf("dbi:%s:dbname=%s;host=%s;port=%d",
57                 $DBDriv,$DBName,$DBHost,$DBPort);
58          $dbh = DBI->connect($data_source,$DBUser,$DBPass) ||die $DBI::error;;
59
60 $DBQuery =  "SELECT foltia_station.tunertype,foltia_station.tunerch ,foltia_station.stationrecch ,foltia_station.stationid FROM foltia_subtitle,foltia_station WHERE foltia_subtitle.stationid = foltia_station.stationid AND foltia_subtitle.pid =  '$pid' ";
61          $sth = $dbh->prepare($DBQuery);
62         $sth->execute();
63  @chstatus = $sth->fetchrow_array;
64         $tunertype = $chstatus[0];
65         $tunercmd =  $chstatus[1];
66         $recch =  $chstatus[2];
67         $stationid =  $chstatus[3];     
68 $cmdjoined = "$tunertype"."$tunercmd";
69
70 &writelog("changestbch DEBUG  $cmdjoined :$recch:$stationid");
71
72 $length = length($cmdjoined);
73 $sendcmdfile = "";
74 for ($i=0 ; $i < $length ; $i++ ){
75         $cmdtxt = substr($cmdjoined,$i,1);
76 #       print "$cmdtxt\n";
77         $sendcmdfile .= " $toolpath/perl/irda/$cmdtxt".".dat ";
78 }#for
79
80 #if (-e "$toolpath/perl/irda/$sendcmdfile"){
81         system("$toolpath/perl/irda/transfer.pl $sendcmdfile");
82 &writelog("changestbch DEBUG  $toolpath/perl/irda/transfer.pl $toolpath/perl/irda/$sendcmdfile");
83 #}else{
84 #       &writelog("changestbch ERR cmd file not found:$toolpath/perl/irda/$sendcmdfile");
85 #}#if -e
86
87
88
89 #BS-hi b x103 || b 3
90 #キッズステーション c x264 || c 2
91
92 #コマンドから実行するコマンド組み立て
93 }else{
94 #デバイス見えない
95                 &writelog("changestbch ERR Tira2 Not found.");
96 }#end if (-e "/dev/ttyUSB0")
97
98 }#endif if ($haveirdaunit == 1
99
100
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。
track feed