Changeset 12711
- Timestamp:
- 12/07/11 09:08:51 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/logtime.cc
r11983 r12711 3 3 #include "tools.h" 4 4 #include "Time.h" 5 #include "dic.hxx" 6 #include <iostream> 5 7 6 #include <iostream> 8 using namespace std; 9 struct testType { 10 long v1; 11 long v2; 12 long v3; 13 long v4; 14 long v5; 15 long v6; 16 long v7; 17 long v8; 18 long v9; 19 long v10; 20 }; 21 22 struct DataLoggerStats { 23 long sizeWritten; 24 long freeSpace; 25 long writingRate; 26 }; 27 28 class StatSub : public DimClient 29 { 30 DimStampedInfo* info; 31 DimStampedInfo* info2; 32 33 public: 34 StatSub() 35 { 36 info = new DimStampedInfo("FAD_CONTROL/START_RUN", const_cast<char*>(""), this); 37 info2 = new DimStampedInfo("TIME/EMPTY", const_cast<char*>(""), this); 38 } 39 void infoHandler() 40 { 41 return; 42 DimInfo* I = getInfo(); 43 if (I == info2) 44 { 45 cout << "EMPTY SERVICE UPDATED. " << "Format: " << I->getFormat() << endl; 46 } 47 if (I != info) 48 return; 49 DataLoggerStats* data = reinterpret_cast<DataLoggerStats*>(I->getData()); 50 std::cout << "size written: " << data->sizeWritten << " free space: " << data->freeSpace << " writing rate" << data->writingRate << std::endl; 51 } 52 }; 53 54 DimService * myService; 7 55 8 56 int main(int, const char **) … … 11 59 setenv("DIM_DNS_NODE", "localhost", 0); 12 60 61 cout << "This is the new version of the service 21 July 2011" << endl; 62 13 63 // Start a DimServer called TIME 14 DimServer::start(" TIME");64 DimServer::start("FAD_CONTROL"); 15 65 16 66 // Some info on the console 17 67 std::cout << "Offering TIME/MESSAGE...\n" << std::endl; 68 long emptyFormatVariable[2]; 69 emptyFormatVariable[0] = 1; 70 emptyFormatVariable[1] = 2; 71 const char* format = "X:1;X:1"; 72 DimService* emptyFormatService = new DimService("FAD_CONTROL/START_RUN", "X:1;X:1", emptyFormatVariable, 2*sizeof(long)); 73 testType variable; 74 variable.v1 = 0; 75 variable.v2 = 1; 76 variable.v3 = 2; 77 variable.v4 = 3; 78 variable.v5 = 4; 79 variable.v6 = 5; 80 variable.v7 = 6; 81 variable.v8 = 7; 82 variable.v9 = 8; 83 variable.v10 = 9; 84 // DimDescribedService srvc("TIME/ETIENNE", "X:1;X:1;X:1;X:1;X:1;X:1;X:1;X:1;X:1;X:1", variable, "Test Service"); 18 85 86 StatSub stSub; 87 // delete emptyFormatService; 88 // usleep(1000000); 89 // emptyFormatService = new DimService("TIME/EMPTY", "X:1", &emptyFormatVariable, sizeof(long)); 90 91 cout << "Test service created" << endl; 19 92 // Setup a DimService called TIME/MESSAGE 20 93 MessageDimTX msg("TIME"); 21 94 while (1) 22 95 { 23 // Send current time 24 msg.Message(Time().GetAsStr()); 96 // if (variable.v1 %10 == 0) 97 // { 98 // delete emptyFormatService; 99 // cout << "Service deleted" << endl; 100 // usleep(1000000); 101 // emptyFormatService = new DimService("TIME/EMPTY", "X:1", &emptyFormatVariable, sizeof(long)); 102 // cout << "Service re-created" << endl; 103 // } 25 104 105 // srvc.updateService(); 106 emptyFormatService->updateService(); 107 emptyFormatVariable[0]++; 108 emptyFormatVariable[1]++; 109 variable.v1++; 110 variable.v2++; 111 variable.v3++; 112 variable.v4++; 113 variable.v5++; 114 variable.v6++; 115 variable.v7++; 116 variable.v8++; 117 variable.v9++; 118 variable.v10++; 26 119 // wait approximately one second 27 120 usleep(1000000);
Note:
See TracChangeset
for help on using the changeset viewer.