Changeset 222 for Evidence/Edd


Ignore:
Timestamp:
06/08/10 13:14:10 (15 years ago)
Author:
ogrimm
Message:
History buffer contains also DIM service format
Location:
Evidence/Edd
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • Evidence/Edd/Edd.cc

    r221 r222  
    2727QWidget *OpenHistory(char *Service, int Index) {
    2828
    29   char *Name, *Format;
    30   DimBrowser Browser;
    31 
    32   // If status service displayed as text history
    33   if (strstr(Service, "/Message") != NULL) return new EddText(Service);
    34 
    35   // If service currently not available, default open as plot
    36   Browser.getServices(Service);
    37   if (Browser.getNextService(Name, Format) != DimSERVICE) return new EddPlot(Service, Index);
    38  
    39   // Otherwise, determine from format if plot or text history
    40   if (strlen(Format) == 1 && *Format != 'C') return new EddPlot(Service, Index);
     29  class EvidenceHistory *Hist = Handler->GetHistory(Service);
     30
     31  // Check if hitory service available
     32  if (Hist == NULL || Hist->GetFormat() == NULL) {
     33        QMessageBox::warning(NULL, "Edd Message", QString("Could not retrieve history for service ") + Service ,QMessageBox::Ok);
     34        Handler->DropHistory(Service);
     35        return NULL;
     36  }
     37
     38  QString Format = Hist->GetFormat();
     39  Handler->DropHistory(Service);
     40 
     41  //if (strlen(Hist->GetFormat()) == 1 && *Hist->GetFormat() != 'C') return new EddPlot(Service, Index);
     42  if (Format.size() == 1 && Format[0] != 'C') return new EddPlot(Service, Index);
    4143  else return new EddText(Service);
    4244}
     
    6668        QLineEdit(P), ServiceName(Name), Index(Index) {
    6769
    68  LastPlot = NULL;
     70 LastHist = NULL;
    6971 
    7072  // Widget properties
     
    135137  // Check if last history plot still open, then raise
    136138  foreach (QWidget *Widget, QApplication::allWidgets()) {
    137     if (Widget == LastPlot) {
     139    if (Widget == LastHist) {
    138140      Widget->activateWindow();
    139141      Widget->raise();
     
    177179void EddLineDisplay::MenuOpenHistory() {
    178180 
    179   LastPlot = OpenHistory(ServiceName.toAscii().data(), Index);
    180   if (LastPlot != NULL) LastPlot->show();
     181  LastHist = OpenHistory(ServiceName.toAscii().data(), Index);
     182  if (LastHist != NULL) LastHist->show();
    181183}
    182184
     
    295297                double Number=0;
    296298                while ((R=Hist->Next()) != NULL) {
    297                   switch (Format[0].toUpper().toAscii()) {
     299                  switch (*(Hist->GetFormat())) {
    298300                case 'I':
    299301                        case 'L':  Number = *((int *) R->Data + List[ItemNo].Index);   break;
     
    311313                if (SizeLimit < 2*Count) SizeLimit = 2*Count;
    312314          }
     315          Handler->DropHistory(List[ItemNo].Name);
    313316        }
    314317
     
    737740          }
    738741        }
     742        Handler->DropHistory(Name);
    739743  }
    740744
     
    876880}
    877881
    878 // Update throughput statistics
     882// Reduce history usage counter
     883void EddDim::DropHistory(QString Name) {
     884
     885  for (int i=0; i<HistoryList.size(); i++) {
     886        if (HistoryList[i].Name == Name) HistoryList[i].Count--;
     887  }
     888}
     889
     890// Update throughput statistics and clear up history memory
    879891void EddDim::UpdateStatistics() {
     892
     893  // Remove unused histories after not less than 5 seconds
     894  for (int i=0; i<HistoryList.size(); i++) {
     895        if ((HistoryList[i].Count <= 0) && (time(NULL)-HistoryList[i].LastUpdate) > 5) {
     896          delete HistoryList[i].HistClass;
     897          HistoryList.removeAt(i);
     898        }
     899  }
    880900
    881901  // Lock before accessing internal variables
     
    15341554  getServices("*");
    15351555  while ((Type = getNextService(Name, Format)) != 0) {
    1536     if (Type==DimSERVICE && strstr(Name, ".hist")==NULL) List.append(Name);
     1556    if (Type==DimSERVICE) List.append(Name);
    15371557  }
    15381558  List.sort();
     
    15431563  if (OK && !Result.isEmpty()) {
    15441564    Result = Result.trimmed();
    1545     if (Result.endsWith(".hist")) Result.chop(5);
    15461565    QWidget *Hist = OpenHistory(Result.toAscii().data(), 0);
    15471566    if (Hist != NULL) Hist->show();
  • Evidence/Edd/Edd.h

    r221 r222  
    9696    QMenu *Menu;
    9797    QPoint dragStart;
    98     QWidget *LastPlot;
     98    QWidget *LastHist;
    9999       
    100100        QString ServiceName;
     
    247247        void Unsubscribe (QString);
    248248        class EvidenceHistory *GetHistory(QString);
     249        void DropHistory(QString);
    249250
    250251  signals:
Note: See TracChangeset for help on using the changeset viewer.