Пример #1
0
        public static IArgumentProvider GetArgumentProvider(ExtractProductIdentify productIdentify, ExtractAlgorithmIdentify algorithmIdentify)
        {
            if (productIdentify == null || algorithmIdentify == null)
            {
                return(null);
            }
            ThemeDef theme = GetThemeDefByIdentify(productIdentify.ThemeIdentify);

            if (theme == null)
            {
                return(null);
            }
            ProductDef prd = theme.GetProductDefByIdentify(productIdentify.ProductIdentify);

            if (prd == null)
            {
                return(null);
            }
            SubProductDef subPrd = prd.GetSubProductDefByIdentify(productIdentify.SubProductIdentify);

            if (subPrd == null)
            {
                return(null);
            }
            AlgorithmDef      alg    = subPrd.GetAlgorithmDefByAlgorithmIdentify(algorithmIdentify);
            IArgumentProvider argprd = CreateArgumentProvider(alg, BandRefTableHelper.GetBandRefTable(algorithmIdentify.Satellite, algorithmIdentify.Sensor));

            if (argprd != null)
            {
                argprd.SetArg("AlgorithmName", alg.Identify);
            }
            return(argprd);
        }
Пример #2
0
        private void GetProductNameByIdentify()
        {
            if (string.IsNullOrEmpty(ProductIdentify))
            {
                return;
            }
            ThemeDef theme = MonitoringThemeFactory.GetThemeDefByIdentify("CMA");

            if (theme == null)
            {
                return;
            }
            ProductDef pro = theme.GetProductDefByIdentify(ProductIdentify);

            if (pro == null)
            {
                return;
            }
            ProductName = pro.Name;
            if (string.IsNullOrEmpty(SubProductIdentify))
            {
                return;
            }
            SubProductDef subPro = pro.GetSubProductDefByIdentify(SubProductIdentify);

            if (subPro == null)
            {
                return;
            }
            SubProductName = subPro.Name;
        }
Пример #3
0
        public static IArgumentProvider GetArgumentProvider(ExtractProductIdentify productIdentify, string algorithmIdentify, string satellite, string sensor)
        {
            if (productIdentify == null || algorithmIdentify == null)
            {
                return(null);
            }
            ThemeDef theme = GetThemeDefByIdentify(productIdentify.ThemeIdentify);

            if (theme == null)
            {
                return(null);
            }
            ProductDef prd = theme.GetProductDefByIdentify(productIdentify.ProductIdentify);

            if (prd == null)
            {
                return(null);
            }
            SubProductDef subPrd = prd.GetSubProductDefByIdentify(productIdentify.SubProductIdentify);

            if (subPrd == null)
            {
                return(null);
            }
            AlgorithmDef alg = subPrd.GetAlgorithmDefByIdentify(algorithmIdentify);

            return(CreateArgumentProvider(alg, BandRefTableHelper.GetBandRefTable(satellite, sensor)));
        }
Пример #4
0
        private ThemeDef CreatTheme(XElement ele)
        {
            ThemeDef theme = new ThemeDef();
            string   value = ele.Attribute("name").Value;

            if (!String.IsNullOrEmpty(value))
            {
                theme.Name = value;
            }
            value = ele.Attribute("identify").Value;
            if (!String.IsNullOrEmpty(value))
            {
                theme.Identify = value;
            }
            value = TryGetString(ele.Attribute("productdefdir"));
            if (!string.IsNullOrWhiteSpace(value))
            {
                theme.ProductDir = value;
            }
            List <ProductDef> products = new List <ProductDef>();

            //解析产品目录下独立xml的产品定义
            ProductDef[] pds = ParseProductDefFromDir(theme.ProductDir, theme);
            if (pds != null && pds.Length != 0)
            {
                foreach (ProductDef product in pds)
                {
                    if (!ExistsProduct(product.Identify, products))
                    {
                        products.Add(product);
                    }
                }
            }
            //解析Theme文档中的产品定义
            ProductDef[] productDefsInXml = ParseProductDefFromXml(ele, theme);
            if (productDefsInXml != null && productDefsInXml.Length != 0)
            {
                foreach (ProductDef product in productDefsInXml)
                {
                    if (!ExistsProduct(product.Identify, products))
                    {
                        products.Add(product);
                    }
                }
            }
            if (products != null && products.Count != 0)
            {
                theme.Products = products.ToArray();
            }
            //AOIDefs
            AOIDef defaultAOI;

            theme.AOIDefs = ParseAOIDefs(ele.Element("SystemAOIs"), out defaultAOI);
            if (defaultAOI != null)
            {
                theme.DefaultAOIDef = defaultAOI;
            }
            return(theme);
        }
Пример #5
0
        public static ProductDef GetProductDef(string themeIdentify, string productIdentify)
        {
            ThemeDef theme = GetThemeDefByIdentify(themeIdentify);

            if (theme == null)
            {
                return(null);
            }
            return(theme.GetProductDefByIdentify(productIdentify));
        }
Пример #6
0
 public virtual void Dispose()
 {
     if (_products != null && _products.Count > 0)
     {
         foreach (IMonitoringProduct prd in _products)
         {
             prd.Dispose();
         }
         _products.Clear();
         _products = null;
     }
     _themeDef = null;
 }
