| [556] | 1 | // rotspeed.cc
 | 
|---|
 | 2 | // Eric Aubourg         CEA/DAPNIA/SPP   octobre 1999
 | 
|---|
 | 3 | 
 | 
|---|
 | 4 | #include "rotspeed.h"
 | 
|---|
 | 5 | #include "archexc.h"
 | 
|---|
 | 6 | #include "archparam.h"
 | 
|---|
 | 7 | #include "templocator.h"
 | 
|---|
 | 8 | 
 | 
|---|
 | 9 | #define rotSpeed        "rotSpeed"
 | 
|---|
 | 10 | 
 | 
|---|
 | 11 | 
 | 
|---|
 | 12 | RotSpeed::RotSpeed() {
 | 
|---|
 | 13 |   possibleTOIs.insert(TOI(rotSpeed,         TOI::unspec, "interp", "deg/s"));
 | 
|---|
 | 14 |   sn1 = sn2 = -1;
 | 
|---|
 | 15 | }
 | 
|---|
 | 16 | 
 | 
|---|
 | 17 | string RotSpeed::getName() {
 | 
|---|
 | 18 |   return("RotSpeed 1.0");
 | 
|---|
 | 19 | }
 | 
|---|
 | 20 | 
 | 
|---|
 | 21 | bool RotSpeed::canGetValue(long sampleNum, TOI const& toi) {
 | 
|---|
 | 22 |   map<TOI, TOIProducer*> & m = neededTOIs[toi];
 | 
|---|
 | 23 | 
 | 
|---|
 | 24 |   TOIProducer* azProd;
 | 
|---|
 | 25 |   TOI azTOI;
 | 
|---|
 | 26 |   
 | 
|---|
 | 27 |   if (sn1<0 || sn2<0 || sampleNum<sn1 || sampleNum >= sn2) {
 | 
|---|
 | 28 |           for (map<TOI, TOIProducer*>::iterator i = m.begin(); i != m.end(); i++) {
 | 
|---|
 | 29 |             TOI const& inToi = (*i).first;
 | 
|---|
 | 30 |             TOIProducer* prod =  (*i).second;
 | 
|---|
 | 31 |             
 | 
|---|
 | 32 |             if (inToi.name == "rotSpeedSample1")  {
 | 
|---|
 | 33 |               if (!prod->canGetValue(sampleNum, inToi)) return false;
 | 
|---|
 | 34 |               sn1 = (long) prod->getValue(sampleNum, inToi);
 | 
|---|
 | 35 |             }
 | 
|---|
 | 36 |             if (inToi.name == "rotSpeedSample2")  {
 | 
|---|
 | 37 |               if (!prod->canGetValue(sampleNum, inToi)) return false;
 | 
|---|
 | 38 |               sn2 = (long) prod->getValue(sampleNum, inToi);
 | 
|---|
 | 39 |             }
 | 
|---|
 | 40 |             if (inToi.name == "azimuthFPC")  {
 | 
|---|
 | 41 |               azProd = prod;
 | 
|---|
 | 42 |               azTOI = inToi;
 | 
|---|
 | 43 |             }
 | 
|---|
 | 44 |           }
 | 
|---|
 | 45 |   } else {
 | 
|---|
 | 46 |           for (map<TOI, TOIProducer*>::iterator i = m.begin(); i != m.end(); i++) {
 | 
|---|
 | 47 |             TOI const&  inToi = (*i).first;
 | 
|---|
 | 48 |             TOIProducer* prod =  (*i).second;
 | 
|---|
 | 49 |             if (inToi.name == "azimuthFPC")  {
 | 
|---|
 | 50 |               azProd = prod;
 | 
|---|
 | 51 |               azTOI = inToi;
 | 
|---|
 | 52 |             }
 | 
|---|
 | 53 |           }
 | 
|---|
 | 54 |   }
 | 
|---|
 | 55 |   
 | 
|---|
 | 56 |   if (!azProd->canGetValue(sn1, azTOI)) return false;
 | 
|---|
 | 57 |   if (!azProd->canGetValue(sn2, azTOI)) return false;
 | 
|---|
 | 58 |   
 | 
|---|
 | 59 |   return true;
 | 
|---|
 | 60 | }
 | 
|---|
 | 61 | 
 | 
|---|
 | 62 | bool RotSpeed::canGetValueLater(long sampleNum, TOI const& toi) {
 | 
|---|
 | 63 |   map<TOI, TOIProducer*> & m = neededTOIs[toi];
 | 
|---|
 | 64 | 
 | 
|---|
 | 65 |   TOIProducer* azProd;
 | 
|---|
 | 66 |   TOI azTOI;
 | 
|---|
 | 67 |   
 | 
|---|
 | 68 |   if (sn1<0 || sn2<0 || sampleNum<sn1 || sampleNum >= sn2) {
 | 
|---|
 | 69 |           for (map<TOI, TOIProducer*>::iterator i = m.begin(); i != m.end(); i++) {
 | 
|---|
 | 70 |             TOI const&  inToi = (*i).first;
 | 
|---|
 | 71 |             TOIProducer* prod =  (*i).second;
 | 
|---|
 | 72 |             
 | 
|---|
 | 73 |             if (inToi.name == "rotSpeedSample1")  {
 | 
|---|
 | 74 |               if (prod->canGetValueLater(sampleNum, inToi)) return true;
 | 
|---|
 | 75 |               sn1 = (long) prod->getValue(sampleNum, inToi);
 | 
|---|
 | 76 |             }
 | 
|---|
 | 77 |             if (inToi.name == "rotSpeedSample2")  {
 | 
|---|
 | 78 |               if (prod->canGetValueLater(sampleNum, inToi)) return true;
 | 
|---|
 | 79 |               sn2 = (long) prod->getValue(sampleNum, inToi);
 | 
|---|
 | 80 |             }
 | 
|---|
 | 81 |             if (inToi.name == "azimuthFPC")  {
 | 
|---|
 | 82 |               azProd = prod;
 | 
|---|
 | 83 |               azTOI = inToi;
 | 
|---|
 | 84 |             }
 | 
|---|
 | 85 |           }
 | 
|---|
 | 86 |   } else {
 | 
|---|
 | 87 |           for (map<TOI, TOIProducer*>::iterator i = m.begin(); i != m.end(); i++) {
 | 
|---|
 | 88 |             TOI const&  inToi = (*i).first;
 | 
|---|
 | 89 |             TOIProducer* prod =  (*i).second;
 | 
|---|
 | 90 |             if (inToi.name == "azimuthFPC")  {
 | 
|---|
 | 91 |               azProd = prod;
 | 
|---|
 | 92 |               azTOI = inToi;
 | 
|---|
 | 93 |             }
 | 
|---|
 | 94 |           }
 | 
|---|
 | 95 |   }
 | 
|---|
 | 96 |   
 | 
|---|
 | 97 |   if (azProd->canGetValueLater(sn1, azTOI)) return true;
 | 
|---|
 | 98 |   if (azProd->canGetValueLater(sn2, azTOI)) return true;
 | 
|---|
 | 99 |   
 | 
|---|
 | 100 |   return false;
 | 
|---|
 | 101 | }
 | 
