用Rhapsody和UML开发导航控制

合集下载

模型驱动的嵌入式系统设计

模型驱动的嵌入式系统设计

空间控制技术与应用Aerospace Con tro l and Applicati o n 第34卷 第1期2008年2月模型驱动的嵌入式系统设计吴一帆,张毅玲,周世安(北京控制工程研究所,北京100080)摘 要:随着嵌入式系统设计周期越来越短,功能越来越复杂,越来越多领域的设计人员参与设计,市场需求导向致使需求变更越来越多,以传统文档形式的需求来驱动开发已根本不能满足时间和成本方面的要求。

本文提出了采用可执行模型、动态需求规格和接口控制文档共同作用的驱动嵌入式系统设计方法,它能够较好地满足目前系统设计的要求。

在文中,我们首先介绍了当前嵌入式系统设计中存在的一些问题,然后介绍了模型驱动设计的方法、语言和优点,并对动态需求规格和接口控制文档的执行给出了建议,最后得出模型驱动的嵌入式系统设计是一种行之有效途径的结论。

关键词:模型驱动;统一建模语言;动态需求规格;接口控制文档中图分类号:TP3 文献标识码:A 文章编号:1674 1579(2008)01 0060 05M ode lD ri ven Em bedded Sy ste m D eve l op m entWU Y ifan,Z HANG Y ili n g ,ZHOU Sh ian(B eijing Institute o f Control Engineeri n g,B eijing 100080,China)Abst ract :This paper presen ts a m e t h od for developm ent of e m bedded syste m s .It addresses issues ho w to desi g n a m ulti technolog ies syste m w ith he l p o fm ode,l specs and interface contro l docum ents(I C D ).Theex isti n g proble m s w ith the desi g n are first analyzed .Then the paper addresses the issues that m ode,l acti v e specs and I CD can drive the deve l o pm ent o f e m bedded syste m s effectively during t h e design phase .F i n all y ,so m e usef u l conclusions for t h e e m bedded syste m developm en t driven by m odel are g i v en .K eyw ords :m ode l dri v en ;UM L ;active spec ;I CD收稿日期:2007 12 09作者简介:吴一帆(1972-),男,四川人,高级工程师,研究方向为电子线路设计(e ma i:l w uy @f bice .org .cn)。

UML类图中关联关系的三种导航方式

UML类图中关联关系的三种导航方式

UML类图中关联关系的三种导航方式在软件开发中,UML(统一建模语言)类图是一种常用的建模工具,用于描述系统中的类和它们之间的关系。

其中,关联关系是类图中最基本的一种关系,描述了类之间的连接。

在关联关系中,导航方式是指一个类如何访问与之相关联的其他类的对象。

在UML类图中,有三种常见的导航方式:单向导航、双向导航和自关联导航。

1. 单向导航单向导航是指一个类可以访问与之关联的其他类的对象,而被关联的类不能直接访问该类的对象。

这种导航方式常见于一对多的关联关系,其中一个类是主导类,而另一个类是从属类。

举个例子,考虑一个图书馆管理系统,图书馆类与图书类之间存在一种关联关系,一个图书馆可以管理多本图书。

在这种情况下,图书馆类可以通过关联关系访问图书类的对象,但是图书类无法直接访问图书馆类的对象。

2. 双向导航双向导航是指两个类可以互相访问对方的对象。

这种导航方式常见于一对一或多对多的关联关系,其中两个类都可以主动访问对方的对象。

继续以图书馆管理系统为例,考虑一个借阅记录类与读者类之间的关联关系。

一个借阅记录可以关联一个读者,同时一个读者也可以关联多个借阅记录。

在这种情况下,借阅记录类和读者类可以通过关联关系互相访问对方的对象。

双向导航可以提供更灵活的访问方式,但也需要注意双向关联的管理和维护。

在设计时,需要考虑到两个类之间的依赖关系和业务逻辑,避免出现循环依赖或不一致的情况。

3. 自关联导航自关联导航是指一个类与自身存在关联关系,可以访问自身的对象。

这种导航方式常见于树状结构或层级结构的模型。

举个例子,考虑一个组织机构管理系统,组织类与自身存在一种关联关系,一个组织可以包含多个子组织。

在这种情况下,组织类可以通过关联关系访问自身的对象,实现对组织结构的层级管理。

自关联导航可以用于描述递归结构或层级结构,提供了一种方便的方式来处理复杂的关系。

但是,在使用自关联导航时需要注意循环引用的问题,避免出现无限循环或死循环的情况。

rhapsody简介

rhapsody简介
apsody提供直观的需求捕获视图和多种需求定义与描述方式。同时,能够对需求的覆盖和需求的变更情况进行分析,并通过模拟、执行和动画演示的方式对模型的正确性加以验证,最终生成可执行的完整应用程序。
“Rhapsody关注实时系统,它通过可执行的实时框架实现了模型的平台无关性。”任群力说。他指出,实时框架是设计模型的集成集合,能够对开发嵌入式应用程序进行针对性优化。在自动合并应用程序的过程中,Rhapsody将生成代码、任何遗留代码、第三方库和其他模型组件都合并到一个构建环境中,实时框架便是其中的关键。
rhapsody简介
类别:模型驱动开发
Telelogic公司在2006年3月收购I-Logix公司后,推出的新版嵌入式软件建模工具Rhapsody(中文释义为“狂想曲”),在用户和软件开发商中赢得了非常高的部署满意度。用户覆盖航空航天、汽车、医疗、制造、电信等行业。
2007年第三季度,Rhapsody领衔的模型产品系列在全球获得了13%的增长率。在中国市场,Rhapsody的销售额和应用范围也有了大规模的拓展。目前,基于协作与SysML/UML 2.0的Rhapsody模型驱动开发环境正进入成熟应用时期。
作为一个完整的、基于模型开发的解决方案,Rhapsody扮演着连接嵌入式软件和UML桥梁的角色,赋予了使用者基于UML 2.0进行可视化建模的能力。
Telelogic中国区总监任群力指出,Rhapsody向开发者提供了一个高效、灵活的开发环境,在这里,开发者可以创建跟踪链接、自动生成跟踪文档,并且从多个源导入开发需求,具有对软件完整生命周期的跟踪能力。
Rhapsody的平台无关性视图可以使用通用的建模语言,目前Rhapsody支持C++、C、Ada和Java作为文本语言,同时Rhapsody还提供根据规则生成代码的选项,以便根据客户需要使用不同的编程语言生成程序。

