Пример #1
0
        private CyPhy.ComponentAssembly CreateComponentAssemblyRoot(avm.Design ad_import)
        {
            CyPhy.ComponentAssemblies cyphy_cas;
            CyPhy.RootFolder          rf = CyPhyClasses.RootFolder.GetRootFolder((MgaProject)project);
            cyphy_cas = rf.Children.ComponentAssembliesCollection.Where(d => d.Name == typeof(CyPhyClasses.ComponentAssemblies).Name).FirstOrDefault();
            if (cyphy_cas == null)
            {
                cyphy_cas      = CyPhyClasses.ComponentAssemblies.Create(rf);
                cyphy_cas.Name = typeof(CyPhyClasses.ComponentAssemblies).Name;
            }
            CyPhy.ComponentAssembly cyphy_container = CyPhyClasses.ComponentAssembly.Create(cyphy_cas);
            // container.Name = ad_import.Name; RootContainer has a name too
            // TODO: check ad_import.SchemaVersion
            int designID;

            if (int.TryParse(ad_import.DesignID, out designID))
            {
                cyphy_container.Attributes.ID = designID;
            }
            if (string.IsNullOrEmpty(ad_import.RootContainer.Description) == false)
            {
                cyphy_container.Attributes.Description = ad_import.RootContainer.Description;
            }
            return(cyphy_container);
        }
Пример #2
0
        private static int GetContainingAssemblies(CyPhyML.ComponentAssembly assembly, Dictionary <CyPhyML.DesignElement, int> visited,
                                                   List <CyPhyML.ComponentAssembly> sorted)
        {
            int ordinal;

            if (visited.TryGetValue(assembly, out ordinal))
            {
                if (ordinal == -1)
                {
                    throw new Exception(String.Format("Cycle involving {0}", assembly.Name));
                }
                return(ordinal);
            }
            visited.Add(assembly, -1);
            ordinal = 0;
            foreach (CyPhyML.ComponentRef compref in assembly.ReferencedBy.ComponentRef)
            {
                if (compref.ParentContainer is CyPhyML.ComponentAssembly)
                {
                    ordinal = Math.Max(ordinal, 1 + GetContainingAssemblies(compref.ParentContainer as CyPhyML.ComponentAssembly, visited, sorted));
                }
            }
            if (assembly.ParentContainer is CyPhyML.ComponentAssembly)
            {
                ordinal = Math.Max(ordinal, 1 + GetContainingAssemblies(assembly.ParentContainer as CyPhyML.ComponentAssembly, visited, sorted));
            }
            visited[assembly] = ordinal;
            sorted.Add(assembly);
            return(ordinal);
        }
Пример #3
0
        private void Process(CyPhy.ComponentAssembly componentAssembly)
        {
            if (Logger == null)
            {
                Logger = new CyPhyGUIs.GMELogger(componentAssembly.Impl.Project, this.ComponentName);
            }

            if (String.IsNullOrWhiteSpace(componentAssembly.Attributes.Path))
            {
                componentAssembly.Attributes.Path = GetRandomComponentAssemblyDir();
            }
            else
            {
                string originalPath = Path.Combine(componentAssembly.Impl.Project.GetRootDirectoryPath(), componentAssembly.Attributes.Path);
                componentAssembly.Attributes.Path = GetRandomComponentAssemblyDir();
                if (Directory.Exists(originalPath))
                {
                    try
                    {
                        CopyDirectory(originalPath, Path.Combine(componentAssembly.Impl.Project.GetRootDirectoryPath(), componentAssembly.Attributes.Path));
                    }
                    catch (Exception ex)
                    {
                        Logger.WriteError("Exception while copying to {0}: {1}", componentAssembly.Attributes.Path, ex);
                    }
                }
            }
        }
