Changeset 174
- Timestamp:
- 03/05/10 15:06:15 (15 years ago)
- Location:
- Evidence
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
Evidence/Alarm.cc
r159 r174 52 52 MasterAlarm = 0; 53 53 54 char *ServerNames = GetConfig(SERVER_NAME " servers");55 56 54 // Create DIM services 57 55 Summary = new DimService(SERVER_NAME"/Summary", AlarmSummary); … … 59 57 60 58 // Copy original list of servers to observe 59 char *ServerNames = GetConfig(SERVER_NAME " servers"); 61 60 ServerList = new char [strlen(ServerNames)+1]; 62 61 strcpy(ServerList, ServerNames); … … 151 150 static AlarmHandler Alarm; 152 151 153 // Request configuration data154 unsigned int Period = atoi(Alarm.GetConfig(SERVER_NAME " period"));155 156 152 // Check periodically if servers are up 157 153 while(!Alarm.ExitRequest) { … … 166 162 167 163 Alarm.UpdateAlarmSummary(); 168 sleep( Period);164 sleep(atoi(Alarm.GetConfig(SERVER_NAME " period"))); 169 165 } 170 166 } -
Evidence/DColl.cc
r173 r174 105 105 106 106 // Request configuration data 107 char *Change = GetConfig(SERVER_NAME " items");108 107 DataDir = GetConfig(SERVER_NAME " datadir"); 109 char *Logname = GetConfig(SERVER_NAME " logfile");110 108 SizeUpdateDelay = atoi(GetConfig(SERVER_NAME " sizeupdate")); 111 109 HistDir = GetConfig(SERVER_NAME " histdir"); 112 110 113 111 // Open log file 112 char *Logname = GetConfig(SERVER_NAME " logfile"); 114 113 if ((LogFile = fopen(Logname, "a")) == NULL) { 115 114 State(FATAL, "Could not open log file '%s' (%s)", Logname, strerror(errno)); … … 129 128 130 129 // Count how many minimum change value regular expressions are present 130 char *Change = GetConfig(SERVER_NAME " items"); 131 131 RegExCount = 0; 132 132 char *Token = strtok(Change, "\t "); … … 274 274 } 275 275 if(mkdir(Dir, S_IRWXU|S_IRWXG)==-1 && errno!=EEXIST) { 276 State(FATAL, "Could not create direc ory '%s' (%s)", Dir, strerror(errno));276 State(FATAL, "Could not create directory '%s' (%s)", Dir, strerror(errno)); 277 277 } 278 278 -
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 -
Evidence/Evidence.cc
r168 r174 34 34 EvidenceServer *ThisServer; 35 35 36 36 37 // Constructor starts server with given name 37 38 EvidenceServer::EvidenceServer(const char *Name) { … … 50 51 // Catch C++ unhandled exceptions 51 52 set_terminate(Terminate); 53 54 // Subscribe to modify service for keeping track of config file changes 55 ModifyInfo = new class ConfigUpdate(); 52 56 53 57 // Start server … … 72 76 delete[] ConfigList[i].Value; 73 77 } 78 delete ModifyInfo; 74 79 } 75 80 … … 125 130 } 126 131 127 // Get configuration data (program terminates if data is missing)132 // Get configuration data 128 133 // 134 // Program terminates if data is missing and no default given. Actual configuration 135 // request will be made only if config file has modification since last request. 129 136 // The memory allocated by all calls to this function will be freed by 130 137 // the destructor. 131 138 char* EvidenceServer::GetConfig(const char *Item, const char *Default) { 132 139 133 // Determine configuration file update time 134 DimCurrentInfo ModifyTime("Config/ModifyTime", 0); 135 int Time = ModifyTime.getInt(), ItemNo = -1; 140 int ItemNo = -1; 136 141 137 142 // Check if configuration request already in list … … 139 144 if (strcmp(ConfigList[i].Name, Item) == 0) { 140 145 // Return original value if still up to date 141 if (ConfigList[i].Time >= Time) return ConfigList[i].Value;146 if (ConfigList[i].Time >= ModifyInfo->LastModifyTime) return ConfigList[i].Value; 142 147 143 148 // Otherwise, free memory of old value … … 172 177 strcpy(ConfigList[ItemNo].Name, Item); 173 178 strcpy(ConfigList[ItemNo].Value, Result); 174 ConfigList[ItemNo].Time = Time;179 ConfigList[ItemNo].Time = ModifyInfo->LastModifyTime; 175 180 176 181 // Return address to configuration value … … 310 315 311 316 // Constructor 312 EvidenceHistory::EvidenceHistory() { 317 EvidenceHistory::EvidenceHistory(std::string Name, int Delay): 318 Name(Name+".hist"), 319 Delay(Delay) { 313 320 314 321 Buffer = NULL; 322 LastUpdate = 0; 315 323 } 316 324 … … 322 330 323 331 // Requests service history 324 bool EvidenceHistory::GetHistory(char *Name) { 325 326 DimCurrentInfo Info((string(Name)+".hist").c_str(), NO_LINK); 327 332 bool EvidenceHistory::GetHistory() { 333 334 // Check if last buffer update less than minimum delay in the past 335 if ((Buffer != NULL) && (time(NULL)-LastUpdate < Delay)) { 336 Offset = *(int *) Buffer; 337 return true; 338 } 339 LastUpdate = time(NULL); 340 328 341 // Check if service available 342 DimCurrentInfo Info(Name.c_str(), NO_LINK); 329 343 if (((Info.getSize() == strlen(NO_LINK)+1) && 330 344 (memcmp(Info.getData(), NO_LINK, Info.getSize()) == 0))) return false; -
Evidence/Evidence.h
r165 r174 19 19 // Class declation of Evidence server 20 20 class EvidenceServer: public DimServer { 21 private: 21 22 22 private: 23 // This class will contain in LastModifyTime always 24 // the unix time of the last config file update 25 class ConfigUpdate: public DimClient { 26 DimInfo *ModifyInfo; 27 28 public: 29 ConfigUpdate() { 30 LastModifyTime = 0; 31 ModifyInfo = new DimInfo("Config/ModifyTime", NO_LINK, this); 32 } 33 ~ConfigUpdate() { 34 delete ModifyInfo; 35 } 36 void infoHandler(){ 37 if (EvidenceServer::ServiceOK(getInfo())) LastModifyTime = getInfo()->getInt(); 38 } 39 int LastModifyTime; 40 }; 41 23 42 struct ConfigItem { 24 43 char *Name; … … 29 48 30 49 DimService *Status; 50 class ConfigUpdate *ModifyInfo; 51 31 52 char *InitMsg; 53 int LastModifyTime; 32 54 33 55 static void SignalHandler(int); // static for signal() … … 39 61 EvidenceServer(const char *); 40 62 ~EvidenceServer(); 41 63 42 64 enum StateType {INFO=0, WARN=1, ERROR=2, FATAL=3}; 43 65 … … 55 77 static const int EndMark[]; 56 78 57 std::string HistoryName;79 std::string Name; 58 80 char *Buffer; 59 81 int BufferSize; 60 82 int Offset; 61 83 int Delay; 84 int LastUpdate; 85 62 86 public: 63 EvidenceHistory( );87 EvidenceHistory(std::string, int = 10); 64 88 ~EvidenceHistory(); 65 89 66 bool GetHistory( char *);90 bool GetHistory(); 67 91 bool Next(int &, int &, void *&); 68 92 };
Note:
See TracChangeset
for help on using the changeset viewer.