void GlassWidget::processReadyReadStandardOutputData() { char data[1500]; int n=0; if((n=gw_process->read(data,1500))>0) { data[n]=0; for(int i=0; i<n; i++) { switch(0xFF&data[i]) { case 13: break; case 10: ProcessFeedback(gw_process_accum); gw_process_accum=""; break; default: gw_process_accum+=data[i]; } } } }
/*----------------------------------------------------------------------------------------------*/ void Correlator::DumpAccum(Correlator_State_S *s, Correlation_S *c, NCO_Command_S *f, int32_t _chan) { double f1, f2, fix, ang; double sang, cang, tI, tQ; double code_phase; int32_t bin, offset, lcv, bread; /* First rotate correlation based on nco frequency and actually frequency used for correlation */ f1 = ((s->sbin - CARRIER_BINS) * CARRIER_SPACING) + IF_FREQUENCY; f2 = s->carrier_nco; fix = (double)PI*(f2-f1)*(double)s->scount*INVERSE_SAMPLE_FREQUENCY; ang = s->carrier_phase_prev*(double)TWO_PI + fix; ang = -ang; cang = cos(ang); sang = sin(ang); s->carrier_phase_prev = s->carrier_phase_mod; tI = c->I[0]; tQ = c->Q[0]; c->I[0] = (int32_t)floor(cang*tI - sang*tQ); c->Q[0] = (int32_t)floor(sang*tI + cang*tQ); tI = c->I[1]; tQ = c->Q[1]; c->I[1] = (int32_t)floor(cang*tI - sang*tQ); c->Q[1] = (int32_t)floor(sang*tI + cang*tQ); tI = c->I[2]; tQ = c->Q[2]; c->I[2] = (int32_t)floor(cang*tI - sang*tQ); c->Q[2] = (int32_t)floor(sang*tI + cang*tQ); /* Get the f */ pChannels[_chan]->Lock(); pChannels[_chan]->Accum(c, f); pChannels[_chan]->Unlock(); /* Apply f */ ProcessFeedback(s, f); /* Is this needed? */ s->count++; /* Now clear out accumulation */ c->I[0] = c->I[1] = c->I[2] = 0; c->Q[0] = c->Q[1] = c->Q[2] = 0; /* Calculate when next rollover occurs (in samples) */ s->rollover = (int32_t) ceil(((double)CODE_CHIPS - s->code_phase_mod)*SAMPLE_FREQUENCY/s->code_nco); bin = (int32_t) floor((s->code_phase_mod + 0.5)*CODE_BINS + 0.5) + CODE_BINS/2; if(bin < 0) bin = 0; if(bin > 2*CODE_BINS) bin = 2*CODE_BINS; s->pcode[0] = s->code_rows[bin]; s->cbin[0] = bin; bin = (int32_t) floor((s->code_phase_mod + 0.0)*CODE_BINS + 0.5) + CODE_BINS/2; if(bin < 0) bin = 0; if(bin > 2*CODE_BINS) bin = 2*CODE_BINS; s->pcode[1] = s->code_rows[bin]; s->cbin[1] = bin; bin = (int32_t) floor((s->code_phase_mod - 0.5)*CODE_BINS + 0.5) + CODE_BINS/2; if(bin < 0) bin = 0; if(bin > 2*CODE_BINS) bin = 2*CODE_BINS; s->pcode[2] = s->code_rows[bin]; s->cbin[2] = bin; /* Update pointer to pre-sampled sine vector */ bin = (int32_t) floor((s->carrier_nco - IF_FREQUENCY)/CARRIER_SPACING + 0.5) + CARRIER_BINS; /* Catch errors if Doppler goes out of range */ if(bin < 0) bin = 0; if(bin > 2*CARRIER_BINS) bin = 2*CARRIER_BINS; s->psine = main_sine_rows[bin]; s->sbin = bin; /* Remember to nuke this! */ s->scount = 0; }