ImageVerifierCode 换一换
格式:DOCX , 页数:30 ,大小:276.34KB ,
资源ID:9021055      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/9021055.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(课程设计报告摩尔斯电码发声器.docx)为本站会员(b****7)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

课程设计报告摩尔斯电码发声器.docx

1、课程设计报告摩尔斯电码发声器课程设计报告Morse电码发声器 程序方案:0-9和A-Z的摩尔斯电码表如下图所示:将0-9和A-Z的摩尔斯电码制作为一个36行6列的二维数组,如下图所示当输入0-9或A-Z之间的字符时,程序会根绝具体的字符,从摩尔斯电码表的二维数组中选出对应该字符的一行数组输出,作为该字符的摩尔斯电码。用一个字节的二进制数代表一个字符的摩尔斯电码,左起第一个1为起始标志(起始标志及之前的0无效)。起始标志后的0表示点。起始标志后的1表示划。如:A 的报文信息 0000 0101B 的报文信息 0001 1000C 的报文信息 0001 1010按此规律建立一个报文信息表,报文信息

2、表要按 09 、AZ的顺序排列,发送时先查表找字符对应的报文信息,左移报文信息找起始标志,(起始标志及之前的0不发声),然后调用点划子程序发点划声响,发送一个字符循环8次则自动结束。报文信息表同样为一个36行6列的二维数组,如下图所示:系统细节方案:点划间隔子程序是通过调用window.h库中的Beep函数是系统发出声音。程序收到字符后,根据字符对应的摩尔斯电码表中的数组,输出该字符的摩尔斯电码,并且查找到该字符的01报文信息表,通过两个循环,调用点划子程序,完成电码的发音功能。子程序及其流程图:点声音程序代码: 点声音程序流程图int dot()/点声音 Beep(7000,200); re

3、turn 0;划声音程序代码: 划声音程序流程图int dash()/划声音 Beep(7000,600); return 0;点划之间间隔程序代码:int space()/电码间隔声音 Beep(0,400); return 0; 主程序详解:程序设计初期,用C+编写了一个控制台应用,先编写了一个电码编译的子程序:int tra(char c)/电码编译 if(c=48&c=57) coutc的摩尔斯电码是:mc-48endl; for(i=0;i8;i+) if(nc-48i=1) j=i+1; break; for(i=j;i=65&c=90) coutc的摩尔斯电码是:mc-65+10

4、endl; for(i=0;i8;i+) if(nc-65+10i=1) j=i+1; break; for(i=j;i8;i+) if(nc-65+10i=0) dot(); if(nc-65+10i=1) dash(); space(); else if(c57&c90) coutc输入格式错误,不是0-9或A-Z之间的字符endl; return 0;电码编译子程序流程图:在主程序中利用fstream库中的ifstream文件流又编写了一段可以打开文件的语句,主程序代码如下:int main()/主程序 while(1) cout请选择输入字符或者文件路径ch; if(ch=c)/输入字

