Initial version
git-svn-id: https://fhem.svn.sourceforge.net/svnroot/fhem/trunk/fhem@3 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
37
webfrontend/pgm1/scripts/hfm_get.pl
Executable file
37
webfrontend/pgm1/scripts/hfm_get.pl
Executable file
@@ -0,0 +1,37 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
use CGI;
|
||||
use IO::Socket::INET;
|
||||
use warnings;
|
||||
|
||||
|
||||
$host="localhost:7072";
|
||||
|
||||
sub
|
||||
getXmlList() {
|
||||
my $server = IO::Socket::INET->new(PeerAddr => $host);
|
||||
my $str = "";
|
||||
|
||||
if ($server) {
|
||||
my $buf;
|
||||
|
||||
syswrite($server, "xmllist; quit\n");
|
||||
while(sysread($server, $buf, 256) > 0) {
|
||||
$str .= $buf
|
||||
}
|
||||
} else {
|
||||
$str="<ERROR msg='Cannot connect to the server'/>\n";
|
||||
}
|
||||
return $str;
|
||||
}
|
||||
|
||||
my $cgi = new CGI;
|
||||
print $cgi->header( "-type" => "text/xml; charset=UTF-8",
|
||||
"-Expires" => "0",
|
||||
"-Cache-Control" => "no-chache",
|
||||
"-Pragma" => "no-cache"
|
||||
);
|
||||
|
||||
print "<?xml version='1.0'?>\n";
|
||||
print getXmlList();
|
||||
|
||||
72
webfrontend/pgm1/scripts/hfm_set.pl
Executable file
72
webfrontend/pgm1/scripts/hfm_set.pl
Executable file
@@ -0,0 +1,72 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
use CGI;
|
||||
use IO::Socket;
|
||||
use warnings;
|
||||
|
||||
$host="localhost:7072";
|
||||
|
||||
sub setFs20($){
|
||||
my $cgi = shift;
|
||||
my $name=$cgi->param("name");
|
||||
my $cmd=$cgi->param("cmd");
|
||||
return sendCommand("set $name $cmd");
|
||||
}
|
||||
|
||||
sub setFht($){
|
||||
my $cgi = shift;
|
||||
my $name=$cgi->param("name");
|
||||
my $tempToSet=$cgi->param("tempToSet");
|
||||
my $degreeToSet=$cgi->param("degreeToSet");
|
||||
return sendCommand("set $name $tempToSet $degreeToSet");
|
||||
}
|
||||
|
||||
sub sendCommand($) {
|
||||
my $cmd = shift;
|
||||
my $server;
|
||||
$server = IO::Socket::INET->new(PeerAddr => $host);
|
||||
if ($server) {
|
||||
syswrite($server, "$cmd; quit\n");
|
||||
return "<OK/>\n";
|
||||
} else {
|
||||
return "<ERROR msg='Cannot connect to the server'/>\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
my $cgi = new CGI;
|
||||
|
||||
my $str="<ERROR msg='Unknown command'/>\n";
|
||||
my $action=$cgi->param("action");
|
||||
|
||||
if ($action eq "setFS20") {
|
||||
$str = setFs20($cgi);
|
||||
}
|
||||
|
||||
if ($action eq "setFHT") {
|
||||
$str = setFht($cgi);
|
||||
}
|
||||
|
||||
my $thinClient = $cgi->param("thinclient") || "false";
|
||||
|
||||
if ("true" eq $thinClient) {
|
||||
# No ajax, send redirect
|
||||
print $cgi->header( "-type" => "text/xml",
|
||||
"-Expires" => "0",
|
||||
"-Cache-Control" => "no-chache",
|
||||
"-Pragma" => "no-cache",
|
||||
"-Status" => "302 Moved Temporarily",
|
||||
"-Location" => "/hfm/scripts/hfm_tc.pl"
|
||||
);
|
||||
} else {
|
||||
print $cgi->header( "-type" => "text/xml",
|
||||
"-Expires" => "0",
|
||||
"-Cache-Control" => "no-chache",
|
||||
"-Pragma" => "no-cache"
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
print "<?xml version='1.0'?>\n";
|
||||
print $str;
|
||||
|
||||
48
webfrontend/pgm1/scripts/hfm_tc.pl
Executable file
48
webfrontend/pgm1/scripts/hfm_tc.pl
Executable file
@@ -0,0 +1,48 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
use XML::XSLT;
|
||||
use CGI;
|
||||
use warnings;
|
||||
use IO::Socket::INET;
|
||||
|
||||
my $host="localhost:7072";
|
||||
my $xsl="/home/httpd/cgi-bin/xsl/hfm_tc.xsl";
|
||||
|
||||
sub
|
||||
getXmlList() {
|
||||
my $server = IO::Socket::INET->new(PeerAddr => $host);
|
||||
my $str = "";
|
||||
|
||||
if ($server) {
|
||||
my $buf;
|
||||
|
||||
syswrite($server, "xmllist; quit\n");
|
||||
while(sysread($server, $buf, 256) > 0) {
|
||||
$str .= $buf
|
||||
}
|
||||
} else {
|
||||
$str="<ERROR msg='Cannot connect to the server'/>\n";
|
||||
}
|
||||
return $str;
|
||||
}
|
||||
|
||||
|
||||
my $cgi = new CGI;
|
||||
print $cgi->header( "-type" => "text/html",
|
||||
"-Expires" => "0",
|
||||
"-Cache-Control" => "no-chache",
|
||||
"-Pragma" => "no-cache"
|
||||
);
|
||||
|
||||
|
||||
my $xml=getXmlList();
|
||||
|
||||
my $xslt = XML::XSLT->new ($xsl, warnings => 1);
|
||||
|
||||
$xslt->transform ($xml);
|
||||
print $xslt->toString;
|
||||
$xslt->dispose();
|
||||
|
||||
|
||||
|
||||
|
||||
77
webfrontend/pgm1/scripts/xsl/hfm_tc.xsl
Executable file
77
webfrontend/pgm1/scripts/xsl/hfm_tc.xsl
Executable file
@@ -0,0 +1,77 @@
|
||||
<?xml version="1.0"?>
|
||||
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
||||
<xsl:template match="/FHZINFO">
|
||||
<HTML>
|
||||
|
||||
<STYLE>
|
||||
|
||||
BODY {
|
||||
font-size:8pt;
|
||||
font-family:Helvetica,Arial, Sans Serif;
|
||||
padding-bottom:0px;
|
||||
background-color:#d5d6d8
|
||||
|
||||
}
|
||||
|
||||
TD {
|
||||
font-size:8pt;
|
||||
font-family:Helvetica,Arial, Sans Serif;
|
||||
padding-bottom:0px;
|
||||
background-color:#d5d6d8
|
||||
|
||||
}
|
||||
TABLE{
|
||||
border-spacing:0px
|
||||
cellpadding:0
|
||||
cellspacing:0
|
||||
}
|
||||
</STYLE>
|
||||
|
||||
|
||||
<BODY>
|
||||
|
||||
FS20<BR/>
|
||||
<xsl:apply-templates select="FS20_DEVICES/FS20"/>
|
||||
|
||||
|
||||
FHT<BR/>
|
||||
<xsl:apply-templates select="FHT_DEVICES/FHT"/>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="FS20">
|
||||
Name: <xsl:value-of select="@name"/><BR/>
|
||||
State: <xsl:value-of select="@state"/><BR/>
|
||||
<A>
|
||||
<xsl:attribute name="href">/cgi-bin/hfm_set.pl?action=setFS20&name=<xsl:value-of select="@name"/>&cmd=on&thinclient=true</xsl:attribute>
|
||||
On
|
||||
</A> |
|
||||
<A>
|
||||
<xsl:attribute name="href">/cgi-bin/hfm_set.pl?action=setFS20&name=<xsl:value-of select="@name"/>&cmd=off&thinclient=true</xsl:attribute>
|
||||
Off</A>
|
||||
<BR/><BR/>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template match="FHT">
|
||||
<B>Name: <xsl:value-of select="@name"/></B><BR/>
|
||||
<xsl:apply-templates/>
|
||||
<BR/><BR/>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="STATE">
|
||||
<xsl:if test='@name="measured-temp"'>
|
||||
<xsl:value-of select="@name"/>=<xsl:value-of select="@value"/><BR/>
|
||||
</xsl:if>
|
||||
<xsl:if test="@name='desired-temp'">
|
||||
<xsl:value-of select="@name"/>=<xsl:value-of select="@value"/><BR/>
|
||||
</xsl:if>
|
||||
<xsl:if test="@name='actuator'">
|
||||
<xsl:value-of select="@name"/>=<xsl:value-of select="@value"/><BR/>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
</xsl:stylesheet>
|
||||
Reference in New Issue
Block a user