基于嵌入式系统框架的星载相控阵信号处理架构设计方法[发明专利]

基于嵌入式系统框架的星载相控阵信号处理架构设计方法[发明专利]

专利名称:基于嵌入式系统框架的星载相控阵信号处理架构设计方法
专利类型:发明专利
发明人:朱杰斌,许彦章,高路
申请号:CN201310436879.X
申请日:20130924
公开号:CN103473426A
公开日:
20131225
专利内容由知识产权出版社提供
摘要:一种基于嵌入式系统框架的星载相控阵信号处理架构设计方法,将信号处理的硬件架构进行功能的划分,分成数据处理模块和控制通信模块,利用统一建模语言UML建立状态控制处理器的状态控制流程,充分利用Rhapsody的中断驱动框架的状态跳转优势,将星载相控阵雷达处理机的功能进行状态分解,同时将状态跳转和数据处理分离,充分利用面向对象的思想,实现数据处理的流水形式,提高了数据处理速度,同时提高了代码的可维护性,可扩展性和可移植性。

申请人:上海无线电设备研究所
地址:200090 上海市杨浦区黎平路203号
国籍:CN
代理机构:上海信好专利代理事务所(普通合伙)
更多信息请下载全文后查看。

UML原理与应用

UML原理与应用

UML原理与应用UML(Unified Modeling Language)是一种标准的图形化建模语言,它提供了一套丰富的符号和构造,用于描述软件系统的结构、行为和交互。

UML不仅仅是一种用于建模的语言,更是一种软件工程中的艺术和科学。

它的设计原则是简洁、直观和易于理解,适用于各种软件开发方法和过程。

UML的核心概念主要包括结构图和行为图。

结构图用于描述系统的静态结构,其中最常使用的是类图、对象图和组件图。

类图描述了系统中的对象和它们之间的关系,其中包括类、接口、关联、继承、依赖等元素。

对象图是类图的实例化,用于描述系统中的具体对象和对象之间的关系。

组件图则描述了系统中的组件和组件之间的关系,可以用于描述系统的模块化结构。

行为图用于描述系统的动态行为,其中最常使用的是用例图、活动图和状态图。

用例图用于描述系统的功能需求,其中包括参与者、用例、关联关系等元素。

活动图描述了系统中的控制流程和并发行为,可以用于描述系统的业务流程、算法等。

状态图描述系统中对象的状态转换和事件触发的流程,可以用于描述系统的状态变化和状态机制。

UML不仅仅可以用于系统设计和分析,还可以用于系统开发的各个阶段,包括需求分析、设计、编码和测试等。

在需求分析阶段,可以使用用例图和活动图来描述系统的功能需求和业务流程。

在设计阶段,可以使用类图和组件图来描述系统的结构和模块化设计。

在编码阶段,可以使用类图来实现系统的类和对象,并通过序列图来描述类之间的交互。

在测试阶段,可以使用状态图来描述系统的状态变化和状态转换的测试用例。

除了用于系统开发的各个阶段,UML还可以应用于系统维护和演化。

通过使用UML建模工具,可以方便地对系统进行分析和改进。

比如在系统维护阶段,可以使用类图来识别系统中的代码重复和耦合,从而进行代码重构。

在系统演化阶段,可以使用组件图来识别系统中的模块,从而进行模块化的重构。

总之,UML是一种广泛应用于软件工程的建模语言,它提供了一套丰富的图形符号和构造,用于描述软件系统的结构和行为。

Rhapsody和UML实时系统开发培训

Rhapsody和UML实时系统开发培训

Rhapsody和UML实时系统开发培训训练介绍随着时代的发展,嵌入式实时系统的应用越来越丰富,复杂度越来越高,而且嵌入式实时系统往往用于涉及人类生命安全的领域,对质量的要求远比企业应用要高,对系统做全方位的建模,就有了必要性;而且,嵌入式实时系统往往个头较小,全方位的建模也就有了可能性。

Rational Rhapsody工具强大的模型驱动开发能力,能大大提高软件的质量以及减少开发人员的工作量。

本训练就是教授给开发团队如何使用Rhapsody工具以及UML2.x相关的需求和设计技能来全程实作一个实时系统的过程。

本训练秉行UMLChina一贯的“聚焦最后一公里”原则,【训练过程中,专家当场和团队一起讨论和研究团队的当前项目,一起把所授知识当场应用到团队的当前项目,得到团队当前项目的模型】,目标明确,效果明显。

训练目标通过大量练习和项目实践,使开发团队真正理解如何结合用例、类图、结构图、序列图、状态图等UML要素以及Rhapsody建模工具来完成需求和设计工作,能在项目开发中灵活应用。

【主办单位】中国电子标准协会【协办单位】深圳市威硕企业管理咨询有限公司训练时间:4天,每天7小时(9:00-12:00,13:30-17:30)。

训练方式针对每个工作流(需求、分析、设计)循环以下步骤1-51. 老师将先作知识和建模要点讲解。

2. 老师演示如何根据要点实作UMLChina案例项目3. 老师演示如何根据要点实作客户的一个当前项目。

4 学员根据要点实作一个自己当前正在做的项目。

5 老师检查学员实作结果,和大家讨论,指出其中错误和改进要点,修改出正确结果。

*自训练结束开始,提供一年的免费Email、MSN、QQ答疑。

