Ejemplo n.º 1
0
        private CyPhy.DesignContainer CreateDesignSpaceRoot(avm.Design ad_import)
        {
            CyPhy.DesignSpace ds;
            CyPhy.RootFolder  rf = CyPhyClasses.RootFolder.GetRootFolder((MgaProject)project);
            ds = rf.Children.DesignSpaceCollection.Where(d => d.Name == "DesignSpaces").FirstOrDefault();
            if (ds == null)
            {
                ds      = CyPhyClasses.DesignSpace.Create(rf);
                ds.Name = "DesignSpaces";
            }

            CyPhy.DesignContainer cyphy_container = CyPhyClasses.DesignContainer.Create(ds);
            // container.Name = ad_import.Name; RootContainer has a name too
            int designID;

            if (int.TryParse(ad_import.DesignID, out designID))
            {
                cyphy_container.Attributes.ID = designID;
            }
            cyphy_container.Attributes.ContainerType = CyPhyClasses.DesignContainer.AttributesClass.ContainerType_enum.Compound;
            return(cyphy_container);
        }
Ejemplo n.º 2
0
 private void processMux(CyPhyML.DesignContainer designContainer, avm.ValueFlowMux ad_mux)
 {
     _avmValueNodeIDMap.Add(ad_mux.ID, new KeyValuePair <avm.ValueNode, object>(null, ad_mux));
 }
Ejemplo n.º 3
0
        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'");
            });
        }