차은영

receiver change

1 - constellation_main.cpp 1 +C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\Microsoft.Cpp.Platform.targets(57,5): error MSB8020: v142에 대한 빌드 도구(플랫폼 도구 집합 = 'v142')를 찾을 수 없습니다. v142 빌드 도구를 사용하여 빌드하려면 v142 빌드 도구를 설치하십시오. [프로젝트] 메뉴를 선택하거나 솔루션을 마우스 오른쪽 단추로 클릭한 다음 "솔루션 대상 변경"을 선택하여 현재 Visual Studio 도구로 업그레이드할 수도 있습니다.
2 - myMatrix.cpp
3 -c:\users\현우\desktop\0509_team2\constellation\constellation\mymatrix.cpp(29): warning C4101: 'temp' :참조되지 않은 지역 변수입니다.
4 - sender.cpp
5 -c:\users\현우\desktop\0509_team2\constellation\constellation\sender.cpp(7): error C2084: 'Csender::Csender(void)' 함수에 이미 본문이 있습니다.
6 - c:\users\현우\desktop\0509_team2\constellation\constellation\sender.h(7): note: '{ctor}'의 이전 정의를 참조하십시오.
7 -c:\users\현우\desktop\0509_team2\constellation\constellation\sender.cpp(8): warning C4552: '+': 의미 없는 연산자입니다. 파생 작업이 있는 연산자여야 합니다.
8 -c:\users\현우\desktop\0509_team2\constellation\constellation\sender.cpp(10): warning C4244: '=': 'int'에서 'float'(으)로 변환하면서 데이터가 손실될 수 있습니다.
9 -c:\users\현우\desktop\0509_team2\constellation\constellation\sender.cpp(15): error C2059: 구문 오류: ')'
10 -c:\users\현우\desktop\0509_team2\constellation\constellation\sender.cpp(15): error C2143: 구문 오류: ';'이(가) '{' 앞에 없습니다.
11 -c:\users\현우\desktop\0509_team2\constellation\constellation\sender.cpp(15): error C2447: '{': 함수 헤더가 없습니다. 이전 스타일의 형식 목록입니까?
12 - 코드를 생성하고 있습니다...
......
...@@ -111,7 +111,9 @@ ...@@ -111,7 +111,9 @@
111 </ItemDefinitionGroup> 111 </ItemDefinitionGroup>
112 <ItemGroup> 112 <ItemGroup>
113 <ClCompile Include="constellation_main.cpp" /> 113 <ClCompile Include="constellation_main.cpp" />
114 + <ClCompile Include="evaluate.cpp" />
114 <ClCompile Include="myMatrix.cpp" /> 115 <ClCompile Include="myMatrix.cpp" />
116 + <ClCompile Include="receiver.cpp" />
115 <ClCompile Include="sender.cpp"> 117 <ClCompile Include="sender.cpp">
116 <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader> 118 <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
117 </ClCompile> 119 </ClCompile>
......
...@@ -27,6 +27,12 @@ ...@@ -27,6 +27,12 @@
27 <ClCompile Include="channel.cpp"> 27 <ClCompile Include="channel.cpp">
28 <Filter>소스 파일</Filter> 28 <Filter>소스 파일</Filter>
29 </ClCompile> 29 </ClCompile>
30 + <ClCompile Include="receiver.cpp">
31 + <Filter>소스 파일</Filter>
32 + </ClCompile>
33 + <ClCompile Include="evaluate.cpp">
34 + <Filter>소스 파일</Filter>
35 + </ClCompile>
30 </ItemGroup> 36 </ItemGroup>
31 <ItemGroup> 37 <ItemGroup>
32 <ClInclude Include="sender.h"> 38 <ClInclude Include="sender.h">
......
1 +#include "evaluate.h"
2 +void Cevaluate::evaluate() {
3 + float errors = 0;
4 + for (int i = 0; i < Nbits; i++) if (Data[i] != DecodedData[i]) errors += 1;
5 + BER = errors / Nbits;
6 +}
...\ No newline at end of file ...\ No newline at end of file
...@@ -9,5 +9,6 @@ public: ...@@ -9,5 +9,6 @@ public:
9 char *DecodedData; // from the receiver 9 char *DecodedData; // from the receiver
10 char *Data; // from the sender 10 char *Data; // from the sender
11 void evaluate(); 11 void evaluate();
12 + float BER;
12 }; 13 };
13 #endif 14 #endif
......
...@@ -7,6 +7,11 @@ using namespace std; ...@@ -7,6 +7,11 @@ using namespace std;
7 7
8 8
9 Creceiver::Creceiver() { 9 Creceiver::Creceiver() {
10 +
11 +
12 +}
13 +void Creceiver::demodulate()
14 +{
10 float c0[20]; 15 float c0[20];
11 float c1[20]; 16 float c1[20];
12 for (float t = 0; t < Nsamplespersymbol; t++) 17 for (float t = 0; t < Nsamplespersymbol; t++)
...@@ -14,41 +19,43 @@ Creceiver::Creceiver() { ...@@ -14,41 +19,43 @@ Creceiver::Creceiver() {
14 c0[(int)t] = sqrt(2 * Nsamplespersymbol)*cos(2 * PI*Nsamplespersymbol*t); 19 c0[(int)t] = sqrt(2 * Nsamplespersymbol)*cos(2 * PI*Nsamplespersymbol*t);
15 c1[(int)t] = sqrt(2 * Nsamplespersymbol)*sin(2 * PI*Nsamplespersymbol*t); 20 c1[(int)t] = sqrt(2 * Nsamplespersymbol)*sin(2 * PI*Nsamplespersymbol*t);
16 } 21 }
17 - for (int i = 0; i < Nbits * 10; i = i + 20) // 22 +
23 + for (int i = 0; i < Nbits * 10; i = i + 20)
18 { 24 {
19 - float sum = 0; 25 + float sum_C0 = 0;
20 - float sum2 = 0; 26 + float sum_C1 = 0;
21 - for (int j = 0; j < 20; i++) 27 + for (int j = 0; j < 20; j++)
22 { 28 {
23 - sum = sum + (r[i + j] * c0[j]); 29 + sum_C0 = sum_C0 + (r[i + j] * c0[j]);
24 - sum2 = sum2 + (r[i + j] * c1[j]); 30 + sum_C1 = sum_C1 + (r[i + j] * c1[j]);
25 } 31 }
26 - constellation[i] = sum; 32 + constellation[i / 10] = sum_C0 / 383.;
27 - constellation[i + 1] = sum2; 33 + constellation[(i / 10) + 1] = sum_C1 / 415.;
28 } 34 }
29 -} 35 +
30 -float *r; // corrupted signal = received signal 36 + for (int i = 0; i < Nbits; i = i + 2)
31 -float constellation[Nbits];
32 -char DecodedData[Nbits];
33 -void Creceiver::demodulate()
34 -{
35 - float c0[20];
36 - float c1[20];
37 - for (float t = 0; t < Nsamplespersymbol; t++)
38 - {
39 - c0[(int)t] = sqrt(2 * Nsamplespersymbol)*cos(2 * PI*Nsamplespersymbol*t);
40 - c1[(int)t] = sqrt(2 * Nsamplespersymbol)*sin(2 * PI*Nsamplespersymbol*t);
41 - }
42 - for (int i = 0; i < Nbits * 10; i = i + 20) //
43 { 37 {
44 - float sum = 0; 38 + if (constellation[i] > 0 && constellation[i + 1] > 0)
45 - float sum2 = 0; 39 + {
46 - for (int j = 0; j < 20; i++) 40 + DecodedData[i] = 0;
41 + DecodedData[i + 1] = 0;
42 + }
43 + else if (constellation[i] < 0 && constellation[i + 1] > 0)
44 + {
45 + DecodedData[i] = 1;
46 + DecodedData[i + 1] = 0;
47 + }
48 +
49 + else if (constellation[i] < 0 && constellation[i + 1] < 0)
50 + {
51 + DecodedData[i] = 1;
52 + DecodedData[i + 1] = 1;
53 + }
54 +
55 + else if (constellation[i] > 0 && constellation[i + 1] < 0)
47 { 56 {
48 - sum = sum + (r[i + j] * c0[j]); 57 + DecodedData[i] = 0;
49 - sum2 = sum2 + (r[i + j] * c1[j]); 58 + DecodedData[i + 1] = 1;
50 } 59 }
51 - constellation[i] = sum;
52 - constellation[i + 1] = sum2;
53 } 60 }
54 }; 61 };
...\ No newline at end of file ...\ No newline at end of file
......