/// <summary> /// Returns PCCProperties for all Properties in the component that fullfil the requirements to be a PCCProperty. /// If called with doLog and a Property has the registry node "Distribution" it will be added to DirtyProperties if the property /// does not fulfill the requirements. /// </summary> /// <param name="doLog">Indicating if info should be written to log and if DirtyProperties are gathered.</param> /// <returns>All properties that fulfill the requirements.</returns> private List <PCC.PCCProperty> GetPCCPropertiesFromComponent(bool doLog = false) { var results = new List <PCC.PCCProperty>(); var component = CyPhyClasses.Component.Cast(this.MainParameters.CurrentFCO); if (doLog) { this.Logger.WriteInfo("Looking for candidate properties in component.."); } foreach (var property in component.Children.PropertyCollection) { double value; if (property.DstConnections.ModelicaParameterPortMapCollection.Any() == false && doLog) { this.Logger.WriteInfo("Not adding {0} to GUI - it does not map to a ModelicaParameter", property.Name); var distValue = (property.Impl as GME.MGA.MgaFCO).RegistryNode["Distribution"].Value; if (distValue != null) { this.Logger.WriteDebug("It had a Distribution registry, will be cleaned up..."); this.DirtyProperties.Add(new PCC.PCCProperty(property)); } } else if (property.SrcConnections.ValueFlowCollection.Any() && doLog) { this.Logger.WriteInfo("Not adding {0} to GUI - it has an incoming value flow.", property.Name); var distValue = (property.Impl as GME.MGA.MgaFCO).RegistryNode["Distribution"].Value; if (distValue != null) { this.Logger.WriteDebug("It had a Distribution registry, will be cleaned up..."); this.DirtyProperties.Add(new PCC.PCCProperty(property)); } } else if (double.TryParse(property.Attributes.Value, out value) == false && doLog) { this.Logger.WriteInfo("Not adding {0} to GUI - '{1}' is not a real value.", property.Name, property.Attributes.Value); var distValue = (property.Impl as GME.MGA.MgaFCO).RegistryNode["Distribution"].Value; if (distValue != null) { this.Logger.WriteDebug("It had a Distribution registry, will be cleaned up..."); this.DirtyProperties.Add(new PCC.PCCProperty(property)); } } else { var pccProp = new PCC.PCCProperty(property); var distValue = (property.Impl as GME.MGA.MgaFCO).RegistryNode["Distribution"].Value; if (distValue != null) { if (doLog) { this.Logger.WriteDebug("Found Distribution registry node for {0}, Value : {1}", property.Name, distValue); } var success = pccProp.UpdateDistributionFromExistingNode(distValue); if (success == false && doLog) { this.Logger.WriteDebug("but was in wrong format. Resetting..."); } } results.Add(pccProp); } } return(results); }
/// <summary> /// Returns PCCProperties for all Properties in the component that fullfil the requirements to be a PCCProperty. /// If called with doLog and a Property has the registry node "Distribution" it will be added to DirtyProperties if the property /// does not fulfill the requirements. /// </summary> /// <param name="doLog">Indicating if info should be written to log and if DirtyProperties are gathered.</param> /// <returns>All properties that fulfill the requirements.</returns> private List<PCC.PCCProperty> GetPCCPropertiesFromComponent(bool doLog = false) { var results = new List<PCC.PCCProperty>(); var component = CyPhyClasses.Component.Cast(this.MainParameters.CurrentFCO); if (doLog) { this.Logger.WriteInfo("Looking for candidate properties in component.."); } foreach (var property in component.Children.PropertyCollection) { double value; if (property.DstConnections.ModelicaParameterPortMapCollection.Any() == false && doLog) { this.Logger.WriteInfo("Not adding {0} to GUI - it does not map to a ModelicaParameter", property.Name); var distValue = (property.Impl as GME.MGA.MgaFCO).RegistryNode["Distribution"].Value; if (distValue != null) { this.Logger.WriteDebug("It had a Distribution registry, will be cleaned up..."); this.DirtyProperties.Add(new PCC.PCCProperty(property)); } } else if (property.SrcConnections.ValueFlowCollection.Any() && doLog) { this.Logger.WriteInfo("Not adding {0} to GUI - it has an incoming value flow.", property.Name); var distValue = (property.Impl as GME.MGA.MgaFCO).RegistryNode["Distribution"].Value; if (distValue != null) { this.Logger.WriteDebug("It had a Distribution registry, will be cleaned up..."); this.DirtyProperties.Add(new PCC.PCCProperty(property)); } } else if (double.TryParse(property.Attributes.Value, out value) == false && doLog) { this.Logger.WriteInfo("Not adding {0} to GUI - '{1}' is not a real value.", property.Name, property.Attributes.Value); var distValue = (property.Impl as GME.MGA.MgaFCO).RegistryNode["Distribution"].Value; if (distValue != null) { this.Logger.WriteDebug("It had a Distribution registry, will be cleaned up..."); this.DirtyProperties.Add(new PCC.PCCProperty(property)); } } else { var pccProp = new PCC.PCCProperty(property); var distValue = (property.Impl as GME.MGA.MgaFCO).RegistryNode["Distribution"].Value; if (distValue != null) { if (doLog) { this.Logger.WriteDebug("Found Distribution registry node for {0}, Value : {1}", property.Name, distValue); } var success = pccProp.UpdateDistributionFromExistingNode(distValue); if (success == false && doLog) { this.Logger.WriteDebug("but was in wrong format. Resetting..."); } } results.Add(pccProp); } } return results; }