您好,欢迎来到二三四教育网。
搜索
您的当前位置:首页基于stm32和dm9000的照明控制系统毕业论文

基于stm32和dm9000的照明控制系统毕业论文

来源:二三四教育网

本科毕业论文

:

测控技术与仪器


:

11 测控2

_

学生姓名:

管国翀

:

11210040218

: 基于STM32 DM9000 的照明控制系统

指导老师:

陈 松

完成时间:

2015 6 7

安徽建筑大学机械与电气工程学 院

二〇一五年六月七日



摘 要

随着计算机技术和电子信息技术的高速发展,特别是近年来在互联网建设的推动下,照明控制系统越来越受到人们的关注。本课题在分析照明控制系统的研究现状、发展趋势、研究意义的基础上提出了基于单片机以及嵌入式操作系统的照明控制系统的设计方案。STM32F103是意法半导体推出全新STM32互连型系列微控制器中的一款性能较强产品,此芯片集成了各种高性能工业标准接口,且STM32不同型号产品在引脚和软件上具有完美的兼容性,可以轻松适应更多的应用,此芯片可以满足工业、医疗、楼宇自动化、家庭音响和家电市场多种产品需求。DM9000是一款单芯片快速以太网MAC控制器,它与STM32控制器通信,发送指令,通过I/O端口高低电平,控制继电器,来实现整个照明系统的智能控制。其主要特点在于功能实用、操作简单、价格低廉、易于安装,使得该系统可以广泛应用于学校、工厂等照明设施。

关键词:单片机;照明控制;嵌入式

Abstract
With the rapid development of computer technology and electronicinformation technology, especially in recent years in theconstruction of the Internet Push the lighting control system moreand more attention of people. This paper on the basis of analysis oflighting control system, the research present situation, developmenttrend and the research significance the microcontroller and embeddedoperating system of lighting control system design based on.STM32F103 is STMicroelectronics launched new STM32 interconnectionseries micro controller in a high performance products. The chipintegrates a variety of high performance industrial standardinterface and STM32 different types of products on the pin andsoftware with perfect compatibility can easily adapt to theapplication of more, this chip can meet the industrial, medical,building automation and home audio and home appliances market variousdemands of products. Dm9000 is a single chip fast Ethernet MACcontroller, it communicate with the STM32 controller, send thecommand, through the I / O port level, control relay to achieveintelligent control of the lighting system. Its main features arepractical, simple operation, low cost, easy installation, so that thesystem can be widely used in schools, factories and other lightingfacilities.

Keywords: singlechip computer;;

目录

第一章绪论.......................................................................................................................11.1 照明控制系统设计研究的意义........................................................................11.2 国内外发展概况与发展趋势............................................................................1第二章系统总体设计方案与硬件介绍.........................................................................32.1 系统的总体方案设计介绍...............................................................................32.2 系统的硬件设计...............................................................................................42.2.1 单片机控制模块设计.............................................................................4
2.2.2 DM9000网络通信模块........................................................................7
第三章系统软件设计....................................................................................................103.1网络通信协议.....................................................................................................133.1.1 uIP协议栈及其体系结构........................................................................14
3.1.2协议栈接口..............................................................................................14
3.2程序流程图......................................................................................................163.2.1程序运行初始化流程图.........................................................................16
3.2.2程序功能流程图.....................................................................................17
3.3系统LED灯程序..............................................................................................183.4系统主程序........................................................................................................223.5通信协议程序....................................................................................................30第四章系统的程序调试..............................................................................................314.1系统的主程序调试............................................................................................31

4.1.1编写程序...................................................................................................31

4.1.2 烧写代码下载

32

4.2系统硬件连接
33
4.3系统调试结果....................................................................................................34第五章毕业设计总结....................................................................................................36致谢...................................................................................................................................37参考文献...........................................................................................................................38附录一:硬件电路图......................................................................................................39附录二:英文资料和译文..............................................................................................41

第一章绪论

1.1 照明控制系统设计研究的意义

采用智能照明控制系统,使照明系统工作在全自动状态,系统按预先设定的开馆、值班、清扫、保安等照明模式进行工作,这些照明模式会按预先设定的时间相互自动地进行切换。提高管理水平,减少维护费用。博物馆建筑面积一般较大,人工维护繁琐,智能照明控制系统的应用,将普通照明人为的开与关转换成,使管理者能将其高素质的管理意识运用于照明控制系统中去,同时大大减少了馆内的运行维护费用。可观的节能效果。智能照明控制系统使用了先进的电力电子技术,能对控制区域内的灯具进行智能调光,当室外光较强时,室内照度自动调暗,室外光较弱时,室内照度则自动调亮,使室内的照度始终保持在恒定值附近,从而能够充分利用自然光实现节能的目的。此外,智能照明的管理系统采用设置照明工作状态等方式,通过智能化自动管理避免了照明区域“长明灯”等现象,根据照明的使用规律启动不用的灯光场景,通过对灯光的调光也可以让灯光不用满负荷使用,又达到好的照度效果,大幅度的节约用电。

保护灯具,延长寿命。保护灯具实际上也是节能的一种方式,灯具损坏
的致命原因主要是电压过高,工作电压越高,其寿命则成倍降低。因此适当降低灯具工作电压是延长灯具寿命的有效途径。美莱恩控制系统能成功地抑制电网的并且美莱恩采用了软冲击电压和浪涌电压,使灯具不会因上述原因而过早损坏。

启动和软关断技术,避免了灯丝的热冲击,使灯具寿命进一步得到延长。智能照明系统通常能使灯具寿命延长24倍,不仅节省大量灯具,而且大大减少更换灯具的工作量,有效地降低了照明系统的运行费用。

1.2 国内外发展概况与发展趋势

上世纪90年代,美国率先提出了“绿色照明计划”,这以后,各国也都在不同程度开始对其进行推广工作。在我国,近几年也加大了扶持LED绿色照明企业的力度,并制定节能认证标准,提高产品技术和质量水平,建立持续、高效发热照明产品市场。更值得一提的是,国家和地方组织的“LED照明产品的大宗采购”,将LED绿色照明产品推广到市政建设、轨道交通、公共空间等领域;同时,

开展电力需求管理活动,将活动扩展到大型的集团公司、央企及私人企


业。

从绿色照明的发展阶段来看,目前正处在产品创新、节能标准进一步规范的环节。以LED照明产品为例,由于其是一种高效、节能环保的新光源,国家和地方已开始从各方面推广和扶持。然而照明行业的发展也面临着一些难题,例如LED照明市场混乱,低价、质量差的产品居多,为一些性能优异的绿色照明产品的市场占有率造成了很大影响。除此之外,照明产品标准不明确、节能要求不统一也为其推广造成了困扰。

年初,国家出台的《绿色建筑行动方案》中,倡导节能减排、降低建筑能耗、发展绿色建筑,这对绿色照明的发展是有一定的影响和推动减少二氧化碳排放、作用的。当然,仅有这个方案也是远远不够的,我认为,在建立绿色建材标准体系时,绿色照明作为绿色建材的一部分也应该纳入标准体系之中。同时,国家在规范绿色照明标准及要求、对照明产品进行质量管制的同时,也应该为照明企业的产品发展与创新指出阶段性的方向,并适当对绿色照明企业进行扶持。

