示例#1
0
        public IEnumerable <CyDRCInfo_v1> GetDRCs(ICyDWComponentDRCArgs_v1 args)
        {
            IList <CyPropertyBundle> ListBundle = args.GetPropertyBundlesFor(BUNDLE_ID_GENERAL);
            IList <string>           linNames   = args.GetInstNamesFor("LIN");

            string  compName = typeof(CyCustomizer).Namespace;
            string  compNameWithoutMinorVersion = compName.Substring(0, compName.LastIndexOf("_"));
            string  minorVersion     = compName.Substring(compName.LastIndexOf("_") + 1);
            string  majorVersion     = compNameWithoutMinorVersion.Substring(compNameWithoutMinorVersion.LastIndexOf("v") + 1);
            Version curentDWCVersion = new Version(Convert.ToInt32(majorVersion), Convert.ToInt32(minorVersion));

            bool isEqualVersion = true;

            Debug.Assert(linNames.Count > 0, "Should have been caught by ICyDWComponent_v1.IsValid");

            for (int i = 0; i < linNames.Count - 1; i++)
            {
                if (args.GetVersion(args.GetCompNameWithVersion(linNames[i])) !=
                    args.GetVersion(args.GetCompNameWithVersion(linNames[i + 1])))
                {
                    isEqualVersion = false;
                    break;
                }
            }

            if (isEqualVersion)
            {
                // if version of LIN instance is higher than version of DWC component
                if (args.GetVersion(args.GetCompNameWithVersion(linNames[0])) > curentDWCVersion)
                {
                    yield return(new CyDRCInfo_v1(CyDRCInfo_v1.CyDRCType_v1.Error, resource.DWC_VERSION_ERROR));
                }
                else if (ListBundle.Count == 1)                                     // if only one instance with valid version is present on schematic
                {
                    if (ListBundle[0].GetProperty <bool>(BDNAME_MULT_INST_SUPPORT)) // if Multiple instance support is checked
                    {
                        yield return(new CyDRCInfo_v1(CyDRCInfo_v1.CyDRCType_v1.Error,
                                                      string.Format(resource.MULTIPLE_SUPPORT_IS_CHECKED_ERROR, ListBundle[0].InstName)));
                    }
                }
                else // if two instances with valid version are present on schematic
                {
                    for (int i = 0; i < ListBundle.Count; i++)
                    {
                        if (!ListBundle[i].GetProperty <bool>(BDNAME_MULT_INST_SUPPORT)) // if Multiple instance support is not checked
                        {
                            yield return(new CyDRCInfo_v1(CyDRCInfo_v1.CyDRCType_v1.Error,
                                                          string.Format(resource.MULTIPLE_SUPPORT_IS_NOT_CHECKED_ERROR, ListBundle[i].InstName)));
                        }
                    }

                    bool foundIfcNumber1 = false;
                    for (int i = 0; i < ListBundle.Count; i++)
                    {
                        ushort ifcNumber = ListBundle[i].GetProperty <ushort>(BDNAME_IFC_NUM);
                        if (ifcNumber == IFC_NUM_1)
                        {
                            foundIfcNumber1 = true;
                        }
                        for (int j = i + 1; j < ListBundle.Count; j++)
                        {
                            if (ifcNumber == ListBundle[j].GetProperty <ushort>(BDNAME_IFC_NUM))
                            {
                                // Found two LIN instances with the same interface number
                                yield return(new CyDRCInfo_v1(CyDRCInfo_v1.CyDRCType_v1.Error, resource.DIFERENT_IFC_ERROR));

                                // Avoid multiple DRCs thrown for the same issue
                                yield break;
                            }
                        }
                    }

                    if (foundIfcNumber1 == false)
                    {
                        yield return(new CyDRCInfo_v1(CyDRCInfo_v1.CyDRCType_v1.Error, resource.IFC1_NOT_FOUND));
                    }
                }
            }
            else
            {
                yield return(new CyDRCInfo_v1(CyDRCInfo_v1.CyDRCType_v1.Error, resource.DIFERENT_VERSION_ERROR));
            }
        }
示例#2
0
 public IEnumerable <CyDRCInfo_v1> GetDRCs(ICyDWComponentDRCArgs_v1 args)
 {
     return(new List <CyDRCInfo_v1>());
 }