Пример #4
0
        /// <summary>
        /// Gets ComponentAssemblys that contain component directly, or through references to ComponentAssemblys
        /// </summary>
        public static IEnumerable <CyPhyML.ComponentAssembly> GetContainingAssemblies(CyPhyML.Component component)
        {
            Queue <CyPhyML.ComponentAssembly> containingAssemblies = new Queue <CyPhyML.ComponentAssembly>();

            foreach (CyPhyML.ComponentRef compref in component.ReferencedBy.ComponentRef)
            {
                if (compref.ParentContainer is CyPhyML.ComponentAssembly)
                {
                    containingAssemblies.Enqueue(compref.ParentContainer as CyPhyML.ComponentAssembly);
                }
            }
            while (containingAssemblies.Count > 0)
            {
                CyPhyML.ComponentAssembly asm = containingAssemblies.Dequeue();
                yield return(asm);

                foreach (CyPhyML.ComponentRef compref in asm.ReferencedBy.ComponentRef)
                {
                    if (compref.ParentContainer is CyPhyML.ComponentAssembly)
                    {
                        containingAssemblies.Enqueue(compref.ParentContainer as CyPhyML.ComponentAssembly);
                    }
                }
                if (asm.ParentContainer is CyPhyML.ComponentAssembly)
                {
                    containingAssemblies.Enqueue(asm.ParentContainer as CyPhyML.ComponentAssembly);
                }
            }
        }
Пример #5
0
 // Verify ComponentAssembly model so that it's Meta-Link compatible
 private bool VerifyAssembly(CyPhyML.ComponentAssembly assembly, List <string> errorList)
 {
     // An assembly should only contain component references
     if (assembly.Children.ComponentCollection.Any())
     {
         foreach (var comp in assembly.Children.ComponentCollection)
         {
             errorList.Add("The assembly contains a component:" + comp.Name + ". Meta-Link will only work with references.");
         }
     }
     if (assembly.Children.ComponentAssemblyCollection.Any())
     {
         foreach (var comp in assembly.Children.ComponentCollection)
         {
             errorList.Add("The assembly contains a component assembly:" + comp.Name + ". Meta-Link will only work with references.");
         }
     }
     foreach (var cref in assembly.Children.ComponentRefCollection)
     {
         if (cref.AllReferred == null)
         {
             errorList.Add("The assembly contains a null-reference:" + cref.Name);
         }
     }
     VerifyCADResources(assembly, errorList);
     return(errorList.Count == 0);
 }
Пример #6
0
        // Collects all the component references this assembly contains, including multi-level hierarchies
        public static List <CyPhyML.ComponentRef> CollectComponentRefsRecursive(CyPhyML.ComponentAssembly assembly)
        {
            List <CyPhyML.ComponentRef> complist = new List <CyPhyML.ComponentRef>();

            CollectComponentRefs(complist, assembly);
            return(complist);
        }
Пример #7
0
        // Collects all the components this assembly contains, including multi-level hierarchies
        public static HashSet <CyPhyML.Component> CollectComponentsRecursive(CyPhyML.ComponentAssembly assembly)
        {
            HashSet <CyPhyML.Component> complist = new HashSet <CyPhyML.Component>();

            CollectComponents(complist, assembly);
            return(complist);
        }
Пример #8
0
        private void PartManufacturingGeneration(CyPhy.ComponentAssembly componentasm)
        {
            // [1] Create ManufacturingData
            // [2] Regenerate manufacturing xml file for each ManufacturingData
            // [3] Generate manifest file

            if (this.AVMComponentList == null)
            {
                return;
            }

            TraverseComponentAssembly(componentasm);
            //foreach (ComponentManufacturingData data in this.ComponentManufacturingDataList)
            //{
            //    data.UpdateManufacturingSpec();
            //}

            // manifest
            string reportJson = Newtonsoft.Json.JsonConvert.SerializeObject(
                this.ManufacturingManifestData,
                Newtonsoft.Json.Formatting.Indented);

            using (StreamWriter writer = new StreamWriter(Path.Combine(this.OutputDirectory, "manufacturing.manifest.json")))
            {
                writer.WriteLine(reportJson);
            }
        }