第二章系统总体设计方案与硬件介绍2.1 系统的总体方案设计介绍

电脑


照明灯状态

命令


DM9000


命令

I/O 状态(照明灯状态)

STM32

I/O


继电器





照明灯

2.1方案介绍

首先控制端,通过网络给网络端口(dm9000网卡)发命令stm32取到命令控制I/O高低电平,控制继电器控制照明灯。

2.2 系统的硬件设计

电路原理图绘制软件Protel99SE介绍
Protel99SE 是应用于Windows9X/2000/NT操作系统下的EDA设计软件,采用设计库管理模式,可以进行联网设计,具有很强的数据交换能力和开放性及3D模拟功能,是一个32位的设计软件,可以完成电路原理图设计,印制电路板设计和可编程逻辑器件设计等工作,可以设计32个信号层,16个电源--

层和16个机加工层。

2.2.1 单片机控制模块设计

普通设计中大多采用51单片机、PIC单片机或者是AVR单片机,这些单片机的缺点是高功耗、性能低并且硬件资源匮乏。相比之下, STM32系列是基于专为要求高性能、低成本、低功耗的嵌入式应用而专门设计的ARM
Cortex-M3内核的微控制器。

2.2STM32F103

1.ARM控制器使用STM32F103STM32F103是意法半导体推出全新STM32互连型系列微控制器中的一款性能较强产品,此芯片集成了各种高性能工业标准接口,且STM32不同型号产品在引脚和软件上具有完美的兼容性,可以轻松适应更多的应用。新STM32的标准外设包括10个定时器、两个12AD(模数转换器)(快速交替模式下2Msample/s)、两个12DA(数模转换器)、两个I2C接口、五个USART接口和三个SPI端口和高质量数字音频接口IIS,另外STM32F103拥有全速USBOTG)接口,两路CAN2.0B接口,以及以太网10/100MAC 模块。此芯片可以满足工业、医疗、楼宇自动化、家庭音响和家电市场多种产品需求。

2.STM32F1系列属于中低端的32ARM微控制器,该系列芯片是意法半导体(ST)公司出品,其内核是Cortex-M3。该系列芯片按片内Flash的大小可分为三大类:小容量(16K32K)、中容量(K128K)、大容量(256K384K512K)。

3.芯片集成,,,,,USB,,等多种功能内核:--ARM32 位的,--最高72MHz工作频率,在的0

