Example #1
0
        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));
        }
Example #2
0
        public override void visit(ComponentAssembly obj)
        {
            Logger.WriteDebug("CyPhyBuildVisitor::visit({0})", obj.Impl.Path);

            var ca = obj.Impl;

            if (mode == CodeGenerator.Mode.SPICE || mode == CodeGenerator.Mode.SPICE_SI)
            {
                var spiceModels             = obj.Impl.Children.SPICEModelCollection;
                Tonka.SPICEModel spiceModel = GetSpiceModel(obj, spiceModels);

                if (spiceModel != null)
                {
                    GetSpiceModel(spiceModel, obj, isTestComponent: false);
                    foreach (var port in spiceModel.Children.SchematicModelPortCollection)
                    {
                        var port_obj = new Port(port)
                        {
                            Parent = obj,
                        };
                        obj.Ports.Add(port_obj);
                        CyPhyBuildVisitor.Ports.Add(port.ID, port_obj);
                        Logger.WriteInfo("Mapping Port <a href=\"mga:{0}\">{1}</a> with ID {2}", Traceability.GetID(port.Impl), port.Name, port.ID);
                    }
                }
            }


            // ------- ComponentAssemblies -------
            foreach (var innerComponentAssembly in ca.Children.ComponentAssemblyCollection)
            {
                var innerComponentAssembly_obj = new ComponentAssembly(innerComponentAssembly)
                {
                    Parent          = obj,
                    SystemUnderTest = this.systemUnderTest
                };
                obj.ComponentAssemblyInstances.Add(innerComponentAssembly_obj);
            }

            // ------- Components -------
            foreach (var component in ca.Children.ComponentCollection)
            {
                var component_obj = new Component(component)
                {
                    Parent          = obj,
                    SystemUnderTest = this.systemUnderTest
                };
                obj.ComponentInstances.Add(component_obj);
                CyPhyBuildVisitor.Components.Add(component.ID, component_obj);   // Add to global component list, component type ID-s?
                var componentInstanceGUID = Layout.LayoutGenerator.GetComponentID(component);
                //GME.CSharp.GMEConsole console = GME.CSharp.GMEConsole.CreateFromProject(component.Impl.Project);
                //console.Info.WriteLine(componentInstanceGUID);
                try
                {
                    CyPhyBuildVisitor.ComponentInstanceGUIDs.Add(componentInstanceGUID, component_obj);   // component instance guid-s?
                }
                catch (ArgumentException e)
                {
                    throw new ArgumentException(e.Message + " " + componentInstanceGUID);
                }
            }
        }