Esempio n. 1
0
        private void Save()
        {
            Atend.Base.Calculating.CNetWorkCross cNetWorkCross = new Atend.Base.Calculating.CNetWorkCross();
            //if (string.IsNullOrEmpty(txt11.Text))
            //{
            //    txt11.Text = "0";
            //}


            //if (string.IsNullOrEmpty(txt20.Text))
            //{
            //    txt20.Text = "0";
            //}

            //if (string.IsNullOrEmpty(txt33.Text))
            //{
            //    txt33.Text = "0";
            //}

            //if (string.IsNullOrEmpty(txt380.Text))
            //{
            //    txt380.Text = "0";
            //}
            cNetWorkCross.KV11 = Convert.ToDouble(txt11.Text);
            cNetWorkCross.KV20 = Convert.ToDouble(txt20.Text);
            cNetWorkCross.KV32 = Convert.ToDouble(txt33.Text);
            cNetWorkCross.V380 = Convert.ToDouble(txt380.Text);
            cNetWorkCross.Name = txtName.Text;



            if (SelectedNetWorkCross == -1)
            {
                if (cNetWorkCross.AccessInsert())
                {
                    Reset();
                }
                else
                {
                    MessageBox.Show("امکان ثبت کردن اطلاعات نمی باشد", "خطا");
                }
            }
            else
            {
                cNetWorkCross.Code = SelectedNetWorkCross;
                if (cNetWorkCross.AccessUpdate())
                {
                    Reset();
                }
                else
                {
                    MessageBox.Show("امکان به روز رسانی اطلاعات نمی باشد", "خطا");
                }
            }
        }
Esempio n. 2
0
        public void BindDataToOwnControl(int Code)
        {
            SelectedNetWorkCross = Code;
            Atend.Base.Calculating.CNetWorkCross NetWorkCross = Atend.Base.Calculating.CNetWorkCross.AccessSelectByCode(Code);



            txtName.Text = NetWorkCross.Name;
            txt11.Text   = NetWorkCross.KV11.ToString();
            txt380.Text  = NetWorkCross.V380.ToString();
            txt20.Text   = NetWorkCross.KV20.ToString();
            txt33.Text   = NetWorkCross.KV32.ToString();
        }
