Changeset 1759
- Timestamp:
- 02/14/03 23:21:35 (22 years ago)
- Location:
- trunk/MagicSoft/Cosy
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Cosy/Changelog
r1758 r1759 49 49 - don't use second SE when only one is attached 50 50 - added SE Test stuff 51 52 * base/BaseLinkDef.h, base/Makefile: 53 - added MParContainer 54 - added MObservatory 55 56 * base/timer.[h,cc]: 57 - changed the calculation of the date according to slalib 51 58 52 59 -
trunk/MagicSoft/Cosy/base/BaseLinkDef.h
r1691 r1759 9 9 #pragma link C++ class MStar+; 10 10 #pragma link C++ class MGList+; 11 #pragma link C++ class MParContainer+; 12 #pragma link C++ class MObservatory+; 11 13 12 14 #endif -
trunk/MagicSoft/Cosy/base/Makefile
r1691 r1759 33 33 SRCFILES = File.cc \ 34 34 MStopwatch.cc \ 35 MParContainer.cc \ 35 36 MThread.cc \ 36 37 MTimeout.cc \ … … 40 41 MLog.cc \ 41 42 MLogManip.cc \ 43 MObservatory.cc \ 42 44 MGList.cc \ 43 45 timer.cc … … 46 48 MGList.h \ 47 49 MLog.h \ 48 MLogManip.h 50 MLogManip.h \ 51 MObservatory.h \ 52 MParContainer.h 49 53 50 54 SRCS = $(SRCFILES) -
trunk/MagicSoft/Cosy/base/timer.cc
r926 r1759 4 4 #include <iostream.h> 5 5 6 #include "math.h"// modf6 #include <math.h> // modf 7 7 #include "sys/time.h" // struct timeval 8 8 #include "slalib/slalib.h" // slacldj … … 22 22 tv_sec /= 24; 23 23 24 fDay = tv_sec%365; 25 tv_sec /= 365; 24 Set(tv_sec + 40587); 26 25 27 fYea = tv_sec+1970; 26 fDiv = fmod((fMs+fSecs)/(60*60*24), 1.0); 27 } 28 28 29 fDay -= (fYea-1972)/4; 29 void Timer::Set(const long mjd) 30 { 31 // 32 // Express day in Gregorian calendar 33 // (taken from slalib slaDjcl) 34 // 35 fMjd = mjd; 30 36 31 int days = fDay; 37 const long jd = mjd + 2400001; 38 const long n4 = (((((jd*4-17918)/146097)*6)/4+1)/2+jd-37)*4; 39 const long nd10 = (((n4-237)%1461)/4)*10+5; 32 40 33 fMon=0; 34 do fDay -= fDays[fMon++]; 35 while (fDay>0); 36 37 int i=1; 38 while (i<fMon) 39 days -= fDays[i++]; 40 41 fDay = days; 42 43 double dummy; 44 fDiv = modf((fMs+fSecs)/(60*60*24), &dummy); 41 fYea = n4/1461 - 4712; 42 fMon = ((nd10/306+2)%12) + 1; 43 fDay = (nd10%306)/10 + 1; 45 44 } 46 45 … … 73 72 fMon = t.fMon; 74 73 fYea = t.fYea; 74 fMjd = t.fMjd; 75 } 76 77 void Timer::SetMjd(double mjd) 78 { 79 Set((long)mjd); 80 81 fDiv = fmod(mjd, 1.0); 82 83 mjd -= 40587; 84 85 mjd *= 24; 86 fHor = (int)mjd; 87 88 mjd *= 60; 89 fMin = (int)mjd; 90 91 mjd *= 60; 92 fSec = (int)mjd; 93 94 fMs = mjd * 1000; 75 95 } 76 96 … … 83 103 84 104 return fMs+fSecs; 85 }86 87 double Timer::CalcMjd()88 {89 int status;90 double mjd=0;91 slaCldj(fYea, fMon, fDay, &mjd, &status);92 93 if (status)94 cout << "Warning: slaCldj returned " << status << endl;95 96 return mjd + fDiv;97 105 } 98 106 … … 115 123 } 116 124 117 const int Timer::fDays[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; -
trunk/MagicSoft/Cosy/base/timer.h
r1531 r1759 7 7 { 8 8 private: 9 const static int fDays[12];10 9 double fMs; 11 10 double fDiv; 11 12 12 int fSec; 13 13 int fSecs; … … 18 18 int fYea; 19 19 20 double fMjd; 21 20 22 char fDateStr[30]; 21 23 24 void Set(const long mjd); 25 22 26 public: 23 Timer() : fMs(0), fSec(0), fSecs(0), fMin(0), fHor(0), fDay(0), fMon(0), fYea(0) {}27 Timer() : fMs(0), fSec(0), fSecs(0), fMin(0), fHor(0), fDay(0), fMon(0), fYea(0), fMjd(0) {} 24 28 Timer(double t); 25 29 Timer(struct timeval *tv); … … 30 34 31 35 int GetSecs() { return fSecs; } 36 32 37 double Now(); //[s] 33 double CalcMjd(); 38 double GetMjd() const { return fMjd+fDiv; } 39 40 virtual void SetMjd(double mjd); 34 41 35 42 int Day() const { return fDay; }
Note:
See TracChangeset
for help on using the changeset viewer.