Пример #9
0
        public void FindComponents(CyPhy.ComponentAssembly cyphyasm,
                                   List <CyPhy.Component> regular,
                                   List <CyPhy.Component> size2fit)
        {
            CheckAssembly(cyphyasm);

            foreach (var item in cyphyasm.Children.ComponentAssemblyCollection)
            {
                FindComponents(item, regular, size2fit);
            }

            foreach (var item in cyphyasm.Children.ComponentCollection)
            {
                if (CheckComponent(item))
                {
                    // size2fit or regular
                    if (item.Children.SizedToFitCollection.Any())
                    {
                        size2fit.Add(item);
                    }
                    else
                    {
                        regular.Add(item);
                    }
                }
            }
        }
Пример #10
0
 private static void CollectComponents(HashSet <CyPhyML.Component> complist, CyPhyML.ComponentAssembly assembly, HashSet <CyPhyML.ComponentAssembly> visitedComponentAssemblies)
 {
     // Get all the components from here
     foreach (var compref in assembly.Children.ComponentRefCollection)
     {
         if (compref.AllReferred is CyPhyML.Component)
         {
             complist.Add(compref.AllReferred as CyPhyML.Component);
         }
         else if (compref.AllReferred is CyPhyML.ComponentAssembly)
         {
             if (visitedComponentAssemblies.Add(compref.AllReferred as CyPhyML.ComponentAssembly) == false)
             {
                 throw new ApplicationException(String.Format("Cycle involving {0}", compref.AllReferred.Name));
             }
             CollectComponents(complist, compref.AllReferred as CyPhyML.ComponentAssembly, visitedComponentAssemblies);
             visitedComponentAssemblies.Remove(compref.AllReferred as CyPhyML.ComponentAssembly);
         }
     }
     foreach (var comp in assembly.Children.ComponentCollection)
     {
         complist.Add(comp);
     }
     foreach (var ca in assembly.Children.ComponentAssemblyCollection)
     {
         CollectComponents(complist, ca, visitedComponentAssemblies);
     }
 }
Пример #11
0
        private void PrepareMetaLinkData(CyPhy2CAD_CSharp.MetaLinkData data, CyPhyML.ComponentAssembly assembly, String prefix)
        {
            Dictionary <string, CyPhyML.ComponentRef> instanceguids = new Dictionary <string, CyPhyML.ComponentRef>();

            CyphyMetaLinkUtils.CollectInstanceGUIDs(instanceguids, "", assembly);
            if (assembly.Children.ComponentCollection.Any())
            {
                GMEConsole.Warning.WriteLine("Assembly contains components, Meta-Link may not work properly on this model.");
            }
            //List<CyPhyML.ComponentRef> comps = CyphyMetaLinkUtils.CollectComponentRefsRecursive(assembly);
            foreach (var item in instanceguids)
            {
                CyPhy2CAD_CSharp.MetaLinkData.Component mcomp = new CyPhy2CAD_CSharp.MetaLinkData.Component();
                mcomp.ID    = item.Key;
                mcomp.AvmID = (item.Value.AllReferred as CyPhyML.Component).Attributes.AVMID;
                data.Components.Add(mcomp);
                foreach (CyPhyML.Connector conn in (item.Value.AllReferred as CyPhyML.Component).Children.ConnectorCollection)
                {
                    CyPhy2CAD_CSharp.MetaLinkData.Connector mconn = new CyPhy2CAD_CSharp.MetaLinkData.Connector();
                    mconn.ID          = conn.Guid.ToString();
                    mconn.DisplayName = conn.Name;
                    mcomp.Connectors.Add(mconn);
                    foreach (CyPhyML.CADDatum d in conn.Children.CADDatumCollection)
                    {
                        CyPhy2CAD_CSharp.MetaLinkData.Datum md = new CyPhy2CAD_CSharp.MetaLinkData.Datum();
                        md.ID          = d.Guid.ToString();
                        md.DisplayName = d.Name;
                        mconn.Datums.Add(md);
                    }
                }
            }
        }
Пример #12
0
 /// <summary>
 /// Injects Meta-Link related data into a pre-existing structure
 /// </summary>
 /// <param name="assembly"></param>
 public void InjectMetaLinkData(CyPhy.ComponentAssembly assembly, MetaLinkData data)
 {
     // There's only one cadassembly in case of Meta-Link!!
     foreach (DataRep.CADAssembly a in assemblies.Values)
     {
         a.MetaLinkData = data;
     }
 }
