Changeset 10928
- Timestamp:
- 06/08/11 14:59:22 (14 years ago)
- Location:
- fact
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
fact/Evidence/GUI.cc
r10280 r10928 81 81 setFrame(false); 82 82 setAttribute(Qt::WA_DeleteOnClose); 83 setText("connecting..."); 83 84 84 85 // Connect to DIM handler 85 if (connect(Handler, SIGNAL(YEP(QString, int, QByteArray, QString, QString)), SLOT(Update(QString, int, QByteArray, QString, QString)) ) == false) {86 if (connect(Handler, SIGNAL(YEP(QString, int, QByteArray, QString, QString)), SLOT(Update(QString, int, QByteArray, QString, QString)), Qt::QueuedConnection) == false) { 86 87 printf("Failed connection for %s\n", Name.toAscii().data()); 87 88 } … … 242 243 243 244 // Connect to DIM handler 244 if (connect(Handler, SIGNAL(YEP(QString, int, QByteArray, QString, QString)), SLOT(Update(QString, int, QByteArray, QString, QString)) ) == false) {245 if (connect(Handler, SIGNAL(YEP(QString, int, QByteArray, QString, QString)), SLOT(Update(QString, int, QByteArray, QString, QString)), Qt::QueuedConnection) == false) { 245 246 printf("Failed connection for %s\n", Service.toAscii().data()); 246 247 } … … 795 796 setAttribute(Qt::WA_DeleteOnClose); 796 797 setAutoFillBackground(true); 798 setText("connecting..."); 797 799 document()->setMaximumBlockCount(1000); 798 800 Accumulate = true; 799 801 800 802 // Connect to DIM handler 801 if (connect(Handler, SIGNAL(YEP(QString, int, QByteArray, QString, QString)), SLOT(Update(QString, int, QByteArray, QString, QString)) ) == false) {803 if (connect(Handler, SIGNAL(YEP(QString, int, QByteArray, QString, QString)), SLOT(Update(QString, int, QByteArray, QString, QString)), Qt::QueuedConnection) == false) { 802 804 printf("Failed connection for %s\n", Name.toAscii().data()); 803 805 } … … 839 841 Pal.setColor(QPalette::Base, Qt::lightGray); 840 842 setPalette(Pal); 843 setText("n/a"); 841 844 return; 842 845 } … … 875 878 printf("Failed connection in EddDim()\n"); 876 879 } 880 881 // To ensure responsiveness of GUI, subscriptions handled only when no GUI events (timeout 0) 882 Timer = new QTimer(this); 883 connect(Timer, SIGNAL(timeout()), SLOT(MakeSubscriptions())); 884 Timer->start(); 877 885 } 878 886 … … 886 894 } 887 895 888 // Subscribe to DIM service 896 // Subscribe to DIM service (actual subscription handled in worker thread below) 889 897 void EddDim::Subscribe(QString Name) { 890 898 891 899 // Lock before accessing list 892 900 QMutexLocker Locker(Mutex); 893 894 // If already subscribed to service, increase usage count and reemit data for new subscriber 901 WaitingList.append(Name); 902 } 903 904 // Subscriptions handled only when no GUI events waiting (launched by timer, see constructor) 905 void EddDim::MakeSubscriptions() { 906 907 if (WaitingList.isEmpty()) return; 908 909 // Lock before accessing list 910 QMutexLocker Locker(Mutex); 911 912 QString Name = WaitingList.first(); 913 WaitingList.removeFirst(); 914 915 // If already subscribed to service, increase usage count 895 916 if (ServiceList.contains(Name)) { 896 917 ServiceList[Name].Count++; 897 YEP(Name, ServiceList[Name].TimeStamp, ServiceList[Name].ByteArray, ServiceList[Name].Format, ServiceList[Name].Text);918 //YEP(Name, ServiceList[Name].TimeStamp, ServiceList[Name].ByteArray, ServiceList[Name].Format, ServiceList[Name].Text); 898 919 return; 899 920 } … … 904 925 ServiceList[Name].Count = 1; 905 926 ServiceList[Name].DIMService = new DimStampedInfo(Name.toAscii().data(), INT_MAX, NO_LINK, this); 906 return; 907 } 927 } 928 908 929 909 930 // Unsubsribe from DIM service … … 973 994 } 974 995 996 // Force reemit of all buffered DIM data (work around for widget update problem) 997 void EddDim::ForceEmit() { 998 999 // Lock before accessing list 1000 QMutexLocker Locker(Mutex); 1001 1002 QMap<QString, struct Item>::const_iterator i = ServiceList.constBegin(); 1003 1004 while (i != ServiceList.constEnd()) { 1005 YEP(i.key(), i.value().TimeStamp, i.value().ByteArray, i.value().Format, i.value().Text); 1006 ++i; 1007 } 1008 } 1009 975 1010 // Store service information for usage by Subscribe(), update statistics and emit signal to widgets 976 1011 void EddDim::Update(QString Name, int Time, QByteArray Data, QString Format, QString Text) { … … 1027 1062 1028 1063 if (M->isVisible()) M->hide(); 1029 else M->show(); 1064 else { 1065 M->show(); 1066 M->raise(); 1067 } 1030 1068 } 1031 1069 -
fact/Evidence/GUI.h
r10280 r10928 3 3 4 4 #include <QtGui> 5 5 #include <QtConcurrentRun> 6 6 7 #include <qwt_plot.h> 7 8 #include <qwt_plot_curve.h> … … 224 225 QMap<QString, struct Item> ServiceList; 225 226 QMutex *Mutex; 227 QList<QString> WaitingList; 226 228 227 229 struct HistItem { … … 239 241 void Update(QString, int, QByteArray, QString, QString); 240 242 void UpdateStatistics(); 243 void MakeSubscriptions(); 241 244 242 245 public: … … 248 251 class EvidenceHistory *GetHistory(QString); 249 252 void DropHistory(QString); 253 void ForceEmit(); 250 254 251 255 signals: -
fact/tools/Edd/Edd.cc
r10912 r10928 732 732 Scope->SetActive(!State); 733 733 StartStopButton->setText(State ? "Start" : "Stop"); 734 //if (!State) connect(Handler, SIGNAL(YEP(QString, int, QByteArray, QString, QString)), Scope, SLOT(Update(QString, int, QByteArray, QString, QString)));735 //else disconnect(Handler, SIGNAL(YEP(QString, int, QByteArray, QString, QString)), Scope, SLOT(Update(QString, int, QByteArray, QString, QString)));736 734 } 737 735 … … 828 826 829 827 Button = new QPushButton(); 830 Button->setText(" StartDIM browser");828 Button->setText("DIM browser"); 831 829 connect(Button, SIGNAL(released()), SLOT(StartDIMBrowser())); 832 830 Layout->addWidget(Button, 7, 1, 1, 1); … … 904 902 connect(Timer, SIGNAL(timeout()), this, SLOT(CheckAlarm())); 905 903 Timer->start(5000); 904 905 // Force update of all widgets constructed (in thread for GUI responsiveness) 906 QtConcurrent::run(Handler, &EddDim::ForceEmit); 906 907 } 907 908
Note:
See TracChangeset
for help on using the changeset viewer.