private string FindTestBenchParameter(Tonka.SPICEModelParameter parameter, FCO element) { Tonka.ValueFlow srcConnection = null; if (element is Tonka.Parameter) { srcConnection = ((Tonka.Parameter)element).SrcConnections.ValueFlowCollection.FirstOrDefault(); } else if (element is Tonka.Property) { srcConnection = ((Tonka.Property)element).SrcConnections.ValueFlowCollection.FirstOrDefault(); } else { CodeGenerator.Logger.WriteWarning("Encountered unsupported element <a href=\"mga:{1}\">{0}</a> while attempting to trace ValueFlow network from {4} Parameter <a href=\"mga:{3}\">{2}</a> back to a Test Bench Parameter. If you intend for {4} Parameter <a href=\"mga:{3}\">{2}</a> to update dynamically from one or more Test Bench Parameters, include only Parameters and/or Properties in the ValueFlow Network.", element.Name, traceability.GetID(element.Impl), parameter.Name, traceability.GetID(parameter.Impl), parameter.ParentContainer.ParentContainer.Name); return(null); } if (srcConnection == null) { if (element.ParentContainer is Tonka.TestBench) { CodeGenerator.Logger.WriteDebug("Mapped Test Bench Parameter <a href=\"mga:{1}\">{0}</a> to {4} Parameter <a href=\"mga:{3}\">{2}</a> from ValueFlow network.", element.Name, traceability.GetID(element.Impl), parameter.Name, traceability.GetID(parameter.Impl), parameter.ParentContainer.ParentContainer.Name); return("${" + element.Name + "}"); } else { return(null); } } return(FindTestBenchParameter(parameter, srcConnection.SrcEnd)); }
private CyPhy.Parameter FollowParam(CyPhy.Parameter input) { CyPhy.ValueFlow conn = null; while ((conn = input.SrcConnections.ValueFlowCollection.FirstOrDefault()) != null) { input = conn.SrcEnds.Parameter; } return(input); }
public void OutgoingValueFlowWithVariableName() { CyPhy.DesignContainer rootDC = null; CyPhy.ComponentRef comp1 = null; List <MgaFCO> selected = new List <MgaFCO>(); List <CyPhy.DesignContainer> childDCs = null; CyPhy.DesignContainer childDC = null; List <CyPhy.ComponentRef> childComponents = null; CyPhy.ComponentRef childComp1 = null; List <CyPhy.ValueFlow> childValueFlows = null; CyPhy.ValueFlow childValueFlow = null; proj.PerformInTransaction(delegate { // Assuming test model has 1 and only 1 DesignContainer called "ValueFlowVariableName" rootDC = proj.GetDesignContainersByName("ValueFlowVariableName").First(); comp1 = rootDC.Children .ComponentRefCollection .Where(x => x.Name == "C1") .First(); selected.Add(comp1.Impl as MgaFCO); }); Utils.RunDSRefactorer(rootDC.Impl as MgaFCO, selected, "DesignContainer"); proj.PerformInTransaction(delegate { // Assuming test model has 1 and only 1 DesignContainer called "ValueFlowVariableName" rootDC = proj.GetDesignContainersByName("ValueFlowVariableName").First(); // Make sure only 1 child DesignContainer of name 'NewDC_C1' is found childDCs = rootDC.Children .DesignContainerCollection .Where(x => x.Name == "NewDC__C1").ToList(); String countStr = "Count = " + childDCs.Count(); Assert.True(childDCs.Count() == 1, "Expected to find exactly 1 DesignContainer named 'NewDC__C1', " + countStr); // Make sure only 1 child ComponentRef of name 'C1' is found childDC = childDCs.First(); childComponents = childDC.Children .ComponentRefCollection .Where(x => x.Name == "C1").ToList(); Assert.True(childComponents.Count() == 1, "Expected to find exactly 1 ComponentRefs named 'C1' in DesignContainer 'NewDC__C1'"); // Make sure only this ComponentRef and original ComponentRef point to the same component childComp1 = childComponents.First(); Assert.True("C1" == childComp1.Referred.Component.Name, "Child ComponentRef and original ComponentRef points to different components!"); // Make sure that the ValueFlow has the alias 'C1P1' childValueFlows = rootDC.Children .ValueFlowCollection .Where(x => x.SrcEnd.Name == "CustomFormula_C1" && x.DstEnd.Kind == "CustomFormula").ToList(); Assert.True(childValueFlows.Count() == 1, "No ValueFlow found from 'CustomFormula_C1' property to the CustomFormula'"); childValueFlow = childValueFlows.First(); string aliasName = childValueFlow.Attributes.FormulaVariableName; Assert.True("C1P1" == aliasName, "Alias found on ValueFlow from 'CustomFormula_C1' property to CustomFormula is not 'C1P1'"); }); }