Example #1
0
        /// <summary>
        /// Get Left Origin Point
        /// </summary>
        /// <param name="m_gtComponents"></param>
        /// <param name="m_gtRelativePoint"></param>
        /// <param name="m_gtLineGeometry"></param>
        /// <returns></returns>
        private IGTPoint GetLeftOriginPoint(IGTKeyObject m_KeyObject, IGTComponents m_gtComponents, IGTKeyObject m_gtRelativePoint, IGTGeometry m_gtLineGeometry, IGTKeyObjects m_gtRelativeLines)
        {
            try
            {
                //Get Left Origin Point
                IGTPoint m_gtLeftOriginPoint = null;
                IGTRelationshipService m_gtRelationshipService = GTClassFactory.Create <IGTRelationshipService>();
                m_gtRelationshipService.DataContext = m_gtApplication.DataContext;
                if (m_rlnode2 != 0)
                {
                    m_gtLeftOriginPoint = PointAtDistanceBetweenTwoPoints(m_gtLineGeometry.FirstPoint, m_gtLineGeometry.LastPoint, xOffset, 0);
                    m_gtRelativeLines[0].Components.GetComponent(ConnectivityCNO).Recordset.Fields["NODE_2_ID"].Value = 0;
                    m_gtRelativeLines[0].Components.GetComponent(ConnectivityCNO).Recordset.Update();

                    //establish the relationship
                    m_gtRelationshipService.ActiveFeature = m_KeyObject;
                    m_gtRelationshipService.SilentEstablish(iRNO, m_gtRelativeLines[0], GTRelationshipOrdinalConstants.gtrelRelationshipOrdinal1, GTRelationshipOrdinalConstants.gtrelRelationshipOrdinal2);
                    m_gtRelativeLines[0].Components.GetComponent(ConnectivityCNO).Recordset.Update();
                    m_gtComponents.GetComponent(ConnectivityCNO).Recordset.Update();
                }
                else
                {
                    m_gtLeftOriginPoint = PointAtDistanceBetweenTwoPoints(m_gtLineGeometry.LastPoint, m_gtLineGeometry.FirstPoint, -xOffset, 0);
                    m_gtRelativeLines[0].Components.GetComponent(ConnectivityCNO).Recordset.Fields["NODE_2_ID"].Value = 0;
                    m_gtRelativeLines[0].Components.GetComponent(ConnectivityCNO).Recordset.Update();
                    m_gtComponents.GetComponent(ConnectivityCNO).Recordset.Update();
                }
                m_gtRelationshipService = null;
                return(m_gtLeftOriginPoint);
            }
            catch
            {
                throw;
            }
        }
Example #2
0
        /// <summary>
        /// Set Right Node Values
        /// </summary>
        /// <param name="m_gtComponents"></param>
        /// <param name="m_gtRelativePoint"></param>
        /// <param name="m_gtLineGeometry"></param>
        /// <returns></returns>
        private IGTPoint GetRightOriginPoint(IGTKeyObject m_KeyObject, IGTKeyObject m_gtRelativeLine, IGTKeyObject m_gtRelativePoint, IGTGeometry m_gtLineGeometry)
        {
            try
            {
                IGTPoint m_gtRightOriginPoint = null;
                IGTRelationshipService m_gtRelationshipService = GTClassFactory.Create <IGTRelationshipService>();
                m_gtRelationshipService.DataContext = m_gtApplication.DataContext;
                //get the related feature
                IGTKeyObjects m_gtElbow = GetRelatedFeature(m_gtRelativePoint, iRNO, m_KeyObject.FNO);

                //delete the relationship to remove primary conductor
                m_gtRelationshipService.ActiveFeature = m_gtRelativePoint;
                m_gtRelationshipService.SilentDelete(iRNO, GTRelationshipOrdinalConstants.gtrelRelationshipOrdinal1);
                m_gtRelativePoint.Components.GetComponent(ConnectivityCNO).Recordset.Update();
                m_gtElbow[0].Components.GetComponent(ConnectivityCNO).Recordset.Update();
                m_gtRelativeLine.Components.GetComponent(ConnectivityCNO).Recordset.Update();

                //establish the relationhip
                m_gtRelationshipService.SilentEstablish(iRNO, m_gtElbow[0], GTRelationshipOrdinalConstants.gtrelRelationshipOrdinal1, GTRelationshipOrdinalConstants.gtrelRelationshipOrdinal2);
                m_gtRelativePoint.Components.GetComponent(ConnectivityCNO).Recordset.Update();
                m_gtElbow[0].Components.GetComponent(ConnectivityCNO).Recordset.Update();

                if (m_rlnode1 != 0)
                {
                    m_gtRightOriginPoint = PointAtDistanceBetweenTwoPoints(m_gtLineGeometry.LastPoint, m_gtLineGeometry.FirstPoint, xOffset, 0);
                    m_gtRelativeLine.Components.GetComponent(ConnectivityCNO).Recordset.Fields["NODE_1_ID"].Value = 0;
                    m_gtRelativeLine.Components.GetComponent(ConnectivityCNO).Recordset.Update();
                    //establish the relationhip
                    m_gtRelationshipService.ActiveFeature = m_KeyObject;
                    m_gtRelationshipService.SilentEstablish(iRNO, m_gtRelativeLine, GTRelationshipOrdinalConstants.gtrelRelationshipOrdinal2, GTRelationshipOrdinalConstants.gtrelRelationshipOrdinal1);
                    m_KeyObject.Components.GetComponent(ConnectivityCNO).Recordset.Update();
                }
                else
                {
                    m_gtRightOriginPoint = PointAtDistanceBetweenTwoPoints(m_gtLineGeometry.FirstPoint, m_gtLineGeometry.LastPoint, -xOffset, 0);
                    m_gtRelativeLine.Components.GetComponent(ConnectivityCNO).Recordset.Fields["NODE_1_ID"].Value = 0;
                }
                m_gtRelativeLine.Components.GetComponent(ConnectivityCNO).Recordset.Update();
                m_gtRelationshipService = null;
                return(m_gtRightOriginPoint);
            }
            catch
            {
                throw;
            }
        }