Пример #13
0
        /// <summary>
        /// Meta-Link feature: If there's no components in an assembly still need to add one empty root component
        /// </summary>
        /// <param name="?"></param>
        public void AddRootComponent(CyPhy.ComponentAssembly assembly)
        {
            CADAssembly a = new CADAssembly();

            a.Id   = a.ConfigID = assembly.Guid.ToString();
            a.Name = a.DisplayName = assembly.Name;
            assemblies.Add(UtilityHelpers.CleanString2(assembly.Name), a);
        }
Пример #14
0
        private void VerifyCADResources(CyPhyML.ComponentAssembly assembly, List <string> errorList)
        {
            var componentlist = CyphyMetaLinkUtils.CollectComponentsRecursive(assembly);

            foreach (var component in componentlist)
            {
                VerifyCADResources(component, errorList);
            }
        }
Пример #15
0
        public CommonTraversal(CyPhy.ConnectorComposition connection, CyPhy.ComponentAssembly topassembly)
        {
            Initialize();
            startNodeID = "";

            this.topAssembly = topassembly;

            VisitConnectorComposition(connection);
        }
Пример #16
0
        public CommonTraversal(CyPhy.ConnectorComposition connection, CyPhy.ComponentAssembly topassembly)
        {
            Initialize();
            startNodeID = "";

            this.topAssembly = topassembly;

            VisitConnectorComposition(connection);
        }
Пример #17
0
        public void FindTopLevelPort(CyPhy.ComponentAssembly topAssembly)
        {
            return;

            /*
             * CyPhy.KinematicJoint joint = CyphyJoint;
             * string id = null;
             * while (true)
             * {
             *  if (joint.DstConnections.JointCompositionCollection.Any())
             *  {
             *      if (joint.DstConnections.JointCompositionCollection.First().DstEnds.KinematicJoint == null)
             *      {
             *          id = joint.Name;
             *      }
             *      else
             *      {
             *          joint = joint.DstConnections.JointCompositionCollection.First().DstEnds.KinematicJoint;
             *      }
             *  }
             *  else
             *  {
             *      if (joint != CyphyJoint && joint.ParentContainer.Guid == topAssembly.Guid)
             *          id = joint.Name;
             *      break;
             *  }
             * }
             * if (id == null)
             * {
             *  while (true)
             *  {
             *      if (joint.SrcConnections.JointCompositionCollection.Any())
             *      {
             *          if (joint.SrcConnections.JointCompositionCollection.First().SrcEnds.KinematicJoint == null)
             *          {
             *              id = joint.Name;
             *              break;
             *          }
             *          else
             *          {
             *              joint = joint.SrcConnections.JointCompositionCollection.First().SrcEnds.KinematicJoint;
             *          }
             *      }
             *      else
             *      {
             *          if (joint != CyphyJoint && joint.ParentContainer.Guid == topAssembly.Guid)
             *              id = joint.Name;
             *          break;
             *      }
             *  }
             * }
             *
             * this.TopLevelID = id;
             */
        }
Пример #18
0
        public void CreateFlatData(CyPhy.ComponentAssembly cyphyasm)
        {
            List <CyPhy.Component> regular            = new List <CyPhy.Component>();
            List <CyPhy.Component> size2fitcomponents = new List <CyPhy.Component>();

            // [1] Grabs all components
            FindComponents(cyphyasm, regular, size2fitcomponents);

            ProcessComponents(regular, size2fitcomponents, cyphyasm);
            ProcessReferenceCoordinateSystems(cyphyasm);
        }