训练大纲1. 概论--利润=需求-设计--软件开发核心工作流--UML的意义--UML图形概览--实时系统的模型驱动开发-- IBM Rational Rhapsody介绍2. 需求--系统的愿景--系统的涉众利益--示范和分组实作:愿景和涉众利益--用例图元素讲解--识别系统执行者--识别系统用例--示范和分组实作:绘制系统用例图--识别用例包含的各种需求--编写用例规约--示范和分组实作:编写用例规约--通过用例关系整理用例规约--用例的分包--通过业务建模来推导需求--业务建模对嵌入式系统的意义--需求的跟踪、变更和管理3. 分析设计(1)--分析和设计的区别--关键抽象和若即若离的思考力--识别类及其属性--识别泛化关系--识别关联--特殊关联:聚合和组合--思考关联的方向--关联和泛化的转换--示范和分组实作:绘制类图--类图和代码的映射--彩色建模架构型--彩色建模在类建模上的应用--结构图元素讲解--示范:绘制结构图--结构图和代码的映射4. 分析设计(2)--序列图元素讲解--消息的各种特征--用例、类图、序列图的互动--分配用例规约的责任--专家原则和单一责任原则--老板原则和聚合根--可视原则--彩色建模的责任协作模式--示范和分组实作:绘制序列图--比较序列图--序列图之间的引用--序列图和代码的映射--调试序列图--协作图(通信图)元素讲解--示范:绘制协作图5. 分析设计(3)--状态图、类图、序列图的映射--状态和转换--正交状态--进入和退出动作--内部转换--历史状态--行为复用和层次嵌套状态--分层设计思路--转换执行序列--示范和分组实作:绘制状态图--状态机的各种实现模式--状态图和代码的映射--调试状态图--活动图元素讲解--示范:绘制活动图6. 分析设计(4)--对象执行框架 (OXF)--OXF、OSAL和RTOS之间的机制-- OXF的组织方式--实现活动类、反应类--实现事件处理(OMEvent、OMTimeout、OMThread...)--实现状态机--实现并发控制和资源保护--实现内存管理--定制Rhapsody模型的代码生成--代码的双向工程--复用遗留代码--组件图元素讲解--示范:绘制组件图--部署图元素讲解--示范:绘制部署图--面板图元素讲解--示范:绘制面板图7. 改进指南--根据团队情况改进--小步前进--正确的改进心态以上时间分配会根据项目特点和训练进程调整。

使用Rhapsody软件框架和UML的实时系统开发

使用Rhapsody软件框架和UML的实时系统开发摘要:UML已成为复杂系统建模的工业标准,并可借助代码自动生成工具实现从分析到编码的开发过程自动化。

而实时系统的行为特征可以很好地用UML的状态机表示,从而成为自动代码生成、测试、分析和校验的最佳选择。

Ilogix公司的Rhapsody是一个基于UML支持模型驱动开发的CASE工具,它使用一套为实时系统量身打造的软件框架实现实时系统软件的开发自动化。

关键词:实时系统 UML Rhapsody 状态机引言面向对象的软件设计方法推崇抽象、可重用且易维护的设计模式。

其中,一个普遍采用的做法是使用预定义的框架构建复杂的软件系统。

在面向对象领域中,框架是指为某一具体应用领域提供解决方案的类集。

程序员使用继承、聚合等技术定制框架并将其用于具体的应用程序设计。

基于框架的软件开发具有如下优点*由于重用了框架提供的代码,目标系统不必从头写起;*规范的框架结构能够指导目标系统的设计;*框架的设计是开放的,因此可以通过子类化等技术定制和扩展。

本文介绍Rhapsody的实时代码生成策略。

Ilogix公司提供的Rhapsody是一个基于UML支持实时嵌入式系统全过程面向对象开发的CASE工具。

Rhapsody基于一个内置的实时系统软件框架—OXF生成C/C++代码。

1 Rhapsody的软件框架Rhapsody的OXF框架专为实时嵌入式系统而设计,它由一系列UML类组成。

这些类相互协作,组成了一个结构严整、跨实时操作系统平台的实时嵌入式软件架构。

活动类活动对象在UML中被定义为“拥有一个线程并能够发起控制活动的对象”。

Rhapsody给这个一般定义赋予了具体含义,如图1所示。

活动类在框架中以OXFActive表示,它拥有一个执行线程和一个事件队列,并提供事件调度功能。

用户活动类从OXFActive继承。

该活动类包装了实时系统中的事件调度器。

Execute方法是一个无限循环。

13种uml简介、工具及示例

13种uml简介、工具及示例UML(Unified Modeling Language)是一种用于软件开发的标准化建模语言,它使用图形表示法来描述软件系统的不同方面。

在软件开发过程中,使用UML可以帮助开发人员更清晰地理解系统的结构和行为,从而更好地进行设计和实现。

UML提供了包括结构模型、行为模型和交互模型在内的多种建模方式,其中每种模型都有各自的符号和语法规则。

通过使用这些模型,开发人员可以将系统分解成不同的部分,然后逐步细化这些部分的设计,以便更好地组织和管理项目。

在UML中,最常用的建模元素包括用例图、类图、时序图、活动图、状态图等。

每种图表都有其特定的用途和表达能力,开发人员可以根据实际需要选择合适的图表进行建模。

除了建模元素外,UML还定义了一系列的建模工具,这些工具可以帮助开发人员更高效地进行建模和分析。

其中一些常用的建模工具包括Enterprise Architect、Rational Rose、StarUML等。

下面将对13种UML简介、工具及示例进行详细介绍:1. 用例图(Use Case Diagram)用例图是UML中描述系统功能和用户交互的基本图表之一。

它用椭圆表示用例,用直线连接用例和参与者,展示了系统外部用户和系统之间的交互。

用例图可以帮助开发人员更清晰地理解系统的功能需求,从而指导系统的设计和实现。

示例:一个简单的在线购物系统的用例图包括用例“浏览商品”、“添加商品到购物车”、“提交订单”等,以及参与者“顾客”和“管理员”。

