コード例 #1
0
ファイル: linedaixuan.cs プロジェクト: github188/myitoppsp
        public int CompareTo(object obj)
        {
            int res = 0;

            try
            {
                linedaixuan sObj = (linedaixuan)obj;
                if (this.linetouzilv > sObj.linetouzilv)
                {
                    res = 1;
                }
                else if (this.linetouzilv < sObj.linetouzilv)
                {
                    res = -1;
                }
            }
            catch (Exception ex)
            {
                throw new Exception("±È½ÏÒì³£", ex.InnerException);
            }
            return(res);
        }
コード例 #2
0
ファイル: frmTLWangjia.cs プロジェクト: EdgarEDT/myitoppsp
        private void addrightcheck()
        {
            FileStream dh;
            StreamReader readLine;
            char[] charSplit;
            string strLine;
            string[] array1;
            string output = null;
            string[] array2;

            string strLine2;

            char[] charSplit2 = new char[] { ' ' };
            FileStream op;
            StreamWriter str1;
            FileStream dh2;
            StreamReader readLine2;
            //List<PSPDEV> linedengdai = new List<PSPDEV>();          //记录所有待选的线路(一次运行以后就会发生变化)
            if (!Check())
            {
                return;
            }
            PSPDEV pspdev = new PSPDEV();
            pspdev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
            pspdev.LineStatus = "运行";
            pspdev.Type = "Polyline";
            IList list1 = Services.BaseService.GetList("SelectPSPDEVBySvgUIDAndLineStatus", pspdev);
            double yinzi = 0, capability = 0, volt = 0, current = 0, standvolt = 0, Rad_to_Deg = 57.29577951;
            PSPDEV benchmark = new PSPDEV();
            benchmark.Type = "power";
            benchmark.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
            IList list3 = Services.BaseService.GetList("SelectPSPDEVBySvgUIDAndType", benchmark);
            if (list3 == null)
            {
                MessageBox.Show("请设置基准后再进行计算!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            foreach (PSPDEV dev in list3)
            {
                yinzi = Convert.ToDouble(dev.PowerFactor);
                capability = Convert.ToDouble(dev.StandardCurrent);
                volt = Convert.ToDouble(dev.StandardVolt);
                if (dev.PowerFactor == 0)
                {
                    yinzi = 1;
                }
                if (dev.StandardCurrent == 0)
                {
                    capability = 1;
                }
                if (dev.StandardVolt == 0)
                {
                    volt = 1;
                }
                standvolt = volt;
                current = capability / (Math.Sqrt(3) * volt);

            }
            capability = 100;
            ercilinedengdai.Clear();//清空之前的记录

            for (int i = 0; i < list1.Count; i++)
            {
                N1Test.NBcal kk = new N1Test.NBcal();
                kk.Show_ZLKMPSP(((PSPDEV)list1[i]).Number);
                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\ZL.txt"))
                {
                }
                else
                {
                    return;
                }
                dh2 = new FileStream(System.Windows.Forms.Application.StartupPath + "\\ZL.txt", FileMode.Open);

                readLine2 = new StreamReader(dh2);
                charSplit2 = new char[] { ' ' };
                strLine2 = readLine2.ReadLine();
                output = null;
                bool lineflag = true;
                bool jielieflag = true;
                while (!string.IsNullOrEmpty(strLine2))
                {
                    array2 = strLine2.Split(charSplit2);

                    string[] dev = new string[2 * brchcount + 1];
                    dev.Initialize();

                    PSPDEV CR = new PSPDEV();
                    CR.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                    int m = 0;
                    foreach (string str in array2)
                    {

                        if (str != "")
                        {

                            dev[m++] = str.ToString();

                        }
                    }
                    //进行解裂和负荷判断

                    if (dev[1] != "-1")
                    {
                        for (int j = 0; j < brchcount; j++)
                        {

                            double pij = System.Math.Abs(Convert.ToDouble(dev[j * 2 + 2])) * capability;

                            PSPDEV psp = new PSPDEV();

                            psp.Name = dev[j * 2 + 1];
                            psp.Type = "Polyline";
                            psp.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            IList listName = Services.BaseService.GetList("SelectPSPDEVByName", psp);
                            PSPDEV pspline = (PSPDEV)listName[0];
                            if (pspline != null && !pspline.Name.Contains("虚拟线路"))
                            {
                                double voltR = pspline.VoltR;
                                WireCategory wirewire = new WireCategory();
                                wirewire.WireType = pspline.LineType;
                                if (pspline.LineType == null || pspline.LineType == "")
                                {
                                    MessageBox.Show(pspline.Name + "的线路类型没有输入,无法进行可靠性检验", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                    return;
                                }
                                WireCategory listware = (WireCategory)Services.BaseService.GetObject("SelectWireCategoryByKey", wirewire);
                                double Ichange = (double)listware.WireChange;
                                double linXij = System.Math.Sqrt(3) * voltR * Ichange / 1000;
                                if (pij >= linXij)
                                {
                                    lineflag = false;
                                    //lineclass _line = new lineclass(n, j);
                                    //Overlinp.Add(_line);
                                    // OverPhege[n] = j;
                                }
                            }

                        }

                    }

                    else
                    {
                        jielieflag = false;
                    }

                    strLine2 = readLine2.ReadLine();
                }
                readLine2.Close();
                if (!lineflag)
                {
                    PSPDEV psperci = new PSPDEV();
                    psperci = (PSPDEV)list1[i];
                    psperci.LineStatus = "等待";
                    Services.BaseService.Update<PSPDEV>(psperci);
                    ercilinedengdai.Add(psperci);
                    break;
                }
                else                  //没有出现过负荷
                    continue;
            }
            //新添加的 如果记录二次等待的线路没有则停止下面的运行 表示断开任意一条也没有出现过负荷
            if (ercilinedengdai.Count == 0)
            {
                return;
            }
            //此过程是添加一条线路使其不出现过负荷

            fuhecheck();
            for (int j = 0; j < linedengdai.Count; j++)
            {
                if (!Checkadd(linedengdai[j].EleID))
                    return;
                N1Test.NBcal zl = new NBcal();
                //zl.Show_KmRelia(1);
                zl.ZLpsp();

                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\DH1.txt"))
                {
                }
                else
                {
                    return;
                }
                dh = new FileStream(System.Windows.Forms.Application.StartupPath + "\\DH1.txt", FileMode.Open);

                readLine = new StreamReader(dh);
                charSplit = new char[] { ' ' };
                strLine = readLine.ReadLine();
                output = null;
                double sumpij = 0.0;
                bool lineflag = true;
                while (!string.IsNullOrEmpty(strLine))
                {
                    array1 = strLine.Split(charSplit);

                    string[] dev = new string[2];
                    dev.Initialize();
                    int i = 0;
                    PSPDEV CR = new PSPDEV();
                    CR.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;

                    foreach (string str in array1)
                    {
                        if (str != "")
                        {
                            if (i == 0)
                            {
                                dev[i++] = str.ToString();
                            }
                            else
                            {
                                if (str != "NaN")
                                {
                                    dev[i++] = Convert.ToDouble(str).ToString();
                                }
                                else
                                {
                                    dev[i++] = str;
                                }

                            }
                        }

                    }

                    CR.Name = dev[0];
                    CR.Type = "Polyline";
                    CR = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByName", CR);
                    if (CR != null && CR.ReferenceVolt != 0)
                    {
                        volt = CR.ReferenceVolt;
                    }
                    else
                        volt = standvolt;
                    current = capability / (Math.Sqrt(3) * volt);
                    if (CR != null && !CR.Name.Contains("虚拟线路"))
                    {

                        double linepij = Convert.ToDouble(dev[1]) * capability;
                        double voltR = CR.VoltR;
                        WireCategory wirewire = new WireCategory();
                        wirewire.WireType = CR.LineType;
                        if (string.IsNullOrEmpty(CR.LineType))
                        {
                            MessageBox.Show(CR.Name + "的线路类型没有输入,无法进行可靠性检验", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }
                        WireCategory listware = (WireCategory)Services.BaseService.GetObject("SelectWireCategoryByKey", wirewire);
                        double Ichange = (double)listware.WireChange;
                        double linXij = System.Math.Sqrt(3) * voltR * Ichange / 1000;
                        if (linepij >= linXij)
                        {
                            lineflag = false;

                            //sumpij += linepij;
                        }
                        for (int k = 0; k < fuheline.Count; k++)
                        {
                            if (CR.SUID == fuheline[k].Suid)
                            {
                                sumpij += System.Math.Abs(fuheline[k].linepij - linepij);
                            }
                        }
                        //
                        //    //output += "'" + CR.Name.ToString() + "," + (Convert.ToDouble(dev[3]) * capability).ToString() + "," + (Convert.ToDouble(dev[4]) * capability).ToString() + "," + (Convert.ToDouble(dev[5]) * capability).ToString() + "," + (Convert.ToDouble(dev[6]) * capability).ToString() + "," + (Convert.ToDouble(dev[7]) * current).ToString() + "," + (Convert.ToDouble(dev[8]) * Rad_to_Deg).ToString() + "," + dev[11] + "," + "\r\n";
                    }

                    strLine = readLine.ReadLine();
                }
                readLine.Close();
                //if (lineflag)              //如果没有出现过负荷现象 就停止进行加线
                //{
                //    PSPDEV pspb = (PSPDEV)linedengdai[j];
                //    pspb.LineStatus = "运行";
                //    Services.BaseService.Update<PSPDEV>(pspb);
                //    lineyiyou.Add(pspb);
                //    for (int i = 0; i < linedengdai.Count; i++)
                //    {
                //        if (linedengdai[i].SUID == pspb.SUID)
                //        {
                //            linedengdai.RemoveAt(j);
                //        }
                //    }
                //    return;
                //}
                //else
                //{
                    XmlNode el = tlVectorControl1.SVGDocument.SelectSingleNode("svg/polyline[@layer='" + tlVectorControl1.SVGDocument.CurrentLayer.ID + "' and @id='" + linedengdai[j].EleID + "']");
                    double linevalue = 0;
                    if (!string.IsNullOrEmpty(((XmlElement)el).GetAttribute("linevalue")))
                    {
                        linevalue = Convert.ToDouble(((XmlElement)el).GetAttribute("linevalue"));
                    }
                    else
                        linevalue = 1;
                    linedaixuan linedai = new linedaixuan(linedengdai[j].Number, linedengdai[j].SUID, linedengdai[j].Name);
                    linedai.linepij = sumpij;
                    linedai.linevalue = linevalue;
                    linedai.linetouzilv = sumpij / linevalue;

                    waitlineindex.Add(linedai);
                //}

            }
            waitlineindex.Sort();
            //在此处获得指标最大的线路 将其线路的状态变为 运行并且在运行的集合里面记录 在等待的集合里将其线路去掉 重新进行下一轮的操作
            PSPDEV pspbianhua = new PSPDEV();
            if (waitlineindex.Count > 0)
            {
                pspbianhua.SUID = waitlineindex[waitlineindex.Count - 1].Suid;
            }
            else
            {
                //MessageBox.Show("没有出现过负荷的线路集,请查看一下线路参数是否设定正确!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            pspbianhua = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByKey", pspbianhua);
            pspbianhua.LineStatus = "运行";
            Services.BaseService.Update<PSPDEV>(pspbianhua);
            lineyiyou.Add(pspbianhua);
            for (int i = 0; i < linedengdai.Count; i++)
            {
                if (linedengdai[i].SUID == pspbianhua.SUID)
                {
                    linedengdai.RemoveAt(i);
                }
            }
            waitlineindex.Clear();
        }
コード例 #3
0
ファイル: frmTLWangjia.cs プロジェクト: EdgarEDT/myitoppsp
        private void Topology()
        {
            brchcount = 0; buscount = 0; transcount = 0;
            //XPathNavigator nav = tlVectorControl1.SVGDocument.CreateNavigator();
            //XPathExpression exp = nav.Compile("svg/use");
            //exp.AddSort("x", XmlSortOrder.Ascending, XmlCaseOrder.None, "", XmlDataType.Number);
            XmlNodeList nodeList1 = tlVectorControl1.SVGDocument.SelectNodes("svg/use [@layer='" + tlVectorControl1.SVGDocument.CurrentLayer.ID + "']");
            //XPathNodeIterator nodeList1 = nav.Select(exp);
            PSPDEV pspDev = new PSPDEV();
            foreach (XmlNode node in nodeList1)
            {
                XmlElement element = node as XmlElement;
                RectangleF t = ((IGraph)element).GetBounds();
                XmlNode temp = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + element.GetAttribute("id") + "']");
                //if (temp == null)
                //    return;
                if (element.GetAttribute("xlink:href").Contains("Power") || element.GetAttribute("xlink:href").Contains("motherlinenode"))
                {
                    pspDev.EleID = element.GetAttribute("id");
                    if (temp != null)
                        pspDev.Name = temp.InnerText;
                    pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                    pspDev.X1 = t.X;
                    pspDev.Y1 = t.Y;
                    pspDev.X2 = t.X + t.Width;
                    pspDev.Y2 = t.Y + t.Height;
                    pspDev.FirstNode = -1;
                    pspDev.LastNode = -1;
                    pspDev.Number = -1;
                    Services.BaseService.Update("UpdatePSPDEVByEleID", pspDev);
                }
                else if (element.GetAttribute("xlink:href").Contains("Substation"))
                {
                    pspDev.EleID = element.GetAttribute("id");
                    if (temp != null)
                        pspDev.Name = temp.InnerText;
                    pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                    pspDev.X1 = t.X + t.Width / 2;
                    pspDev.Y1 = t.Y + t.Height / 2;
                    pspDev.X2 = 0;
                    pspDev.Y2 = 0;
                    pspDev.FirstNode = -1;
                    pspDev.LastNode = -1;
                    pspDev.Number = -1;
                    Services.BaseService.Update("UpdatePSPDEVByEleID", pspDev);
                }
                else if (element.GetAttribute("xlink:href").Contains("dynamotorline") || element.GetAttribute("xlink:href").Contains("gndline"))
                {
                    Transf transfElement = (element as Use).Transform;
                    RectangleF tt = (element as Use).GetRectangle();
                    float x = tt.X;
                    float y = tt.Y + tt.Height / 2;
                    PointF[] startPoint = new PointF[] { new PointF(x, y) };
                    transfElement.Matrix.TransformPoints(startPoint);
                    pspDev.EleID = element.GetAttribute("id");
                    pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;

                    pspDev.X1 = startPoint[0].X;
                    pspDev.Y1 = startPoint[0].Y;
                    pspDev.X2 = t.X + t.Width;
                    pspDev.Y2 = t.Y + t.Height;
                    pspDev.FirstNode = -1;
                    pspDev.LastNode = 0;
                    pspDev.Number = -1;
                    Services.BaseService.Update("UpdatePSPDEVByEleID", pspDev);
                }
            }
            XmlNodeList nodeList2 = tlVectorControl1.SVGDocument.SelectNodes("svg/polyline [@layer='" + tlVectorControl1.SVGDocument.CurrentLayer.ID + "']");
            foreach (XmlNode node in nodeList2)
            {
                XmlElement element = node as XmlElement;
                if ((element.GetAttribute("flag") == "1") || (!element.HasAttributes) || element.GetAttribute("id") == "")
                {
                    break;
                }
                PointF[] t = ((Polyline)element).Pt;
                //XmlNode temp = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + element.GetAttribute("id") + "']");
                pspDev.EleID = element.GetAttribute("id");
                //pspDev.Name = temp.InnerText;
                pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                pspDev.X1 = t[0].X;
                pspDev.Y1 = t[0].Y;
                pspDev.X2 = t[1].X;
                pspDev.Y2 = t[1].Y;
                pspDev.FirstNode = -1;
                pspDev.LastNode = -1;
                pspDev.Number = -1;
                //PSPDEV psp = new PSPDEV();
                //psp.EleID = element.GetAttribute("id");
                //psp.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                //psp = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", psp);
                //if (psp == null)
                //{
                //    pspDev.Number = -1;
                //    pspDev.Name = null;
                //    pspDev.Type = "Polyline";
                //    pspDev.FirstNode = -1;
                //    pspDev.LastNode = -1;
                //    pspDev.SUID = Guid.NewGuid().ToString();
                //    Services.BaseService.Create<PSPDEV>(pspDev);

                //}
                //else
                //{
                Services.BaseService.Update("UpdatePSPDEVByEleID", pspDev);
                //}

            }
            pspDev.Type = "Use";
            pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
            IList list1 = Services.BaseService.GetList("SelectPSPDEVBySvgUIDAndType", pspDev);
            for (int i = 1; i <= list1.Count; i++)
            {
                pspDev = (PSPDEV)list1[i - 1];
                pspDev.Number = i;
                Services.BaseService.Update<PSPDEV>(pspDev);
                buscount += 1;                            //记录母线数

            }
            waitlinecoll.Clear();               //清空原来的线路

            pspDev.Type = "Polyline";
            pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
            IList list2 = Services.BaseService.GetList("SelectPSPDEVBySvgUIDAndType", pspDev);
            int j = 0;
            for (int i = 1; i <= list2.Count; i++)
            {
                pspDev = (PSPDEV)list2[i - 1];
                if (pspDev.LineStatus == "断开" || pspDev.LineStatus == "等待")
                {
                    j += 1;
                    pspDev.Number = -1;
                    Services.BaseService.Update<PSPDEV>(pspDev);
                    continue;

                }
                pspDev.Number = (i - j);
                brchcount += 1;
                if (pspDev.LineStatus == "待选")
                {
                    linedaixuan ll = new linedaixuan(brchcount, pspDev.SUID, pspDev.Name);
                    waitlinecoll.Add(ll);
                }
                Services.BaseService.Update<PSPDEV>(pspDev);
            }
            pspDev.Type = "TransformLine";
            pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
            IList list3 = Services.BaseService.GetList("SelectPSPDEVBySvgUIDAndType", pspDev);
            for (int i = 1; i <= list3.Count; i++)
            {
                pspDev = (PSPDEV)list3[i - 1];
                pspDev.Number = list2.Count - j + i;
                transcount += 1;
                //取首末节点

                PSPDEV dev = new PSPDEV();
                dev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                dev.Name = pspDev.HuganLine1;
                dev.Type = "Use";
                dev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByName", dev);
                if (dev != null)
                {
                    pspDev.FirstNode = dev.Number;
                }
                else
                {
                    pspDev.FirstNode = -1;
                    dev = new PSPDEV();
                }
                dev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                dev.Name = pspDev.HuganLine2;
                dev.Type = "Use";
                dev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByName", dev);
                if (dev != null)
                {
                    pspDev.LastNode = dev.Number;
                }
                else
                {
                    pspDev.LastNode = -1;
                }
                Services.BaseService.Update<PSPDEV>(pspDev);
            }

            pspDev.Type = "GNDLine";
            pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
            IList list13 = Services.BaseService.GetList("SelectPSPDEVBySvgUIDAndType", pspDev);
            for (int i = 1; i <= list13.Count; i++)
            {
                pspDev = (PSPDEV)list13[i - 1];
                pspDev.Number = list2.Count + list3.Count - j + i;
                transcount += 1;
                //取首末节点

                PSPDEV dev = new PSPDEV();
                dev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                dev.Name = pspDev.HuganLine1;
                dev.Type = "Use";
                dev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByName", dev);
                if (dev != null)
                {
                    pspDev.FirstNode = dev.Number;
                }
                else
                {
                    pspDev.FirstNode = -1;
                    dev = new PSPDEV();
                }
                dev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                dev.Name = pspDev.HuganLine2;
                dev.Type = "Use";
                dev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByName", dev);
                if (dev != null)
                {
                    pspDev.LastNode = dev.Number;
                }
                else
                {
                    pspDev.LastNode = -1;
                }
                Services.BaseService.Update<PSPDEV>(pspDev);
            }

            pspDev.Type = "Use";
            pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
            list1 = Services.BaseService.GetList("SelectPSPDEVBySvgUIDAndType", pspDev);
            pspDev.Type = "Polyline";
            pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; ;
            list2 = Services.BaseService.GetList("SelectPSPDEVBySvgUIDAndType", pspDev);
            foreach (PSPDEV dev in list1)
            {
                double devx = Convert.ToDouble(dev.X1);
                double devy = Convert.ToDouble(dev.Y1);
                XmlElement temp = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@id='" + dev.EleID + "']") as XmlElement;
                if (temp == null)
                    continue;

                if (temp.GetAttribute("xlink:href").Contains("Substation"))
                {
                    RectangleF t = ((IGraph)temp).GetBounds();
                    foreach (PSPDEV psp in list2)
                    {
                        double x1 = psp.X1;
                        double x2 = psp.X2;
                        double y1 = psp.Y1;
                        double y2 = psp.Y2;
                        if (Math.Abs(devx - x1) <= ((t.Height) / 2) && Math.Abs(devy - y1) <= ((t.Height) / 2))
                        {
                            psp.FirstNode = dev.Number;
                            Services.BaseService.Update<PSPDEV>(psp);
                        }
                        if (Math.Abs(devx - x2) <= ((t.Height) / 2) && Math.Abs(devy - y2) <= ((t.Height) / 2))
                        {
                            psp.LastNode = dev.Number;
                            Services.BaseService.Update<PSPDEV>(psp);
                        }
                    }
                }
                else if (temp.GetAttribute("xlink:href").Contains("Power") || temp.GetAttribute("xlink:href").Contains("motherlinenode"))
                {
                    RectangleF t = ((IGraph)temp).GetBounds();
                    foreach (PSPDEV psp in list2)
                    {
                        double x1 = psp.X1;
                        double x2 = psp.X2;
                        double y1 = psp.Y1;
                        double y2 = psp.Y2;
                        if ((x1 - devx) <= t.Width && (y1 - devy) <= t.Height && x1 >= devx && y1 >= devy)
                        {
                            psp.FirstNode = dev.Number;
                            Services.BaseService.Update<PSPDEV>(psp);
                        }
                        if ((x2 - devx) <= t.Width && (y2 - devy) <= t.Height && x2 >= devx && y2 >= devy)
                        {
                            psp.LastNode = dev.Number;
                            Services.BaseService.Update<PSPDEV>(psp);
                        }
                    }
                }
            }
        }
コード例 #4
0
ファイル: frmTLWangjia.cs プロジェクト: EdgarEDT/myitoppsp
        //记录负荷的线路
        private bool fuhecheck()
        {
            FileStream dh;
            StreamReader readLine;
            char[] charSplit;
            string strLine;
            string[] array1;
            string output = null;
            string[] array2;

            string strLine2;

            char[] charSplit2 = new char[] { ' ' };
            FileStream op;
            StreamWriter str1;
            FileStream dh2;
            StreamReader readLine2;
            fuheline.Clear();            //清空上一次的记录  为下一个时期的应用做准备

            // linedengdai.Clear();          //清空上一次记录待选线路 为下一个时期的应用做准备

            if (!Checkfuhe())
                return true;
            N1Test.NBcal zl = new NBcal();
            //zl.Show_KmRelia(1);
            zl.ZLpsp();

            double yinzi = 0, capability = 0, volt = 0, current = 0, standvolt = 0, Rad_to_Deg = 57.29577951;
            PSPDEV benchmark = new PSPDEV();
            benchmark.Type = "power";
            benchmark.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
            IList list3 = Services.BaseService.GetList("SelectPSPDEVBySvgUIDAndType", benchmark);
            if (list3 == null)
            {
                MessageBox.Show("请设置基准后再进行计算!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return true;
            }
            foreach (PSPDEV dev in list3)
            {
                yinzi = Convert.ToDouble(dev.PowerFactor);
                capability = Convert.ToDouble(dev.StandardCurrent);
                volt = Convert.ToDouble(dev.StandardVolt);
                if (dev.PowerFactor == 0)
                {
                    yinzi = 1;
                }
                if (dev.StandardCurrent == 0)
                {
                    capability = 1;
                }
                if (dev.StandardVolt == 0)
                {
                    volt = 1;
                }
                standvolt = volt;
                current = capability / (Math.Sqrt(3) * volt);

            }
            capability = 100;
            if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\DH1.txt"))
            {
            }
            else
            {
                return true;
            }
            dh = new FileStream(System.Windows.Forms.Application.StartupPath + "\\DH1.txt", FileMode.Open);

            readLine = new StreamReader(dh);
            charSplit = new char[] { ' ' };
            strLine = readLine.ReadLine();
            output = null;
            //double sumpij = 0.0;
            bool lineflag = true;
            while (!string.IsNullOrEmpty(strLine))
            {
                array1 = strLine.Split(charSplit);

                string[] dev = new string[2];
                dev.Initialize();
                int i = 0;
                PSPDEV CR = new PSPDEV();
                CR.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;

                foreach (string str in array1)
                {
                    if (str != "")
                    {
                        if (i == 0)
                        {
                            dev[i++] = str.ToString();
                        }
                        else
                        {
                            if (str != "NaN")
                            {
                                dev[i++] = Convert.ToDouble(str).ToString();
                            }
                            else
                            {
                                dev[i++] = str;
                            }

                        }
                    }

                }

                CR.Name = dev[0];
                CR.Type = "Polyline";
                CR = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByName", CR);
                if (CR != null && CR.ReferenceVolt != 0)
                {
                    volt = CR.ReferenceVolt;
                }
                else
                    volt = standvolt;
                current = capability / (Math.Sqrt(3) * volt);
                if (CR != null && !CR.Name.Contains("虚拟线路"))
                {

                    double linepij = System.Math.Abs(Convert.ToDouble(dev[1])) * capability;
                    double voltR = CR.VoltR;
                    WireCategory wirewire = new WireCategory();
                    wirewire.WireType = CR.LineType;
                    if (string.IsNullOrEmpty(CR.LineType))
                    {
                        MessageBox.Show(CR.Name + "的线路类型没有输入,无法进行可靠性检验", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return true;
                    }
                    WireCategory listware = (WireCategory)Services.BaseService.GetObject("SelectWireCategoryByKey", wirewire);
                    double Ichange = (double)listware.WireChange;
                    double linXij = System.Math.Sqrt(3) * voltR * Ichange / 1000;
                    if (linepij >= linXij)
                    {
                        lineflag = false;
                        linedaixuan ld = new linedaixuan(CR.Number, CR.SUID, CR.Name);
                        ld.linepij = linepij;
                        fuheline.Add(ld);

                    }

                    //
                    //    //output += "'" + CR.Name.ToString() + "," + (Convert.ToDouble(dev[3]) * capability).ToString() + "," + (Convert.ToDouble(dev[4]) * capability).ToString() + "," + (Convert.ToDouble(dev[5]) * capability).ToString() + "," + (Convert.ToDouble(dev[6]) * capability).ToString() + "," + (Convert.ToDouble(dev[7]) * current).ToString() + "," + (Convert.ToDouble(dev[8]) * Rad_to_Deg).ToString() + "," + dev[11] + "," + "\r\n";
                }
                strLine = readLine.ReadLine();
            }
            readLine.Close();
            return lineflag;
        }
コード例 #5
0
ファイル: ElectricWjgh.cs プロジェクト: EdgarEDT/myitoppsp
        public bool Check(string GprogUID, int Type, double ratedCapacity)
        {
            try
            {
                //ɾ��������·
                string con = "WHERE SvgUID='" + GprogUID + "'AND ProjectID='" + Itop.Client.MIS.ProgUID + "'AND Type='05' AND KName ='������·'";
                IList list0 = Services.BaseService.GetList("SelectPSPDEVByCondition", con);
                for (int i = 0; i < list0.Count; i++)
                {
                    PSPDEV pspDev = (PSPDEV)list0[i];
                    Services.BaseService.Delete<PSPDEV>(pspDev);
                }
                string strBus = null;
                string strBranch = null;
                waitlinecoll.Clear();
                if (Type==1)
                {
                    brchcount = 0;buscount = 0; transcount = 0;
                    string strCon = "WHERE Type='01' AND SvgUID in (select DeviceSUID from PSP_GprogElevice where GprogUID='" + GprogUID + "'and Type in ('���վ','��Դ')) ";
                    string strCon2 = "WHERE Type='05' AND SUID in (select DeviceSUID from PSP_GprogElevice where GprogUID='" + GprogUID + "'and type='��·') ";
                    string strCon3 = "WHERE Projectid='" + Itop.Client.MIS.ProgUID + "'";
                double Rad_to_Deg = 180 / Math.PI;
                {

                    IList listMX = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon);
                    IList listXL = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon2);
                    strCon2 = " and Type='02' AND SUID in (select DeviceSUID from PSP_GprogElevice where GprogUID='" + GprogUID + "'and type='�������ѹ��')";
                    strCon = strCon3 + strCon2;
                    IList listBYQ2 = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon);
                    strCon2 = "and Type='03' AND SUID in (select DeviceSUID from PSP_GprogElevice where GprogUID='" + GprogUID + "'and type='�������ѹ��')";
                    strCon = strCon3 + strCon2;
                    IList listBYQ3 = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon);
                    foreach (PSPDEV dev in listXL)
                    {
                        if (dev.KSwitchStatus == "0")
                        {
                            if (dev.FirstNode ==0 || dev.LastNode ==0)
                            {
                                string temp = "���ӷ���ʧ��,";
                                temp += dev.Name;
                                temp += "û����ȷ����,����д������";
                                System.Windows.Forms.MessageBox.Show(temp, "��ʾ", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return false;
                            }
                            if (strBranch != null && (dev.LineStatus == "����" || dev.LineStatus == "��ѡ" || dev.LineStatus == "Ͷ��"))
                            {
                                strBranch += "\r\n";
                            }
                            if (dev.LineStatus == "����" || dev.LineStatus == "��ѡ" || dev.LineStatus == "Ͷ��")
                            {
                                if (dev.UnitFlag == "0")
                                {
                                    strBranch += dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + dev.Name.ToString() + " " + "1" + " " + dev.LineR.ToString() + " " + dev.LineTQ.ToString() + " " + (dev.LineGNDC * 2).ToString() + " " + "0" + " " + "0";

                                }
                                else
                                {
                                    strBranch += dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + dev.Name.ToString() + " " + "1" + " " + (dev.LineR * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.LineTQ * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.LineGNDC * 2 * dev.ReferenceVolt * dev.ReferenceVolt / (ratedCapacity * 1000000)).ToString() + " " + "0" + " " + "0";

                                }

                                brchcount++;

                            }

                            if (dev.LineStatus == "��ѡ")
                            {
                                linedaixuan ll = new linedaixuan(brchcount, dev.SUID, dev.Name);
                                waitlinecoll.Add(ll);
                            }
                        }
                    }
                    foreach (PSPDEV dev in listBYQ2)
                    {
                        bool flag = false;
                        if (dev.KSwitchStatus == "0")
                        {

                            if (dev.FirstNode != 0 && dev.LastNode != 0)
                            {
                                if (strBranch != null)
                                {
                                    strBranch += "\r\n";
                                }
                                if (dev.UnitFlag == "0")
                                {
                                    strBranch += dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + dev.Name.ToString() + " " + "2" + " " + dev.LineR.ToString() + " " + dev.LineTQ.ToString() + " " + (dev.LineGNDC * 2).ToString() + " " + dev.K.ToString() + " " + dev.G.ToString();

                                }
                                else
                                {
                                    strBranch += dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + dev.Name.ToString() + " " + "2" + " " + (dev.LineR * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.LineTQ * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.LineGNDC * 2 * dev.ReferenceVolt * dev.ReferenceVolt / (ratedCapacity * 1000000)).ToString() + " " + dev.K.ToString() + " " + dev.G.ToString();

                                }
                                transcount++;
                            }

                        }
                    }

                    foreach (PSPDEV dev in listBYQ3)
                    {
                        if (dev.KSwitchStatus == "0")
                        {
                         if (dev.FirstNode!=0&&dev.LastNode!=0&&dev.Flag!=0)
                         {

                             if (dev.UnitFlag == "0")
                             {
                                 if (strBranch != null)
                                 {
                                     strBranch += "\r\n";
                                 }
                                 strBranch += dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + dev.Name.ToString() + " " + "2" + " " + dev.HuganTQ1.ToString() + " " + dev.HuganTQ4.ToString() + " " + "0" + " " + dev.K.ToString() + " " + "0";
                                 if (strBranch != null)
                                 {
                                     strBranch += "\r\n";
                                 }
                                 strBranch += dev.LastNode.ToString() + " " + dev.Flag.ToString() + " " + dev.Name.ToString() + " " + "2" + " " + dev.HuganTQ2.ToString() + " " + dev.HuganTQ5.ToString() + " " + "0" + " " + dev.StandardCurrent.ToString() + " " + "0";
                                 if (strBranch != null)
                                 {
                                     strBranch += "\r\n";
                                 }
                                 strBranch += dev.FirstNode.ToString() + " " + dev.Flag.ToString() + " " + dev.Name.ToString() + " " + "2" + " " + dev.HuganTQ3.ToString() + " " + dev.ZeroTQ.ToString() + " " + "0" + " " + dev.BigP.ToString() + " " + "0";

                             }
                             else
                             {
                                 if (strBranch != null)
                                 {
                                     strBranch += "\r\n";
                                 }
                                 strBranch += dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + dev.Name.ToString() + " " + "2" + " " + (dev.HuganTQ1 * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.HuganTQ4 * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + "0" + " " + dev.K.ToString() + " " + "0";
                                 if (strBranch != null)
                                 {
                                     strBranch += "\r\n";
                                 }
                                 strBranch += dev.LastNode.ToString() + " " + dev.Flag.ToString() + " " + dev.Name.ToString() + " " + "2" + " " + (dev.HuganTQ2 * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.HuganTQ5 * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + "0" + " " + dev.StandardCurrent.ToString() + " " + "0";
                                 if (strBranch != null)
                                 {
                                     strBranch += "\r\n";
                                 }
                                 strBranch += dev.FirstNode.ToString() + " " + dev.Flag.ToString() + " " + dev.Name.ToString() + " " + "2" + " " + (dev.HuganTQ3 * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.ZeroTQ * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + "0" + " " + dev.BigP.ToString() + " " + "0";
                             }
                             transcount += 3;
                         }

                        }
                    }
                    //���˷����Ƿ���ڹ���ĸ��ĸ�߽ڵ�
                    List<string> busname = new List<string>();
                    foreach (PSPDEV dev in listMX)
                    {
                        bool flag = false;
                        foreach (PSPDEV devline in listXL)
                        {
                            if (dev.Number == devline.LastNode || dev.Number == devline.FirstNode)
                            {
                                flag = true;
                                break;
                            }
                        }
                        foreach (PSPDEV devtrans in listBYQ2)
                        {
                            if (dev.Number == devtrans.LastNode || dev.Number == devtrans.FirstNode)
                            {
                                flag = true;
                                break;
                            }
                        }
                        foreach (PSPDEV devtrans in listBYQ3)
                        {
                            if (dev.Number == devtrans.LastNode || dev.Number == devtrans.FirstNode || dev.Number == devtrans.Flag)
                            {
                                flag = true;
                                break;
                            }
                        }
                        if (!flag)
                        {
                            busname.Add(dev.Name);
                        }
                    }
                    if (busname.Count > 0)
                    {
                        string temp = "���˷���ʧ��";
                        for (int i = 0; i < busname.Count; i++)
                        {
                            temp += "��" + busname[i];

                        }
                        temp += "Ϊ�����Ľڵ㣡";
                        System.Windows.Forms.MessageBox.Show(temp, "��ʾ", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return false;
                    }
                    foreach (PSPDEV dev in listMX)
                    {

                        if (dev.KSwitchStatus == "0")
                        {
                            if (strBus != null)
                            {
                                strBus += "\r\n";
                            }
                            double outP = 0;
                            double outQ = 0;
                            double inputP = 0;
                            double inputQ = 0;
                           strCon3 = "WHERE Projectid='" + Itop.Client.MIS.ProgUID + "'and Type = '04' AND IName = '" + dev.Name + "'and SUID in (select DeviceSUID from PSP_GprogElevice where GprogUID='" + GprogUID + "'and type='�����')";
                            IList listFDJ = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon3);
                            string strCon4 = "WHERE Projectid='" + Itop.Client.MIS.ProgUID + "' and Type = '12' AND IName = '" + dev.Name + "' and SUID in (select DeviceSUID from PSP_GprogElevice where GprogUID='" + GprogUID + "'and type='����')";
                            IList listFH = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon4);
                            foreach (PSPDEV devFDJ in listFDJ)
                            {
                                if (devFDJ.UnitFlag == "0")
                                {
                                    outP += devFDJ.OutP;
                                    outQ += devFDJ.OutQ;
                                }
                                else
                                {
                                    outP += devFDJ.OutP / ratedCapacity;
                                    outQ += devFDJ.OutQ / ratedCapacity;
                                }
                            }
                            foreach (PSPDEV devFH in listFH)
                            {
                                if (devFH.UnitFlag == "0")
                                {
                                    inputP += devFH.InPutP;
                                    inputQ += devFH.InPutQ;
                                }
                                else
                                {
                                    inputP += devFH.InPutP / ratedCapacity;
                                    inputQ += devFH.InPutQ / ratedCapacity;
                                }
                            }
                            if (dev.UnitFlag == "0")
                            {
                                outP += dev.OutP;
                                outQ += dev.OutQ;
                                inputP += dev.InPutP;
                                inputQ += dev.InPutQ;
                                strBus += (dev.Number.ToString() + " " + dev.Name.ToString() + " " + MXNodeType(dev.NodeType) + " " + (dev.VoltR / dev.ReferenceVolt).ToString() + " " + (dev.VoltV * Rad_to_Deg).ToString() + " " + ((inputP - outP)).ToString() + " " + ((inputQ - outQ)).ToString());
                                //strData += (dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + "0" + " " + (dev.LineR).ToString() + " " + (dev.LineTQ).ToString() + " " + (dev.LineGNDC).ToString() + " " + "0" + " " + dev.Name.ToString())
                            }
                            else
                            {
                                outP += dev.OutP / ratedCapacity;
                                outQ += dev.OutQ / ratedCapacity;
                                inputP += dev.InPutP / ratedCapacity;
                                inputQ += dev.InPutQ / ratedCapacity;
                                strBus += (dev.Number.ToString() + " " + dev.Name.ToString() + " " + MXNodeType(dev.NodeType) + " " + (dev.VoltR / dev.ReferenceVolt).ToString() + " " + (dev.VoltV * Rad_to_Deg).ToString() + " " + (inputP- outP).ToString() + " " + (inputQ- outQ).ToString());
                                //strData += (dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + "0" + " " + (dev.LineR * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.LineTQ * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + ((dev.LineGNDC) * dev.ReferenceVolt * dev.ReferenceVolt / (ratedCapacity * 1000000)).ToString() + " " + "0" + " " + dev.Name.ToString());
                            }
                            buscount++;
                        }
                    }
                }
                }

                if (Type == 2)
                {
                    brchcount = 0; buscount = 0; transcount = 0;
                    string strCon = "WHERE Type='01' AND SvgUID in (select DeviceSUID from PSP_GprogElevice where GprogUID='" + GprogUID + "'and Type in ('���վ','��Դ') and L1 in('����','����')) ";
                    string strCon2 = "WHERE Type='05' AND SUID in (select DeviceSUID from PSP_GprogElevice where GprogUID='" + GprogUID + "'and type='��·'and ZTstatus in('����','��ѡ')) ";
                    string strCon3 = "WHERE ProjectID='" + Itop.Client.MIS.ProgUID + "'";

                    double Rad_to_Deg = 180 / Math.PI;
                    {
                        List<PSPDEV> remvelement = new List<PSPDEV>();         //ɾ�������õ���·
                        IList listMX = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon);
                        IList listXL = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon2);
                        strCon2 = "and Type='02' AND SUID in (select DeviceSUID from PSP_GprogElevice where GprogUID='" + GprogUID + "'and type='�������ѹ��' and L1 in('����','����'))";
                        strCon = strCon3 + strCon2;
                        IList listBYQ2 = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon);
                        strCon2 = "and Type='03' AND SUID in (select DeviceSUID from PSP_GprogElevice where GprogUID='" + GprogUID + "'and type='�������ѹ��'and L1 in('����','����'))";
                        strCon = strCon3 + strCon2;
                        IList listBYQ3 = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon);

                        foreach (PSPDEV dev in listXL)
                        {
                            if (dev.KSwitchStatus == "0")
                            {
                                bool fistflag = false;
                                bool lastflag = false;
                                bool flag = false;                //�Ѳ�������׶ε���·��ӵ� Ҫɾ������·���� Ϊ�����ĸ�����˷�������
                                foreach (PSPDEV pspdev in listMX)
                                {
                                    if (dev.IName == pspdev.Name)
                                    {
                                        fistflag = true;
                                    }
                                    if (dev.JName == pspdev.Name)
                                    {
                                        lastflag = true;
                                    }
                                }
                                if (lastflag && fistflag)
                                {

                                    if (strBranch != null && (dev.LineStatus == "����" || dev.LineStatus == "��ѡ" || dev.LineStatus == "Ͷ��"))
                                    {
                                        strBranch += "\r\n";
                                    }
                                    if (dev.LineStatus == "����" || dev.LineStatus == "��ѡ" || dev.LineStatus == "Ͷ��")
                                    {
                                        flag = true;
                                        if (dev.UnitFlag == "0")
                                        {
                                            strBranch += dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + dev.Name.ToString() + " " + "1" + " " + dev.LineR.ToString() + " " + dev.LineTQ.ToString() + " " + (dev.LineGNDC * 2).ToString() + " " + "0" + " " + "0";

                                        }
                                        else
                                        {
                                            strBranch += dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + dev.Name.ToString() + " " + "1" + " " + (dev.LineR * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.LineTQ * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.LineGNDC * 2 * dev.ReferenceVolt * dev.ReferenceVolt / (ratedCapacity * 1000000)).ToString() + " " + "0" + " " + "0";

                                        }

                                        brchcount++;

                                    }

                                    if (dev.LineStatus == "��ѡ")
                                    {
                                        linedaixuan ll = new linedaixuan(brchcount, dev.SUID, dev.Name);
                                        waitlinecoll.Add(ll);
                                    }
                                }

                                if (!flag)
                                {
                                    remvelement.Add(dev);
                                }
                            }
                        }
                        foreach (PSPDEV dev in remvelement)
                        {
                            listXL.Remove(dev);
                        }
                        foreach (PSPDEV dev in listBYQ2)
                        {
                            bool flag = false;
                            if (dev.KSwitchStatus == "0")
                            {

                                if (dev.FirstNode != 0 && dev.LastNode != 0)
                                {
                                    if (strBranch != null)
                                    {
                                        strBranch += "\r\n";
                                    }
                                    if (dev.UnitFlag == "0")
                                    {
                                        strBranch += dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + dev.Name.ToString() + " " + "2" + " " + dev.LineR.ToString() + " " + dev.LineTQ.ToString() + " " + (dev.LineGNDC * 2).ToString() + " " + dev.K.ToString() + " " + dev.G.ToString();

                                    }
                                    else
                                    {
                                        strBranch += dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + dev.Name.ToString() + " " + "2" + " " + (dev.LineR * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.LineTQ * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.LineGNDC * 2 * dev.ReferenceVolt * dev.ReferenceVolt / (ratedCapacity * 1000000)).ToString() + " " + dev.K.ToString() + " " + dev.G.ToString();

                                    }
                                    transcount++;
                                }

                            }
                        }

                        foreach (PSPDEV dev in listBYQ3)
                        {
                            if (dev.KSwitchStatus == "0")
                            {
                                if (dev.FirstNode != 0 && dev.LastNode != 0 && dev.Flag != 0)
                                {

                                    if (dev.UnitFlag == "0")
                                    {
                                        if (strBranch != null)
                                        {
                                            strBranch += "\r\n";
                                        }
                                        strBranch += dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + dev.Name.ToString() + " " + "2" + " " + dev.HuganTQ1.ToString() + " " + dev.HuganTQ4.ToString() + " " + "0" + " " + dev.K.ToString() + " " + "0";
                                        if (strBranch != null)
                                        {
                                            strBranch += "\r\n";
                                        }
                                        strBranch += dev.LastNode.ToString() + " " + dev.Flag.ToString() + " " + dev.Name.ToString() + " " + "2" + " " + dev.HuganTQ2.ToString() + " " + dev.HuganTQ5.ToString() + " " + "0" + " " + dev.StandardCurrent.ToString() + " " + "0";
                                        if (strBranch != null)
                                        {
                                            strBranch += "\r\n";
                                        }
                                        strBranch += dev.FirstNode.ToString() + " " + dev.Flag.ToString() + " " + dev.Name.ToString() + " " + "2" + " " + dev.HuganTQ3.ToString() + " " + dev.ZeroTQ.ToString() + " " + "0" + " " + dev.BigP.ToString() + " " + "0";

                                    }
                                    else
                                    {
                                        if (strBranch != null)
                                        {
                                            strBranch += "\r\n";
                                        }
                                        strBranch += dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + dev.Name.ToString() + " " + "2" + " " + (dev.HuganTQ1 * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.HuganTQ4 * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + "0" + " " + dev.K.ToString() + " " + "0";
                                        if (strBranch != null)
                                        {
                                            strBranch += "\r\n";
                                        }
                                        strBranch += dev.LastNode.ToString() + " " + dev.Flag.ToString() + " " + dev.Name.ToString() + " " + "2" + " " + (dev.HuganTQ2 * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.HuganTQ5 * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + "0" + " " + dev.StandardCurrent.ToString() + " " + "0";
                                        if (strBranch != null)
                                        {
                                            strBranch += "\r\n";
                                        }
                                        strBranch += dev.FirstNode.ToString() + " " + dev.Flag.ToString() + " " + dev.Name.ToString() + " " + "2" + " " + (dev.HuganTQ3 * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.ZeroTQ * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + "0" + " " + dev.BigP.ToString() + " " + "0";
                                    }
                                    transcount += 3;
                                }

                            }
                        }
                        //���˷����Ƿ���ڹ���ĸ��ĸ�߽ڵ�
                        List<string> busname = new List<string>();
                        foreach (PSPDEV dev in listMX)
                        {
                            bool flag = false;
                            foreach (PSPDEV devline in listXL)
                            {
                                if (dev.Number == devline.LastNode || dev.Number == devline.FirstNode)
                                {
                                    flag = true;
                                    break;
                                }
                            }
                            foreach (PSPDEV devtrans in listBYQ2)
                            {
                                if (dev.Number == devtrans.LastNode || dev.Number == devtrans.FirstNode)
                                {
                                    flag = true;
                                    break;
                                }
                            }
                            foreach (PSPDEV devtrans in listBYQ3)
                            {
                                if (dev.Number == devtrans.LastNode || dev.Number == devtrans.FirstNode || dev.Number == devtrans.Flag)
                                {
                                    flag = true;
                                    break;
                                }
                            }
                            if (!flag)
                            {
                                busname.Add(dev.Name);
                            }
                        }
                        if (busname.Count > 0)
                        {
                            //Ϊ�Ҳ�ļ��߷�����
                            string temp = "���˷���ʧ��";
                            bool flag = false;
                            for (int i = 0; i < busname.Count; i++)
                            {
                                PSPDEV pspdev = new PSPDEV();
                                 foreach(PSPDEV dev in linedengdai)
                                {
                                    if (dev.IName==busname[i]||dev.JName==busname[i])
                                    {

                                        strBranch += "\r\n";
                                        if (dev.UnitFlag == "0")
                                        {
                                            strBranch += dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + dev.Name.ToString() + " " + "1" + " " + dev.LineR.ToString() + " " + dev.LineTQ.ToString() + " " + (dev.LineGNDC * 2).ToString() + " " + "0" + " " + "0";

                                        }
                                        else
                                        {
                                            strBranch += dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + dev.Name.ToString() + " " + "1" + " " + (dev.LineR * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.LineTQ * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.LineGNDC * 2 * dev.ReferenceVolt * dev.ReferenceVolt / (ratedCapacity * 1000000)).ToString() + " " + "0" + " " + "0";

                                        }
                                        dev.LineStatus = "����";
                                        Services.BaseService.Update<PSPDEV>(dev);
                                        brchcount++;
                                        lineyiyou.Add(dev);
                                        pspdev = dev;
                                        flag = true;
                                        break;
                                    }

                               }
                               linedengdai.Remove(pspdev);

                               if (!flag)
                               {
                                   temp += "��" + busname[i];
                                   temp += "Ϊ�����Ľڵ㣡";
                                   System.Windows.Forms.MessageBox.Show(temp, "��ʾ", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                   return false;
                               }
                            }

                        }
                        foreach (PSPDEV dev in listMX)
                        {

                            if (dev.KSwitchStatus == "0")
                            {
                                if (strBus != null)
                                {
                                    strBus += "\r\n";
                                }
                                double outP = 0;
                                double outQ = 0;
                                double inputP = 0;
                                double inputQ = 0;
                                strCon3 = "WHERE Projectid='" + Itop.Client.MIS.ProgUID + "'and Type = '04' AND IName = '" + dev.Name + "'and SUID in (select DeviceSUID from PSP_GprogElevice where GprogUID='" + GprogUID + "'and type='�����')";
                                IList listFDJ = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon3);
                                string strCon4 = "WHERE Projectid='" + Itop.Client.MIS.ProgUID + "' and Type = '12' AND IName = '" + dev.Name + "' and SUID in (select DeviceSUID from PSP_GprogElevice where GprogUID='" + GprogUID + "'and type='����')";
                                IList listFH = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon4);
                                foreach (PSPDEV devFDJ in listFDJ)
                                {
                                    if (devFDJ.UnitFlag == "0")
                                    {
                                        outP += devFDJ.OutP;
                                        outQ += devFDJ.OutQ;
                                    }
                                    else
                                    {
                                        outP += devFDJ.OutP / ratedCapacity;
                                        outQ += devFDJ.OutQ / ratedCapacity;
                                    }
                                }
                                foreach (PSPDEV devFH in listFH)
                                {
                                    if (devFH.UnitFlag == "0")
                                    {
                                        inputP += devFH.InPutP;
                                        inputQ += devFH.InPutQ;
                                    }
                                    else
                                    {
                                        inputP += devFH.InPutP / ratedCapacity;
                                        inputQ += devFH.InPutQ / ratedCapacity;
                                    }
                                }
                                if (dev.UnitFlag == "0")
                                {
                                    outP += dev.OutP;
                                    outQ += dev.OutQ;
                                    inputP += dev.InPutP;
                                    inputQ += dev.InPutQ;
                                    strBus += (dev.Number.ToString() + " " + dev.Name.ToString() + " " + MXNodeType(dev.NodeType) + " " + (dev.VoltR / dev.ReferenceVolt).ToString() + " " + (dev.VoltV * Rad_to_Deg).ToString() + " " + ((inputP -outP)).ToString() + " " + ((inputQ -outQ)).ToString());
                                    //strData += (dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + "0" + " " + (dev.LineR).ToString() + " " + (dev.LineTQ).ToString() + " " + (dev.LineGNDC).ToString() + " " + "0" + " " + dev.Name.ToString())
                                }
                                else
                                {
                                    outP += dev.OutP / ratedCapacity;
                                    outQ += dev.OutQ / ratedCapacity;
                                    inputP += dev.InPutP / ratedCapacity;
                                    inputQ += dev.InPutQ / ratedCapacity;
                                    strBus += (dev.Number.ToString() + " " + dev.Name.ToString() + " " + MXNodeType(dev.NodeType) + " " + (dev.VoltR / dev.ReferenceVolt).ToString() + " " + (dev.VoltV * Rad_to_Deg).ToString() + " " + (inputP - outP).ToString() + " " + (inputQ -outQ).ToString());
                                    //strData += (dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + "0" + " " + (dev.LineR * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.LineTQ * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + ((dev.LineGNDC) * dev.ReferenceVolt * dev.ReferenceVolt / (ratedCapacity * 1000000)).ToString() + " " + "0" + " " + dev.Name.ToString());
                                }
                                buscount++;
                            }
                        }
                    }
                }
              if (Type == 3)
              {
                  brchcount = 0; buscount = 0; transcount = 0;
                  string strCon = "WHERE Type='01' AND SvgUID in (select DeviceSUID from PSP_GprogElevice where GprogUID='" + GprogUID + "'and Type in ('���վ','��Դ') and L1 in('����','����','����')) ";
                  string strCon2 = "WHERE Type='05' AND SUID in (select DeviceSUID from PSP_GprogElevice where GprogUID='" + GprogUID + "'and type='��·' and JQstatus in('����','Ͷ��','��ѡ')) ";
                  string strCon3 = "WHERE Projectid='" + Itop.Client.MIS.ProgUID + "'";

                  double Rad_to_Deg = 180 / Math.PI;
                  {

                      IList listMX = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon);
                      IList listXL = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon2);
                      strCon2 = "and Type='02' AND SUID in (select DeviceSUID from PSP_GprogElevice where GprogUID='" + GprogUID + "'and type='�������ѹ��' and L1 in('����','����','����'))";
                      strCon = strCon3 + strCon2;
                      IList listBYQ2 = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon);
                      strCon2 = "and Type='03' AND SUID in (select DeviceSUID from PSP_GprogElevice where GprogUID='" + GprogUID + "'and type='�������ѹ��'and L1 in('����','����','����'))";
                      strCon = strCon3 + strCon2;
                      IList listBYQ3 = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon);
                      List<PSPDEV> remvelement = new List<PSPDEV>();
                      foreach (PSPDEV dev in listXL)
                      {

                          if (dev.KSwitchStatus == "0")
                          {
                              bool flag = false;
                              bool fistflag = false;
                              bool lastflag = false;
                              foreach (PSPDEV pspdev in listMX)
                              {
                                  if (dev.IName == pspdev.Name)
                                  {
                                      fistflag = true;
                                  }
                                  if (dev.JName == pspdev.Name)
                                  {
                                      lastflag = true;
                                  }
                              }
                              if (lastflag && fistflag)
                              {
                                  if (strBranch != null && (dev.LineStatus == "����" || dev.LineStatus == "��ѡ" || dev.LineStatus == "Ͷ��"))
                                  {
                                      strBranch += "\r\n";
                                  }
                                  if (dev.LineStatus == "����" || dev.LineStatus == "��ѡ" || dev.LineStatus == "Ͷ��")
                                  {
                                      flag = true;
                                      if (dev.UnitFlag == "0")
                                      {
                                          strBranch += dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + dev.Name.ToString() + " " + "1" + " " + dev.LineR.ToString() + " " + dev.LineTQ.ToString() + " " + (dev.LineGNDC * 2).ToString() + " " + "0" + " " + "0";

                                      }
                                      else
                                      {
                                          strBranch += dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + dev.Name.ToString() + " " + "1" + " " + (dev.LineR * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.LineTQ * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.LineGNDC * 2 * dev.ReferenceVolt * dev.ReferenceVolt / (ratedCapacity * 1000000)).ToString() + " " + "0" + " " + "0";

                                      }

                                      brchcount++;

                                  }
                                  PSP_GprogElevice pg = new PSP_GprogElevice();
                                  pg.GprogUID = GprogUID;
                                  pg.DeviceSUID = dev.SUID;
                                  pg = (PSP_GprogElevice)Services.BaseService.GetObject("SelectPSP_GprogEleviceByKey", pg);

                                  if (dev.LineStatus == "��ѡ" && pg.JQstatus == "��ѡ")
                                  {
                                      linedaixuan ll = new linedaixuan(brchcount, dev.SUID, dev.Name);
                                      waitlinecoll.Add(ll);
                                  }
                              }
                              if (!flag)
                              {
                                  remvelement.Add(dev);
                              }

                          }
                      }
                      foreach (PSPDEV dev in remvelement)
                      {
                          listXL.Remove(dev);
                      }
                      foreach (PSPDEV dev in listBYQ2)
                      {
                          bool flag = false;
                          if (dev.KSwitchStatus == "0")
                          {

                              if (dev.FirstNode != 0 && dev.LastNode != 0)
                              {
                                  if (strBranch != null)
                                  {
                                      strBranch += "\r\n";
                                  }
                                  if (dev.UnitFlag == "0")
                                  {
                                      strBranch += dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + dev.Name.ToString() + " " + "2" + " " + dev.LineR.ToString() + " " + dev.LineTQ.ToString() + " " + (dev.LineGNDC * 2).ToString() + " " + dev.K.ToString() + " " + dev.G.ToString();

                                  }
                                  else
                                  {
                                      strBranch += dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + dev.Name.ToString() + " " + "2" + " " + (dev.LineR * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.LineTQ * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.LineGNDC * 2 * dev.ReferenceVolt * dev.ReferenceVolt / (ratedCapacity * 1000000)).ToString() + " " + dev.K.ToString() + " " + dev.G.ToString();

                                  }
                                  transcount++;
                              }

                          }
                      }

                      foreach (PSPDEV dev in listBYQ3)
                      {
                          if (dev.KSwitchStatus == "0")
                          {
                              if (dev.FirstNode != 0 && dev.LastNode != 0 && dev.Flag != 0)
                              {

                                  if (dev.UnitFlag == "0")
                                  {
                                      if (strBranch != null)
                                      {
                                          strBranch += "\r\n";
                                      }
                                      strBranch += dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + dev.Name.ToString() + " " + "2" + " " + dev.HuganTQ1.ToString() + " " + dev.HuganTQ4.ToString() + " " + "0" + " " + dev.K.ToString() + " " + "0";
                                      if (strBranch != null)
                                      {
                                          strBranch += "\r\n";
                                      }
                                      strBranch += dev.LastNode.ToString() + " " + dev.Flag.ToString() + " " + dev.Name.ToString() + " " + "2" + " " + dev.HuganTQ2.ToString() + " " + dev.HuganTQ5.ToString() + " " + "0" + " " + dev.StandardCurrent.ToString() + " " + "0";
                                      if (strBranch != null)
                                      {
                                          strBranch += "\r\n";
                                      }
                                      strBranch += dev.FirstNode.ToString() + " " + dev.Flag.ToString() + " " + dev.Name.ToString() + " " + "2" + " " + dev.HuganTQ3.ToString() + " " + dev.ZeroTQ.ToString() + " " + "0" + " " + dev.BigP.ToString() + " " + "0";

                                  }
                                  else
                                  {
                                      if (strBranch != null)
                                      {
                                          strBranch += "\r\n";
                                      }
                                      strBranch += dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + dev.Name.ToString() + " " + "2" + " " + (dev.HuganTQ1 * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.HuganTQ4 * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + "0" + " " + dev.K.ToString() + " " + "0";
                                      if (strBranch != null)
                                      {
                                          strBranch += "\r\n";
                                      }
                                      strBranch += dev.LastNode.ToString() + " " + dev.Flag.ToString() + " " + dev.Name.ToString() + " " + "2" + " " + (dev.HuganTQ2 * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.HuganTQ5 * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + "0" + " " + dev.StandardCurrent.ToString() + " " + "0";
                                      if (strBranch != null)
                                      {
                                          strBranch += "\r\n";
                                      }
                                      strBranch += dev.FirstNode.ToString() + " " + dev.Flag.ToString() + " " + dev.Name.ToString() + " " + "2" + " " + (dev.HuganTQ3 * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.ZeroTQ * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + "0" + " " + dev.BigP.ToString() + " " + "0";
                                  }
                                  transcount += 3;
                              }

                          }
                      }
                      //���˷����Ƿ���ڹ���ĸ��ĸ�߽ڵ�
                      List<string> busname = new List<string>();
                      foreach (PSPDEV dev in listMX)
                      {
                          bool flag = false;
                          foreach (PSPDEV devline in listXL)
                          {
                              if (dev.Number == devline.LastNode || dev.Number == devline.FirstNode)
                              {
                                  flag = true;
                                  break;
                              }
                          }
                          foreach (PSPDEV devtrans in listBYQ2)
                          {
                              if (dev.Number == devtrans.LastNode || dev.Number == devtrans.FirstNode)
                              {
                                  flag = true;
                                  break;
                              }
                          }
                          foreach (PSPDEV devtrans in listBYQ3)
                          {
                              if (dev.Number == devtrans.LastNode || dev.Number == devtrans.FirstNode || dev.Number == devtrans.Flag)
                              {
                                  flag = true;
                                  break;
                              }
                          }
                          if (!flag)
                          {
                              busname.Add(dev.Name);
                          }
                      }
                      if (busname.Count > 0)
                      {
                          //Ϊ�Ҳ�ļ��߷�����
                          string temp = "���˷���ʧ��";
                          bool flag = false;
                          for (int i = 0; i < busname.Count; i++)
                          {
                              PSPDEV pspdev = new PSPDEV();
                              foreach (PSPDEV dev in linedengdai)
                              {
                                  if (dev.IName == busname[i] || dev.JName == busname[i])
                                  {

                                      strBranch += "\r\n";
                                      if (dev.UnitFlag == "0")
                                      {
                                          strBranch += dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + dev.Name.ToString() + " " + "1" + " " + dev.LineR.ToString() + " " + dev.LineTQ.ToString() + " " + (dev.LineGNDC * 2).ToString() + " " + "0" + " " + "0";

                                      }
                                      else
                                      {
                                          strBranch += dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + dev.Name.ToString() + " " + "1" + " " + (dev.LineR * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.LineTQ * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.LineGNDC * 2 * dev.ReferenceVolt * dev.ReferenceVolt / (ratedCapacity * 1000000)).ToString() + " " + "0" + " " + "0";

                                      }
                                      dev.LineStatus = "����";
                                      Services.BaseService.Update<PSPDEV>(dev);
                                      brchcount++;
                                      lineyiyou.Add(dev);
                                      pspdev = dev;
                                      flag = true;
                                      break;
                                  }

                              }
                              linedengdai.Remove(pspdev);
                              if (!flag)
                              {
                                  temp += "��" + busname[i];
                                  temp += "Ϊ�����Ľڵ㣡";
                                  System.Windows.Forms.MessageBox.Show(temp, "��ʾ", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                  return false;
                              }

                          }

                      }
                      foreach (PSPDEV dev in listMX)
                      {

                          if (dev.KSwitchStatus == "0")
                          {
                              if (strBus != null)
                              {
                                  strBus += "\r\n";
                              }
                              double outP = 0;
                              double outQ = 0;
                              double inputP = 0;
                              double inputQ = 0;
                              strCon3 = "WHERE Projectid='" + Itop.Client.MIS.ProgUID + "'and Type = '04' AND IName = '" + dev.Name + "'and SUID in (select DeviceSUID from PSP_GprogElevice where GprogUID='" + GprogUID + "'and type='�����')";
                              IList listFDJ = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon3);
                              string strCon4 = "WHERE Projectid='" + Itop.Client.MIS.ProgUID + "' and Type = '12' AND IName = '" + dev.Name + "' and SUID in (select DeviceSUID from PSP_GprogElevice where GprogUID='" + GprogUID + "'and type='����')";
                              IList listFH = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon4);
                              foreach (PSPDEV devFDJ in listFDJ)
                              {
                                  if (devFDJ.UnitFlag == "0")
                                  {
                                      outP += devFDJ.OutP;
                                      outQ += devFDJ.OutQ;
                                  }
                                  else
                                  {
                                      outP += devFDJ.OutP / ratedCapacity;
                                      outQ += devFDJ.OutQ / ratedCapacity;
                                  }
                              }
                              foreach (PSPDEV devFH in listFH)
                              {
                                  if (devFH.UnitFlag == "0")
                                  {
                                      inputP += devFH.InPutP;
                                      inputQ += devFH.InPutQ;
                                  }
                                  else
                                  {
                                      inputP += devFH.InPutP / ratedCapacity;
                                      inputQ += devFH.InPutQ / ratedCapacity;
                                  }
                              }
                              if (dev.UnitFlag == "0")
                              {
                                  outP += dev.OutP;
                                  outQ += dev.OutQ;
                                  inputP += dev.InPutP;
                                  inputQ += dev.InPutQ;
                                  strBus += (dev.Number.ToString() + " " + dev.Name.ToString() + " " + MXNodeType(dev.NodeType) + " " + (dev.VoltR / dev.ReferenceVolt).ToString() + " " + (dev.VoltV * Rad_to_Deg).ToString() + " " + ((inputP - outP)).ToString() + " " + ((inputQ - outQ)).ToString());
                                  //strData += (dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + "0" + " " + (dev.LineR).ToString() + " " + (dev.LineTQ).ToString() + " " + (dev.LineGNDC).ToString() + " " + "0" + " " + dev.Name.ToString())
                              }
                              else
                              {
                                  outP += dev.OutP / ratedCapacity;
                                  outQ += dev.OutQ / ratedCapacity;
                                  inputP += dev.InPutP / ratedCapacity;
                                  inputQ += dev.InPutQ / ratedCapacity;
                                  strBus += (dev.Number.ToString() + " " + dev.Name.ToString() + " " + MXNodeType(dev.NodeType) + " " + (dev.VoltR / dev.ReferenceVolt).ToString() + " " + (dev.VoltV * Rad_to_Deg).ToString() + " " + (inputP - outQ).ToString() + " " + (inputQ - outQ).ToString());
                                  //strData += (dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + "0" + " " + (dev.LineR * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.LineTQ * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + ((dev.LineGNDC) * dev.ReferenceVolt * dev.ReferenceVolt / (ratedCapacity * 1000000)).ToString() + " " + "0" + " " + dev.Name.ToString());
                              }
                              buscount++;
                          }
                      }
                  }
              }
                  if (Type == 4)
               {
              brchcount = 0;buscount = 0; transcount = 0;
                 string strCon = "WHERE Type='01' AND SvgUID in (select DeviceSUID from PSP_GprogElevice where GprogUID='" + GprogUID + "'and Type in ('���վ','��Դ') ) ";
                 string strCon2 = "WHERE Type='05' AND SUID in (select DeviceSUID from PSP_GprogElevice where GprogUID='" + GprogUID + "'and type='��·' and ZQstatus in('����','Ͷ��','��ѡ')) ";
                 string strCon3 = "WHERE ProjectID='" + Itop.Client.MIS.ProgUID + "'";

                double Rad_to_Deg = 180 / Math.PI;
                {

                    IList listMX = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon);
                    IList listXL = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon2);
                    strCon2 = "and Type='02' AND SUID in (select DeviceSUID from PSP_GprogElevice where GprogUID='" + GprogUID + "'and type='�������ѹ��')";
                    strCon = strCon3 + strCon2;
                    IList listBYQ2 = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon);
                    strCon2 = "and Type='03' AND SUID in (select DeviceSUID from PSP_GprogElevice where GprogUID='" + GprogUID + "'and type='�������ѹ��')";
                    strCon = strCon3 + strCon2;
                    IList listBYQ3 = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon);
                    List<PSPDEV> remvelement = new List<PSPDEV>();
                    foreach (PSPDEV dev in listXL)
                    {
                        if (dev.KSwitchStatus == "0")
                        {
                            bool fistflag=false;
                            bool lastflag=false;
                            bool flag = false;
                            foreach (PSPDEV pspdev in listMX)
                            {
                              if (dev.IName==pspdev.Name)
                              {
                                  fistflag=true;
                              }
                                if (dev.JName==pspdev.Name)
                                {
                                    lastflag=true;
                                }
                            }
                            if (lastflag&&fistflag)
                            {
                                if (strBranch != null && (dev.LineStatus == "����" || dev.LineStatus == "��ѡ" || dev.LineStatus == "Ͷ��"))
                            {
                                strBranch += "\r\n";
                            }
                            if (dev.LineStatus == "����" || dev.LineStatus == "��ѡ" || dev.LineStatus == "Ͷ��")
                            {
                                flag = true;
                                if (dev.UnitFlag == "0")
                                {
                                    strBranch += dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + dev.Name.ToString() + " " + "1" + " " + dev.LineR.ToString() + " " + dev.LineTQ.ToString() + " " + (dev.LineGNDC * 2).ToString() + " " + "0" + " " + "0";

                                }
                                else
                                {
                                    strBranch += dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + dev.Name.ToString() + " " + "1" + " " + (dev.LineR * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.LineTQ * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.LineGNDC * 2 * dev.ReferenceVolt * dev.ReferenceVolt / (ratedCapacity * 1000000)).ToString() + " " + "0" + " " + "0";

                                }

                                brchcount++;

                            }
                            PSP_GprogElevice pg = new PSP_GprogElevice();
                            pg.GprogUID = GprogUID;
                            pg.DeviceSUID = dev.SUID;
                            pg = (PSP_GprogElevice)Services.BaseService.GetObject("SelectPSP_GprogEleviceByKey", pg);
                            if (dev.LineStatus == "��ѡ"&&pg.ZQstatus=="��ѡ")
                            {
                                linedaixuan ll = new linedaixuan(brchcount, dev.SUID, dev.Name);
                                waitlinecoll.Add(ll);
                            }
                          }

                           if (!flag)
                           {
                               remvelement.Add(dev);
                           }
                        }
                    }
                    foreach(PSPDEV dev in remvelement)
                    {
                        listXL.Remove(dev);
                    }
                    foreach (PSPDEV dev in listBYQ2)
                    {
                        bool flag = false;
                        if (dev.KSwitchStatus == "0")
                        {

                            if (dev.FirstNode != 0 && dev.LastNode != 0)
                            {
                                if (strBranch != null)
                                {
                                    strBranch += "\r\n";
                                }
                                if (dev.UnitFlag == "0")
                                {
                                    strBranch += dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + dev.Name.ToString() + " " + "2" + " " + dev.LineR.ToString() + " " + dev.LineTQ.ToString() + " " + (dev.LineGNDC * 2).ToString() + " " + dev.K.ToString() + " " + dev.G.ToString();

                                }
                                else
                                {
                                    strBranch += dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + dev.Name.ToString() + " " + "2" + " " + (dev.LineR * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.LineTQ * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.LineGNDC * 2 * dev.ReferenceVolt * dev.ReferenceVolt / (ratedCapacity * 1000000)).ToString() + " " + dev.K.ToString() + " " + dev.G.ToString();

                                }
                                transcount++;
                            }

                        }
                    }

                    foreach (PSPDEV dev in listBYQ3)
                    {
                        if (dev.KSwitchStatus == "0")
                        {
                            if (dev.FirstNode != 0 && dev.LastNode != 0 && dev.Flag != 0)
                            {

                                if (dev.UnitFlag == "0")
                                {
                                    if (strBranch != null)
                                    {
                                        strBranch += "\r\n";
                                    }
                                    strBranch += dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + dev.Name.ToString() + " " + "2" + " " + dev.HuganTQ1.ToString() + " " + dev.HuganTQ4.ToString() + " " + "0" + " " + dev.K.ToString() + " " + "0";
                                    if (strBranch != null)
                                    {
                                        strBranch += "\r\n";
                                    }
                                    strBranch += dev.LastNode.ToString() + " " + dev.Flag.ToString() + " " + dev.Name.ToString() + " " + "2" + " " + dev.HuganTQ2.ToString() + " " + dev.HuganTQ5.ToString() + " " + "0" + " " + dev.StandardCurrent.ToString() + " " + "0";
                                    if (strBranch != null)
                                    {
                                        strBranch += "\r\n";
                                    }
                                    strBranch += dev.FirstNode.ToString() + " " + dev.Flag.ToString() + " " + dev.Name.ToString() + " " + "2" + " " + dev.HuganTQ3.ToString() + " " + dev.ZeroTQ.ToString() + " " + "0" + " " + dev.BigP.ToString() + " " + "0";

                                }
                                else
                                {
                                    if (strBranch != null)
                                    {
                                        strBranch += "\r\n";
                                    }
                                    strBranch += dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + dev.Name.ToString() + " " + "2" + " " + (dev.HuganTQ1 * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.HuganTQ4 * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + "0" + " " + dev.K.ToString() + " " + "0";
                                    if (strBranch != null)
                                    {
                                        strBranch += "\r\n";
                                    }
                                    strBranch += dev.LastNode.ToString() + " " + dev.Flag.ToString() + " " + dev.Name.ToString() + " " + "2" + " " + (dev.HuganTQ2 * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.HuganTQ5 * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + "0" + " " + dev.StandardCurrent.ToString() + " " + "0";
                                    if (strBranch != null)
                                    {
                                        strBranch += "\r\n";
                                    }
                                    strBranch += dev.FirstNode.ToString() + " " + dev.Flag.ToString() + " " + dev.Name.ToString() + " " + "2" + " " + (dev.HuganTQ3 * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.ZeroTQ * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + "0" + " " + dev.BigP.ToString() + " " + "0";
                                }
                                transcount += 3;
                            }

                        }
                    }
                    //���˷����Ƿ���ڹ���ĸ��ĸ�߽ڵ�
                    List<string> busname = new List<string>();
                    foreach (PSPDEV dev in listMX)
                    {
                        bool flag = false;
                        foreach (PSPDEV devline in listXL)
                        {
                            if (dev.Number == devline.LastNode || dev.Number == devline.FirstNode)
                            {
                                flag = true;
                                break;
                            }
                        }
                        foreach (PSPDEV devtrans in listBYQ2)
                        {
                            if (dev.Number == devtrans.LastNode || dev.Number == devtrans.FirstNode)
                            {
                                flag = true;
                                break;
                            }
                        }
                        foreach (PSPDEV devtrans in listBYQ3)
                        {
                            if (dev.Number == devtrans.LastNode || dev.Number == devtrans.FirstNode || dev.Number == devtrans.Flag)
                            {
                                flag = true;
                                break;
                            }
                        }
                        if (!flag)
                        {
                            busname.Add(dev.Name);
                        }
                    }
                    if (busname.Count > 0)
                    {
                        //Ϊ�Ҳ�ļ��߷�����
                        string temp = "���˷���ʧ��";
                        bool flag = false;
                        for (int i = 0; i < busname.Count; i++)
                        {
                            PSPDEV pspdev = new PSPDEV();
                            foreach (PSPDEV dev in linedengdai)
                            {
                                if (dev.IName == busname[i] || dev.JName == busname[i])
                                {

                                    strBranch += "\r\n";
                                    if (dev.UnitFlag == "0")
                                    {
                                        strBranch += dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + dev.Name.ToString() + " " + "1" + " " + dev.LineR.ToString() + " " + dev.LineTQ.ToString() + " " + (dev.LineGNDC * 2).ToString() + " " + "0" + " " + "0";

                                    }
                                    else
                                    {
                                        strBranch += dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + dev.Name.ToString() + " " + "1" + " " + (dev.LineR * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.LineTQ * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.LineGNDC * 2 * dev.ReferenceVolt * dev.ReferenceVolt / (ratedCapacity * 1000000)).ToString() + " " + "0" + " " + "0";

                                    }
                                    dev.LineStatus = "����";
                                    Services.BaseService.Update<PSPDEV>(dev);
                                    brchcount++;
                                    lineyiyou.Add(dev);
                                    pspdev = dev;
                                    flag = true;
                                    break;
                                }

                            }
                            linedengdai.Remove(pspdev);

                            if (!flag)
                            {
                                temp += "��" + busname[i];
                                temp += "Ϊ�����Ľڵ㣡";
                                System.Windows.Forms.MessageBox.Show(temp, "��ʾ", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return false;
                            }
                        }

                    }
                    foreach (PSPDEV dev in listMX)
                    {

                        if (dev.KSwitchStatus == "0")
                        {
                            if (strBus != null)
                            {
                                strBus += "\r\n";
                            }
                            double outP = 0;
                            double outQ = 0;
                            double inputP = 0;
                            double inputQ = 0;
                            strCon3 = "WHERE Projectid='" + Itop.Client.MIS.ProgUID + "'and Type = '04' AND IName = '" + dev.Name + "'and SUID in (select DeviceSUID from PSP_GprogElevice where GprogUID='" + GprogUID + "'and type='�����')";
                            IList listFDJ = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon3);
                            string strCon4 = "WHERE Projectid='" + Itop.Client.MIS.ProgUID + "' and Type = '12' AND IName = '" + dev.Name + "' and SUID in (select DeviceSUID from PSP_GprogElevice where GprogUID='" + GprogUID + "'and type='����')";
                            IList listFH = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon4);
                            foreach (PSPDEV devFDJ in listFDJ)
                            {
                                if (devFDJ.UnitFlag == "0")
                                {
                                    outP += devFDJ.OutP;
                                    outQ += devFDJ.OutQ;
                                }
                                else
                                {
                                    outP += devFDJ.OutP / ratedCapacity;
                                    outQ += devFDJ.OutQ / ratedCapacity;
                                }
                            }
                            foreach (PSPDEV devFH in listFH)
                            {
                                if (devFH.UnitFlag == "0")
                                {
                                    inputP += devFH.InPutP;
                                    inputQ += devFH.InPutQ;
                                }
                                else
                                {
                                    inputP += devFH.InPutP / ratedCapacity;
                                    inputQ += devFH.InPutQ / ratedCapacity;
                                }
                            }
                            if (dev.UnitFlag == "0")
                            {
                                outP += dev.OutP;
                                outQ += dev.OutQ;
                                inputP += dev.InPutP;
                                inputQ += dev.InPutQ;
                                strBus += (dev.Number.ToString() + " " + dev.Name.ToString() + " " + MXNodeType(dev.NodeType) + " " + (dev.VoltR / dev.ReferenceVolt).ToString() + " " + (dev.VoltV * Rad_to_Deg).ToString() + " " + ((inputP - outP)).ToString() + " " + ((inputQ - outQ)).ToString());
                                //strData += (dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + "0" + " " + (dev.LineR).ToString() + " " + (dev.LineTQ).ToString() + " " + (dev.LineGNDC).ToString() + " " + "0" + " " + dev.Name.ToString())
                            }
                            else
                            {
                                outP += dev.OutP / ratedCapacity;
                                outQ += dev.OutQ / ratedCapacity;
                                inputP += dev.InPutP / ratedCapacity;
                                inputQ += dev.InPutQ / ratedCapacity;
                                strBus += (dev.Number.ToString() + " " + dev.Name.ToString() + " " + MXNodeType(dev.NodeType) + " " + (dev.VoltR / dev.ReferenceVolt).ToString() + " " + (dev.VoltV * Rad_to_Deg).ToString() + " " + (inputP - outP).ToString() + " " + (inputQ -outQ).ToString());
                                //strData += (dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + "0" + " " + (dev.LineR * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.LineTQ * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + ((dev.LineGNDC) * dev.ReferenceVolt * dev.ReferenceVolt / (ratedCapacity * 1000000)).ToString() + " " + "0" + " " + dev.Name.ToString());
                            }
                            buscount++;
                        }
                    }
                   }
                 }
                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\branch.txt"))
                {
                    File.Delete(System.Windows.Forms.Application.StartupPath + "\\branch.txt");
                }
                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\bus.txt"))
                {
                    File.Delete(System.Windows.Forms.Application.StartupPath + "\\bus.txt");
                }

                FileStream VK1 = new FileStream((System.Windows.Forms.Application.StartupPath + "\\branch.txt"), FileMode.OpenOrCreate);
                StreamWriter str3 = new StreamWriter(VK1, Encoding.Default);
                str3.Write(strBranch);
                str3.Close();
                FileStream L = new FileStream((System.Windows.Forms.Application.StartupPath + "\\bus.txt"), FileMode.OpenOrCreate);
                StreamWriter str2 = new StreamWriter(L, Encoding.Default);
                str2.Write(strBus);
                str2.Close();
                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\DH1.txt"))
                {
                    File.Delete(System.Windows.Forms.Application.StartupPath + "\\DH1.txt");
                }
                if ((strBus.Contains("������") || strBus.Contains("�������")) || (strBranch.Contains("������") || strBranch.Contains("�������")))
                {
                    MessageBox.Show("ȱ�ٲ������������������", "��ʾ", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return false;
                }
            }
            catch (System.Exception ex)
            {
                MessageBox.Show("���ݴ���������������ȫ���ٲ���", "��ʾ", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return false;
            }
            return true;
        }
