请移步至https://download.csdn.net/download/xianghuaizi/10650646 下载演示程序(需积分)
一、开发方法
WPF4.0 + C#
二、开发步骤
1、利用 Microsoft SDKs\Windows\v7.0A\bin\xsd.exe工具,将AUTOSAR_MMOD_XMLSchema中 AUTOSAR_4-0-3.xsd 生成C#的解析类AUTOSAR。
C#的解析类可在AUTOSAR ARXML处理 - C#的解析代码(一)_c# 解析arxml-CSDN博客 找到免费下载路径。
3、使用 C#解析类AUTOSAR 和 C#操作XML的API,解析XML文件(例:AUTOSAR_MOD_ECUConfigurationParameters.arxml)。
2、使用 WPF 构建界面,使用元素绑定和控件绑定,完成PARAMS的配置界面。
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:data="clr-namespace:AutoSar4">
<!-- This is Tree display template -->
<HierarchicalDataTemplate DataType="{x:Type data:ARPACKAGE}">
<HierarchicalDataTemplate.ItemsSource>
<Binding Path="ELEMENTS"></Binding>
</HierarchicalDataTemplate.ItemsSource>
<TextBlock Text="{Binding Path=SHORTNAME.Value}" />
</HierarchicalDataTemplate>
<HierarchicalDataTemplate DataType="{x:Type data:ECUCMODULEDEF}"
ItemsSource ="{Binding Path=CONTAINERS}">
<TextBlock Text="{Binding Path=SHORTNAME.Value}" Foreground="Blue"/>
</HierarchicalDataTemplate>
<HierarchicalDataTemplate DataType="{x:Type data:ECUCPARAMCONFCONTAINERDEF}"
ItemsSource ="{Binding Path=SUBCONTAINERS}">
<TextBlock Text="{Binding Path=SHORTNAME.Value,StringFormat={}{0}_Param}" />
</HierarchicalDataTemplate>
<HierarchicalDataTemplate DataType="{x:Type data:ECUCCHOICECONTAINERDEF}"
ItemsSource ="{Binding Path=CHOICES}">
<TextBlock Text="{Binding Path=SHORTNAME.Value,StringFormat={}{0}_Choice}" />
</HierarchicalDataTemplate>
</ResourceDictionary>
通过以上部分,可以完成大部分ECU配置功能,基本上开发人员只要写很少代码即可。