Changeset 12894
- Timestamp:
- 02/16/12 14:44:55 (13 years ago)
- Location:
- fact
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
fact/Evidence/Evidence.cc
r12892 r12894 421 421 } 422 422 423 // Simplify format "?;1" to "?"424 if (strlen(Format)==3 && Format[2]=='1') Format[1] = '\0';425 426 // Structure: print hex representation427 if (strlen(Format) != 1) {428 for (int i=0; i<Size; i++) {429 Text << setw(2) << hex << *((char *) Data + i) << " ";430 }431 return Text.str();432 }433 434 423 // String if format "C" and terminated with \0 435 424 if (strcmp(Format, "C") == 0 && Size > 0 && *((char *) Data+Size-1)=='\0') { 436 425 return string((char *) Data); 437 426 } 438 427 428 // Check if format is made of identical component types 429 vector<string> Components = Tokenize(Format, ";"); 430 431 for (unsigned int i=0; i<Components.size(); i++) { 432 if (Components[i].empty()) return string(); 433 434 // Print hex representation if format complex 435 if (Components[i][0] != Components[0][0]) { 436 for (int i=0; i<Size; i++) { 437 Text << setw(2) << hex << *((char *) Data + i) << " "; 438 } 439 return Text.str(); 440 } 441 } 442 439 443 // Number array 440 444 int ElementSize; 445 441 446 switch (toupper(*Format)) { 442 447 case 'B': -
fact/Evidence/GUI.cc
r11360 r12894 8 8 a DIM status service 9 9 10 April 2010, Oliver Grimm10 April 2010, February 2012, Oliver Grimm 11 11 12 12 ============================================================ */ … … 19 19 // History chooser function (opens plot for numeric data, TextHist for all other) 20 20 // 21 void OpenHistory(char *Service, int Index) {21 void OpenHistory(char *Service, int FromIndex, int ToIndex) { 22 22 23 23 QString Format; … … 29 29 if (strcmp(Service, "Edd/Rate_kBSec") == 0) Format = "F"; 30 30 else if (Hist == NULL || Hist->GetFormat() == NULL) { 31 QMessageBox::warning(NULL, "Edd Message", QString("Could not retrieve history for service ") + Service ,QMessageBox::Ok); 31 //QMessageBox::warning(NULL, "Edd Message", QString("Could not retrieve history for service ") + Service ,QMessageBox::Ok); 32 printf("Edd Message: Could not retrieve history for service %s\n", Service); 32 33 } 33 34 else Format = Hist->GetFormat(); … … 44 45 M->setStatusBar(new QStatusBar(M)); 45 46 M->setAttribute(Qt::WA_DeleteOnClose); 46 M->setWindowTitle("Edd History - " + QString(Service)); 47 48 QWidget *W; 49 if (Format.size() == 1 && Format[0] != 'C') W = new EddPlot(Service, Index); 50 else W = new EddText(Service); 47 M->setWindowTitle("Edd History"); 51 48 52 49 QGridLayout *Layout = new QGridLayout(M->centralWidget()); 53 Layout->addWidget(W, 0, 0); 54 Layout->addWidget(new EddLineDisplay(Service, Index), 1, 0); 55 M->resize(300,350); 50 51 if (Format.size() == 1 && Format[0] == 'C') Layout->addWidget(new EddText(Service), 0, 0); 52 else { 53 EddPlot *W = new EddPlot(Service, FromIndex); 54 for (int i=FromIndex+1; i<=ToIndex; i++) { 55 W->AddService(Service,i); 56 Layout->addWidget(new EddLineDisplay(Service, i), 1 + (i-FromIndex)/5, (i-FromIndex)%5); 57 } 58 Layout->addWidget(W, 0, 0, 1, 5); 59 } 60 61 Layout->addWidget(new EddLineDisplay(Service, FromIndex), 1, 0); 62 M->resize(400,450); 56 63 M->show(); 57 64 } … … 107 114 EddLineDisplay::~EddLineDisplay() { 108 115 109 Handler->Unsubscribe(ServiceName, this );116 Handler->Unsubscribe(ServiceName, this, Index); 110 117 } 111 118 … … 404 411 405 412 // Append data if service available 406 if (SetStatus(this, Name, Time, Format)) { 407 //QString Txt = Text; 408 //Txt = Txt.section(' ', List[ItemNo].Index, List[ItemNo].Index); 409 //AddPoint(ItemNo, Time, atof(Txt.toAscii().data())); 410 AddPoint(ItemNo, Time, atof(Text.toAscii().data())); 411 } 412 413 if (SetStatus(this, Name, Time, Format)) AddPoint(ItemNo, Time, atof(Text.toAscii().data())); 413 414 NewData = true; 414 415 } … … 485 486 486 487 for (int i=0; i<List.size(); i++) if (List[i].Signal == Curve) { 487 Handler->Unsubscribe(List[i].Name, this );488 Handler->Unsubscribe(List[i].Name, this, List[i].Index); 488 489 List.removeAt(i); 489 490 } … … 1007 1008 // Check if already subscribed to service 1008 1009 if (ServiceList.contains(Name)) { 1009 ServiceList[Name].Subscribers[Instance] = Index; 1010 if (Index>=0 && Index<ServiceList[Name].Items.size()) Instance->Update(Name, ServiceList[Name].TimeStamp, ServiceList[Name].ByteArray, ServiceList[Name].Format, ServiceList[Name].Items[Index]); 1010 ServiceList[Name].Subscribers.append(QPair<class EddWidget *, int>(Instance, Index)); 1011 1012 if (Index>=0 && Index<ServiceList[Name].Items.size()) { 1013 Instance->Update(Name, ServiceList[Name].TimeStamp, ServiceList[Name].ByteArray, ServiceList[Name].Format, ServiceList[Name].Items[Index]); 1014 } 1011 1015 else Instance->Update(Name, ServiceList[Name].TimeStamp, ServiceList[Name].ByteArray, ServiceList[Name].Format, ServiceList[Name].Text); 1012 1016 … … 1017 1021 ServiceList[Name].ByteArray = QByteArray(); 1018 1022 ServiceList[Name].TimeStamp = -1; 1019 ServiceList[Name].Subscribers [Instance] = Index;1023 ServiceList[Name].Subscribers.append(QPair<class EddWidget *, int>(Instance, Index)); 1020 1024 ServiceList[Name].DIMService = new DimStampedInfo(Name.toAscii().data(), INT_MAX, NO_LINK, this); 1021 1025 } … … 1023 1027 1024 1028 // Unsubscribe from DIM service 1025 void EddDim::Unsubscribe(QString Name, class EddWidget *Instance ) {1029 void EddDim::Unsubscribe(QString Name, class EddWidget *Instance, int Index) { 1026 1030 1027 1031 // Lock before accessing list … … 1029 1033 1030 1034 if (!ServiceList.contains(Name)) return; 1031 1032 if (ServiceList[Name].Subscribers.contains(Instance)) { 1033 ServiceList[Name].Subscribers.remove(Instance); 1034 } 1035 1035 1036 QPair<class EddWidget *, int> P(Instance, Index); 1037 1038 if (ServiceList[Name].Subscribers.contains(P)) { 1039 ServiceList[Name].Subscribers.removeAt(ServiceList[Name].Subscribers.indexOf(P)); 1040 } 1041 1042 // If no more needed, drop DIM subsription 1036 1043 if (ServiceList[Name].Subscribers.isEmpty()) { 1037 1044 delete ServiceList[Name].DIMService; 1038 1045 ServiceList.remove(Name); 1039 return;1040 1046 } 1041 1047 } … … 1111 1117 Volume += Data.size(); 1112 1118 1113 // Store service data 1119 // Store service data and update all subscribers 1114 1120 if (ServiceList.contains(Name)) { 1115 1121 ServiceList[Name].TimeStamp = Time; … … 1119 1125 ServiceList[Name].Items = ServiceList[Name].Text.split(" "); 1120 1126 1121 QMap<class EddWidget *, int>::const_iterator i = ServiceList[Name].Subscribers.constBegin(); 1122 while (i != ServiceList[Name].Subscribers.constEnd()) { 1123 if (i.value() >=0 && i.value() < ServiceList[Name].Items.size()) i.key()->Update(Name, Time, Data, Format, ServiceList[Name].Items[i.value()], i.value()); 1124 else i.key()->Update(Name, Time, Data, Format, ServiceList[Name].Text, i.value()); 1125 i++; 1127 for (int i=0; i<ServiceList[Name].Subscribers.size(); i++) { 1128 QPair<class EddWidget *, int> P = ServiceList[Name].Subscribers[i]; 1129 1130 if (P.second >=0 && P.second < ServiceList[Name].Items.size()) { 1131 P.first->Update(Name, Time, Data, Format, ServiceList[Name].Items[P.second], P.second); 1132 } 1133 else P.first->Update(Name, Time, Data, Format, ServiceList[Name].Text, P.second); 1126 1134 } 1127 1135 } -
fact/Evidence/GUI.h
r11360 r12894 31 31 const QColor EddPlotBackgroundColor(Qt::yellow); 32 32 33 void OpenHistory(char *, int );33 void OpenHistory(char *, int, int=-1); 34 34 bool SetStatus(QWidget *, QString, int, QString, int = -1); 35 35 … … 231 231 struct Item { 232 232 DimStampedInfo *DIMService; 233 Q Map<class EddWidget *, int> Subscribers;233 QList<QPair<class EddWidget *, int> > Subscribers; 234 234 int TimeStamp; 235 235 QByteArray ByteArray; … … 263 263 264 264 void Subscribe(QString, class EddWidget *, int = -1); 265 void Unsubscribe (QString, class EddWidget * );265 void Unsubscribe (QString, class EddWidget *, int = -1); 266 266 void Ignore (QString, bool); 267 267 class EvidenceHistory *GetHistory(QString); -
fact/tools/Edd/Edd.cc
r11462 r12894 921 921 QTimer *Timer = new QTimer(this); 922 922 connect(Timer, SIGNAL(timeout()), this, SLOT(CheckAlarm())); 923 Timer->start(5000);923 if (QString(DimServer::getDnsNode()).contains("ethz.ch")) Timer->start(5000); 924 924 } 925 925 … … 940 940 void GUI::MenuNewHistory() { 941 941 942 QStringList List ;942 QStringList List, Index; 943 943 char *Name, *Format; 944 944 int Type; … … 954 954 // Open dialog and open history window 955 955 QString Result = QInputDialog::getItem(this, "Edd Request", 956 "Enter or choose DIM service name (add index separated by colon)", List, 0, true, &OK);956 "Enter or choose DIM service name (add index or index range a-b separated by colon)", List, 0, true, &OK); 957 957 958 958 // Check if cancelled or empty data … … 960 960 if (!OK || List.isEmpty()) return; 961 961 962 if (List.size() == 1) OpenHistory(List[0].toAscii().data(), 0); 963 else OpenHistory(List[0].toAscii().data(), atoi(List[1].toAscii().data())); 962 // Check if index was given 963 if (List.size() == 1) { 964 OpenHistory(List[0].toAscii().data(), 0); 965 return; 966 } 967 968 // Single index or index range? 969 Index = List[1].trimmed().split("-", QString::SkipEmptyParts); 970 if (Index.isEmpty()) { 971 QMessageBox::warning(NULL, "Edd Message", QString("Incorrect index range given") ,QMessageBox::Ok); 972 return; 973 } 974 975 if (Index.size() == 1) OpenHistory(List[0].toAscii().data(), atoi(Index[0].toAscii().data())); 976 else OpenHistory(List[0].toAscii().data(), atoi(Index[0].toAscii().data()), atoi(Index[1].toAscii().data())); 964 977 } 965 978
Note:
See TracChangeset
for help on using the changeset viewer.