コード例 #6
0
ファイル: ElectricWjgh.cs プロジェクト: EdgarEDT/myitoppsp
        /// <summary>
        ///�����߷�
        /// <param name="GprogUID">
        /// Ϊ�����Ż���ĿID
        /// </param>
        /// <param name="Type">
        /// Ϊ�Ǹ�ʱ�ڵ������Ż���1Ϊ���塢2���ڡ�3���ڡ�4Զ�ڣ�
        /// </param>
        /// </summary>
        public void addlinecheck(string GprogUID,int Type,double ratacapality)
        {
            FileStream dh;
               StreamReader readLine;
               char[] charSplit;
               string strLine;
               string[] array1;

               char[] charSplit2 = new char[] { ' ' };
               string strCon = null;
               linedengdai.Clear();
               if (Type==2)
               {
            strCon = "WHERE Type='05' AND SUID in (select DeviceSUID from PSP_GprogElevice where GprogUID='" + GprogUID + "'and type='��·'and ZTstatus ='��ѡ') ";
               }
               if (Type == 3)
               {
               strCon = "WHERE Type='05' AND SUID in (select DeviceSUID from PSP_GprogElevice where GprogUID='" + GprogUID + "'and type='��·'and JQstatus ='��ѡ') ";
               }
               if (Type ==4)
               {
               strCon = "WHERE Type='05' AND SUID in (select DeviceSUID from PSP_GprogElevice where GprogUID='" + GprogUID + "'and type='��·'and ZQstatus ='��ѡ') ";
               }
               PSPDEV pspdev = new PSPDEV();
               IList list1 = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon);
               for (int i = 0; i < list1.Count; i++)
               {
               bool flag=false;
               pspdev = list1[i] as PSPDEV;
               foreach (eleclass el in JDlinecol)
               {

                   if (el.suid==pspdev.SUID)
                   {
                       flag = true;
                   }
               }
               if (flag)
               {
                   pspdev.LineStatus = "�ȴ�";
                   linedengdai.Add(pspdev);
                   Services.BaseService.Update<PSPDEV>(pspdev);
               }

               }
               lineyiyou.Clear();            //�����һ�εļ�¼  Ϊ��һ��ʱ�ڵ�Ӧ����׼��

              // linedengdai.Clear();          //�����һ�μ�¼��ѡ��· Ϊ��һ��ʱ�ڵ�Ӧ����׼��

               AA:
               if (!fuhecheck(GprogUID,Type,ratacapality))
               {
               waitlineindex.Clear();
               for (int j = 0; j < linedengdai.Count; j++)
               {
                   if (!Checkadd(GprogUID,Type,ratacapality,linedengdai[j].SUID))
                       return;
                   N1Test.NBcal zl = new N1Test.NBcal();
                   zl.ZLpsp();

                   double yinzi = 0, capability = 0, volt = 0, current = 0, standvolt = 0, Rad_to_Deg = 57.29577951;
                   capability = ratacapality;
                   if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\DH1.txt"))
                   {
                   }
                   else
                   {
                       return;
                   }
                   dh = new FileStream(System.Windows.Forms.Application.StartupPath + "\\DH1.txt", FileMode.Open);

                   readLine = new StreamReader(dh, Encoding.Default);
                   charSplit = new char[] { ' ' };
                   strLine = readLine.ReadLine();
                   double sumpij = 0.0;
                   bool lineflag = true;
                   while (!string.IsNullOrEmpty(strLine))
                   {
                       array1 = strLine.Split(charSplit);

                       string[] dev = new string[2];
                       dev.Initialize();
                       int i = 0;
                       PSPDEV CR = new PSPDEV();
                       //CR.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;

                       foreach (string str in array1)
                       {
                           if (str != "")
                           {
                               if (i == 0)
                               {
                                   dev[i++] = str.ToString();
                               }
                               else
                               {
                                   if (str != "NaN")
                                   {
                                       dev[i++] = Convert.ToDouble(str).ToString();
                                   }
                                   else
                                   {
                                       dev[i++] = str;
                                   }

                               }
                           }

                       }
                       string con = " WHERE Type='05' AND Name='" + dev[0] + "'AND KSwitchStatus = '0' AND SUID in (select DeviceSUID from PSP_GprogElevice where GprogUID='" + GprogUID + "'and type='��·') ";
                      // string con = ",PSP_GprogElevice WHERE PSPDEV.Name='" + dev[0] + "' PSPDEV.SUID = PSP_GprogElevice.DeviceSUID AND PSP_GprogElevice.GprogUID = '" + GprogUID + "'AND PSPDEV.type='05'AND PSPDEV.KSwitchStatus = '0'";
                       CR = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByCondition", con);
                       if (CR != null && CR.ReferenceVolt != 0)
                       {
                           volt = CR.ReferenceVolt;
                       }
                       else
                           volt = standvolt;
                       current = capability / (Math.Sqrt(3) * volt);
                       if (CR != null && !CR.Name.Contains("������·"))
                       {

                           double linepij = System.Math.Abs(Convert.ToDouble(dev[1])) * capability;
                           double voltR = CR.RateVolt;
                           double Ichange = (double)CR.Burthen;
                           double linXij = System.Math.Sqrt(3) * voltR * Ichange / 1000;

                           if (linepij >= linXij)
                           {
                               lineflag = false;

                           }
                           for (int k = 0; k < fuheline.Count; k++)
                           {
                               if (CR.SUID == fuheline[k].Suid)
                               {
                                   sumpij += System.Math.Abs(fuheline[k].linepij - linepij);
                               }
                           }

                       }
                       strLine = readLine.ReadLine();
                   }
                   readLine.Close();
                  //if (lineflag)              //���û�г��ֹ��������� ��ֹͣ���м���
                  // {
                  // //    PSPDEV pspb = (PSPDEV)linedengdai[j];
                  // //    pspb.LineStatus = "����";
                  // //    Services.BaseService.Update<PSPDEV>(pspb);
                  // //    lineyiyou.Add(pspb);
                  // //    for (int i = 0; i < linedengdai.Count; i++)
                  // //    {
                  // //        if (linedengdai[i].SUID == pspb.SUID)
                  // //        {
                  // //            linedengdai.RemoveAt(j);
                  // //        }
                  // //    }
                  //    return;
                  //  }
                   double linevalue = 0;
                   if (linedengdai[j].HuganTQ1!=0)
                   {
                       linevalue =linedengdai[j].HuganTQ1;
                   }
                   else
                       linevalue = 1;
                   linedaixuan linedai = new linedaixuan(linedengdai[j].Number, linedengdai[j].SUID, linedengdai[j].Name);
                   linedai.linepij = sumpij;
                   linedai.linevalue = linevalue;
                   linedai.linetouzilv = sumpij / linevalue;

                   waitlineindex.Add(linedai);
                   //}

               }
               waitlineindex.Sort();
               //�ڴ˴����ָ��������· ������·��״̬��Ϊ ���в��������еļ��������¼ �ڵȴ��ļ����ォ����·ȥ�� ���½�����һ�ֵIJ���
               PSPDEV pspbianhua = new PSPDEV();
               if (waitlineindex.Count > 0)
               {
                   pspbianhua.SUID = waitlineindex[waitlineindex.Count - 1].Suid;
               }
               else
               {
                   //MessageBox.Show("û�г��ֹ����ɵ���·������鿴һ����·�����Ƿ��趨��ȷ��", "��ʾ", MessageBoxButtons.OK, MessageBoxIcon.Information);
                   return;
               }

               pspbianhua = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByKey", pspbianhua);
               pspbianhua.LineStatus = "����";
               Services.BaseService.Update<PSPDEV>(pspbianhua);
               lineyiyou.Add(pspbianhua);
               for (int i = 0; i < linedengdai.Count; i++)
               {
                   if (linedengdai[i].SUID == pspbianhua.SUID)
                   {
                       linedengdai.RemoveAt(i);
                   }
               }

               goto AA;
               }
        }
