#!/usr/bin/perl -w # Directories where the log files reside in; get configured # $logdir="/home/chris/construction/BTUmetering/log"; $logdir="MAINPROGROOT/log"; # $htdocsroot="/srv/www/htdocs/static"; $htdocsroot="HTDOCROOT/static"; #$htimgroot="HTDOCROOT/img2"; # heat files to log @filecores=("AHU1", "AHU2", "AHU3", "S14L3", "AHU4", "AHU5", "AHU6", "PCW2"); %wcolor=("AHU1" =>"#ffffa0", "AHU2" => "#efdfff", "AHU3" => "#c0ffff", "S14L3" =>"b0f0ff", "AHU5" =>"#ffdfc0", "AHU4" => "#d8ffd8", "AHU6" =>"#f8f8f8", "PCW2" => "#ffefef" ); # electricity meter stuff %eunits= ( "EAHU2" => "94529486" , "EAHU1" => "94529485", "MDB1" => "94529479", "E-MDB1" => "94529480", "E-MDB2" => "94529484", "MDB2" => "94529481", "MDB3" => "94529482", "EAHU3" => "94529487", "MDB3-S14" =>"38751745", "E-MDB3-S14" => "40183481", "EAHU3-S14" => "38751742", "MDB4" => "94529483", "EAHU4" => "94529488", "MDB6" => "99828529", "EAHU6" => "99828528" ); # Current transformer ratios - confirmed so far: AHU1, AHU2, MDB1, # E-MDB1, E-MDB2, MDB2, MDB3, MDB4, EAHU4 %eCT= ( "EAHU2" => 12, "EAHU1" => 12, "MDB1" => 50, "E-MDB1" => 30, "E-MDB2" => 20, "MDB2" => 50, "MDB3" => 50, "EAHU3" => 12, "MDB3-S14" =>50, "E-MDB3-S14" => 1, "EAHU3-S14" => 12, "MDB4" => 20, "EAHU4" => 12, "MDB6" => 40, "EAHU6" => 12, ); # color for display %ecolor= ( "EAHU2" => "#efdfff", "EAHU1" => "#ffffa0", "MDB1" => "#ffffa0", "E-MDB1" => "#ffffa0", "E-MDB2" => "#efdfff", "MDB2" => "#efdfff", "MDB3" => "#c0ffff", "EAHU3" => "#c0ffff", "MDB4" => "#d8ffd8", "EAHU4" => "#e0ffe0", "MDB6" => "#f8f8f8", "EAHU6" => "#f8f8f8", "MDB3-S14" =>"#b0f0ff", "EAHU3-S14" =>"#b0f0ff", "E-MDB3-S14" => "#b0f0ff", ); sub sortbyname { (reverse $a) cmp (reverse $b); } @showelist=sort sortbyname (keys %eunits); # generate some header print "content-type: text/html CQT utility consumption server "; # General blurb: print "

CQT Chilled water metering status

The values shown below reflect the readings of the metering devices at the indicated date/time. Instant values reflect the temperatures/heat, the total values the accumulated values since the meter installation.

"; # Generate the table header print " "; # make list of all entries foreach $core (@filecores) { # generate logging file name $file=$logdir."/heat_".$core.".log"; # read last line from that file (latest entry) open LOGHANDLE, "tail -n 1 ".$file." |"; $logline=; close LOGHANDLE ; # split it in different entries @loglist=split ' ', $logline; if ($#loglist <1) { # No file/entry present print ""; print ""; } elsif ($loglist[0] eq "#") { # extract error msg ($dummy, $date, $time, @rest) = @loglist; print ""; print ""; print "" } else { # Assign the proper values ($date, $time, $kWh, $Volume, $power, $Thot, $Tcold) = @loglist; # Print out stuff as table rows print ""; print ""; printf "", $power; printf "", $Thot, $Tcold; printf "", $Volume; printf "", $kWh; print "\n"; } } print "
UnitDate
MM/DD/YY
Time
hh:mm:ss
Instant valuesTotal values
Thermal loadReturn TempSupply Temp CHW volumeTotal heat
$core(no logfile entry present)
$core$date$time@rest
$core$date$time%3.2f kW%2.2f °C%2.2f °C%5.1f m3%6.1f kWh
\n"; # Some blurb print "

The total chilled water volume and removed heat refers to the time since installation of the corresponding meters. AHU1...6 refers to the heat from the air handling units in levels 1...6, PCW2 to the process water for labs 2/15, 2/16, 1/16, 1/16. Meter installation date were:

"; # electrical metering stuff print "

CQT Electricity metering status

Displayed values reflect the meter readings at the indicated date/time. Instant values give an idea about the consumption at this moment, the total values represent the accumulated consumption since the meter installation. New readings are available every 2 minutes.

"; # Generate the table header print " "; # make list of all entries foreach $unitname (@showelist) { $core=$eunits{$unitname}; # generate logging file name $file=$logdir."/emeter_".$core.".log"; # read last line from that file (latest entry) open LOGHANDLE, "tail -n 1 ".$file." |"; $logline=; close LOGHANDLE ; # split it in different entries @loglist=split ' ', $logline; if ($#loglist <1) { # No file/entry present print ""; print ""; print ""; } elsif ($loglist[0] eq "#") { # extract error msg ($dummy, $date, $time, @rest) = @loglist; print ""; print ""; print ""; print "" } else { # Assign the proper values ($date, $time, $kWh, $V1, $V2, $V3, $I1, $I2, $I3, $pkVAhr, $mkVAhr) = @loglist; # Correct for current transformer ratios $I1 *= $eCT{$unitname}; $I2 *= $eCT{$unitname}; $I3 *= $eCT{$unitname}; # calculate instantaneous apparent power $kVA = ( ( $V1 * $I1 ) + ( $V2 * $I2 ) + ( $V3 * $I3 ) ) / 1000.0; # Print out stuff as table rows print ""; print ""; print ""; printf "", $V1, $V2, $V3; printf "", $I1, $I2, $I3; printf "", $kVA; # printf "", $pkVAhr, $mkVAhr; printf "", $kWh; print "\n"; } } print "
Unit locationMeter serial Date
MM/DD/YY
Time
hh:mm:ss
Instant valuesTotal value
Voltage (V)Current (A) apparent power (kVA) active energy (kWh)
RYBRYB
$unitname$core(no logfile entry present)
$unitname$core$date$time@rest
$unitname$core$date$time%3.1f%3.1f%3.1f%4.1f%4.1f%4.1f%3.2f%6.0f%6.0f%7.0f
\n"; print "

The apparent power is calculated via V1*I1+V2*I2+V3*I3.\n"; print "Missing entries are awaiting installation.

\n"; # prepare monthly bill page request print "

Monthly billing overview

"; print "

Below is a list of the last billing cycle. The values are read off shortly (1 minute) after midnight of the 25th of each month. We also have a summary over all billing periodes for water and electricity.

\n"; $lastbilling=`cat $htdocsroot/lastmonth.html`; print $lastbilling; $lastbilling=`cat $htdocsroot/e_lastmonth.html`; print $lastbilling; # Link to main page of this server print "

Back to main page.

"; # Finish html page print "\n\n";