예제 #1
0
/**
 * Create a time series of input data.
 *
 * Description:\n
 * 	Creates a time series of complex floats representing a signal at
 * 	a given frequency.
 */
ComplexFloat32 *
createTdData(float64_t fMHz, float64_t driftHz, int32_t samples,
		float64_t noise)
{
	size_t size = samples * sizeof(ComplexFloat32);
	ComplexFloat32 *td = static_cast<ComplexFloat32 *> (fftwf_malloc(size));
	float64_t dfMHz = fMHz - centerFreqMHz;
	float64_t widthMHz = subchannels * subchannelWidthMHz;
	Gaussian gen;
	// no noise, just signal
	gen.setup(0, widthMHz, noise);
	gen.addCwSignal(dfMHz, driftHz, 1);
	gen.getSamples(td, samples);
	return (td);
}
예제 #2
0
int
main(int argc, char **argv)
{
	parseArgs(argc, argv);

   if (beam)
      channel = 0;
	sndX = new MCSend(channel, mcPortX+channel, mcAddr);
	sndY = new MCSend(channel, mcPortY+channel, mcAddr);

	/**
	* initialize the sample generators
	*/
	genX.setup(seedX, bandwidth, power);
	genY.setup(seedY, bandwidth, power);
	/**
	* if we're writing to output, open the file
	*/
	if (packetFile.length())
		openFile(packetFile);

	if (beam) {
		pkt = new BeamPacket(source, channel);
		xPkt = new BeamPacket(source, channel);
		yPkt = new BeamPacket(source, channel);
		ATADataPacketHeader hdr = pkt->getHeader();
		complex<float> val(1, 1);
		for (uint32_t i = 0; i < hdr.len; ++i) {
			pkt->putSample(i, val);
			xPkt->putSample(i, val);
			yPkt->putSample(i, val);
		}
		/**
		* send packets with no valid bit to reset Channelizer
		*/
		createPackets(genX, genY, *xPkt, *yPkt);
		sendPackets(*xPkt, *yPkt);
	}
	else {
		pkt = new ChannelPacket(source, channel);
		xPkt = new ChannelPacket(source, channel);
		yPkt = new ChannelPacket(source, channel);
		ATADataPacketHeader hdr = pkt->getHeader();
		complex<float> val(1, 1);
		for (uint32_t i = 0; i < hdr.len; ++i) {
			pkt->putSample(i, val);
			xPkt->putSample(i, val);
			yPkt->putSample(i, val);
		}
	}

	//
	// set the valid flag for all remaining packets
	//
	data_valid = ATADataPacketHeader::DATA_VALID;

	//
	// add signals
	//
	for (PacketSigList::iterator p = signals.begin(); p != signals.end(); ++p) {
		PacketSig sig = *p;
		if (sig.tOff == 0.0)
		{
			if (sig.pol == ATADataPacketHeader::XLINEAR ||
					sig.pol ==  ATADataPacketHeader::BOTH )
						genX.addCwSignal(sig.freq, sig.drift, sig.snr);
			if (sig.pol == ATADataPacketHeader::YLINEAR ||
					sig.pol ==  ATADataPacketHeader::BOTH )
						genY.addCwSignal(sig.freq, sig.drift, sig.snr);
		}
		else
		{
			if (sig.pol == ATADataPacketHeader::XLINEAR ||
					sig.pol ==  ATADataPacketHeader::BOTH )
						genX.addPulseSignal(sig.freq, sig.drift, sig.snr,
							sig.tStart, sig.tOn, sig.tOff);
			if (sig.pol == ATADataPacketHeader::YLINEAR ||
					sig.pol ==  ATADataPacketHeader::BOTH )
						genY.addPulseSignal(sig.freq, sig.drift, sig.snr,
							sig.tStart, sig.tOn, sig.tOff);
		}
	}

	gettimeofday(&start, NULL);
	//
	// now create and send packets at an interval or
	// 	continuously
	//
	if (alarmInterval)
		frameAlarm.set(&alarmHandler, alarmInterval, alarmInterval);
	else
		fullThrottle();

	while (1)
		;
}