5、符进行编括译 cout请输入0-9或A-Z之间的字符c; tra(c);/调用编码函 Sleep(500);/设置读取字符延迟 else if(ch=f)/输入文件路径进行编译 cout请输入文件路径filename; ifstream infile(filename,ios:in); if(!infile) cerr打开文件错误endl; while(infile.get(c) tra(c); Sleep(500);/设置读取字符延迟 else cout输入格式错误endl; 主程序流程图编译运行的结果:程序设计后期在windows窗体应用中创建项目,建立一个窗体,在窗体中完成字符、文件的打

6、开、编译功能,在窗体中添加控件,将之前的程序写入各个控件的动作中,完成程序的功能,程序运行结果如下图:在textBox1中输入字符,程序将textBox1中的字符存入指向字符数组的指针中,再根绝数组中字符,找到相对应的报文信息进行编译发声。利用openFileDialog打开文件,利用richTextBox中的LoadFile方法加载文件,再将richTextBox中的字符存入数组指针中,利用指针循环自加对数组指针中的字符进行编译发声。Morse电码主程序自动生成的cpp:/ morse.cpp: 主项目文件#include stdafx.h#include Form1.husing name

7、space morse;STAThreadAttributeint main(array args) / 在创建任何控件之前启用 Windows XP 可视化效果 Application:EnableVisualStyles(); Application:SetCompatibleTextRenderingDefault(false); / 创建主窗口并运行它 Application:Run(gcnew Form1(); return 0;Form1.h库中的源代码:#pragma once#includenamespace morse using namespace System; usin

8、g namespace System:ComponentModel; using namespace System:Collections; using namespace System:Windows:Forms; using namespace System:Data; using namespace System:Drawing; using namespace System:Runtime:InteropServices; / / Form1 摘要 / public ref class Form1 : public System:Windows:Forms:Form public: F

9、orm1(void) InitializeComponent(); / /TODO: 在此处添加构造函数代码 / protected: / / 清理所有正在使用的资源 / Form1() if (components) delete components; private: System:Windows:Forms:Label label1; protected: private: System:Windows:Forms:TextBox textBox1; private: System:Windows:Forms:ListBox listBox1; private: System:Wind

10、ows:Forms:Button button1; private: System:Windows:Forms:Label label3; private: System:Windows:Forms:Label label4; private: System:Windows:Forms:OpenFileDialog openFileDialog1; private: System:Windows:Forms:RichTextBox richTextBox1; private: System:Windows:Forms:Button button3; private: System:Window

11、s:Forms:Label label2; private: System:Windows:Forms:Label label5; private: System:Windows:Forms:Button button4; private: System:Windows:Forms:Button button6; private: System:Windows:Forms:Button button2; private: / / 必需的设计器变量 / System:ComponentModel:Container components;#pragma region Windows Form D

12、esigner generated code / / 设计器支持所需的方法不要 / 使用代码编辑器修改此方法的内容 / void InitializeComponent(void) this-label1 = (gcnew System:Windows:Forms:Label(); this-textBox1 = (gcnew System:Windows:Forms:TextBox(); this-listBox1 = (gcnew System:Windows:Forms:ListBox(); this-button1 = (gcnew System:Windows:Forms:Butto

13、n(); this-label3 = (gcnew System:Windows:Forms:Label(); this-label4 = (gcnew System:Windows:Forms:Label(); this-openFileDialog1 = (gcnew System:Windows:Forms:OpenFileDialog(); this-richTextBox1 = (gcnew System:Windows:Forms:RichTextBox(); this-button3 = (gcnew System:Windows:Forms:Button(); this-lab

14、el2 = (gcnew System:Windows:Forms:Label(); this-label5 = (gcnew System:Windows:Forms:Label(); this-button4 = (gcnew System:Windows:Forms:Button(); this-button6 = (gcnew System:Windows:Forms:Button(); this-button2 = (gcnew System:Windows:Forms:Button(); this-SuspendLayout(); / / label1 / this-label1-

15、AutoSize = true; this-label1-Location = System:Drawing:Point(51, 32); this-label1-Name = Llabel1; this-label1-Size = System:Drawing:Size(65, 12); this-label1-TabIndex = 0; this-label1-Text = L请输入字符; / / textBox1 / this-textBox1-Location = System:Drawing:Point(53, 49); this-textBox1-Name = LtextBox1;

16、 this-textBox1-Size = System:Drawing:Size(100, 21); this-textBox1-TabIndex = 1; this-textBox1-KeyDown += gcnew System:Windows:Forms:KeyEventHandler(this, &Form1:textBox1_KeyDown); / / listBox1 / this-listBox1-FormattingEnabled = true; this-listBox1-ItemHeight = 12; this-listBox1-Location = System:Dr

17、awing:Point(315, 55); this-listBox1-Name = LlistBox1; this-listBox1-Size = System:Drawing:Size(120, 184); this-listBox1-TabIndex = 2; / / button1 / this-button1-Location = System:Drawing:Point(67, 132); this-button1-Name = Lbutton1; this-button1-Size = System:Drawing:Size(75, 23); this-button1-TabIn

18、dex = 4; this-button1-Text = L发声; this-button1-UseVisualStyleBackColor = true; this-button1-MouseClick += gcnew System:Windows:Forms:MouseEventHandler(this, &Form1:button1_MouseClick); / / label3 / this-label3-AutoSize = true; this-label3-Location = System:Drawing:Point(53, 95); this-label3-Name = L

19、label3; this-label3-Size = System:Drawing:Size(89, 12); this-label3-TabIndex = 6; this-label3-Text = L输入的字符是:; / / label4 / this-label4-AutoSize = true; this-label4-Location = System:Drawing:Point(138, 95); this-label4-Name = Llabel4; this-label4-Size = System:Drawing:Size(0, 12); this-label4-TabInd

20、ex = 7; / / openFileDialog1 / this-openFileDialog1-FileName = LopenFileDialog1; / / richTextBox1 / this-richTextBox1-Location = System:Drawing:Point(12, 256); this-richTextBox1-Name = LrichTextBox1; this-richTextBox1-Size = System:Drawing:Size(213, 132); this-richTextBox1-TabIndex = 8; this-richText

21、Box1-Text = L; / / button3 / this-button3-Location = System:Drawing:Point(315, 256); this-button3-Name = Lbutton3; this-button3-Size = System:Drawing:Size(74, 25); this-button3-TabIndex = 9; this-button3-Text = L打开文件; this-button3-UseVisualStyleBackColor = true; this-button3-Click += gcnew System:Ev

22、entHandler(this, &Form1:button3_Click); / / label2 / this-label2-AutoSize = true; this-label2-Location = System:Drawing:Point(313, 32); this-label2-Name = Llabel2; this-label2-Size = System:Drawing:Size(29, 12); this-label2-TabIndex = 11; this-label2-Text = L编码; / / label5 / this-label5-AutoSize = t

23、rue; this-label5-Location = System:Drawing:Point(55, 238); this-label5-Name = Llabel5; this-label5-Size = System:Drawing:Size(0, 12); this-label5-TabIndex = 12; / / button4 / this-button4-Location = System:Drawing:Point(315, 312); this-button4-Name = Lbutton4; this-button4-Size = System:Drawing:Size

24、(75, 23); this-button4-TabIndex = 13; this-button4-Text = L编码; this-button4-UseVisualStyleBackColor = true; this-button4-Click += gcnew System:EventHandler(this, &Form1:button4_Click); / / button6 / this-button6-Location = System:Drawing:Point(315, 364); this-button6-Name = Lbutton6; this-button6-Si

25、ze = System:Drawing:Size(75, 23); this-button6-TabIndex = 15; this-button6-Text = L发声; this-button6-UseVisualStyleBackColor = true; this-button6-Click += gcnew System:EventHandler(this, &Form1:button6_Click); / / button2 / this-button2-Location = System:Drawing:Point(453, 55); this-button2-Name = Lbutton2; this-button2-Size = System:Drawing:Size(75, 23); this-button2-TabIndex = 16; this-button2-Text = L清空; this-button2-UseVisualStyleBackColor = true; this-button2-Click += gcnew System:EventHandler(this, &Form1:button2_Click); /

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1