2. 类图(Class Diagram)类图是UML中描述系统结构和静态关系的基本图表之一。

它用矩形表示类,用线连接类之间的关系,包括关联关系、聚合关系、继承关系等。

类图可以帮助开发人员更清晰地理解系统的对象结构和类之间的关系,从而支持系统的设计和重构。

示例:一个简单的学生信息管理系统的类图包括类“学生”、“课程”、“教师”等,以及它们之间的关系如“选修”、“授课”等。

UML类图中关联关系的导航方式与选择原则

UML类图中关联关系的导航方式与选择原则在软件开发中,UML(统一建模语言)类图是一种常用的工具,用于描述系统的结构和行为。

在类图中,关联关系是一种重要的元素,用于表示类之间的连接和依赖。

本文将探讨关联关系的导航方式和选择原则。

一、关联关系的导航方式1. 单向导航单向导航是指关联关系中的一方可以访问另一方,而另一方不能访问该方。

这种导航方式常见于一对多的关联关系,其中一方充当“一”的角色,另一方充当“多”的角色。

例如,在一个图书馆管理系统中,每本图书都属于某个图书馆,但是图书馆并不需要知道哪些图书属于它,因此图书类可以通过图书馆类进行导航,而图书馆类无需导航到具体的图书。

2. 双向导航双向导航是指关联关系中的两方可以相互访问对方。

这种导航方式常见于一对一或多对多的关联关系。

例如,在一个学生和课程的关联关系中,学生可以访问所选的课程,而课程也可以访问选择该课程的学生。

这样的导航方式可以方便地获取相关对象的信息,提高系统的灵活性和效率。

二、关联关系的选择原则1. 考虑业务需求在选择关联关系时,首先要考虑业务需求。

关联关系应该能够准确地表达对象之间的关系,并满足业务逻辑的要求。

例如,在一个电商系统中,商品和订单之间存在关联关系,商品可以属于多个订单,而订单只能包含特定的商品。

因此,可以选择一对多的关联关系来表示商品和订单之间的联系。

2. 考虑数据一致性关联关系的选择还应考虑数据一致性的问题。

如果两个类之间的关联关系是双向的,那么在更新其中一个类的实例时,需要同时更新另一个类的实例,以保持数据的一致性。

因此,如果没有必要,应尽量避免使用双向导航的关联关系,以减少数据更新的复杂性。

3. 考虑性能和扩展性关联关系的选择还应考虑系统的性能和扩展性。

如果关联关系会导致频繁的查询和更新操作,可能会影响系统的性能。

因此,应尽量选择简单和高效的关联关系。

另外,关联关系还应具备良好的扩展性,能够适应系统需求的变化。

如果关联关系过于复杂,可能会导致系统难以扩展和维护。

Rhapsody介绍

Rhapsody介绍Rhapsody介绍-Logix公司的Rhapsody与苹果公司的Rhapsody操作系统完全是两码事,I-Logix的Rhapsody 是遵循UML标准的面向对象设计工具。

其中国大陆及香港地区独家代理华力创通的副总经理熊运鸿先生这样形容Rhapsody:它为嵌入式软件的开发提供了一个“四化”的支撑平台,即可视化、工程化、自动化和团队化。

它提供了可视化的开发环境,贯穿了工程化的设计思想,使用了自动化的开发模式,并支持团队化的协作开发。

通常首次使用此类软件工程工具对开发效率的提升并不是很明显,但据I-Logix介绍,第一次使用Rhapsody的用户可以比常规开发周期缩短30%。

I-Logix的首席讲师Bruce Powel Douglass博士在近期来华访问的演讲中,介绍了Rhapsody的几个重要特性:完全遵循UML标准、独特的模型/代码相关性技术以及图形化的、设计级的调试和验证技术。

此外,Rhapsody还能支持大项目开发对于信息共享的需要。

每个用户在私有工作区维护自己的设计模型,Rhapsody将所有设计模型以包的形式存储在项目内,并提供管理和划分功能。

团队之间可以通过工作区的直接导入以及现有的配置管理工具实现协同开发。

UML的忠实“追星族”UML(统一建模语言)给软件界带来的震动不亚于六级地震,它与OOAD(面向对象分析和设计)工具的结合,更使软件工程思想的实现往前走了一大步。

Rhapsody是业界第一个遵循UML语言的面向对象设计工具。

总部在美国的I-Logix是OMG(对象管理组织)的成员,并且参与了UML标准的制订。

UML在1997年11月成为OMG 采纳的标准建模语言,Rhapsody 在1998年2月就开始提供对UML 的支持。

在Rhapsody中,设计者可以创建UML支持的9种图:顺序图、协作图、类图、对象图、用例图、构件图、状态图、活动图和实施图,其中类图和对象图在Rhapsody中统称为对象模型图。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

