diff --git a/src/CyPhyPET/Rules/Global.cs b/src/CyPhyPET/Rules/Global.cs index 47609297d..0cff0d7b6 100755 --- a/src/CyPhyPET/Rules/Global.cs +++ b/src/CyPhyPET/Rules/Global.cs @@ -142,7 +142,46 @@ public static IEnumerable UniqueTestBenchRefNames(CyPhy.Parame .Concat(pet.Children.DriverCollection) .Concat(pet.Children.ParametricExplorationCollection); - return UniqueNames(components); + return UniqueConstantsParametersAndOutputs(pet) + .Concat(UniqueNames(components)); + } + + public static IEnumerable UniqueConstantsParametersAndOutputs(CyPhy.ParametricExploration pet) + { + var result = new List(); + + var names = pet.Children.ConstantsCollection.SelectMany( + constants_block => constants_block.Children.MetricCollection.Select( + constant => new Tuple(constant.Name, string.Format("{0}.{1} ({2})", constants_block.Name, constant.Name, constant.Kind)))); + names = names.Concat(pet.Children.DriverCollection.SelectMany( + driver => driver.AllChildren.Where( + child => new List() { typeof(CyPhyClasses.DesignVariable).Name, typeof(CyPhyClasses.IntermediateVariable).Name, typeof(CyPhyClasses.Objective).Name }.Contains(child.Kind)).Select( + child => new Tuple(child.Name, string.Format("{0}.{1} ({2})", driver.Name, child.Name, child.Kind))))); + + foreach (var group in names.GroupBy(variable => variable.Item1).Where(group => group.Count() > 1)) + { + var feedback = new GenericRuleFeedback() + { + FeedbackType = FeedbackTypes.Warning, + InvolvedObjectsByRole = null, + Message = string.Format( + "PET requires unique names. Duplicate Names: {0}: {1}", + group.Key, String.Join(",", group.Select(pair => pair.Item2).ToArray())) + }; + result.Add(feedback); + } + if (result.Count() > 0) + { + var feedback = new GenericRuleFeedback() + { + FeedbackType = FeedbackTypes.Warning, + InvolvedObjectsByRole = null, + Message = "Values in Merged PET file for variables with conflicting names may not get associated corretly" + }; + result.Insert(0, feedback); + } + + return result; } public static IEnumerable UniqueNames(IEnumerable components) @@ -155,6 +194,7 @@ public static IEnumerable UniqueNames(IEnumerable compone var feedback = new GenericRuleFeedback() { FeedbackType = FeedbackTypes.Error, + InvolvedObjectsByRole = null, Message = string.Format("PET requires unique names. Duplicate names: {0}", String.Join(",", dupNames.ToArray())) }; result.Add(feedback);