Esempio n. 3
0
        private void پروندهToolStripMenuItem_Click(object sender, EventArgs e)
        {
            calcOptimalSagTension = new Atend.Global.Calculation.Mechanical.CalcOptimalSagTensionTest();

            if (Validation())
            {
                Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
                calcOptimalSagTension.DtPoleSection = Atend.Base.Design.DPoleSection.AccessSelectBySectionCodeProductType(new Guid(cboSelectSection.SelectedValue.ToString()), Convert.ToInt32(Atend.Control.Enum.ProductType.Pole));
                ed.WriteMessage("dtPoleSection1={0}\n", calcOptimalSagTension.DtPoleSection.Rows.Count);
                System.Data.DataTable dtPole = Atend.Base.Design.DPoleSection.AccessSelectBySectionCodeProductType(new Guid(cboSelectSection.SelectedValue.ToString()), Convert.ToInt32(Atend.Control.Enum.ProductType.PoleTip));

                ed.WriteMessage("dtPoleSection2={0}\n", calcOptimalSagTension.DtPoleSection.Rows.Count);
                foreach (DataRow dr in dtPole.Rows)
                {
                    DataRow drPole = calcOptimalSagTension.DtPoleSection.NewRow();
                    drPole["ProductType"] = dr["ProductType"].ToString();
                    drPole["ProductCode"] = dr["ProductCode"].ToString();
                    drPole["SectionCode"] = dr["SectionCode"].ToString();
                    calcOptimalSagTension.DtPoleSection.Rows.Add(drPole);
                }

                System.Data.DataColumn dc = new System.Data.DataColumn("PoleNumber");
                calcOptimalSagTension.DtPoleSection.Columns.Add(dc);
                foreach (DataRow dr in calcOptimalSagTension.DtPoleSection.Rows)
                {
                    Atend.Base.Design.DPackage node = Atend.Base.Design.DPackage.AccessSelectByNodeCode(new Guid(dr["ProductCode"].ToString()));
                    dr["PoleNumber"] = node.Number.ToString();
                }
                calcOptimalSagTension.VTS          = Convert.ToDouble(txtVTS.Text);
                calcOptimalSagTension.Volt         = Convert.ToDouble(cboVolt.Text);
                calcOptimalSagTension.DtPoleCond   = section.dtGlobal;
                calcOptimalSagTension.dtBranchList = section.dtBranchList;

                //ed.WriteMessage("Befor Read NetCross\n");
                for (int i = 0; i < gvNetCross.Rows.Count; i++)
                {
                    if (Convert.ToInt32(gvNetCross.Rows[i].Cells[0].Value) == Convert.ToInt32(cboSelectSection.Text))
                    {
                        DataGridViewComboBoxCell cboNetCross = (DataGridViewComboBoxCell)gvNetCross.Rows[i].Cells["Column2"];
                        NetCross = Atend.Base.Calculating.CNetWorkCross.AccessSelectByCode(Convert.ToInt32(cboNetCross.Value.ToString()));
                    }
                }

                if (cboVolt.Text == "400")
                {
                    calcOptimalSagTension.Clearance = NetCross.V380;
                }
                if (cboVolt.Text == "11000")
                {
                    calcOptimalSagTension.Clearance = NetCross.KV11;
                }
                if (cboVolt.Text == "20000")
                {
                    calcOptimalSagTension.Clearance = NetCross.KV20;
                }
                if (cboVolt.Text == "33000")
                {
                    calcOptimalSagTension.Clearance = NetCross.KV32;
                }
                //ed.WriteMessage("Create DtconductorSectionConsol={0}\n", cboSelectSection.SelectedValue.ToString());

                calcOptimalSagTension.DtconductorSection = Atend.Base.Design.DPoleSection.AccessSelectBySectionCodeProductType(new Guid(cboSelectSection.SelectedValue.ToString()), Convert.ToInt32(Atend.Control.Enum.ProductType.Conductor));
                if (calcOptimalSagTension.DtconductorSection.Rows.Count == 0)
                {
                    //ed.WriteMessage("Create DtconductorSection={0}\n", cboSelectSection.SelectedValue.ToString());
                    calcOptimalSagTension.DtconductorSection = Atend.Base.Design.DPoleSection.AccessSelectBySectionCodeProductType(new Guid(cboSelectSection.SelectedValue.ToString()), Convert.ToInt32(Atend.Control.Enum.ProductType.SelfKeeper));
                    //ed.WriteMessage("Count={0}\n", calcOptimalSagTension.DtconductorSection.Rows.Count);
                }

                System.Data.DataColumn dc1 = new System.Data.DataColumn("Angle");
                calcOptimalSagTension.DtconductorSection.Columns.Add(dc1);
                calcOptimalSagTension.SectionCode = new Guid(cboSelectSection.SelectedValue.ToString());
                calcOptimalSagTension.Start       = Convert.ToInt32(txtStart.Text);
                calcOptimalSagTension.End         = Convert.ToInt32(txtEnd.Text);
                calcOptimalSagTension.Distance    = Convert.ToInt32(txtDistance.Text);
                Atend.Base.Design.DBranch MyBranch = Atend.Base.Design.DBranch.AccessSelectByCode(new Guid(calcOptimalSagTension.DtconductorSection.Rows[0]["ProductCode"].ToString()));
                //ed.WriteMessage("OOO\n");
                dtSagTension.Rows.Clear();
                dtPole.Rows.Clear();
                dtConductorDay.Rows.Clear();

                se        = calcOptimalSagTension.ComputeSE();
                SpanCount = calcOptimalSagTension.DtconductorSection.Rows.Count;

                dtSagTension   = calcOptimalSagTension.CalSagTension(MyBranch).Copy();
                dtConductorDay = calcOptimalSagTension.CalcTempTable();

                gvSagAndTension.AutoGenerateColumns = false;
                gvPole.AutoGenerateColumns          = false;

                gvSagAndTension.DataSource = dtSagTension;
                gvConductorDay.DataSource  = dtConductorDay;
                dtPole            = calcOptimalSagTension.WindOnPole();
                gvPole.DataSource = dtPole;
                //calcOptimalSagTension.IsSagOk();


                DataRow dr1 = dtRow.NewRow();
                dr1["ProjectName"] = "";
                dr1["NumSection"]  = cboSelectSection.Text;
                dr1["FirstPole"]   = "";
                dr1["LastPole"]    = "";
                dr1["UTS"]         = txtVTS.Text;
                dr1["SE"]          = se.ToString();
                dr1["SpanCount"]   = SpanCount;
                dr1["SpanLenght"]  = "";
                dr1["CondName"]    = gvSagAndTension.Rows[0].Cells[0].Value;
                dtRow.Rows.Add(dr1);
            }
        }
