$("#button_clear_spectrum").click(function(){
clear_spectrum();
});
+ $("#button_delete_selected").click(function(){
+ spectrum_delete();
+ });
$("#button_record_spectrum").click(function(){
record_spectrum();
});
// alert($(this).prop('checked'));
plot_spectrum();
});
+ $('#checkbox_diff_spectrum').change(function(){
+// alert($(this).prop('checked'));
+ plot_spectrum();
+ });
$( "#progressbar" ).progressbar({
value: 1000
"<label for='id" + key + "'>"
+ key + "</label>");
});
-
choiceContainer.find("input").click(function(){plot_spectrum();});
+
+
+ // select all or none with one master checkbox
+ choiceContainer.append("<br><hr><input type='checkbox' id='checkbox_allnone' checked='true'></input>"
+ + "<label for='checkbox_allnone'>select all/none</label>");
+ $('#checkbox_allnone').click(function(){
+ var master = $(this);
+ choiceContainer.find("input").each(function(){
+ $(this).prop( "checked", master.prop("checked") );
+ });
+ plot_spectrum();
+ });
}
$('#choices').find("input:checked").each(function () {
var key = $(this).attr("name");
+
+
if (key && spectrum[key]) {
// data.push(datasets[key]);
+ var dataset = spectrum[key].data;
+
+ if($('#checkbox_diff_spectrum').prop('checked') == true){
+ var diff = [];
+
+ for (var i = 0; i < dataset.length; i++) {
+ if(i > 0) {
+ diff.push([(dataset[i][0]+dataset[i-1][0])/2, dataset[i][1]-dataset[i-1][1] ]);
+ }
+ }
+ dataset = diff;
+ }
data.push(
{
- data: spectrum[key].data,
+ data: dataset,
bars: { show: true , barWidth: 0.8*parseFloat(spectrum[key].meta.bin_width), align: "center" },
label: key
}
plot_spectrum();
}
});
+}
+
+function spectrum_delete(){
+ var runs = $('#choices input[type=checkbox]:checked').map(function() {
+ return $(this).attr("name");
+ }).get().join(',');
+ $.ajax({
+ url: "pmt_ro.pl",
+ cache: false,
+ async: true,
+ dataType: "text",
+ data: {
+ sub : "spectrum_delete",
+ runs : runs
+ },
+ success: function(answer) {
+ spectrum = get_spectrum_JSON();
+ plot_choices();
+ plot_spectrum();
+ }
+ });
}
\ No newline at end of file
print "</td></tr></table>";
print "<input type='button' id='button_plot_spectrum' value='plot spectrum'>";
print "<input type='button' id='button_clear_spectrum' value='clear spectrum'>";
+ print "<input type='button' id='button_delete_selected' value='delete selected'>";
print "<label><input type='checkbox' id='checkbox_log_spectrum' >log y</label>";
+ print "<label><input type='checkbox' id='checkbox_diff_spectrum' >diff</label>";
print br;
print "record name: ";
print "<input type='text' id='text_spectrum_name' value='signal'>";
}
+sub spectrum_delete {
+ my $self = shift;
+ my %options = @_;
+
+ my @runs = split(",",$options{runs});
+
+ my $spectrum = $self->{spectrum_shm}->readShm();
+ for my $run (@runs){
+ delete $spectrum->{$run};
+ }
+ $self->{spectrum_shm}->writeShm($spectrum);
+ return " ";
+
+}
+
+sub spectrum_csv {
+ my $self = shift;
+
+ my $spectrum = $self->{spectrum_shm}->readShm();
+
+ for my $key (keys %$spectrum){
+ my $run = $spectrum->{$key};
+ print "run name:\t".$key."\n";
+ for my $info (sort keys %{$run->{meta}}){
+ print $info.":\t".$run->{meta}->{$info}."\n";
+ }
+ print "\n";
+ print "threshold\tcounts\n";
+ for my $data_pair (@{$run->{data}}){
+ print $data_pair->[0]."\t".$data_pair->[1]."\n";
+ }
+
+ print "\n";
+ print "\n";
+
+ }
+ return " ";
+
+}
+
sub clear_spectrum {
my $self = shift;