Changeset 10068


Ignore:
Timestamp:
Dec 10, 2010, 9:59:23 AM (10 years ago)
Author:
ogrimm
Message:
Alarm has 5 s minimum period, updates to Edd
Location:
fact/Evidence
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • fact/Evidence/Alarm.cc

    r9852 r10068  
    2727
    2828const char* LevelStr[] = {"OK", "WARN", "ERROR", "FATAL", "UNAVAILABLE"};
     29const int MIN_PERIOD = 5;  // Minimum period in seconds for checking servers are alive
    2930
    3031//
     
    3839        char *AlarmText;
    3940        int MasterAlarm;
    40         bool Active;
    4141
    4242    void infoHandler();
     
    5656        };
    5757        vector<struct Item> List;
     58        bool Active;
    5859
    5960        void UpdateAlarmSummary();
     
    128129void AlarmHandler::infoHandler() {
    129130
     131  // Check if alarm server active
     132  if (!Active) return;
     133
    130134  // Identify status service
    131135  for (int i=0; i<List.size(); i++) if (getInfo() == List[i].Subscription) {
     
    134138        else {
    135139          int Severity = atoi(ToString(getInfo()->getFormat(), getInfo()->getData(), getInfo()->getSize()).c_str());
    136           if (Severity > List[i].Level) List[i].Level = Severity;
     140          if ((Severity>List[i].Level) || (List[i].Level==4 && Severity==0)) List[i].Level = Severity;
    137141        }
    138142  }
     
    231235  // Static declaration ensures calling of destructor by exit()
    232236  static AlarmHandler A;
    233  
     237
     238  // Verify periodically that servers exist (if Alarm is active) 
    234239  while(!A.ExitRequest) {
    235     for (int i=0; i<A.List.size(); i++) {
     240    for (int i=0; i<A.List.size() && A.Active; i++) {
    236241          // Check if server exists
    237242      Exist = false;
     
    242247          if (!Exist) A.List[i].Level = 4;
    243248
    244           // Check if standard service available in case server not yet chcked (Level is -1)
     249          // Check if standard service available in case server not yet checked (Level is -1)
    245250          if (B.getServices((A.List[i].Server+"/VERSION_NUMBER").c_str())>0 && A.List[i].Level==-1) A.List[i].Level = 0;
    246     }
     251        }
    247252   
    248     A.UpdateAlarmSummary();
    249     sleep(atoi(A.GetConfig("period").c_str()));
    250   }
    251 }
     253        A.UpdateAlarmSummary();
     254        sleep(max(atoi(A.GetConfig("period").c_str()), MIN_PERIOD));
     255  }
     256}
  • fact/Evidence/Edd/Edd.cc

    r274 r10068  
    956956
    957957  Name = "drsdaq/EventData";
     958  Active = false;
    958959
    959960  Tmpfile = tmpfile();
     
    980981    printf("Failed connection for %s\n", Name.toAscii().data());
    981982  }
    982   Handler->Subscribe(Name);
     983  SetActive(true);
    983984}
    984985
     
    986987EventScope::~EventScope() {
    987988
    988   Handler->Unsubscribe(Name);
     989  SetActive(false);
    989990  while (!List.isEmpty()) DeleteCurve(List.last().Signal);
    990991  delete RD;
     
    10911092 
    10921093  // Only process if valid data in RawDataCTX class
    1093   if (ErrCode != CTX_OK) return;
     1094  if (!Active || ErrCode != CTX_OK) return;
    10941095 
    10951096  // Set x axis title
     
    11611162  }
    11621163}
     1164
     1165// Set display active (if inactive, disconnect from server)
     1166void EventScope::SetActive(bool State) {
     1167
     1168  if (State && !Active) Handler->Subscribe("drsdaq/EventData");
     1169  if (!State && Active) Handler->Unsubscribe("drsdaq/EventData");
     1170  Active = State;
     1171}
     1172
    11631173
    11641174//------------------------------------------------------------------
     
    12091219  Plot->setMinimumWidth(400);
    12101220  for (int i=0; i<18; i++) {
    1211     Line = new EddLineDisplay("Bias/VOLT/ID00", i);
     1221    Line = new EddLineDisplay("Bias/VOLT/ID00", i+64);
    12121222    Layout->addWidget(Line, i%9+1, 0+i/9, 1, 1);
    1213     Plot->AddService("Bias/VOLT/ID00", i);
    1214 
    1215     Line = new EddLineDisplay("Bias/VOLT/ID00", i+32);
     1223    Plot->AddService("Bias/VOLT/ID00", i+64);
     1224
     1225    Line = new EddLineDisplay("Bias/VOLT/ID00", i+96);
    12161226    Layout->addWidget(Line, i%9+1, 2+i/9, 1, 1);
    1217     Plot->AddService("Bias/VOLT/ID00",i+32);
     1227    Plot->AddService("Bias/VOLT/ID00",i+96);
    12181228  }
    12191229
     
    12291239  Text->setFixedWidth(400);
    12301240  Layout->addWidget(Text, 11, 0, 4, 4);
     1241 
     1242  QWidget *Button = new QPushButton("Currents");
     1243  Layout->addWidget(Button, 13, 4, 1, 1);     
     1244  connect(Button, SIGNAL(pressed()), SLOT(BiasCurrents()));
     1245}
     1246
     1247void TP_Bias::BiasCurrents() {
     1248
     1249  QMainWindow *M = new QMainWindow;
     1250  M->setCentralWidget(new QWidget);
     1251  M->setStatusBar(new QStatusBar(M));
     1252  M->setWindowTitle("Edd - Bias currents");
     1253  M->setAttribute(Qt::WA_DeleteOnClose);
     1254
     1255  QGridLayout *Layout = new QGridLayout(M->centralWidget());
     1256  EddLineDisplay *Line;
     1257  EddPlot *Plot = new EddPlot();
     1258
     1259  for (int i=0; i<36; i++) {
     1260    Line = new EddLineDisplay("Bias/MICROAMP/ID00", i+64);
     1261        Line->setMaximumWidth(60);
     1262    Layout->addWidget(Line, i%9, 0+i/9, 1, 1);
     1263    Plot->AddService("Bias/MICROAMP/ID00", i+64);       
     1264  }
     1265  Layout->addWidget(Plot, 0, 4, 30, 12);
     1266 
     1267  M->show();
    12311268}
    12321269
     
    12631300  Layout->addWidget(Button, 12, 0, 1, 1);     
    12641301  connect(Button, SIGNAL(pressed()), SLOT(FeedbackDetails()));
    1265 
    12661302}
    12671303
     
    13411377  Layout->addWidget(TabWidget, 1, 1, 5, 5);
    13421378
    1343   connect(Scope, SIGNAL(RunHeaderChanged(QString)), RunHeaderDisplay, SLOT(setPlainText(QString)));
    1344   connect(Scope, SIGNAL(EventHeaderChanged(QString)), EventHeaderDisplay, SLOT(setPlainText(QString)));
    1345 
    13461379  // Channel number
    13471380  Channel = new QSpinBox;
     
    13811414  connect(Button, SIGNAL(clicked()), SLOT(KeepCurrent()));
    13821415
     1416  // Stop/start
     1417  StartStopButton = new QPushButton("Stop");
     1418  StartStopButton->setToolTip("Start/stop display");
     1419  StartStopButton->setMaximumWidth(80);
     1420  StartStopButton->setCheckable(true);
     1421  QPalette Palette = StartStopButton->palette();
     1422  Palette.setColor(QPalette::ButtonText, Qt::blue);
     1423  Palette.setColor(QPalette::Button, Qt::green);
     1424  StartStopButton->setPalette(Palette);
     1425  StartStopButton->setFont(QFont("Times", 10, QFont::Bold));
     1426  Layout->addWidget(StartStopButton, 4, 0);
     1427  connect(StartStopButton, SIGNAL(toggled(bool)), SLOT(StartStop(bool)));
     1428
    13831429  // Button to show event display
    13841430  QPushButton *PixDisplay = new QPushButton("Pixel display");
     
    13861432  PixDisplay->setToolTip("Show event display window");
    13871433  PixDisplay->setMaximumWidth(80);
    1388   Layout->addWidget(PixDisplay, 4, 0);
     1434  Layout->addWidget(PixDisplay, 5, 0);
    13891435  connect(PixDisplay, SIGNAL(clicked()), SLOT(ShowPixelDisplay()));
    13901436
     
    14111457  }
    14121458
     1459  StartStop(false);
    14131460  connect(Scope, SIGNAL(PixelData(QVector<double>)), SLOT(SetPixelData(QVector<double>)));
    14141461}
     
    14321479}
    14331480
    1434 // Update event scope
     1481// Keep current trace
    14351482void TP_DAQ::KeepCurrent() {
    14361483
    14371484  Scope->AddTrace(Board->value(), Chip->value(), Channel->value());
     1485}
     1486
     1487// Start/stop event acquisition
     1488void TP_DAQ::StartStop(bool State) {
     1489
     1490  Scope->SetActive(!State);
     1491  StartStopButton->setText(State ? "Start" : "Stop");
     1492  if (!State) {
     1493        connect(Scope, SIGNAL(RunHeaderChanged(QString)), RunHeaderDisplay, SLOT(setPlainText(QString)));
     1494        connect(Scope, SIGNAL(EventHeaderChanged(QString)), EventHeaderDisplay, SLOT(setPlainText(QString)));
     1495  }
     1496  else {
     1497        disconnect(Scope, SIGNAL(RunHeaderChanged(QString)), RunHeaderDisplay, SLOT(setPlainText(QString)));
     1498        disconnect(Scope, SIGNAL(EventHeaderChanged(QString)), EventHeaderDisplay, SLOT(setPlainText(QString)));
     1499  }
    14381500}
    14391501
     
    14771539  Line->setMaximumWidth(200);
    14781540  Layout->addWidget(Line, 0, 0, 1, 2);     
     1541
     1542  QPushButton *Button = new QPushButton();
     1543  Button->setText("ON/OFF");
     1544  Button->setCheckable(true);
     1545  connect(Button, SIGNAL(toggled(bool)), SLOT(ToggleAlarm(bool)));
     1546  Layout->addWidget(Button, 0, 3, 1, 1);
    14791547
    14801548  Line = new EddLineDisplay("Alarm/MasterAlarm");
     
    15101578  Layout->addWidget(Line, 7, 0, 1, 1);
    15111579
    1512   QPushButton *Button = new QPushButton();
     1580  Button = new QPushButton();
    15131581  Button->setText("eLogBook");
    15141582  connect(Button, SIGNAL(released()), SLOT(StartELog()));
     
    15221590  Line = new EddLineDisplay("Edd/Rate_kBSec");
    15231591  Layout->addWidget(Line, 8, 0, 1, 1);
     1592}
     1593
     1594// Toggle state of Alarm server
     1595void TP_Evidence::ToggleAlarm(bool State) {
     1596
     1597  if (State) DimClient::sendCommandNB((char *) "Alarm/Switch", (char *) "off");
     1598  else DimClient::sendCommandNB((char *) "Alarm/Switch", (char *) "on");
    15241599}
    15251600 
  • fact/Evidence/Edd/Edd.h

    r274 r10068  
    276276        QAction *PhysPipeAction;
    277277        FILE *Tmpfile;
     278        bool Active;
    278279
    279280  public:
     
    283284        void UpdateFirst(int, int, int);
    284285        void AddTrace(int, int, int);
     286        void SetActive(bool);
    285287
    286288  private slots:
     
    306308class TP_Bias: public QWidget {
    307309  Q_OBJECT
     310
     311  private slots:
     312        void BiasCurrents();
    308313
    309314  public:
     
    334339        QWidget *Display;
    335340        QPushButton **Pixel;
     341        QPushButton *StartStopButton;
    336342
    337343  private slots:
     
    339345        void UpdateScope(int);
    340346        void KeepCurrent();
     347        void StartStop(bool);
    341348        void ShowPixelDisplay();
    342349        void SetPixelData(QVector<double>);
     
    351358
    352359  private slots:
     360        void ToggleAlarm(bool);
    353361        void StartDIMBrowser();
    354362        void StartELog();
  • fact/Evidence/readme.txt

    r9852 r10068  
    4646                        is checked in GetConfig() and also from this thread it will make blocking requests.
    474712/8/2010       Added command to switch alarm server on/off (command 'Alarm/Switch').
     489/12/2010       Minimum period for checking server status in Alarm set to 5 seconds.
Note: See TracChangeset for help on using the changeset viewer.