Пример #19
0
        public override void Expand(CyPhy.ComponentAssembly configuration)
        {
            this.Configuration = configuration;

            if (this.OriginalSystemUnderTest.Referred.DesignEntity.ID == configuration.ID)
            {
                this.expandedTestBenchType = this.testBenchType;
            }
            else
            {
                // create temp folder for test bench
                CyPhy.Testing testing = CyPhyClasses.Testing.Cast(this.testBenchType.ParentContainer.Impl);

                var tempFolderName = AnalysisModelProcessor.GetTemporaryFolderName(this.testBenchType.Impl);

                CyPhy.Testing tempFolder = testing.Children.TestingCollection.FirstOrDefault(x => x.Name == tempFolderName);
                if (tempFolder == null)
                {
                    tempFolder      = CyPhyClasses.Testing.Create(testing);
                    tempFolder.Name = tempFolderName;

                    this.AddToTraceabilityAndTemporary(tempFolder.Impl, testing.Impl, recursive: false);
                }

                // copy test bench
                var tempCopy = (tempFolder.Impl as MgaFolder).CopyFCODisp(this.testBenchType.Impl as MgaFCO);
                // fix name
                tempCopy.Name = AnalysisModelProcessor.GetTemporaryObjectName(this.testBenchType.Impl, configuration.Impl);

                this.AddToTraceabilityAndTemporary(tempCopy, this.testBenchType.Impl);

                // set expanded property to the expanded element
                this.expandedTestBenchType = CyPhyClasses.TestBenchType.Cast(tempCopy);

                var tlsut = this.expandedTestBenchType.Children.TopLevelSystemUnderTestCollection.FirstOrDefault();

                // switch references
                try
                {
                    // redirect SUT
                    var switcher = new ReferenceSwitcher.ReferenceSwitcherInterpreter();
                    switcher.SwitchReference(configuration.Impl as MgaFCO, tlsut.Impl as IMgaReference);
                }
                catch (Exception ex)
                {
                    // handle failures for this (use case we can lose ports/connections/
                    // what if something is an instance/subtype/readonly etc...
                    throw new AnalysisModelExpandFailedException("ReferenceSwitcher failed.", ex);
                }

                // redirect TIPs
                this.SwitchAllTipReferences();
            }
        }
Пример #20
0
 public void ProcessReferenceCoordinateSystems(CyPhy.ComponentAssembly cyphyasm)
 {
     if (cyphyasm != null)
     {
         // [4] Find ReferenceCoordinateComponents
         foreach (CyPhy.ReferenceCoordinateSystem refCoord in cyphyasm.Children.ReferenceCoordinateSystemCollection)
         {
             ReferenceCoordinateSystemTraversal traverser = new ReferenceCoordinateSystemTraversal(refCoord);
             referenceCoordComponents.AddRange(traverser.referenceCoordComponents);
         }
     }
 }
Пример #21
0
        public AbstractClasses.Design ParseCyPhyDesign(CyPhy.ComponentAssembly componentAssembly)
        {
            AbstractClasses.Design design = new AbstractClasses.Design()
            {
                Name = componentAssembly.Name,
                ID   = componentAssembly.Attributes.ID.ToString()
            };

            design.TopContainer = ParseCyPhyComponentAssembly(componentAssembly);

            return(design);
        }
Пример #22
0
        private void Visit(CyPhyInterfaces.ComponentAssembly componentAssembly)
        {
            foreach (var innerComponentAssembly in componentAssembly.Children.ComponentAssemblyCollection)
            {
                Visit(componentAssembly);
            }

            foreach (var component in componentAssembly.Children.ComponentCollection)
            {
                Visit(component);
            }
        }
