|
| 1 | +#include "hirs.h" |
| 2 | +/* |
| 3 | +virtual void YourPlotMagnifier::rescale(double factor) |
| 4 | +{ |
| 5 | + QwtPlotMagnifier::rescale(factor); |
| 6 | +
|
| 7 | + emit Magnified(); |
| 8 | +}*/ |
| 9 | + |
| 10 | +/*viod HIRS::HIRSPlotsZoomed() |
| 11 | + { |
| 12 | + Parent->ui->HIRSRawPlot->setAxisAutoScale( QwtPlot::yLeft ); |
| 13 | + Parent->ui->HIRSElemPlot->setAxisAutoScale( QwtPlot::yLeft ); |
| 14 | + Parent->ui->HIRSScanPosPlot->setAxisAutoScale( QwtPlot::yLeft ); |
| 15 | + }*/ |
| 16 | + |
| 17 | +HIRS::HIRS(MainWindow *aParent) |
| 18 | + { |
| 19 | + Parent = aParent; |
| 20 | + |
| 21 | + (void )new QwtPlotPanner( Parent->ui->HIRSScanPosPlot->canvas() ); |
| 22 | + QwtPlotMagnifier *zoom_x2 = new QwtPlotMagnifier( Parent->ui->HIRSScanPosPlot->canvas() ); |
| 23 | + QwtPlotMagnifier *zoom_y2 = new QwtPlotMagnifier( Parent->ui->HIRSScanPosPlot->canvas() ); |
| 24 | + zoom_x2->setWheelModifiers(Qt::ControlModifier); |
| 25 | + zoom_x2->setAxisEnabled(Qt::XAxis, true); |
| 26 | + zoom_x2->setAxisEnabled(Qt::YAxis,false); |
| 27 | + |
| 28 | + zoom_y2->setAxisEnabled(Qt::XAxis,false); |
| 29 | + zoom_y2->setAxisEnabled(Qt::YAxis,true); |
| 30 | + |
| 31 | + (void )new QwtPlotPanner( Parent->ui->HIRSElemPlot->canvas() ); |
| 32 | + QwtPlotMagnifier *zoom_x3 = new QwtPlotMagnifier( Parent->ui->HIRSElemPlot->canvas() ); |
| 33 | + QwtPlotMagnifier *zoom_y3 = new QwtPlotMagnifier( Parent->ui->HIRSElemPlot->canvas() ); |
| 34 | + zoom_x3->setWheelModifiers(Qt::ControlModifier); |
| 35 | + zoom_x3->setAxisEnabled(Qt::XAxis, true); |
| 36 | + zoom_x3->setAxisEnabled(Qt::YAxis,false); |
| 37 | + |
| 38 | + zoom_y3->setAxisEnabled(Qt::XAxis,false); |
| 39 | + zoom_y3->setAxisEnabled(Qt::YAxis,true); |
| 40 | + |
| 41 | + (void )new QwtPlotPanner( Parent->ui->HIRSRawPlot->canvas() ); |
| 42 | + QwtPlotMagnifier *zoom_x = new QwtPlotMagnifier( Parent->ui->HIRSRawPlot->canvas() ); |
| 43 | + QwtPlotMagnifier *zoom_y = new QwtPlotMagnifier( Parent->ui->HIRSRawPlot->canvas() ); |
| 44 | + zoom_x->setWheelModifiers(Qt::ControlModifier); |
| 45 | + zoom_x->setAxisEnabled(Qt::XAxis, true); |
| 46 | + zoom_x->setAxisEnabled(Qt::YAxis,false); |
| 47 | + |
| 48 | + zoom_y->setAxisEnabled(Qt::XAxis,false); |
| 49 | + zoom_y->setAxisEnabled(Qt::YAxis,true); |
| 50 | + } |
| 51 | + |
| 52 | +void HIRS::processHIRS() |
| 53 | + { |
| 54 | + plotHIRSMirrorScanPos(); |
| 55 | + plotHIRSElements(); |
| 56 | + for(int i=2; i < HIRS_WORDS_PER_FRAME; i++) |
| 57 | + plotHIRSElement(i); |
| 58 | + } |
| 59 | + |
| 60 | +void HIRS::plotHIRSElements() |
| 61 | + { |
| 62 | + QwtPlotCurve *curve1 = new QwtPlotCurve("Element Number"); |
| 63 | + QwtSymbol *marker = new QwtSymbol; |
| 64 | + double *xPoints1, *yPoints1; |
| 65 | + |
| 66 | + QwtPlotCurve *curve2 = new QwtPlotCurve("Period Monitor"); |
| 67 | + QwtSymbol *marker2 = new QwtSymbol; |
| 68 | + double *xPoints2, *yPoints2; |
| 69 | + |
| 70 | + xPoints1 = new double[HIRSstream[1].length()]; |
| 71 | + yPoints1 = new double[HIRSstream[1].length()]; |
| 72 | + |
| 73 | + //for(int frame=0, igood=0, ibad=0; frame < numFrames; frame++) |
| 74 | + for(int point=0; point < HIRSstream[1].length(); point++) |
| 75 | + { |
| 76 | + yPoints1[point] = (HIRSstream[1][point] >> 1) & 63; |
| 77 | + xPoints1[point] = HIRSTime[1][point]; |
| 78 | + } |
| 79 | + |
| 80 | + curve1->setRenderHint(QwtPlotItem::RenderAntialiased, true); |
| 81 | + curve1->setRawSamples(&xPoints1[1], &yPoints1[1], HIRSstream[1].length()); |
| 82 | + curve1->setPen( QColor( "blue" ) ); |
| 83 | + |
| 84 | + marker->setStyle(QwtSymbol::Ellipse); |
| 85 | + marker->setSize(4); |
| 86 | + marker->setColor(QColor( "purple" )); |
| 87 | + marker->setPen(QColor( "cyan" )); |
| 88 | + curve1->setStyle( QwtPlotCurve::NoCurve ); |
| 89 | + curve1->setSymbol(marker); |
| 90 | + |
| 91 | + curve1->attach(Parent->ui->HIRSElemPlot); |
| 92 | + |
| 93 | + xPoints2 = new double[HIRSstream[1].length()]; |
| 94 | + yPoints2 = new double[HIRSstream[1].length()]; |
| 95 | + |
| 96 | + for(int point=0; point < HIRSstream[1].length(); point++) |
| 97 | + { |
| 98 | + yPoints2[point] = HIRSstream[1][point] >> 7; |
| 99 | + xPoints2[point] = HIRSTime[1][point]; |
| 100 | + } |
| 101 | + |
| 102 | + curve2->setRenderHint(QwtPlotItem::RenderAntialiased, true); |
| 103 | + curve2->setRawSamples(&xPoints2[0], &yPoints2[0], HIRSstream[1].length()); |
| 104 | + curve2->setPen( QColor( "orange" ) ); |
| 105 | + |
| 106 | + marker2->setStyle(QwtSymbol::Ellipse); |
| 107 | + marker2->setSize(4); |
| 108 | + marker2->setColor(QColor( "purple" )); |
| 109 | + marker2->setPen(QColor( "orange" )); |
| 110 | + curve2->setStyle( QwtPlotCurve::NoCurve ); |
| 111 | + curve2->setSymbol(marker2); |
| 112 | + |
| 113 | + curve2->attach(Parent->ui->HIRSElemPlot); |
| 114 | + |
| 115 | + Parent->ui->HIRSElemPlot->autoFillBackground(); |
| 116 | + |
| 117 | + // finally, refresh the plot |
| 118 | + Parent->ui->HIRSElemPlot->axisScaleEngine(QwtPlot::xBottom)->setAttribute(QwtScaleEngine::Floating,true); |
| 119 | + Parent->ui->HIRSElemPlot->axisScaleEngine(QwtPlot::yLeft)->setAttribute(QwtScaleEngine::Floating,true); |
| 120 | + Parent->ui->HIRSElemPlot->replot(); |
| 121 | + Parent->ui->HIRSElemPlot->show(); |
| 122 | + } |
| 123 | + |
| 124 | +void HIRS::plotHIRSMirrorScanPos() |
| 125 | + { |
| 126 | + QwtPlotCurve *curve1 = new QwtPlotCurve("all HIRS"); |
| 127 | + QwtSymbol *marker = new QwtSymbol; |
| 128 | + double *xPoints1, *yPoints1; |
| 129 | + |
| 130 | + QwtPlotCurve *curve2 = new QwtPlotCurve("Cal Level Indicator"); |
| 131 | + QwtSymbol *marker2 = new QwtSymbol; |
| 132 | + double *xPoints2, *yPoints2; |
| 133 | + |
| 134 | + xPoints1 = new double[HIRSstream[0].length()]; |
| 135 | + yPoints1 = new double[HIRSstream[0].length()]; |
| 136 | + |
| 137 | + //for(int frame=0, igood=0, ibad=0; frame < numFrames; frame++) |
| 138 | + for(int point=0; point < HIRSstream[0].length(); point++) |
| 139 | + { |
| 140 | + yPoints1[point] = HIRSstream[0][point] >> 5; //bitshift(uint16(HIRSwords(:,1)),-5) |
| 141 | + xPoints1[point] = HIRSTime[0][point]; |
| 142 | + } |
| 143 | + |
| 144 | + curve1->setRenderHint(QwtPlotItem::RenderAntialiased, true); |
| 145 | + curve1->setRawSamples(&xPoints1[0], &yPoints1[0], HIRSstream[0].length()); |
| 146 | + curve1->setPen( QColor( "blue" ) ); |
| 147 | + |
| 148 | + marker->setStyle(QwtSymbol::Ellipse); |
| 149 | + marker->setSize(4); |
| 150 | + marker->setColor(QColor( "purple" )); |
| 151 | + marker->setPen(QColor( "cyan" )); |
| 152 | + curve1->setStyle( QwtPlotCurve::NoCurve ); |
| 153 | + curve1->setSymbol(marker); |
| 154 | + |
| 155 | + curve1->attach(Parent->ui->HIRSScanPosPlot); |
| 156 | + |
| 157 | + xPoints2 = new double[HIRSstream[0].length()]; |
| 158 | + yPoints2 = new double[HIRSstream[0].length()]; |
| 159 | + |
| 160 | + //for(int frame=0, igood=0, ibad=0; frame < numFrames; frame++) |
| 161 | + for(int point=0; point < HIRSstream[0].length(); point++) |
| 162 | + { |
| 163 | + yPoints2[point] = HIRSstream[0][point] & 0x1F; |
| 164 | + xPoints2[point] = HIRSTime[0][point]; |
| 165 | + } |
| 166 | + |
| 167 | + curve2->setRenderHint(QwtPlotItem::RenderAntialiased, true); |
| 168 | + curve2->setRawSamples(&xPoints2[0], &yPoints2[0], HIRSstream[0].length()); |
| 169 | + curve2->setPen( QColor( "orange" ) ); |
| 170 | + |
| 171 | + marker2->setStyle(QwtSymbol::Ellipse); |
| 172 | + marker2->setSize(4); |
| 173 | + marker2->setColor(QColor( "purple" )); |
| 174 | + marker2->setPen(QColor( "orange" )); |
| 175 | + curve2->setStyle( QwtPlotCurve::NoCurve ); |
| 176 | + curve2->setSymbol(marker2); |
| 177 | + |
| 178 | + curve2->attach(Parent->ui->HIRSScanPosPlot); |
| 179 | + |
| 180 | + Parent->ui->HIRSScanPosPlot->autoFillBackground(); |
| 181 | + |
| 182 | + // finally, refresh the plot |
| 183 | + Parent->ui->HIRSScanPosPlot->axisScaleEngine(QwtPlot::xBottom)->setAttribute(QwtScaleEngine::Floating,true);; |
| 184 | + Parent->ui->HIRSScanPosPlot->axisScaleEngine(QwtPlot::yLeft)->setAttribute(QwtScaleEngine::Floating,true);; |
| 185 | + Parent->ui->HIRSScanPosPlot->replot(); |
| 186 | + Parent->ui->HIRSScanPosPlot->show(); |
| 187 | + } |
| 188 | + |
| 189 | +void HIRS::plotHIRSElement(int identToPlot) |
| 190 | + { |
| 191 | + QwtPlotCurve *curve1 = new QwtPlotCurve("Raw Filter Data"); |
| 192 | + |
| 193 | + double *xPoints1, *yPoints1; |
| 194 | + |
| 195 | + |
| 196 | + xPoints1 = new double[HIRSstream[identToPlot].length()]; |
| 197 | + yPoints1 = new double[HIRSstream[identToPlot].length()]; |
| 198 | + |
| 199 | + //for(int frame=0, igood=0, ibad=0; frame < numFrames; frame++) |
| 200 | + for(int point=0; point < HIRSstream[identToPlot].length(); point++) |
| 201 | + { |
| 202 | + yPoints1[point] = HIRSstream[identToPlot][point]; |
| 203 | + xPoints1[point] = HIRSTime[identToPlot][point]; |
| 204 | + } |
| 205 | + |
| 206 | + curve1->setRenderHint(QwtPlotItem::RenderAntialiased, true); |
| 207 | + curve1->setRawSamples(&xPoints1[0], &yPoints1[0], HIRSstream[identToPlot].length()); |
| 208 | + |
| 209 | + curve1->setPen( QColor( "red" ).darker(identToPlot*10+50) ); |
| 210 | + |
| 211 | + curve1->attach(Parent->ui->HIRSRawPlot); |
| 212 | + |
| 213 | + Parent->ui->HIRSRawPlot->autoFillBackground(); |
| 214 | + |
| 215 | + // finally, refresh the plot |
| 216 | + Parent->ui->HIRSRawPlot->axisScaleEngine(QwtPlot::xBottom)->setAttribute(QwtScaleEngine::Floating,true);; |
| 217 | + Parent->ui->HIRSRawPlot->axisScaleEngine(QwtPlot::yLeft)->setAttribute(QwtScaleEngine::Floating,true);; |
| 218 | + Parent->ui->HIRSRawPlot->replot(); |
| 219 | + Parent->ui->HIRSRawPlot->show(); |
| 220 | + } |
| 221 | + |
| 222 | +void HIRS::clearAll() |
| 223 | + { |
| 224 | + for(int i=0; i < HIRS_WORDS_PER_FRAME; i++) |
| 225 | + { |
| 226 | + HIRSstream[i].clear(); |
| 227 | + HIRSTime[i].clear(); |
| 228 | + } |
| 229 | + //frameQualityList.clear; //we do need this because we need to know if we can trust the contrast/brightness calc for individual pixels |
| 230 | + } |
| 231 | + |
| 232 | +void HIRS::addHIRSFrame(uchar *HIRSBytes, float *frameTime, uchar *frameChunkQuality) |
| 233 | + { |
| 234 | + //When we get passed a frame, we need to dissect it into the HIRS_BYTES_PER_FRAME parts, we need |
| 235 | + //to assign a quality based on 5 chunks to each part (giving each byte a quality based on the |
| 236 | + //larger chunk will just make our life easier later becacuse we will soon lose sight of where |
| 237 | + //each byte came from as this is an independant subcommutated stream. The same goes for time, |
| 238 | + //we need to interpolate through to assign each byte a time. |
| 239 | + |
| 240 | + //Assume MSB first, LSBs second like this (i<<8 + (i+1)) |
| 241 | + QString windowContents, hexStr; |
| 242 | + uint32_t HIRSword; |
| 243 | + uchar offset = 0; |
| 244 | + //uchar k=0; |
| 245 | + //i=> the HIRS word number (0-22) |
| 246 | + //j=> The HIRS byte number used to index the uchar array |
| 247 | + |
| 248 | + hexStr.sprintf("%04.2f\t",frameTime[0]); |
| 249 | + windowContents.append(hexStr); |
| 250 | + |
| 251 | + for(int i=0; i < HIRS_WORDS_PER_FRAME; i++) |
| 252 | + { |
| 253 | + HIRSword = 0; |
| 254 | + //k=0; |
| 255 | + for(int j=((i*13)/8); j <= (((i+1)*13)/8); j++) |
| 256 | + { |
| 257 | + HIRSword = HIRSword << 8; |
| 258 | + HIRSword |= HIRSBytes[j]; |
| 259 | + //HIRSword |= uint32_t(HIRSBytes[j]) << (8*k); |
| 260 | + //k++; |
| 261 | + } |
| 262 | + offset = 8 - ((13*(i+1)) % 8); //mod tells us how many bits into the last byte we ARE using, and we want to shift out the bits that we AREN'T using, so we substract it from 8 |
| 263 | + HIRSword = HIRSword >> offset; //shift out the bits not used (they're the MSB of the next word) |
| 264 | + HIRSword &= 0x1FFF; //finally mask out only the 13 wanted bits to remove LSB's of the previous word |
| 265 | + |
| 266 | + if( i>1 && (HIRSword >> 12 == 0)) //sign bit is 0, means negative number |
| 267 | + HIRSstream[i].append(-(HIRSword & 0xFFF)); |
| 268 | + else if( i>1 && (HIRSword >> 12 == 1)) //sign bit is 1, means positive number |
| 269 | + HIRSstream[i].append((HIRSword & 0xFFF)); |
| 270 | + else //unsigned element |
| 271 | + HIRSstream[i].append(HIRSword); |
| 272 | + |
| 273 | + HIRSTime[i].append(frameTime[(i*13)/8]); //use time of whichever byte the first bit was in |
| 274 | + |
| 275 | + hexStr.sprintf("%04X:%04X\t",HIRSword,HIRSstream[i].last()&0x1FFF); |
| 276 | + windowContents.append(hexStr); |
| 277 | + } |
| 278 | + Parent->ui->HIRSRawHex->appendPlainText(windowContents); |
| 279 | + //frameIDList.append(frameID); |
| 280 | + //frameQualityList.append(frameGood); |
| 281 | + //frameTimeList.append(frameTime); |
| 282 | + //22 words with 2 left over status bits (23 words) |
| 283 | + } |
| 284 | + |
| 285 | + |
| 286 | + |
| 287 | + |
0 commit comments