Ejemplo n.º 1
0
        /// <summary>
        /// Locate a generation type by the specified name
        /// </summary>
        /// <param name="GenType">The type to search for</param>
        /// <returns></returns>
        public static MM_Unit_Type FindGenerationType(string GenType)
        {
            if (string.IsNullOrWhiteSpace(GenType))
            {
                GenType = "OTHER";
            }

            if (GenerationTypes.ContainsKey(GenType))
            {
                return(GenerationTypes[GenType]);
            }
            else
            {
                MM_Unit_Type Newtype = new MM_Unit_Type(GenType);
                GenerationTypes.Add(GenType, Newtype);
                return(Newtype);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Load the XML Configuration file for the Macomber Map system
        /// </summary>
        /// <param name="MapConfiguration"></param>
        private static void LoadXmlConfiguration(String MapConfiguration)
        {
            //Create a blank violation entry for 'none'
            //ViolationImages.Images.Add("None", new Bitmap(16, 16));

            xConfiguration = new XmlDocument();
            xConfiguration.LoadXml(MapConfiguration);
            Data_Integration.Permissions = new MM_Permissions(xConfiguration["Configuration"]["Permissions"]);
            foreach (XmlElement xElem in xConfiguration["Configuration"]["DisplayParameters"].ChildNodes.OfType <XmlElement>())
            {
                try
                {
                    if (xElem.Name == "VoltageLevel")
                    {
                        KVLevels.Add(xElem.Attributes["Name"].Value, new MM_KVLevel(xElem, true));
                    }
                    else if (xElem.Name == "ElementType")
                    {
                        ElemTypes.Add(xElem.Attributes["Name"].Value, new MM_Element_Type(xElem, true));
                    }
                    else if (xElem.Name == "MM_Unit_Type" || xElem.Name == "GenerationType" || xElem.Name == "UnitType")
                    {
                        MM_Unit_Type NewGen = new MM_Unit_Type(xElem, true);
                        GenerationTypes.Add(NewGen.Name, NewGen);
                        if (!GenerationTypes.ContainsKey(NewGen.EMSName))
                        {
                            GenerationTypes.Add(NewGen.EMSName, NewGen);
                        }
                    }
                    else if (xElem.Name == "Violation")
                    {
                        ViolationTypes.Add(xElem.Attributes["Name"].Value, new MM_AlarmViolation_Type(xElem, true));
                    }
                    else if (xElem.Name == "Substation")
                    {
                        SubstationDisplay = new MM_Substation_Display(xElem, true);
                    }
                    else if (xElem.Name == "Overall")
                    {
                        OverallDisplay = new MM_Display(xElem, true);
                    }
                    else if (xElem.Name == "WeatherStationDetail")
                    {
                        Weather.MM_WeatherStation.QueryPrepend = xElem.Attributes["URL"].Value;
                    }
                    else if (xElem.Name == "WeatherStations")
                    {
                        Weather.MM_WeatherStationCollection.QueryPrepend = xElem.Attributes["URL"].Value;
                    }
                    else if (xElem.Name == "WeatherStationAlerts")
                    {
                        Weather.MM_WeatherStationCollection.AlertsPrepend = xElem.Attributes["URL"].Value;
                    }
                    else if (xElem.Name == "WeatherStationForecast")
                    {
                        Weather.MM_WeatherStationCollection.ForecastPrepend = xElem.Attributes["URL"].Value;
                    }
                    else if (xElem.Name == "StateBorder")
                    {
                        MM_Boundary.StateDisplay = new MM_DisplayParameter(xElem, true);
                    }
                    else if (xElem.Name == "CountyBorder")
                    {
                        MM_Boundary.CountyDisplay = new MM_DisplayParameter(xElem, true);
                    }
                    else if (xElem.Name == "Displays" || xElem.Name == "Views" || xElem.Name == "KeyIndicators")
                    {
                    }
                    else
                    {
                        MM_System_Interfaces.WriteConsoleLine("Unknown element from XML configuration: " + xElem.Name);
                    }
                }
                catch
                { }
            }

            //Now pull in our views
            Views.Add(xConfiguration["Configuration"]["DisplayParameters"], new MM_Display_View(xConfiguration["Configuration"]["DisplayParameters"].Attributes["DefaultName"].Value));
            foreach (XmlElement xElem in xConfiguration["Configuration"]["DisplayParameters"]["Views"].SelectNodes("//View"))
            {
                Views.Add(xElem, new MM_Display_View(xElem));
            }

            //Pull in our commands
            foreach (XmlElement xElem in xConfiguration.SelectNodes("/Configuration/Commands/Command").OfType <XmlElement>())
            {
                try
                {
                    Data_Integration.Commands.Add(new MM_Command(xElem, true));
                }
                catch
                { }
            }
            try
            {
                foreach (XmlElement xElem in xConfiguration.SelectNodes("/Configuration/DataTypes/DataType").OfType <XmlElement>())
                {
                    MM_DataRetrieval_Information Retr = new MM_DataRetrieval_Information(xElem);
                    MM_Server_Interface.DataRetrievalInformation.Add(Retr.BaseType, Retr);
                }
            }
            catch (Exception ex)
            {
                MM_System_Interfaces.LogError(ex);
            }

            //Now add in our icons for actions to our image collection
            ViolationImages.Images.Add("Note", Properties.Resources.NoteHS);
            ViolationImages.Images.Add("OneLine", Properties.Resources.OneLine);
            ViolationImages.Images.Add("MoveMap", Properties.Resources.MoveMap);
            ViolationImages.Images.Add("Web", Properties.Resources.SearchWebHS);
            ViolationImages.Images.Add("Acknowledge", Properties.Resources.Acknowledge);
            ViolationImages.Images.Add("Archive", Properties.Resources.Archive);
            ViolationImages.Images.Add("Properties", Properties.Resources.PropertiesHS);

            //Pull in any one-line or element type information
            foreach (XmlElement xElem in xConfiguration["Configuration"]["OneLineData"].ChildNodes.OfType <XmlElement>())
            {
                if (!MM_Repository.ElemTypes.ContainsKey(xElem.Attributes["Name"].Value))
                {
                    MM_Repository.ElemTypes.Add(xElem.Attributes["Name"].Value, new MM_Element_Type(xElem, false));
                }
            }

            //override the permissions
            if (MM_Server_Interface.ISQse)
            {
                Data_Integration.Permissions.LassoStandard  = false;
                Data_Integration.Permissions.ShowViolations = false;
            }
        }