Пример #23
0
        public override void Expand(CyPhy.ComponentAssembly configuration)
        {
            this.Configuration = configuration;

            if (this.OriginalSystemUnderTest == null)
            {
                // don't need to do anything
            }
            else if (this.OriginalSystemUnderTest.Referred.DesignEntity.ID == configuration.ID)
            {
                this.expandedTestBenchSuite = this.testBenchSuite;
            }
            else
            {
                // create temp folder for test bench suite
                CyPhy.TestBenchSuiteFolder testing = CyPhyClasses.TestBenchSuiteFolder.Cast(this.testBenchSuite.ParentContainer.Impl);

                var tempFolderName = AnalysisModelProcessor.GetTemporaryFolderName(this.testBenchSuite.Impl);

                CyPhy.TestBenchSuiteFolder tempFolder = testing.Children.TestBenchSuiteFolderCollection.FirstOrDefault(x => x.Name == tempFolderName);
                if (tempFolder == null)
                {
                    tempFolder      = CyPhyClasses.TestBenchSuiteFolder.Create(testing);
                    tempFolder.Name = tempFolderName;

                    this.AddToTraceabilityAndTemporary(tempFolder.Impl, testing.Impl, recursive: false);
                }

                // copy test bench suite
                var tempCopy = (tempFolder.Impl as MgaFolder).CopyFCODisp(this.testBenchSuite.Impl as MgaFCO);
                // fix name
                tempCopy.Name = AnalysisModelProcessor.GetTemporaryObjectName(this.testBenchSuite.Impl, configuration.Impl);

                this.AddToTraceabilityAndTemporary(tempCopy, this.testBenchSuite.Impl);

                // set expanded property to the expanded element
                this.expandedTestBenchSuite = CyPhyClasses.TestBenchSuite.Cast(tempCopy);
            }

            // expand all test benches
            foreach (var testBenchRef in this.expandedTestBenchSuite.Children.TestBenchRefCollection)
            {
                var testBenchTypeExpander = new TestBenchTypeProcessor(testBenchRef.Referred.TestBenchType);
                testBenchTypeExpander.Expand(configuration);

                // switch references
                var switcher = new ReferenceSwitcher.ReferenceSwitcherInterpreter();
                // TODO: handle failures for this
                switcher.SwitchReference(testBenchTypeExpander.expandedTestBenchType.Impl as MgaFCO, testBenchRef.Impl as IMgaReference);

                this.InnerExpanders.Push(testBenchTypeExpander);
            }
        }
Пример #24
0
        /// <summary>
        /// Given a component assembly, ensures that the component assembly has a backend folder
        /// for storing resources. Creates a folder if necessary.
        /// </summary>
        /// <param name="ProjectDirectory">Directory in which the /designs/ folder resides. Defaults to project directory of <paramref name="componentAssembly"/></param>
        /// <returns>The path of the ComponentAssembly folder, relative to the project root</returns>
        public static String EnsureComponentAssemblyFolder(CyPhy.ComponentAssembly componentAssembly, string ProjectDirectory = null)
        {
            var    mp_MgaProject = componentAssembly.Impl.Project;
            String p_ProjectRoot = ProjectDirectory ?? mp_MgaProject.GetRootDirectoryPath();

            if (string.IsNullOrEmpty(componentAssembly.Attributes.Path))
            {
                componentAssembly.Attributes.Path = GetRandomComponentAssemblyDir();
            }
            Directory.CreateDirectory(Path.Combine(p_ProjectRoot, componentAssembly.Attributes.Path));

            return(componentAssembly.Attributes.Path);
        }