コード例 #7
0
ファイル: ElectricWjgh.cs プロジェクト: EdgarEDT/myitoppsp
        /// <summary>
        ///�Ҳ���߷� �������һ����·ȷ�������ֹ�����
        /// <param name="GprogUID">
        /// Ϊ�����Ż���ĿID
        /// </param>
        /// <param name="Type">
        /// Ϊ�Ǹ�ʱ�ڵ������Ż���1Ϊ���塢2���ڡ�3���ڡ�4Զ�ڣ�
        /// </param>
        /// </summary>
        public void addrightcheck(string GprogUID,int Type,double ratacapality)
        {
            FileStream dh;
            StreamReader readLine;
            char[] charSplit;
            string strLine;
            string[] array1;
            string[] array2;

            string strLine2;

            char[] charSplit2 = new char[] { ' ' };
            FileStream dh2;
            StreamReader readLine2;
            string strCon2 = null;
            //List<PSPDEV> linedengdai = new List<PSPDEV>();          //��¼���д�ѡ����·��һ�������Ժ�ͻᷢ���仯��
            if (!Check(GprogUID,Type,ratacapality))
            {
                return;
            }
            if (Type == 2)
            {
                //strCon = "WHERE Type='01' AND SvgUID in (select DeviceSUID from PSP_GprogElevice where GprogUID='" + GprogUID + "'and Type in ('���վ','��Դ') and L1 in('����','����')) ";
                strCon2 = "WHERE Type='05'AND LineStatus='����' AND SUID in (select DeviceSUID from PSP_GprogElevice where GprogUID='" + GprogUID + "'and type='��·'and ZTstatus in('����','��ѡ')) ";

            }
            if (Type == 3)
            {
               // strCon = "WHERE Type='01' AND SvgUID in (select DeviceSUID from PSP_GprogElevice where GprogUID='" + GprogUID + "'and Type in ('���վ','��Դ') and L1 in('����','����','����')) ";
                strCon2 = "WHERE Type='05'AND LineStatus='����' AND SUID in (select DeviceSUID from PSP_GprogElevice where GprogUID='" + GprogUID + "'and type='��·'and JQstatus in('����','��ѡ','Ͷ��')) ";
                //strCon3 = "WHERE ProjectID='" + Itop.Client.MIS.ProgUID + "'";

            }
            if (Type == 4)
            {
                //strCon = "WHERE Type='01' AND SvgUID in (select DeviceSUID from PSP_GprogElevice where GprogUID='" + GprogUID + "'and Type in ('���վ','��Դ')) ";
                strCon2 = "WHERE Type='05'AND LineStatus='����' AND SUID in (select DeviceSUID from PSP_GprogElevice where GprogUID='" + GprogUID + "'and type='��·'and ZQstatus in('����','��ѡ','Ͷ��')) ";
                // strCon3 = "WHERE ProjectID='" + Itop.Client.MIS.ProgUID + "'";

            }
            IList list1 = Services.BaseService.GetList("SelectPSPDEVByCondition",strCon2);
             double yinzi = 0, capability = 0, volt = 0, current = 0, standvolt = 0, Rad_to_Deg = 57.29577951;
            capability = ratacapality;
            ercilinedengdai.Clear();//���֮ǰ�ļ�¼
            waitlineindex.Clear();

            for (int i = 0; i < list1.Count; i++)
            {
                N1Test.NBcal kk = new N1Test.NBcal();
                kk.Show_KmRelia(i + 1);
                //kk.Show_ZLKMPSP(i+1);
                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\ZL.txt"))
                {
                }
                else
                {
                    return;
                }
                dh2 = new FileStream(System.Windows.Forms.Application.StartupPath + "\\ZL.txt", FileMode.Open);

                readLine2 = new StreamReader(dh2, Encoding.Default);
                charSplit2 = new char[] { ' ' };
                strLine2 = readLine2.ReadLine();

                bool lineflag = true;
                string tiaochuname = "";
                bool jielieflag = true;
                while (!string.IsNullOrEmpty(strLine2))
                {
                    array2 = strLine2.Split(charSplit2);

                    string[] dev = new string[2 * brchcount + 1];
                    dev.Initialize();

                    PSPDEV CR = new PSPDEV();
                   // CR.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                    int m = 0;
                    foreach (string str in array2)
                    {

                        if (str != "")
                        {

                            dev[m++] = str.ToString();

                        }
                    }
                    //���н��Ѻ͸����ж�

                    if (dev[1] != "-1")
                    {
                        for (int j = 0; j < brchcount; j++)
                        {

                            double pij = System.Math.Abs(Convert.ToDouble(dev[j * 2 + 2])) * ratacapality;

                            string con = " WHERE Type='05' AND Name='" + dev[0] + "'AND KSwitchStatus = '0' AND SUID in (select DeviceSUID from PSP_GprogElevice where GprogUID='" + GprogUID + "'and type='��·') ";
                            //string con = ",PSP_GprogElevice WHERE PSPDEV.Name='" + dev[j * 2 + 1] + "' PSPDEV.SUID = PSP_GprogElevice.DeviceSUID AND PSP_GprogElevice.GprogUID = '" + GprogUID + "'AND PSPDEV.type='05'AND PSPDEV.KSwitchStatus = '0'";

                            PSPDEV pspline = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByCondition", con);
                            if (pspline != null && !pspline.Name.Contains("������·"))
                            {
                                double voltR = pspline.RateVolt;
                                double Ichange = (double)pspline.Burthen;

                                double linXij = System.Math.Sqrt(3) * voltR * Ichange / 1000;
                                if (pij >= linXij)
                                {
                                    lineflag = false;
                                    tiaochuname = dev[0];
                                    //lineclass _line = new lineclass(n, j);
                                    //Overlinp.Add(_line);
                                    // OverPhege[n] = j;
                                }
                            }

                        }

                    }

                    else
                    {
                        jielieflag = false;
                    }

                    strLine2 = readLine2.ReadLine();
                }
                readLine2.Close();
                if (!lineflag)
                {
                    PSPDEV psperci = new PSPDEV();
                    string con = " WHERE Type='05' AND Name='" + tiaochuname + "'AND KSwitchStatus = '0' AND SUID in (select DeviceSUID from PSP_GprogElevice where GprogUID='" + GprogUID + "'and type='��·') ";
                    psperci= (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByCondition", con );
                    psperci.LineStatus = "�ȴ�";
                    Services.BaseService.Update<PSPDEV>(psperci);
                    ercilinedengdai.Add(psperci);
                    break;
                }
                else                  //û�г��ֹ�����
                    continue;
            }
            //����ӵ� �����¼���εȴ�����·û����ֹͣ��������� ��ʾ�Ͽ�����һ��Ҳû�г��ֹ�����
            if (ercilinedengdai.Count == 0)
            {
                return;
            }
            //�˹��������һ����·ʹ�䲻���ֹ�����

            fuhecheck(GprogUID,Type,ratacapality);
            for (int j = 0; j < linedengdai.Count; j++)
            {
                if (!Checkadd(GprogUID, Type, ratacapality,linedengdai[j].SUID))
                    return;
                N1Test.NBcal zl = new N1Test.NBcal();
                //zl.Show_KmRelia(1);
                zl.ZLpsp();

                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\DH1.txt"))
                {
                }
                else
                {
                    return;
                }
                dh = new FileStream(System.Windows.Forms.Application.StartupPath + "\\DH1.txt", FileMode.Open);

                readLine = new StreamReader(dh, Encoding.Default);
                charSplit = new char[] { ' ' };
                strLine = readLine.ReadLine();

                double sumpij = 0.0;
                bool lineflag = true;
                while (!string.IsNullOrEmpty(strLine))
                {
                    array1 = strLine.Split(charSplit);

                    string[] dev = new string[2];
                    dev.Initialize();
                    int i = 0;
                    PSPDEV CR = new PSPDEV();
                    //CR.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;

                    foreach (string str in array1)
                    {
                        if (str != "")
                        {
                            if (i == 0)
                            {
                                dev[i++] = str.ToString();
                            }
                            else
                            {
                                if (str != "NaN")
                                {
                                    dev[i++] = Convert.ToDouble(str).ToString();
                                }
                                else
                                {
                                    dev[i++] = str;
                                }

                            }
                        }

                    }
                    string con = " WHERE Type='05' AND Name='" + dev[0] + "'AND KSwitchStatus = '0' AND SUID in (select DeviceSUID from PSP_GprogElevice where GprogUID='" + GprogUID + "'and type='��·') ";
                    //string con = ",PSP_GprogElevice WHERE PSPDEV.Name='" + dev[0] + "' PSPDEV.SUID = PSP_GprogElevice.DeviceSUID AND PSP_GprogElevice.GprogUID = '" + GprogUID + "'AND PSPDEV.type='05'AND PSPDEV.KSwitchStatus = '0'";
                    CR = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByCondition",con);
                    if (CR != null && CR.ReferenceVolt != 0)
                    {
                        volt = CR.ReferenceVolt;
                    }
                    else
                        volt = standvolt;
                    current = capability / (Math.Sqrt(3) * volt);
                    if (CR != null && !CR.Name.Contains("������·"))
                    {

                        double linepij = Convert.ToDouble(dev[1]) * capability;
                        double voltR = CR.RateVolt;
                        double Ichange = (double)CR.Burthen;
                        double linXij = System.Math.Sqrt(3) * voltR * Ichange / 1000;
                        if (linepij >= linXij)
                        {
                            lineflag = false;

                            //sumpij += linepij;
                        }
                        for (int k = 0; k < fuheline.Count; k++)
                        {
                            if (CR.SUID == fuheline[k].Suid)
                            {
                                sumpij += System.Math.Abs(fuheline[k].linepij - linepij);
                            }
                        }
                        //
                        //    //output += "'" + CR.Name.ToString() + "," + (Convert.ToDouble(dev[3]) * capability).ToString() + "," + (Convert.ToDouble(dev[4]) * capability).ToString() + "," + (Convert.ToDouble(dev[5]) * capability).ToString() + "," + (Convert.ToDouble(dev[6]) * capability).ToString() + "," + (Convert.ToDouble(dev[7]) * current).ToString() + "," + (Convert.ToDouble(dev[8]) * Rad_to_Deg).ToString() + "," + dev[11] + "," + "\r\n";
                    }

                    strLine = readLine.ReadLine();
                }
                readLine.Close();
                //if (lineflag)              //���û�г��ֹ��������� ��ֹͣ���м���
                //{
                //    PSPDEV pspb = (PSPDEV)linedengdai[j];
                //    pspb.LineStatus = "����";
                //    Services.BaseService.Update<PSPDEV>(pspb);
                //    lineyiyou.Add(pspb);
                //    for (int i = 0; i < linedengdai.Count; i++)
                //    {
                //        if (linedengdai[i].SUID == pspb.SUID)
                //        {
                //            linedengdai.RemoveAt(j);
                //        }
                //    }
                //    return;
                //}
                //else
                //{
                //XmlNode el = tlVectorControl1.SVGDocument.SelectSingleNode("svg/polyline[@layer='" + tlVectorControl1.SVGDocument.CurrentLayer.ID + "' and @id='" + linedengdai[j].EleID + "']");
                double linevalue = 0;
                if (linedengdai[j].HuganTQ1!=0)
                {
                    linevalue = linedengdai[j].HuganTQ1;
                }
                else
                    linevalue = 1;
                linedaixuan linedai = new linedaixuan(linedengdai[j].Number, linedengdai[j].SUID, linedengdai[j].Name);
                linedai.linepij = sumpij;
                linedai.linevalue = linevalue;
                linedai.linetouzilv = sumpij / linevalue;

                waitlineindex.Add(linedai);
                //}

            }
            waitlineindex.Sort();
            //�ڴ˴����ָ��������· ������·��״̬��Ϊ ���в��������еļ��������¼ �ڵȴ��ļ����ォ����·ȥ�� ���½�����һ�ֵIJ���
            PSPDEV pspbianhua = new PSPDEV();
            if (waitlineindex.Count > 0)
            {
                pspbianhua.SUID = waitlineindex[waitlineindex.Count - 1].Suid;
            }
            else
            {
                //MessageBox.Show("û�г��ֹ����ɵ���·������鿴һ����·�����Ƿ��趨��ȷ��", "��ʾ", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            pspbianhua = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByKey", pspbianhua);
            pspbianhua.LineStatus = "����";
            Services.BaseService.Update<PSPDEV>(pspbianhua);
            lineyiyou.Add(pspbianhua);
            for (int i = 0; i < linedengdai.Count; i++)
            {
                if (linedengdai[i].SUID == pspbianhua.SUID)
                {
                    linedengdai.RemoveAt(i);
                }
            }
        }
コード例 #8
0
ファイル: ElectricWjgh.cs プロジェクト: EdgarEDT/myitoppsp
        /// <summary>
        ///���ɼ�� �ҵ����ֹ����ɵ���·��
        /// <param name="GprogUID">
        /// Ϊ�����Ż���ĿID
        /// </param>
        /// <param name="Type">
        /// Ϊ�Ǹ�ʱ�ڵ������Ż���1Ϊ���塢2���ڡ�3���ڡ�4Զ�ڣ�
        /// </param>
        /// </summary>
        public bool fuhecheck(string GprogUID,int Type,double ratacapality)
        {
            FileStream dh;
            StreamReader readLine;
            char[] charSplit;
            string strLine;
            string[] array1;
            char[] charSplit2 = new char[] { ' ' };

            fuheline.Clear();            //�����һ�εļ�¼  Ϊ��һ��ʱ�ڵ�Ӧ����׼��

            // linedengdai.Clear();          //�����һ�μ�¼��ѡ��· Ϊ��һ��ʱ�ڵ�Ӧ����׼��

            if (!Checkfuhe(GprogUID,Type,ratacapality))
                return true;
            N1Test.NBcal zl = new N1Test.NBcal();
            //zl.Show_KmRelia(1);
            zl.ZLpsp();

            double capability = 0, volt = 0, current = 0, standvolt = 0;
            capability = ratacapality;
            if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\DH1.txt"))
            {
            }
            else
            {
                return true;
            }
            dh = new FileStream(System.Windows.Forms.Application.StartupPath + "\\DH1.txt", FileMode.Open);

            readLine = new StreamReader(dh, Encoding.Default);
            charSplit = new char[] { ' ' };
            strLine = readLine.ReadLine();
            //output = null;
            //double sumpij = 0.0;
            bool lineflag = true;
            while (!string.IsNullOrEmpty(strLine))
            {
                array1 = strLine.Split(charSplit);

                string[] dev = new string[2];
                dev.Initialize();
                int i = 0;
                PSPDEV CR = new PSPDEV();
                //CR.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;

                foreach (string str in array1)
                {
                    if (str != "")
                    {
                        if (i == 0)
                        {
                            dev[i++] = str.ToString();
                        }
                        else
                        {
                            if (str != "NaN")
                            {
                                dev[i++] = Convert.ToDouble(str).ToString();
                            }
                            else
                            {
                                dev[i++] = str;
                            }

                        }
                    }

                }
                string con = " WHERE Type='05' AND Name='" + dev[0] + "'AND KSwitchStatus = '0' AND SUID in (select DeviceSUID from PSP_GprogElevice where GprogUID='" + GprogUID + "'and type='��·') ";
               // string con = ",PSP_GprogElevice WHERE PSPDEV.Name='" + dev[0] + "' PSPDEV.SUID = PSP_GprogElevice.DeviceSUID AND PSP_GprogElevice.GprogUID = '" + GprogUID + "'AND PSPDEV.type='05'AND PSPDEV.KSwitchStatus = '0'";
                CR = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByCondition", con);

                if (CR != null && CR.ReferenceVolt != 0)
                {
                    volt = CR.ReferenceVolt;
                }
                else
                    volt = standvolt;
                current = capability / (Math.Sqrt(3) * volt);
                if (CR != null && !CR.Name.Contains("������·"))
                {

                    double linepij = System.Math.Abs(Convert.ToDouble(dev[1])) * ratacapality;
                    double voltR = CR.RateVolt;
                    double Ichange = (double)CR.Burthen;

                    double linXij = System.Math.Sqrt(3) * voltR * Ichange / 1000;
                    if (linepij >= linXij)
                    {
                        lineflag = false;
                        linedaixuan ld = new linedaixuan(CR.Number, CR.SUID, CR.Name);
                        ld.linepij = linepij;
                        fuheline.Add(ld);

                    }

                    //
                    //    //output += "'" + CR.Name.ToString() + "," + (Convert.ToDouble(dev[3]) * capability).ToString() + "," + (Convert.ToDouble(dev[4]) * capability).ToString() + "," + (Convert.ToDouble(dev[5]) * capability).ToString() + "," + (Convert.ToDouble(dev[6]) * capability).ToString() + "," + (Convert.ToDouble(dev[7]) * current).ToString() + "," + (Convert.ToDouble(dev[8]) * Rad_to_Deg).ToString() + "," + dev[11] + "," + "\r\n";
                }
                strLine = readLine.ReadLine();
            }
            readLine.Close();
            return lineflag;
        }