Development of aCruise Control in UMLusing Rhapsodya design project in order to familiarisewith this new development toolG.R. de BoerReport of IOOSupervisor: dr. ir. J. BroeninkMarch 2001Report Nr. 002R2001Control LaboratoryElectrical Engineering DepartmentUniversity of TwenteP.O. Box 2177500 AE EnschedeThe Netherlands12SummaryThis project has the objective of familiarising with Rhapsody, a Unified Modeling Language (UML) based development tool. The additional goal of embedding the developed software in a TMS-320LF2407 board has appeared to be out of the scope of the project. It turned out that Rhapsody assumes a Real Time Operating System (RTOS) at the target, for which the TMS board did not qualify.During the project, the Rapid Objec-Oriented Process for Embedded Systems (ROPES) has been followed. This method prescribes ‘cyclic prototyping’, an iterative approach allowing early testing of analysis models, even though they are not complete (Douglas, 2000). To discover the possibilities of this tool, it has been chosen to use it to model a Cruise Control (CC).The objective of getting acquainted with Rhapsody proved to be successful. A fully functional CC has been developed and comprehensive knowledge of the tool has been gathered and documented. It is recommended that further research is dedicated to improve the control law used for speed maintenance, as well as to development of a graphical user interface allowing plotting of the system output and easy event insertion. Furthermore, development of a framework for Rhapsody, allowing embedding in non-RTOS, is recommended.SamenvattingDit project heeft als doel het bekend worden met Rhapsody, een ontwikkel-omgeving gebaseerd op de Unified Modeling Language (UML). Het bijkomstige doel, de ontwikkelde software te embedden in een TMS-320LF2407 board is gebleken buiten de reikwijdte van het project te vallen. Rhapsody bleek een Real Time Operating System (RTOS) als target te verwachten. Het TMS-bord voldoet niet aan die eis. Gedurende het project is de Rapid Object-Oriented Process for Embedded Systems (ROPES) methode gevolgd. Deze methode schrijft voor om cyclisch prototypes te ontwerpen; een iteratieve aanpak die vroege tests van modellen mogelijk maakt, ook als ze nog niet compleet zijn (Douglas, 2000)Om de mogelijkheden van deze ontwikkel omgeving te ontdekken, is de omgeving ingezet om een Cruise Control (CC) te ontwikkelen.Het doel om bekend te geraken met Rhapsody is succesvol gebleken. Een volledig werkende CC is ontwikkeld en er is veel kennis omtrent de ontwikkelomgeving vergaard en gedocumenteerd. Het wordt aanbevolen om verder onderzoek te richten op verbetering van het regelalgoritme dat de snelheid probeert vast te houden. Eveneens kan onderzoek gericht worden op het ontwerpen va neen grafische User Interface om het plotten van de uitgangswaarden mogelijk te maken, evenals makkelijkere event-generatie. Ook zou een framework dat embedden in een niet-RTOS mogelijk maakt, ontwikkeld kunnen worden.3Contents1 Introduction (1)2 ROPES (5)3 Analysis (7)3.1 Cruise Control (7)3.2 Use Cases (8)3.3 Object Model Diagram (11)3.3.1 Implementation Note (12)3.3.2 Skills Needed (13)4 Design (15)4.1 State Charts (15)4.1.1 Simulation and Animation (19)4.1.2 Implementation Note (20)4.2 20-SIM (20)5 Implementation (23)5.1 Manual Implementation of the Car model (23)5.2 Tuning the Controller (25)6 Testing and Results (27)6.1 Testing (27)6.2 Results (28)7 Conclusions and Recommendations (31)7.1 Conclusions (31)7.2 Recommendations (31)Appendix A: Troubleshooting for Rhapsody (33)References (35)4511IntroductionThis project has the objective of familiarizing with Rhapsody; a Unified Modeling Language (UML) based development tool. It allows high level designing and structuring of embedded software. To discover the possibilities of this tool, it has been chosen to use it to model a Cruise Control (CC). CC has become very common in cars nowadays, making it very suitable to serve as an everyday-life example of a controlled system. A CC contains the basics of loop control as well as some user interfacing. The CC can be positioned in a schematic user-car system as depicted in fig. 1.1.Figure 1.1A schematic representation of the position of the CC in a user-car systemRhapsody provides for a means of defining a system with use cases, sequence diagrams, class diagrams and state charts. Use cases are specific situations the system can encounter; global sketches of the system functions. Sequence diagrams allow a systematic definition of the sequences of events the system has go through, in order to realize the desired behavior. The class structure of the model can be defined in the Object Model Diagram. Eventually, the embedded software is completed with state charts.The development strategy has been taken from the Rapid Object-Oriented Process for Embedded Systems (ROPES) approach (Douglas, 2000). This method prescribes ‘cyclic prototyping’, an iterative approach allowing early testing of analysis models, even though they are not complete. The following figure depicts this cycle.Figure 1.2 The ROPES cycle (Douglas, 1999, p 160)2An elaborate explanation of this method is given in Chapter 2.Initially, the goal of the project was embedding the software in a TMS-320LF2407 programmable board, using a Code Composer. This initial project strategy is depicted schematically as in figure1.3.Figure 1.3Scheme of the initial modeling strategyLater, this goal has been renounced because of a mismatch between the output assumptions of Rhapsody and the features of the TMS-board. Rhapsody assumes a Real Time Operating System (RTOS), and the TMS-board does not qualify for that. The project has been redirected as shown in figure 1.4.plan realizationFigure 1.4 Redirection of the project strategyThe TMS-board could not be addressed without writing a new framework, replacing the OXF-framework Rhapsody normally includes to the design. This would be far too extensive for this assignment, so it has been decided to use a model of a car. This way, it can still be tested if a proper CC can be developed using Rhapsody.Chapter 3 will contain the Analysis of the development process. More details on the CC are given in section 3.1. The tools and skills that were available or needed during the course of the project are reviewed in section 3.2. Besides Rhapsody and the necessary C++, these tools also comprise 20-SIM for the modeling of a car. Chapter 4 covers the Design of the CC in Rhapsody. Chapter 5 elaborates on the implementation of the CC, using the tools mentioned in section 3.2. Also it reports on the tuning of the CC (section 5.2). The testing of the CC and the results are given in chapter 6. Chapter 7 contains the conclusions and recommendations of the project.342 ROPESThis project owes it strategy to the ROPES approach. The structure prescribed in the approach returns in the chapter-arrangement of this report. A more detailed ROPES-cycle is given in figure 2.1.Figure 2.1 A detailed ROPES cycle (Douglas, 1999, p 167)The primary purposes of any development process are to(1) increase the quality of the end product(2) improve the repeatability and predictability of the development effort(3) decrease the effort required to develop the end product at the required level of quality(Douglas, 1999).As can be seen, the approach breaks the software development into four primary phases: analysis, design, implementation and testing. In as much as the sub-phases apply to this development-project, they are deployed as well.Iterative project development requires sub-goals to be recognized in the project. Every cycle, new elements have to be included in the design, making it resemble the desired design more and more. The following sub-goals in order to achieve the total design have been distinguished:• Define the Use Cases, Sequence Charts and Class structure• Realize data transport by the class structure• Set a speed/Resuming a speed• Control the Speed• Rewrite the C++ code to C code• Realize the embedded system on the TMS-boardthe last two stages have later been replaced by:• Model a car in 20-SIM• Import the model in Rhapsody• Feed the countermeasure to the car engine• Tuning the controller, thus keeping the speed constantThe Analysis part of these stages is documented in chapter 3. The Design is covered in chapter 4. Chapter 5 will report on the Implementation and the Testing is accounted for in chapter 6. This way the ROPES structure can be recognized in the structure of the report as well.3 AnalysisThis chapter contains analysis of the CC, needed to implement it in Rhapsody. First, use cases will be found. To obtain specific use cases for a CC, as well as providing the reader with a general understanding of the working of a CC, section 1.1 gives a description of its functioning in words. Words that give notice of possible objects that have to be taken into account are underlined. Possible use cases can be recognized in the text as being bold.3.1 Cruise ControlTo keep the speed of an automobile at a certain level in the first place requires knowledge of the actual speed. In the case of a CC, the speed information is acquired using a speed sensor. This actual speed has to be compared to the desired speed in order to know whether the speed is actually being maintained. To maintain the desired speed, the CC has to be able to influence the amount of gas fed to the engine. Thus the output of the CC is a signal which gives a measure for the amount of gas. With this signal a servo can be controlled which is attached to the throttle-lever at the engine.Pushing a button labeled ‘On/Off’ while driving can set the desired speed. The CC unit will at that moment acquire and store the actual speed. This speed will then serve as the value for the desired speed, and the CC will try to maintain that speed, continuously comparing it to the actual speed.Next, conditions for deactivating the CC have to be specified. The driver can simply turn off the CC by pressing the ‘On/Off’ button again. More important is the deactivation of the CC when braking. This way, it is prevented that the CC will try to countermeasure the speed loss, in this case initiated (and therefore wanted) by the driver.After deactivation of the CC the user can reset the speed at a new level, by pressing ‘On/Off’ again at a desired level of speed, or he can resume the speed level set previously.Finally some additional functions can be implemented, for instance ‘CC up’ or ‘CC down’. Using these buttons, the user can fine-tune the set speed to the desired level.The indicated objects and use cases can be translated into the following list of objects and use cases:Objects Use CasesUser Acquire actual speedButton panel Store actual speedEngine Compare speedSpeed Sensor Keep speed constantStore speed Activate/Deactivate CCCalculate Difference/Throttle Resume speedController Fine-tune speedTable 3.1 The Objects and Use Cases recognized in the Cruise ControlThese use cases and objects have almost all found their way in the Use Case Diagram or Object Model Diagram. Only those that do not have to be designed in software have been omitted in the Object Model Diagram (Button Panel, Speed Sensor and the Engine (the class Car will later model the behavior of the engine in a car)).3.2 Use CasesIn this modeling stage it is difficult and not yet necessary to use real sensor-signals, and producing lifelike outputs. Hence the objects found in table 3.1 reduce to:• GenerateSpeed (a temporary replacement for the sensor)• SignalConditionerIn (shapes the sensorreading to a usable (controllable) form)• ProcessUserCommand (processes inputs from user (provided by Input), and distributes the accompanying tasks to the system)• StoreSpeed (captures a sample of the actual speed when the user sets the speed)• Controller (controls the speed of the car trying to maintain the setpoint)• SignalConditionerOut (shapes the output of the controller to a fit range for the servo on the speed lever, or the electro-motor)• Display (temporary object, sorting out the interesting signals in the system and• displaying them in an orderly manner for inspection)The first step in the design was to define the actors in a CC system as well as the Use Cases identified in the previous chapter. Second came the identification of relationships between users and Use Cases, and the generalizations that can be made between the Use Cases. This resulted in the diagram of figure 3.1.Figure 3.1The Use Case Diagram of the Cruise ControlAs can be seen, this diagram shows the different functions the CC is capable of, as well as the locations at which the user can intervene in its functioning.The use of this diagram is merely explanatory. No code is generated so far; the problem has only been outlined en schematized. It can be used as a reference for total overview, but also as anillustration of how the programmer regards the problem (e.g. to the project manager). Only when a use case has the same name as a class defined in the Sequence Diagram or Object Model Diagram, Rhapsody suggests merging them. This way relations defined in the Use Case Diagram do have some effect on the code, though hardly worth mentioning.The Sequence Diagram gives a means for sketching possible sequences of action the system can go through. One Sequence Diagram has been created, comprising the reactions of the system to each button the user can press. Again it has to be noted that this chart does not narrow down the design, it merely visualizes a possible sequence of actions. Figure 3.2 shows the Sequence Diagram.Figure 3.2 The Sequence Diagram of the Cruise ControlStore ControllerSignal ProcessAs can be seen, the ProcessUserCommand class distributes the user commands to the rest of the system. The evOn and evOff to the SignalConditionerOut are necessary since the CC has to release its influence on the speed directly, when the user adjusts the speed himself.3.3Object Model DiagramThe Object Model Diagram is where the structure of the software is outlined. It is where the user defines the classes and their mutual relations. The following figure shows the class-structure for the CC.Whenever one class needs data from another class for its operation, it has to be connected to that class with a relation or aggregation in the Object Model Diagram. So the Object Model Diagram is also where the infrastructure for the data-transport is defined.In the diagram, the straight lines represent the data-flow, whereas the curved lines depict signal lines for on and off switching, event generation or monitoring, i.e. the control-flow. This is not a UML feature, but the programmer is completely free in drawing the lines. It has been chosen for clearness of the picture, in a way similar to K.C.J. Wijbrans, 1993.StoreSpeedSetSpeed : doubleGetSpeed()GiveSetPoint()IncreaseSpeed()DecreaseSpeed()ContollerSpeed : double SetPoint : double SpeedDifference : Output : double GetSpeed()GetSetPoint()CompareSp()ControlLaw()GiveOutput()ProcessUserCommandevSetSpeed()evResumeSpeed()evBrake()evCCUp()evCCDown()evActivate()evDeactivate()11111111111111111111DisplaySignalConditionerIn SignalConditionerOutSpeed : doubleShapedSpeed : doubl GetSpeed()ShapeSpeed()GiveSpeed()ShapedOutput : dou Output : double GetOutput()ShapeOutput()GiveOutput()SignalGeneratorFigure 3.3 The Object Model Diagram of the Cruise ControlThe ‘1-character’ on each end of the relation indicates the multiplicity of the relation, meaning the number of objects that can be made from a class.As it became clear that the design and testing of the CC would be completely in software, and a model of a car would have to be implemented in Rhapsody, a new Object Model Diagram was created. The new diagram is given in figure 3.4. The class has been connected to Input and Output in order to close the control loop. ProcessUserCommand has also been connected to Car , since the user has to be able to address the car without mediation of the CC as well (speed up, brake, etc.). Car has a connection to Display too, since monitoring of its internal variables has to be possible.ProcessUserCommandevSetSpeed()evResumeSpeed()evBrake()evCCUp()evCCDown()evActivate()evDeactivate()111111111111111111111111111111SignalConditionerIn DisplayCarOutputInputContollerStoreSpeedSignalConditionerOut Speed : doubleShapedSpeed : doubl GetSpeed()ShapeSpeed()GiveSpeed()Throttle : double Mass : int Friction : int Speed : doubleGetCThrottle()Euler()EvaluateModel()GiveSpeed()Speed : double SetPoint : double SpeedDifference : Output : doubleGetSpeed()GetSetPoint()CompareSp()ControlLaw()GiveOutput()SetSpeed : doubleGetSpeed()GiveSetPoint()IncreaseSpeed()DecreaseSpeed()ShapedOutput : dou Output : double GetOutput()ShapeOutput()GiveOutput()Figure 3.4 Object Model Diagram of the CC with a model of a car3.3.1 Implementation NoteWhen connecting classes with aggregations , data transport and event distribution can be done as soon as the ‘part of’ classes are ‘set’ in the ‘whole’ or ‘aggregated’ class. This is done in the manner of the set-functions defined in the tutorial (Ilogix, 1999, p 4-17). When a relation is used to connect the classes, Rhapsody automatically sets the connected classes. However, Rhapsodydoes not set the pointers to those classes; this has to be done manually. For every connection the programmer has to write a code similar to:p_Class1->setItsClass2(p_Class2);This code has to be added to the model in the initialization tab in Components, YourModel, Configuration, YourActiveConfiguration.Please note that, depending on the type of the relation (one-way or symmetric), one or two pointers need to be set for each relation.Appendix A gives a list of the most time consuming and disturbing difficulties that were encountered during the use of Rhapsody. For problem handling refer to this appendix.3.3.2 Skills NeededImplementing the CC in Rhapsody requires the user to be familiar with the program. The tutorial and reference guides are of help in gaining familiarity, although they are far from sufficient. Some of the options in the wide range of feature-windows are hardly documented, probably assuming enough programming-background for those options to become trivial. Since this background was substandard at first, a proper understanding and operation of Rhapsody advanced slowly. Knowledge of C++ is also required, since the actual function of the states, the body of the objects defined, has to be manually programmed. Maybe in-depth knowledge of C++ would have indeed made the above-mentioned options trivial, but in my case the opposite applied. The attended lectures in C++ have hardly covered object orientated programming, so most of the understanding was gained during the design. The first four weeks have mainly been dedicated to familiarizing with Rhapsody and object-orientated programming.Regarding the scheme of fig. 1.1, the CC and User Interface will first be implemented using Rhapsody. On a very high level the programmer is able to abstract and define the system, some features only clarifying the problem to the programmer, other features generating code for the program.Development in Rhapsody is done in three stages:• defining Use Cases and specifying a Sequence Diagram• creating an Object Model Diagram of the system• designing the StatechartsThe first two stages can be recognized as the Analysis part of the ROPES approach, whereas the last stage is part of the Design.The first stage, the Use Case and Sequence Diagram, mainly outlines the problem to the programmer and allows him to narrow down and pinpoint the exact design-problem he is dealing with. The second stage, the Object Model Diagram, creates a framework of classes and theirmutual dependencies, outlining the structure of the program and the data-flow. The third stage, the statecharts, is where the program is completed. All the different states the system can be in, have to be defined, as well as the actions that are related to those states. The programmer can choose to make one huge statechart, or define several statecharts, e.g. one for each class defined in the abstract-part. Regarding the iterative development approach of ROPES, the latter is recommended. This way gradual refining is easy to realize.The car was to be modeled in hardware, using an electro-motor. The Rhapsody design of the CC would be embedded in the TMS-board, and the user interface would be implemented with a set of buttons. Embedding the software in the TMS-board requires some knowledge of C, since the Code Composer for the TMS-board uses C. The conversion of C++ to C however, can be done using Appendix A of J.M. van Drunen, 2000.As became clear during the project, 20-SIM had to be put into action where the Code Composer fell short. The car now has been modeled with bond graphs. This model has been implemented in Rhapsody, thus realizing a complete user-CC-car system.4 DesignThe design in software becomes of interest, since the functionality and requirements of the CC have been analyzed. Section 4.1 gives notice of the state charts that define the desired behavior of the CC. The car model developed with 20-SIM is covered in section 4.2.4.1 State ChartsThe next stage in the UML programming process is the definition of the statecharts. The exact behavior of the CC is fixed by defining the states and transitions the CC can be in, as well as the actions that accompany them. It has been decided to assign a statechart to each class. This way it is prevented that the statecharts become complex. Furthermore, gradual refinement is possible, as stated in chapter 3. The following figures show the statecharts that have been created.At first the statechart of the straightforward classes (SignalConditionerIn and GenerateSpeed) will be reviewed. These classes loop one single state, repeatedly executing the function defined in the body of the state. Figure 4.1 shows the form of these classes.Figure 4.1 The State Chart of SignalConditionerIn and GenerateSpeedThe loop time of 100 ms (tm(100)) is maintained in the whole design of the CC. This way the total loop time of the CC results in 500 ms, because a signal goes through 5 classes from input tooutput (see the Object Model Diagram). That this loop-time satisfies the demands of the design will be discussed in the following section.The following list shows the functions each of these classes loops:• SignalConditionerIn GetSpeed(), ShapeSpeed()• GenerateSpeed GenerateSpeed()SignalConditionerOut has a slightly different statechart, since it has to have the ability to switch off. This is realized in the manner of figure 4.2.Figure 4.2The State Chart of SignalConditionerOutSignalConditionerOut executes the operations GetOutput() and ShapeOutput().A look at ProcessUserCommand shows that the whole system can be mastered by inserting 5 events in this class:• evSetSpeed (the CC is activated to maintain a new speed (the ‘On/Off’ button) or deactivated)• evRestoreSpeed (the CC is activated to maintain previous speed)• evCCUp (the set speed is increased by 1 km/h)• evCCDown (the set speed is decreased by 1 km/h)• evBrake (the brake is used, and the CC is deactivated)Figure 4.3 shows how these events are included in the statechart of ProcessUserCommand.Figure 4.3 The State Chart of ProcessUserCommandThe class ProcessUserCommand is where the entire system is coordinated. The other classes are invoked from here. Entering the Idle state deactivates the Controller and the SignalConditionerOut, exiting the Idle state activates it. Entering the S tore state generates an event in the class StoreSpeed(evStoreSpeed()). It can be seen that evSetSpeed() results in entering the Store state, and also in returning to the idle state (when evSetSpeed() reoccurs within 100 ms. since after that time the Controlling state is entered). This has been done for the sake of completeness, since it could occur that the user accidentally presses the On/Off button and corrects that within 100 ms. The controlling state does not contain code, since exiting the idle state already started the controller.It can be seen that (when in the Controlling state) the event evCCUp() and evCCDown() result in evIncrease() and evDecrease() in the class StoreSpeed. Pressing ‘On/Off’ (evSetSpeed()), hitting the brake or adjusting the speed in another way, results in returning to the state idle. It has to be noted that de CC has to react to accelerating just as to hitting the brake, or even clutching. As soon as the driver wants to adjust the speed in any way, the CC has to deactivate. So pressing either one of these levers results in the same event: evBrake().The StoreSpeed class has been defined as follows. The evStoreSpeed(), generated in ProcessUserCommand, results in taking a sample from the speed in SignalConditionerIn and storing it in the variable SetSpeed with the following function (the operation GetSpeed(), invoked in the state On):SetSpeed=itsSignalConditionerIn->GiveSpeed();The class SignalConditionerIn reacts to this call by returning the actual speed:Return Speed;Figure 4.4The State Chart of StoreSpeedThe reactions to evIncrease() and evDecrease() are respectively SetSpeed++ and SetSpeed--. This way the driver can tune the set speed by 1 km/h.Finally the main function of the CC will be shown: the controller. Every 100 ms the controller refreshes the values it needs for speed-control: Speed and SetSpeed (in the controller this is called SetPoint). With these values, it continuously loops a cycle of comparing and controlling(for now no real countermeasure is necessary, since we do not know what engine we are going to control). The control-law used in the controller is a proportional one. As soon as the car model is implemented in Rhapsody, this control-law will be tuned to control the speed of the car. Figure 4.5 shows the state chart of the controller. It can be seen that this class contains three parallel processes, each with a loop time of 100 ms.Figure 4.5The State Chart of ControllerThis way a simple Cruise Control has been realized. The next section will give some comments on the animation of the system (one of the features of Rhapsody).4.1.1 Simulation and Animation When simulating the model, Rhapsody allows insight via a graphical way in the operation of the system, by means of animation. One can choose to animate any statechart of the system, as well as a sequence diagram. This displays the sequence of the events the system goes through duringanimation. This way, one can quickly see if and how the system functions and check if that corresponds with the demands.Simulating and animating a model can be done as described in the tutorial. However, since the tutorial does not provide for comprehensive explanation of the instructions, some remarks regarding indistinct issues are given here.• In the folder Component/Configuration, the ‘initialization-tag’ shows all the constructed classes, with a check-box. Only the checked classes will be included in the animation. If a class has a function whatsoever in the animation, check its check-box. In general one can simply check all check-boxes, to avoid failing animations.• Animation is only possible when the simulation is running.• When the initial state of a class invokes other classes (e.g. generating an event), be sure to start with a few milliseconds delay, before entering the initial state. This way, indefinite errors are prevented, caused by an incomplete data-structure.4.1.2 Implementation Note The 40 ms. before entering the on state in ProcessUserCommand has been done because the startup state, idle, directly inserts events into another class (Controller and SignalConditionerOut). They first have to be constructed before they can be addressed. Without this delay, a memory exception occurs, caused by an incomplete data-structure.A presence-check should be implemented, holding the program until the addressed class is present (only for a limited time, since it could occur that the class does not exist due to caused by other than startup problems)4.2 20-SIMSince controlling the speed of a real electro-motor is out of the picture, the design of the CC will now be tested in software. 20-SIM has been used to create a model of a car and engine, and to generate C++ code for that model so that it can be implemented in Rhapsody. The model and the reductions that were applicable will be discussed in this section.At first a complete picture of the relevant parts of the system of a car and engine have been modeled. Relevant are the dynamic properties of the engine as well as the weight and total friction of the car. However, in this stage of the design it is of little importance whether we use a。

相关文档
最新文档