예제 #1
0
        public static ISIS.GME.Common.Interfaces.FCO CastReferred(
            MgaReference mgaReference,
            Dictionary <int, Type> metaRefTypes,
            string kind)
        {
            Contract.Requires(mgaReference != null);

            IMgaFCO referred = mgaReference.Referred;

            if (referred == null)
            {
                return(null);
            }
            else
            {
                ISIS.GME.Common.Interfaces.FCO result = null;
                Type t;
                if (metaRefTypes.TryGetValue(referred.MetaBase.MetaRef, out t) == false)
                {
                    // backwards compat dictates that this exception must be KeyNotFoundException
                    throw new System.Collections.Generic.KeyNotFoundException(String.Format("Tried to retrieve Referred.{0}, but the referred object is \"{1}\", which does not inherit from \"{0}\"", kind, referred.MetaBase.Name));
                }
                result = Activator.CreateInstance(t) as ISIS.GME.Common.Interfaces.FCO;
                (result as ISIS.GME.Common.Classes.FCO).Impl = referred as IMgaObject;
                return(result);
            }
        }
            public void Increment(ISIS.GME.Common.Interfaces.FCO fco)
            {
                if (fco is CyPhy.ValueFlowTarget)
                {
                    int i_CharsOver10 = Math.Max(fco.Name.Length - 12, 12);
                    int i_XOffset     = 160 + (i_CharsOver10 * 10);
                    i_x += i_XOffset;
                }
                else if (fco is CyPhy.Connector)
                {
                    i_x += 250;
                }
                else if (fco is CyPhy.Port)
                {
                    i_x += 100;
                }
                else if (fco is CyPhy.ModelicaConnector)
                {
                    i_x += 250;
                }
                else
                {
                    i_x += 250;
                }

                if (i_x > i_MaxX)
                {
                    NextLine();
                }
            }
            public String GetCoordinatesAndIncrement(ISIS.GME.Common.Interfaces.FCO fco)
            {
                String s_Rtn = GetCoordinates();

                Increment(fco);
                return(s_Rtn);
            }
