--- /dev/null
+#Board Sensor Y X Name
+0 0 1 0
+0 1 1 5
+0 2 1 10
+0 3 1 15
+0 4 13 15
+0 5 9 10
+0 6 13 5
+0 7 9 0
+
+1 0 5 10
+1 1 13 0
+1 2 9 5
+1 3 5 15
+1 4 9 15
+1 5 5 0
+1 6 13 10
+1 7 5 5
+
+2 0 1 25 CoolIn
+2 1 4 25 CoolOut
+2 2 25 20
+2 3 25 21
+2 4 25 22
+2 5 25 23
+2 6 25 24
+2 7 25 25
+
+3 0 29 18
+3 1 29 19
+3 2 29 20
+3 3 29 21
+3 4 29 22
+3 5 29 23
+3 6 29 24
+3 7 29 25
--- /dev/null
+AT001ffbb4
+AT01100a28
+AT021021fc
+AT03102af8
+AT04102ee0
+AT051028a0
+AT06102580
+AT07101a2c
+AT10102774
+AT11102580
+AT121021fc
+AT13102af8
+AT14102ee0
+AT151ffeff
+AT16102ee0
+AT17000000
+AT20102580
+AT21101a2c
--- /dev/null
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <title>Temperature Visualizer</title>
+ <link rel="stylesheet" type="text/css" href="style.css">
+ <meta charset="UTF-8"/>
+
+ <script type="text/javascript">
+
+ function makeInfo(target) {
+ str = target.id.replace('.',',')+","
+ +(parseInt(target.style.top)/20)+","
+ +(parseInt(target.style.left)/20)+","
+ +target.lastChild.previousSibling.innerHTML;
+ getdata('writeconfig.pl?'+str,null);
+// document.getElementById("info").innerHTML = "<tt>"+str+"</tt>";
+ }
+
+ function makeMovable(target, handle) {
+ handle.onmousedown = function(event) {
+ var initialXOffset = target.offsetLeft - event.pageX;
+ var initialYOffset = target.offsetTop - event.pageY;
+
+ document.onmousemove = function(event) {
+ target.style.left = (Math.round((event.pageX + initialXOffset)/20)*20)+'px';
+ target.style.top = (Math.round((event.pageY + initialYOffset)/20)*20)+'px';
+ }
+
+ document.onmouseup = function() {
+ document.onmousemove = null;
+ document.onmouseup = null;
+ makeInfo(target);
+ }
+
+ return false;
+ }
+ }
+
+ function makeNameChange(target) {
+ target.ondblclick = function(event) {
+ v = prompt('New Name',target.lastChild.previousSibling.innerHTML);
+ if(v != null) target.lastChild.previousSibling.innerHTML = v;
+ makeInfo(target);
+ }
+ }
+
+ function getdata(command,callback) {
+ var xmlhttp = null;
+ var cb = null;
+ xmlhttp=new XMLHttpRequest();
+ cb = callback;
+
+ xmlhttp.onreadystatechange = function() {
+ if(xmlhttp.readyState == 4) {
+ if(cb)
+ cb(xmlhttp.responseText);
+ }
+ }
+ xmlhttp.open("GET",command,true);
+ xmlhttp.send(null);
+ }
+
+ function UpdatePage(text) {
+
+ a = document.getElementsByClassName('sensor');
+ for(i = 0; i < a.length;i++) {
+ a[i].onmousedown = null;
+ }
+
+ a = document.getElementsByClassName('name');
+ for(i = 0; i < a.length;i++) {
+ a[1].ondblclick = null;
+ }
+
+
+ document.getElementById('container').innerHTML = text;
+
+ a = document.getElementsByClassName('sensor');
+ for(i = 0; i < a.length;i++) {
+ makeMovable(a[i],a[i]);
+ makeNameChange(a[i]);
+ }
+
+// a = document.getElementsByClassName('name');
+// for(i = 0; i < a.length;i++) {
+// makeNameChange(a[i]);
+// }
+
+ setTimeout("getdata('update.pl',UpdatePage)",1000);
+ }
+
+ </script>
+
+</head>
+<body>
+<div id="header">
+ <h1>Temperature Measurements</h1>
+ <div id="info"></div>
+</div>
+<div id="container">
+</div>
+
+<script type="text/javascript">
+ setTimeout("getdata('update.pl',UpdatePage)",100);
+</script>
+
+</body></html>
--- /dev/null
+body {
+ font-family:"Trebuchet MS";
+ margin:0;
+ height:100%;
+ width:100%;
+}
+
+#header {
+ width:100%;
+ height:90px;
+ background:#eee;
+ border-bottom:1px solid #aaa;
+ position:relative;
+ }
+
+h1{
+ font-size:25px;
+ color:#aaa;
+ margin:0 0 0 10px;
+ padding:0;
+ }
+
+#info {
+ position:absolute;
+ bottom:0;
+ right:20px;
+ text-align:right;
+}
+
+#container {
+ margin:20px;
+ position:relative;
+ }
+
+
+.sensor{
+ background:red;
+ position:absolute;
+ width:80px;
+ height:40px;
+ border-radius:0 15px 0 0;
+ border:1px solid #aaa;
+ margin:auto;
+ cursor:default;
+ font-family:monospace;
+ box-model:border-box;
+ box-shadow:3px 3px 2px 2px #ddd;
+ }
+
+.value {
+ width:100%;
+ height:100%;
+ margin-left:5px;
+ margin-top:2px;
+ font-size:20px;
+ user-select: none;
+ -moz-user-select: none;
+}
+
+.sid {
+ padding:2px;
+ font-family:monospace;
+ position:absolute;
+ right:0;
+ bottom:-2px;
+ font-size:10px;
+ user-select: none;
+ -moz-user-select: none;
+}
+
+.name {
+ padding:2px;
+ font-family:monospace;
+ position:absolute;
+ bottom:-2px;
+ font-size:10px;
+ width:80px;
+ height:12px;
+ user-select: none;
+ -moz-user-select: none;
+}
+
+.scale {
+ position:absolute;
+ bottom:20px;
+ }
+
+table.scale {
+ display:inline-block;
+ border-collapse:collapse;
+ }
+
+.scale td {
+ min-width:12px;
+}
--- /dev/null
+#!/usr/bin/perl
+print "Content-Type: text/html; charset=utf-8\r\n\r\n";
+
+use warnings;
+use strict;
+use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
+use utf8;
+use POSIX;
+use List::Util qw(min max);
+
+my $min = 1000;
+my $max = -1000;
+
+sub defineScale {
+ my $aref = shift @_;
+ $min = min(@{$aref});
+ $max = max(@{$aref});
+
+ $min = floor($min/5)*5;
+ $max = ceil($max/5)*5;
+
+ }
+
+
+sub findcolor {
+ my ($v,$min,$max) = @_;
+ my ($r,$g,$b);
+ $v = 0 unless defined $v;
+
+ my $step = (($max-$min)/1000.);
+
+
+ if ($v == 0) {
+ $r = 220;
+ $g = 220;
+ $b = 220;
+ } else {
+ $v -= $min;
+ $v = $v/$step if $step;
+ if ($v<240) { $r = 255-$v/240*255;}
+ elsif ($v<333) { $r = 0;}
+ elsif ($v<666) { $r = ($v-333)/333.*255.;}
+ elsif ($v<900) { $r = 255;}
+ else { $r = 255 - ($v-900);}
+
+ if ($v<200) { $g = 0;}
+ elsif ($v<430) { $g = ($v-200)/230.*255.;}
+ elsif ($v<730) { $g = 255;}
+ elsif ($v<920) { $g = 255-($v-730)/190.*255.;}
+ else { $g = 0;}
+
+ if ($v<160) { $b = 200+$v/160.*55.;}
+ elsif ($v<333) { $b = 255;}
+ elsif ($v<666) { $b = 255-($v-333)/333.*255.;}
+ else { $b = 0;}
+ }
+
+ my $ret = sprintf("#%02x%02x%02x",$r%256,$g%256,$b%256);
+
+ return $ret;
+}
+
+
+sub DrawScale {
+ my ($min,$max,$steps) = @_;
+ my $str;
+ return "" if $max == $min;
+ $str .= "<table class=\"scale\"><tr>";
+ $str .= sprintf("<td style=\"background-color:%4s;\">",findcolor(0,0,$steps,0));
+ return $str.="</table>" if $max == $min;
+ $str .= sprintf("<td class=\"label\">%#2.3G",$min);
+ for (my $i = 1;$i<$steps;$i++) {
+ # my $j = ($max-$min)/$steps*$i;
+ $str .= sprintf("<td style=\"background-color:%7s;\" title=\"%.2f\">",findcolor($i,0,$steps,0),($max-$min)/$steps*$i+$min);
+ }
+ $str .= sprintf("<td class=\"label\">%#2.3G",$max);
+ $str .= "</table>\n";
+ return $str;
+}
+
+my $values;
+my $tfile = "tail -n40 data/pt100.log";
+open(my $tdata, '-|', $tfile) or die "Could not open '$tfile' $!\n";
+while (my $line = <$tdata>) {
+ #AT051028a0
+ if($line =~ /^AT([0-9])([0-9])([0-1])((\w){5})/){
+ next if $2 >= 8;
+ my $v = hex($4);
+ $v -= 0x100000 if $v >= 0x80000;
+ $values->[$1*8+$2] = $v/1000.;
+ $values->[$1*8+$2] = undef unless $3;
+ }
+ }
+
+defineScale($values);
+
+my $cfile = "config/default.conf";
+open(my $cdata, '<', $cfile) or die "Could not open '$cfile' $!\n";
+while (my $line = <$cdata>) {
+ $line =~ s/#.*//;
+ my @f = split(" " , $line);
+ if(defined $f[3]) {
+ $f[4] = $f[4] || '';
+ my $val = '--.--';
+ $val = sprintf('%02.2f',$values->[$f[0]*8+$f[1]]) if defined $values->[$f[0]*8+$f[1]];
+ print "
+ <div class=\"sensor\" id=\"$f[0].$f[1]\" style=\"left:".($f[3]*20)."px;top:".($f[2]*20)."px;background:".findcolor($values->[$f[0]*8+$f[1]],$min,$max)."\">
+ <div class=\"value\">$val</div>
+ <div class=\"sid\">$f[0]/$f[1]</div>
+ <div class=\"name\">$f[4]</div>
+ </div>
+ ";
+ }
+
+ }
+
+print '<div class="scale">'.DrawScale($min,$max,50).'</div>';
+
\ No newline at end of file
--- /dev/null
+#!/usr/bin/perl
+print "Content-Type: text/html; charset=utf-8\r\n\r\n";
+
+use warnings;
+use strict;
+use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
+use utf8;
+use Data::Dumper;
+
+
+my $str = $ENV{'QUERY_STRING'};
+my @new = split(',', $str);
+$str =~ s/,/\t\t\t\t/g;
+
+my $out = "";
+
+my $cfile = "config/default.conf";
+open(my $cdata, '<', $cfile) or die "Could not open '$cfile' $!\n";
+while (my $line = <$cdata>) {
+ chomp $line;
+ if($line =~ /^#/) {
+ $out .= $line."\n";
+ next;
+ }
+
+ my @f = split(" " , $line);
+ if(defined $f[3] && $f[0] eq $new[0] && $f[1] eq $new[1] ) {
+ $out .= $str."\n";
+ }
+ else {
+ $out .= $line."\n";
+ }
+ }
+close($cdata);
+
+open($cdata, '>', $cfile) or die "Could not open '$cfile' $!\n";
+print $cdata $out;
+close($cdata);
+
\ No newline at end of file