Пример #7
0
 public static void MergerTheme(string fname)
 {
     ThemeDef[] ths = (new MonitoringThemesParser(fname)).Parse();
     if (ths != null)
     {
         if (_themes == null)
         {
             _themes = ths;
         }
         else
         {
             ThemeDef[] newThemes = new ThemeDef[_themes.Length + ths.Length];
             Array.Copy(_themes, newThemes, _themes.Length);
             Array.Copy(ths, 0, newThemes, _themes.Length, ths.Length);
             _themes = newThemes;
         }
     }
 }
Пример #8
0
        private ProductDef[] ParseProductDefFromXml(XElement ele, ThemeDef theme)
        {
            List <ProductDef>      products = new List <ProductDef>();
            IEnumerable <XElement> elements = ele.Element(XName.Get("Products")).Elements();

            if (elements == null || elements.Count() == 0)
            {
                return(null);
            }
            //productDefs
            ProductDef productdef;

            foreach (XElement element in elements)
            {
                productdef = CreatProduct(element, theme);
                products.Add(productdef);
            }
            return(products.ToArray());
        }
Пример #9
0
        private ProductDef[] ParseProductDefFromDir(string productDefDir, ThemeDef theme)
        {
            if (string.IsNullOrWhiteSpace(productDefDir))
            {
                return(null);
            }
            string productdir = Path.GetFullPath(System.AppDomain.CurrentDomain.BaseDirectory + productDefDir);

            if (!Directory.Exists(productdir))
            {
                return(null);
            }
            string[] pds = Directory.GetFiles(productdir, "*.xml");
            if (pds == null || pds.Length == 0)
            {
                return(null);
            }
            ProductDef        product;
            List <ProductDef> products = new List <ProductDef>();

            for (int i = 0; i < pds.Length; i++)
            {
                try
                {
                    XElement element = XElement.Load(pds[i]);
                    product = CreatProduct(element, theme);
                    if (product != null)
                    {
                        products.Add(product);
                    }
                }
                catch
                {
                    continue;
                }
            }
            return(products.ToArray());
        }
Пример #10
0
        public static IArgumentProvider GetArgumentProvider(ExtractProductIdentify productIdentify, string algorithmIdentify)
        {
            if (productIdentify == null || algorithmIdentify == null)
            {
                return(null);
            }
            ThemeDef theme = GetThemeDefByIdentify(productIdentify.ThemeIdentify);

            if (theme == null)
            {
                return(null);
            }
            ProductDef prd = theme.GetProductDefByIdentify(productIdentify.ProductIdentify);

            if (prd == null)
            {
                return(null);
            }
            SubProductDef subPrd = prd.GetSubProductDefByIdentify(productIdentify.SubProductIdentify);

            if (subPrd == null)
            {
                return(null);
            }
            AlgorithmDef      alg    = subPrd.GetAlgorithmDefByIdentify(algorithmIdentify);
            IArgumentProvider argPrd = CreateArgumentProvider(alg, null);

            if (alg.Bands != null)
            {
                foreach (BandDef b in alg.Bands)
                {
                    argPrd.SetArg(b.Identify, b.BandNo);
                }
            }
            return(argPrd);
        }
Пример #11
0
 public MonitoringTheme(ThemeDef themeDef)
 {
     _themeDef = themeDef;
 }
Пример #12
0
        private ProductDef CreatProduct(XElement element, ThemeDef theme)
        {
            ProductDef product = new ProductDef();

            product.Theme = theme;
            string value = element.Attribute("name").Value;

            if (!String.IsNullOrEmpty(value))
            {
                product.Name = value;
            }
            value = element.Attribute("image").Value;
            if (!String.IsNullOrEmpty(value))
            {
                product.Image = value;
            }
            value = element.Attribute("group").Value;
            if (!String.IsNullOrEmpty(value))
            {
                product.Group = value;
            }
            value = element.Attribute("uiprovider").Value;
            if (!String.IsNullOrEmpty(value))
            {
                product.UIProvider = value;
            }
            value = element.Attribute("identify").Value;
            if (!String.IsNullOrEmpty(value))
            {
                product.Identify = value;
            }
            IEnumerable <XElement> subProductsElements = element.Element(XName.Get("SubProducts")).Elements();

            if (subProductsElements != null && subProductsElements.Count() != 0)
            {
                SubProductDef        subPro;
                List <SubProductDef> subs = new List <SubProductDef>();
                foreach (XElement ele in subProductsElements)
                {
                    subPro = CreatSubProduct(ele);
                    if (subPro != null)
                    {
                        subs.Add(subPro);
                    }
                    subPro.ProductDef = product;
                    //Console.WriteLine("SubProduct:"+ele.Attribute("name").Value);
                }
                if (subs != null && subs.Count != 0)
                {
                    product.SubProducts = subs.ToArray();
                }
            }
            IEnumerable <XElement> aoisElements = Elements(element.Element("AOITemplates"));

            if (aoisElements != null && aoisElements.Count() != 0)
            {
                List <AOITemplate> aoiList = new List <AOITemplate>();
                foreach (XElement ele in aoisElements)
                {
                    AOITemplate aoi = CreateAOITemplate(ele);
                    if (aoi != null)
                    {
                        aoiList.Add(aoi);
                    }
                }
                product.AOITemplates = aoiList.ToArray();
            }
            return(product);
        }
Пример #13
0
 public MonitoringThemeCMA(ThemeDef themeDef)
     : base(themeDef)
 {
 }