Changeset 11837 for trunk/FACT++
- Timestamp:
- 08/07/11 18:43:13 (13 years ago)
- Location:
- trunk/FACT++/src
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/DimDescriptionService.cc
r11059 r11837 37 37 38 38 #include "dis.hxx" 39 #include "Time.h" 39 40 40 41 using namespace std; … … 118 119 fData += fDescription + '\n'; 119 120 121 const Time t; 122 fService->setTimestamp(t.Time_t(), t.ms()); 120 123 fService->setData(const_cast<char*>(fData.c_str())); 121 124 fService->updateService(); … … 141 144 fService=0; 142 145 } 146 147 void DimDescribedService::setTime(const Time &t) 148 { 149 setTimestamp(t.Time_t(), t.ms()); 150 } 151 152 void DimDescribedService::setTime() 153 { 154 setTime(Time()); 155 } 156 157 int DimDescribedService::Update(const Time &t) 158 { 159 setTime(t); 160 return updateService(); 161 } 162 163 int DimDescribedService::Update() 164 { 165 return Update(Time()); 166 } 167 168 int DimDescribedService::Update(const string &data) 169 { 170 return Update(data.data()); 171 } 172 173 int DimDescribedService::Update(const char *data) 174 { 175 DimService::setData(const_cast<char*>(data)); 176 return Update(); 177 } -
trunk/FACT++/src/DimDescriptionService.h
r11246 r11837 2 2 #define FACT_DimDescriptionService 3 3 4 #include <array> 4 5 #include <string> 5 6 #include <vector> 6 7 8 class Time; 7 9 class DimService; 8 10 … … 45 47 } 46 48 47 template<class T> 48 void Update(const T &data) 49 void setData(const void *ptr, size_t sz) 49 50 { 50 //cout << "Update: " << svc.getName() << " (" << sizeof(T) << ")" << endl; 51 setData(const_cast<T*>(&data), sizeof(T)); 52 updateService(); 51 DimService::setData(const_cast<void*>(ptr), sz); 53 52 } 54 53 55 54 template<typename T> 56 void Update(const std::vector<T> &data)55 void setData(const std::vector<T> &data) 57 56 { 58 //std::cout << "Update: " << getName() << " " << data.size() << " " << sizeof(T) << std::endl; 59 setData(const_cast<T*>(data.data()), data.size()*sizeof(T)); 60 updateService(); 57 setData(data.data(), data.size()*sizeof(T)); 58 } 59 60 template<class T, size_t N> 61 void setData(const std::array<T, N> &data) 62 { 63 setData(data.data(), N*sizeof(T)); 64 } 65 66 void setTime(const Time &t); 67 void setTime(); 68 69 int Update(); 70 int Update(const Time &t); 71 int Update(const std::string &data); 72 int Update(const char *data); 73 74 template<class T> 75 int Update(const T &data) 76 { 77 setData(&data, sizeof(T)); 78 return Update(); 79 } 80 81 template<typename T> 82 int Update(const std::vector<T> &data) 83 { 84 setData(data); 85 return Update(); 86 } 87 88 template<class T, size_t N> 89 int Update(const std::array<T, N> &data) 90 { 91 setData(data); 92 return Update(); 61 93 } 62 94 63 95 // FIXME: Implement callback with boost::function instead of Pointer to this 64 65 96 }; 66 97 -
trunk/FACT++/src/EventBuilderWrapper.h
r11824 r11837 197 197 uint32_t maxevt; 198 198 199 string name; 200 199 201 FAD::Configuration reference; 202 203 bool started; 200 204 }; 201 205 202 206 map<uint32_t, RunDescription> fExpectedRuns; 203 207 204 uint32_t StartNewRun(int64_t maxtime, int64_t maxevt, const FAD::Configuration&ref)208 uint32_t StartNewRun(int64_t maxtime, int64_t maxevt, const pair<string, FAD::Configuration> &ref) 205 209 { 206 210 if (maxtime<=0 || maxtime>24*60*60) … … 213 217 uint32_t(maxtime), 214 218 uint32_t(maxevt), 215 ref 219 ref.first, 220 ref.second, 221 false 216 222 }; 217 223 218 224 // FIMXE: Maybe reset an event counter so that the mcp can count events? 225 226 fMsg.Info(" ==> TODO: Set a limit on the size of fExpectedRuns!"); 219 227 220 228 fExpectedRuns[fRunNumber] = descr; … … 484 492 { 485 493 fMsg.Info(" ==> TODO: Update run configuration in database!"); 494 fMsg.Info(" ==> TODO: Remove run from fExpected runs in case of failure!"); 495 fMsg.Info(" ==> TODO: Write information from fTargetConfig to header!"); 486 496 487 497 // Check if file already exists... … … 563 573 } 564 574 575 virtual void CloseRun(uint32_t runid) { } 576 565 577 int runClose(FileHandle_t handler, RUN_TAIL *tail, size_t) 566 578 { 567 579 fMsg.Info(" ==> TODO: Update run configuration in database!"); 580 fMsg.Info(" ==> TODO: Remove run from fExpected runs!"); 568 581 569 582 DataProcessorImp *file = reinterpret_cast<DataProcessorImp*>(handler); … … 581 594 582 595 fLastClosed = file->GetRunId(); 596 CloseRun(fLastClosed); 583 597 UpdateRuns(); 584 598 … … 710 724 const FAD::EventHeader *end = reinterpret_cast<FAD::EventHeader*>(fadhd)+40; 711 725 726 // FIMXE: Compare with target configuration 727 712 728 for (const FAD::EventHeader *ptr=beg; ptr!=end; ptr++) 713 729 { … … 813 829 bool IsRunStarted() const 814 830 { 815 return fExpectedRuns.find(fRunNumber-1)==fExpectedRuns.end(); 831 const map<uint32_t,RunDescription>::const_iterator it = fExpectedRuns.find(fRunNumber-1); 832 return it==fExpectedRuns.end();// ? true : it->second.started; 816 833 } 817 834 … … 834 851 CloseRunFile(runnr, time(NULL)+it->second.maxtime, it->second.maxevt); 835 852 // return: 0=close scheduled / >0 already closed / <0 does not exist 853 854 // FIXME: Move configuration from expected runs to runs which will soon 855 // be opened/closed 856 857 it->second.started = true; 836 858 837 859 fExpectedRuns.erase(it); … … 1056 1078 // svc.setQuality(vec[40]<=vec[41]); 1057 1079 svc.setData(const_cast<T*>(data.data()), sizeof(T)*n); 1058 svc. updateService();1080 svc.Update(); 1059 1081 } 1060 1082 -
trunk/FACT++/src/MessageDim.cc
r11395 r11837 91 91 // We have to use setData to make sure the DimService will 92 92 // hold a local copy of the data. 93 setTimestamp(t.Time_t(), t.ms());94 setData(const_cast<char*>(txt.c_str()));95 93 setQuality(qos); 96 94 97 const int rc = updateService();95 const int rc = DimDescribedService::Update(txt); 98 96 99 97 dim_unlock(); -
trunk/FACT++/src/StateMachineDim.cc
r11479 r11837 112 112 return; 113 113 114 fDescriptionStates.setData(const_cast<char*>((str0+str1+doc+'\n').c_str())); 115 fDescriptionStates.updateService(); 114 fDescriptionStates.Update(str0+str1+doc+'\n'); 116 115 } 117 116 … … 131 130 132 131 fSrvState.setQuality(state); 133 fSrvState.setData(const_cast<char*>(msg.c_str())); 134 fSrvState.updateService(); 132 fSrvState.Update(msg); 135 133 136 134 return msg; 137 135 } 138 136 137 // -------------------------------------------------------------------------- 138 // 139 //! In the case of dim this secures HandleEvent against dim's commandHandler 140 //! 139 141 void StateMachineDim::Lock() 140 142 { 141 // dim_lock(); 142 } 143 143 dim_lock(); 144 } 145 146 // -------------------------------------------------------------------------- 147 // 148 //! In the case of dim this secures HandleEvent against dim's commandHandler 149 //! 144 150 void StateMachineDim::UnLock() 145 151 { 146 //dim_unlock();152 dim_unlock(); 147 153 } 148 154 -
trunk/FACT++/src/datalogger.cc
r11733 r11837 1757 1757 service->setData(reinterpret_cast<void*>(&fToDim), name.size()+1+sizeof(uint32_t)); 1758 1758 service->setQuality(0); 1759 service-> updateService();1759 service->Update(); 1760 1760 } 1761 1761 // -------------------------------------------------------------------------- … … 1862 1862 NotifyOpenedFile(baseFileName, 7, fOpenedNightlyFiles); 1863 1863 if (fNumSubAndFitsIsOn) 1864 fNumSubAndFits-> updateService();1864 fNumSubAndFits->Update(); 1865 1865 } 1866 1866 //do the actual file open … … 1930 1930 1931 1931 if (fNumSubAndFitsIsOn) 1932 fNumSubAndFits-> updateService();1932 fNumSubAndFits->Update(); 1933 1933 } 1934 1934 } … … 2219 2219 NotifyOpenedFile("", 0, fOpenedRunFiles); 2220 2220 if (fNumSubAndFitsIsOn) 2221 fNumSubAndFits-> updateService();2221 fNumSubAndFits->Update(); 2222 2222 2223 2223 while (fRunNumber.size() > 0) … … 2264 2264 NotifyOpenedFile("", 0, fOpenedNightlyFiles); 2265 2265 if (fNumSubAndFitsIsOn) 2266 fNumSubAndFits-> updateService();2266 fNumSubAndFits->Update(); 2267 2267 } 2268 2268 #ifdef HAVE_FITS -
trunk/FACT++/src/drivectrl.cc
r11578 r11837 535 535 void Update(DimDescribedService &svc, const Time &t, const array<double, N> &arr) const 536 536 { 537 svc.setTimestamp(int(t.UnixTime()), t.ms()); 538 svc.setData(const_cast<double*>(arr.data()), arr.size()*sizeof(double)); 539 svc.updateService(); 537 svc.setData(arr); 538 svc.Update(t); 540 539 } 541 540
Note:
See TracChangeset
for help on using the changeset viewer.