예제 #4
0
        public static IEnumerable <ISIS.GME.Common.Interfaces.FCO> CastReferencedBy(
            IMgaFCO IMgaFCO,
            Dictionary <int, Type> dictionary)
        {
            Contract.Requires(IMgaFCO != null);

            int metaRef;

            ISIS.GME.Common.Interfaces.FCO fco = null;

            foreach (IMgaFCO item in IMgaFCO.ReferencedBy)
            {
                try
                {
                    metaRef = item.MetaBase.MetaRef;
                    Type type = null;
                    if (dictionary.TryGetValue(metaRef, out type))
                    {
                        // can be casted to the requested type
                        fco = Activator.CreateInstance(type) as ISIS.GME.Common.Interfaces.FCO;
                        (fco as ISIS.GME.Common.Classes.FCO).Impl = item as IMgaObject;
                    }
                    else
                    {
                        // cannot be casted to DSML types
                        continue;
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                yield return(fco);
            }
        }
예제 #5
0
        private bool portHasCorrectParentType(ISIS.GME.Common.Interfaces.FCO port)
        {
            ISIS.GME.Common.Interfaces.Container parent = port.ParentContainer;
            Type parentType = parent.GetType();

            return(this.SchematicModelType.IsAssignableFrom(parentType));
        }
예제 #6
0
        public List <CADGeometry> Geometry = new List <CADGeometry>();                             // If geometries are associated with this interface

        public StructuralInterfaceConstraint(GmeCommon.Interfaces.FCO impl,
                                             string parentID,
                                             string parentinstanceGUID)
        {
            CyPhyImpl          = impl;
            PortID             = impl.ID;
            ParentID           = parentID;
            ParentInstanceGUID = parentinstanceGUID;
            DatumList          = new Dictionary <string, Datum>();
            DegreeFreedom      = 0;

            if (impl is CyPhy.Connector)
            {
                InterfaceDefinition = (impl as CyPhy.Connector).Attributes.Definition;
                Name = impl.Name;
            }
            else if (impl is CyPhy.CADDatum)
            {
                InterfaceDefinition = (impl as CyPhy.CADDatum).Attributes.Definition;
                Name = impl.Name;
            }
            else
            {
                InterfaceDefinition = "";
                Name = "";
            }
        }
예제 #7
0
        public string ParentID;     // The project-unique ID of the endpoint's container.

        /// <summary>
        /// Initialize Endpoint info from an endpoint.
        /// </summary>
        /// <param name="endpoint">The endpoint of interest.</param>
        public Endpoint(InterfaceFCO endpoint, InterfaceReference epReference)
        {
            const string defaultString = "unknown";

            Name       = defaultString;
            Kind       = defaultString;
            ID         = defaultString;
            ParentName = defaultString;
            ParentKind = defaultString;
            ParentID   = defaultString;

            if (endpoint != null)
            {
                if (endpoint.Name != null)
                {
                    Name = endpoint.Name;
                }

                if (endpoint.Kind != null)
                {
                    Kind = endpoint.Kind;
                }

                if (endpoint.ID != null)
                {
                    ID = endpoint.ID;
                }

                if (endpoint.ParentContainer != null)
                {
                    if (endpoint.ParentContainer.Name != null)
                    {
                        ParentName = endpoint.ParentContainer.Name;
                    }

                    if (endpoint.ParentContainer.Kind != null)
                    {
                        ParentKind = endpoint.ParentContainer.Kind;
                    }

                    if (endpoint.ParentContainer.ID != null)
                    {
                        ParentID = endpoint.ParentContainer.ID;
                    }
                }

                // If the endpoint reference exists, use it to get the parent name.
                if (epReference != null)
                {
                    ParentName = epReference.Name;
                    ID        += "/" + epReference.ID;
                    ParentID   = epReference.ID;
                }
            }
        }
        private static void SetCoordinates(ISIS.GME.Common.Interfaces.FCO fco, String s_Coord)
        {
            string[] sa_coords = s_Coord.Split(',');
            int      x         = int.Parse(sa_coords[0]);
            int      y         = int.Parse(sa_coords[1]);

            foreach (IMgaPart part in (fco.Impl as IMgaFCO).Parts)
            {
                part.SetGmeAttrs(null, x, y);
            }
        }
예제 #9
0
        public string ParentID;     // The project-unique ID of the endpoint's container.

        /// <summary>
        /// Initialize Endpoint info from an endpoint.
        /// </summary>
        /// <param name="endpoint">The endpoint of interest.</param>
        public Endpoint(InterfaceFCO endpoint, InterfaceReference epReference)
        {
            const string defaultString = "unknown";
            Name = defaultString;
            Kind = defaultString;
            ID = defaultString;
            ParentName = defaultString;
            ParentKind = defaultString;
            ParentID = defaultString;

            if (endpoint != null)
            {
                if (endpoint.Name != null)
                {
                    Name = endpoint.Name;
                }

                if (endpoint.Kind != null)
                {
                    Kind = endpoint.Kind;
                }

                if (endpoint.ID != null)
                {
                    ID = endpoint.ID;
                }

                if (endpoint.ParentContainer != null)
                {
                    if (endpoint.ParentContainer.Name != null)
                    {
                        ParentName = endpoint.ParentContainer.Name;
                    }

                    if (endpoint.ParentContainer.Kind != null)
                    {
                        ParentKind = endpoint.ParentContainer.Kind;
                    }

                    if (endpoint.ParentContainer.ID != null)
                    {
                        ParentID = endpoint.ParentContainer.ID;
                    }
                }

                // If the endpoint reference exists, use it to get the parent name.
                if (epReference != null)
                {
                    ParentName = epReference.Name;
                    ID += "/" + epReference.ID;
                    ParentID = epReference.ID;
                }
            }
        }
예제 #10
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);
        }