Esempio n. 4
0
        private void Calculation()
        {
            chkSelectSection.Focus();

            if (Validation())
            {
                this.Cursor = Cursors.WaitCursor;
                System.Data.DataTable dtGlobal = Atend.Base.Design.DGlobal.AccessSelectAll();
                System.Data.DataTable dtBranch = Atend.Global.Acad.UAcad.FillBranchList();
                Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
                for (int gCounter = 0; gCounter < gvSection.Rows.Count; gCounter++)
                {
                    DataGridViewCheckBoxCell chk = (DataGridViewCheckBoxCell)gvSection.Rows[gCounter].Cells[1];
                    if (chk.Value.ToString() == "True")
                    {
                        calcOptimalSagTension = new Atend.Global.Calculation.Mechanical.CalcOptimalSagTension();
                        calcOptimalSagTension.DtPoleSection = Atend.Base.Design.DPoleSection.AccessSelectBySectionCodeProductType(new Guid(gvSection.Rows[gCounter].Cells[0].Value.ToString()), Convert.ToInt32(Atend.Control.Enum.ProductType.Pole));

                        System.Data.DataTable dtPole1 = Atend.Base.Design.DPoleSection.AccessSelectBySectionCodeProductType(new Guid(gvSection.Rows[gCounter].Cells[0].Value.ToString()), Convert.ToInt32(Atend.Control.Enum.ProductType.PoleTip));
                        foreach (DataRow dr in dtPole1.Rows)
                        {
                            DataRow drPole = calcOptimalSagTension.DtPoleSection.NewRow();
                            drPole["ProductType"] = dr["ProductType"].ToString();
                            drPole["ProductCode"] = dr["ProductCode"].ToString();
                            drPole["SectionCode"] = dr["SectionCode"].ToString();
                            calcOptimalSagTension.DtPoleSection.Rows.Add(drPole);
                        }


                        System.Data.DataColumn dc = new System.Data.DataColumn("PoleNumber");
                        calcOptimalSagTension.DtPoleSection.Columns.Add(dc);
                        foreach (DataRow dr in calcOptimalSagTension.DtPoleSection.Rows)
                        {
                            Atend.Base.Design.DPackage node = Atend.Base.Design.DPackage.AccessSelectByNodeCode(new Guid(dr["ProductCode"].ToString()));
                            dr["PoleNumber"] = node.Number.ToString();
                        }
                        ReadVoltage(gCounter);
                        calcOptimalSagTension.Volt = Volt;

                        calcOptimalSagTension.DtPoleCond   = dtGlobal;
                        calcOptimalSagTension.dtBranchList = dtBranch;

                        DataGridViewComboBoxCell cboNetCross = (DataGridViewComboBoxCell)gvSection.Rows[gCounter].Cells[4];
                        //ed.WriteMessage("NetCrossCode={0}\n", cboNetCross.Value.ToString());
                        NetCross = Atend.Base.Calculating.CNetWorkCross.AccessSelectByCode(Convert.ToInt32(cboNetCross.Value.ToString()));

                        if (Volt == 400)
                        {
                            calcOptimalSagTension.Clearance = NetCross.V380;
                        }
                        if (Volt == 11000)
                        {
                            calcOptimalSagTension.Clearance = NetCross.KV11;
                        }
                        if (Volt == 20000)
                        {
                            calcOptimalSagTension.Clearance = NetCross.KV20;
                        }
                        if (Volt == 33000)
                        {
                            calcOptimalSagTension.Clearance = NetCross.KV32;
                        }

                        calcOptimalSagTension.DtconductorSection = Atend.Base.Design.DPoleSection.AccessSelectBySectionCodeProductType(new Guid(gvSection.Rows[gCounter].Cells[0].Value.ToString()), Convert.ToInt32(Atend.Control.Enum.ProductType.Conductor));
                        if (calcOptimalSagTension.DtconductorSection.Rows.Count == 0)
                        {
                            calcOptimalSagTension.DtconductorSection = Atend.Base.Design.DPoleSection.AccessSelectBySectionCodeProductType(new Guid(gvSection.Rows[gCounter].Cells[0].Value.ToString()), Convert.ToInt32(Atend.Control.Enum.ProductType.SelfKeeper));
                            //ed.WriteMessage("Count={0}\n", calcOptimalSagTension.DtconductorSection.Rows.Count);
                        }

                        calcOptimalSagTension.VTS = Convert.ToDouble(gvSection.Rows[gCounter].Cells["UTS"].Value.ToString());
                        //System.Data.DataColumn dc1 = new System.Data.DataColumn("Angle");
                        //calcOptimalSagTension.DtconductorSection.Columns.Add(dc1);
                        calcOptimalSagTension.SectionCode = new Guid(gvSection.Rows[gCounter].Cells[0].Value.ToString());
                        //calcOptimalSagTension.Start = Convert.ToInt32(txtStart.Text);
                        //calcOptimalSagTension.End = Convert.ToInt32(txtEnd.Text);
                        //calcOptimalSagTension.Distance = Convert.ToInt32(txtDistance.Text);
                        Atend.Base.Design.DBranch MyBranch = Atend.Base.Design.DBranch.AccessSelectByCode(new Guid(calcOptimalSagTension.DtconductorSection.Rows[0]["ProductCode"].ToString()));
                        //ed.WriteMessage("OOO\n");
                        dtResult.Rows.Clear();

                        //se = calcOptimalSagTension.ComputeSE();
                        //ed.WriteMessage("&&&&&&&&&&&&&&&&&&&SE={0}\n", se.ToString());
                        //SpanCount = calcOptimalSagTension.DtconductorSection.Rows.Count;
                        calcOptimalSagTension.dtStTable.Rows.Clear();

                        ed.WriteMessage("GOTOSurface\n");
                        dtResult = calcOptimalSagTension.calcRudSurface02().Copy();
                        gvResult.AutoGenerateColumns = false;
                        calcOptimalSagTension.CloseConnection();
                        gvResult.DataSource = dtResult;
                        Save(gCounter);
                    }
                }
                this.Cursor = Cursors.Default;
                //DataRow dr1 = dtRow.NewRow();
                //dr1["ProjectName"] = "";
                //dr1["NumSection"] = gvSection.SelectedRows[0].Cells[1].Value.ToString();
                //dr1["FirstPole"] = "";
                //dr1["LastPole"] = "";
                //dr1["UTS"] = calcOptimalSagTension.VTS;
                //dr1["SE"] = se.ToString();
                //dr1["SpanCount"] = SpanCount;
                //dr1["SpanLenght"] = "";
                //dr1["CondName"] = gvSagAndTension.Rows[0].Cells[0].Value;
                //dtRow.Rows.Add(dr1);
                //ChangeColor();
            }
        }
        /// <summary>
        /// محاسبه تعداد اسپن و طول هر اسپن
        /// spanCount will return from method
        /// </summary>
        /// <param name="SelectedPathLength"></param>
        /// <param name="SpanLength"></param>
        /// <param name="MaxSpanLength"></param>
        private int SpanCalculation(double RealSectionLength, out double SpanLength)
        {
            Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;

            SpanLength = -1;
            //ed.WriteMessage("--^^--ChangePercent:{0}\n", ChangePercent);
            double _MaxSpanLength = Math.Abs(Se + (Se / 100 * ChangePercent));
            double _MinSpanLength = Math.Abs(Se - (Se / 100 * ChangePercent));

            ed.WriteMessage("--^^--_MaxSpanLength:{0}\n", _MaxSpanLength);
            ed.WriteMessage("--^^--_MinSpanLength:{0}\n", _MinSpanLength);
            double SpanL           = _MaxSpanLength;
            bool   SpanLengthFound = false;

            while ((SpanL >= _MinSpanLength && SpanL <= _MaxSpanLength) && !SpanLengthFound)
            {
                //call mechanical calculation for suitable SpanLength
                //assign SpanLength here
                double _Clereance = 0;
                int    _Voltage   = 0;

                if (SelectedBranch.ProductType == (int)Atend.Control.Enum.ProductType.Conductor)
                {
                    _Voltage = SelectedConsol.VoltageLevel;
                }
                else if (SelectedBranch.ProductType == (int)Atend.Control.Enum.ProductType.SelfKeeper)
                {
                    _Voltage = SelectedClamp.VoltageLevel;
                }

                Atend.Base.Calculating.CNetWorkCross _CNetWorkCross = Atend.Base.Calculating.CNetWorkCross.AccessSelectByCode(NetCrossCode);
                if (_Voltage == 400)
                {
                    _Clereance = _CNetWorkCross.V380;
                }
                if (_Voltage == 11000)
                {
                    _Clereance = _CNetWorkCross.KV11;
                }
                if (_Voltage == 20000)
                {
                    _Clereance = _CNetWorkCross.KV20;
                }
                if (_Voltage == 33000)
                {
                    _Clereance = _CNetWorkCross.KV32;
                }


                //ed.WriteMessage("--^^--_Voltage:{0}\n", _Voltage);
                //ed.WriteMessage("--^^--SpanL:{0}\n", SpanL);
                //ed.WriteMessage("--^^--_Clereance:{0}\n", _Clereance);
                //ed.WriteMessage("--^^--Relibility:{0}\n", Relibility);
                //ed.WriteMessage("--^^--UTS:{0}\n", UTS);
                Atend.Global.Calculation.Mechanical.CalcOptimalSagTension _CalcOptimalSagTension = new CalcOptimalSagTension();
                if (_CalcOptimalSagTension.CalSagTension02(SelectedBranch, SpanL, SelectedConsol, SelectedClamp, SelectedPole, _Clereance, Relibility, UTS))
                {
                    SpanLength      = SpanL;
                    SpanLengthFound = true;
                    //ed.WriteMessage("--------------\n");
                }
                _CalcOptimalSagTension.CloseConnection();
                SpanL = SpanL - 1;
            }
            int SpanCount = Convert.ToInt32(Math.Ceiling(RealSectionLength / SpanLength));

            //ed.WriteMessage("--^^-- BEFORE SpanLength:{0}\n", SpanLength);
            //SpanLength = RealSectionLength / SpanCount;
            ed.WriteMessage("--^^--SpanLength:{0}\n", SpanLength);
            ed.WriteMessage("--^^--SpanCount:{0}\n", SpanCount);
            return(SpanCount);
        }