Пример #25
0
        public override void Expand(CyPhy.ComponentAssembly configuration)
        {
            this.Configuration = configuration;

            // FIXME: this test should be repaired. It does not work correctly if TBs have different SUTs. Be safe and make a copy always
            // if (this.OriginalSystemUnderTest.Referred.DesignEntity.ID == configuration.ID)
            if (false)
            {
                this.expandedParametricExploration = this.parametricExploration;
            }
            else
            {
                // create temp folder for parametric exploration
                CyPhy.ParametricExplorationFolder testing = CyPhyClasses.ParametricExplorationFolder.Cast(this.parametricExploration.ParentContainer.Impl);

                var tempFolderName = AnalysisModelProcessor.GetTemporaryFolderName(this.parametricExploration.Impl);

                CyPhy.ParametricExplorationFolder tempFolder = testing.Children.ParametricExplorationFolderCollection.FirstOrDefault(x => x.Name == tempFolderName);
                if (tempFolder == null)
                {
                    tempFolder      = CyPhyClasses.ParametricExplorationFolder.Create(testing);
                    tempFolder.Name = tempFolderName;

                    this.AddToTraceabilityAndTemporary(tempFolder.Impl, testing.Impl, recursive: false);
                }

                // copy parametric exploration
                var tempCopy = (tempFolder.Impl as MgaFolder).CopyFCODisp(this.parametricExploration.Impl as MgaFCO);
                // fix name
                tempCopy.Name = AnalysisModelProcessor.GetTemporaryObjectName(this.parametricExploration.Impl, configuration.Impl);

                this.AddToTraceabilityAndTemporary(tempCopy, this.parametricExploration.Impl);

                // set expanded property to the expanded element
                this.expandedParametricExploration = CyPhyClasses.ParametricExploration.Cast(tempCopy);
            }

            // expand all test benches
            foreach (var testBenchRef in this.expandedParametricExploration.Children.TestBenchRefCollection)
            {
                var testBenchTypeExpander = new TestBenchTypeProcessor(testBenchRef.Referred.TestBenchType);
                testBenchTypeExpander.Expand(configuration);

                // switch references
                var switcher = new ReferenceSwitcher.ReferenceSwitcherInterpreter();
                // TODO: handle failures for this
                switcher.SwitchReference(testBenchTypeExpander.expandedTestBenchType.Impl as MgaFCO, testBenchRef.Impl as IMgaReference);

                this.InnerExpanders.Push(testBenchTypeExpander);
            }
        }
Пример #26
0
        private CyPhyML.ComponentAssembly FindTopLevelAssembly(GmeCommon.Interfaces.FCO componentasm)
        {
            CyPhyML.ComponentAssembly topassembly = null;
            if (componentasm.ParentContainer.Kind == "ComponentAssemblies")             // Top Level Assembly
            {
                topassembly = (componentasm as CyPhyML.ComponentAssembly);
            }
            else if (componentasm.ParentContainer.Kind == "ComponentAssembly")
            {
                topassembly = FindTopLevelAssembly(componentasm.ParentContainer as CyPhyML.ComponentAssembly);
            }

            return(topassembly);
        }
Пример #27
0
        private bool IsParent(CyPhy.ConnectorComposition conn, CyPhy.ComponentAssembly topassembly)
        {
            GmeCommon.Interfaces.Container container = conn.ParentContainer;
            while (container != null)
            {
                if (container.Guid == topAssembly.Guid)
                {
                    return(true);
                }

                container = container.ParentContainer;
            }
            return(false);
        }
Пример #28
0
        public void StartAssemblySync(MgaProject project, MgaFCO currentobj, int param)
        {
            // FIXME: possible race between sending MetaLink Bridge INTEREST and it registering it, and Creo sending its INTEREST
            // n.b. the tests call StartAssemblySync directly
            metalinkAddon.assemblySyncPaused = false;
            ProjectDirectory = Path.GetDirectoryName(project.ProjectConnStr.Substring("MGA=".Length));
            if (ConnectToMetaLinkBridgeTask == null)
            {
                ConnectToMetaLinkBridge(project, param);
            }
            metalinkAddon.Enable(true);

            CyPhyML.ComponentAssembly topasm = null;
            MgaGateway.PerformInTransaction(delegate
            {
                topasm = Run(project, currentobj, param);
                if (topasm != null)
                {
                    metalinkAddon.AssemblyID = topasm.Guid.ToString();
                }
            });

            ConnectToMetaLinkBridgeTask.Wait();
            if (ConnectToMetaLinkBridgeTask.Result == false)
            {
                return;
            }

            if (topasm == null)
            {
                metalinkAddon.AssemblyID = null;
                GMEConsole.Error.WriteLine("No top level assembly can be found. Open an assembly and try again.");
                return;
            }
            try
            {
                metalinkAddon.CallCyPhy2CADWithTransaction(project,
                                                           (topasm.Impl as MgaFCO),
                                                           param);
            }
            catch (Exception e)
            {
                metalinkAddon.syncedComponents.Remove(metalinkAddon.AssemblyID);
                // FIXME: propagateAddon.LastStartedInstance.Remove
                metalinkAddon.AssemblyID = null;
                GMEConsole.Error.Write(e.Message);
            }
        }
