Changeset 174 for Evidence/Edd
- Timestamp:
- 03/05/10 15:06:15 (15 years ago)
- Location:
- Evidence/Edd
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
Evidence/Edd/Edd.cc
r171 r174 6 6 Qt-based graphical user interface for the Evidence contron system 7 7 8 Edd _Indicatorchanges its background colour in case it display8 EddLineDisplay changes its background colour in case it display 9 9 a DIM status service 10 10 … … 21 21 22 22 23 class Edd _DIM*Handler;23 class EddDim *Handler; 24 24 25 25 … … 31 31 32 32 Browser.getServices(Service); 33 if (Browser.getNextService(Name, Format) != DimSERVICE) return new Edd _Plot(Service, Index);//return NULL;34 35 if (strlen(Format) == 1 && *Format != 'C') return new Edd _Plot(Service, Index);36 else return new Edd _TextHist(Service);33 if (Browser.getNextService(Name, Format) != DimSERVICE) return new EddPlot(Service, Index); 34 35 if (strlen(Format) == 1 && *Format != 'C') return new EddPlot(Service, Index); 36 else return new EddText(Service); 37 37 } 38 38 … … 43 43 44 44 // Constructor 45 Edd _Indicator::Edd_Indicator(QString Name, int Index, QWidget *P):45 EddLineDisplay::EddLineDisplay(QString Name, int Index, QWidget *P): 46 46 QLineEdit(P), ServiceName(Name), Index(Index) { 47 48 LastPlot = NULL; 47 49 48 50 // Widget properties … … 67 69 68 70 // Destructor 69 Edd _Indicator::~Edd_Indicator() {71 EddLineDisplay::~EddLineDisplay() { 70 72 71 73 Handler->Unsubscribe(ServiceName); … … 73 75 74 76 // Update widget 75 void Edd _Indicator::Update(QString Name, int Time, QByteArray Array, QString Format, QString Text) {77 void EddLineDisplay::Update(QString Name, int Time, QByteArray Array, QString Format, QString Text) { 76 78 77 79 if (ServiceName != Name) return; … … 109 111 110 112 // Open plot if mouse release within widget 111 void Edd _Indicator::mouseReleaseEvent(QMouseEvent *Event) {113 void EddLineDisplay::mouseReleaseEvent(QMouseEvent *Event) { 112 114 113 115 if (Event->button()!=Qt::LeftButton || !contentsRect().contains(Event->pos())) return; … … 123 125 124 126 // If not, open new plot 125 Edd _Indicator::MenuOpenHistory();127 EddLineDisplay::MenuOpenHistory(); 126 128 } 127 129 128 130 // Handling of mouse press event: Register start position for drag 129 void Edd _Indicator::mousePressEvent(QMouseEvent *Event) {131 void EddLineDisplay::mousePressEvent(QMouseEvent *Event) { 130 132 131 133 if (Event->button() == Qt::LeftButton) dragStart = Event->pos(); … … 133 135 134 136 // Handling of dragging (Drag and MimeData will be deleted by Qt) 135 void Edd _Indicator::mouseMoveEvent(QMouseEvent *Event) {137 void EddLineDisplay::mouseMoveEvent(QMouseEvent *Event) { 136 138 137 139 if ((Event->buttons() & Qt::LeftButton) == 0) return; … … 149 151 // Opening context menu 150 152 // 151 void Edd _Indicator::contextMenuEvent(QContextMenuEvent *Event) {153 void EddLineDisplay::contextMenuEvent(QContextMenuEvent *Event) { 152 154 153 155 Menu->exec(Event->globalPos()); … … 155 157 156 158 // Menu: Open history plot 157 void Edd _Indicator::MenuOpenHistory() {159 void EddLineDisplay::MenuOpenHistory() { 158 160 159 161 LastPlot = OpenHistory(ServiceName.toAscii().data(), Index); … … 162 164 163 165 // Menu: Copy service name 164 void Edd _Indicator::MenuCopyService() {166 void EddLineDisplay::MenuCopyService() { 165 167 166 168 QMimeData *MimeData = new QMimeData; … … 171 173 172 174 // Menu: Copy data 173 void Edd _Indicator::MenuCopyData() {175 void EddLineDisplay::MenuCopyData() { 174 176 175 177 QApplication::clipboard()->setText(text()); … … 184 186 // Constructor 185 187 // 186 Edd _Plot::Edd_Plot(QString DIMService, int Index, QWidget *P):187 QwtPlot(P) , EvidenceHistory(){188 EddPlot::EddPlot(QString DIMService, int Index, QWidget *P): 189 QwtPlot(P) { 188 190 189 191 Mutex = new QMutex(QMutex::Recursive); … … 238 240 // Destructor (items with parent widget are automatically deleted) 239 241 // 240 Edd _Plot::~Edd_Plot() {242 EddPlot::~EddPlot() { 241 243 242 244 for (int i=0; i<Items.size(); i++) { … … 251 253 // Add history service to plot 252 254 // 253 void Edd _Plot::AddService(QString Name, int Index) {255 void EddPlot::AddService(QString Name, int Index) { 254 256 255 257 // Lock before accessing Items list … … 280 282 281 283 // Update widget (must happen in GUI thread) 282 void Edd _Plot::Update(QString Name, int Time, QByteArray, QString Format, QString Text) {284 void EddPlot::Update(QString Name, int Time, QByteArray, QString Format, QString Text) { 283 285 284 286 // Lock before accessing Items list … … 306 308 void *Data; 307 309 308 if (GetHistory(Items[ItemNo].Name.toAscii().data())) { 310 class EvidenceHistory *HistClass = Handler->GetHistory(Items[ItemNo].Name); 311 312 if (HistClass->GetHistory()) { 309 313 double Smallest = DBL_MAX, Largest = DBL_MIN; 310 314 double Number=0; 311 while ( Next(Time, Size, Data)) {315 while (HistClass->Next(Time, Size, Data)) { 312 316 switch (Format[0].toUpper().toAscii()) { 313 317 case 'I': … … 357 361 // Update all curves in plot 358 362 // 359 void Edd _Plot::UpdatePlot() {363 void EddPlot::UpdatePlot() { 360 364 361 365 static QwtSymbol Symbol, Sym1; … … 405 409 // Reset graph axes to autoscale when fully unzoomed 406 410 // 407 void Edd _Plot::HandleZoom(const QwtDoubleRect &) {411 void EddPlot::HandleZoom(const QwtDoubleRect &) { 408 412 409 413 if(Zoomer->zoomRectIndex() == 0) { … … 417 421 // 418 422 419 void Edd _Plot::dragEnterEvent(QDragEnterEvent *Event) {423 void EddPlot::dragEnterEvent(QDragEnterEvent *Event) { 420 424 421 425 if (Event->mimeData()->hasFormat("Edd/Service")) Event->acceptProposedAction(); 422 426 } 423 427 424 void Edd _Plot::dropEvent(QDropEvent *Event) {428 void EddPlot::dropEvent(QDropEvent *Event) { 425 429 426 430 QByteArray D(Event->mimeData()->data("Edd/Service")); … … 429 433 430 434 // Opening context menu 431 void Edd _Plot::contextMenuEvent(QContextMenuEvent *Event) {435 void EddPlot::contextMenuEvent(QContextMenuEvent *Event) { 432 436 433 437 Menu->exec(Event->globalPos()); … … 435 439 436 440 // Drag&Drop method 437 void Edd _Plot::LegendClicked(QwtPlotItem *Item) {441 void EddPlot::LegendClicked(QwtPlotItem *Item) { 438 442 439 443 … … 451 455 452 456 // Zoom completely out 453 void Edd _Plot::MenuZoomOut() {457 void EddPlot::MenuZoomOut() { 454 458 455 459 Zoomer->zoom(0); … … 458 462 459 463 // Remove all items except last 460 void Edd _Plot::MenuSingleTrace() {464 void EddPlot::MenuSingleTrace() { 461 465 462 466 // Lock before accessing Items list … … 472 476 473 477 // Save data of plot as test 474 void Edd _Plot::MenuSaveASCII() {478 void EddPlot::MenuSaveASCII() { 475 479 QString Filename = QFileDialog::getSaveFileName(this, 476 480 "Filename", ".", "Text files (*.txt *.ascii *.asc);;All files (*)"); … … 497 501 498 502 // Print plot 499 void Edd _Plot::MenuPrint() {503 void EddPlot::MenuPrint() { 500 504 501 505 QPrinter *Printer = new QPrinter; … … 510 514 511 515 // Save plot as image 512 void Edd _Plot::MenuSave() {516 void EddPlot::MenuSave() { 513 517 514 518 QString Filename = QFileDialog::getSaveFileName(this, … … 524 528 525 529 // Add new service by pasting name 526 void Edd _Plot::MenuPasteService() {530 void EddPlot::MenuPasteService() { 527 531 528 532 const QMimeData *D = QApplication::clipboard()->mimeData(); … … 541 545 // Constructor 542 546 // 543 Edd _TextHist::Edd_TextHist(QString Name, bool Pure, QWidget *P):544 QTextEdit(P), EvidenceHistory(),Name(Name), Pure(Pure) {547 EddText::EddText(QString Name, bool Pure, QWidget *P): 548 QTextEdit(P), Name(Name), Pure(Pure) { 545 549 546 550 // Widget properties … … 561 565 void *Data; 562 566 563 if (GetHistory(Name.toAscii().data())) { 564 while (Next(Time, Size, Data)) { 567 class EvidenceHistory *HistClass = Handler->GetHistory(Name); 568 569 if (HistClass->GetHistory()) { 570 while (HistClass->Next(Time, Size, Data)) { 565 571 moveCursor (QTextCursor::Start); 566 572 insertPlainText(QString("(")+QDateTime::fromTime_t(Time).toString()+") "); … … 575 581 576 582 // Destructor 577 Edd _TextHist::~Edd_TextHist() {583 EddText::~EddText() { 578 584 579 585 Handler->Unsubscribe(Name); … … 582 588 583 589 // Update widget (must happen in GUI thread) 584 void Edd _TextHist::Update(QString Name, int Time, QByteArray, QString Format, QString Text) {590 void EddText::Update(QString Name, int Time, QByteArray, QString Format, QString Text) { 585 591 586 592 if (this->Name != Name) return; … … 617 623 // Interface to Dim system // 618 624 ///////////////////////////// 619 Edd _DIM::Edd_DIM() {625 EddDim::EddDim() { 620 626 621 627 Mutex = new QMutex(QMutex::Recursive); … … 630 636 // Connect to DIM handler 631 637 if (connect(this, SIGNAL(YEP(QString, int, QByteArray, QString, QString)), SLOT(Update(QString, int, QByteArray, QString, QString))) == false) { 632 printf("Failed connection in Edd_DIM()\n"); 633 } 634 } 635 636 Edd_DIM::~Edd_DIM() { 637 638 printf("Failed connection in EddDim()\n"); 639 } 640 } 641 642 EddDim::~EddDim() { 643 644 for (int i=0; i<HistoryList.size(); i++) delete HistoryList[i].HistClass; 638 645 delete Mutex; 639 646 } 640 647 641 648 // Subscribe to DIM service 642 void Edd _DIM::Subscribe(QString Name) {649 void EddDim::Subscribe(QString Name) { 643 650 644 651 // Lock before accessing list … … 667 674 668 675 // Unsubsribe from DIM service 669 void Edd _DIM::Unsubscribe(QString Name) {676 void EddDim::Unsubscribe(QString Name) { 670 677 671 678 // Lock before accessing list … … 682 689 } 683 690 691 // Get history buffer 692 class EvidenceHistory *EddDim::GetHistory(QString Name) { 693 694 // If history already available, return this 695 for (int i=0; i<HistoryList.size(); i++) if (HistoryList[i].Name == Name) { 696 HistoryList[i].Count++; 697 return HistoryList[i].HistClass; 698 } 699 700 struct HistItem New; 701 New.Name = Name; 702 New.HistClass = new EvidenceHistory(Name.toStdString()); 703 New.Count = 1; 704 HistoryList.append(New); 705 706 return New.HistClass; 707 708 } 709 684 710 // Update throughput statistics 685 void Edd _DIM::UpdateStatistics() {711 void EddDim::UpdateStatistics() { 686 712 687 713 // Lock before accessing internal variables … … 697 723 698 724 // Store service information for usage by Subscribe() and update statistics 699 void Edd _DIM::Update(QString Name, int Time, QByteArray Data, QString Format, QString Text) {725 void EddDim::Update(QString Name, int Time, QByteArray Data, QString Format, QString Text) { 700 726 701 727 // Lock before accessing list … … 717 743 718 744 // Handling of DIM service update 719 void Edd _DIM::infoHandler() {745 void EddDim::infoHandler() { 720 746 721 747 if (!EvidenceServer::ServiceOK(getInfo())) YEP(getInfo()->getName(), -1); … … 733 759 GUI::GUI() { 734 760 735 Handler = new Edd _DIM();761 Handler = new EddDim(); 736 762 737 763 // Set features of main window … … 742 768 setWindowTitle("Edd - Evidence Data Display"); 743 769 744 Edd _Indicator*Value;745 Edd _Plot *Graph;746 Edd _TextHist *Textout;770 EddLineDisplay *Value; 771 EddPlot *Graph; 772 EddText *Textout; 747 773 QString Text; 748 774 749 775 // TextBox for value 750 //Value = new Edd_Indicator((char *) "SQM/NSB", Central);751 //Graph = new Edd_Plot((char *) "SQM/NSB", Central);752 //Graph->AddService("BIAS/VOLT/ID00/00-000");753 776 754 777 … … 768 791 MainLayout = new QGridLayout(MainWidget); 769 792 770 Value = new Edd _Indicator("Alarm/Status");793 Value = new EddLineDisplay("Alarm/Status"); 771 794 Value->setMaximumWidth(200); 772 795 MainLayout->addWidget(Value, 0, 0, 1, 2); 773 796 774 Value = new Edd _Indicator("Alarm/MasterAlarm");797 Value = new EddLineDisplay("Alarm/MasterAlarm"); 775 798 MainLayout->addWidget(Value, 0, 1, 1, 1); 776 799 777 Textout = new Edd _TextHist("Alarm/Summary", true);800 Textout = new EddText("Alarm/Summary", true); 778 801 Textout->Accumulate = false; 779 802 Textout->setMaximumWidth(200); … … 781 804 MainLayout->addWidget(Textout, 1, 0, 1, 2); 782 805 783 Value = new Edd _Indicator("DColl/Status");806 Value = new EddLineDisplay("DColl/Status"); 784 807 Value->setMaximumWidth(200); 785 808 MainLayout->addWidget(Value, 3, 0, 1, 2); 786 809 787 Value = new Edd _Indicator("DColl/DataSizekB");810 Value = new EddLineDisplay("DColl/DataSizekB"); 788 811 MainLayout->addWidget(Value, 4, 0, 1, 1); 789 812 790 Value = new Edd _Indicator("DColl/LogSizekB");813 Value = new EddLineDisplay("DColl/LogSizekB"); 791 814 MainLayout->addWidget(Value, 4, 1, 1, 1); 792 815 793 Value = new Edd _Indicator("DColl/CurrentFile");816 Value = new EddLineDisplay("DColl/CurrentFile"); 794 817 Value->setMaximumWidth(400); 795 818 MainLayout->addWidget(Value, 5, 0, 1, 3); 796 819 797 Value = new Edd _Indicator("Config/Status");820 Value = new EddLineDisplay("Config/Status"); 798 821 Value->setMaximumWidth(200); 799 822 MainLayout->addWidget(Value, 6, 0, 1, 2); 800 823 801 Value = new Edd _Indicator("Config/ModifyTime");824 Value = new EddLineDisplay("Config/ModifyTime"); 802 825 Value->setMaximumWidth(200); 803 826 Value->ShowAsTime = true; … … 809 832 MainLayout->addWidget(Button, 7, 1, 1, 1); 810 833 811 Value = new Edd _Indicator("Edd/Rate_kBMin");834 Value = new EddLineDisplay("Edd/Rate_kBMin"); 812 835 MainLayout->addWidget(Value, 8, 0, 1, 1); 813 Value = new Edd _Indicator("Edd/Total_MB");836 Value = new EddLineDisplay("Edd/Total_MB"); 814 837 MainLayout->addWidget(Value, 8, 1, 1, 1); 815 838 … … 826 849 FeedbackWidget = new QWidget(); 827 850 FeedbackLayout = new QGridLayout(FeedbackWidget); 828 Graph = new Edd _Plot();851 Graph = new EddPlot(); 829 852 for (int i=0; i<36; i++) { 830 Value = new Edd _Indicator("Feedback/Average", i);853 Value = new EddLineDisplay("Feedback/Average", i); 831 854 FeedbackLayout->addWidget(Value, i%9+1, 0+i/9, 1, 1); 832 855 Graph->AddService("Feedback/Average", i); 833 856 } 834 FeedbackLayout->addWidget(Graph, 0, 4, 1 0, 3);835 836 //Graph = new Edd _Plot();857 FeedbackLayout->addWidget(Graph, 0, 4, 11, 3); 858 859 //Graph = new EddPlot(); 837 860 //for (int i=0; i<36; i++) { 838 861 //Text = Text.sprintf("Feedback/Sigma/ID%.2d/%.2d-%.3d",i/16, (i%16)/8, i%8); … … 841 864 //FeedbackLayout->addWidget(Graph, 10, 0, 10, 3); 842 865 843 Value = new Edd _Indicator("Feedback/Status");866 Value = new EddLineDisplay("Feedback/Status"); 844 867 Value->setMaximumWidth(200); 845 868 FeedbackLayout->addWidget(Value, 0, 0, 1, 3); 846 Value = new Edd _Indicator("Feedback/Count");869 Value = new EddLineDisplay("Feedback/Count"); 847 870 FeedbackLayout->addWidget(Value, 0, 3, 1, 1); 871 872 QWidget *Value1 = new QPushButton("Details"); 873 FeedbackLayout->addWidget(Value1, 10, 0, 1, 1); 874 connect(Value1, SIGNAL(pressed()), this, SLOT(FeedbackDetails())); 875 848 876 849 877 // Bias voltage page 850 878 BiasWidget = new QWidget(); 851 879 BiasLayout = new QGridLayout(BiasWidget); 852 Graph = new Edd _Plot();880 Graph = new EddPlot(); 853 881 for (int i=0; i<18; i++) { 854 Value = new Edd _Indicator("Bias/VOLT/ID00", i);882 Value = new EddLineDisplay("Bias/VOLT/ID00", i); 855 883 BiasLayout->addWidget(Value, i%9+1, 0+i/9, 1, 1); 856 884 Graph->AddService("Bias/VOLT/ID00", i); 857 885 858 Value = new Edd _Indicator("Bias/VOLT/ID00", i+32);886 Value = new EddLineDisplay("Bias/VOLT/ID00", i+32); 859 887 BiasLayout->addWidget(Value, i%9+1, 2+i/9, 1, 1); 860 888 Graph->AddService("Bias/VOLT/ID00",i+32); … … 862 890 863 891 BiasLayout->addWidget(Graph, 0, 4, 12, 3); 864 Value = new Edd _Indicator("Bias/Status");892 Value = new EddLineDisplay("Bias/Status"); 865 893 Value->setMaximumWidth(200); 866 894 BiasLayout->addWidget(Value, 0, 0, 1, 3); 867 895 868 Textout = new Edd _TextHist("Bias/Textout", true);896 Textout = new EddText("Bias/Textout", true); 869 897 Textout->setFixedWidth(400); 870 898 BiasLayout->addWidget(Textout, 10, 0, 4, 4); … … 873 901 EnvironmentWidget = new QWidget(); 874 902 EnvironmentLayout = new QGridLayout(EnvironmentWidget); 875 Value = new Edd _Indicator("ARDUINO/Status");903 Value = new EddLineDisplay("ARDUINO/Status"); 876 904 Value->setMaximumWidth(200); 877 905 EnvironmentLayout->addWidget(Value, 0, 0, 1, 3); 878 906 879 Graph = new Edd _Plot();907 Graph = new EddPlot(); 880 908 for (int i=0; i<10; i++) { 881 Value = new Edd _Indicator("ARDUINO/Data", i);909 Value = new EddLineDisplay("ARDUINO/Data", i); 882 910 EnvironmentLayout->addWidget(Value, i%5+1, i/5, 1, 1); 883 911 Graph->AddService("ARDUINO/Data", i); … … 885 913 EnvironmentLayout->addWidget(Graph, 0, 3, 6, 4); 886 914 887 Value = new Edd _Indicator("SQM/NSB");915 Value = new EddLineDisplay("SQM/NSB"); 888 916 EnvironmentLayout->addWidget(Value, 6, 0, 1, 1); 889 917 … … 951 979 } 952 980 981 // Feedback details page 982 void GUI::FeedbackDetails() { 983 984 QWidget *Value; 985 QWidget *Widget = new QWidget(); 986 QGridLayout *Layout = new QGridLayout(Widget); 987 EddPlot *Graph = new EddPlot(); 988 for (int i=0; i<36; i++) { 989 Value = new EddLineDisplay("Feedback/Sigma", i); 990 Layout->addWidget(Value, i%9+1, 0+i/9, 1, 1); 991 Graph->AddService("Feedback/Sigma", i); 992 } 993 Layout->addWidget(Graph, 0, 4, 11, 3); 994 995 Widget->show(); 996 } 997 953 998 // Start DIM Browser 954 999 void GUI::StartDIMBrowser() { -
Evidence/Edd/Edd.h
r171 r174 39 39 40 40 // General indicator for DIM service 41 class Edd _Indicator: public QLineEdit {41 class EddLineDisplay: public QLineEdit { 42 42 Q_OBJECT 43 43 … … 54 54 55 55 public: 56 Edd _Indicator(QString, int=0, QWidget * = NULL);57 ~Edd _Indicator();56 EddLineDisplay(QString, int=0, QWidget * = NULL); 57 ~EddLineDisplay(); 58 58 59 59 bool ShowAsTime; … … 68 68 69 69 // Graph class for history display 70 class Edd _Plot: public QwtPlot, public EvidenceHistory{70 class EddPlot: public QwtPlot { 71 71 Q_OBJECT 72 72 … … 99 99 100 100 public: 101 Edd _Plot(QString = QString(), int = 0, QWidget * = NULL);102 ~Edd _Plot();101 EddPlot(QString = QString(), int = 0, QWidget * = NULL); 102 ~EddPlot(); 103 103 void AddService(QString, int = 0); 104 104 … … 119 119 120 120 // Text history and output class 121 class Edd _TextHist: public QTextEdit, public EvidenceHistory{121 class EddText: public QTextEdit { 122 122 Q_OBJECT 123 123 … … 126 126 127 127 public: 128 Edd _TextHist(QString, bool = false, QWidget * = NULL);129 ~Edd _TextHist();128 EddText(QString, bool = false, QWidget * = NULL); 129 ~EddText(); 130 130 131 131 bool Accumulate; … … 136 136 137 137 // Interface to DIM system 138 class Edd _DIM: public QObject, public DimInfo {138 class EddDim: public QObject, public DimInfo { 139 139 Q_OBJECT 140 140 … … 151 151 QMutex *Mutex; 152 152 153 struct HistItem { 154 QString Name; 155 int Count; 156 class EvidenceHistory *HistClass; 157 }; 158 QList<HistItem> HistoryList; 159 153 160 long long TotalVolume; 154 161 long long MinuteVolume; … … 161 168 162 169 public: 163 Edd _DIM();164 ~Edd _DIM();170 EddDim(); 171 ~EddDim(); 165 172 166 173 void Subscribe(QString); 167 174 void Unsubscribe (QString); 175 class EvidenceHistory *GetHistory(QString); 168 176 169 177 signals: … … 178 186 QwtAnalogClock *Clock; 179 187 180 QWidget *Central, *MainWidget, *BiasWidget, *FeedbackWidget, * EnvironmentWidget;181 QGridLayout *MainLayout, *BiasLayout, *FeedbackLayout, * EnvironmentLayout;188 QWidget *Central, *MainWidget, *BiasWidget, *FeedbackWidget, *FeedbackDetailsWidget, *EnvironmentWidget; 189 QGridLayout *MainLayout, *BiasLayout, *FeedbackLayout, *FeedbackDetailsLayout, *EnvironmentLayout; 182 190 183 191 QTabWidget *TabWidget; … … 193 201 void MenuNewHistory(); 194 202 void StartDIMBrowser(); 203 void FeedbackDetails(); 195 204 }; 196 205
Note:
See TracChangeset
for help on using the changeset viewer.