]> jspc29.x-matter.uni-frankfurt.de Git - hadesdaq.git/commitdiff
added new GUI for online qa control
authorhadaq@countinghouse <hadaq@CountingHouse>
Mon, 30 Jun 2014 11:49:06 +0000 (13:49 +0200)
committerhadaq@countinghouse <hadaq@CountingHouse>
Mon, 30 Jun 2014 11:49:06 +0000 (13:49 +0200)
control/gui/expert/NxyterDataMode [new file with mode: 0755]
control/qa/Buttons2.pm [new file with mode: 0644]
control/qa/QA/10_Start_OnlineQA [new file with mode: 0755]
control/qa/QA/15_Vertex_Reconstruction [new file with mode: 0755]
control/qa/QA/20_Arrange_Windows [new file with mode: 0755]
control/qa/call_programs2.pl [new file with mode: 0755]
control/qa/call_programs_local.sh [new file with mode: 0755]
control/qa/call_programs_wrapper.sh [new file with mode: 0755]
utils/hldlast_store [new file with mode: 0755]

diff --git a/control/gui/expert/NxyterDataMode b/control/gui/expert/NxyterDataMode
new file mode 100755 (executable)
index 0000000..5e27c9b
--- /dev/null
@@ -0,0 +1,18 @@
+#!/usr/bin/perl
+use warnings;
+use HADES::TrbNet;
+$ENV{'DAQOPSERVER'} = "hades31";
+trb_init_ports() or die "could not reach trbnet-daemon.", trb_strerror();
+
+my $rh = trb_register_read(0x3800, 0x8400) or print trb_strerror() and die;
+
+foreach my $a (0x3800,0x3801,0x3810,0x3811) {
+  if($rh->{0x3800} & 0x80000000) {
+    system("trbcmd clearbit $a 0x8400 0x80000000");
+    }
+  else {
+    system("trbcmd setbit $a 0x8400 0x80000000");
+    }
+
+  
+  }
diff --git a/control/qa/Buttons2.pm b/control/qa/Buttons2.pm
new file mode 100644 (file)
index 0000000..e56e84f
--- /dev/null
@@ -0,0 +1,342 @@
+package Buttons2;
+
+use strict;
+use warnings;
+
+use QtCore4 ;
+use QtGui4;
+
+use Data::Dumper;
+use QtCore4::debug qw(ambiguous);
+
+
+#use Qt::isa qw(Qt::Widget);
+#use QtCore4::isa qw(Qt::Widget);
+#use QtCore4;
+
+use QtCore4::isa qw( Qt::Widget );
+
+use QtCore4::slots
+    hide_expert_checked => ['int'];
+
+
+sub groupBox_3 {
+    return shift->{groupBox_3};
+}
+
+sub hide_expert_checked {
+    my ( $state)  = @_;
+
+    if($state == Qt::Unchecked()) {
+      this->{self}->{groupBox_4}->hide();
+    }
+    else {
+      this->{self}->{groupBox_4}->show();
+    }
+}
+
+
+use Data::Dumper;
+
+
+
+# # make slots
+my $str;
+$str = "use QtCore4::slots\n slotQuitPressed => [], ";
+foreach my $i (0..150) {
+  $str .= " slot". $i . "Pressed => [], ";
+}
+$str .= "slotdummyPressed => [];";
+
+#print "will eval command: $str\n";
+eval $str;
+#print "error: $@\n";
+
+
+# }
+
+
+
+sub NEW {
+    my ( $class, $mainWindow ) = @_;
+    $class->SUPER::NEW($mainWindow);
+
+    my $self = bless {}, $class;
+
+    this->{self} = $self;
+
+    $self->{ra_buttons} = [];
+
+    #print "self: "; print Dumper $self;
+    #print "this: "; print Dumper this;
+
+    #my $self = $mainWindow;
+    if ( !defined $mainWindow->objectName() ) {
+        $mainWindow->setObjectName( "mainWindow" );
+    }
+    #$mainWindow->resize( 800, 600 );
+    #$mainWindow->resize( 400, 300 );
+
+    #$self->{hide_expert_checked} = hide_expert_checked;
+
+    my $centralwidget = Qt::Widget( $mainWindow );
+    $self->{centralwidget} = $centralwidget;
+    $centralwidget->setObjectName( "centralwidget" );
+
+    my $vl_mw = Qt::VBoxLayout( $centralwidget );
+
+#    my $layoutWidget = Qt::Widget( $centralwidget );
+#    $self->{layoutWidget} = $layoutWidget;
+#    $layoutWidget->setObjectName( "layoutWidget" );
+    #$layoutWidget->setGeometry( Qt::Rect(30, 110, 723, 418) );
+#    my $horizontalLayout = Qt::HBoxLayout( $centralwidget );
+    my $horizontalLayout = Qt::HBoxLayout( );
+    $self->{horizontalLayout} = $horizontalLayout;
+    $horizontalLayout->setObjectName( "horizontalLayout" );
+    $horizontalLayout->setContentsMargins(0, 0, 0, 0 );
+
+    #$horizontalLayout->addStretch(1);
+
+    my $groupBox_1 = Qt::GroupBox( $centralwidget );
+    $self->{groupBox_1} = $groupBox_1;
+    $groupBox_1->setObjectName( "groupBox_1" );
+    my $vl_gb1 = Qt::VBoxLayout( $groupBox_1 );
+    $self->{vl_gb1} = $vl_gb1;
+    $vl_gb1->setObjectName( "vl_gb1" );
+
+
+
+    $horizontalLayout->addWidget( $groupBox_1 );
+
+
+
+
+#     my $groupBox_4 = Qt::GroupBox( $centralwidget );
+#     $self->{groupBox_4} = $groupBox_4;
+#     $groupBox_4->setObjectName( "groupBox_4" );
+# 
+#     #$groupBox_3->setCheckable(1);
+#     #$groupBox_3->setChecked(0);
+#     $groupBox_4->hide();
+# 
+# 
+#     my $vl_gb4 = Qt::VBoxLayout( $groupBox_4 );
+#     $self->{vl_gb4} = $vl_gb4;
+#     $vl_gb4->setObjectName( "vl_gb4" );
+# 
+#     $horizontalLayout->addWidget( $groupBox_4 );
+# 
+# 
+# 
+    my $vl_top = Qt::VBoxLayout( );
+    $self->{vl_top} = $vl_top;
+    $vl_top->setObjectName( "vl_top" );
+    $vl_top->setContentsMargins(0, 0, 0, 0 );
+
+    $vl_mw->addLayout($vl_top);
+    $vl_mw->addLayout($horizontalLayout);
+# 
+# 
+# #    my $pushButton = Qt::PushButton( $centralwidget );
+# #    $self->{pushButton} = $pushButton;
+# #    $pushButton->setObjectName( "pushButton" );
+# 
+# #    my $sizePolicy = Qt::SizePolicy( Qt::SizePolicy::Minimum(), Qt::SizePolicy::Fixed() );
+# #    $self->{$sizePolicy} = $sizePolicy;
+# #    $sizePolicy->setHorizontalStretch( 0 );
+# #    $sizePolicy->setVerticalStretch( 0 );
+# #    $sizePolicy->setHeightForWidth( $pushButton->sizePolicy()->hasHeightForWidth() );
+# #    $pushButton->setSizePolicy( $sizePolicy );
+# #    $pushButton->setMinimumSize( Qt::Size(0, 0) );
+# #    my $icon = Qt::Icon;
+# #    $icon->addPixmap(Qt::Pixmap("/usr/share/icons/oxygen/64x64/apps/preferences-desktop-icons.png"), Qt::Icon::Normal(), Qt::Icon::Off() );
+# #    $icon->addPixmap(Qt::Pixmap("close_window.png"), Qt::Icon::Normal(), Qt::Icon::Off() );
+#     #$icon->addPixmap(Qt::Pixmap("/usr/share/icons/oxygen/64x64/apps/preferences-system-login.png"), Qt::Icon::Normal(), Qt::Icon::On() );
+# #    $pushButton->setIcon( $icon );
+# #    $pushButton->setIconSize( Qt::Size(50, 50) );
+# 
+# #    $vl_top->addWidget( $pushButton );
+# 
+#     my $checkBox = Qt::CheckBox( $centralwidget );
+#     $self->{checkBox} = $checkBox;
+#     $checkBox->setObjectName( "checkBox" );
+# 
+#     $vl_top->addWidget( $checkBox );
+
+    $mainWindow->setCentralWidget( $centralwidget );
+    my $menubar = Qt::MenuBar( $mainWindow );
+    $self->{menubar} = $menubar;
+    $menubar->setObjectName( "menubar" );
+    #$menubar->setGeometry( Qt::Rect(0, 0, 800, 25) );
+    $mainWindow->setMenuBar( $menubar );
+    my $statusbar = Qt::StatusBar( $mainWindow );
+    $self->{statusbar} = $statusbar;
+    $statusbar->setObjectName( "statusbar" );
+    $mainWindow->setStatusBar( $statusbar );
+
+    $self->retranslateUi( $mainWindow );
+
+
+    my $cur_button_number = 0;
+
+    my $dir;
+    my $buttons = [];
+
+
+    make_buttons($self, "QA", \$cur_button_number, $groupBox_1, $vl_gb1);
+    #print "cur_button: $cur_button_number\n";
+
+    #$layoutWidget->updateGeometry();
+
+
+#    Qt::Object::connect($pushButton, SIGNAL 'clicked()' , $mainWindow, SLOT 'close()' );
+
+
+#     Qt::Object::connect($checkBox, SIGNAL 'stateChanged(int)' ,
+#                     this, SLOT 'hide_expert_checked(int)' );
+
+    Qt::MetaObject::connectSlotsByName( $mainWindow );
+
+    return $self;
+
+}
+
+
+sub retranslateUi {
+    my ( $self, $mainWindow ) = @_;
+    $mainWindow->setWindowTitle( Qt::Application::translate( 'MainWindow', "Online QA", undef, Qt::Application::UnicodeUTF8() ) );
+    $self->{groupBox_1}->setTitle( Qt::Application::translate( 'MainWindow', "QA", undef, Qt::Application::UnicodeUTF8() ) );
+
+
+} # retranslateUi
+
+
+
+
+sub make_buttons {
+  (my $self, my $dir, my $r_current_button_number, my $bgrp, my $layout) = @_;
+
+  #print  $bgrp;
+  #print "current number_; $r_current_button_number\n";
+
+  my $c = qq"find $dir -maxdepth 1 -type f| sort";
+  my @f = qx($c);
+
+  my $i = $$r_current_button_number;
+
+  my $button_list=[];
+
+  foreach (@f) {
+    next if /.png$/i;
+    chomp;
+    s/.*\///;
+    next if /\~$/;
+    push @$button_list, $_;
+    my $br = $self->{ra_buttons};
+    push @{$br}, $_;
+  }
+
+
+
+
+  foreach my $cur_button_name (@$button_list) {
+
+
+    next if ($cur_button_name =~ /.png$/);
+#    my $icon->addPixmap(Qt::Pixmap("/usr/share/icons/oxygen/64x64/apps/preferences-desktop-icons.png"), Qt::Icon::Normal(), Qt::Icon::Off() );
+    my $icon_path = "$dir/$cur_button_name" . ".png";
+#    print "path: $icon_path_file \n";
+#    my $fh_icon;
+#    my $res = open($fh_icon, "<", $icon_path_file);
+#    my @file  = <$fh_icon>;
+#    $fh_icon->close();
+
+    #/usr/share/icons/hicolor/48x48/apps/
+#    my ($icon_name) = grep /Icon=/, @file;
+#    $icon_name =~ s/Icon=//;
+#    my $icon_path = "/usr/share/icons/hicolor/48x48/apps/$icon_name";
+#    print "got icon path: $icon_path \n";
+
+
+    my $name = $cur_button_name;
+    $name =~ s/^\d+_//;
+    $name =~ s/_/ /g;
+
+
+    my $com = qq|
+my \$pb$i = Qt::PushButton("$cur_button_name", \$bgrp);
+\$self->{pb$i} = \$pb$i;
+\$layout->addWidget( \$pb$i );
+\$pb$i->setText (  Qt::Application::translate( 'MainWindow', "$name", undef,
+                                               Qt::Application::UnicodeUTF8() ) );
+
+my \$icon$i = Qt::Icon;
+\$icon$i->addPixmap(Qt::Pixmap(\"$icon_path\"), Qt::Icon::Normal(), Qt::Icon::Off() );
+
+\$pb$i->setIcon( \$icon$i );
+\$pb$i->setIconSize( Qt::Size(50, 50) );
+
+|;
+
+
+#    my $pb_$i = Qt::PushButton("$_", \$bgrp);
+#   $self->{pb$i} = $pb_$i;
+#    $layout->addWidget( $pb_$i );
+#    $pushButton->setIcon( $icon );
+#    $pushButton->setIconSize( Qt::Size(50, 50) );
+#    $pb$i->setText (  Qt::Application::translate( 'MainWindow', "$name", undef, Qt::Application::UnicodeUTF8() ) );
+
+
+#/usr/share/icons/hicolor/48x48/apps/yast-bootloader.png
+
+    #   print "command1: $com\n";
+
+    #print "command: $com\n";
+    eval $com;
+    print "$@\n" if ($@);
+
+
+#my $iconstr = "$icon" . "$i";
+
+$com = qq |
+|;
+
+
+
+    #Qt::Object::connect($pushButton, SIGNAL 'clicked()' , $mainWindow, SLOT 'close()' );
+    $com = qq|Qt::Object::connect(\$self->{pb$i}, SIGNAL 'clicked()', this, SLOT 'slot| . $i . qq|Pressed()');|;
+    #print "command2: $com\n";
+    eval $com;
+    print "error: " , $@ , "\n" if ($@);
+
+    make_subroutine($i, $dir);
+
+    $i++;
+    #last if $i >=10;
+  }
+
+  $$r_current_button_number = $i;
+}
+
+
+sub make_subroutine {
+    (my $i, my $dir) = @_;
+    # make subroutines
+    #sub slot0Pressed { my $c = buttons->[0]; $c = "cd ../control; ./$c"; print "will execute: $c\n"; qx($c); }
+    
+    my $str = qq|sub slot| . $i . qq|Pressed { my \$c = this->{self}->{ra_buttons}->[$i]; \$c = "cd $dir; ./\$c &"; print "will execute: \$c\n"; system('logger -p local1.info -t DAQ MdcLV \\<I\\> Powercycle in '.$dir.'/'.this->{self}->{ra_buttons}->[$i]); system(\$c); }|;
+#    my $str = qq|sub slot| . $i . qq|Pressed { print "$i pressed\n"; }|;
+#system(\$c); }|;
+    #print "sub: $str\n";
+    eval $str;
+}
+
+
+# sub slotQuitPressed {
+#     exit;
+# }
+
+#sub slot0Pressed { my $c = buttons->[0]; $c = "cd ../control; ./$c"; print "will execute: $c\n"; qx($c); }
+
+
+1;
diff --git a/control/qa/QA/10_Start_OnlineQA b/control/qa/QA/10_Start_OnlineQA
new file mode 100755 (executable)
index 0000000..a4c888a
--- /dev/null
@@ -0,0 +1,2 @@
+#!/bin/bash
+/home/hades-qa/bin/start_OLM.sh &
diff --git a/control/qa/QA/15_Vertex_Reconstruction b/control/qa/QA/15_Vertex_Reconstruction
new file mode 100755 (executable)
index 0000000..632ae9f
--- /dev/null
@@ -0,0 +1,2 @@
+#!/bin/bash
+/home/hades-qa/bin/VertexReconstruction.sh &
diff --git a/control/qa/QA/20_Arrange_Windows b/control/qa/QA/20_Arrange_Windows
new file mode 100755 (executable)
index 0000000..c8d7f73
--- /dev/null
@@ -0,0 +1,2 @@
+#!/bin/bash
+/home/hades-qa/bin/moveQAwindows.pl &
diff --git a/control/qa/call_programs2.pl b/control/qa/call_programs2.pl
new file mode 100755 (executable)
index 0000000..360b8c8
--- /dev/null
@@ -0,0 +1,22 @@
+#!/usr/bin/perl -w
+
+package main;
+
+use warnings;
+use strict;
+use QtCore4;
+use QtGui4;
+use Buttons2;
+
+sub main {
+
+  my $a = Qt::Application(\@ARGV);
+  my $w = Qt::MainWindow;
+  my $u = Buttons2($w);
+  $w->show();
+  exit $a->exec();
+}
+
+
+main();
+
diff --git a/control/qa/call_programs_local.sh b/control/qa/call_programs_local.sh
new file mode 100755 (executable)
index 0000000..88dd62c
--- /dev/null
@@ -0,0 +1,9 @@
+#!/bin/bash
+
+cd /home/hadaq/trbsoft/hadesdaq/control/qa/
+./call_programs_wrapper.sh -geometry -0-0 &
+#/home/hadaq/trbsoft/hadesdaq/control/gui/call_programs_wrapper.sh -geometry -0-0 &
+
+#cd /home/hadaq/trbsoft/daq/control/gui/
+#./call_programs2.pl -geometry -0-0
+
diff --git a/control/qa/call_programs_wrapper.sh b/control/qa/call_programs_wrapper.sh
new file mode 100755 (executable)
index 0000000..fe7b756
--- /dev/null
@@ -0,0 +1,5 @@
+#ssh -X lxhadeb06 "export PATH=\$PATH:\$HOME/bin; echo $PATH; cd /home/hadaq/trbsoft/hadesdaq/control/gui/; ./call_programs2.pl -geometry -0-0" 
+#ssh -X lxhadeb06 ". .bashrc; export PATH=\$PATH:\$HOME/bin; echo $PATH; cd /home/hadaq/trbsoft/hadesdaq/control/gui/; ./call_programs2.pl -geometry -0-0" 
+
+cd /home/hadaq/trbsoft/daq/control/qa/
+/home/hadaq/trbsoft/daq/control/qa/call_programs2.pl -geometry -0-0
diff --git a/utils/hldlast_store b/utils/hldlast_store
new file mode 100755 (executable)
index 0000000..ba4f9d5
--- /dev/null
@@ -0,0 +1,9 @@
+#!/bin/bash
+find /store -mtime 0 -name \*$1\* -size +100c -printf %A@\\t%p\\n 2>/dev/null | sort | tail -n 20 | cut -f 2
+
+
+#zsh
+#print -rl **/*.hld(.Om) | tail -$1
+
+#bash
+#find /store/ -type f -iname '*.hld' -printf '%T+\t%p\n' | sort -n | cut -f2 | tail -$1