Пример #29
0
        public static HashSet <CyPhyML.Component> getCyPhyMLComponentSet(CyPhyML.ComponentAssembly cyPhyMLComponentAssembly)
        {
            HashSet <CyPhyML.Component> cyPhyMLComponentSet = new HashSet <CyPhyML.Component>();

            foreach (CyPhyML.ComponentAssembly childComponentAssemblyFolder in cyPhyMLComponentAssembly.Children.ComponentAssemblyCollection)
            {
                cyPhyMLComponentSet.UnionWith(getCyPhyMLComponentSet(childComponentAssemblyFolder));
            }

            foreach (CyPhyML.Component childComponent in cyPhyMLComponentAssembly.Children.ComponentCollection)
            {
                cyPhyMLComponentSet.Add(childComponent);
            }

            return(cyPhyMLComponentSet);
        }
Пример #30
0
        public CommonTraversal(GmeCommon.Interfaces.FCO start, CyPhy.ComponentAssembly topassembly)
        {
            Initialize();
            startNodeID = start.ID;

            this.topAssembly = topassembly;

            if (start is CyPhy.Connector)
            {
                VisitConnector(start as CyPhy.Connector, (MgaFCO)start.ParentContainer.Impl);
            }
            else if (start is CyPhy.CADDatum)
            {
                VisitCADDatum(start as CyPhy.CADDatum);
            }
        }
        public CommonTraversal(GmeCommon.Interfaces.FCO start, CyPhy.ComponentAssembly topassembly)
        {
            Initialize();
            startNodeID = start.ID;

            this.topAssembly = topassembly;

            if (start is CyPhy.Connector)
            {
                VisitConnector(start as CyPhy.Connector, (MgaFCO)start.ParentContainer.Impl);
            }
            else if (start is CyPhy.CADDatum)
            {
                VisitCADDatum(start as CyPhy.CADDatum);
            }
        }
Пример #32
0
        private void ManufacturingGeneration(MgaFCO currentobj)
        {
            if (currentobj.MetaBase.Name == "TestBench")
            {
                // DDP Generation
                CyPhy.TestBench tb      = CyPhyClasses.TestBench.Cast(currentobj);
                var             catlsut = tb.Children.ComponentAssemblyCollection.FirstOrDefault(); // should be an instance b/c elaborate was called earlier
                if (catlsut == null)
                {
                    throw new Exception("There is no elaborated system under test component assembly in the model!");
                }

                var design = CyPhy2DesignInterchange.CyPhy2DesignInterchange.Convert(catlsut);
                this.TestBenchName = tb.Name;
                this.AssemblyName  = design.Name;
                design.SaveToFile(Path.Combine(this.OutputDirectory, this.TestBenchName + ".adm"));

                if (catlsut.Attributes.ConfigurationUniqueID.Contains("{"))
                {
                    this.ManufacturingManifestData.DesignID = catlsut.Attributes.ConfigurationUniqueID;
                }
                else
                {
                    this.ManufacturingManifestData.DesignID = "{" + catlsut.Attributes.ConfigurationUniqueID + "}";
                }
                this.ManufacturingManifestData.Name = catlsut.Name;
                PartManufacturingGeneration(catlsut);
            }
            else if (currentobj.MetaBase.Name == "ComponentAssembly")
            {
                // DDP Generation
                CyPhy.ComponentAssembly assembly = CyPhyClasses.ComponentAssembly.Cast(currentobj);

                var design = CyPhy2DesignInterchange.CyPhy2DesignInterchange.Convert(assembly);
                this.AssemblyName  = design.Name;
                this.TestBenchName = design.Name;
                design.SaveToFile(Path.Combine(this.OutputDirectory, this.TestBenchName + ".adm"));

                this.ManufacturingManifestData.DesignID = "{" + assembly.Attributes.ConfigurationUniqueID + "}";
                this.ManufacturingManifestData.Name     = assembly.Name;
                PartManufacturingGeneration(assembly);
            }
            else
            {
                throw new NotImplementedException();
            }
        }