Example #3
0
        /// <summary>
        /// override After establish
        /// </summary>
        public override void AfterEstablish()
        {
            IGTRelationshipService gtRelationshipService = GTClassFactory.Create <IGTRelationshipService>() as IGTRelationshipService;

            try
            {
                if ((ActiveFeature.FNO == RecloserOH_FNO) || (ActiveFeature.FNO == RecloserUG_FNO) || (ActiveFeature.FNO == VoltageRegulator_FNO) || (ActiveFeature.FNO == Autotransformer_FNO) || (ActiveFeature.FNO == TransformerUG_FNO))
                {
                    gtRelationshipService.DataContext   = gtApplication.DataContext;
                    gtRelationshipService.ActiveFeature = this.ActiveFeature;

                    //Get related features
                    IGTKeyObjects relationshipcandidates = gtRelationshipService.GetRelatedFeatures(m_RNO);
                    if (relationshipcandidates != null)
                    {
                        for (int i = 0; i < relationshipcandidates.Count; i++)
                        {
                            // check if opposite nodes are connected otherwise .. change the node of the related feature
                            if ((relationshipcandidates.Count == 2) || (GetComponentType(relationshipcandidates[i].CNO).ToString() == "PolylineGeometry") && (GetComponentType(ActiveFeature.CNO) != GetComponentType(relationshipcandidates[i].CNO)))
                            {
                                if (Convert.ToString(relationshipcandidates[i].Components.GetComponent(ConnectivityG3eCno).Recordset.Fields["NODE_2_ID"].Value) != Convert.ToString(relationshipcandidates[i + 1].Components.GetComponent(ConnectivityG3eCno).Recordset.Fields["NODE_1_ID"].Value))
                                {
                                    ActiveFeature.Components.GetComponent(ConnectivityG3eCno).Recordset.Fields["NODE_1_ID"].Value = relationshipcandidates[i].Components.GetComponent(ConnectivityG3eCno).Recordset.Fields["NODE_2_ID"].Value;
                                    ActiveFeature.Components.GetComponent(ConnectivityG3eCno).Recordset.Fields["NODE_2_ID"].Value = relationshipcandidates[i + 1].Components.GetComponent(ConnectivityG3eCno).Recordset.Fields["NODE_1_ID"].Value;
                                    ActiveFeature.Components.GetComponent(ConnectivityG3eCno).Recordset.Update();
                                    break;
                                }
                                else
                                {
                                    ActiveFeature.Components.GetComponent(ConnectivityG3eCno).Recordset.Fields["NODE_1_ID"].Value = relationshipcandidates[i].Components.GetComponent(ConnectivityG3eCno).Recordset.Fields["NODE_2_ID"].Value;
                                    relationshipcandidates[i + 1].Components.GetComponent(ConnectivityG3eCno).Recordset.Fields["NODE_1_ID"].Value = 0;
                                    relationshipcandidates[i + 1].Components.GetComponent(ConnectivityG3eCno).Recordset.Update();
                                    gtRelationshipService.SilentEstablish(m_RNO, relationshipcandidates[i + 1], GTRelationshipOrdinalConstants.gtrelRelationshipOrdinal2, GTRelationshipOrdinalConstants.gtrelRelationshipOrdinal1);
                                    break;
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error " + ex.Message, sMsgBoxCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                if (gtRelationshipService != null)
                {
                    gtRelationshipService.Dispose();
                    gtRelationshipService = null;
                }
            }
        }
Example #4
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);
        }
Example #5
0
        /// <summary>
        /// Establish ownership between street light and Miscellaneous Structure.
        /// </summary>
        /// <param name="gtStreetLightKObject"></param>
        private void EstablishOwnership(IGTKeyObject gtStreetLightKObject)
        {
            IGTRelationshipService gtRelationshipService = GTClassFactory.Create <IGTRelationshipService>();

            try
            {
                Recordset ownerRNORecords = m_oGTDataContext.MetadataRecordset("G3E_RELATIONSHIPS_OPTABLE", "G3E_TYPE = 3 AND G3E_TABLE = 'G3E_OWNERSHIP_ELEC' AND G3E_USERNAME = '******'");
                ownerRNORecords.MoveFirst();
                gtRelationshipService.DataContext   = m_oGTDataContext;
                gtRelationshipService.ActiveFeature = gtStreetLightKObject;
                if (gtRelationshipService.AllowSilentEstablish(gTOwnerKeyObject))
                {
                    gtRelationshipService.SilentEstablish(Convert.ToInt16(ownerRNORecords.Fields["G3E_RNO"].Value), gTOwnerKeyObject);
                }
            }
            catch
            {
                throw;
            }
        }
Example #6
0
        public void EstablishOwnerShip(IGTKeyObject activeKO, IGTKeyObject isolationPoint)
        {
            IGTRelationshipService relationshipService = null;

            try
            {
                relationshipService               = GTClassFactory.Create <IGTRelationshipService>();
                relationshipService.DataContext   = DataContext;
                relationshipService.ActiveFeature = activeKO;
                IGTKeyObjects m_relatedFeatures = relationshipService.GetRelatedFeatures(3);

                foreach (IGTKeyObject ownerFeature in m_relatedFeatures)
                {
                    relationshipService.ActiveFeature = isolationPoint;

                    if (relationshipService.AllowSilentEstablish(ownerFeature))
                    {
                        try
                        {
                            relationshipService.SilentEstablish(3, ownerFeature);
                        }
                        catch
                        {
                        }
                    }
                }
            }
            catch
            {
            }
            finally
            {
                relationshipService.Dispose();
                relationshipService = null;
            }
        }
Example #7
0
        public void CreateDuct(string sASSIGNMENT, int iPOS_HORZ_FROM, int iPOS_VERT_FROM, int iPOS_HORZ_TO, int iPOS_VERT_TO, int iSTALE_FLAG_FROM, int iSTALE_FLAG_TO)
        {
            IGTKeyObject tmpFeatureDuct = null;

            try
            {
                object oMissing = System.Reflection.Missing.Value;

                //Create fORMATION
                tmpFeatureDuct = m_oDataContext.NewFeature(csConstant.SHORT_DUCT);
                //NETELEM
                tmpFeatureDuct.Components["COMMON_N"].Recordset.MoveFirst();
                //csGlobals.tmpFeatureFormation.Components["GC_NETELEM"].Recordset.Fields["FEATURE_STATE"].Value = dataGridViewExpansion.Rows[i].Cells["STATE"].Value.ToString();
                //MAIN COMPONENT
                tmpFeatureDuct.Components["DUCT_N"].Recordset.MoveFirst();
                //ASSIGNMENT,POS_HORZ_FROM,POS_HORZ_TO,POS_VERT_FROM,POS_VERT_TO,STALE_FLAG_FROM,STALE_FLAG_TO
                tmpFeatureDuct.Components["DUCT_N"].Recordset.Fields["ASSIGNMENT_ID"].Value   = sASSIGNMENT;
                tmpFeatureDuct.Components["DUCT_N"].Recordset.Fields["FROM_POS_HORZ"].Value   = iPOS_HORZ_FROM;
                tmpFeatureDuct.Components["DUCT_N"].Recordset.Fields["TO_POS_HORZ"].Value     = iPOS_HORZ_TO;
                tmpFeatureDuct.Components["DUCT_N"].Recordset.Fields["FROM_POS_VERT"].Value   = iPOS_VERT_FROM;
                tmpFeatureDuct.Components["DUCT_N"].Recordset.Fields["TO_POS_VERT"].Value     = iPOS_VERT_TO;
                tmpFeatureDuct.Components["DUCT_N"].Recordset.Fields["FROM_STALE_FLAG"].Value = iSTALE_FLAG_FROM;
                tmpFeatureDuct.Components["DUCT_N"].Recordset.Fields["TO_STALE_FLAG"].Value   = iSTALE_FLAG_TO;

                IGTRelationshipService gServices = GTClassFactory.Create <IGTRelationshipService>();
                gServices.DataContext   = m_oDataContext;
                gServices.ActiveFeature = m_FormationFeature;
                gServices.SilentEstablish(csConstant.iContains, tmpFeatureDuct);
                gServices.Dispose();
                gServices = null;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Create Duct", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #8
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);
        }