- Timestamp:
- 05/25/10 07:38:03 (15 years ago)
- Location:
- Evidence
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
Evidence/DColl.cc
r209 r212 225 225 char *Token = strtok(Info->getString(), "+-!@"); 226 226 while (Token != NULL) { 227 if (*Info->getString()=='-' || *Info->getString()=='!') RemoveService(string(Token)+"/SERVICE_LIST"); 228 else AddService(string(Token)+"/SERVICE_LIST"); 227 if (*Info->getString()=='+') AddService(string(Token)+"/SERVICE_LIST"); 229 228 Token = strtok(NULL, "|"); // Skip server IP address 230 229 Token = strtok(NULL, "@"); … … 243 242 if (strstr(Type, "|CMD")==NULL && strstr(Type, "|RPC")==NULL) { 244 243 // Add or remove service 245 if (*Info->getString()=='-' || *Info->getString()=='!') RemoveService(Name); 246 else AddService(Name); 244 if (*Info->getString()=='+') AddService(Name); 247 245 } 248 246 Name = strtok(NULL, "|"); -
Evidence/Edd/Edd.cc
r208 r212 58 58 ////////////////////////////////////////// 59 59 60 // Constructor61 60 EddLineDisplay::EddLineDisplay(QString Name, int Index, QWidget *P): 62 61 QLineEdit(P), ServiceName(Name), Index(Index) { … … 192 191 193 192 193 ////////////////////////////////////////// 194 // Sending string command to DIM server // 195 ////////////////////////////////////////// 196 197 EddCommand::EddCommand(QString Name, QWidget *P): QLineEdit(P), Name(Name) { 198 199 setToolTip("Send command "+Name); 200 connect(this, SIGNAL(returnPressed()), SLOT(SendCommand())); 201 } 202 203 // Send command 204 void EddCommand::SendCommand() { 205 206 DimClient::sendCommand(Name.toAscii().data(), text().toAscii().data()); 207 } 208 209 194 210 ////////////////////////////////// 195 211 // History plot for DIM service // 196 212 ////////////////////////////////// 197 213 198 // Constructor199 214 EddPlot::EddPlot(QString DIMService, int Index, QWidget *P): EddBasePlot(P) { 200 215 … … 269 284 // If buffer empty, request new history buffer 270 285 if (List[ItemNo].Signal->dataSize() == 0) { 271 int Time, Size ;286 int Time, Size, Count=0; 272 287 void *Data; 273 274 class EvidenceHistory *HistClass = Handler->GetHistory(List[ItemNo].Name); 275 276 if (HistClass->GetHistory()) { 288 class EvidenceHistory *Hist; 289 290 if ((Hist = Handler->GetHistory(List[ItemNo].Name)) != NULL) { 277 291 double Number=0; 278 while (Hist Class->Next(Time, Size, Data)) {292 while (Hist->Next(Time, Size, Data)) { 279 293 switch (Format[0].toUpper().toAscii()) { 280 294 case 'I': … … 287 301 } 288 302 AddPoint(ItemNo, Time, Number); 303 Count++; 289 304 } 290 305 291 306 // Local buffer at least twice as large as longest history 292 if (SizeLimit < 2* List[ItemNo].Signal->dataSize()) SizeLimit = 2*List[ItemNo].Signal->dataSize();307 if (SizeLimit < 2*Count) SizeLimit = 2*Count; 293 308 } 294 309 } … … 708 723 int Time, Size; 709 724 void *Data; 710 711 class EvidenceHistory *HistClass = Handler->GetHistory(Name); 712 713 if (HistClass->GetHistory()) { 714 while (HistClass->Next(Time, Size, Data)) { 725 class EvidenceHistory *Hist; 726 727 if ((Hist = Handler->GetHistory(Name)) != NULL) { 728 while (Hist->Next(Time, Size, Data)) { 715 729 moveCursor (QTextCursor::Start); 716 730 insertPlainText(QString("(")+QDateTime::fromTime_t(Time).toString()+") "); … … 770 784 TotalVolume = 0; 771 785 786 // Timer to calculate data rates 772 787 QTimer *Timer = new QTimer(this); 773 788 Timer->connect(Timer, SIGNAL(timeout()), this, SLOT(UpdateStatistics())); … … 783 798 784 799 for (int i=0; i<HistoryList.size(); i++) delete HistoryList[i].HistClass; 800 785 801 delete Mutex; 786 802 } … … 795 811 for (int i=0; i<ServiceList.size(); i++) if (ServiceList[i].Name == Name) { 796 812 ServiceList[i].Count++; 797 // If service already re veived, reemit for new subscriber813 // If service already received, reemit for new subscriber 798 814 if (!ServiceList[i].ByteArray.isEmpty()) { 799 815 YEP(Name, ServiceList[i].TimeStamp, ServiceList[i].ByteArray, ServiceList[i].Format, ServiceList[i].Text); … … 832 848 class EvidenceHistory *EddDim::GetHistory(QString Name) { 833 849 834 // If history already available, return this850 // History already available (only request again if too old) 835 851 for (int i=0; i<HistoryList.size(); i++) if (HistoryList[i].Name == Name) { 836 852 HistoryList[i].Count++; 837 return HistoryList[i].HistClass; 838 } 839 853 if (time(NULL)-HistoryList[i].LastUpdate < 5) { 854 HistoryList[i].HistClass->Rewind(); 855 return HistoryList[i].HistClass; 856 } 857 HistoryList[i].LastUpdate = time(NULL); 858 if (HistoryList[i].HistClass->GetHistory()) return HistoryList[i].HistClass; 859 else return NULL; 860 } 861 862 // Create new history class 840 863 struct HistItem New; 841 864 New.Name = Name; 842 865 New.HistClass = new EvidenceHistory(Name.toStdString()); 843 866 New.Count = 1; 867 New.LastUpdate = time(NULL); 844 868 HistoryList.append(New); 845 869 846 return New.HistClass;847 870 if (New.HistClass->GetHistory()) return New.HistClass; 871 else return NULL; 848 872 } 849 873 … … 906 930 EventScope::EventScope(QWidget *P): EddBasePlot(P), PixelMap("../../config/PixelMap.txt", false) { 907 931 908 Name = " Feedback/EventData";932 Name = "drsdaq/EventData"; 909 933 910 934 Tmpfile = tmpfile(); … … 1048 1072 else setAxisTitle(QwtPlot::xBottom, "Time from trigger minus one revolution (ns)"); 1049 1073 1050 // Loop through event data 1074 // Loop through event data to update event scope 1051 1075 RunHeader *R = RD->RHeader; 1052 1076 for (int i=0; i<List.size(); i++) { … … 1081 1105 1082 1106 UpdatePlot(); 1107 1108 // Loop through event data for pixel display 1109 QVector<double> Pixel(R->NBoards*R->NChips*R->NChannels); 1110 int Count = 0; 1111 1112 for (unsigned int Board=0; Board<R->NBoards; Board++) { 1113 for (unsigned int Chip=0; Chip<R->NChips; Chip++) { 1114 for (unsigned int Channel=0; Channel<R->NChannels; Channel++) { 1115 Pixel[Count] = DBL_MIN; 1116 1117 for (unsigned int i=0; i<R->Samples; i++) { 1118 y = *((short *) (RD->Data + R->NBoards*R->NChips*sizeof(int)) + 1119 Board*R->NChips*R->NChannels*R->Samples + Chip*R->NChannels*R->Samples + 1120 Channel*R->Samples + i) * RD->BStruct[Board].ScaleFactor; 1121 1122 if (y > Pixel[Count]) Pixel[Count] = y; 1123 } 1124 Count++; 1125 }}} 1126 1127 emit(PixelData(Pixel)); 1083 1128 } 1084 1129 … … 1092 1137 } 1093 1138 1094 // 1095 // Tab page classes 1096 // 1097 1139 //------------------------------------------------------------------ 1140 //**************************** Tab pages *************************** 1141 //------------------------------------------------------------------ 1142 1143 // 1098 1144 // Environment page 1145 // 1099 1146 TP_Environment::TP_Environment() { 1100 1147 … … 1104 1151 EddLineDisplay *Line = new EddLineDisplay("ARDUINO/Status"); 1105 1152 Line->setMaximumWidth(200); 1106 Layout->addWidget(Line, 0, 0, 1, 3);1153 Layout->addWidget(Line, 0, 0, 1, 2); 1107 1154 1108 1155 // Generate plot and data displays … … 1113 1160 Plot->AddService("ARDUINO/Data", i); 1114 1161 } 1115 Layout->addWidget(Plot, 0, 3, 6, 4);1162 Layout->addWidget(Plot, 0, 2, 8, 7); 1116 1163 1117 1164 // Night sky monitor … … 1120 1167 } 1121 1168 1169 // 1122 1170 // Bias page 1171 // 1123 1172 TP_Bias::TP_Bias() { 1124 1173 … … 1143 1192 Layout->addWidget(Line, 0, 0, 1, 3); 1144 1193 1145 EddText *Text = new EddText("Bias/Textout", true); 1194 EddCommand *Command = new EddCommand("Bias/Command"); 1195 Layout->addWidget(Command, 10, 0, 1, 4); 1196 1197 EddText *Text = new EddText("Bias/StdOut", true); 1146 1198 Text->setFixedWidth(400); 1147 Layout->addWidget(Text, 10, 0, 4, 4); 1148 } 1149 1199 Layout->addWidget(Text, 11, 0, 4, 4); 1200 } 1201 1202 // 1150 1203 // Feedback page 1204 // 1151 1205 TP_Feedback::TP_Feedback() { 1152 1206 … … 1156 1210 EddPlot *Plot = new EddPlot(); 1157 1211 for (int i=0; i<36; i++) { 1158 Line = new EddLineDisplay("Feedback/Average", i); 1212 Line = new EddLineDisplay("drsdaq/Average", i); 1213 Line->setMaximumWidth(60); 1159 1214 Layout->addWidget(Line, i%9+1, 0+i/9, 1, 1); 1160 Plot->AddService(" Feedback/Average", i);1161 } 1162 Layout->addWidget(Plot, 0, 4, 1 1, 3);1215 Plot->AddService("drsdaq/Average", i); 1216 } 1217 Layout->addWidget(Plot, 0, 4, 12, 10); 1163 1218 1164 1219 //Graph = new EddPlot(); … … 1169 1224 //FeedbackLayout->addWidget(Graph, 10, 0, 10, 3); 1170 1225 1171 Line = new EddLineDisplay(" Feedback/Status");1226 Line = new EddLineDisplay("drsdaq/Status"); 1172 1227 Line->setMaximumWidth(200); 1173 Layout->addWidget(Line, 0, 0, 1, 3); 1174 Line = new EddLineDisplay("Feedback/Count"); 1175 Layout->addWidget(Line, 0, 3, 1, 1); 1228 Layout->addWidget(Line, 0, 0, 1, 2); 1229 Line = new EddLineDisplay("drsdaq/Count"); 1230 Line->setMaximumWidth(60); 1231 Layout->addWidget(Line, 0, 2); 1176 1232 1177 1233 QWidget *Button = new QPushButton("Details"); … … 1188 1244 EddPlot *Plot = new EddPlot(); 1189 1245 for (int i=0; i<36; i++) { 1190 Line = new EddLineDisplay("Feedback/Sigma", i); 1246 Line = new EddLineDisplay("drsdaq/Sigma", i); 1247 Line->setMaximumWidth(50); 1191 1248 Layout->addWidget(Line, i%9+1, 0+i/9, 1, 1); 1192 Plot->AddService(" Feedback/Sigma", i);1193 } 1194 Layout->addWidget(Plot, 0, 4, 1 1, 3);1249 Plot->AddService("drsdaq/Sigma", i); 1250 } 1251 Layout->addWidget(Plot, 0, 4, 12, 10); 1195 1252 1196 1253 Widget->show(); 1197 1254 } 1198 1255 1199 // DAQ page 1256 // 1257 // Event scope page 1258 // 1200 1259 TP_DAQ::TP_DAQ() { 1201 1260 … … 1217 1276 TabWidget->addTab(RunHeaderDisplay, "&Run Header"); 1218 1277 TabWidget->addTab(EventHeaderDisplay, "&Event Header"); 1219 Layout->addWidget(TabWidget, 0, 1, 3, 3);1278 Layout->addWidget(TabWidget, 0, 1, 5, 3); 1220 1279 1221 1280 connect(Scope, SIGNAL(RunHeaderChanged(QString)), RunHeaderDisplay, SLOT(setPlainText(QString))); … … 1250 1309 FormLayout->addRow("Board", Board); 1251 1310 FormLayout->addRow("Pixel ID", PixelID); 1252 Layout->addLayout(FormLayout, 0, 0 );1311 Layout->addLayout(FormLayout, 0, 0, 2, 1); 1253 1312 1254 1313 // Add trace permanently … … 1258 1317 Layout->addWidget(Button, 2, 0); 1259 1318 connect(Button, SIGNAL(clicked()), SLOT(KeepCurrent())); 1260 } 1261 1319 1320 // Button to show event display 1321 QPushButton *PixDisplay = new QPushButton("Pixel display"); 1322 PixDisplay->setFont(QFont("Times", 10, QFont::Bold)); 1323 PixDisplay->setToolTip("Show event display window"); 1324 Layout->addWidget(PixDisplay, 4, 0); 1325 connect(PixDisplay, SIGNAL(clicked()), SLOT(ShowPixelDisplay())); 1326 1327 // Event display window 1328 Display = new QWidget(); 1329 Display->setWindowTitle("Edd - Event display"); 1330 1331 Pixel = new QPushButton *[MAXPIXEL]; 1332 int Count = 0; 1333 double x,y; 1334 1335 for (int ix=-22; ix<=22; ix++) for (int iy=-19; iy<=20; iy++) { 1336 if (Count == MAXPIXEL) break; 1337 1338 x = ix*0.866; 1339 y = iy - (ix%2==0 ? 0.5:0); 1340 if ((pow(x,2)+pow(y,2) >= 395) && !(abs(ix)==22 && iy==7)) continue; 1341 1342 Pixel[Count] = new QPushButton(Display); 1343 Pixel[Count]->setAutoFillBackground(true); 1344 Pixel[Count]->setGeometry(x*12.5 + 250, y*12.5 + 250, 10, 10); 1345 Pixel[Count]->show(); 1346 Count++; 1347 } 1348 1349 connect(Scope, SIGNAL(PixelData(QVector<double>)), SLOT(SetPixelData(QVector<double>))); 1350 } 1351 1352 TP_DAQ::~TP_DAQ() { 1353 1354 delete[] Pixel; 1355 } 1356 1357 // Translate pixel ID to board, chip, channel 1262 1358 void TP_DAQ::TranslatePixelID() { 1263 1359 … … 1287 1383 } 1288 1384 1289 // DAQ page 1385 // Show/hide pixel display 1386 void TP_DAQ::ShowPixelDisplay() { 1387 1388 Display->show(); 1389 Display->raise(); 1390 } 1391 1392 void TP_DAQ::SetPixelData(QVector<double> Data) { 1393 1394 QwtLinearColorMap Map; 1395 1396 for (int i=0; i<Data.size(); i++) { 1397 Pixel[i]->setPalette(QPalette(Map.color(QwtDoubleInterval(300, 400), Data[i]))); 1398 } 1399 } 1400 1401 1402 // 1403 // Evidence page 1404 // 1290 1405 TP_Evidence::TP_Evidence() { 1291 1406 … … 1367 1482 // Arrangement in tabs 1368 1483 TabWidget = new QTabWidget(Central); 1369 TabWidget->addTab(new TP_DAQ, " &drsdaq");1484 TabWidget->addTab(new TP_DAQ, "Event scope"); 1370 1485 TabWidget->addTab(new TP_Bias, "&Bias"); 1371 1486 TabWidget->addTab(new TP_Feedback, "&Feedback"); -
Evidence/Edd/Edd.h
r208 r212 19 19 #include <qwt_plot_marker.h> 20 20 #include <qwt_data.h> 21 #include <qwt_color_map.h> 21 22 22 23 #include <limits.h> … … 118 119 }; 119 120 121 // Sending command to DIM server 122 class EddCommand: public QLineEdit { 123 Q_OBJECT 124 125 QString Name; 126 127 public: 128 EddCommand(QString, QWidget * = NULL); 129 130 private slots: 131 void SendCommand(); 132 }; 133 120 134 // Graph class for history display 121 135 class EddPlot: public EddBasePlot { … … 213 227 QString Name; 214 228 int Count; 229 int LastUpdate; 215 230 class EvidenceHistory *HistClass; 216 231 }; … … 277 292 void RunHeaderChanged(QString); 278 293 void EventHeaderChanged(QString); 294 void PixelData(QVector<double>); 279 295 }; 280 296 … … 307 323 class TP_DAQ: public QWidget { 308 324 Q_OBJECT 325 static const int MAXPIXEL = 1440; 309 326 310 327 private: … … 315 332 QLineEdit *PixelID; 316 333 QFormLayout *FormLayout; 334 QWidget *Display; 335 QPushButton **Pixel; 317 336 318 337 private slots: … … 320 339 void UpdateScope(int); 321 340 void KeepCurrent(); 341 void ShowPixelDisplay(); 342 void SetPixelData(QVector<double>); 322 343 323 344 public: 324 345 TP_DAQ(); 346 ~TP_DAQ(); 325 347 }; 326 348 -
Evidence/Evidence.cc
r209 r212 370 370 } 371 371 372 // Requests service history 372 // Requests service history (returns true if data received OK) 373 373 bool EvidenceHistory::GetHistory() { 374 374 375 375 DimRpcInfo R((char *) "ServiceHistory", NO_LINK); 376 376 R.setData((char *) Name.c_str()); 377 378 // Check if data OK 377 379 if (!EvidenceServer::ServiceOK(&R)) return false; 378 380 if (R.getSize() == 0) return false; 381 382 // Copy data to buffer 379 383 delete[] Buffer; 380 384 BufferSize = R.getSize(); … … 382 386 383 387 memcpy(Buffer, R.getData(), BufferSize); 384 Offset = *(int *) Buffer;388 Rewind(); 385 389 386 390 return true; … … 406 410 return true; 407 411 } 412 413 // Reset to start of buffer 414 void EvidenceHistory::Rewind() { 415 416 if (Buffer != NULL) Offset = *(int *) Buffer; 417 } -
Evidence/Evidence.h
r209 r212 91 91 bool GetHistory(); 92 92 bool Next(int &, int &, void *&); 93 void Rewind(); 93 94 }; 94 95 #endif -
Evidence/readme.txt
r209 r212 28 28 When regular expression compiling results in error, State is set to ERROR, not 29 29 FATAL. The erroneous expression is ignored in the following. 30 25/5/2010 Service history remains available if service itself become unavailable 30 31 31 32
Note:
See TracChangeset
for help on using the changeset viewer.