本文介绍在ARXML的自动解析库基础上如何进行修改,以支持配置工具的操作。
ECUCMODULEDEF moduleDef:用于创建的模型模版
ECUCMODULECONFIGURATIONVALUES moduleData:非空时,支持从配置数据创建
string moduleDefParentPath:用于创建的父路径
格式:/AUTOSAR/EcucDefs/CanIf/CanIfInitCfg
- public partial class ECUCMODULEDEF : INotifyPropertyChanged
- {
- public ECUCMODULEDEF(ECUCMODULEDEF moduleDef, ECUCMODULECONFIGURATIONVALUES moduleData, string moduleDefParentPath)
- {
-
- if (moduleDef != null)
- {
- this.PARAMTER_DEF_SHORT_NAME = moduleDef.SHORTNAME.Value;
- }
-
- if (moduleData != null)
- {
- this.SHORTNAME = moduleData.SHORTNAME;
- this.PARAMTER_DEF_FULL_URL_PATH = moduleData.DEFINITIONREF.Value;
-
- this.cONFIGURATIONVALUESField = moduleData;
- this.cONFIGURATIONCLASSField = moduleData.IMPLEMENTATIONCONFIGVARIANT;
- }
- else
- {
- this.SHORTNAME = moduleDef.SHORTNAME;
- this.PARAMTER_DEF_FULL_URL_PATH = moduleDefParentPath + "/" + moduleDef.SHORTNAME.Value;
-
- cONFIGURATIONVALUESField = new ECUCMODULECONFIGURATIONVALUES(moduleDef.SHORTNAME.Value, PARAMTER_DEF_FULL_URL_PATH);
- }
-
- this.LOWERMULTIPLICITY = moduleDef.LOWERMULTIPLICITY;
- this.UPPERMULTIPLICITY = moduleDef.UPPERMULTIPLICITY;
- this.UPPERMULTIPLICITYINFINITE = moduleDef.UPPERMULTIPLICITYINFINITE;
-
- this.REFINEDMODULEDEFREF = moduleDef.REFINEDMODULEDEFREF;
- this.DESC = moduleDef.DESC;
- this.INTRODUCTION = moduleDef.INTRODUCTION;
- this.LONGNAME = moduleDef.LONGNAME;
- this.SUPPORTEDCONFIGVARIANTS = moduleDef.SUPPORTEDCONFIGVARIANTS;
-
- CreateContainers(moduleDef, moduleData, moduleDefParentPath);
- }
- }
ECUCMODULEDEF moduleDef:用于创建的模型模版
ECUCMODULECONFIGURATIONVALUES moduleData:非空时,支持从配置数据创建
string moduleDefParentPath:用于创建的父路径
- public void CreateContainers(ECUCMODULEDEF moduleDef, ECUCMODULECONFIGURATIONVALUES moduleData, string moduleDefParentPath)
- {
- // 检查多重性为 (1:1)的子容器
- if (moduleDef.CONTAINERS != null)
- {
- //ObservableCollection
- //List
containers = new List(); - this.CONTAINERS = new ObservableCollection
(); - foreach (object container in moduleDef.CONTAINERS)
- {
- string containerType = container.GetType().ToString();
- if (containerType == Common.AR_NAME_SPACE + ".ECUCCHOICECONTAINERDEF")
- {
- if (Common.IsMultiplicityObject(container))
- {
- ECUCPARAMCONFCONTAINERDEF paramContainer = new ECUCPARAMCONFCONTAINERDEF((ECUCCHOICECONTAINERDEF)container,
- this.PARAMTER_DEF_FULL_URL_PATH,
- ((ECUCCHOICECONTAINERDEF)container).SHORTNAME.Value);
- paramContainer.IS_TOP_CONTAINER = true;
- CONTAINERS.Add(paramContainer);
- }
- }
- else if (containerType == Common.AR_NAME_SPACE + ".ECUCPARAMCONFCONTAINERDEF")
- {
- if (Common.IsMultiplicityObject(container))
- {
- // 创建虚拟容器
- ECUCPARAMCONFCONTAINERDEF paramContainer = new ECUCPARAMCONFCONTAINERDEF((ECUCPARAMCONFCONTAINERDEF)container,
- this.PARAMTER_DEF_FULL_URL_PATH,
- ((ECUCPARAMCONFCONTAINERDEF)container).SHORTNAME.Value);
- paramContainer.IS_TOP_CONTAINER = true;
- CONTAINERS.Add(paramContainer);
-
- }
- else if (Common.IsMandatoryObject(container))
- {
- ECUCPARAMCONFCONTAINERDEF paramContainer = new ECUCPARAMCONFCONTAINERDEF((ECUCPARAMCONFCONTAINERDEF)container,
- null,
- this.PARAMTER_DEF_FULL_URL_PATH,
- ((ECUCPARAMCONFCONTAINERDEF)container).SHORTNAME.Value, 1);
- paramContainer.IS_TOP_CONTAINER = true;
- CONTAINERS.Add(paramContainer);
-
- }
- }
- }
- }
- }
多重性大于1时,需要为视图创建一个虚拟容器,用于包含所有集合实例:
ECUCPARAMCONFCONTAINERDEF containerDef:配置模版参数容器
ECUCCONTAINERVALUE containterData:配置数据参数容器
- public ECUCPARAMCONFCONTAINERDEF(ECUCPARAMCONFCONTAINERDEF containerDef, ECUCCONTAINERVALUE containterData)
- {
- if (containerDef != null)
- {
- this.SHORTNAME = new IDENTIFIER(containerDef.SHORTNAME.Value);
- string url = containterData.DEFINITIONREF.Value;/// +"/" + containerDef.SHORTNAME.Value;
- this.PARAMTER_DEF_FULL_URL_PATH = url;
- CONFIGURATIONVALUES = new ECUCCONTAINERVALUE(containerDef.SHORTNAME.Value, url);
- }
-
- MultConfcontainerBuildCommon(containerDef);
- }
ECUCPARAMCONFCONTAINERDEF containerDef:配置模版参数容器
string containerDefParentPath: 配置模版父容器路径
string newName:新建容器名称
- public ECUCPARAMCONFCONTAINERDEF(ECUCPARAMCONFCONTAINERDEF containerDef, string containerDefParentPath, string newName)
- {
- if (containerDef != null)
- {
- this.SHORTNAME = new IDENTIFIER(newName);
- string url = containerDefParentPath + "/" + containerDef.SHORTNAME.Value;
- this.PARAMTER_DEF_FULL_URL_PATH = url;
- CONFIGURATIONVALUES = new ECUCCONTAINERVALUE(containerDef.SHORTNAME.Value, url);
- }
-
- MultConfcontainerBuildCommon(containerDef);
- }
ECUCPARAMCONFCONTAINERDEF containerDef:配置模版参数容器
ECUCCONTAINERVALUE containterData:配置数据参数容器
string containerDefParentPath:配置模版父容器路径
string newName:新建容器名称
- public ECUCPARAMCONFCONTAINERDEF(ECUCPARAMCONFCONTAINERDEF containerDef, ECUCCONTAINERVALUE containterData, string containerDefParentPath, string newName)
- {
- if (containerDef != null)
- {
- bool isMultFlg = false;
- if (containerDef.SHORTNAME.Value == UrlHandle.GetAbsolutePathLastStringName(containerDefParentPath))
- {
- isMultFlg = true;
- }
- if (containerDef.PARAMETERS != null)
- {
- //List
paramers = new List(); - this.PARAMETERS = new ObservableCollection<object>();
- foreach (Object defObject in containerDef.PARAMETERS)
- {
- Object paramer = ObjectHandle.CloneObject(defObject, Common.AR_DLL_NAME.GetType());
-
- IDENTIFIER shortName = (IDENTIFIER)(defObject.GetType().GetProperty("SHORTNAME").GetValue(defObject, null));
- string fullUrl = containerDefParentPath + "/" + shortName.Value;
- if (!isMultFlg)
- {
- fullUrl = containerDefParentPath + "/" + containerDef.SHORTNAME.Value + "/" + shortName.Value;
- }
- ((ECUCPARAMERSDEFBase)paramer).PARAMTER_DEF_FULL_URL_PATH = fullUrl;
- ((ECUCPARAMERSDEFBase)paramer).LoadDefaultValueIntoSetValue();
- this.PARAMETERS.Add(paramer);
- }
- //this.PARAMETERS = paramers.ToArray();
- }
-
- if (containerDef.REFERENCES != null)
- {
- List
references = new List(); - foreach (Object defObject in containerDef.REFERENCES)
- {
- Object reference = ObjectHandle.CloneObject(defObject, Common.AR_DLL_NAME.GetType());
- IDENTIFIER shortName = (IDENTIFIER)(defObject.GetType().GetProperty("SHORTNAME").GetValue(defObject, null));
- string fullUrl = containerDefParentPath + "/" + shortName.Value;
- if (!isMultFlg)
- {
- fullUrl = containerDefParentPath + "/" + containerDef.SHORTNAME.Value + "/" + shortName.Value;
- }
-
- ((REFERENCESBase)reference).PARAMTER_DEF_FULL_URL_PATH = fullUrl;
- //((ECUCPARAMERSDEFBase)paramer).LoadDefaultValueIntoSetValue();
- if (reference != null)
- {
- references.Add(reference);
- }
- }
-
- this.REFERENCES = new ObservableCollection<object>();
- foreach (object obj in references)
- {
- this.REFERENCES.Add(obj);
- }
- }
-
- this.PARAMTER_DEF_SHORT_NAME = containerDef.SHORTNAME.Value;
-
- if (containterData != null) // 由数据加载到定义
- {
- this.SHORTNAME = containterData.SHORTNAME;
-
- string cTemplateStr = containterData.DEFINITIONREF.Value;
- this.PARAMTER_DEF_FULL_URL_PATH = cTemplateStr;
-
- this.CONFIGURATIONVALUES = containterData;
- }
- else
- {
- this.SHORTNAME = new IDENTIFIER(newName);
-
- // 多重性容器,补丁
- if (isMultFlg)
- {
- this.PARAMTER_DEF_FULL_URL_PATH = containerDefParentPath;
-
- // 该部分与module调用的构造函数不同之处
- this.LOWERMULTIPLICITY = containerDef.LOWERMULTIPLICITY;// TODO: 只有【1, 1】复杂度
-
- string[] LowerMulitplicityValue = { "1" };
- string[] UpperMulitplicityValue = { "1" };
- string[] UpperMulitplicityInfiniteValue = { "false" };
-
- POSITIVEINTEGERVALUEVARIATIONPOINT LowerMulitplicity = new POSITIVEINTEGERVALUEVARIATIONPOINT();
- LowerMulitplicity.Text = LowerMulitplicityValue;
- this.LOWERMULTIPLICITY = LowerMulitplicity;
-
- POSITIVEINTEGERVALUEVARIATIONPOINT UpperMulitplicity = new POSITIVEINTEGERVALUEVARIATIONPOINT();
- UpperMulitplicity.Text = UpperMulitplicityValue;
- this.UPPERMULTIPLICITY = UpperMulitplicity;
-
- BOOLEANVALUEVARIATIONPOINT UpperMulitplicityInfinite = new BOOLEANVALUEVARIATIONPOINT();
- UpperMulitplicityInfinite.Text = UpperMulitplicityInfiniteValue;
- }
- else
- {
- this.PARAMTER_DEF_FULL_URL_PATH = containerDefParentPath + "/" + containerDef.SHORTNAME.Value;
- this.LOWERMULTIPLICITY = containerDef.LOWERMULTIPLICITY;// TODO: 只有【1, 1】复杂度
- this.UPPERMULTIPLICITY = containerDef.UPPERMULTIPLICITY;
- this.UPPERMULTIPLICITYINFINITE = containerDef.UPPERMULTIPLICITYINFINITE;
- }
-
- this.INTRODUCTION = containerDef.INTRODUCTION;
- this.DESC = containerDef.DESC;
-
- CONFIGURATIONVALUES = new ECUCCONTAINERVALUE(containerDef.SHORTNAME.Value, PARAMTER_DEF_FULL_URL_PATH);
- }
- CreateSubContainer(containerDef, containterData, containerDefParentPath, newName);
- }
- }
ECUCPARAMCONFCONTAINERDEF containerDef:配置模版参数容器
ECUCCONTAINERVALUE containterData:配置数据参数容器
string containerDefParentPath:配置模版父容器路径
string newNam:新建容器名称
- public void CreateSubContainer(ECUCPARAMCONFCONTAINERDEF containerDef, ECUCCONTAINERVALUE containterData, string containerDefParentPath, string newName)
- {
- // 检查多重性为 (1:1)的子容器
- if (containerDef.SUBCONTAINERS != null)
- {
- //List
containers = new List(); - SUBCONTAINERS = new ObservableCollection<object>();
- foreach (object container in containerDef.SUBCONTAINERS)
- {
- string containerType = container.GetType().ToString();
- if (containerType == Common.AR_NAME_SPACE + ".ECUCCHOICECONTAINERDEF")
- {
- if (Common.IsMultiplicityObject(container))
- {
- ECUCPARAMCONFCONTAINERDEF paramContainer = new ECUCPARAMCONFCONTAINERDEF((ECUCCHOICECONTAINERDEF)container,
- this.PARAMTER_DEF_FULL_URL_PATH,
- ((ECUCCHOICECONTAINERDEF)container).SHORTNAME.Value);
- SUBCONTAINERS.Add(paramContainer);
- }
- else if (Common.IsMandatoryObject(container))
- {
- string newCondName = ((ECUCCHOICECONTAINERDEF)container).SHORTNAME.Value;
- ECUCCHOICECONTAINERDEF paramContainer = new ECUCCHOICECONTAINERDEF((ECUCCHOICECONTAINERDEF)container,
- null,
- this.PARAMTER_DEF_FULL_URL_PATH, newCondName);
- SUBCONTAINERS.Add(paramContainer);
- }
- }
- else if (containerType == Common.AR_NAME_SPACE + ".ECUCPARAMCONFCONTAINERDEF")
- {
- if (Common.IsMultiplicityObject(container))
- {
- if (containterData != null) // 加载配置数据时功能分支
- {
- ECUCPARAMCONFCONTAINERDEF paramContainer = new ECUCPARAMCONFCONTAINERDEF((ECUCPARAMCONFCONTAINERDEF)container,
- containterData.DEFINITIONREF.Value,
- ((ECUCPARAMCONFCONTAINERDEF)container).SHORTNAME.Value);
- SUBCONTAINERS.Add(paramContainer);
- }
- else // 无加载配置数据时功能分支
- {
- ECUCPARAMCONFCONTAINERDEF paramContainer = new ECUCPARAMCONFCONTAINERDEF((ECUCPARAMCONFCONTAINERDEF)container,
- this.PARAMTER_DEF_FULL_URL_PATH,
- ((ECUCPARAMCONFCONTAINERDEF)container).SHORTNAME.Value);
- SUBCONTAINERS.Add(paramContainer);
- }
- }
- else if (Common.IsMandatoryObject(container)) // Must create one.
- {
- string newCondName = ((ECUCPARAMCONFCONTAINERDEF)container).SHORTNAME.Value;
- ECUCPARAMCONFCONTAINERDEF paramContainer = new ECUCPARAMCONFCONTAINERDEF((ECUCPARAMCONFCONTAINERDEF)container, null, this.PARAMTER_DEF_FULL_URL_PATH, newCondName);
- SUBCONTAINERS.Add(paramContainer);
- }
- }
- }
- }
- }