예제 #1
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;
            }
        }
예제 #2
0
        /// <summary>
        /// Refresh our list of operated equipment
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnRefresh_Click(object sender, EventArgs e)
        {
            OperatedSubstations.Clear();
            MM_Substation_Display     FoundSub       = null;
            Dictionary <int, MM_Line> LineCollection = new Dictionary <int, MM_Line>();
            bool IsMaster = MM_Server_Interface.ClientAreas.ContainsKey("ERCOT");


            foreach (MM_Element Elem in MM_Repository.TEIDs.Values)
            {
                if (Elem.ElemType != null && Elem.Operator != null && Elem is MM_Blackstart_Corridor_Element == false && (IsMaster || MM_Server_Interface.ClientAreas.ContainsKey(Elem.Operator.Alias)))
                {
                    if (Elem.Substation != null)
                    {
                        if (!OperatedSubstations.TryGetValue(Elem.Substation.TEID, out FoundSub))
                        {
                            OperatedSubstations.Add(Elem.Substation.TEID, FoundSub = new MM_Substation_Display(Elem.Substation, this));
                        }
                        if (Elem.ElemType.Name == "Breaker")
                        {
                            FoundSub.Breakers++;
                        }
                        else if (Elem.ElemType.Name == "Switch")
                        {
                            FoundSub.Switches++;
                        }
                        else if (Elem.ElemType.Name == "Capacitor")
                        {
                            FoundSub.Capacitors++;
                        }
                        else if (Elem.ElemType.Name == "Reactor")
                        {
                            FoundSub.Reactors++;
                        }
                        else if (Elem.ElemType.Name == "StaticVarCompensator")
                        {
                            FoundSub.SVCs++;
                        }
                    }
                    else if (Elem is MM_Line)
                    {
                        MM_Line Line = (MM_Line)Elem;
                        if (!Line.IsSeriesCompensator)
                        {
                            foreach (MM_Substation Sub in Line.ConnectedStations)
                            {
                                if (!OperatedSubstations.TryGetValue(Sub.TEID, out FoundSub))
                                {
                                    OperatedSubstations.Add(Sub.TEID, FoundSub = new MM_Substation_Display(Sub, this));
                                }
                                FoundSub.Lines++;
                                if (!LineCollection.ContainsKey(Line.TEID))
                                {
                                    LineCollection.Add(Line.TEID, Line);
                                }
                            }
                        }
                    }
                }
            }


            //Clear our lines and loads tables
            dgvLines.Elements.Clear();
            dgvUnits.Elements.Clear();
            dgvSubstations.Elements.Clear();

            //Now, write out each element
            dgvSubstations.Elements.RaiseListChangedEvents = false;
            dgvUnits.Elements.RaiseListChangedEvents       = false;
            dgvLines.Elements.RaiseListChangedEvents       = false;
            foreach (MM_Substation_Display Sub in OperatedSubstations.Values)
            {
                dgvSubstations.Elements.Add(Sub);
                if (Sub.Substation.Units != null)
                {
                    foreach (MM_Unit Unit in Sub.Substation.Units)
                    {
                        if (MM_Server_Interface.ClientAreas.ContainsKey("ERCOT") || MM_Server_Interface.ClientAreas.ContainsKey(Unit.Operator.Alias))
                        {
                            dgvUnits.Elements.Add(new MM_Unit_Display(Unit, this));
                        }
                    }
                }
            }

            foreach (MM_Line Line in LineCollection.Values)
            {
                dgvLines.Elements.Add(new MM_Line_Display(Line, this));
            }

            dgvSubstations.Elements.RaiseListChangedEvents = false;
            dgvUnits.Elements.RaiseListChangedEvents       = false;
            dgvLines.Elements.RaiseListChangedEvents       = false;

            dgvSubstations.Elements.ResetBindings();
            dgvUnits.Elements.ResetBindings();
            dgvLines.Elements.ResetBindings();
        }