# Receive form args if present and write them out sub LoadData { local(*I,*O); my $FORMFILE = "/tmp/temp_graph_control.txt"; if (exists $form->{'date'}) { # Send back a redirect $self->print(<<"EOT"

Reloading... please wait

EOT ); open(O,">$FORMFILE"); foreach my $k (keys %$form) { if ($k eq "reset") { local(*O); open(O,">/tmp/reset_temp_graph"); print O "reset\n"; close(O); next; } my $v = $form->{$k}; print O "$k:$v\n"; } print O "END\n"; close(O); open(O,">/tmp/doing-reset"); print O "doing reset\n"; close(O); return -1; } if (exists $form->{'dutycycle-high'} and $form->{'dutycycle-high'} ne "") { if (open(O,">/tmp/cooler-params.txt")) { print O "threshhold_lo=",$form->{'threshhold_lo'},"\n"; print O "threshhold_hi=",$form->{'threshhold_hi'},"\n"; print O "dutycycle-high=",$form->{'dutycycle-high'},"\n"; print O "dutycycle-on=",$form->{'dutycycle-on'},"\n"; print O "dutycycle-low=",$form->{'dutycycle-low'},"\n"; close(O); } } $auto="checked"; $manual=""; $manual_value=""; if (open(I,"<$FORMFILE")) { while(my $line = ) { chomp $line; last if $line eq "END"; my ($k,$v) = split(/:/, $line); $auto="checked" if ($k eq "track" and $v eq "auto"); $manual="checked" if ($k eq "track" and $v eq "manual"); $temp=$v if $k eq "manual_value"; } close(I); } if (open(I,") { chomp $line; next if $line =~ /^#/; next if ! $line; if ($line =~ /^([\w\-]+)\s*=\s*(.+)/) { my $arg = $1; my $val = $2; if ($arg =~ /dutycycle-(\w+)/) { my $dc_name = $1; my $dc_val = $val; $dc_val = int($dc_val/5) * 5; $dutycycle{$dc_name}{$dc_val} = "selected"; } if ($arg eq "threshhold_lo") { my $th = $val; if ($2>-0.5) { $threshhold_lo{0.0}="selected";} elsif ($2>-1.0) { $threshhold_lo{-0.5}="selected";} elsif ($2>-1.5) { $threshhold_lo{-1.0}="selected";} elsif ($2>-2.0) { $threshhold_lo{-1.5}="selected";} elsif ($2>-2.5) { $threshhold_lo{-2.0}="selected";} elsif ($2>-3.0) { $threshhold_lo{-2.5}="selected";} else { $threshhold_lo{-3.0}="selected";} } if ($arg eq "threshhold_hi") { my $th = $val; if ($2>-0.5) { $threshhold_hi{0.0}="selected";} elsif ($2>-1.0) { $threshhold_hi{-0.5}="selected";} elsif ($2>-1.5) { $threshhold_hi{-1.0}="selected";} elsif ($2>-2.0) { $threshhold_hi{-1.5}="selected";} elsif ($2>-2.5) { $threshhold_hi{-2.0}="selected";} elsif ($2>-3.0) { $threshhold_hi{-2.5}="selected";} else { $threshhold_hi{-3.0}="selected";} } } } } } return(0) if LoadData() == -1; $self->print(<<"EOT"

Auto      
Manual   Temperature:  
Reset graph and restart logger:  

HIGH Dutycycle:   LOW Dutycycle:
Threshhold_low: Threshhold_high:

EOT );