예제 #11
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);
            }
        }
예제 #12
0
        public static IEnumerable <Interfaces.FCO> CastMembersOfSet(
            IMgaFCO mgaFco,
            Dictionary <int, Type> dictionary)
        {
            Contract.Requires(mgaFco != null);

            int metaRef;

            ISIS.GME.Common.Interfaces.FCO fco = null;
            Type t = null;

            foreach (IMgaFCO item in mgaFco.MemberOfSets)
            {
                metaRef = item.MetaBase.MetaRef;
                if (dictionary.TryGetValue(metaRef, out t))
                {
                    fco = Activator.CreateInstance(t) as ISIS.GME.Common.Interfaces.FCO;
                    (fco as ISIS.GME.Common.Classes.FCO).Impl = item as IMgaObject;
                    yield return(fco);
                }
            }
        }
예제 #13
0
        public static void SetReferred(
            MgaReference Impl,
            ISIS.GME.Common.Interfaces.FCO value)
        {
            Contract.Requires(Impl != null);
            Contract.Requires(Impl is MgaReference);

            try
            {
                if (value != null)
                {
                    (Impl as MgaReference).Referred = value.Impl as MgaFCO;
                }
                else
                {
                    (Impl as MgaReference).Referred = null;
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Referred value could not be set.", ex);
            }
        }
예제 #14
0
        public void MakeManifest(
            ISIS.GME.Common.Interfaces.FCO testBench,
            string outputDir = "",
            bool update      = true)
        {
            Contract.Requires(testBench != null);

            string fullPathFileName = Path.Combine(outputDir, TESTBENCH_FILENAME);
            bool   shouldUpdate     = false;

            if (update && System.IO.File.Exists(fullPathFileName))
            {
                MetaTBManifest oldManifest = Deserialize(fullPathFileName);
                this.CopyManifest(oldManifest);
                shouldUpdate = true;
            }

            this.TestBench = string.IsNullOrEmpty((testBench.Impl as MgaFCO).RegistryValue["TestBenchUniqueName"]) ?
                             testBench.Name :
                             (testBench.Impl as MgaFCO).RegistryValue["TestBenchUniqueName"];

            this.Created = DateTime.UtcNow.ToString("o");
            // FIXME: put design name here...
            this.DesignName = testBench.Name;

            if (testBench is CyPhy.BallisticTestBench)
            {
                this.TierLevel = (int)(testBench as CyPhy.BallisticTestBench).Attributes.Tier;
            }

            if (testBench is CyPhy.TestBenchType)
            {
                var testBenchType = ISIS.GME.Dsml.CyPhyML.Classes.TestBenchType.Cast(testBench.Impl);

                foreach (var item in testBenchType.Children.MetricCollection)
                {
                    if (shouldUpdate)
                    {
                        var oldData = this.Metrics.FirstOrDefault(x => x.ID == item.Guid.ToString());
                        if (oldData != null)
                        {
                            this.Metrics.Remove(oldData);
                        }
                    }

                    AVM.DDP.MetaTBManifest.Metric metric = new AVM.DDP.MetaTBManifest.Metric();
                    metric.Name = item.Name.Trim();
                    metric.Unit = (item.Impl as MgaReference).Referred == null ?
                                  string.Empty :
                                  (item.Impl as MgaReference).Referred.Name;

                    // TODO: add the displayed name
                    metric.Value       = item.Attributes.Value;
                    metric.ID          = item.Guid.ToString();
                    metric.GMEID       = item.ID;
                    metric.Description = item.Attributes.Description;
                    this.Metrics.Add(metric);
                }

                foreach (var item in testBenchType.Children.ParameterCollection)
                {
                    if (shouldUpdate)
                    {
                        var oldData = this.Parameters.FirstOrDefault(x => x.ID == item.Guid.ToString());
                        if (oldData != null)
                        {
                            this.Parameters.Remove(oldData);
                        }
                    }

                    AVM.DDP.MetaTBManifest.Parameter parameter = new AVM.DDP.MetaTBManifest.Parameter();
                    parameter.Name = item.Name;
                    parameter.Unit = (item.Impl as MgaReference).Referred == null ?
                                     string.Empty :
                                     (item.Impl as MgaReference).Referred.Name;

                    parameter.Description = item.Attributes.Description;
                    parameter.GMEID       = item.ID;
                    parameter.ID          = item.Guid.ToString();
                    parameter.Range       = item.Attributes.Range;
                    parameter.Value       = item.Attributes.Value;

                    this.Parameters.Add(parameter);
                }

                foreach (var item in testBenchType.Children.FileInputCollection)
                {
                    if (shouldUpdate)
                    {
                        var oldData = this.FileInputs.FirstOrDefault(x => x.Name == item.Name);
                        if (oldData != null)
                        {
                            this.FileInputs.Remove(oldData);
                        }
                    }

                    AVM.DDP.MetaTBManifest.FileInput fileInput = new AVM.DDP.MetaTBManifest.FileInput();
                    fileInput.Name     = item.Name;
                    fileInput.FileName = item.Attributes.FileName != "" ? item.Attributes.FileName : fileInput.Name;

                    this.FileInputs.Add(fileInput);
                }

                foreach (var item in testBenchType.Children.FileOutputCollection)
                {
                    if (shouldUpdate)
                    {
                        var oldData = this.FileOutputs.FirstOrDefault(x => x.Name == item.Name);
                        if (oldData != null)
                        {
                            this.FileOutputs.Remove(oldData);
                        }
                    }

                    AVM.DDP.MetaTBManifest.FileOutput fileOutput = new AVM.DDP.MetaTBManifest.FileOutput();
                    fileOutput.Name     = item.Name;
                    fileOutput.FileName = item.Attributes.FileName != "" ? item.Attributes.FileName : item.Name;

                    this.FileOutputs.Add(fileOutput);
                }

                // get designID
                string designID = null;
                var    tlsut    = testBenchType.Children.TopLevelSystemUnderTestCollection.FirstOrDefault();
                var    catlsut  = testBenchType.Children.ComponentAssemblyCollection.FirstOrDefault();
                if (tlsut != null)
                {
                    // if it is a reference
                    if (tlsut.Referred.DesignEntity != null)
                    {
                        designID = tlsut.Referred.DesignEntity.Properties.Guid.ToString("B");
                        if (tlsut.Referred.DesignEntity is CyPhy.ComponentAssembly)
                        {
                            catlsut = tlsut.Referred.ComponentAssembly;
                            var cid = catlsut.Attributes.ConfigurationUniqueID;
                            //this.ConfigurationUniqueID = cid;

                            if (string.IsNullOrWhiteSpace(cid))
                            {
                                cid = Guid.NewGuid().ToString("B");
                                catlsut.Attributes.ConfigurationUniqueID = cid;
                            }

                            if (!string.IsNullOrEmpty(cid))
                            {
                                try
                                {
                                    Guid guid = new Guid(cid);
                                    designID = guid.ToString("B");
                                }
                                catch (System.FormatException ex)
                                {
                                    Trace.TraceError("{0} is not a vaild GUID.", cid);
                                    Trace.TraceError(ex.ToString());
                                }
                            }
                        }
                    }
                }
                else if (catlsut != null)
                {
                    // if it is an instance
                    var cid = catlsut.Attributes.ConfigurationUniqueID;

                    if (!string.IsNullOrEmpty(cid))
                    {
                        Guid guid = new Guid(cid);
                        designID = guid.ToString("B");
                    }
                }

                // this.CopyTestResults = testBench.Attributes.CopyResults;

                this.DesignID = designID;
            }
        }
예제 #15
0
 public DesignPrimitivesWrapper(ISIS.GME.Common.Interfaces.FCO primitive)
 {
     Primitive             = primitive;
     _portCompositionCache = new Dictionary <object, List <CyPhy.PortComposition> >();
 }