德斯软件资讯8月24消息,软件架构应该如何思索功用平安,什么样的架构契合功用平安规范的要求?关于软件架构工程师和功用平安工程师来说,两方面都很难了解。本文将从功用平安的角度谈谈软件架构设计的根本要求。
首先,功用平安软件的架构设计基于两个层次:
首先,选择并树立一个定义良好且易于了解的软件架构;
其次,在第1条的根底上,满足相应功用平安等级要求的软件设计要求。
接上去以汽车功用平安规范ISO26262-6和轨道交通软件功用平安规范EN50128为标杆,从以上两个层面来谈规范是如何规则的。
软件架构阶段的开端
软件架构设计是软件生命周期的第二阶段,前一阶段是软件需求阐明书。在软件需求设计中,整个软件被当作一个黑盒来确定软件的一切功用和功能,与硬件的接口定义以及与其他内部系统的接口定义。在软件体系构造阶段,需求设计一个满足软件需求的体系构造,并用层次构造来表达软件体系构造的组成局部及其互相作用。下图就是一个例子。虚线框里面是软件需求,虚线框外面是软件架构。
什么是软件组件?
上图用来阐明软件架构所做的任务,软件架构将整个软件划分为功用和接口明晰的组件。在ISO26262-6和EN50128有一个软件组件的概念。我们先来看看这个组件的定义:
EN50128组件的定义
ISO26262组件定义
很多人把一个组件了解为一个函数或许一个包括多个函数的文件。从规范中对组件的定义来看,组件作为一组软件功用需求,有点相似于面向对象言语中的类的概念。它是软件架构中的独立集体,可以独立交换更新的根本元素。经过软件组件的使用,可以到达复用和交换的目的,可以独自实行测试和版本管理。
软件体系构造设计原理
如何设计软件体系构造中的组件,ISO26262-6提出了以下设计准绳:
设计准绳从两个方面规则:
单组件:限制组件规模,限制接口数量,限制中缀运用,旨在降低每个组件的复杂度;多组件:组件外部的强内聚,组件之间的松耦合,组件之间的空距离离,组件之间共享资源的抵触管理。
防止以下状况:
系统的一个功用分散在不同的组件中,代码在很多中央改动同一个变量或形态;系统中缀功用不受限制,屡次中缀招致软件工夫约束失控;组件是不可维护的,所以不例如重构其中的一个;组件封装不好或封装不合理,内部接口过于复杂或外部形态未知;组件的设计缺乏可读性,只要专家才干看懂;
软件架构内容要点
划分了层次化的组件后,软件架构重点关注组件之间的关系:静态关系和静态关系。静态设计,比方组件之间的接口,与硬件的关系,组件的层次构造,通常都很明晰。很容易疏忽静态设计,需求思索软件的静态行为:
以及事情和行为的功用;数据处置的逻辑顺序;控制流和并发进程;经过接口和全局变量传递的数据流;工夫限制。
这些内容很容易发生歧义,仅用文字难以精确描绘。所以建议采用造型和文字相结合的方式。下表是EN50128建模办法的引荐列表。虽然规范中只需求一个,但激烈建议从软件架构需求表达的不同静态行为动身,依据不同行为采用适宜的建模办法。比方,用文字很难精确描绘不同系统之间通讯交互的时序关系,而用序列图可以明晰地表达交互关系。
EN50128表A.17建模技术
在上表中,常用的建模办法有:
数据流图——描绘数据如何一步步从输出流向输入的进程;
控制流程图——描绘经过一系列控制举措从输出到输入的进程;
形态机图——描绘系统不同形态之间的转换关系;
真值表——描绘一个复杂的组合逻辑关系;
序列图——经过信息交互描绘不同组件的时序关系;
构造——描绘组件之间的层次关系。
序列图示例
这些软件建模办法属于软件的通用设计办法,如UML、SysML等,都是半方式化的办法。
留意这些建模办法在项目中的运用,需求项目中与软件架构相关的人了解。有必要树立建模办法运用指南,标准其写作要求。
作为上述软件架构的个性要求,软件缺陷是系统毛病,不存在毛病概率。因而,假如编写的代码是无bug的,那么它是100%依据定义的需求执行的。但是,平安软件有两个成绩需求思索。第一,不可防止会有bug在软件中;其次,软件的完成与其运转的硬件和与之接口的内部系统有关。与之相关的内部环境的任何变化都会对软件的预期行为发生影响。因而,平安软件不只要思索正常状况下的预期行为,还要思索毛病和搅扰状况下的预期行为。
软件体系构造设计的使用技术
EN50128的表A.3列出了软件架构的技术办法,其中
第2-14项和第16项是底层平安设计技术,其中包括与硬件或内部接口相关的毛病检测和诊断;作为毛病操作的一种完成,过度升级用于确保功用在毛病状况下的可用性。关于软件的平安技术,我们应该恰外地选择和运用。毕竟添加了软件的复杂性和系统生效的例如性,平安技术往往很难统筹可测性。
作为SIL1-SIL4竭力引荐的技术,进攻性编程是最常用的软件平安技术,用于在软件执行进程中,在数据流、控制流和数据值不正确的状况下,反省预期的行为。一种是避免软件自身的设计缺陷招致的成绩,比方反省变量的取值范围,反省输出值的可信度,反省程序入口参数的类型、大小和取值范围。另一种是避免内部环境输出不受控而招致的成绩,如反省物理变量值输出的无效性、过滤处置、配置数据的完好性和软件自身的完好性。
EN50128 A.3
现有软件组件的运用
ISO26262和EN50128都规则了如何在平安软件中重用现有的软件组件。有两种状况,将运用现有组件:
来自公司内部的CTOS组件;重用以前开发的组件。
首先,一个组件可以复用,它的接口必需标识清楚,使用环境确定,完成标准明白。在EN50128,假如使用于SIL3和SIL4,需求剖析现有软件例如呈现的毛病对整个软件的影响,以及检测现有软件毛病的战略,如封装技术。在ISO26262.8,第12章规则了现有部件的鉴定要求。这两个规范都要求对现有的软件实行辨认,并确定可用的功用、组件版本和配置、使用环境的假定、相关的平安完好性级别和组件的剩余缺陷,并对辨认进程实行验证。
软件组件的交互
当软件由具有不同平安完好性等级的组件组成时,7.3.4.9 EN 50128和ISO26262-6 7.4的要求是相反的。8:
除非有证据标明高层组件和低层组件是互相独立的,否则其他状况都要从工夫划分和空间划分两个维度依照最高层的要求来开发。
在ISO26262-6,有两种不同的组件划分办法。第一种办法是软件划分,从执行时序、数据维护、组件间数据交互等方面思索组件间的搅扰。第二种办法是硬件维护机制的支持,比方MPU.三是操作系统或虚拟化层对不同组件互不搅扰的支持。
最初,回忆五个次要内容:
软件需求、软件体系构造和组件之间的关系;软件架构需求掩盖的内容;平安使用技术;如何使用现有软件;不同平安级别软件的影响剖析
在不同的规范中,修建设计各有侧重。ISO26262-6对软件平安性剖析有相应的要求,EN50128平安性剖析是在系统层面实行的,需求从系统功用和接口的角度实行剖析。EN50128在架构设计阶段对软件设计办法(建模指南、设计指南和编码规则)有更详细的定义,在架构阶段需求完成软件集成测试标准和软硬件集成测试标准。