|---|
 | 102 | 
 | 
|---|
 | 103 | 
 | 
|---|
 | 104 | 
 | 
|---|
 | 105 | double RotSpeed::getValue(long sampleNum, TOI const& toi) {
 | 
|---|
 | 106 |   if (!canGetValue(sampleNum, toi)) return -99999;
 | 
|---|
 | 107 | 
 | 
|---|
 | 108 |   map<TOI, TOIProducer*> &m = neededTOIs[toi];
 | 
|---|
 | 109 | 
 | 
|---|
 | 110 |   TOIProducer* azProd;
 | 
|---|
 | 111 |   TOI azTOI;
 | 
|---|
 | 112 |   
 | 
|---|
 | 113 |   if (sn1<0 || sn2<0 || sampleNum<sn1 || sampleNum >= sn2) {
 | 
|---|
 | 114 |           for (map<TOI, TOIProducer*>::iterator i = m.begin(); i != m.end(); i++) {
 | 
|---|
 | 115 |             TOI const& inToi = (*i).first;
 | 
|---|
 | 116 |             TOIProducer* prod =  (*i).second;
 | 
|---|
 | 117 |             
 | 
|---|
 | 118 |             if (inToi.name == "rotSpeedSample1")  {
 | 
|---|
 | 119 |               if (prod->canGetValueLater(sampleNum, inToi)) return true;
 | 
|---|
 | 120 |               sn1 = (long) prod->getValue(sampleNum, inToi);
 | 
|---|
 | 121 |             }
 | 
|---|
 | 122 |             if (inToi.name == "rotSpeedSample2")  {
 | 
|---|
 | 123 |               if (prod->canGetValueLater(sampleNum, inToi)) return true;
 | 
|---|
 | 124 |               sn2 = (long) prod->getValue(sampleNum, inToi);
 | 
|---|
 | 125 |             }
 | 
|---|
 | 126 |             if (inToi.name == "azimuthFPC")  {
 | 
|---|
 | 127 |               azProd = prod;
 | 
|---|
 | 128 |               azTOI = inToi;
 | 
|---|
 | 129 |             }
 | 
|---|
 | 130 |           }
 | 
|---|
 | 131 |   } else {
 | 
|---|
 | 132 |           for (map<TOI, TOIProducer*>::iterator i = m.begin(); i != m.end(); i++) {
 | 
|---|
 | 133 |             TOI const& inToi = (*i).first;
 | 
|---|
 | 134 |             TOIProducer* prod =  (*i).second;
 | 
|---|
 | 135 |             if (inToi.name == "azimuthFPC")  {
 | 
|---|
 | 136 |               azProd = prod;
 | 
|---|
 | 137 |               azTOI = inToi;
 | 
|---|
 | 138 |             }
 | 
|---|
 | 139 |           }
 | 
|---|
 | 140 |   }
 | 
|---|
 | 141 |   
 | 
|---|
 | 142 |   double az1 = azProd->getValue(sn1, azTOI);
 | 
|---|
 | 143 |   double az2 = azProd->getValue(sn2, azTOI);
 | 
|---|
 | 144 | 
 | 
|---|
 | 145 |   return (az1 - az2 + 360)/(sn2-sn1)/ archParam.acq.perEch;
 | 
|---|
 | 146 | }
 | 
|---|
 | 147 | 
 | 
|---|
 | 148 | 
 | 
|---|
 | 149 | set<TOI> RotSpeed::reqTOIFor(TOI const& toi) {
 | 
|---|
 | 150 |   set<string> opts = toi.options;
 | 
|---|
 | 151 |   set<TOI> t; 
 | 
|---|
 | 152 |   t.insert(TOI("rotSpeedSample1",  TOI::unspec, opts));
 | 
|---|
 | 153 |   t.insert(TOI("rotSpeedSample2",  TOI::unspec, opts));
 | 
|---|
 | 154 |   t.insert(TOI("azimuthFPC",       TOI::unspec, opts));
 | 
|---|
 | 155 |   return t;
 | 
|---|
 | 156 | }
 | 
|---|
 | 157 | 
 | 
|---|
 | 158 | 
 | 
|---|
 | 159 | 
 | 
|---|
 | 160 | 
 | 
|---|
 | 161 | 
 | 
|---|
 | 162 | 
 | 
|---|
 | 163 | 
 | 
|---|