资源描述
ASP.NET课程设计报告设计题目:计算机通信年级四年级班级计科075班姓名刘风珍王盼盼李然学号200715155072007151550820071515523姓名刘冬晓张莹陈志杰学号200715155212007151552520071515506指导教师王建平起止时间2010-12-122010-12-172010-2011年第一学期1需求分析31.1 系统开发的目的和意义31.2 要解决的问题31.3能解决的问题31.4没有解决的问题41.5开发的难度42模块功能描述与设计实现: 42.1 模块的描述42.2非归零反相码的设计实现。52.3双极性信号交替反转码的设计实现72.4 双极性8零替换码的设计实现92.5曼彻斯特编码的设计实现202.6二进制振幅键控调制(2ASK)的设计实现242.7二相相对移相调制(2DPSK)的设计实现263开发小结273.1 未来扩充方向273.2其他待考虑因素274参考文献271需求分析1.1系统开发的目的和意义在Windows应用程序中,绘图是非常重要的操作。虽然我们可以用已经创建好的位 图来显示图形,但是许多情况下仍然希望应用程序能够对视图控件绘图,这要求了解 Windows的绘图机制。任何程序需要直接在屏幕或打印机上绘图时,都需要使用图形设备接口。图形设备 接口(Graphics Device Interface,GDI)是指这样一个可执行程序:他处理来自Windows 应用程序的图形函数调用,然后把这些调用传递给合适的设备驱动程序,由设备驱动程 序来执行与硬件相关的函数,并产生最后的输出结果。经常同图形设备接口相提并论的 另一个概念是设备上下文(D evice Con tex t,DC)。设备上下文是一种Windows数据结构, 它包括了于一个设备(如显示器或打印机)的绘制属性相关的信息。所有的绘制操作通 过一个设备上下文对象进行、,该对象封装了实现绘制线条、形状和文本的Windows API 函数。设备上下文可以用来向屏幕、打印机和图元文件输出结果。利用C#开发图形绘制内容的相关知识,了解.NET对于绘图功能所提供的支持,以及 相关的类运用,并且了解+GDI的绘图服务,一种专门提供在NET平台上绘制图形的绘图 应用程序接口,然后绘制各种图形,如线条、曲线或虚线等,另外还有画笔和画刷的应 用。Graphics是System.Drawing命名空间里一个很重要的核心绘图类,这个类提供各 种绘制图形以及文字的相关方法,GDI+不同于GDI,其本身导入面向对象设计模型,因 此使用GDI+与使用其他类并无不同,在学习GDI+前先了解如何使用Graphics类。本设计目的在于通过对图形设备接口的学习,能够绘制出基于计算机通信的数字数据 编码波形图和频带传输系统编码波形图。12要解决的问题(1) 数字编码波形生成器:单极性编码、极化编码、双极性编码的所有波形的设计。(2) 频带传输编码波形生成器:FSKASKPSK2DPSK所有波形的设计。(3) 图形的保存与输出。1.3能解决的问题我们能实现基带传输的二电平码、差分码、双极性信号交替反转码、8零替换码、 曼彻斯特编码、差分曼彻斯特编码、密勒码、双二进制码、多电平码以及频带传输的 2ASK/2PSK/2FSK/2DPSK波形图,能对文本框内的内容进行验证,只允许输入0或1, 并且图形能在网页上显示输出。1.4没有解决的问题帮助系统没有完善,图片画出不能自定义保存,双极性3零码没有实现,横坐标没有根 据输入数据流的长度而变化。1.5开发的难度图形编程需要频繁引用 System.Drawing、System.Drawing.Drawing2D、System.IO 名称 空间中的类型,在代码的开头需要添加它们。在C#图形开发中,Graphics类型是最重要的 类型,它表示一个画布对象,任何图形操作都是输出到这个画布上。这个类型提供了很多属 性和方法,可以设置某些图形输出质量,还提供了一系列的以Draw开头的方法来绘制图形, 以Fill开头的方法来填充图形。此外还提供方法和属性进行坐标转换。在开发自定义的控件 时,可以相应控件的Paint事件,也可以重写OnPaint方法。主要是掌握直线,曲线的绘制 方法。2.模块功能描述与设计实现:2.1模块的描述主要包含14个编码,分别是:二电平码、差分码、双极性信号交替反转码、8零替换 码、曼彻斯特编码、差分曼彻斯特编码、密勒码、双二进制码、多电平码以及频带传输的 2ASK/2PSK/2FSK/2DPSK。22非归零反相码的设计实现。采用这种码型时,如果传输一个比特的起始时刻电平发生了跳转,那么这个比特就表示 二进制的1;如果此刻电平没有发生跳转,那么这个比特就代表二进制的0。图2.1描述了 非归零反相码对数据流110001011010进行编码的情况。非归零反相码图2.1非归零反相码for (int i = 0; i str1length; i+)g.DrawLine(BluePen , new Point(x += 30, y - 50), new Point(x, y + 50);if (i = 0)ch = str1i;if (ch = 0)g.DrawString(0, smFont, myBrush, new Point(Linestart.X + 8, 150); Lineend.Y = Lineend.Y + 30;g.DrawLine(RedPen, Linestart, Lineend);Linestart = Lineend;Lineend.X = Lineend.X + 30;g.DrawLine(RedPen, Linestart, Lineend);Linestart = Lineend;if (ch = T)g.DrawString(1, smFont, myBrush, new Point(Linestart.X + 8, 150); m = m + 1;Linestart.Y = Linestart.Y + 30;Lineend.Y = Lineend.Y - 30;g.DrawLine(RedPen, Linestart, Lineend); Linestart = Lineend;Lineend.X = Lineend.X + 30;g.DrawLine(RedPen, Linestart, Lineend);Linestart = Lineend;elsech = strli;chpre = str1i - 1;if (ch = 0)g.DrawString(O, smFont, myBrush, new Point(Linestart.X + 8, 150);Lineend.X = Lineend.X + 30;g.DrawLine(RedPen, Linestart, Lineend);Linestart = Lineend;if (ch = T)g.DrawString(1, smFont, myBrush, new Point(Linestart.X + & 150); m = m + 1;if (m % 2 = 0)Lineend.Y = Lineend.Y + 60;g.DrawLine(RedPen, Linestart, Lineend);Linestart = Lineend;Lineend.X = Lineend.X + 30;g.DrawLine(RedPen, Linestart, Lineend);Linestart = Lineend;elseLineend.Y = Lineend.Y - 60;g.DrawLine(RedPen, Linestart, Lineend);Linestart = Lineend;Lineend.X = Lineend.X + 30;g.DrawLine(RedPen, Linestart, Lineend);Linestart = Lineend;2.3双极性信号交替反转码的设计实现双极性信号交替反转码用无电压的状态表示二进制0,用交替的正负电平表示二进制1。图2.2描述了用双极性信号交替反转码对数据110001011010进行编码的情况。信号交替反转码for (int i = 0; i str1length ; i+)g.DrawLine(BluePen, new Point(x += 30, y - 50), new Point(x, y + 50);if (i = 0)ch = str1i;if (ch = 0)g.DrawString(0, smFont, myBrush, new Point(Linestart.X + 8, 150);Lineend.X = Lineend.X + 30;g.DrawLine(RedPen, Linestart, Lineend);Linestart = Lineend;if (ch = T)g.DrawString(1, smFont, myBrush, new Point(Linestart.X + 8, 150); m+;Linestart.Y = Linestart.Y - 30;Lineend.X = Lineend.X + 30;Lineend.Y = Lineend.Y - 30;g.DrawLine(RedPen, Linestart, Lineend);Linestart = Lineend;elsech = str1i;chpre = str1i - 1;if (ch = T)g.DrawString(l, smFont, myBrush, new Point(Linestart.X + & 150);M+;if (chpre = O & m % 2 != 0)Lineend.Y = Lineend.Y - 30;g.DrawLine(RedPen, Linestart, Lineend);Linestart = Lineend;Lineend.X = Lineend.X + 30;g.DrawLine(RedPen, Linestart, Lineend);Linestart = Lineend;else if (chpre = O & m % 2 = 0)Lineend.Y = Lineend.Y + 30;g.DrawLine(RedPen, Linestart, Lineend);Linestart = Lineend;Lineend.X = Lineend.X + 30;g.DrawLine(RedPen, Linestart, Lineend);Linestart = Lineend;else if (chpre = 1 & m % 2 = 0)Lineend.Y = Lineend.Y + 60;g.DrawLine(RedPen, Linestart, Lineend);Linestart = Lineend;Lineend.X = Lineend.X + 30;g.DrawLine(RedPen, Linestart, Lineend);Linestart = Lineend;else if (chpre = 1 & m % 2 != 0)Lineend.Y = Lineend.Y - 60;g.DrawLine(RedPen, Linestart, Lineend);Linestart = Lineend;Lineend.X = Lineend.X + 30;g.DrawLine(RedPen, Linestart, Lineend);Linestart = Lineend;if (ch = 0)g.DrawString(O, smFont, myBrush, new Point(Linestart.X + 8, 150); if (chpre = 0)Lineend.X = Lineend.X + 30;g.DrawLine(RedPen, Linestart, Lineend);Linestart = Lineend;else if (chpre = 1 & m % 2 = 0)Lineend.Y = Lineend.Y - 30;g.DrawLine(RedPen, Linestart, Lineend);Linestart = Lineend;Lineend.X = Lineend.X + 30;g.DrawLine(RedPen, Linestart, Lineend);Linestart = Lineend;else if (chpre = 1 & m % 2 != 0)Lineend.Y = Lineend.Y + 30;g.DrawLine(RedPen, Linestart, Lineend);Linestart = Lineend;Lineend.X = Lineend.X + 30;g.DrawLine(RedPen, Linestart, Lineend);Linestart = Lineend;2.4双极性8零替换码的设计实现8零替换码是北美地区使用的一种AMI变形码,它在一定程序上解决了为长0串提供 同步信息的问题,B8ZS通过对连续8个比特0进行替换实现功能,具体的替换方法是,如 果前导1是正电平,则8个0被编码为0, 0, 0,正,负0,负,正;当前导1为负电平, 则8个0被编码为0,0, 0,负,正,0,正,负,即如图2.3(a)所示。图2.3(b)描述了用双+ 00 0 0000 0 000 00 0 0 01 1+ 00 0 +0+ - 000 -+ 0 +2极性8零替换码对数据1001000000000进行编码的情况。 前导比特1的极性o i匸O) O一GOI 一IA电(b)图2.3 8零替换码for (int i = 0; i strllength ; i+)ch = str1i;if (ch = 0)b+;m = 1;if (b = 8 & m = 1)b = 0;k = i- 8;elsem = 0;b = 0; 判断是否有8个连续零for (int i = 0; i = k; i+)g.DrawLine(BluePen, new Point(x += 30, y - 50), new Point(x, y + 50); if (i = 0)ch = str1i;if (ch = 0)g.DrawString(O, smFont, myBrush, new Point(Linestart.X + 8, 150); Lineend.X = Lineend.X + 30;g.DrawLine(RedPen, Linestart, Lineend);Linestart = Lineend;if (ch = T)g.DrawString(1, smFont, myBrush, new Point(Linestart.X + & 150);a+;Linestart.Y = Linestart.Y - 30;Lineend.X = Lineend.X + 30;Lineend.Y = Lineend.Y - 30;g.DrawLine(RedPen, Linestart, Lineend);Linestart = Lineend;elsech = str1i;chpre = str1i - 1;if (ch = 0)g.DrawString(0, smFont, myBrush, new Point(Linestart.X + 8, 150); if (chpre = 1 & a % 2 != 0)Lineend.Y = Lineend.Y + 30;g.DrawLine(RedPen, Linestart, Lineend);Linestart = Lineend;Lineend.X = Lineend.X + 30;g.DrawLine(RedPen, Linestart, Lineend);Linestart = Lineend;else if (chpre = 1 & a % 2 = 0)Lineend.Y = Lineend.Y - 30;g.DrawLine(RedPen, Linestart, Lineend);Linestart = Lineend;Lineend.X = Lineend.X + 30;g.DrawLine(RedPen, Linestart, Lineend);Linestart = Lineend;else if (ch = 0)Lineend.X = Lineend.X + 30;g.DrawLine(RedPen, Linestart, Lineend);Linestart = Lineend;if (ch = T)g.DrawString(l, smFont, myBrush, new Point(Linestart.X + & 150); a+;if (chpre = T & a % 2 = 0)Lineend.Y = Lineend.Y + 60;g.DrawLine(RedPen, Linestart, Lineend);Linestart = Lineend;Lineend.X = Lineend.X + 30;g.DrawLine(RedPen, Linestart, Lineend);Linestart = Lineend;else if (chpre = T & a % 2 != 0)Lineend.Y = Lineend.Y - 60;g.DrawLine(RedPen, Linestart, Lineend);Linestart = Lineend;Lineend.X = Lineend.X + 30;g.DrawLine(RedPen, Linestart, Lineend);Linestart = Lineend;else if (chpre = 0 & a % 2 = 0)Lineend.Y = Lineend.Y + 30;g.DrawLine(RedPen, Linestart, Lineend);Linestart = Lineend;Lineend.X = Lineend.X + 30;g.DrawLine(RedPen, Linestart, Lineend);Linestart = Lineend;else if (chpre = O & a % 2 != 0)Lineend.Y = Lineend.Y - 30; g.DrawLine(RedPen, Linestart, Lineend); Linestart = Lineend;Lineend.X = Lineend.X + 30; g.DrawLine(RedPen, Linestart, Lineend); Linestart = Lineend;for (int i = k + 1; i = k + 8; i+)g.DrawString(0, smFont, myBrush, new Point(Linestart.X + 8, 150); g.DrawLine(BluePen, new Point(x += 30, y - 50), new Point(x, y + 50); if (i = k + 1)if (a % 2 = 0)Lineend.Y = Lineend.Y - 30;g.DrawLine(RedPen, Linestart, Lineend); Linestart = Lineend;Lineend.X = Lineend.X + 30;g.DrawLine(RedPen, Linestart, Lineend);Linestart = Lineend;elseLineend.Y = Lineend.Y + 30;g.DrawLine(RedPen, Linestart, Lineend);Linestart = Lineend;Lineend.X = Lineend.X + 30;g.DrawLine(RedPen, Linestart, Lineend);Linestart = Lineend;elseif (i = k + 2 | i = k + 3)Lineend.X = Lineend.X + 30;g.DrawLine(RedPen, Linestart, Lineend);Linestart = Lineend;if (i = k + 4)if (a % 2 = 0)Lineend.Y = Lineend.Y + 30;g.DrawLine(RedPen, Linestart, Lineend);Linestart = Lineend;Lineend.X = Lineend.X + 30;g.DrawLine(RedPen, Linestart, Lineend);Linestart = Lineend;elseif (a % 2 != 0)Lineend.Y = Lineend.Y - 30; g.DrawLine(RedPen, Linestart, Lineend); Linestart = Lineend;Lineend.X = Lineend.X + 30;g.DrawLine(RedPen, Linestart, Lineend);Linestart = Lineend;if (i = k + 5)if (a % 2 = 0)Lineend.Y = Lineend.Y - 60;g.DrawLine(RedPen, Linestart, Lineend); Linestart = Lineend;Lineend.X = Lineend.X + 30;g.DrawLine(RedPen, Linestart, Lineend);Linestart = Lineend;elseif (a % 2 != 0)Lineend.Y = Lineend.Y + 60; g.DrawLine(RedPen, Linestart, Lineend); Linestart = Lineend;Lineend.X = Lineend.X + 30;g.DrawLine(RedPen, Linestart, Lineend);Linestart = Lineend;if (i = k + 6)if (a % 2 = 0)Lineend.Y = Lineend.Y + 30;g.DrawLine(RedPen, Linestart, Lineend);Linestart = Lineend;Lineend.X = Lineend.X + 30;g.DrawLine(RedPen, Linestart, Lineend);Linestart = Lineend;elseif (a % 2 != 0)Lineend.Y = Lineend.Y - 30;g.DrawLine(RedPen, Linestart, Lineend); Linestart = Lineend;Lineend.X = Lineend.X + 30;g.DrawLine(RedPen, Linestart, Lineend);Linestart = Lineend;if (i = k + 7)if (a % 2 = 0)Lineend.Y = Lineend.Y - 30;g.DrawLine(RedPen, Linestart, Lineend);Linestart = Lineend;Lineend.X = Lineend.X + 30;g.DrawLine(RedPen, Linestart, Lineend);Linestart = Lineend;elseif (a % 2 != 0)Lineend.Y = Lineend.Y + 30;g.DrawLine(RedPen, Linestart, Lineend);Linestart = Lineend;Lineend.X = Lineend.X + 30;g.DrawLine(RedPen, Linestart, Lineend);Linestart = Lineend;if (i = k + 8)if (a % 2 = 0)Lineend.Y = Lineend.Y + 60;g.DrawLine(RedPen, Linestart, Lineend);Linestart = Lineend;Lineend.X = Lineend.X + 30;g.DrawLine(RedPen, Linestart, Lineend);Linestart = Lineend;elseif (a % 2 != 0)Lineend.Y = Lineend.Y - 60;g.DrawLine(RedPen, Linestart, Lineend);Linestart = Lineend;Lineend.X = Lineend.X + 30;g.DrawLine(RedPen, Linestart, Lineend);Linestart = Lineend;for (int i = k + 9; i strllength ; i+)g.DrawLine(BluePen, new Point(x += 30, y - 50), new Point(x, y + 50);ch = str1i;if (i = k + 9)if (ch = 0)g.DrawString(0, smFont, myBrush, new Point(Linestart.X + 8, 150); if (a % 2 = 0)Lineend.Y = Lineend.Y - 30;g.DrawLine(RedPen, Linestart, Lineend);Linestart = Lineend;Lineend.X = Lineend.X + 30;g.DrawLine(RedPen, Linestart, Lineend);Linestart = Lineend;elseLineend.Y = Lineend.Y + 30;g.DrawLine(RedPen, Linestart, Lineend);Linestart = Lineend;Lineend.X = Lineend.X + 30;g.DrawLine(RedPen, Linestart, Lineend);Linestart = Lineend;if (ch = T)g.DrawString(l, smFont, myBrush, new Point(Linestart.X + & 150);a+;if (a % 2 = 0)Lineend.Y = Lineend.Y + 60;g.DrawLine(RedPen, Linestart, Lineend);Linestart = Lineend;Lineend.X = Lineend.X + 30;g.DrawLine(RedPen, Linestart, Lineend);Linestart = Lineend;elseLineend.Y = Lineend.Y - 60;g.DrawLine(RedPen, Linestart, Lineend);Linestart = Lineend;Lineend.X = Lineend.X + 30;g.DrawLine(RedPen, Linestart, Lineend);Linestart = Lineend;elsech = str1i;chpre = strli - 1; if (ch = 0)g.DrawString(O, smFont, myBrush, new Point(Linestart.X + 8, 150); if (chpre = 1 & a % 2 != 0)Lineend.Y = Lineend.Y + 30;g.DrawLine(RedPen, Linestart, Lineend);Linestart = Lineend;Lineend.X = Lineend.X + 30;g.DrawLine(RedPen, Linestart, Lineend);Linestart = Lineend;else if (chpre = 1 & a % 2 = 0)Lineend.Y = Lineend.Y - 30;g.DrawLine(RedPen, Linestart, Lineend); Linestart = Lineend;Lineend.X = Lineend.X + 30;g.DrawLine(RedPen, Linestart, Lineend);Linestart = Lineend;else if (ch = 0)Lineend.X = Lineend.X + 30;g.DrawLine(RedPen, Linestart, Lineend);Linestart = Lineend;if (ch = 1)g.DrawString(1, smFont, myBrush, new Point(Linestart.X + & 150); a+;if (chpre = 1 & a % 2 = 0)Lineend.Y = Lineend.Y + 60;g.DrawLine(RedPen, Linestart, Lineend);Linestart = Lineend;Lineend.X = Lineend.X + 30;g.DrawLine(RedPen, Linestart, Lineend); Linestart = Lineend;else if (chpre = T & a % 2 != 0)Lineend.Y = Lineend.Y - 60; g.DrawLine(RedPen, Linestart, Lineend); Linestart = Lineend;Lineend.X = Lineend.X + 30;g.DrawLine(RedPen, Linestart, Lineend);Linestart = Lineend;else if (chpre = 0 & a % 2 = 0)Lineend.Y = Lineend.Y + 30;g.DrawLine(RedPen, Linestart, Lineend);Linestart = Lineend;Lineend.X = Lineend.X + 30;g.DrawLine(RedPen, Linestart, Lineend);Linestart = Lineend;else if (chpre = 0 & a % 2 != 0)Lineend.Y = Lineend.Y - 30; g.DrawLine(RedPen, Linestart, Lineend); Linestart = Lineend;Lineend.X = Lineend.X + 30;g.DrawLine(RedPen, Linestart, Lineend);Linestart = Lineend;2.5曼彻斯特编码的设计实现曼彻斯特编码以在比特中点位置上出现的从负电平到正电平时的跳变表示二进制的1,将此刻出现从正电平到负电平的跳变表示二制0。图2.3描述了用曼彻斯特编码对数据110001011010进行编码的情况。曼彻斯特编码1100010110101Ii ,一1lIL1I八etii图2.4曼彻斯特编码for (int i = 0; i 乘法罢 一 帯国注雪 一 s(t)Tm锻戎生关(a)(b)图2.5二进制振幅键控调制for (int j = 0; j n; j+)g.DrawCurve(Pens.Red, new Point new Point(x2, y2),new Point(x2 + 5, y2 - 40),new Point(x2 + 10, y2), new Point(x2 + 15, y2 + 40),new Point(x2 + 20, y2),new Point(x2 + 25, y2 - 40), new Point(x2 + 30, y2),new Point(x2+35,y2+40),new Point(x2+40,y2) );g.DrawLine(Pen, new Point(x2 += 40, y2 - 60), new Point(x2, y2 + 60);for (int k = 0; k n; k+)ch = strlk;if (ch = 0)g.DrawLine(myPen, x3, y3, x3 + 40, y3);g.DrawLine(Pen, new Point(x3 += 40, y3 - 60), new Point(x3, y3 + 60); else if (ch = T
展开阅读全文