VXT文件解析(一)
CANoe的demo里面有个Gateway Tester。(我很纳闷,不是有CAPL和.net支持,为啥还要搞个XML)
首先研究一下这个VXT文件。打开其实是一个xml文件。这个xml文件是通过VBA生成的。
根元素是testmodule,查了一下Canoe的说明如下:
testmodule是一个测试序列,通过特定的测试函数用于测试控制单元和网络。它可以用于验证各个开发步骤,检查模型和回归验证,以及整合测试。
testmodule可以通过Test Automation Editor(这个玩意儿不知道哪里有)来编辑,并可在Canoe的simulation和Test setup运行。
xml格式的testmodule包含了一系列预设的可参数化得测试函数和控制函数。它可以包含CAPL格式的函数,测试用例或.net格式的测试用例。
xml格式的testmodule包含:
任意数目的测试用例,可以组合进test group
语法格式:
<testmodule title="Title of test module " version="1.0" xmlns="Namespace of test module (as html)" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="Namespace with assigned schema-file"> </testmodule>
其中title和version是必须的的属性。
engineer、testsetup、sut没啥好说的。。。。
conditions的介绍如下:
constraints和conditions是当执行一个测试用例的时候被同步检查的条件。这些条件在test module或test group或test case中被详细描述。
语法格式:
<conditions> List of test conditions </conditions>
requestresponsecheck,canoe的说明如下:
这个检查,监测是面向消息的,但simul没有用到
这个检查用于验证处理时间,一个信号从一个消息转换成另一个消息需要多长时间。
对于用于检查时间的情况,必须在到达超时之前发送响应消息
对于用于检查值得情况,响应消息的物理信号值会与请求消息的物理信号值或常值进行核对。
有两种可用的配置:
第一种配置one2one = Yes,每个请求只允许一个响应,所有其他响应都会导致检查失败。在检查的开始阶段请求和相应消息都会被忽略,忽略的间隔时间是最短超时时间和第一次的路由时间。
第一种配置one2one = NO,每个请求允许多个响应,然而对附加响应的数据一致性进行了监视,这些响应的消息内容也必须满足condition里面的内容。如果没有实现数据一致性,检查将失败。数据一致性的间隔时间从第一条路由时间或超时时间。
在这个check的<response>部分,不仅<signal>和<byte>属性可以用到,<signalref>和<byteref>属性也可以被用到。它们的引用直接与请求消息有关。
对于元素<signalref>也可以指定值即使它没有被rooted。
<signalref>在帮助文件中没有详细的说明,但分析一下基本可以得出
<signalref name="Comf_CarSpeed" refname="CarSpeed" />
name属性是目标网段的信号,refname是源网段的信号。
当使用<mostmsg>作为<response>的参数时,<param>可以与<byte>一起使用来描述消息内容。
<requestresponsecheck title="..." mintime="..." timeout="..." observetime="..." one2one="yes|no"> <request> Definition of the trigger message <canmsg/> or <linframe/> or <mostmsg/> or <frframe/> or <frpdu/> </request> <response> Definition of the independent message It is possible to refer to the trigger message <canmsg/> or <linframe/> or <mostmsg/> or <frframe/> or <frpdu/> </response> </requestresponsecheck>
以上定义了检验的标准。下面是测试用例使用:
<testcase> 包含测试执行的实际指令
使用语法: title和ident是必须的
<testcase ident=" ID of the test case, e.g. number " title="Title of test case" version="1.0" variants="A" > </testcase>
<Initialize>中包含一系列被赋值的CAN信号,它们将被发送到总线上去。第二步,会有一个指定的等待时间。这个等待时间允许系统"投入",这样系统希望的值会被实际改变。
使用语法:
<initialize title="Headline for the primitive, visible in report" wait="Wait time in ms"> List of CAN signals/messages, LIN signals, FlexRay signals MOST messages and environment/system variables </initialize>
再来详细说一下cansignal、byte,用来定义signal信号的。
<cansignal name="Signal name" msg="Message name" node="Node name" bus="Bus name">Value</cansignal>
<byte pos="Byte position from 0">Value</byte>
贴上源代码,后面慢慢分析。
<?xml version="1.0" encoding="iso-8859-1"?> <!-- Generated from Excel --> <!--Vector Test Automation Editor 1.1.55.0--> <testmodule title="Gateway Tester" version="" xmlns="http://www.vector-informatik.de/CANoe/TestModule/1.16"> <engineer> <info> <name>Name</name> <description>vislke</description> </info> </engineer> <testsetup> <info> <name>Version of test configuration</name> <description>1.2</description> </info> <info> <name>Test configuration created by</name> <description>Stefan</description> </info> </testsetup> <sut> <info> <name>ECU name</name> <description>Gateway</description> </info> <info> <name>ECU version</name> <description>0.99</description> </info> </sut> <conditions> <!-- relates to line # 8 in the excel file --> <requestresponsecheck timeout=" 1000ms" mintime="100us"> <request> <canmsg id="ABSdata" bus="Engine" /> </request> <response> <canmsg id="EngineInfo" bus="Comfort"> <signalref name="Comf_CarSpeed" refname="CarSpeed" /> </canmsg> </response> </requestresponsecheck> <!-- relates to line # 9 in the excel file --> <requestresponsecheck timeout=" 1000ms" mintime="100us"> <request> <canmsg id="ABSdata" bus="Engine" /> </request> <response> <canmsg id="EngineInfo" bus="Comfort"> <signalref name="Comf_GearLock" refname="Gear_Lock" /> </canmsg> </response> </requestresponsecheck> <!-- relates to line # 10 in the excel file --> <requestresponsecheck timeout=" 1000ms" mintime="100us"> <request> <canmsg id="EngineData" bus="Engine" /> </request> <response> <canmsg id="EngineInfo" bus="Comfort"> <signalref name="Comf_EngSpeed" refname="EngineSpeed" /> </canmsg> </response> </requestresponsecheck> <!-- relates to line # 11 in the excel file --> <requestresponsecheck timeout=" 1000ms" mintime="100us"> <request> <canmsg id="EngineData" bus="Engine" /> </request> <response> <canmsg id="EngineInfo" bus="Comfort"> <signalref name="Comf_EngTemp" refname="EngineTemp" /> </canmsg> </response> </requestresponsecheck> <!-- relates to line # 12 in the excel file --> <requestresponsecheck timeout=" 1000ms" mintime="100us"> <request> <canmsg id="GearBoxInfo" bus="Engine" /> </request> <response> <canmsg id="EngineInfo" bus="Comfort"> <signalref name="Comf_Gear" refname="GearBox" /> </canmsg> </response> </requestresponsecheck> <!-- relates to line # 13 in the excel file --> <requestresponsecheck timeout=" 2000us" mintime="100us"> <request> <canmsg id="IgnitionInfo" bus="Comfort" /> </request> <response> <canmsg id="Ignition_key" bus="Engine"> <byteref pos=" 0" refpos=" 0" /> </canmsg> </response> </requestresponsecheck> <!-- relates to line # 14 in the excel file --> <requestresponsecheck timeout=" 1000ms" mintime="100us"> <request> <canmsg id="LSeat_Sensoric" bus="Comfort" /> </request> <response> <canmsg id="ComfortStatus" bus="Engine"> <signalref name="DriverDetect" refname="Comf_DriverDetection" /> </canmsg> </response> </requestresponsecheck> <!-- relates to line # 15 in the excel file --> <requestresponsecheck timeout=" 1000ms" mintime="100us"> <request> <canmsg id="RSeat_Sensoric" bus="Comfort" /> </request> <response> <canmsg id="ComfortStatus" bus="Engine"> <signalref name="PassengerDetect" refname="Comf_PassengerDetection" /> </canmsg> </response> </requestresponsecheck> </conditions> <!-- This gateway checks can be used either in an isolated configuration (the test stimulates) or within a setup where an extra stimulation is not needed, because other ECUs are sending the stimulation messages. This can be controlled within the generation dialog. --> <!-- Stimulation by the test case has been selected during generation --> <!-- Start: The test cases itself --> <testcase title="Stimulate values for signal CarSpeed" ident=""> <initialize title="" wait=" 3000ms"> <cansignal name="CarSpeed" msg="ABSdata" bus="Engine">0</cansignal> </initialize> <initialize title="" wait=" 3000ms"> <cansignal name="CarSpeed" msg="ABSdata" bus="Engine">255</cansignal> </initialize> </testcase> <testcase title="Stimulate values for signal Gear_Lock" ident=""> <initialize title="" wait=" 3000ms"> <cansignal name="Gear_Lock" msg="ABSdata" bus="Engine">1</cansignal> </initialize> <initialize title="" wait=" 3000ms"> <cansignal name="Gear_Lock" msg="ABSdata" bus="Engine">2</cansignal> </initialize> </testcase> <testcase title="Stimulate values for signal EngineSpeed" ident=""> <initialize title="" wait=" 3000ms"> <cansignal name="EngineSpeed" msg="EngineData" bus="Engine">0</cansignal> </initialize> <initialize title="" wait=" 3000ms"> <cansignal name="EngineSpeed" msg="EngineData" bus="Engine">8000</cansignal> </initialize> </testcase> <testcase title="Stimulate values for signal EngineTemp" ident=""> <initialize title="" wait=" 3000ms"> <cansignal name="EngineTemp" msg="EngineData" bus="Engine">-50</cansignal> </initialize> <initialize title="" wait=" 3000ms"> <cansignal name="EngineTemp" msg="EngineData" bus="Engine">150</cansignal> </initialize> </testcase> <testcase title="Stimulate values for signal GearBox" ident=""> <initialize title="" wait=" 3000ms"> <cansignal name="GearBox" msg="GearBoxInfo" bus="Engine">0</cansignal> </initialize> <initialize title="" wait=" 3000ms"> <cansignal name="GearBox" msg="GearBoxInfo" bus="Engine">8</cansignal> </initialize> </testcase> <testcase title="Stimulate values for message Ignition" ident=""> <initialize title="" wait=" 6000us"> <canmsg id="IgnitionInfo" bus="Comfort"> <byte pos=" 0 ">0x12</byte> </canmsg> </initialize> </testcase> <testcase title="Stimulate values for signal Comf_DriverDetection" ident=""> <initialize title="" wait=" 3000ms"> <cansignal name="Comf_DriverDetection" msg="LSeat_Sensoric" bus="Comfort">0</cansignal> </initialize> <initialize title="" wait=" 3000ms"> <cansignal name="Comf_DriverDetection" msg="LSeat_Sensoric" bus="Comfort">5</cansignal> </initialize> </testcase> <testcase title="Stimulate values for signal Comf_PassengerDetection" ident=""> <initialize title="" wait=" 3000ms"> <cansignal name="Comf_PassengerDetection" msg="RSeat_Sensoric" bus="Comfort">0</cansignal> </initialize> <initialize title="" wait=" 3000ms"> <cansignal name="Comf_PassengerDetection" msg="RSeat_Sensoric" bus="Comfort">5</cansignal> </initialize> </testcase> <testcase title="Wait for 10 more seconds after the stimulation and purely observe" ident=""> <untilend title="" wait="10s" /> </testcase> <!-- End: The test cases itself --> </testmodule>