Beispiel #1
0
        private void DeleteNodeRelatedfeatures(GTRelationshipOrdinalConstants ordinal, IGTKeyObject m_feature)
        {
            try
            {
                using (IGTRelationshipService oRel = GTClassFactory.Create <IGTRelationshipService>())
                {
                    oRel.DataContext   = m_dataContext;
                    oRel.ActiveFeature = m_feature;

                    IGTKeyObjects relatedFeatures = GTClassFactory.Create <IGTKeyObjects>();
                    try
                    {
                        relatedFeatures = oRel.GetRelatedFeatures(14, ordinal);
                    }
                    catch
                    {
                    }

                    if (relatedFeatures != null)
                    {
                        foreach (IGTKeyObject feature in relatedFeatures)
                        {
                            if (m_IsoScenarioselectedFeatureFNOs.Contains(feature.FNO))
                            {
                                oRel.SilentDelete(14, ordinal);
                            }
                        }
                    }
                }
            }
            catch
            {
                throw;
            }
        }
Beispiel #2
0
        private void EstablishIsolationPointConnectivity(IGTKeyObject oIsolationPointParent, IGTKeyObject oIsolationPointNew, GTRelationshipOrdinalConstants node)
        {
            try
            {
                IGTKeyObjects oldIsoRelatedFeatures = GTClassFactory.Create <IGTKeyObjects>();

                using (IGTRelationshipService oRel = GTClassFactory.Create <IGTRelationshipService>())
                {
                    oRel.ActiveFeature = oIsolationPointParent;
                    oRel.DataContext   = m_dataContext;
                    try
                    {
                        oldIsoRelatedFeatures = oRel.GetRelatedFeatures(14, node);
                    }
                    catch
                    {
                    }

                    oRel.ActiveFeature = oIsolationPointNew;

                    oRel.SilentDelete(14, node);
                    GTRelationshipOrdinalConstants relatedNode = GTRelationshipOrdinalConstants.gtrelRelationshipOrdinal1;

                    foreach (IGTKeyObject feature in oldIsoRelatedFeatures)
                    {
                        if (m_isolationScenarioType == IsolationScenarios.BYPASS && feature.FNO == 40)
                        {
                            continue;
                        }
                        else
                        {
                            DetermineConnectivityNode(oIsolationPointParent, feature, ref relatedNode);
                            EstablishConnectivity(oIsolationPointNew, feature, node, relatedNode);
                        }
                    }
                }
            }
            catch
            {
                throw;
            }
        }
