Changeset 174


Ignore:
Timestamp:
03/05/10 15:06:15 (15 years ago)
Author:
ogrimm
Message:
Update to configuration handling: Dim request only made if configuration file was modified since last request
Location:
Evidence
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • Evidence/Alarm.cc

    r159 r174  
    5252  MasterAlarm = 0;
    5353
    54   char *ServerNames = GetConfig(SERVER_NAME " servers");
    55 
    5654  // Create DIM services
    5755  Summary = new DimService(SERVER_NAME"/Summary", AlarmSummary);
     
    5957
    6058  // Copy original list of servers to observe
     59  char *ServerNames = GetConfig(SERVER_NAME " servers");
    6160  ServerList = new char [strlen(ServerNames)+1];
    6261  strcpy(ServerList, ServerNames);
     
    151150  static AlarmHandler Alarm;
    152151 
    153   // Request configuration data
    154   unsigned int Period = atoi(Alarm.GetConfig(SERVER_NAME " period"));
    155 
    156152  // Check periodically if servers are up
    157153  while(!Alarm.ExitRequest) {
     
    166162   
    167163    Alarm.UpdateAlarmSummary();
    168     sleep(Period);
     164    sleep(atoi(Alarm.GetConfig(SERVER_NAME " period")));
    169165  }
    170166}
  • Evidence/DColl.cc

    r173 r174  
    105105
    106106  // Request configuration data
    107   char *Change = GetConfig(SERVER_NAME " items");
    108107  DataDir = GetConfig(SERVER_NAME " datadir");
    109   char *Logname = GetConfig(SERVER_NAME " logfile");
    110108  SizeUpdateDelay = atoi(GetConfig(SERVER_NAME " sizeupdate"));
    111109  HistDir = GetConfig(SERVER_NAME " histdir");
    112110   
    113111  // Open log file
     112  char *Logname = GetConfig(SERVER_NAME " logfile");
    114113  if ((LogFile = fopen(Logname, "a")) == NULL) {
    115114    State(FATAL, "Could not open log file '%s' (%s)", Logname, strerror(errno));
     
    129128
    130129  // Count how many minimum change value regular expressions are present
     130  char *Change = GetConfig(SERVER_NAME " items");
    131131  RegExCount = 0;
    132132  char *Token = strtok(Change, "\t ");
     
    274274        }
    275275        if(mkdir(Dir, S_IRWXU|S_IRWXG)==-1 && errno!=EEXIST) {
    276           State(FATAL, "Could not create direcory '%s' (%s)", Dir, strerror(errno));
     276          State(FATAL, "Could not create directory '%s' (%s)", Dir, strerror(errno));
    277277        }
    278278
  • Evidence/Edd/Edd.cc

    r171 r174  
    66Qt-based graphical user interface for the Evidence contron system
    77
    8 Edd_Indicator changes its background colour in case it display
     8EddLineDisplay changes its background colour in case it display
    99a DIM status service
    1010
     
    2121
    2222
    23 class Edd_DIM *Handler;
     23class EddDim *Handler;
    2424
    2525
     
    3131
    3232  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);
    3737}
    3838
     
    4343
    4444// Constructor
    45 Edd_Indicator::Edd_Indicator(QString Name, int Index, QWidget *P):
     45EddLineDisplay::EddLineDisplay(QString Name, int Index, QWidget *P):
    4646        QLineEdit(P), ServiceName(Name), Index(Index) {
     47 
     48 LastPlot = NULL;
    4749 
    4850  // Widget properties
     
    6769
    6870// Destructor
    69 Edd_Indicator::~Edd_Indicator() {
     71EddLineDisplay::~EddLineDisplay() {
    7072
    7173  Handler->Unsubscribe(ServiceName);
     
    7375
    7476// Update widget
    75 void Edd_Indicator::Update(QString Name, int Time, QByteArray Array, QString Format, QString Text) {
     77void EddLineDisplay::Update(QString Name, int Time, QByteArray Array, QString Format, QString Text) {
    7678
    7779  if (ServiceName != Name) return;
     
    109111
    110112// Open plot if mouse release within widget
    111 void Edd_Indicator::mouseReleaseEvent(QMouseEvent *Event) {
     113void EddLineDisplay::mouseReleaseEvent(QMouseEvent *Event) {
    112114
    113115  if (Event->button()!=Qt::LeftButton || !contentsRect().contains(Event->pos())) return;
     
    123125
    124126  // If not, open new plot
    125   Edd_Indicator::MenuOpenHistory();
     127  EddLineDisplay::MenuOpenHistory();
    126128}
    127129
    128130// Handling of mouse press event: Register start position for drag
    129 void Edd_Indicator::mousePressEvent(QMouseEvent *Event) {
     131void EddLineDisplay::mousePressEvent(QMouseEvent *Event) {
    130132
    131133  if (Event->button() == Qt::LeftButton) dragStart = Event->pos();
     
    133135
    134136// Handling of dragging (Drag and MimeData will be deleted by Qt)
    135 void Edd_Indicator::mouseMoveEvent(QMouseEvent *Event) {
     137void EddLineDisplay::mouseMoveEvent(QMouseEvent *Event) {
    136138
    137139  if ((Event->buttons() & Qt::LeftButton) == 0) return;
     
    149151// Opening context menu
    150152//
    151 void Edd_Indicator::contextMenuEvent(QContextMenuEvent *Event) {
     153void EddLineDisplay::contextMenuEvent(QContextMenuEvent *Event) {
    152154
    153155  Menu->exec(Event->globalPos());
     
    155157
    156158// Menu: Open history plot
    157 void Edd_Indicator::MenuOpenHistory() {
     159void EddLineDisplay::MenuOpenHistory() {
    158160 
    159161  LastPlot = OpenHistory(ServiceName.toAscii().data(), Index);
     
    162164
    163165// Menu: Copy service name
    164 void Edd_Indicator::MenuCopyService() {
     166void EddLineDisplay::MenuCopyService() {
    165167 
    166168  QMimeData *MimeData = new QMimeData;
     
    171173
    172174// Menu: Copy data
    173 void Edd_Indicator::MenuCopyData() {
     175void EddLineDisplay::MenuCopyData() {
    174176
    175177  QApplication::clipboard()->setText(text());
     
    184186// Constructor
    185187//
    186 Edd_Plot::Edd_Plot(QString DIMService, int Index, QWidget *P):
    187         QwtPlot(P), EvidenceHistory() {
     188EddPlot::EddPlot(QString DIMService, int Index, QWidget *P):
     189        QwtPlot(P) {
    188190
    189191  Mutex = new QMutex(QMutex::Recursive);
     
    238240// Destructor (items with parent widget are automatically deleted)
    239241//
    240 Edd_Plot::~Edd_Plot() {
     242EddPlot::~EddPlot() {
    241243
    242244  for (int i=0; i<Items.size(); i++) {
     
    251253// Add history service to plot
    252254//
    253 void Edd_Plot::AddService(QString Name, int Index) {
     255void EddPlot::AddService(QString Name, int Index) {
    254256
    255257  // Lock before accessing Items list
     
    280282
    281283// Update widget (must happen in GUI thread)
    282 void Edd_Plot::Update(QString Name, int Time, QByteArray, QString Format, QString Text) {
     284void EddPlot::Update(QString Name, int Time, QByteArray, QString Format, QString Text) {
    283285
    284286  // Lock before accessing Items list
     
    306308          void *Data;
    307309
    308           if (GetHistory(Items[ItemNo].Name.toAscii().data())) {
     310          class EvidenceHistory *HistClass = Handler->GetHistory(Items[ItemNo].Name);
     311         
     312          if (HistClass->GetHistory()) {
    309313        double Smallest = DBL_MAX, Largest = DBL_MIN;
    310314                double Number=0;
    311                 while (Next(Time, Size, Data)) {
     315                while (HistClass->Next(Time, Size, Data)) {
    312316                  switch (Format[0].toUpper().toAscii()) {
    313317                case 'I':
     
    357361// Update all curves in plot
    358362//
    359 void Edd_Plot::UpdatePlot() {
     363void EddPlot::UpdatePlot() {
    360364
    361365  static QwtSymbol Symbol, Sym1;
     
    405409// Reset graph axes to autoscale when fully unzoomed
    406410//
    407 void Edd_Plot::HandleZoom(const QwtDoubleRect &) {
     411void EddPlot::HandleZoom(const QwtDoubleRect &) {
    408412
    409413  if(Zoomer->zoomRectIndex() == 0) {
     
    417421//
    418422
    419 void Edd_Plot::dragEnterEvent(QDragEnterEvent *Event) {
     423void EddPlot::dragEnterEvent(QDragEnterEvent *Event) {
    420424   
    421425  if (Event->mimeData()->hasFormat("Edd/Service")) Event->acceptProposedAction();
    422426}
    423427
    424 void Edd_Plot::dropEvent(QDropEvent *Event) {
     428void EddPlot::dropEvent(QDropEvent *Event) {
    425429
    426430  QByteArray D(Event->mimeData()->data("Edd/Service"));
     
    429433   
    430434// Opening context menu
    431 void Edd_Plot::contextMenuEvent(QContextMenuEvent *Event) {
     435void EddPlot::contextMenuEvent(QContextMenuEvent *Event) {
    432436
    433437  Menu->exec(Event->globalPos());
     
    435439
    436440// Drag&Drop method
    437 void Edd_Plot::LegendClicked(QwtPlotItem *Item) {
     441void EddPlot::LegendClicked(QwtPlotItem *Item) {
    438442
    439443
     
    451455
    452456// Zoom completely out
    453 void Edd_Plot::MenuZoomOut() {
     457void EddPlot::MenuZoomOut() {
    454458
    455459  Zoomer->zoom(0);
     
    458462
    459463// Remove all items except last
    460 void Edd_Plot::MenuSingleTrace() {
     464void EddPlot::MenuSingleTrace() {
    461465
    462466  // Lock before accessing Items list
     
    472476
    473477// Save data of plot as test
    474 void Edd_Plot::MenuSaveASCII() {
     478void EddPlot::MenuSaveASCII() {
    475479  QString Filename = QFileDialog::getSaveFileName(this,
    476480     "Filename", ".", "Text files (*.txt *.ascii *.asc);;All files (*)");
     
    497501
    498502// Print plot
    499 void Edd_Plot::MenuPrint() {
     503void EddPlot::MenuPrint() {
    500504
    501505  QPrinter *Printer = new QPrinter;
     
    510514
    511515// Save plot as image
    512 void Edd_Plot::MenuSave() {
     516void EddPlot::MenuSave() {
    513517
    514518  QString Filename = QFileDialog::getSaveFileName(this,
     
    524528
    525529// Add new service by pasting name
    526 void Edd_Plot::MenuPasteService() {
     530void EddPlot::MenuPasteService() {
    527531
    528532  const QMimeData *D = QApplication::clipboard()->mimeData();
     
    541545// Constructor
    542546//
    543 Edd_TextHist::Edd_TextHist(QString Name, bool Pure, QWidget *P):
    544         QTextEdit(P), EvidenceHistory(), Name(Name), Pure(Pure) {
     547EddText::EddText(QString Name, bool Pure, QWidget *P):
     548        QTextEdit(P), Name(Name), Pure(Pure) {
    545549 
    546550  // Widget properties
     
    561565        void *Data;
    562566
    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)) {
    565571                moveCursor (QTextCursor::Start);
    566572                insertPlainText(QString("(")+QDateTime::fromTime_t(Time).toString()+") ");       
     
    575581
    576582// Destructor
    577 Edd_TextHist::~Edd_TextHist() {
     583EddText::~EddText() {
    578584
    579585  Handler->Unsubscribe(Name);
     
    582588
    583589// Update widget (must happen in GUI thread)
    584 void Edd_TextHist::Update(QString Name, int Time, QByteArray, QString Format, QString Text) {
     590void EddText::Update(QString Name, int Time, QByteArray, QString Format, QString Text) {
    585591
    586592  if (this->Name != Name) return;
     
    617623// Interface to Dim system //
    618624/////////////////////////////
    619 Edd_DIM::Edd_DIM() {
     625EddDim::EddDim() {
    620626
    621627  Mutex = new QMutex(QMutex::Recursive);
     
    630636  // Connect to DIM handler
    631637  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
     642EddDim::~EddDim() {
     643
     644  for (int i=0; i<HistoryList.size(); i++) delete HistoryList[i].HistClass;
    638645  delete Mutex;
    639646}
    640647
    641648// Subscribe to DIM service
    642 void Edd_DIM::Subscribe(QString Name) {
     649void EddDim::Subscribe(QString Name) {
    643650
    644651  // Lock before accessing list
     
    667674
    668675// Unsubsribe from DIM service
    669 void Edd_DIM::Unsubscribe(QString Name) {
     676void EddDim::Unsubscribe(QString Name) {
    670677
    671678  // Lock before accessing list
     
    682689}
    683690
     691// Get history buffer
     692class 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
    684710// Update throughput statistics
    685 void Edd_DIM::UpdateStatistics() {
     711void EddDim::UpdateStatistics() {
    686712
    687713  // Lock before accessing internal variables
     
    697723
    698724// 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) {
     725void EddDim::Update(QString Name, int Time, QByteArray Data, QString Format, QString Text) {
    700726
    701727  // Lock before accessing list
     
    717743
    718744// Handling of DIM service update
    719 void Edd_DIM::infoHandler() {
     745void EddDim::infoHandler() {
    720746
    721747  if (!EvidenceServer::ServiceOK(getInfo())) YEP(getInfo()->getName(), -1);
     
    733759GUI::GUI() {
    734760 
    735   Handler = new Edd_DIM();
     761  Handler = new EddDim();
    736762 
    737763  // Set features of main window
     
    742768  setWindowTitle("Edd - Evidence Data Display");
    743769
    744   Edd_Indicator *Value;
    745   Edd_Plot *Graph;
    746   Edd_TextHist *Textout;
     770  EddLineDisplay *Value;
     771  EddPlot *Graph;
     772  EddText *Textout;
    747773  QString Text;
    748774
    749775   // 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");
    753776 
    754777
     
    768791  MainLayout = new QGridLayout(MainWidget);
    769792
    770   Value = new Edd_Indicator("Alarm/Status");
     793  Value = new EddLineDisplay("Alarm/Status");
    771794  Value->setMaximumWidth(200);
    772795  MainLayout->addWidget(Value, 0, 0, 1, 2);     
    773796
    774   Value = new Edd_Indicator("Alarm/MasterAlarm");
     797  Value = new EddLineDisplay("Alarm/MasterAlarm");
    775798  MainLayout->addWidget(Value, 0, 1, 1, 1);
    776799
    777   Textout = new Edd_TextHist("Alarm/Summary", true);
     800  Textout = new EddText("Alarm/Summary", true);
    778801  Textout->Accumulate = false;
    779802  Textout->setMaximumWidth(200);
     
    781804  MainLayout->addWidget(Textout, 1, 0, 1, 2);
    782805
    783   Value = new Edd_Indicator("DColl/Status");
     806  Value = new EddLineDisplay("DColl/Status");
    784807  Value->setMaximumWidth(200);
    785808  MainLayout->addWidget(Value, 3, 0, 1, 2);     
    786809
    787   Value = new Edd_Indicator("DColl/DataSizekB");
     810  Value = new EddLineDisplay("DColl/DataSizekB");
    788811  MainLayout->addWidget(Value, 4, 0, 1, 1);
    789812
    790   Value = new Edd_Indicator("DColl/LogSizekB");
     813  Value = new EddLineDisplay("DColl/LogSizekB");
    791814  MainLayout->addWidget(Value, 4, 1, 1, 1);
    792815
    793   Value = new Edd_Indicator("DColl/CurrentFile");
     816  Value = new EddLineDisplay("DColl/CurrentFile");
    794817  Value->setMaximumWidth(400);
    795818  MainLayout->addWidget(Value, 5, 0, 1, 3);
    796819
    797   Value = new Edd_Indicator("Config/Status");
     820  Value = new EddLineDisplay("Config/Status");
    798821  Value->setMaximumWidth(200);
    799822  MainLayout->addWidget(Value, 6, 0, 1, 2);     
    800823
    801   Value = new Edd_Indicator("Config/ModifyTime");
     824  Value = new EddLineDisplay("Config/ModifyTime");
    802825  Value->setMaximumWidth(200);
    803826  Value->ShowAsTime = true;
     
    809832  MainLayout->addWidget(Button, 7, 1, 1, 1);
    810833
    811   Value = new Edd_Indicator("Edd/Rate_kBMin");
     834  Value = new EddLineDisplay("Edd/Rate_kBMin");
    812835  MainLayout->addWidget(Value, 8, 0, 1, 1);
    813   Value = new Edd_Indicator("Edd/Total_MB");
     836  Value = new EddLineDisplay("Edd/Total_MB");
    814837  MainLayout->addWidget(Value, 8, 1, 1, 1);
    815838
     
    826849  FeedbackWidget = new QWidget();
    827850  FeedbackLayout = new QGridLayout(FeedbackWidget);
    828   Graph = new Edd_Plot();
     851  Graph = new EddPlot();
    829852  for (int i=0; i<36; i++) {
    830     Value = new Edd_Indicator("Feedback/Average", i);
     853    Value = new EddLineDisplay("Feedback/Average", i);
    831854    FeedbackLayout->addWidget(Value, i%9+1, 0+i/9, 1, 1);
    832855    Graph->AddService("Feedback/Average", i);
    833856  }
    834   FeedbackLayout->addWidget(Graph, 0, 4, 10, 3);
    835 
    836   //Graph = new Edd_Plot();
     857  FeedbackLayout->addWidget(Graph, 0, 4, 11, 3);
     858
     859  //Graph = new EddPlot();
    837860  //for (int i=0; i<36; i++) {
    838861    //Text = Text.sprintf("Feedback/Sigma/ID%.2d/%.2d-%.3d",i/16, (i%16)/8, i%8);
     
    841864  //FeedbackLayout->addWidget(Graph, 10, 0, 10, 3);
    842865
    843   Value = new Edd_Indicator("Feedback/Status");
     866  Value = new EddLineDisplay("Feedback/Status");
    844867  Value->setMaximumWidth(200);
    845868  FeedbackLayout->addWidget(Value, 0, 0, 1, 3);     
    846   Value = new Edd_Indicator("Feedback/Count");
     869  Value = new EddLineDisplay("Feedback/Count");
    847870  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 
    848876
    849877  // Bias voltage page
    850878  BiasWidget = new QWidget();
    851879  BiasLayout = new QGridLayout(BiasWidget);
    852   Graph = new Edd_Plot();
     880  Graph = new EddPlot();
    853881  for (int i=0; i<18; i++) {
    854     Value = new Edd_Indicator("Bias/VOLT/ID00", i);
     882    Value = new EddLineDisplay("Bias/VOLT/ID00", i);
    855883    BiasLayout->addWidget(Value, i%9+1, 0+i/9, 1, 1);
    856884    Graph->AddService("Bias/VOLT/ID00", i);
    857885
    858     Value = new Edd_Indicator("Bias/VOLT/ID00", i+32);
     886    Value = new EddLineDisplay("Bias/VOLT/ID00", i+32);
    859887    BiasLayout->addWidget(Value, i%9+1, 2+i/9, 1, 1);
    860888    Graph->AddService("Bias/VOLT/ID00",i+32);
     
    862890
    863891  BiasLayout->addWidget(Graph, 0, 4, 12, 3);
    864   Value = new Edd_Indicator("Bias/Status");
     892  Value = new EddLineDisplay("Bias/Status");
    865893  Value->setMaximumWidth(200);
    866894  BiasLayout->addWidget(Value, 0, 0, 1, 3);     
    867895
    868   Textout = new Edd_TextHist("Bias/Textout", true);
     896  Textout = new EddText("Bias/Textout", true);
    869897  Textout->setFixedWidth(400);
    870898  BiasLayout->addWidget(Textout, 10, 0, 4, 4);     
     
    873901  EnvironmentWidget = new QWidget();
    874902  EnvironmentLayout = new QGridLayout(EnvironmentWidget);
    875   Value = new Edd_Indicator("ARDUINO/Status");
     903  Value = new EddLineDisplay("ARDUINO/Status");
    876904  Value->setMaximumWidth(200);
    877905  EnvironmentLayout->addWidget(Value, 0, 0, 1, 3);     
    878906
    879   Graph = new Edd_Plot();
     907  Graph = new EddPlot();
    880908  for (int i=0; i<10; i++) {
    881     Value = new Edd_Indicator("ARDUINO/Data", i);
     909    Value = new EddLineDisplay("ARDUINO/Data", i);
    882910    EnvironmentLayout->addWidget(Value, i%5+1, i/5, 1, 1);
    883911    Graph->AddService("ARDUINO/Data", i);
     
    885913  EnvironmentLayout->addWidget(Graph, 0, 3, 6, 4);     
    886914
    887   Value = new Edd_Indicator("SQM/NSB");
     915  Value = new EddLineDisplay("SQM/NSB");
    888916  EnvironmentLayout->addWidget(Value, 6, 0, 1, 1);     
    889917
     
    951979}
    952980
     981// Feedback details page
     982void 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
    953998// Start DIM Browser
    954999void GUI::StartDIMBrowser() {
  • Evidence/Edd/Edd.h

    r171 r174  
    3939                 
    4040// General indicator for DIM service
    41 class Edd_Indicator: public QLineEdit {
     41class EddLineDisplay: public QLineEdit {
    4242    Q_OBJECT
    4343
     
    5454       
    5555  public:
    56     Edd_Indicator(QString, int=0, QWidget * = NULL);
    57     ~Edd_Indicator();
     56    EddLineDisplay(QString, int=0, QWidget * = NULL);
     57    ~EddLineDisplay();
    5858
    5959        bool ShowAsTime;
     
    6868
    6969// Graph class for history display
    70 class Edd_Plot: public QwtPlot, public EvidenceHistory {
     70class EddPlot: public QwtPlot {
    7171    Q_OBJECT
    7272
     
    9999
    100100  public:
    101     Edd_Plot(QString = QString(), int = 0, QWidget * = NULL);
    102     ~Edd_Plot();
     101    EddPlot(QString = QString(), int = 0, QWidget * = NULL);
     102    ~EddPlot();
    103103    void AddService(QString, int = 0);
    104104
     
    119119
    120120// Text history and output class
    121 class Edd_TextHist: public QTextEdit, public EvidenceHistory {
     121class EddText: public QTextEdit {
    122122    Q_OBJECT
    123123
     
    126126       
    127127  public:
    128     Edd_TextHist(QString, bool = false, QWidget * = NULL);
    129     ~Edd_TextHist();
     128    EddText(QString, bool = false, QWidget * = NULL);
     129    ~EddText();
    130130
    131131        bool Accumulate;
     
    136136
    137137// Interface to DIM system
    138 class Edd_DIM: public QObject, public DimInfo {
     138class EddDim: public QObject, public DimInfo {
    139139    Q_OBJECT
    140140
     
    151151    QMutex *Mutex;
    152152
     153        struct HistItem {
     154          QString Name;
     155          int Count;
     156          class EvidenceHistory *HistClass;
     157        };
     158    QList<HistItem> HistoryList;
     159
    153160        long long TotalVolume;
    154161        long long MinuteVolume;
     
    161168
    162169  public:
    163     Edd_DIM();
    164     ~Edd_DIM();
     170    EddDim();
     171    ~EddDim();
    165172
    166173        void Subscribe(QString);
    167174        void Unsubscribe (QString);
     175        class EvidenceHistory *GetHistory(QString);
    168176
    169177  signals:
     
    178186    QwtAnalogClock *Clock;
    179187       
    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;
    182190
    183191    QTabWidget *TabWidget;
     
    193201    void MenuNewHistory();
    194202        void StartDIMBrowser();
     203        void FeedbackDetails();
    195204};
    196205
  • Evidence/Evidence.cc

    r168 r174  
    3434EvidenceServer *ThisServer;
    3535
     36
    3637// Constructor starts server with given name
    3738EvidenceServer::EvidenceServer(const char *Name) {
     
    5051  // Catch C++ unhandled exceptions
    5152  set_terminate(Terminate);
     53
     54  // Subscribe to modify service for keeping track of config file changes
     55  ModifyInfo = new class ConfigUpdate();
    5256 
    5357  // Start server
     
    7276        delete[] ConfigList[i].Value;
    7377  }
     78  delete ModifyInfo;
    7479}
    7580
     
    125130}
    126131
    127 // Get configuration data (program terminates if data is missing)
     132// Get configuration data
    128133//
     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.
    129136// The memory allocated by all calls to this function will be freed by
    130137// the destructor.
    131138char* EvidenceServer::GetConfig(const char *Item, const char *Default) {
    132139 
    133   // Determine configuration file update time
    134   DimCurrentInfo ModifyTime("Config/ModifyTime", 0);
    135   int Time = ModifyTime.getInt(), ItemNo = -1;
     140  int ItemNo = -1;
    136141 
    137142  // Check if configuration request already in list
     
    139144    if (strcmp(ConfigList[i].Name, Item) == 0) {
    140145          // 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;
    142147
    143148          // Otherwise, free memory of old value
     
    172177  strcpy(ConfigList[ItemNo].Name, Item);
    173178  strcpy(ConfigList[ItemNo].Value, Result);
    174   ConfigList[ItemNo].Time = Time;
     179  ConfigList[ItemNo].Time = ModifyInfo->LastModifyTime;
    175180   
    176181  // Return address to configuration value 
     
    310315
    311316// Constructor
    312 EvidenceHistory::EvidenceHistory() {
     317EvidenceHistory::EvidenceHistory(std::string Name, int Delay):
     318        Name(Name+".hist"),
     319        Delay(Delay) {
    313320
    314321  Buffer = NULL;
     322  LastUpdate = 0;
    315323}
    316324
     
    322330
    323331// Requests service history
    324 bool EvidenceHistory::GetHistory(char *Name) {
    325 
    326   DimCurrentInfo Info((string(Name)+".hist").c_str(), NO_LINK);
    327 
     332bool 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 
    328341  // Check if service available
     342  DimCurrentInfo Info(Name.c_str(), NO_LINK);
    329343  if (((Info.getSize() == strlen(NO_LINK)+1) && 
    330344          (memcmp(Info.getData(), NO_LINK, Info.getSize()) == 0))) return false;
  • Evidence/Evidence.h

    r165 r174  
    1919// Class declation of Evidence server
    2020class EvidenceServer: public DimServer {
     21  private:
    2122
    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
    2342        struct ConfigItem {
    2443          char *Name;
     
    2948
    3049    DimService *Status;
     50        class ConfigUpdate *ModifyInfo;
     51       
    3152        char *InitMsg;
     53        int LastModifyTime;
    3254
    3355    static void SignalHandler(int); // static for signal()
     
    3961    EvidenceServer(const char *);
    4062        ~EvidenceServer();
    41        
     63
    4264        enum StateType {INFO=0, WARN=1, ERROR=2, FATAL=3};
    4365
     
    5577  static const int EndMark[];
    5678
    57   std::string HistoryName;
     79  std::string Name;
    5880  char *Buffer;
    5981  int BufferSize;
    6082  int Offset;
    61    
     83  int Delay;
     84  int LastUpdate;
     85 
    6286  public:
    63         EvidenceHistory();
     87        EvidenceHistory(std::string, int = 10);
    6488        ~EvidenceHistory();
    6589       
    66         bool GetHistory(char *);
     90        bool GetHistory();
    6791        bool Next(int &, int &, void *&);
    6892};
Note: See TracChangeset for help on using the changeset viewer.