|
From: <pf...@us...> - 2012-05-27 20:28:57
|
Revision: 840
http://openautomation.svn.sourceforge.net/openautomation/?rev=840&view=rev
Author: pfry
Date: 2012-05-27 20:28:51 +0000 (Sun, 27 May 2012)
Log Message:
-----------
Diverse kleinere Bugfixes
Szenencontroller speichert jetzt die Szenendaten kompakter in plugin_info
Modified Paths:
--------------
wiregate/plugin/generic/Ansagen.pl
wiregate/plugin/generic/Logikprozessor.pl
wiregate/plugin/generic/Szenencontroller.pl
Modified: wiregate/plugin/generic/Ansagen.pl
===================================================================
--- wiregate/plugin/generic/Ansagen.pl 2012-05-27 06:29:07 UTC (rev 839)
+++ wiregate/plugin/generic/Ansagen.pl 2012-05-27 20:28:51 UTC (rev 840)
@@ -31,7 +31,7 @@
# speechdir muss im mpddir liegen!
$speechdir=~s!/$!!;
$mpddir=~s!/$!!;
-return "config error" if $@ || ($mode eq 'mpd' && $speechdir !~ /^$mpddir/);
+return "config error: $@" if $@ || ($mode eq 'mpd' && $speechdir !~ /^$mpddir/);
# Aufrufgrund ermitteln
my $event=undef;
@@ -442,7 +442,7 @@
my $speech=shift;
my $pattern=shift;
- my @hits=sort { length($a) cmp length($b) } grep /$pattern/i, @{$speech};
+ my @hits=sort { length($a) <=> length($b) } grep /$pattern/i, @{$speech};
return @hits ? (shift @hits) : undef;
}
@@ -517,17 +517,42 @@
{
system "$mpc volume $1";
}
- elsif(defined $stations{$val})
+ elsif(grep /$val/i, keys %stations)
{
+ my $station=undef;
+
+ unless(defined $stations{$val})
+ {
+ my @hits=grep /$val/i, sort { length($a) <=> length($b) } keys %stations;
+ $val=shift @hits;
+ }
+ $station=$stations{$val};
+
+ my $wget=checkexec('wget');
+
+ # MusicPal-Links "uebersetzen"
+ if($station=~/freecom\.vtuner\.com/)
+ {
+ $station=~s!freecom\.vtuner\.com!vtuner.com!;
+ $station=~s!setupapp/fc/asp!setupapp/guide/asp!;
+ $station=~s!dynam.*?\.asp!dynampls.asp!;
+ $station=~s!\?ex45v=.*\&id=!\?id=!;
+ }
+
+ # vtuner-Links "uebersetzen"
+ $station = `$wget 2>/dev/null -O - $station` if $station=~/vtuner/;
+
system "$mpc clear" unless $lfd_ansage; # nur leeren falls abgespielt
- system "$mpc add \"$stations{$val}\"";
- plugin_log($plugname, "$mpc add \"$stations{$val}\"");
+ system "$mpc add \"$station\"";
+ plugin_log($plugname, "$mpc add \"$station\"");
system "$mpc play" unless `$mpc`=~/playing/s; # starten falls noch nicht aktiv
- $plugin_info{$plugname.'_radio_'.$channel}=$stations{$val};
+ $plugin_info{$plugname.'_radio_'.$channel}=$station;
+
+ $retval.="$channel:Radiosender '$val'='$station'";
}
else
{
- return "Unbekannter Radiosender '$val'";
+ $retval.="Unbekannter Radiosender '$val'";
}
}
else # Regelfall: Sprachausgabe
@@ -550,13 +575,13 @@
# wird die zweite die erste unterbrechen, weil $lfd_ansage hier (inkorrekt) 0 sein wird.
system "$mpc add \"".(join "\" \"", @_)."\"";
- plugin_log($plugname, "$mpc add \"".(join "\" \"", @_)."\"");
+# plugin_log($plugname, "$mpc add \"".(join "\" \"", @_)."\"");
system "$mpc play" unless `$mpc`=~/playing/s; # starten falls noch nicht aktiv
map s!^.*/(.*?)\.wav!$1!, @_;
+
+ $retval.=$channel.':'.(join ' ', @_);
}
-
- $retval.=$channel.':'.(join ' ', @_);
}
else
{
Modified: wiregate/plugin/generic/Logikprozessor.pl
===================================================================
--- wiregate/plugin/generic/Logikprozessor.pl 2012-05-27 06:29:07 UTC (rev 839)
+++ wiregate/plugin/generic/Logikprozessor.pl 2012-05-27 20:28:51 UTC (rev 840)
@@ -505,7 +505,7 @@
if($k eq 'day_of_week')
{
- for my $wd (sort { length($b) cmp length($a) } keys %weekday)
+ for my $wd (sort { length($b) <=> length($a) } keys %weekday)
{
foreach (@{$s->{$k}}) { s/$wd/$weekday{$wd}/gie } # Wochentage in Zahlenform
}
Modified: wiregate/plugin/generic/Szenencontroller.pl
===================================================================
--- wiregate/plugin/generic/Szenencontroller.pl 2012-05-27 06:29:07 UTC (rev 839)
+++ wiregate/plugin/generic/Szenencontroller.pl 2012-05-27 20:28:51 UTC (rev 840)
@@ -91,7 +91,7 @@
$count++;
}
- $plugin_info{$plugname.'__SceneLookup'}=$scene_lookup;
+ $plugin_info{$plugname.'__Lookup'}=$scene_lookup;
$plugin_info{$plugname.'_cycle'}=0;
$retval.=$count." initialisiert";
@@ -110,7 +110,7 @@
my $n=int($msg{value}); # die Szenennummer
# die betreffende Szene finden
- unless($plugin_info{$plugname.'__SceneLookup'}=~/(St|Rc)\($ga\)=>\'(.+?)\',/)
+ unless($plugin_info{$plugname.'__Lookup'}=~/(St|Rc)\($ga\)=>\'(.+?)\',/)
{
plugin_log($plugname, "Storniere $ga");
delete $plugin_subscribe{$ga}{$plugname}; # unbekannte GA
@@ -230,25 +230,9 @@
sub store_to_plugin_info
{
my $z=shift; # die Szenenbezeichnung
-
- # Alle Laufzeitvariablen im Hash %{$dyn}
- # in das (flache) Hash plugin_info schreiben
-
my @keylist=keys %{$scene{$z}};
- map { $_=sprintf("$_=>'%.2f'",$scene{$z}{$_}) } @keylist;
-
+ map { $_=sprintf("'$_'=>'%.2f'",$scene{$z}{$_}) } @keylist;
$plugin_info{$plugname.'__'.$z} = join ',', @keylist;
-# plugin_log($plugname, "stored: ".$plugin_info{$plugname.'__'.$z});
-
-# for my $k (grep /^$plugname\__$z/, keys %plugin_info)
-# {
-# delete $plugin_info{$k};
-# }
-#
-# for my $v (keys %{$scene{$z}})
-# {
-# $plugin_info{$plugname.'__'.$z.'__'.$v}=$scene{$z}{$v};
-# }
}
sub recall_from_plugin_info
@@ -259,15 +243,8 @@
my $z=$1;
$scene{$z}={};
my $pi=$plugin_info{$k};
- while($pi=~m/(.*?)=>\'(.*?)\'/g) { $scene{$z}{$1}=$2 }
-# plugin_log($plugname, "retrieved: ".join ',', map $_=sprintf("$_=>'%.2f'",$scene{$z}{$_}), keys %{$scene{$z}});
+ while($pi=~m/\'(.*?)\'=>\'(.*?)\'/g) { $scene{$z}{$1}=$2 }
}
-# for my $k (grep /^$plugname\__/, keys %plugin_info)
-# {
-# next unless($k=~/^$plugname\__(.*\#.*)__(.*)$/);
-# my ($z,$v)=($1,$2);
-# $scene{$z}{$v}=$plugin_info{$k};
-# }
}
# Umgang mit GA-Kurznamen und -Adressen
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|