diff --git a/EDSEditorGUI/Form1.cs b/EDSEditorGUI/Form1.cs index 8aae707a..edef9f57 100644 --- a/EDSEditorGUI/Form1.cs +++ b/EDSEditorGUI/Form1.cs @@ -180,6 +180,17 @@ void ProfileAddClick(object sender, EventArgs e) } } + private void AddArrayElementAttributeWarnings(EDSsharp eds) + { + // Only CANopenNode V4 stores a single attribute for all elements of an ARRAY. + // For other stacks different access of the elements is valid, so do not warn. + if ((ExporterFactory.Exporter)Properties.Settings.Default.ExporterType != ExporterFactory.Exporter.CANOPENNODE_V4) + return; + + foreach (string warning in eds.VerifyArrayElementAttributes()) + Warnings.AddWarning(warning, Warnings.warning_class.WARNING_BUILD); + } + private void openEDSfile(string path,InfoSection.Filetype ft) { Warnings.warning_list.Clear(); @@ -190,6 +201,7 @@ private void openEDSfile(string path,InfoSection.Filetype ft) eds.Loadfile(path); Warnings.warning_list.AddRange(eds.VerifyCompoundSubIndexZero()); + AddArrayElementAttributeWarnings(eds); DeviceView device = new DeviceView(eds, network); @@ -332,6 +344,7 @@ private void openXDDfile(string path) { EDSsharp eds = XddLoader.Load(path); Warnings.warning_list.AddRange(eds.VerifyCompoundSubIndexZero()); + AddArrayElementAttributeWarnings(eds); eds.projectFilename = path; tabControl1.TabPages.Add(eds.di.ProductName); diff --git a/EditorRegressionTests/EditorRegressionTests.cs b/EditorRegressionTests/EditorRegressionTests.cs index 18b00d11..520ed314 100644 --- a/EditorRegressionTests/EditorRegressionTests.cs +++ b/EditorRegressionTests/EditorRegressionTests.cs @@ -328,6 +328,109 @@ private static void XddSchemaLoading() } } + private static void SetEnum(object target, string name, string value) + { + FieldInfo field = target.GetType().GetField(name); + field.SetValue(target, Enum.Parse(field.FieldType, value)); + } + + private static void AddCompoundElement(object compound, ushort subindex, string datatype, string access, string defaultvalue) + { + object element = Activator.CreateInstance(compound.GetType()); + compound.GetType().GetField("parent").SetValue(element, compound); + compound.GetType().GetField("parameter_name").SetValue(element, "Element " + subindex); + compound.GetType().GetField("defaultvalue").SetValue(element, defaultvalue); + SetEnum(element, "objecttype", "VAR"); + SetEnum(element, "datatype", datatype); + SetEnum(element, "accesstype", access); + ((IDictionary)Field(compound, "subobjects")).Add(subindex, element); + } + + private static Form[] OpenWarningForms() + { + return Application.OpenForms.Cast