- Timestamp:
- 01/29/10 14:27:34 (15 years ago)
- Location:
- Evidence
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
Evidence/Alarm.cc
r152 r154 112 112 strcmp(getInfo()->getString(), NO_LINK)==0) State[i] = 4; 113 113 else { 114 State[i] = *(getInfo()->getString()+getInfo()->getSize() );114 State[i] = *(getInfo()->getString()+getInfo()->getSize()-1); 115 115 116 printf("*** String length: %d Message length: %d Last number: %d\n",strlen(getInfo()->getString()),getInfo()->getSize(),State[i]); 116 117 // Print message 117 118 time_t RawTime = getInfo()->getTimestamp(); … … 156 157 157 158 // Check periodically if servers are up 158 while(! EvidenceServer::ExitRequest) {159 while(!Alarm.ExitRequest) { 159 160 for (int i=0; i<Alarm.NumServers; i++) { 160 161 Exists = false; -
Evidence/Config.cc
r151 r154 158 158 Notify = -1; 159 159 } 160 160 161 161 // Sleep until file changes or signal caught 162 while (! EvidenceServer::ExitRequest) {162 while (!Config.ExitRequest) { 163 163 if (Notify != -1) { 164 164 read(Notify, &Event, sizeof(Event)); -
Evidence/Edd/Edd.cc
r152 r154 69 69 // If this is a status indicator, adapt background colour 70 70 if (Data.size() == Text.size()+2) { 71 switch (Data[Text.size() + 2]) {71 switch (Data[Text.size() + 1]) { 72 72 case 0: Pal.setColor(QPalette::Base, Qt::white); break; 73 case 1: Pal.setColor(QPalette::Base, Qt:: cyan); break;73 case 1: Pal.setColor(QPalette::Base, Qt::yellow); break; 74 74 case 2: Pal.setColor(QPalette::Base, Qt::red); break; 75 75 case 3: Pal.setColor(QPalette::Base, Qt::red); break; … … 623 623 MainLayout->addWidget(Textout, 1, 0, 1, 2); 624 624 625 QFrame *Val = new QFrame(); 626 Val->setFrameStyle(QFrame::HLine); 627 Val->setLineWidth(10); 628 //Value->setMaximumWidth(200); 629 MainLayout->addWidget(Val, 2, 0, 2, 1); 630 625 631 Value = new Edd_Indicator("DColl/Status"); 626 632 Value->setMaximumWidth(200); … … 702 708 // Tab widget 703 709 TabWidget = new QTabWidget(Central); 704 TabWidget->addTab(MainWidget, "&Main");705 710 TabWidget->addTab(BiasWidget, "&Bias"); 706 711 TabWidget->addTab(EnvironmentWidget, "&Environment"); 712 TabWidget->addTab(MainWidget, "Evidence"); 707 713 708 714 // Menu bar -
Evidence/Evidence.cc
r152 r154 25 25 #include "Evidence.h" 26 26 27 bool EvidenceServer::ExitRequest = false; 28 string __StatusName; 27 EvidenceServer *ThisServer; 29 28 30 29 // Constructor starts server with given name … … 33 32 // Initialize 34 33 Status = NULL; 35 ConfigList = NULL; 36 ConfigNum = 0; 37 __StatusName = string(Name) + "/Status"; 34 ExitRequest = false; 35 ThisServer = this; 38 36 39 37 // Catch some signals … … 47 45 48 46 // Start server 49 Status = new DimService(__StatusName.c_str(), (char *) "Server started"); 47 static char Init[] = "Server started"; 48 Status = new DimService((string(Name) + "/Status").c_str(), (char *) "C", Init, sizeof(Init)); 50 49 51 50 start(Name); 52 51 addExitHandler(this); 52 53 53 } 54 54 … … 56 56 EvidenceServer::~EvidenceServer() { 57 57 58 for (unsigned int i=0; i<Config Num; i++) {58 for (unsigned int i=0; i<ConfigList.size(); i++) { 59 59 delete[] ConfigList[i].Name; 60 60 delete[] ConfigList[i].Value; 61 61 } 62 free(ConfigList);63 62 } 64 63 … … 93 92 va_end(ArgumentPointer); 94 93 95 snprintf(TBuf, sizeof(TBuf), "%s (%s): %s", __StatusName.c_str(), StateString[Severity], Tmp); // Normal string 96 snprintf(SBuf, sizeof(SBuf), "%s*%c", Tmp, (char) Severity); 97 *(strrchr(SBuf, '*')) = '\0'; // String with severity encoding 94 // Create normal string 95 snprintf(TBuf, sizeof(TBuf), "%s (%s): %s", Status->getName(), StateString[Severity], Tmp); 96 97 // Create string with severity encoding 98 snprintf(SBuf, sizeof(SBuf), "%s**", Tmp); 99 SBuf[strlen(SBuf)-2] = '\0'; 100 SBuf[strlen(SBuf)+1] = Severity; 101 98 102 if (Tmp != ErrorString) free(Tmp); 99 103 … … 120 124 121 125 // Check if configuration request already in list 122 for (unsigned int i=0; i<Config Num; i++) {126 for (unsigned int i=0; i<ConfigList.size(); i++) { 123 127 if (strcmp(ConfigList[i].Name, Item) == 0) { 124 128 // Return original value if still up to date … … 144 148 } 145 149 146 // Enlarge memory to hold new pointerif necessary150 // Enlarge list if necessary 147 151 if (ItemNo == -1) { 148 void *N = realloc(ConfigList, sizeof(struct ConfigItem)*(++ConfigNum)); 149 if (N == NULL) { 150 State(WARN, "Could not realloc() memory for configuration, will lose memory (%s)", strerror(errno)); 151 ConfigNum--; 152 } 153 else ConfigList = (struct ConfigItem *) N; 154 155 ItemNo = ConfigNum-1; 156 } 157 158 // Allocate memory for strings, and copy data to this memory 152 struct ConfigItem New; 153 ConfigList.push_back(New); 154 ItemNo = ConfigList.size()-1; 155 } 156 157 // Create new entry in item list, allocate memory and copy data to this memory 159 158 ConfigList[ItemNo].Value = new char [strlen(Result)+1]; 160 159 ConfigList[ItemNo].Name = new char [strlen(Item)+1]; 161 160 strcpy(ConfigList[ItemNo].Name, Item); 162 161 strcpy(ConfigList[ItemNo].Value, Result); 163 164 162 ConfigList[ItemNo].Time = Time; 165 163 166 164 // Return address to configuration value 167 165 return ConfigList[ItemNo].Value; … … 174 172 void EvidenceServer::SignalHandler(int) { 175 173 176 EvidenceServer::ExitRequest = true;174 ThisServer->ExitRequest = true; 177 175 } 178 176 … … 180 178 void EvidenceServer::Terminate() { 181 179 182 string Msg = __StatusName + ": Caught unhandled exception"; 180 string Msg = string(ThisServer->Status->getName()) + ": Caught unhandled exception"; 181 183 182 printf("%s\n", Msg.c_str()); 184 183 DimClient::sendCommand("DColl/Log", Msg.c_str()); … … 187 186 } 188 187 188 189 189 // Translates DIMInfo to string (memory has to be freed by caller) 190 190 // No DIM structures are supported (only a single number or string is converted) 191 // For string conversion, a terminating \0 is enforced. 191 192 char *EvidenceServer::ToString(DimInfo *Item) { 192 193 … … 198 199 switch (*(Item->getFormat())) { 199 200 case 'I': R = asprintf(&Text, "%d", Item->getInt()); break; 200 case 'C': R = asprintf(&Text, "%s", Item->getString()); break;201 201 case 'S': R = asprintf(&Text, "%hd", Item->getShort()); break; 202 202 case 'F': R = asprintf(&Text, "%.5f", Item->getFloat()); break; 203 203 case 'D': R = asprintf(&Text, "%.5f", Item->getDouble()); break; 204 204 case 'X': R = asprintf(&Text, "%lld", Item->getLonglong()); break; 205 case 'C': *(Item->getString() + Item->getSize()) = '\0'; 206 R = asprintf(&Text, "%s", Item->getString()); 207 break; 205 208 default: return NULL; 206 209 } -
Evidence/Evidence.h
r152 r154 7 7 #include <errno.h> 8 8 #include <exception> 9 #include <vector> 9 10 10 11 #include "dis.hxx" … … 30 31 char *Value; 31 32 int Time; 32 } *ConfigList;33 unsigned int ConfigNum;33 }; 34 vector<struct ConfigItem> ConfigList; 34 35 35 36 DimService *Status; … … 50 51 static char* ToString(DimInfo *); 51 52 52 staticbool ExitRequest;53 bool ExitRequest; 53 54 }; 54 55
Note:
See TracChangeset
for help on using the changeset viewer.