待访问时可达1.25DMips/MHZDhrystONe2.1--单周期乘法和硬件除法存储器--32K512K的闪存器(STM32F103XXXX中的第二个X表示FLASH容量,其中:“4”=16K,“6”=32K,“8”=KB=128KC=256KD=384KE=512K--最大K字节的SRAM电源管理--2.0-3.6V供电和I/O-上电/断电复位(POR/PDR)、可编程电压监测器(PVD--4-16MHZ晶振振荡器--内嵌经出厂调教的8MHzRC振荡器 --内嵌带校准的40KHzRC振荡器-产生CPU时钟的PLL--带校准的32KHzRC振荡器
低功耗睡眠、停机和待机模为RTC和后备寄存器供电
模数转换器--212位模数转换器,1us转换时间(多达16个输入通道)--转换范围:03.6V--双采样和保持功能--温度传感器DMA--2DMA控制器,共12DMA通道:DMA17个通道,DMA25个通道--支持的外设:、ADCSPIUSBIICUART
--多达112个快速I/O端口(Z系列有超过100个引脚)
-26/37/51/80/112I/O口,所有I/O口一块映像到16个外部中断;几乎所有的端口均可容忍5V信号
调试模式
--串行单线调试(SWD)JTAG接口--多达8个定时器--316位,每个定时器有多达4个用于输入捕获/输出比较/PWM或脉冲计数的通道和增量编码器输入--116位带死区控制和紧急刹车,用于电机控制的PWM高级控制定时器--2个(的和窗口型的)--系统:
24位自减型计数器--多达9个通信接口:2I2C接口3USART接口(支持ISO7816接口,LINIRDA接口和控制)2SPI接口(18M/秒)CAN接口(2.0B主动)USB2.0 全速接口计算单元CRC计算单元,96位的新批唯一代码封装 ECOPACK封装。

2.3STM32F103 电路原理图

2.4 时钟电路

2.5STM32F103 引脚分布图

2.2.2 DM9000 网络通信模块

1.DM9000是一款单芯片快速以太网MAC控制器。它有一个一般处理接口,一个10/100M自适应的PHY4KDWORD 值的SRAM。它的目的是在低功耗和高性能进程的3.3V5V的支持宽容,DM9000还提供了介质无关的接口,来连接所有提供支持介质无关接口功能的家用电话线网络设备或其他收发器。该DM9000支持8位,16位和32位接口访问内部存储器,以支持不同的处理器。DM9000物理协议层接口完全支持使用10MBps3类、4类、5类非屏蔽双绞线和100MBps5类非屏蔽双绞线,完全符合IEEE802.3u 规格。

2.DM9000Davicom公司的一款以太网控制芯片,在网络中他可自动获得同设定MAC地址一致的IP包,完成IP包的收发,再用ARM来结合完成上层

协议,就构成了一个完整的网络终端。

2.6 DM9000 电路原理图

2.7驱动电路电路图

3.网卡芯片DM9000STM32的连接。首先,可 以 从 硬 件 上 完 成 网 卡 芯 片DM9000ARM处理器STM32的三大总线连接,以及和以太网的连接,嵌入式 ARM系统和以太网接口连接图

嵌入式系统

数据

网卡芯片

以太网连接

地址 DMDM9000

STM32

控制

2.8连接示意图

4.DM9000默认I/O基地址为300HCMD引脚用于设置COMMAND模式,CMD为高时,选择数据端口。CMD为低时,选地址端口。数据端口和地址端口的地址码由下式决定:DM9000地址端口=高位片选地址

+300H+0HDM9000数据端口=高位片选地址+300H+4H
5.DM9000的调试过程
DM9000的调试过程中,首先要确保芯片能否正常工作, 即确保 MAC地址是存储在EE-PROM中,且MAC地址正常。对DM9000的寄存器进行读写测试,从 PAB0PAB5MAC地址写入到DM9000寄存器,然后再读取寄存器来验证它。其次可以进行EEPROM93C46 的字数据测试,进行以太网连接测试, 通过连接LED灯的亮灭以及读取NSR寄存器来检查IINKSTbit6]的状态是否为“1”来验证以太网是否已经连接成功。进行外部环回测试,使用一个交叉线插到 RJ-45,检查能否收到所发送的包。进行向另一台主机发包、收包的测试, 最后连上交换机, 把事先编译好的程序下载到处理器中去,验证是否实现联网。

第三章系统软件设计

3.1网络通信协议

TCPIP协议在全球互联网上取得了巨大的成功,人们通过该协议进行文件传送,电子邮件发送等多种应用,TCPIP协议已成为事实上的全球网络通信标准。随着嵌入式系统技术的深入发展,越来越多的嵌入式设备也需要互连成网,协同工作,如无线传感器、信息家电、智能仪表等。在嵌入式设备中通过TCPIP协议连接Interact网络需求更加强烈。在嵌入式系统上运行TCPIP协议可以使得该系统直接与内部网络甚至全球互联网相联,而不需要引入额外的网关设备,给嵌入式设备通信带来巨大的便利。嵌入式系统的本身资源有限,并且其应用和功能比较单一,具有较强的针对性,因此不需要一个完整的TCPIP网络协议组件,只需要实现与需求相关的部分协议,不使用的协议则不需要支持。另一方面,对于某些特定的嵌入式系统,甚至需要优化TCPIP协议栈或者在TCPIP协议栈中编写自己需要的网络协议。那些不能提供开放源码的商用嵌入式系统的TCPIP协议栈很难满足用户的配置需求,需要用户自行开发和定制适合自己系统需求的嵌入式
TCPIP协议栈。

由瑞典计算机科学研究所AdamDunkels 开发的uIP09,去掉了全功能TCPIP协议栈中不常用的功能,保留网络通信所必要的协议机制,大大减少了协议代码量,降低了协议对系统资源的要求。该协议由公开源代码的c语言编写,任何人都可以在网络上下载其源代码并对其进行修改,以适应各自不同的应用场合。uIP09采用模块化设计,其代码量在几千字节左右,仅需要几百字节的内存就可以顺利运行,完全适应当前的嵌入式系统。

3.1.1UIP 协议栈及其体系结构
UIP是一个适用于816位机上的小型嵌入式TCPIP协议栈,简单易用,资源占用少是它的设计特点。其设计重点放在IPICMPTCP协议的实现上,协议虽然也同时实现了UDPARP协议,但仅将其作为可选模块。UIP处于网络通信的中间层,其上层协议在这里被称之为应用程序,而下层硬件或固件被称之为网络设备驱动。TCPIP协议组中的链路层协议如PPP等可由UIP之下的设备驱动实现;应用层协议如H33"PFTPSMTP等可由UIP之上的应用程序实现。这样的设计方式大大减小了协议代码量和RAM占用量。为进一步节省资源占用,简化应用接口,UIP在内部实现上还作了如下特殊的处理:
采用单一的全局数据收发缓冲区,不支持内存动态分配;
基于事件驱动的应用程序接口,各并发连接采用轮循处理,仅当网络事件发生时,由UIP内核唤起应用程序处理。这样,UIP用户只须关注特定应用就可以了。传统的TCPIP实现一般要基于多任务处理环境,而大多数8位机系统不具备这个条件;
应用程序主动参与部分协议栈功能的实现(TCP的重发机制,数据包分段和流量控制),由UIP内核设置重发事件,应用程序重新生成数据提交发送,免去了大量内部缓存的占用。基于事件驱动的应用接口使得这些实现较为简单。正是由于UIP所具有的以上显著特点,自从06版本以来就被移植到多种处理器上,包括MSP430AVRZ80等。

3.1.2协议栈接口

1描述了UIP、底层系统和应用程序三者之间的调用关系。其中UIP协议通过一系列接口函数与底层系统和上层应用程序通信,它内部的协议集合对外部

系统来说是透明的,从而增强了该协议的通用性和性,可以非常方便地移植


到不同系统和应用平台。图1描述了UIP、底层系统和应用程序三者之间的调用

关系。其中UIP提供了3个函数给底层系统:uip—init()'uip— input()’uip—

periodic()。应用程序向UIP提供一个调用函数uipappcall(),在网络事件或计时

事件发生时进行调用;同时,UIP也要向应用程序提供一些与协议栈的接口函数,

应用程序根据接口函数提供的信息或者状态,执行相应的操作。

应用程序


Uip-appcall()


UIP 协议栈


Uip-input()

uip-periodc()


底层系统

网卡驱动系统定时器

3.1UIP、底层系统和应用程序之间的调用关系

设备驱动程序接口:UIP内核中有两个函数直接提供给底层设备驱动程序。一

个是uip—input(),当设备驱动程序从网络层收到的一个数据包时要调用这个函

数,设备驱动程序必须事先将数据包存入到uipbur 中,包长放到uip—len,然后交由uip—input()处理。当函数返回时,如果uip—len 不为0,则表明有带外数据(SYNACK)要发送。当需要ARP支持时,还需要考虑更新ARP表示或发出ARP请求和回应。以下代码即为设备驱动程序从网络层收到的个数据包后的处理过程:
#defineBUF ((struet uip—eth— hdr*)&uip— buf[O])
uip

len=ethemet

devicedriver
—poll()
//接收以太网数据包(设备驱动程序)
if(uip—len>0){ //收到数据
if(BUF>type::HTONS(UIP

ETHTYPE
—IP)){
//是IP包吗?

uip
—arp—ipin();//去除以太网头结构,更新ARP
uip
—input();//IP包处理
if(uip—len>0){ //有带外回应数据

uip-arpout();//加以太网头结构,
在主动连接时可能要构造ARP请求
ethemet

devieedriver
—send()
//发送数据到以太网(设备驱动程序)
}
}else
if(sot>type==HTONS(U1P-ETHTYPE-ARP)){
//是ARP请求包
uip
—arp—arpin();//如是是ARP回应,更新ARP表;
如果是请求,构造回应数据包
if(uip—len>0){
//是ARP请求,要发送回应
ethernet

devicedriver
—send()
//发ARP回应到以太网上

另一个UIP内核直接提供给底层设备驱动程序的函数是uip—periodic(conn)。这个函数用于UIP内核对各连接的定时轮循,因此需要一个硬件支持的定时程序周期性地用它轮循各连接,一般用于检查主机是否有数据要发送,如有,则构造IP包。以下示例即为UIP内核对各连接的定时轮循过程:
for(i=0i<UIP—CONNSi++){
uip
—periodic(i)
if(uip—len>O){
uip
—arp—out()
ethemet

devicedriver
—send()
从本质上来说,uip—input()uip—periodic()在内部是一个函数,即uip—process(u8 tflag)uIP的设计者将uip—process(UIP— DATA)定义成uip_intput(),而将uip—process(UIP— TIMER)定义成uip—periodic(),因此从代码实现上来说是完全复用的。

应用程序接口:UIP使用基于事件的程序模式,应用程序由c语言函数实现。当收发数据、新连接建立或者数据需要重新传输时,UIP都会调用应用程序。同时,应用程序还要周期查询是否有新的数据收发。因为应用程序只提供了一个回调函数,所以应用程序还要把不同的网络服务映射到不同的端13和连接。UIP

在接受到底层传来的数据包后,如果需要送上层应用程序处理,就调用UIP—APPCALL()。同时设置结构体UIP—eonn 指针指向当前连接。UIPconn 记录一条TCP连接的所有相关信息,它是维持UIP运行的关键结构,定义如下:structcp—conn{
u8ttcpstateflags;//TCP的状态和标志
ul6
tlportrpert;//当地和远端端口
ul6
tfipodar[2];//远端的地址
u8

trcv
nxt[4];//下一个要接收的序列号
u8

tsod
—xt[4];∥上一个已发送的序列号
u8
taek-nxt[4];//对端下一个应答序列号
u8
ttimer;//重传时间
u8



tnrtx;//计算特殊段的重发数量
u8tmss;//连接中最大分段的大小
u8tappstate[UIP— APPSTATE
—SIZE]
UIP提供给应用程序的接口函数如:teplisten()uip—connect()uip—send()tcp—datalen()tcp—close()tcp—abort()tcp—stop()uip—stopped()uip—restart()等,实现了TCPIP协议栈的基本功能。为了将用户的应用程序挂接到UIP中,
必须将宏UIP—APPcALL()定义成实际的应用程序函数名,这样每当某个UIP事件发生时,内核就会调用该应用程序进行处理。如果要加入应用程序状态的话,必须将宏UIPAPPSTATESIZE定义成应用程序状态结构体的长度。在应用程序函数中,依靠UIP事件检测函数来决定处理的方法,另外可以通过判断当前连接的端口号来区分处理不同的连接。

3.2 程序流程图

3.2.1 程序运行初始化流程图

开始

系统时钟设置

初始化网络设备以及UIP协议栈,配置IP 地址




应用层MAC 初始化

UIP MAC初始化

UIP 初始化

ARP 初始化

创建TCP 监听窗口和HTTP 监听窗口


3.2初始化流程图

3.2.2程序功能流程图

当通过网络调

指令

试助手发来的指令时处理uIP事件

设置指

查询指

错误

设置IO高低平(设查询IO状态

置灯的开关)(灯的开关状态)

输出IO(灯)的状态

发生错




结束

3.3功能流程图

3.3系统LED灯程序

#include"stm32f10x.h"
#include "uip.h"
#include"uipopt.h"
#include"uip_arch.h"
#include<string.h>
#defineLED1_ON() GPIO_SetBits(GPIOB, GPIO_Pin_5);
#defineLED2_ON()GPIO_SetBits(GPIOC, GPIO_Pin_6);
#defineLED3_ON()GPIO_SetBits(GPIOC, GPIO_Pin_7);
#defineLED1_OFF() GPIO_ResetBits(GPIOB, GPIO_Pin_5); #define LED2_OFF() GPIO_ResetBits(GPIOC, GPIO_Pin_6); #define LED3_OFF() GPIO_ResetBits(GPIOC, GPIO_Pin_7); extern unsigned short LPORT;
voidserver_udp_appcall(void);
voidled_poll(void);

*******************************************************************************

*
*
*
*

函数名: void led_poll(void)
参 数:
返 回:
功 能: 查询LED 灯的状态并返回其状态

**************************************************************************/void led_poll(void)
{
uint8_t led1_readvalue;
uint8_t led2_readvalue;
uint8_t led3_readvalue;
led1_readvalue = GPIO_ReadOutputDataBit(GPIOB,GPIO_Pin_5 );led2_readvalue = GPIO_ReadOutputDataBit(GPIOC,GPIO_Pin_6 );led3_readvalue = GPIO_ReadOutputDataBit(GPIOC,GPIO_Pin_7 );if(led1_readvalue == 0)myudp_send("LED1 \n",8);
elsemyudp_send("LED1 \n",8);
if(led2_readvalue == 0)myudp_send("LED2 \n",8);
elsemyudp_send("LED2 \n",8);
if(led3_readvalue == 0)myudp_send("LED3 \n",8);
elsemyudp_send("LED3 \n",8);
}

/*******************************************************************************

*
*
*
*

函数名: void myudp_send(char *str,short n) 参 数:
返 回:
功 能: UDP 数据包发送

**************************************************************************/void myudp_send(char *str,short n)
{

char *nptr;
nptr = (char *)uip_appdata;
memcpy(nptr, str, n);
uip_udp_send(n); //发送n个数据
}

/*******************************************************************************

*
*
*
*

函数名: void UDP_newdata(void) 参 数:
返 回:
功 能: UDP 数据包发送


**************************************************************************/void server_udp_newdata(void)
{
char *nptr;
shortlen;
len= uip_datalen(); //读取数据长度 nptr= (char *)uip_appdata;
//取得数据起始指针
if(len<4)myudp_send("Pleasecheck the command!\n",26);

else

if(strncmp(nptr,"getname",7)==0)

myudp_send("Board

of

microcreat\n",19);
elseif(strncmp(nptr,"ledon 1",7)==0){
LED1_ON();
myudp_send("LED1\n",8);
}
elseif(strncmp(nptr,"ledon 2",7)==0){
LED2_ON();
myudp_send("LED2\n",8);
}
elseif(strncmp(nptr,"ledon 3",7)==0){
LED3_ON();
myudp_send("LED3\n",8);

}
elseif(strncmp(nptr,"ledoff 1",8)==0){
LED1_OFF();
myudp_send("LED1\n",8);
}
elseif(strncmp(nptr,"ledoff 2",8)==0){
LED2_OFF();
myudp_send("LED2\n",8);
}
elseif(strncmp(nptr,"ledoff 3",8)==0){
LED3_OFF();
myudp_send("LED3\n",8);
}
elseif(strncmp(nptr,"ledpoll",7)==0) led_poll();
elsemyudp_send("Unkown command!\n",16);
}
/*******************************************************************************

*
*
*
*

函数名: void myudp_appcall(void) ) 参 数:
返 回:
功 能: UDP 主函数


**************************************************************************/void server_udp_appcall(void)
{
if(uip_newdata())
{
server_udp_newdata(); } }

3.4系统主程序

voidLED_config(void)
{
GPIO_InitTypeDefGPIO_InitStructure;

RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);

/*LED -> PB1 */
GPIO_InitStructure.GPIO_Pin= GPIO_Pin_1;
GPIO_InitStructure.GPIO_Speed= GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode= GPIO_Mode_Out_PP; GPIO_Init(GPIOA,&GPIO_InitStructure);
}

/***************************************************************************** 称:voidRCC_Configuration(void)
* 能:系统时钟配置为72MHZ,外设时钟配置
*入口参数:无
*出口参数:无
*
明:*调用方法:无
****************************************************************************/void RCC_Configuration(void)
{
// RCC_APB2PeriphClockCmd( RCC_APB2Periph_AFIO , ENABLE); SystemInit();
}

structtimer periodic_timer, arp_timer;

/***************************************************************************** 称:intmain(void)
* 能:程序入口
*入口参数:无

*出口参数:无
* 明:
*调用方法:无
****************************************************************************/int main(void)
{
constuint8_t mac_addr[6] = {0x00,0xe0,0x3d,0xf4,0xdd,0xf7};
inti;
structuip_eth_addr ethaddr;
structtimer t;
DHCP_SUCCESS_FLAG= 0x00;

RCC_Configuration(); //系统时钟设置
LED_config();
Usart1_Init(); //串口1初始化
Usart2_Init();

timer_set(&t,100);

//基本时钟
clock_arch_init();
timer_set(&periodic_timer,CLOCK_SECOND / 2);

timer_set(&arp_timer,CLOCK_SECOND * 10);

/*显示例程Logo*/

printf("****system is run *******\r\n"); //向串口1发送开机字符。

net_inital();

/* 初始化网络设备以及UIP 协议栈,配置IP 地址 */

//应用层MAC初始化

for(i = 0; i < 6; i++)

ethaddr.addr[i]= mac_addr[i];

uip_setethaddr(ethaddr);//UIPMAC 初始化

//UIP初始化

uip_init();

//ARP初始化

uip_arp_init();

dhcpc_init(&mac_addr,6);

/*创建一个TCP监听端口和http监听端口,端口号为120080*/ uip_listen(HTONS(1200));
while(1) uip_listen(HTONS(5005));

{
/*处理uip事件,必须插入到用户程序的循环体中*/

UipPro();

//中断触发读取网络接收缓存

ARP

eth_poll();

//定时查询TCP UDP 连接收发状态

更新,并响应
}
}
/****************************************************************************

*

称:void eth_poll(void)

ARP 表更新, 并响应

*

能:定时查询TCP 连接收发状态

*入口参数:无
*出口参数:无
* 明:
*调用方法:无
****************************************************************************/void eth_poll(void){
unsignedchar i=0;
if(timer_expired(&periodic_timer))

{
if(0x02 == DHCP_SUCCESS_FLAG)
{
led_flag= ~led_flag;

(led_flag== 0x00)
GPIO_WriteBit(GPIOA,GPIO_Pin_1, Bit_SET) ;
GPIO_WriteBit(GPIOA,GPIO_Pin_1, Bit_RESET);
}

timer_reset(&periodic_timer);

/*轮流处理每个TCP连接,UIP_CONNS 缺省是10*/
for(i= 0; i < UIP_CONNS; i++)
{
uip_periodic(i); /*处理TCP通信事件*/
/*
当上面的函数执行后,如果需要发送数据,则全局变量uip_len> 0
需要发送的数据在uip_buf,长度是uip_len (这是2个全局变量)
*/

if(uip_len> 0)
{
uip_arp_out(); //加以太网头结构,在主动连接时可能要构造ARP请求
tapdev_send(); //发送数据到以太网(设备驱动程序) }
}

#ifUIP_UDP
/*轮流处理每个UDP连接,UIP_UDP_CONNS 缺省是10*/
for(i= 0; i < UIP_UDP_CONNS; i++)
{
uip_udp_periodic(i); /*处理UDP通信事件*/
/*如果上面的函数调用导致数据应该被发送出去,全局变量uip_len设定值>0 */
if(uip_len> 0)
{
uip_arp_out(); //加以太网头结构,在主动连接时可能要构造ARP请求
tapdev_send(); //发送数据到以太网(设备驱动程序) }
}

#endif/* UIP_UDP */

/*Call the ARP timer function every 10 seconds. */
if(timer_expired(&arp_timer))
{
timer_reset(&arp_timer);
uip_arp_timer();
}
}
}
/*******************************************************************************

*
*
*
*

函数名:UipPro
输 入:
输 出:
功能说明:中断触发读取网络接收缓存

********************************************************************/void UipPro(void)
{
/*if(ETH_INT==1)*/{ //当网络接收到数据时,会产生中断 rep:;
ETH_INT=0;


uip_len = tapdev_read(); if(uip_len > 0)

//从网络设备读取一个IP ,返回数据长度//收到数据

{
/*处理IP数据包(只有校验通过的IP包才会被接收)*/
if(BUF->type== htons(UIP_ETHTYPE_IP))
{
uip_arp_ipin(); //去除以太网头结构,更新ARP uip_input(); //IP 包处理
/*
当上面的函数执行后,如果需要发送数据,则全局变量uip_len> 0
*/
if(uip_len > 0) //有带外回应数据
{
uip_arp_out();
//加以太网头结构,在主动连接时可能要构造ARP请求
tapdev_send(); //发送数据到以太网(设备驱动程序) }
}
/*处理arp报文*/
elseif (BUF->type == htons(UIP_ETHTYPE_ARP))
//ARP请求包

{
uip_arp_arpin(); /*
当上面的函数执行后,如果需要发送数据,则全局变量uip_len> 0
需要发送的数据在uip_buf,长度是uip_len (这是2个全局变量)
*/
if(uip_len > 0) //ARP请求,要发送回应
{
tapdev_send(); //ARP回应到以太网上
}
}
}
}

//

else{

//防止大包造成接收死机,当没有产生中断,

而中断信号始终为低说明接收死机
// if(ETH_rec_f==0) goto rep;
// }
}

/*******************************************************************************


*
*
*
*

函数名:InitNet
输 入:
输 出:
功能说明:初始化网络硬件、UIP 协议栈、配置本机IP 地址

************************************************************/void net_inital(void)
{
uip_ipaddr_tipaddr;

//

tapdev_init();

//dm9000aep 初始化

uip_init();

//UIP 协议栈初始化

server_udp_flag= SERVER_UDP_NULL;
server_udp_flag= SERVER_UDP_DHCP;

#if1
printf("uipip address : 192,168,1,8\r\n");
uip_ipaddr(ipaddr,192,168,1,8); //设置IP地址
uip_sethostaddr(ipaddr);

printf("uiproute address : 192,168,1,1\r\n");
uip_ipaddr(ipaddr,192,168,1,1); //设置默认路由器IP地址uip_setdraddr(ipaddr);

printf("uipnet mask : 255,255,255,0\r\n");
uip_ipaddr(ipaddr,255,255,255,0); //设置网络掩码 uip_setnetmask(ipaddr);
#endif
}

3.5通信协议程序

uip_listen(HTONS(1200));

while (1)

uip_listen(HTONS(5005));

{
/*处理uip事件,必须插入到用户程序的循环体中*/

UipPro();

//中断触发读取网络接收缓存

ARP

eth_poll();

//定时查询TCP UDP 连接收发状态

更新,并响应
}
}
/****************************************************************************

*

称:void eth_poll(void)

ARP 表更新, 并响应

*

能:定时查询TCP 连接收发状态

*入口参数:无

*出口参数:无
* 明:
*调用方法:无
****************************************************************************/void eth_poll(void){
unsignedchar i=0;
if(timer_expired(&periodic_timer))
{
if(0x02 == DHCP_SUCCESS_FLAG)
{
led_flag= ~led_flag;

(led_flag== 0x00)
GPIO_WriteBit(GPIOA,GPIO_Pin_1, Bit_SET) ; GPIO_WriteBit(GPIOA, GPIO_Pin_1, Bit_RESET);
}

timer_reset(&periodic_timer);

/*轮流处理每个TCP连接,UIP_CONNS 缺省是10*/
for(i= 0; i < UIP_CONNS; i++)
{


uip_periodic(i);

/* 处理TCP 通信事件 */

/*
当上面的函数执行后,如果需要发送数据,则全局变量uip_len> 0
需要发送的数据在uip_buf,长度是uip_len (这是2个全局变量)
*/
if(uip_len> 0)
{
uip_arp_out(); //加以太网头结构,在主动连接时可能要构造ARP请求
tapdev_send(); //发送数据到以太网(设备驱动程序) }
}

#ifUIP_UDP
/*轮流处理每个UDP连接,UIP_UDP_CONNS 缺省是10*/
for(i= 0; i < UIP_UDP_CONNS; i++)
{
uip_udp_periodic(i); /*处理UDP通信事件*/
/*如果上面的函数调用导致数据应该被发送出去,全局变量uip_len设定值>0 */

if(uip_len> 0)
{
uip_arp_out(); //加以太网头结构,在主动连接时可能要构造ARP请求
tapdev_send(); //发送数据到以太网(设备驱动程序) }
}
#endif/* UIP_UDP */

/*Call the ARP timer function every 10 seconds. */
if(timer_expired(&arp_timer))
{
timer_reset(&arp_timer);
uip_arp_timer();
}
}
}
/*******************************************************************************

*
*
*

函数名:UipPro
输 入:
输 出:



*

功能说明:中断触发读取网络接收缓存

********************************************************************/
voidUipPro(void)
{
/*if(ETH_INT==1)*/{ //当网络接收到数据时,会产生中断
rep:;
ETH_INT=0;
uip_len= tapdev_read();
//从网络设备读取一个IP,返回数据长度 if(uip_len> 0) //收到数据
{
/*处理IP数据包(只有校验通过的IP包才会被接收)*/
if(BUF->type== htons(UIP_ETHTYPE_IP))
{
uip_arp_ipin();
//去除以太网头结构,更新ARP uip_input(); //IP 包处理
/*当上面的函数执行后,如果需要发送数据,则全局变量uip_len> 0
需要发送的数据在uip_buf,长度是uip_len (这是2个全局变量)
*/
if(uip_len > 0) //有带外回应数据
{


uip_arp_out();

//加以太网头结构,在主动连接时可能

要构造ARP请求
tapdev_send(); //发送数据到以太网(设备驱动程序) }
}
/*处理arp报文*/
elseif (BUF->type == htons(UIP_ETHTYPE_ARP)) //ARP请求包
{
uip_arp_arpin(); //如是是ARP回应,更新ARP表;如果是请求,构造回应数据包
/*当上面的函数执行后,如果需要发送数据,则全局变量uip_len> 0
需要发送的数据在uip_buf,长度是uip_len (这是2个全局变量)
*/
if(uip_len > 0) //ARP请求,要发送回应
{
tapdev_send(); //ARP回应到以太网上
}
}
}

}

//

else{

//防止大包造成接收死机,当没有产生中断,

而中断信号始终为低说明接收死机
// if(ETH_rec_f==0) goto rep;
// }
}

第四章 系统的程序调试

4.1系统的主程序调试

4.1.1编写程序

根据各个程序模块,编写所需的程序,下面介绍一下用软件KeiluVision4编写过程。

1.运行软件KeiluVision4,进入操作界面,新建工程,单击“Project”出现下拉菜单,单击“NewProject” 弹出创建工程窗口,输入新建工程名称,然后保存,弹出窗口图4.1,选择CPU的类型为ARMCortex M3,该工程建立成功。

4.1新建工程

2.在新的工程里,单击,出现文本“Text1”,在文本中编写主程序如图4.2,编写完成后,单击保存,在文件名中输入“main.c”,保存该程序。

4.2编写主程序

3.完成所有程序后,将对其编译和连接,查看有没有错误存在。单击,对所有的程序进行编译和连接,结果在“Build”里,如图4.3所示

4.3编译和连接

4.1.2烧写代码下载

在“project”中选择“options for target target1”,在界面中选择“Debug”,设置“Cortex-M3J-Link”之后创建,将烧写速度选择2MHZ,如图4.4所示。打开“Utilities”,选择“Cortex-M3J-Link”,点击“setting”,如图5所示。最后在“Flash”里“download”进行烧写代码的下载,将代码下载到开发板。

4.4 设置烧写速度

4.5下载代码

4.2系统硬件连接

电脑和转接板连在同一个路由器上,转接板接在开发板3V接口上,将开发板接通电源,并打开开关,设置电脑IP地址,打开网络调试助手,设置协议类型,本地端口号并连接,设置目标主机IP地址和目标端口,设置完毕后,通过在网络调试助手上发布命令来实现对小灯的控制。

4.3系统调试结果

4.6 小灯显示结果

4.7网络助手显示结果

第五章毕业设计总结

在的学习过程中,毕业设计是一个重要的环节,是我们步入社会参与实

际项目的规划建设的一次极好的演示.毕业设计是四年学习的总结和提高,和做

科研开发工作一样,要有严谨求实的科学态度。毕业设计有一定的学术价值和实

用价值,能反映出作者所具有的专业基础知识和分析解决问题的能力。此次毕业

设计是我们从毕业生走向未来工作重要的一步。从最初的选题,开题到分析

调查、绘图直到完成设计。其间,查找资料,老师指导,与同学交流,反复修改,

每一个过程都是对自己能力的一次检验和充实。在毕业设计期间,尽可能多的阅

读文献资料是很重要的,一方面是为毕业设计做技术准备,另一方面是学习做毕

业设计的方法。一次优秀的设计对启发我们的思维,掌握设计的规范、流程、具

体操作都很有帮助。但是毕业设计也暴露出自己专业基础的很多不足之处。比如

缺乏综合应用专业知识的能力,对设备的不了解,对具体设计涉及到的规范要求

的不熟悉等等,需要在做的过程中需要去不断的翻阅相关的资料和书籍,这降低

了自己的速度和设计的进程,但这个过程对我来说是对自己知识的不足处的一个

很好的补充和对已学过知识的一个巩固,在、以及自己的不断努力下,

不怕麻烦,不怕重复,当克服了这些问题之后,我会感觉到自己的知识在一点一

滴地积累,不知不觉中增加。我相信,只要肯钻研,只要挤时间,一切自己想要

的知识都可以掌握。这个过程虽然是有一定的难度,但自己还是慢慢的摸索,也

在老师的指导下从熟悉到上手,经过这次努力对自己的信心很好的提高。

通过这样的一个自己从开始到结束全程自己参与的设计来说对知识的了解

和掌握是纯理论的学习远远达不到的效果。这次实践是对自己四年所学的一

次大检阅,使我明白自己知识还很浅薄,虽然马上要毕业了,但是自己的求学之

路还很长,以后更应该在工作习,努力使自己成为一个可以参与工作能

完成设计的人。最后顺利的完成这次毕业设计,为自己的生涯画上一个完美

的句号。

致谢

本次毕业设计的完成,得益于所有直接和间接给过我帮助的人,我要感谢他

们。

首先我要感谢我的毕业设计辅导老师陈松老师,我的毕业设计是在他的亲切

关怀和悉心指导下完成的。陈老师在我毕业设计的过程中给了我充分的指导和帮

助,并且在确定研究方案和收集有关资料时也给了我很大的帮助。在毕业设计过

程中理清了我的毕业设计思路,扫除了我的毕业设计障碍,修改了我毕业设计中

的不足之处,尤其软件学习当中给了我莫大的帮助,陈老师的博学和严谨的科研

态度使我受益匪浅,在此谨向陈老师崇高的敬意和衷心的感谢。

其次,我要感谢我的同学,他们在我毕业设计过程中给了提供过许多有意义

的资料,他们教会了我许多解决问题的方法,使我能够从容的面对困难,克服困

难。

最后,我要感谢大学里所有教过我的老师,感谢他们在这四年当中对我殷切

教导和做人方面的潜移默化的影响。我要感谢大学期间所有结识的朋友,是你们

使我拥有了美好的大学时光!

参考文献

[1]康华光.电子技术基础,模拟部分5[M].等教育出版社,2006.5
[3]王骅.浅谈4线电阻触摸屏和stm32的接口实现[J].中国高新技术企业,2009.11
[4]谭浩强.C程序设计(4)[M].北京:清华大学出版社,2010.6
[5]周润景.基于PROTEUS的电路及单片机设计与仿真(2)[M].北京航空航天大学出版社,2010.1
[6]彭伟.单片机C语言程序设计实训100:基于8051+Proteus仿真[M].电子工业出版社,2009.6
[7]隋宗强.基于STM32单片机的EMS液晶显示触摸屏设计[D].青岛大学硕士,2012.04
[8]朱志国.RT-Thread操作系统在STM32中移植的研究[J].计算机光盘软件与应用,2012.11
[9]吴宇翔.基于RT-ThreadSTM32的数码相框的设计[J].电子世界,2013.09 [10]谈卫星.全彩色LED显示屏系统的设计与实现[D].杭州电子科技大学,2010.12

附录一:
STM32电路原理图

DM9000电路原理图和驱动电路原理图

附录二:英文资料和译文

英文资料:

Rainbow:

Architecture-Based

Self-Adaptation

with

Reusable

Infrastructure
HuaLiu and Manish Parashar
TheApplied Software Systems Laboratory
Deptof Electrical and Computer Engineering, Rutgers University,Piscataway, NJ088,USA
Email:{marialiu,parashar}@caip.rutgers.edu
SalimHariri

Departmentof Electrical and Computer Engineering, University of Arizona, AZ,USA
Email:hariri@ece.arizon.edu

Abstract
The Rainbow framework uses software architectures and a reusableinfrastructure to support self-adaptation of software systems. Theuse of external adaptation mechanisms allows the explicitspecification of adaptation strategies for multiple system concerns.

1.Introduction
Software-basedsystems today increasingly operate in changing environments withvariable user needs, resulting in the continued increase inadministrative overhead for managing these systems. To reduce thesecosts, systems are increasingly expected todynamically self-adapt toaccommodate resource variability, changing user needs, and systemfaults.Mechanisms that support self-adaptation currently exist in theform of programming language features such as exceptions and inalgorithms such as fault-tolerant protocols. But these mechanisms areoften highly specific to the application and tightly bound to thecode. As a result, self-adaptation in today’s systems is costly tobuild, difficult to modify, and usually provides only localized

treatmentof system faults.In contrast to these internal mechanisms, recentwork uses external models and mechanisms in a closed-loop controlfashion to achieve various goals
bymonitoring and adapting system behavior at run-time. 1,2 Asillustrated in Figure 1, control of system adaptation becomes theresponsibility of components outside the system that is beingadapted.In principle, external control mechanisms provide a moreeffective engineering solution than internal mechanisms forself-adaptation because they localize the concerns of problemdetection andre solution in separable modules that can be analyzed,modified, extended, and reused across different systems.Additionally, developers can use this approach to add self-adaptationto legacy systems for which the source code may not be available.Thisexternal approach requires using an appropriate model to reason aboutthe system’s dynamic behavior. Several researchers have proposedusing architectural models, 3 which represent the system
asa gross composition of components, their inter-connections, and theirproperties of interest. 4 Such an architecture-based self-adaptationapproach offers many benefits. Most significantly, an abstractarchitectural model can provide a global perspective of the systemand expose important system-level properties and integrityconstraints.While attractive in principle, architecture-based
self-adaptationraises a number of research and engineering challenges.

First,the ability to handle a wide variety of systems must be addressed.Since different systems have radically different architecural styles,properties of interest, and mechanisms supporting dynamicmodification, it is critical that the architectural control model andmodification strategies be tailored to the specific system.Second,the need to reduce costs in adding external control to asystem must be addressed. Creating the monitoring, modeling, andproblem-detection mechanisms from scratch for each new system wouldrender the approach prohibitively expensive.Our Rainbow frameworkattempts to address both problems. By adopting an architecture-basedapproach, it provides reusable infrastructure together withmechanisms for specializing that infrastructure to the needs ofspecific systems. These specialization mechanisms let the developerof self-adaptation capabilities choose what aspects of the system tomodel and monitor, what conditions should trigger adaptation, and howto adapt the system.

2.THERAINBOW FRAMEWOR
Figure2 shows the Rainbow framework’s control loop for self-adaptation.

Rainbowuses an
abstractarchitectural model to monitor an executing system’s runtimeproperties, evaluates the
modelfor constraint violation, and—if a problem occurs—performsglobal- and module-level adaptations on the running system.

Softwarearchitectures Rainbow adopts a standard view of software architecturethat is typically used today at design time to characterize a systemto be built. Specifically, an architecture is represented as a graphof interacting computational elements. 4 Nodes in the graph, calledcomponents, represent the system’s principal computational elementsand data stores,including clients, servers, databases, and userinter-faces. Arcs, called connectors, represent the path-
waysfor interaction between the components.Additionally, architecturalelements may be annotated with various properties, such as expectedthrough puts, latencies, and protocols of interaction. Componentsthemselves may represent complex systems, which are representedhierarchically as subarchitectures.However, unlike traditional usesof software architecture as strictly a design-time artifact,Rainbowincludes a system’s architectural modelin its run time system. Inparticular, developers of self-adaptation capabilities use a system’ssoftware
architecturalmodel to monitor and reason about the system. Using a system’sarchitecture as a control model for self-adaptation holds promise inseveral areas. As an abstract model, an architecture can provide aglobal perspective of the system and expose important system-levelbehaviors and properties. As a locus of high-level system designdecisions, an architectural model can make a system’s topologicaland behavioral constraints explicit,establishing an envelope ofallowed changes and helping to ensure

thevalidity of a change.

Figure3 shows one example of an architecture in which the componentsrepresent Web clients and
serverclusters. Each server cluster has a subarchi-System Control AdaptMonitor Figure 1. External control of self-adaptation uses externalmodels to monitor and modify a system dynamically. Translationinfrastructure Executing system Architecture layer System APIConstraint evaluator Adaptation engine Model manager MappingsStrategies and tactics Rules Adaptation executor Types and propertiesSystem layer Operators Discovery Probes Resource discovery EffectorsGauges Figure 2. Rainbow framework. The framework uses an abstractmodel to monitor an executing system’s run time properties,evaluates the model for constraint violation, and—if a problemoccurs—performs adaptations on the running system.Client1 Client2Client3 Client4 Client5 Client6ServerGrp2 ServerGrp3ComponentServerGrp1 (ServerGrpRep)ServerGrp1Server3 Server2 Server1Figure 3.Client-server system software architecture. This model representsthear

chitecture

as

a

hierarchical

graph

of

interacting

components.Computerectureconsisting of one or more server components. This architectural modelprovides a global perspective on the system by revealing all thecomponents and how they connect. The model also contains importantproperties such as each server’s load, each connection’sbandwidth, and the response time experienced by each client.Further,the

modelmaintains explicit constraints on the architecture that, for example,require each client to connect to exactly one server cluster. Theconstraints establish an envelope of allowed changes such as ensuringthat no future changes to the system leave a client dangling withouta connection. A system change is valid only if the system satisfiesthe constraints after the change.

ReusableRainbow units To fulfill Rainbow’s objectives, its variouscomponents must be reusable from system to system. To identify whatparts of the framework are reusable,and under what circumstances, wedivide the frame-work into an adaptation infrastructure and thesystem-specific adaptation knowledge. The adaptation infrastructure,divided into system, architecture, and
translationlayers, provides common functionalities across self-adapting systemsand is therefore reusable across all systems, while the adaptation

knowledge

itself

is

typically

system-specific

(Figure

2).System-layer

infrastructure.At this layer, we have defined the system access interface and builtan nfrastructure that implements it. A system measurement mechanism,realized as probes, observes and measures various system states. Thislow-level system information can be published by or queried from theprobes. Additionally, a resource discovery mechanism can be queriedfor new resources based on resource type and other criteria.Finally,an effector

mechanismcarries out the actual system modification.Architecture-layerinfrastructure. At this layer,gauges aggregate information from theprobes and update the appropriate properties in the architecturalmodel. A model manager handles and provides access to the system’sarchitectural model. A con-
straintevaluator checks the model periodically andriggers adaptation if aconstraint violation occurs.An adaptation engine then determines thecourse of action and carries out the necessary adaptation.Translationinfrastructure. This infrastructure helps mediate the mapping ofinformation across the abstraction gap from the system to the modeland vice ver sa. A translation repository within the infra-structuremaintains various mappings that the translator components share, forexample, to trans-late an architectural-level element identifier intoanIP address or an architectural-level change

opera-tor

into

system-level

operations.System-specific

adaptation

knowledge.Adding self-adaptation to a system using the function alities thatthe adaptation infrastructure provides requires using thesystem-specific adaptation knowledge to tailor that infrastructure.This knowledge includes the target system’s operational model,which defines parameters such as component types and properties,behavioral constraints, and adaptation strategies.Architectural styleWhile reusable infrastructure helps reduce the costs of addingself-adaptation to systems, it is also possible to leveragecommonalities in system architecture to encapsulate adaptationknowledge

forvarious system classes.To capture system commonalities, Rainbowadapts the notion of an architectural style. Traditionally, thesoftware engineering community has used architectural styles to helpencode and express system-specific knowledge. 5 An architecturalstyle characterizes a family of systems related by shared structuraland semantic properties. The style is typically defined by four setsof entities:Component and connector types provide a vocabulary ofelements, including components such as Database, Client, Server, andFilter;connectors such as SQL, HTTP, RPC, and Pipe; and component andconnector interfaces.

Constraintsdetermine the permitted composition of the elements instantiated fromthe types. For example, constraints might prohibit cycles in aparticular pipe-filter style, or define a compositional pattern suchas the starfish arrangement of a blackboard system or a compiler’spipelined decomposition.• Propertiesare attributes of the componentandconnector types, and provide analytic, behavioral, or semanticinformation. For example,load and service time properties might becharacteristic of servers in a performance-specificlient-serverstyle, while transfer-rate might bea property in a pipe-filterstyle.• Analysescan be performed on systems built inan appropriatearchitectural style. Examples nclude performance analysis usingqueuing theory in a client-server system, and schedul abilityanalysis for a real-time-oriented style.

Thesefour entity sets primarily capture a system’s static attributes.Rainbow extends this notion of architectural style to support runtime adaptation by also capturing the system’s dynamic attributes,both in terms of the primitive operations that can be performed onthe system to change it dynamically, and how the system can combinehose operations to achieve some effect. Specifically,it augments thenotion of architectural style with adaptation operator sandstrategies, which together determine the system’s adaptation style.

Adaptationoperators determine a set of style-specific actions that the controlinfrastructure
canperform on a system’s elements to alter its configuration. Forexample, a service coalition
stylemight define the operators Add Service or Remove Service to add or



【正确答案】ABCE

17.火灾危险环境分类的说法中正确的是()。

A.具有闪点高于环境温度的可燃液体,在数量和配置上能引起火灾危险的环境,应划为火灾危险21
B.具有悬浮状、堆积状的可燃粉尘或纤维,虽不可能形成爆炸混合物,但在数量和配置上能引起火灾危险的环境,应划为火灾危险21
C.具有闪点高于环境温度的可燃液体,在数量和配置上能引起火灾危险的环境,应划为火灾危险22
D.具有悬浮状、堆积状的可燃粉尘或纤维,虽不可能形成爆炸混合物,但在数量和配置上能引起火灾危险的环境,应划为火灾危险22
E.具有固体状可燃物质,在数量和配置上能引起火灾危险的环境,应划为火灾危险23

【正确答案】ADE

18.在木材加工过程中,刀轴转速高、自动化水平低,存在较多危险因素下列关于安全技术措施的说法中,正确的有()
A.木工机械的刀轴与电器应有安全联控装置
B.圆锯机上应安设分离刀和活动防护罩
C.刨床采用开有小孔的定位垫片降低噪声
D.手压平刨刀轴必须使用方刀轴
E.带锯机应装设锯盘制动控制器

【正确答案】ABCE



19.人与机器的功能和特性在很多方面有着显著的不同,为充分发挥各自的优点,需要进行人机功能的合理分配。下列工作中,适合机器完成的有()。

A.精度高、高价运算
B.操作复杂、环境条件差
C.笨重、持久
D.快速、维修
E.单调性、规律性

【正确答案】ABCE

20.在无法通过设计达到本质安全时,为了消除危险,应补充设计安全装置:设计安全装置时必须考虑的因素有( )。

A.有足够的强度、刚度和耐久性
B.不能影响机器运行的可靠性
C.不应影响对机器危险部位的可视性
D.一律用绝缘材料制作
E.一律用金属材料制作

【正确答案】ABC

21.以下()属于锅炉的工作特性。



A.安装笨重性
B.爆炸危害性
C.易于损坏性
D.使用的广泛性
E.连续运行性

【正确答案】BCDE

22.工业生产过程中,存在着多种引起火灾和爆炸的着火源。化工企业中常见的着火源有( )。

A.化学反应热、原料分解自燃、热辐射
B.高温表面、摩擦和撞击、绝热压缩
C.电气设备及线路的过热和火花、静电放电D.明火、雷击和日光照射
E.粉尘自燃、电磁感应放电

【正确答案】ABCD

23.锻造是一种利用锻压机械对金属坯料施加压力,使其产生塑性变形以获得具有一定机械性能,一定形状和尺寸的加工方法。锻造的主要设备有锻锻锤、压力机、加热炉等。下列关于锻造生产危险有害因素的说法中,正确的是()

A.机械伤害包括锻锤锤头的击伤、打飞的锻件伤人、冲头打崩伤人B.红热的坯料、锻件、飞溅的氧化皮均可造成火灾爆炸事故
C.红热的坯料、锻件、飞溅的氧化皮均可造成灼烫事故
D.锻锤的巨大冲击力产生的噪声和振动

因篇幅问题不能全部显示,请点此查看更多更全内容

Copyright © 2019- how234.cn 版权所有 赣ICP备2023008801号-2

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务