Changeset 10984
- Timestamp:
- 06/10/11 15:02:24 (13 years ago)
- Location:
- fact
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
fact/Evidence/GUI.cc
r10928 r10984 46 46 if (Format.size() == 1 && Format[0] != 'C') return new EddPlot(Service, Index); 47 47 else return new EddText(Service); 48 49 48 50 } 49 51 … … 235 237 setAcceptDrops(true); 236 238 setAxisScaleDraw(QwtPlot::xBottom, new EddTimeScale); 237 239 238 240 // Update time range on plot when axis change (update() results in paintEvent()) 239 241 connect(axisWidget(QwtPlot::xBottom), SIGNAL(scaleDivChanged()), SLOT(update())); … … 252 254 Menu->insertAction(Menu->actions().value(1), Action); 253 255 254 // Maximum number if points in curve (will be increased in Update()) 255 SizeLimit = 0; 256 // Set timer to regularly update plot if new data available 257 SingleShot = new QTimer(this); 258 connect(SingleShot, SIGNAL(timeout()), this, SLOT(UpdatePlot())); 259 SingleShot->setSingleShot(true); 256 260 257 261 // DIM client … … 284 288 List.append(N); 285 289 290 // Request new history buffer 291 const struct EvidenceHistory::Item *R; 292 class EvidenceHistory *Hist; 293 294 if ((Hist = Handler->GetHistory(Name)) != NULL) { 295 double Number=0; 296 while ((R=Hist->Next()) != NULL) { 297 switch (*(Hist->GetFormat())) { 298 case 'I': 299 case 'L': Number = *((int *) R->Data + N.Index); break; 300 case 'S': Number = *((short *) R->Data + N.Index); break; 301 case 'F': Number = *((float *) R->Data + N.Index); break; 302 case 'D': Number = *((double *) R->Data + N.Index); break; 303 case 'X': Number = *((long long *) R->Data + N.Index); break; 304 default: break; 305 } 306 AddPoint(List.size()-1, R->Time, Number); 307 } 308 } 309 Handler->DropHistory(Name); 286 310 Handler->Subscribe(Name); 311 312 SingleShot->start(100); 287 313 } 288 314 … … 290 316 void EddPlot::Update(QString Name, int Time, QByteArray, QString Format, QString Text) { 291 317 292 bool DoUpdate = false; 293 294 // Determine which plot item this call belongs to 295 int ItemNo; 296 for (ItemNo=0; ItemNo<List.size(); ItemNo++) if (List[ItemNo].Name == Name) { 297 298 DoUpdate = true; 299 300 // If size limit reached, clear buffer 301 if (List[ItemNo].Signal->dataSize() > SizeLimit) List[ItemNo].Signal->setData(QPolygonF()); 302 303 // If buffer empty, request new history buffer 304 if (List[ItemNo].Signal->dataSize() == 0) { 305 int Count=0; 306 const struct EvidenceHistory::Item *R; 307 class EvidenceHistory *Hist; 308 309 if ((Hist = Handler->GetHistory(List[ItemNo].Name)) != NULL) { 310 double Number=0; 311 while ((R=Hist->Next()) != NULL) { 312 switch (*(Hist->GetFormat())) { 313 case 'I': 314 case 'L': Number = *((int *) R->Data + List[ItemNo].Index); break; 315 case 'S': Number = *((short *) R->Data + List[ItemNo].Index); break; 316 case 'F': Number = *((float *) R->Data + List[ItemNo].Index); break; 317 case 'D': Number = *((double *) R->Data + List[ItemNo].Index); break; 318 case 'X': Number = *((long long *) R->Data + List[ItemNo].Index); break; 319 default: break; 320 } 321 AddPoint(ItemNo, R->Time, Number); 322 Count++; 323 } 324 325 // Local buffer at least twice as large as longest history 326 if (SizeLimit < 2*Count) SizeLimit = 2*Count; 327 } 328 Handler->DropHistory(List[ItemNo].Name); 329 } 330 331 // Append data only if service available 318 for (int ItemNo=0; ItemNo<List.size(); ItemNo++) if (List[ItemNo].Name == Name) { 319 320 // Append data if service available 332 321 if (SetStatus(this, Name, Time, Format)) { 333 322 QString Txt = Text; … … 335 324 AddPoint(ItemNo, Time, atof(Txt.toAscii().data())); 336 325 } 337 } 338 339 if (DoUpdate) UpdatePlot();326 327 NewData = true; 328 } 340 329 } 341 330 … … 412 401 setCanvasBackground(EddPlotBackgroundColor); 413 402 setMargin(15); 403 NewData = false; 414 404 415 405 // Plot navigation … … 460 450 Menu->addAction("Single trace", this, SLOT(MenuSingleTrace())); 461 451 Menu->addSeparator(); 452 Menu->addAction("Set update rate", this, SLOT(MenuSetUpdateRate())); 453 Menu->addSeparator(); 462 454 Menu->addAction("Save as ASCII", this, SLOT(MenuSaveASCII())); 463 455 Menu->addAction("Save plot", this, SLOT(MenuSave())); 464 456 Menu->addAction("Print plot", this, SLOT(MenuPrint())); 465 457 Menu->addAction("Plot help", this, SLOT(MenuPlotHelp())); 458 459 // Set timer to regularly update plot if new data available 460 Timer = new QTimer(this); 461 connect(Timer, SIGNAL(timeout()), this, SLOT(UpdatePlot())); 462 Timer->start(2000); 466 463 } 467 464 … … 527 524 Symbol.setStyle(QwtSymbol::Ellipse); 528 525 Symbol.setSize(4); 526 527 // Only update if called by timer if new data is available 528 if (sender() == Timer && !NewData) return; 529 NewData = false; 529 530 530 531 // Select engine for linear or logarithmic scale … … 560 561 } 561 562 } 562 563 563 564 // Plot data 564 565 Items[ItemNo].Signal->setData(Items[ItemNo].x.data(), y, DataPoints); … … 716 717 } 717 718 UpdatePlot(); 719 } 720 721 // Set maximum update rate of plot 722 void EddBasePlot::MenuSetUpdateRate() { 723 724 bool OK; 725 double Rate; 726 727 Rate = QInputDialog::getDouble(this, "Edd Request", 728 "Minimum period between plot updates (sec)", (double) Timer->interval()/1000, 0, std::numeric_limits<double>::max(), 2, &OK); 729 if (OK) Timer->setInterval(Rate*1000); 718 730 } 719 731 -
fact/Evidence/GUI.h
r10928 r10984 22 22 #include <qwt_color_map.h> 23 23 24 #include <limits .h>24 #include <limits> 25 25 #include <float.h> 26 #include <limits> 26 27 27 28 #include "dic.hxx" … … 72 73 ~EddBasePlot(); 73 74 75 QTimer *Timer; 76 bool NewData; 74 77 QwtPlotCurve *NewCurve(QwtText); 75 78 void ClearCurve(unsigned int); … … 86 89 void contextMenuEvent(QContextMenuEvent *); 87 90 void MenuSingleTrace(); 91 void MenuSetUpdateRate(); 88 92 void MenuZoomOut(); 89 93 void MenuSaveASCII(); … … 172 176 private: 173 177 QwtLegend *Legend; 174 int SizeLimit;178 QTimer *SingleShot; 175 179 176 180 void dragEnterEvent(QDragEnterEvent *); -
fact/tools/Edd/Edd.cc
r10928 r10984 7 7 EddLineDisplay changes its background colour in case it display 8 8 a DIM status service 9 10 Note: Currently no limit to number of points in plot, can result in out of memory condition. 9 11 10 12 ============================================================ */ … … 55 57 AddTrace(0,0,0); 56 58 59 // Update interval 60 Timer->setInterval(100); 57 61 SetActive(true); 58 62 } … … 334 338 335 339 // 336 // Environment page 340 // Environment page (For M0, server was called ARDUINO) 337 341 // 338 342 TP_Environment::TP_Environment() { … … 342 346 343 347 // Status display 344 EddLineDisplay *Line = new EddLineDisplay("ARDUINO/Message"); 345 Line->setMaximumWidth(200); 346 Layout->addWidget(Line, 0, 0, 1, 2); 347 348 // Generate plot and data displays 348 EddLineDisplay *Line = new EddLineDisplay("FSCctrl/Message"); 349 Line->setMaximumWidth(300); 350 Layout->addWidget(Line, 0, 0, 1, 4); 351 352 Line = new EddLineDisplay("FSCctrl/Time"); 353 Layout->addWidget(Line, 0, 5, 1, 2); 354 355 // Temperatures 349 356 EddPlot *Plot = new EddPlot(); 350 for (int i=0; i<10; i++) { 351 Line = new EddLineDisplay("ARDUINO/Data", i); 352 Layout->addWidget(Line, i%5+1, i/5, 1, 1); 353 Plot->AddService("ARDUINO/Data", i); 354 } 355 Layout->addWidget(Plot, 0, 2, 9, 7); 357 for (int i=0; i<64; i++) { 358 Line = new EddLineDisplay("FSCctrl/Temperature", i); 359 Line->setMaximumWidth(50); 360 Layout->addWidget(Line, i/8+1, i%8); 361 Plot->AddService("FSCctrl/Temperature", i); 362 } 363 Layout->addWidget(Plot, 0, 10, 22, 15); 364 365 // Voltages and currents 366 for (int i=0; i<40; i++) { 367 Line = new EddLineDisplay("FSCctrl/Voltage", i); 368 Line->setMaximumWidth(50); 369 Layout->addWidget(Line, i/8+10, i%8); 370 371 Line = new EddLineDisplay("FSCctrl/Current", i); 372 Line->setMaximumWidth(50); 373 Layout->addWidget(Line, i/8+16, i%8); 374 } 356 375 357 376 // Night sky monitor 358 377 Line = new EddLineDisplay("SQM/Message"); 359 Line->setMaximumWidth( 200);360 Layout->addWidget(Line, 6, 0, 1, 2);378 Line->setMaximumWidth(300); 379 Layout->addWidget(Line, 22, 0, 1, 4); 361 380 362 381 Line = new EddLineDisplay("SQM/NSB"); 363 Layout->addWidget(Line, 7, 0, 1, 1);382 Layout->addWidget(Line, 22, 5, 1, 2); 364 383 } 365 384 … … 872 891 TabWidget->addTab(new TP_Bias, "Bias"); 873 892 TabWidget->addTab(new TP_Feedback, "Feedback"); 874 TabWidget->addTab(new TP_Environment, " Environment");893 TabWidget->addTab(new TP_Environment, "FSC/SQM"); 875 894 TabWidget->addTab(new TP_Evidence, "Evidence"); 876 895
Note:
See TracChangeset
for help on using the changeset viewer.