sender.h 1.23 KB
#ifndef __SENDER
#define __SENDER
#include <cmath>
#include "variables.h"

#include <iostream>
#include <cstdlib>
#include <ctime>
#include <fstream>


#define PI 3.141592

using namespace std;

class Csender 
{
private:


public:
	float c0;
	float c1;
	float T = 20;
	float t = 0;
	float A = 100;

	float b0[500];
	float b1[500];

	int sum = 0;
	
	float data[Nbits]; // 1000°³

	Csender() 
	{};

	



	float s[Nbits/Nbitspersymbol*Nsamplespersymbol]; // trasmitted signal

	void transmitData()
	{
		
		ofstream out("senderoutput.txt");

		srand((unsigned int)time(NULL));
		for (int i = 0; i < 1000; i++)
		{
			data[i] = rand() % 2;
			out << data[i] << endl;
		}


		for (int i = 0; i < 1000; i++)
		{
			if (data[i] == 0)
			{
				data[i] = 1;
			}
			else if (data[i] == 1)
			{
				data[i] = -1;
			}
		}


		for (int i = 0; i < 500; i++)
		{
			b0[i] = data[2 * i];
			b1[i] = data[(2 * i) + 1];

		}

		c0 = sqrt(2 / T) * cos(2 * PI / T * t);
		c1 = sqrt(2 / T) * sin(2 * PI / T * t);
		
		sum = 0;

		for (int i = 0; i < 500; i++)
		{
			for (t = 0; t < 20; t++)
			{
				s[sum] = A * ((b0[i] * sqrt(2 / T) * cos(2 * PI / T * t)) + b1[i] * sqrt(2 / T) * sin(2 * PI / T * t));
				sum++;
			}
		}

	

	}


	
	//1½Éº¼À» 20°³·Î ÂÉ°µ´Ù.

	
};




#endif