Legend:
- Unmodified
- Added
- Removed
-
Evidence/Config.cc
r154 r171 116 116 if(Token1==NULL || Token2==NULL || Token3==NULL) continue; 117 117 118 // Check for match and then send data (removing trainlin whitespace)118 // Check for match and then send data (removing whitespace and both ends) 119 119 if (strstr(Request, Token1)!=NULL && strstr(Request, Token2)!=NULL) { 120 120 while (isspace(*Token3) != 0) Token3++; 121 while ((strlen(Token3)>0) && isspace(*(Token3+strlen(Token3)-1))) *(Token3+strlen(Token3)-1) = '\0'; 121 122 setData(Token3); 122 123 break; -
Evidence/Edd/Edd.cc
r168 r171 31 31 32 32 Browser.getServices(Service); 33 if (Browser.getNextService(Name, Format) != DimSERVICE) return NULL;33 if (Browser.getNextService(Name, Format) != DimSERVICE) return new Edd_Plot(Service, Index);//return NULL; 34 34 35 35 if (strlen(Format) == 1 && *Format != 'C') return new Edd_Plot(Service, Index); … … 52 52 53 53 // Connect to DIM handler 54 if (connect(Handler, SIGNAL(YEP( DimInfo*, int, QByteArray, QString)), SLOT(Update(DimInfo*, int, QByteArray, QString))) == false) {54 if (connect(Handler, SIGNAL(YEP(QString, int, QByteArray, QString, QString)), SLOT(Update(QString, int, QByteArray, QString, QString))) == false) { 55 55 printf("Failed connection for %s\n", Name.toAscii().data()); 56 56 } … … 73 73 74 74 // Update widget 75 void Edd_Indicator::Update( DimInfo *Info, int Time, QByteArray Array, QString Text) {76 77 if (ServiceName != Info->getName()) return;75 void Edd_Indicator::Update(QString Name, int Time, QByteArray Array, QString Format, QString Text) { 76 77 if (ServiceName != Name) return; 78 78 79 79 QPalette Pal = palette(); … … 82 82 if (Time == -1) { 83 83 setText("n/a"); 84 setStatusTip(QString("%1: unavailable").arg( Info->getName()));84 setStatusTip(QString("%1: unavailable").arg(ServiceName)); 85 85 Pal.setColor(QPalette::Base, Qt::lightGray); 86 86 } … … 95 95 } 96 96 97 if ( toupper(*(Info->getFormat()) != 'C')) Text = Text.section(' ', Index, Index);97 if (Format[0].toUpper() != 'C') Text = Text.section(' ', Index, Index); 98 98 99 99 if (!ShowAsTime) setText(Text); … … 102 102 103 103 // Update status tip 104 setStatusTip(QString("%1 : Last update %2 Format '%3' Index %4").arg(Info->getName()).arg( QDateTime::fromTime_t(Time).toString()).arg(Info->getFormat()).arg(Index));104 setStatusTip(QString("%1 (%4): Last update %2 Format '%3'").arg(ServiceName).arg( QDateTime::fromTime_t(Time).toString()).arg(Format).arg(Index)); 105 105 } 106 106 … … 140 140 QDrag *Drag = new QDrag(this); 141 141 QMimeData *MimeData = new QMimeData; 142 MimeData->setText(ServiceName); 142 QByteArray Data; 143 MimeData->setData("Edd/Service", Data.append(ServiceName + " " + QString::number(Index))); 143 144 Drag->setMimeData(MimeData); 144 145 Drag->exec(); … … 163 164 void Edd_Indicator::MenuCopyService() { 164 165 165 QApplication::clipboard()->setText(ServiceName); 166 QMimeData *MimeData = new QMimeData; 167 QByteArray Data; 168 MimeData->setData("Edd/Service", Data.append(ServiceName + " " + QString::number(Index))); 169 QApplication::clipboard()->setMimeData(MimeData); 166 170 } 167 171 168 172 // Menu: Copy data 169 173 void Edd_Indicator::MenuCopyData() { 170 174 171 175 QApplication::clipboard()->setText(text()); 172 176 } 177 173 178 174 179 ////////////////////////////////// … … 205 210 206 211 // Connect to DIM handler 207 if (connect(Handler, SIGNAL(YEP( DimInfo *, int, QByteArray, QString)), SLOT(Update(DimInfo *, int, QByteArray, QString))) == false) {212 if (connect(Handler, SIGNAL(YEP(QString, int, QByteArray, QString, QString)), SLOT(Update(QString, int, QByteArray, QString, QString))) == false) { 208 213 printf("Failed connection for %s\n", DIMService.toAscii().data()); 209 214 } … … 247 252 // 248 253 void Edd_Plot::AddService(QString Name, int Index) { 249 return; 254 250 255 // Lock before accessing Items list 251 256 QMutexLocker Locker(Mutex); … … 254 259 for (int i=0; i<Items.size(); i++) { 255 260 if (Name == Items[i].Name && Index == Items[i].Index) { 256 QMessageBox::warning(this, "Edd Message",Name+" ( index"+QString::number(Index)+") already present",QMessageBox::Ok);261 QMessageBox::warning(this, "Edd Message",Name+" ("+QString::number(Index)+") already present",QMessageBox::Ok); 257 262 return; 258 263 } … … 275 280 276 281 // Update widget (must happen in GUI thread) 277 void Edd_Plot::Update(DimInfo *Info, int Time, QByteArray, QString Text) { 278 279 // Check if service available 280 if (Time == -1) { 281 setStatusTip(QString("%1: unavailable").arg(Info->getName())); 282 return; 283 } 282 void Edd_Plot::Update(QString Name, int Time, QByteArray, QString Format, QString Text) { 284 283 285 284 // Lock before accessing Items list … … 288 287 // Determine which plot item this call belongs to 289 288 int ItemNo; 290 for (ItemNo=0; ItemNo<Items.size(); ItemNo++) if (Items[ItemNo].Name == Info->getName()) { 289 for (ItemNo=0; ItemNo<Items.size(); ItemNo++) if (Items[ItemNo].Name == Name) { 290 291 // Check if service available 292 if (Time == -1) { 293 setStatusTip(QString("%1: unavailable").arg(Name)); 294 return; 295 } 291 296 292 297 // If size limit reached, clear buffer … … 305 310 double Number=0; 306 311 while (Next(Time, Size, Data)) { 307 switch ( toupper(*(Info->getFormat()))) {312 switch (Format[0].toUpper().toAscii()) { 308 313 case 'I': 309 314 case 'L': Number = *((int *) Data + Items[ItemNo].Index); break; … … 314 319 default: break; 315 320 } 316 317 321 Items[ItemNo].x.append(Time); 318 322 Items[ItemNo].y.append(Number); … … 333 337 334 338 // Append data 335 Text = Text.section(' ', Items[ItemNo].Index, Items[ItemNo].Index);336 339 QString Txt = Text; 340 Txt = Txt.section(' ', Items[ItemNo].Index, Items[ItemNo].Index); 337 341 Items[ItemNo].x.append(Time); 338 Items[ItemNo].y.append(atof(T ext.toAscii().data()));342 Items[ItemNo].y.append(atof(Txt.toAscii().data())); 339 343 340 344 // Update largest and smallest value … … 344 348 // Update status tip 345 349 QDateTime Timex = QDateTime::fromTime_t(Time); 346 setStatusTip(QString("%1: Last update %2 Format '%3'").arg( Info->getName(), Timex.toString()).arg(Info->getFormat()));350 setStatusTip(QString("%1: Last update %2 Format '%3'").arg(Name).arg(Timex.toString()).arg(Format)); 347 351 } 348 352 … … 415 419 void Edd_Plot::dragEnterEvent(QDragEnterEvent *Event) { 416 420 417 if (Event->mimeData()->hasFormat(" text/plain")) Event->acceptProposedAction();421 if (Event->mimeData()->hasFormat("Edd/Service")) Event->acceptProposedAction(); 418 422 } 419 423 420 424 void Edd_Plot::dropEvent(QDropEvent *Event) { 421 425 422 AddService(Event->mimeData()->text().toAscii().data()); 426 QByteArray D(Event->mimeData()->data("Edd/Service")); 427 AddService(D.left(D.lastIndexOf(' ')), D.right(D.size()-D.lastIndexOf(' ')).toInt()); 423 428 } 424 429 … … 432 437 void Edd_Plot::LegendClicked(QwtPlotItem *Item) { 433 438 439 440 QString D(Item->title().text()); 441 D.replace('(',' ').chop(1); 442 434 443 QDrag *Drag = new QDrag(this); 435 444 QMimeData *MimeData = new QMimeData; 436 MimeData->setText(Item->title().text().remove(".hist")); 445 QByteArray Data; 446 MimeData->setData("Edd/Service", Data.append(D)); 437 447 Drag->setMimeData(MimeData); 438 448 Drag->exec(); … … 516 526 void Edd_Plot::MenuPasteService() { 517 527 518 AddService(QApplication::clipboard()->text().toAscii().data()); 519 } 520 521 522 /////////////////////////////////////// 528 const QMimeData *D = QApplication::clipboard()->mimeData(); 529 if (!D->hasFormat("Edd/Service")) return; 530 531 QByteArray E(D->data("Edd/Service")); 532 AddService(E.left(E.lastIndexOf(' ')), E.right(E.size()-E.lastIndexOf(' ')).toInt()); 533 } 534 535 536 ////////////////////////////////////// 523 537 // History text box for DIM service // 524 538 ////////////////////////////////////// … … 527 541 // Constructor 528 542 // 529 Edd_TextHist::Edd_TextHist(QString Name, QWidget *P):530 QTextEdit(P), EvidenceHistory(), Name(Name) {543 Edd_TextHist::Edd_TextHist(QString Name, bool Pure, QWidget *P): 544 QTextEdit(P), EvidenceHistory(), Name(Name), Pure(Pure) { 531 545 532 546 // Widget properties … … 535 549 setAutoFillBackground(true); 536 550 document()->setMaximumBlockCount(1000); 551 Accumulate = true; 537 552 538 553 // Connect to DIM handler 539 if (connect(Handler, SIGNAL(YEP( DimInfo*, int, QByteArray, QString)), SLOT(Update(DimInfo*, int, QByteArray, QString))) == false) {554 if (connect(Handler, SIGNAL(YEP(QString, int, QByteArray, QString, QString)), SLOT(Update(QString, int, QByteArray, QString, QString))) == false) { 540 555 printf("Failed connection for %s\n", Name.toAscii().data()); 541 556 } 542 557 543 // Get history for this service 544 int Time, Size; 545 void *Data; 546 547 if (GetHistory(Name.toAscii().data())) { 548 while (Next(Time, Size, Data)) { 549 moveCursor (QTextCursor::Start); 550 insertPlainText(QString("(")+QDateTime::fromTime_t(Time).toString()+") "); 551 insertPlainText(QString((char *) Data) + "\n"); 558 if (!Pure) { 559 // Get history for this service 560 int Time, Size; 561 void *Data; 562 563 if (GetHistory(Name.toAscii().data())) { 564 while (Next(Time, Size, Data)) { 565 moveCursor (QTextCursor::Start); 566 insertPlainText(QString("(")+QDateTime::fromTime_t(Time).toString()+") "); 567 insertPlainText(QString((char *) Data) + "\n"); 568 } 552 569 } 553 570 } … … 565 582 566 583 // Update widget (must happen in GUI thread) 567 void Edd_TextHist::Update(DimInfo *Info, int Time, QByteArray, QString Text) { 568 569 if (Name != Info->getName()) return; 584 void Edd_TextHist::Update(QString Name, int Time, QByteArray, QString Format, QString Text) { 585 586 if (this->Name != Name) return; 587 QPalette Pal = palette(); 570 588 571 589 // Check if service available 572 590 if (Time == -1) { 573 setStatusTip(QString("%1: unavailable").arg(Info->getName())); 591 setStatusTip(QString("%1: unavailable").arg(Name)); 592 Pal.setColor(QPalette::Base, Qt::lightGray); 593 setPalette(Pal); 574 594 return; 575 595 } 576 596 597 Pal.setColor(QPalette::Base, Qt::white); 598 setPalette(Pal); 577 599 QDateTime Timex = QDateTime::fromTime_t(Time); 578 600 579 moveCursor(QTextCursor::Start); 580 insertPlainText(QString("(")+Timex.toString()+QString(") ")); 581 insertPlainText(Text + "\n"); 582 601 // Clear display in case text should not accumulate 602 if (Accumulate == false) clear(); 603 604 if (!Pure) { 605 moveCursor(QTextCursor::Start); 606 insertPlainText(QString("(")+Timex.toString()+QString(") ")); 607 insertPlainText(Text + "\n"); 608 } 609 else if (Format == "C") insertPlainText(Text); 610 583 611 // Update status tip 584 setStatusTip(QString("%1: Last update %2 Format '%3'").arg(Info->getName(), Timex.toString()).arg(Info->getFormat())); 585 } 586 587 588 ////////////////// 589 // Text display // 590 ////////////////// 591 592 // Constructor 593 Edd_Textout::Edd_Textout(QString Name, QWidget *P): QTextEdit(P), Name(Name) { 594 595 // Widget properties 596 setReadOnly(true); 597 setAutoFillBackground(true); 598 document()->setMaximumBlockCount(1000); 599 Accumulate = true; 600 601 // Connect to DIM handler 602 if (connect(Handler, SIGNAL(YEP(DimInfo*, int, QByteArray, QString)), SLOT(Update(DimInfo*, int, QByteArray, QString))) == false) { 603 printf("Failed connection for %s\n", Name.toAscii().data()); 604 } 605 606 // Subscribe to service 607 Handler->Subscribe(Name); 608 } 609 610 // Destructor 611 Edd_Textout::~Edd_Textout() { 612 613 Handler->Unsubscribe(Name); 614 } 615 616 // Handling of DIM service update 617 void Edd_Textout::Update(DimInfo *Info, int Time, QByteArray, QString Text) { 618 619 if (Name != Info->getName()) return; 620 621 QPalette Pal = palette(); 622 623 // Check if service available 624 if (Time == -1) { 625 setStatusTip(QString("%1: unavailable").arg(Info->getName())); 626 Pal.setColor(QPalette::Base, Qt::lightGray); 627 } 628 else { 629 Pal.setColor(QPalette::Base, Qt::white); 630 631 // Clear display in case text should not accumulate 632 if (Accumulate == false) clear(); 633 634 // Add if service contains only a string 635 if (strcmp(Info->getFormat(), "C") == 0) insertPlainText(Text); 636 637 // Update status tip 638 setStatusTip(QString("%1: Last update %2 Format '%3'").arg(Info->getName(), QDateTime::fromTime_t(Time).toString()).arg(Info->getFormat())); 639 } 640 setPalette(Pal); 612 setStatusTip(QString("%1: Last update %2 Format '%3'").arg(Name).arg(Timex.toString()).arg(Format)); 641 613 } 642 614 … … 649 621 Mutex = new QMutex(QMutex::Recursive); 650 622 623 MinuteVolume = 0; 624 TotalVolume = 0; 625 626 QTimer *Timer = new QTimer(this); 627 Timer->connect(Timer, SIGNAL(timeout()), this, SLOT(UpdateStatistics())); 628 Timer->start(10000); 629 651 630 // Connect to DIM handler 652 if (connect(this, SIGNAL(YEP( DimInfo*, int, QByteArray, QString)), SLOT(Update(DimInfo*, int, QByteArray, QString))) == false) {631 if (connect(this, SIGNAL(YEP(QString, int, QByteArray, QString, QString)), SLOT(Update(QString, int, QByteArray, QString, QString))) == false) { 653 632 printf("Failed connection in Edd_DIM()\n"); 654 633 } … … 666 645 QMutexLocker Locker(Mutex); 667 646 668 // Check if already subscribed to service, then increase usage count and emit last service data647 // If already subscribed to service, increase usage count 669 648 for (int i=0; i<ServiceList.size(); i++) if (ServiceList[i].Name == Name) { 670 649 ServiceList[i].Count++; 671 YEP(ServiceList[i].DIMService, ServiceList[i].TimeStamp, ServiceList[i].ByteArray, ServiceList[i].Text); 650 // If service already reveived, reemit for new subscriber 651 if (!ServiceList[i].ByteArray.isEmpty()) { 652 YEP(Name, ServiceList[i].TimeStamp, ServiceList[i].ByteArray, ServiceList[i].Format, ServiceList[i].Text); 653 } 672 654 return; 673 655 } … … 676 658 struct Item New; 677 659 New.Name = Name; 660 New.ByteArray = QByteArray(); 678 661 New.DIMService = new DimStampedInfo(Name.toAscii().data(), INT_MAX, NO_LINK, this); 679 662 New.Count = 1; … … 699 682 } 700 683 701 // Store service information for usage by Subscribe() 702 void Edd_DIM::Update(DimInfo *Info, int Time, QByteArray Data, QString Text) { 684 // Update throughput statistics 685 void Edd_DIM::UpdateStatistics() { 686 687 // Lock before accessing internal variables 688 QMutexLocker Locker(Mutex); 689 690 float Rate = MinuteVolume/1024.0 * 6; 691 float Total = TotalVolume/1024.0/1024.0; 692 693 YEP("Edd/Rate_kBMin", time(NULL), QByteArray::number(Rate), "F", QString::number(Rate)); 694 YEP("Edd/Total_MB", time(NULL), QByteArray::number(Total), "F", QString::number(Total)); 695 MinuteVolume = 0; 696 } 697 698 // 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) { 703 700 704 701 // Lock before accessing list 705 702 QMutexLocker Locker(Mutex); 706 703 707 for (int i=0; i<ServiceList.size(); i++) if (ServiceList[i].Name == Info->getName()) {704 for (int i=0; i<ServiceList.size(); i++) if (ServiceList[i].Name == Name) { 708 705 ServiceList[i].TimeStamp = Time; 709 706 ServiceList[i].ByteArray = Data; 707 ServiceList[i].Format = Format; 710 708 ServiceList[i].Text = Text; 709 } 710 711 // Update statistics only for Dim services 712 if (!Name.startsWith("Edd/")) { 713 TotalVolume += Data.size(); 714 MinuteVolume += Data.size(); 711 715 } 712 716 } … … 715 719 void Edd_DIM::infoHandler() { 716 720 717 if (!EvidenceServer::ServiceOK(getInfo())) YEP(getInfo() , -1);721 if (!EvidenceServer::ServiceOK(getInfo())) YEP(getInfo()->getName(), -1); 718 722 else { 719 char *T xt = EvidenceServer::ToString(getInfo());720 YEP(getInfo() , getInfo()->getTimestamp(), QByteArray((char *) getInfo()->getData(), getInfo()->getSize()), QString(Txt));721 free(T xt);723 char *Text = EvidenceServer::ToString(getInfo()); 724 YEP(getInfo()->getName(), getInfo()->getTimestamp(), QByteArray((char *) getInfo()->getData(), getInfo()->getSize()), getInfo()->getFormat(), Text); 725 free(Text); 722 726 } 723 727 } … … 740 744 Edd_Indicator *Value; 741 745 Edd_Plot *Graph; 742 Edd_Text out *Textout;746 Edd_TextHist *Textout; 743 747 QString Text; 744 748 … … 771 775 MainLayout->addWidget(Value, 0, 1, 1, 1); 772 776 773 Textout = new Edd_Text out("Alarm/Summary");777 Textout = new Edd_TextHist("Alarm/Summary", true); 774 778 Textout->Accumulate = false; 775 779 Textout->setMaximumWidth(200); … … 804 808 connect(Button, SIGNAL(released()), SLOT(StartDIMBrowser())); 805 809 MainLayout->addWidget(Button, 7, 1, 1, 1); 810 811 Value = new Edd_Indicator("Edd/Rate_kBMin"); 812 MainLayout->addWidget(Value, 8, 0, 1, 1); 813 Value = new Edd_Indicator("Edd/Total_MB"); 814 MainLayout->addWidget(Value, 8, 1, 1, 1); 806 815 807 816 // Layout of all widgets … … 819 828 Graph = new Edd_Plot(); 820 829 for (int i=0; i<36; i++) { 821 //Text = Text.sprintf("Feedback/Average/ID%.2d/%.2d-%.3d",i/16, (i%16)/8, i%8); 822 Text = Text.sprintf("Feedback/AverageTest/ID%.2d",i/16); 823 Value = new Edd_Indicator(Text, i%16); 830 Value = new Edd_Indicator("Feedback/Average", i); 824 831 FeedbackLayout->addWidget(Value, i%9+1, 0+i/9, 1, 1); 825 //Graph->AddService(Text);826 } 827 FeedbackLayout->addWidget(Graph, 0, 4, 1 1, 3);832 Graph->AddService("Feedback/Average", i); 833 } 834 FeedbackLayout->addWidget(Graph, 0, 4, 10, 3); 828 835 829 836 //Graph = new Edd_Plot(); … … 847 854 Value = new Edd_Indicator("Bias/VOLT/ID00", i); 848 855 BiasLayout->addWidget(Value, i%9+1, 0+i/9, 1, 1); 849 //Graph->AddService(Text, i);856 Graph->AddService("Bias/VOLT/ID00", i); 850 857 851 858 Value = new Edd_Indicator("Bias/VOLT/ID00", i+32); 852 859 BiasLayout->addWidget(Value, i%9+1, 2+i/9, 1, 1); 853 //Graph->AddService(Text,i+32);860 Graph->AddService("Bias/VOLT/ID00",i+32); 854 861 } 855 862 … … 859 866 BiasLayout->addWidget(Value, 0, 0, 1, 3); 860 867 861 Textout = new Edd_Text out("Bias/Textout");868 Textout = new Edd_TextHist("Bias/Textout", true); 862 869 Textout->setFixedWidth(400); 863 870 BiasLayout->addWidget(Textout, 10, 0, 4, 4); … … 876 883 Graph->AddService("ARDUINO/Data", i); 877 884 } 878 EnvironmentLayout->addWidget(Graph, 0, 3, 7, 4);885 EnvironmentLayout->addWidget(Graph, 0, 3, 6, 4); 879 886 880 887 Value = new Edd_Indicator("SQM/NSB"); -
Evidence/Edd/Edd.h
r168 r171 60 60 61 61 private slots: 62 void Update( DimInfo *, int, QByteArray, QString);62 void Update(QString, int, QByteArray, QString, QString); 63 63 void contextMenuEvent(QContextMenuEvent *); 64 64 void MenuOpenHistory(); … … 104 104 105 105 private slots: 106 void Update(QString, int, QByteArray, QString, QString); 106 107 void UpdatePlot(); 107 void Update(DimInfo* Info, int, QByteArray, QString);108 108 109 109 void HandleZoom(const QwtDoubleRect &); … … 118 118 }; 119 119 120 // Text history class120 // Text history and output class 121 121 class Edd_TextHist: public QTextEdit, public EvidenceHistory { 122 122 Q_OBJECT 123 123 124 124 QString Name; 125 bool Pure; 125 126 126 127 public: 127 Edd_TextHist(QString, QWidget * = NULL);128 Edd_TextHist(QString, bool = false, QWidget * = NULL); 128 129 ~Edd_TextHist(); 129 130 131 bool Accumulate; 132 130 133 private slots: 131 void Update(DimInfo* Info, int, QByteArray, QString); 132 }; 133 134 // Textout indicator for DIM service 135 class Edd_Textout: public QTextEdit, public EvidenceHistory { 136 Q_OBJECT 137 138 QString Name; 139 140 public: 141 Edd_Textout(QString, QWidget * = NULL); 142 ~Edd_Textout(); 143 144 bool Accumulate; 145 146 private slots: 147 void Update(DimInfo* Info, int, QByteArray, QString); 134 void Update(QString, int, QByteArray, QString, QString); 148 135 }; 149 136 … … 158 145 int TimeStamp; 159 146 QByteArray ByteArray; 147 QString Format; 160 148 QString Text; 161 149 }; … … 163 151 QMutex *Mutex; 164 152 153 long long TotalVolume; 154 long long MinuteVolume; 155 165 156 void infoHandler(); 166 157 167 158 private slots: 168 void Update(DimInfo *, int, QByteArray, QString); 159 void Update(QString, int, QByteArray, QString, QString); 160 void UpdateStatistics(); 169 161 170 162 public: … … 176 168 177 169 signals: 178 void YEP( DimInfo *, int, QByteArray = QByteArray(), QString = QString());170 void YEP(QString, int, QByteArray = QByteArray(), QString = QString(), QString = QString()); 179 171 }; 180 172
Note:
See TracChangeset
for help on using the changeset viewer.