Beispiel #3
0
        /// <summary>
        /// Method to validate that the Isolation Scenario is configured correctly.
        /// If configured correctly then no action.
        /// Else, create virtual points and/or establish connectivity as necessary.
        /// </summary>
        public void ValidateIsolationScenario()
        {
            Dictionary <int, GTRelationshipOrdinalConstants> dicRelatedNodes = new Dictionary <int, GTRelationshipOrdinalConstants>();

            try
            {
                bool isoPtExists = false;
                // Check if Isolation Scenario is valid on Node1.
                if (ValidateIsolationPoint(m_IsolationScenarioFeature.RelatedFeaturesNode1, ref isoPtExists, 1))
                {
                    if (!isoPtExists)
                    {
                        // Create Isolation Point since one doesn't exist
                        CreateIsolationPoint(1);
                        m_IsoCommon.SetNormalAndAsOperatedStatus(m_IsolationScenarioFeature.IsolationPoint1, 1);
                    }

                    // Check if Isolation Scenario is valid on Node2.
                    if (ValidateIsolationPoint(m_IsolationScenarioFeature.RelatedFeaturesNode2, ref isoPtExists, 2))
                    {
                        if (!isoPtExists)
                        {
                            // Create Isolation Point since one doesn't exist
                            CreateIsolationPoint(2);
                            m_IsoCommon.SetNormalAndAsOperatedStatus(m_IsolationScenarioFeature.IsolationPoint2, 2);
                        }

                        GTRelationshipOrdinalConstants relatedNode = GTRelationshipOrdinalConstants.gtrelRelationshipOrdinal1;

                        foreach (IGTKeyObject feature in m_IsolationScenarioFeature.RelatedFeaturesNode1)
                        {
                            if (feature.FID != m_IsolationScenarioFeature.IsolationPoint1.FID)
                            {
                                m_IsoCommon.DetermineConnectivityNode(m_IsolationScenarioFeature.GtKeyObject, feature, ref relatedNode);
                                dicRelatedNodes.Add(feature.FID, relatedNode);
                            }
                        }
                        using (IGTRelationshipService oRel = GTClassFactory.Create <IGTRelationshipService>())
                        {
                            oRel.DataContext   = m_dataContext;
                            oRel.ActiveFeature = m_IsolationScenarioFeature.GtKeyObject;
                            oRel.SilentDelete(14, GTRelationshipOrdinalConstants.gtrelRelationshipOrdinal1);

                            // If features related to Isolation Scenario feature are connected directly to Node 1 of Isolation Scenario feature, then
                            // reconnect features to Isolation Point feature.
                            foreach (IGTKeyObject feature in m_IsolationScenarioFeature.RelatedFeaturesNode1)
                            {
                                // Skip the processing for the Isolation Point feature since the Isolation Point was already validated/updated.
                                if (feature.FID != m_IsolationScenarioFeature.IsolationPoint1.FID && dicRelatedNodes.TryGetValue(feature.FID, out relatedNode))
                                {
                                    // m_IsoCommon.DetermineConnectivityNode(m_IsolationScenarioFeature.GtKeyObject, feature, ref relatedNode);
                                    m_IsoCommon.EstablishConnectivity(m_IsolationScenarioFeature.IsolationPoint1, feature, GTRelationshipOrdinalConstants.gtrelRelationshipOrdinal1, relatedNode);
                                }
                            }

                            m_IsoCommon.EstablishConnectivity(m_IsolationScenarioFeature.IsolationPoint1, m_IsolationScenarioFeature.GtKeyObject, GTRelationshipOrdinalConstants.gtrelRelationshipOrdinal2, GTRelationshipOrdinalConstants.gtrelRelationshipOrdinal1);

                            m_IsoCommon.EstablishOwnerShip(m_IsolationScenarioFeature.GtKeyObject, m_IsolationScenarioFeature.IsolationPoint1);

                            m_IsoCommon.PopulateProtectionDeviceIDForIsoPt(m_IsolationScenarioFeature.GtKeyObject, m_IsolationScenarioFeature.IsolationPoint1);



                            dicRelatedNodes.Clear();

                            foreach (IGTKeyObject feature in m_IsolationScenarioFeature.RelatedFeaturesNode2)
                            {
                                if (feature.FID != m_IsolationScenarioFeature.IsolationPoint2.FID)
                                {
                                    m_IsoCommon.DetermineConnectivityNode(m_IsolationScenarioFeature.GtKeyObject, feature, ref relatedNode);
                                    dicRelatedNodes.Add(feature.FID, relatedNode);
                                }
                            }

                            oRel.SilentDelete(14, GTRelationshipOrdinalConstants.gtrelRelationshipOrdinal2);
                        }
                        // If features related to Isolation Scenario feature are connected directly to Node 2 of Isolation Scenario feature, then
                        // reconnect features to Isolation Point feature.
                        foreach (IGTKeyObject feature in m_IsolationScenarioFeature.RelatedFeaturesNode2)
                        {
                            // Skip the processing for the Isolation Point feature since the Isolation Point was already validated/updated.
                            if (feature.FID != m_IsolationScenarioFeature.IsolationPoint2.FID && dicRelatedNodes.TryGetValue(feature.FID, out relatedNode))
                            {
                                //m_IsoCommon.DetermineConnectivityNode(m_IsolationScenarioFeature.GtKeyObject, feature, ref relatedNode);
                                m_IsoCommon.EstablishConnectivity(m_IsolationScenarioFeature.IsolationPoint2, feature, GTRelationshipOrdinalConstants.gtrelRelationshipOrdinal2, relatedNode);
                            }
                        }

                        m_IsoCommon.EstablishConnectivity(m_IsolationScenarioFeature.IsolationPoint2, m_IsolationScenarioFeature.GtKeyObject, GTRelationshipOrdinalConstants.gtrelRelationshipOrdinal1, GTRelationshipOrdinalConstants.gtrelRelationshipOrdinal2);

                        m_IsoCommon.EstablishOwnerShip(m_IsolationScenarioFeature.GtKeyObject, m_IsolationScenarioFeature.IsolationPoint2);

                        m_IsoCommon.PopulateProtectionDeviceIDForIsoPt(m_IsolationScenarioFeature.GtKeyObject, m_IsolationScenarioFeature.IsolationPoint2);
                    }
                }
            }
            catch (Exception ex)
            {
                if (m_IsoCommon.InteractiveMode)
                {
                    MessageBox.Show("Error in Isolation Scenario FI:ValidateIsolationScenario - " + ex.Message, "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
            finally
            {
                dicRelatedNodes.Clear();
                dicRelatedNodes = null;
            }
        }
Beispiel #4
0
        /// <summary>
        /// Determines which node of the related feature is connected to the active feature.
        /// </summary>
        /// <param name="activeKO">Active feature to connect.</param>
        /// <param name="relatedKO">Related feature to connect.</param>
        /// <param name="relatedRelationshipOrdinal">Node on the related feature to connect.</param>
        /// <returns>Boolean indicating status</returns>
        public bool DetermineConnectivityNode(IGTKeyObject activeKO, IGTKeyObject relatedKO, ref GTRelationshipOrdinalConstants relatedRelationshipOrdinal)
        {
            bool returnValue = false;
            IGTRelationshipService relationshipService = null;
            IGTKeyObjects          m_relatedFeatures   = null;
            bool foundNode = false;

            try
            {
                relationshipService               = GTClassFactory.Create <IGTRelationshipService>();
                relationshipService.DataContext   = DataContext;
                relationshipService.ActiveFeature = relatedKO;

                m_relatedFeatures = relationshipService.GetRelatedFeatures(14, GTRelationshipOrdinalConstants.gtrelRelationshipOrdinal1);

                foreach (IGTKeyObject feature in m_relatedFeatures)
                {
                    if (feature.FID == activeKO.FID)
                    {
                        relatedRelationshipOrdinal = GTRelationshipOrdinalConstants.gtrelRelationshipOrdinal1;
                        foundNode = true;
                        break;
                    }
                }

                if (!foundNode)
                {
                    relatedRelationshipOrdinal = GTRelationshipOrdinalConstants.gtrelRelationshipOrdinal2;
                }

                returnValue = true;
            }
            catch (Exception ex)
            {
                returnValue = false;
                if (InteractiveMode)
                {
                    MessageBox.Show("Error in Isolation Scenario FI:DetermineConnectivityNode - " + ex.Message, "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }

            relationshipService.Dispose();

            return(returnValue);
        }
Beispiel #5
0
        /// <summary>
        /// Establishes the connectivity relationship for the input features.
        /// </summary>
        /// <param name="activeKO">Active feature to connect.</param>
        /// <param name="relatedKO">Related feature to connect.</param>
        /// <param name="activeRelationshipOrdinal">Node on the active feature to connect.</param>
        /// <param name="relatedRelationshipOrdinal">Node on the related feature to connect.</param>
        /// <returns>Boolean indicating status</returns>
        public bool EstablishConnectivity(IGTKeyObject activeKO, IGTKeyObject relatedKO, GTRelationshipOrdinalConstants activeRelationshipOrdinal, GTRelationshipOrdinalConstants relatedRelationshipOrdinal)
        {
            bool returnValue = false;
            IGTRelationshipService relationshipService = null;
            Int32     node1  = 0;
            Int32     node2  = 0;
            Recordset connRS = null;

            try
            {
                // Get current connectivity for active feature.
                // This is needed to reset the connectivity if establish connectivity fails.
                // Establish connectivity may fail if data violates the rule defined in metadata.
                //     For example, Feature A is connected to Node 1 of the Transformer.
                //     When the FI fires and creates an Isolation Point at the Transformer,
                //     then all features currently at node 1 of the Transformer are connected to node 1 of the Isolation Point
                //     and the Transformer is connected to node 2 of the Isolation Point.
                //     The FI will attempt to connect Feature A to the Isolation Point which may not be allowed in metadata. This would throw an error.
                // There are many other reasons why the establish could fail, so best to catch any errors and reset the connectivity.
                connRS = relatedKO.Components.GetComponent(11).Recordset;
                if (connRS.RecordCount > 0)
                {
                    connRS.MoveFirst();
                    node1 = Convert.ToInt32(connRS.Fields["NODE_1_ID"].Value);
                    node2 = Convert.ToInt32(connRS.Fields["NODE_2_ID"].Value);
                }

                relationshipService               = GTClassFactory.Create <IGTRelationshipService>();
                relationshipService.DataContext   = DataContext;
                relationshipService.ActiveFeature = activeKO;

                if (relationshipService.AllowSilentEstablish(relatedKO))
                {
                    //relationshipService.SilentDelete(14, activeRelationshipOrdinal);
                    relationshipService.SilentEstablish(14, relatedKO, activeRelationshipOrdinal, relatedRelationshipOrdinal);
                }

                returnValue = true;
            }
            catch
            {
                //returnValue = false;
                returnValue = true;

                // Reset connectivity
                if (connRS != null)
                {
                    if (connRS.RecordCount > 0)
                    {
                        connRS.MoveFirst();
                        connRS.Fields["NODE_1_ID"].Value = node1;
                        connRS.Fields["NODE_2_ID"].Value = node2;
                    }
                }

                //if (InteractiveMode)
                //{
                //    MessageBox.Show("Error in Isolation Scenario FI:EstablishConnectivity - " + ex.Message, "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                //}
            }

            relationshipService.Dispose();

            return(returnValue);
        }
Beispiel #6
0
        public void DetermineConnectivityNode(IGTKeyObject activeKO, IGTKeyObject relatedKO, ref GTRelationshipOrdinalConstants relatedRelationshipOrdinal)
        {
            IGTKeyObjects m_relatedFeatures = null;
            bool          foundNode         = false;

            try
            {
                using (IGTRelationshipService oRel = GTClassFactory.Create <IGTRelationshipService>())
                {
                    oRel.DataContext   = m_dataContext;
                    oRel.ActiveFeature = relatedKO;

                    m_relatedFeatures = oRel.GetRelatedFeatures(14, GTRelationshipOrdinalConstants.gtrelRelationshipOrdinal1);
                }
                foreach (IGTKeyObject feature in m_relatedFeatures)
                {
                    if (feature.FID == activeKO.FID)
                    {
                        relatedRelationshipOrdinal = GTRelationshipOrdinalConstants.gtrelRelationshipOrdinal1;
                        foundNode = true;
                        break;
                    }
                }

                if (!foundNode)
                {
                    relatedRelationshipOrdinal = GTRelationshipOrdinalConstants.gtrelRelationshipOrdinal2;
                }
            }
            catch
            {
                throw;
            }
        }
Beispiel #7
0
        private void GetIsolationPoint(IGTKeyObject feature, ref IGTKeyObject oIsolationPointParent, GTRelationshipOrdinalConstants node)
        {
            try
            {
                IGTKeyObjects relatedFeatures = GTClassFactory.Create <IGTKeyObjects>();

                using (IGTRelationshipService oRel = GTClassFactory.Create <IGTRelationshipService>())
                {
                    oRel.ActiveFeature = feature;
                    oRel.DataContext   = m_dataContext;
                    try
                    {
                        relatedFeatures = oRel.GetRelatedFeatures(14, node);
                    }
                    catch
                    {
                    }

                    if (relatedFeatures != null && relatedFeatures.Count > 0)
                    {
                        if (feature != null)
                        {
                            foreach (IGTKeyObject item in relatedFeatures)
                            {
                                if (m_IsoScenarioselectedFeatureFNOs.Contains(item.FNO) && CheckAssociatedVirtualPoint(item.FID, feature.FID))
                                {
                                    if (m_elbowConnected)
                                    {
                                        m_elbowConnected = false;
                                        continue;
                                    }
                                    else
                                    {
                                        oIsolationPointParent = item;
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch
            {
                throw;
            }
        }
Beispiel #8
0
        public bool EstablishConnectivity(IGTKeyObject activeKO, IGTKeyObject relatedKO, GTRelationshipOrdinalConstants activeRelationshipOrdinal, GTRelationshipOrdinalConstants relatedRelationshipOrdinal)
        {
            bool returnValue = false;
            IGTRelationshipService relationshipService = null;
            Int32     node1  = 0;
            Int32     node2  = 0;
            Recordset connRS = null;

            try
            {
                connRS = relatedKO.Components.GetComponent(11).Recordset;
                if (connRS.RecordCount > 0)
                {
                    connRS.MoveFirst();
                    node1 = Convert.ToInt32(connRS.Fields["NODE_1_ID"].Value);
                    node2 = Convert.ToInt32(connRS.Fields["NODE_2_ID"].Value);
                }

                relationshipService               = GTClassFactory.Create <IGTRelationshipService>();
                relationshipService.DataContext   = m_dataContext;
                relationshipService.ActiveFeature = activeKO;

                if (relationshipService.AllowSilentEstablish(relatedKO))
                {
                    relationshipService.SilentEstablish(14, relatedKO, activeRelationshipOrdinal, relatedRelationshipOrdinal);
                }

                returnValue = true;
            }
            catch
            {
                //returnValue = false;
                returnValue = true;

                // Reset connectivity
                if (connRS != null)
                {
                    if (connRS.RecordCount > 0)
                    {
                        connRS.MoveFirst();
                        connRS.Fields["NODE_1_ID"].Value = node1;
                        connRS.Fields["NODE_2_ID"].Value = node2;
                    }
                }
            }

            relationshipService.Dispose();
            return(returnValue);
        }