my $self = {
appName => "peltierControl",
- tty => "/dev/ttyACM1",
+ tty => "/dev/ttyACM0",
baudrate => 115200,
columnNames => ["temp","pid","setpoint"]
}; # put tons of default values here (if you wish);
# receive CGI query
$self->{query} = CGI->new();
my $action = $self->{query}->param('action') || "print_html";
+
+ if(defined($self->{query}->param('tty'))){
+ $self->{tty} = $self->{query}->param('tty');
+ }
# go only to methods that are in the following dispatch table:
# if associated value is one, sub can be called via CGI
my %options = @_;
my $shm_manager = $self->create_shm_manager();
my $webpage = webpage->new(shm_manager => $shm_manager);
+ $webpage->{shared}->{tty} = $self->{tty};
$webpage->page_body();
-
}
+
+# sub print_status{
+# my $self = shift;
+# my %options = @_;
+# my $shm_manager = $self->create_shm_manager();
+# my $webpage = webpage->new(shm_manager => $shm_manager);
+# $webpage->{shared}->{tty} = $self->{tty};
+# $webpage->status();
+# }
+
+
sub plot {
my $self = shift;
my %options = @_;
}
+#status {
+ float:right;
+ position:absolute;
+ position:fixed;
+ top: 200px;
+ left: 680px;
+ width:280px;
+ padding:10px;
+ margin-top:30px;
+ margin-left:30px;
+
+}
+
+
+
.plotArea {
/* float:left; */
position:absolute;
timer = $.timer(function() {
plot();
+ status();
});
dataType: "text",
data: {
action : "plot",
+ tty : shared.tty,
clientId : clientId
},
success: function(result) {
});
}
+function status(){
+ $.ajax({
+ url: "index.pl",
+ cache: false,
+ async: false,
+ dataType: "text",
+ data: {
+ action : "dump_shm",
+ tty : shared.tty
+ },
+ success: function(result) {
+ $("#statusContainer").html(result);
+ }
+ });
+}
+
function start_logging_tool(){
$.ajax({
url: "index.pl",
dataType: "text",
data: {
action : "start_logging_tool",
+ tty : shared.tty,
daemonize : 1
}
});
async: false,
dataType: "text",
data: {
+ tty : shared.tty,
action : "terminate_logging_tool"
}
});
async: false,
dataType: "text",
data: {
+ tty : shared.tty,
action : "clear_records"
}
});
async: false,
dataType: "text",
data: {
+ tty : shared.tty,
action : "set_setpoint",
setpoint : setpoint
}
print "<div class='header'>Options</div>";
$self->print_device_controls();
print '</div>';
+
+ print '<div id="status" class="stylishBox">';
+ print "<div class='header'>Status</div>";
+ print '<div id="statusContainer">';
+ print '</div>';
+ print '</div>';
print '<div id="plotArea" class="stylishBox plotArea">';
print "<div class='header'>Plots</div>";
} else {
passHashToJs({},"shm");
}
+ passHashToJs($self->{shared},"shared");
return;
}
+
sub print_device_controls {
my $self = shift;
print "<table>";
}
-# sub passHashToJs {
-#
-# my $hashref = shift();
-# my $objname = shift();
-# $objname = 'fromPerl' unless (defined($objname));
-# print "<script language='javascript'>\n";
-# print "var $objname = new Object();\n";
-# for my $key (keys %$hashref){
-# print $objname.qq%["$key"]="%.$hashref->{$key}.qq%";\n%;
-# }
-# print "</script>";
-#
-# }
sub passHashToJs {