| 1 | // timetoiproducer.cc | 
|---|
| 2 | // Eric Aubourg         CEA/DAPNIA/SPP   septembre 1999 | 
|---|
| 3 |  | 
|---|
| 4 | #include "timetoiproducer.h" | 
|---|
| 5 | #include "archparam.h" | 
|---|
| 6 | #include "archexc.h" | 
|---|
| 7 | #include "requesthandler.h" | 
|---|
| 8 |  | 
|---|
| 9 | #define sn "sampleNum" | 
|---|
| 10 | #define mjd "MJD" | 
|---|
| 11 | #define utc "UTC" | 
|---|
| 12 |  | 
|---|
| 13 |  | 
|---|
| 14 | TimeTOIProducer::TimeTOIProducer() | 
|---|
| 15 | { | 
|---|
| 16 | possibleTOIs.insert(TOI(sn,  TOI::unspec, "", "integer")); | 
|---|
| 17 | possibleTOIs.insert(TOI(mjd, TOI::unspec, "", "days")); | 
|---|
| 18 | possibleTOIs.insert(TOI(utc, TOI::unspec, "", "hours")); | 
|---|
| 19 | } | 
|---|
| 20 |  | 
|---|
| 21 | string TimeTOIProducer::getName() { | 
|---|
| 22 | return("TimeTOIProducer 1.0"); | 
|---|
| 23 | } | 
|---|
| 24 |  | 
|---|
| 25 |  | 
|---|
| 26 |  | 
|---|
| 27 | long TimeTOIProducer::firstSampleNum(TOI const& toi) { | 
|---|
| 28 | CHKPROD | 
|---|
| 29 | return -99999999; | 
|---|
| 30 | } | 
|---|
| 31 |  | 
|---|
| 32 | long TimeTOIProducer::lastSampleNum(TOI const& toi) { | 
|---|
| 33 | CHKPROD | 
|---|
| 34 | return  99999999; | 
|---|
| 35 | } | 
|---|
| 36 |  | 
|---|
| 37 | bool TimeTOIProducer::canGetValue(long /*sampleNum*/, TOI const& toi) { | 
|---|
| 38 | CHKPROD | 
|---|
| 39 | return true; | 
|---|
| 40 | } | 
|---|
| 41 |  | 
|---|
| 42 | bool TimeTOIProducer::canGetValueLater(long /*sampleNum*/, TOI const& toi) { | 
|---|
| 43 | CHKPROD | 
|---|
| 44 | return false; // we can always get value NOW | 
|---|
| 45 | } | 
|---|
| 46 |  | 
|---|
| 47 | bool TimeTOIProducer::canGetPrevValue(long /*sampleNum*/, TOI const& toi) { | 
|---|
| 48 | CHKPROD | 
|---|
| 49 | return true; | 
|---|
| 50 | } | 
|---|
| 51 |  | 
|---|
| 52 | bool TimeTOIProducer::canGetNextValue(long /*sampleNum*/, TOI const& toi) { | 
|---|
| 53 | CHKPROD | 
|---|
| 54 | return true; | 
|---|
| 55 | } | 
|---|
| 56 |  | 
|---|
| 57 | double TimeTOIProducer::getValue(long sampleNum, TOI const& toi) { | 
|---|
| 58 | CHKPROD | 
|---|
| 59 | if (toi.name == sn) return sampleNum; | 
|---|
| 60 | if (toi.name == mjd) return archParam.acq.SN2MJD(sampleNum); | 
|---|
| 61 | if (toi.name == utc) return archParam.acq.SN2UTC(sampleNum); | 
|---|
| 62 | throw ArchExc("TimeTOIProducer inconsistence " + toi.name); | 
|---|
| 63 | } | 
|---|
| 64 |  | 
|---|
| 65 | double TimeTOIProducer::getPrevValue(long& sampleNum, TOI const& toi) { | 
|---|
| 66 | sampleNum--; | 
|---|
| 67 | return getValue(sampleNum, toi); | 
|---|
| 68 | } | 
|---|
| 69 |  | 
|---|
| 70 | double TimeTOIProducer::getNextValue(long& sampleNum, TOI const& toi) { | 
|---|
| 71 | sampleNum++; | 
|---|
| 72 | return getValue(sampleNum, toi); | 
|---|
| 73 | } | 
|---|