예제 #1
0
        //复数加法运算
        public complex complex_add(complex c)
        {
            //取得加法运算后的实部
            double complex_real = this.complex_real + c.complex_real;

            //取得加法运算后的虚部
            double complex_imagin = this.complex_imagin + c.complex_imagin;

            //返回一个复数类
            return new complex(complex_real, complex_imagin);
        }
예제 #2
0
        //复数减法运算
        public complex complex_minus(complex c)
        {
            //取得减法运算后的实部
            double complex_real = this.complex_real - c.complex_real;

            //取得减法运算后的虚部
            double complex_imagin = this.complex_imagin - c.complex_imagin;

            //返回一个复数类
            return new complex(complex_real, complex_imagin);
        }
예제 #3
0
        //乘法运算
        public complex complex_multi(complex c)
        {
            //取得乘法运算后的实部
            double complex_real = this.complex_real * c.complex_real - this.complex_imagin * c.complex_imagin;

            //取得乘法运算后的虚部
            double complex_imagin = this.complex_real * c.complex_imagin + this.complex_imagin * c.complex_real;

            //返回一个复数类
            return(new complex(complex_real, complex_imagin));
        }
예제 #4
0
        //复数减法运算
        public complex complex_minus(complex c)
        {
            //取得减法运算后的实部
            double complex_real = this.complex_real - c.complex_real;

            //取得减法运算后的虚部
            double complex_imagin = this.complex_imagin - c.complex_imagin;

            //返回一个复数类
            return(new complex(complex_real, complex_imagin));
        }
예제 #5
0
        //复数加法运算
        public complex complex_add(complex c)
        {
            //取得加法运算后的实部
            double complex_real = this.complex_real + c.complex_real;

            //取得加法运算后的虚部
            double complex_imagin = this.complex_imagin + c.complex_imagin;

            //返回一个复数类
            return(new complex(complex_real, complex_imagin));
        }
예제 #6
0
        //除法运算结果 (a+bi)/(c+di)=(a+bi)(c-di)/(c+di)(c-di)
        public complex complex_divide(complex c)
        {
            //取得(c+di)(c-di)的值
            double d = c.complex_real * c.complex_real + c.complex_imagin * c.complex_imagin;

            //取得除法运算后的实部
            double complex_real = (this.complex_real * c.complex_real + this.complex_imagin * c.complex_imagin) / d;

            //取得除法运算后的虚部
            double complex_imagin = (this.complex_real * (-c.complex_imagin) + this.complex_imagin * c.complex_real) / d;

            //返回一个复数类
            return new complex(complex_real, complex_imagin);
        }
예제 #7
0
        //除法运算结果 (a+bi)/(c+di)=(a+bi)(c-di)/(c+di)(c-di)
        public complex complex_divide(complex c)
        {
            //取得(c+di)(c-di)的值
            double d = c.complex_real * c.complex_real + c.complex_imagin * c.complex_imagin;

            //取得除法运算后的实部
            double complex_real = (this.complex_real * c.complex_real + this.complex_imagin * c.complex_imagin) / d;

            //取得除法运算后的虚部
            double complex_imagin = (this.complex_real * (-c.complex_imagin) + this.complex_imagin * c.complex_real) / d;

            //返回一个复数类
            return(new complex(complex_real, complex_imagin));
        }
예제 #8
0
        public bool DFS(IList branchlist, IList buslist, string projectSUID, float ratedCapacity)
        {
            string strCon1 = ",PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + projectSUID + "'";
            string strCon2 = null;
            string strCon = null;

            double Rad_to_Deg = 180 / Math.PI;
            double Deg_to_Rad = Math.PI / 180;

            strCon2 = " AND Type = '01'";
            strCon = strCon1 + strCon2;
            IList listMX = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon);
            strCon2 = " AND Type = '05'";
            strCon = strCon1 + strCon2;
            IList listXL = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon);
            strCon2 = " AND Type = '02'";
            strCon = strCon1 + strCon2;
            IList listBYQ2 = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon);
            strCon2 = " AND Type = '03'";
            strCon = strCon1 + strCon2;
            IList listBYQ3 = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon);

            foreach (PSPDEV devBUS in buslist)
            {
                ArrayList listLine = new ArrayList();
                ArrayList listLineTemp = new ArrayList();
                IList listBusTxt = new List<PSPDEV>();
                bool visited = false;
                foreach (PSPDEV line in listXL)
                {
                    if (line.FirstNode == devBUS.Number && !branchlist.Contains(line))
                    {
                        if (visited == false)
                        {
                            visited = true;
                            listLine.Add(line);
                        }
                        else if (visited == true)
                        {
                            listLineTemp.Add(line);
                        }
                    }
                }
                PSPDEV lineTemp = new PSPDEV();
                if (listLineTemp.Count > 0)
                {
                    lineTemp = (PSPDEV)listLineTemp[listLineTemp.Count - 1];
                }
                else
                {
                    lineTemp = (PSPDEV)listLine[listLine.Count - 1];
                }
                bool dFlag = true;
                bool flag = true;
                while ((lineTemp.LastNode > 0 && !branchlist.Contains(lineTemp)) || dFlag)
                {
                    bool TFlag = false;
                    foreach (PSPDEV lineDEV in branchlist)
                    {
                        if (lineDEV.SUID == lineTemp.SUID)
                        {
                            TFlag = true;
                        }
                    }
                    if (TFlag == true)
                    {
                        break;
                    }
                    flag = true;
                    while (flag)
                    {
                        visited = false;
                        flag = false;
                        lineTemp = (PSPDEV)listLine[listLine.Count - 1];
                        foreach (PSPDEV line in listXL)
                        {

                            if (line.FirstNode == lineTemp.LastNode && !branchlist.Contains(line.SUID))
                            {
                                bool cFlag = false;
                                foreach (PSPDEV lineDEV in branchlist)
                                {
                                    if (lineDEV.SUID == line.SUID)
                                    {
                                        cFlag = true;
                                    }
                                }
                                if (cFlag == true)
                                {
                                    continue;
                                }
                                flag = true;
                                if (visited == false)
                                {
                                    visited = true;
                                    listLine.Add(line);
                                }
                                else if (visited == true)
                                {
                                    listLineTemp.Add(line);
                                }
                            }
                        }
                    }
                    dFlag = false;
                    if (listLineTemp.Count > 0)
                    {
                        lineTemp = (PSPDEV)listLineTemp[listLineTemp.Count - 1];
                        if (!branchlist.Contains(lineTemp))
                        {
                            listLine.Add(lineTemp);
                        }
                        listLineTemp.Remove(lineTemp);
                    }
                    else
                    {
                        lineTemp = new PSPDEV();
                    }
                }
                listBusTxt.Add(devBUS);
                foreach (PSPDEV busDEV in listMX)
                {
                    foreach (PSPDEV lineD in listLine)
                    {
                        if (busDEV.Number == lineD.LastNode)
                        {
                            listBusTxt.Add(busDEV);
                        }
                    }
                }
                string strData = null;
                string strBus = null;
                string strBranch = null;
                foreach (PSPDEV dev in listLine)
                {
                    if (dev.KSwitchStatus == "0")
                    {
                        if (strBranch != null)
                        {
                            strBranch += "\r\n";
                        }
                        if (strData != null)
                        {
                            strData += "\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";
                            //strData += (dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + "0" + " " + (dev.LineR).ToString() + " " + (dev.LineTQ).ToString() + " " + (dev.LineGNDC).ToString() + " " + "0" + " " + dev.Name.ToString());
                        }
                        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";
                            //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());
                        }
                    }
                }
                foreach (PSPDEV dev in listBYQ2)
                {
                    if (dev.KSwitchStatus == "0")
                    {
                        if (strBranch != null)
                        {
                            strBranch += "\r\n";
                        }
                        if (strData != null)
                        {
                            //strData += "\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();
                            // strData += (dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + "1" + " " + (dev.LineR).ToString() + " " + (dev.LineTQ).ToString() + " " + (dev.K).ToString() + " " + dev.G.ToString() + " " + dev.Name.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();
                            // strData += (dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + "1" + " " + (dev.LineR * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.LineTQ * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.K.ToString()).ToString() + " " + dev.G.ToString() + " " + dev.Name.ToString());
                        }
                    }
                }
                foreach (PSPDEV dev in listBYQ3)
                {
                    if (dev.KSwitchStatus == "0")
                    {

                        if (strData != null)
                        {
                            // strData += "\r\n";
                        }
                        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();
                            //strData += (dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + "1" + " " + (dev.HuganTQ1).ToString() + " " + (dev.HuganTQ4).ToString() + " " + (dev.K).ToString() + " " + "0" + " " + dev.Name.ToString());
                            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();
                            //strData += (dev.LastNode.ToString() + " " + dev.Flag.ToString() + " " + "1" + " " + (dev.HuganTQ2).ToString() + " " + (dev.HuganTQ5).ToString() + " " + (dev.StandardCurrent).ToString() + " " + "0" + " " + dev.Name.ToString());
                            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();
                            //strData += (dev.FirstNode.ToString() + " " + dev.Flag.ToString() + " " + "1" + " " + (dev.HuganTQ3).ToString() + " " + (dev.HuganFirst).ToString() + " " + (dev.BigP).ToString() + " " + "0" + " " + dev.Name.ToString());

                        }
                        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();
                            // strData += (dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + "1" + " " + (dev.HuganTQ1 * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.HuganTQ4 * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.K).ToString() + " " + "0" + " " + dev.Name.ToString());
                            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();
                            //strData += (dev.LastNode.ToString() + " " + dev.Flag.ToString() + " " + "1" + " " + (dev.HuganTQ2 * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.HuganTQ5 * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.StandardCurrent).ToString() + " " + "0" + " " + dev.Name.ToString());
                            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();
                            //strData += (dev.FirstNode.ToString() + " " + dev.Flag.ToString() + " " + "1" + " " + (dev.HuganTQ3 * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + ((float)dev.HuganFirst * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.BigP).ToString() + " " + "0" + " " + dev.Name.ToString());
                        }
                    }
                }
                foreach (PSPDEV dev in listBusTxt)
                {
                    if (dev.KSwitchStatus == "0")
                    {
                        if (strBus != null)
                        {
                            strBus += "\r\n";
                        }
                        if (strData != null)
                        {
                            //strData += "\r\n";
                        }
                        if (dev.UnitFlag == "0")
                        {
                            strBus += (dev.Number.ToString() + " " + dev.Name.ToString() + " " + MXNodeType(dev.NodeType) + " " + (dev.VoltR).ToString() + " " + dev.VoltV.ToString() + " " + ((dev.InPutP - dev.OutP)).ToString() + " " + ((dev.InPutQ - dev.OutQ)).ToString());
                            //strData += (dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + "0" + " " + (dev.LineR).ToString() + " " + (dev.LineTQ).ToString() + " " + (dev.LineGNDC).ToString() + " " + "0" + " " + dev.Name.ToString());
                            //if (dev.NodeType == "1")
                            //{
                            //    strData += (dev.Number.ToString() + " " + dev.Name.ToString() + " " + dev.NodeType + " " + ((dev.OutP)).ToString() + " " + ((dev.OutQ)).ToString());
                            //}
                            //else if (dev.NodeType == "2")
                            //{
                            //    strData += (dev.Number.ToString() + " " + dev.Name.ToString() + " " + dev.NodeType + " " + ((dev.OutP)).ToString() + " " + (dev.VoltR / dev.ReferenceVolt).ToString());
                            //}
                            //else if (dev.NodeType == "0")
                            //{
                            //    strData += (dev.Number.ToString() + " " + dev.Name.ToString() + " " + dev.NodeType + " " + (dev.VoltR / dev.ReferenceVolt).ToString() + " " + "0");
                            //}
                        }
                        else
                        {
                            strBus += (dev.Number.ToString() + " " + dev.Name.ToString() + " " + MXNodeType(dev.NodeType) + " " + (dev.VoltR / dev.ReferenceVolt).ToString() + " " + dev.VoltV.ToString() + " " + ((dev.InPutP - dev.OutP) / ratedCapacity).ToString() + " " + ((dev.InPutQ - dev.OutQ) / ratedCapacity).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());
                            //if (dev.NodeType == "1")
                            //{
                            //    strData += (dev.Number.ToString() + " " + dev.Name.ToString() + " " + dev.NodeType + " " + ((dev.OutP) / ratedCapacity).ToString() + " " + ((dev.OutQ) / ratedCapacity).ToString());
                            //}
                            //else if (dev.NodeType == "2")
                            //{
                            //    strData += (dev.Number.ToString() + " " + dev.Name.ToString() + " " + dev.NodeType + " " + ((dev.OutP) / ratedCapacity).ToString() + " " + (dev.VoltR / dev.ReferenceVolt).ToString());
                            //}
                            //else if (dev.NodeType == "0")
                            //{
                            //    strData += (dev.Number.ToString() + " " + dev.Name.ToString() + " " + dev.NodeType + " " + (dev.VoltR / dev.ReferenceVolt).ToString() + " " + "0");
                            //}
                        }
                    }
                }
                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 (strBus.Contains("非数字") || strBus.Contains("正无穷大") || strBranch.Contains("非数字") || strBranch.Contains("正无穷大"))
                {
                    MessageBox.Show("缺少参数,请检查输入参数!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return false;
                }
                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\PF1.txt"))
                {
                    File.Delete(System.Windows.Forms.Application.StartupPath + "\\PF1.txt");
                }
                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\DH1.txt"))
                {
                    File.Delete(System.Windows.Forms.Application.StartupPath + "\\DH1.txt");
                }
                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\IH1.txt"))
                {
                    File.Delete(System.Windows.Forms.Application.StartupPath + "\\IH1.txt");
                }
                DisFlowCal disf = new DisFlowCal();
                disf.CurrentCal(1);
                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\PF1.txt"))
                {
                }
                else
                {
                    return false;
                }
                FileStream pf = new FileStream(System.Windows.Forms.Application.StartupPath + "\\PF1.txt", FileMode.Open);
                StreamReader readLine = new StreamReader(pf, Encoding.Default);
                char[] charSplit = new char[] { ' ' };
                string strLine = readLine.ReadLine();
                while (strLine != null && strLine != "")
                {
                    string[] array1 = strLine.Split(charSplit);
                    strCon2 = " AND Type= '01' AND Number = " + array1[0];
                    strCon = strCon1 + strCon2;
                    PSPDEV devMX = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByCondition", strCon);
                    if (devMX != null)
                    {
                        PSP_ElcDevice elcDev = new PSP_ElcDevice();
                        elcDev.ProjectSUID = projectSUID;
                        elcDev.DeviceSUID = devMX.SUID;
                        elcDev = (PSP_ElcDevice)Services.BaseService.GetObject("SelectPSP_ElcDeviceByKey", elcDev);
                        if (elcDev != null)
                        {
                            elcDev.COL1 = devMX.Name;
                            elcDev.COL19 = devMX.ReferenceVolt.ToString();
                            elcDev.COL20 = ratedCapacity.ToString();
                            double temp = 0.0;
                            double.TryParse(array1[1], out temp);
                            elcDev.COL2 = (temp * (devMX.ReferenceVolt)).ToString();
                            temp = 0.0;
                            double.TryParse(array1[2], out temp);
                            elcDev.COL3 = (temp * Rad_to_Deg).ToString();
                            temp = 0.0;
                            double.TryParse(array1[3], out temp);
                            elcDev.COL4 = (temp * ratedCapacity).ToString();
                            temp = 0.0;
                            double.TryParse(array1[4], out temp);
                            elcDev.COL5 = (temp * ratedCapacity).ToString();

                            Services.BaseService.Update<PSP_ElcDevice>(elcDev);
                        }
                    }
                    strLine = readLine.ReadLine();
                }
                readLine.Close();
                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\DH1.txt"))
                {
                }
                else
                {
                    return false;
                }
                FileStream dh = new FileStream(System.Windows.Forms.Application.StartupPath + "\\DH1.txt", FileMode.Open);
                readLine = new StreamReader(dh, Encoding.Default);
                strLine = readLine.ReadLine();
                while (strLine != null && strLine != "")
                {
                    string[] array1 = strLine.Split(charSplit);
                    strCon2 = " AND Type= '05' AND Name = '" + array1[0] + "' AND FirstNode = " + array1[1] + " AND LastNode = " + array1[2];
                    strCon = strCon1 + strCon2;
                    PSPDEV devMX = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByCondition", strCon);
                    if (devMX != null)
                    {
                        PSP_ElcDevice elcDev = new PSP_ElcDevice();
                        elcDev.ProjectSUID = projectSUID;
                        elcDev.DeviceSUID = devMX.SUID;
                        elcDev = (PSP_ElcDevice)Services.BaseService.GetObject("SelectPSP_ElcDeviceByKey", elcDev);
                        if (elcDev != null)
                        {
                            elcDev.COL1 = devMX.Name;
                            elcDev.COL2 = devMX.FirstNode.ToString();
                            elcDev.COL3 = devMX.LastNode.ToString();
                            elcDev.COL19 = devMX.ReferenceVolt.ToString();
                            if (Convert.ToDouble(devMX.Burthen) ==0.0)
                            {
                                elcDev.COL20 = ratedCapacity.ToString();
                            }
                            else
                                elcDev.COL20 = devMX.Burthen.ToString();

                            double temp = 0.0;
                            double.TryParse(array1[3], out temp);
                            elcDev.COL4 = (temp * ratedCapacity).ToString();
                            temp = 0.0;
                            double.TryParse(array1[4], out temp);
                            elcDev.COL5 = (temp * ratedCapacity).ToString();
                            temp = 0.0;
                            double.TryParse(array1[5], out temp);
                            elcDev.COL6 = (temp * ratedCapacity).ToString();
                            temp = 0.0;
                            double.TryParse(array1[6], out temp);
                            elcDev.COL7 = (temp * ratedCapacity).ToString();

                            temp = 0.0;
                            double.TryParse(array1[7], out temp);
                            elcDev.COL8 = (temp * ratedCapacity).ToString();
                            temp = 0.0;
                            double.TryParse(array1[8], out temp);
                            elcDev.COL9 = (temp * ratedCapacity).ToString();
                            temp = 0.0;
                            double.TryParse(array1[9], out temp);
                            elcDev.COL10 = (temp * ratedCapacity / (Math.Sqrt(3) * devMX.ReferenceVolt)).ToString();

                            temp = 0.0;
                            double.TryParse(array1[10], out temp);
                            elcDev.COL11 = (temp * Rad_to_Deg).ToString();
                            temp = 0.0;
                            double.TryParse(array1[11], out temp);
                            elcDev.COL12 = (temp * (devMX.ReferenceVolt)).ToString();
                            temp = 0.0;
                            double.TryParse(array1[12], out temp);
                            elcDev.COL13 = (temp * (devMX.ReferenceVolt)).ToString();
                            PSP_ElcDevice elcTemp = (PSP_ElcDevice)Services.BaseService.GetObject("SelectPSP_ElcDeviceByKey", elcDev);

                            Services.BaseService.Update<PSP_ElcDevice>(elcDev);
                        }
                    }
                    strLine = readLine.ReadLine();
                }
                readLine.Close();
                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\IH1.txt"))
                {
                }
                else
                {
                    return false;
                }
                FileStream ih = new FileStream(System.Windows.Forms.Application.StartupPath + "\\IH1.txt", FileMode.Open);
                readLine = new StreamReader(ih, Encoding.Default);
                strLine = readLine.ReadLine();
                while (strLine != null && strLine != "")
                {
                    string[] array1 = strLine.Split(charSplit);
                    strCon2 = " AND Type= '05' AND Name = '" + array1[0] + "' AND FirstNode = " + array1[1] + " AND LastNode = " + array1[2];
                    strCon = strCon1 + strCon2;
                    PSPDEV devMX = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByCondition", strCon);
                    if (devMX != null)
                    {
                        PSP_ElcDevice elcDev = new PSP_ElcDevice();
                        elcDev.ProjectSUID = projectSUID;
                        elcDev.DeviceSUID = devMX.SUID;
                        elcDev = (PSP_ElcDevice)Services.BaseService.GetObject("SelectPSP_ElcDeviceByKey", elcDev);
                        if (elcDev != null)
                        {
                            elcDev.COL1 = devMX.Name;
                            elcDev.COL2 = devMX.FirstNode.ToString();
                            elcDev.COL3 = devMX.LastNode.ToString();
                            elcDev.COL19 = devMX.ReferenceVolt.ToString();
                            if (Convert.ToDouble(devMX.Burthen) == 0.0)
                            {
                                elcDev.COL20 = ratedCapacity.ToString();
                            }
                            else
                                elcDev.COL20 = devMX.Burthen.ToString();
                            double temp = 0.0;
                            double.TryParse(array1[3], out temp);
                            elcDev.COL14 = (temp * ratedCapacity / (Math.Sqrt(3) * devMX.ReferenceVolt)).ToString();
                            temp = 0.0;
                            double.TryParse(array1[4], out temp);
                            elcDev.COL15 = (temp * Rad_to_Deg).ToString();
                            PSP_ElcDevice elcTemp = (PSP_ElcDevice)Services.BaseService.GetObject("SelectPSP_ElcDeviceByKey", elcDev);

                            Services.BaseService.Update<PSP_ElcDevice>(elcDev);
                        }
                    }
                    strLine = readLine.ReadLine();
                }
                readLine.Close();
            }
            foreach (PSPDEV devLine in branchlist)
            {
                PSP_ElcDevice elcDev = new PSP_ElcDevice();
                elcDev.ProjectSUID = projectSUID;
                elcDev.DeviceSUID = devLine.SUID;
                elcDev = (PSP_ElcDevice)Services.BaseService.GetObject("SelectPSP_ElcDeviceByKey", elcDev);
                strCon2 = " AND Type= '01' AND Number = " + devLine.FirstNode;
                strCon = strCon1 + strCon2;
                PSPDEV devMXI = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByCondition", strCon);

                PSP_ElcDevice elcDevi = new PSP_ElcDevice();
                elcDevi.ProjectSUID = projectSUID;
                elcDevi.DeviceSUID = devMXI.SUID;
                elcDevi = (PSP_ElcDevice)Services.BaseService.GetObject("SelectPSP_ElcDeviceByKey", elcDevi);

                strCon2 = " AND Type= '01' AND Number = " + devLine.LastNode;
                strCon = strCon1 + strCon2;
                PSPDEV devMXJ = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByCondition", strCon);

                PSP_ElcDevice elcDevj = new PSP_ElcDevice();
                elcDevj.ProjectSUID = projectSUID;
                elcDevj.DeviceSUID = devMXJ.SUID;
                elcDevj = (PSP_ElcDevice)Services.BaseService.GetObject("SelectPSP_ElcDeviceByKey", elcDevj);
                complex Vi = new complex((Convert.ToDouble(GetColValue(elcDevi, 0).COL2) / devMXI.ReferenceVolt) * Math.Sin(Convert.ToDouble(GetColValue(elcDevi, 0).COL3) * Deg_to_Rad), (Convert.ToDouble(GetColValue(elcDevi, 0).COL2) / devMXI.ReferenceVolt) * Math.Cos(Convert.ToDouble(GetColValue(elcDevi, 0).COL3) * Deg_to_Rad));
                complex Vj = new complex((Convert.ToDouble(GetColValue(elcDevj, 0).COL2) / devMXJ.ReferenceVolt) * Math.Sin(Convert.ToDouble(GetColValue(elcDevj, 0).COL3) * Deg_to_Rad), (Convert.ToDouble(GetColValue(elcDevj, 0).COL2) / devMXJ.ReferenceVolt) * Math.Cos(Convert.ToDouble(GetColValue(elcDevj, 0).COL3) * Deg_to_Rad));
                complex Iij;
                complex Iji;
                if (devLine.UnitFlag == "0")
                {
                    Iij = (Vi.complex_minus(Vj)).complex_divide(new complex(devLine.LineR, devLine.LineTQ));
                    Iji = (Vj.complex_minus(Vi)).complex_divide(new complex(devLine.LineR, devLine.LineTQ));
                }
                else
                {
                    Iij = (Vi.complex_minus(Vj)).complex_divide(new complex(devLine.LineR * ratedCapacity / (devLine.ReferenceVolt * devLine.ReferenceVolt), devLine.LineTQ * ratedCapacity / (devLine.ReferenceVolt * devLine.ReferenceVolt)));
                    Iji = (Vj.complex_minus(Vi)).complex_divide(new complex(devLine.LineR * ratedCapacity / (devLine.ReferenceVolt * devLine.ReferenceVolt), devLine.LineTQ * ratedCapacity / (devLine.ReferenceVolt * devLine.ReferenceVolt)));
                }

                complex Pij = Vi.complex_multi(Iij);
                complex Pji = Vj.complex_multi(Iji);

                if (elcDev != null)
                {
                    elcDev.COL1 = devLine.Name;
                    elcDev.COL2 = devLine.FirstNode.ToString();
                    elcDev.COL3 = devLine.LastNode.ToString();
                    elcDev.COL19 = devLine.ReferenceVolt.ToString();
                    elcDev.COL20 = ratedCapacity.ToString();

                    elcDev.COL4 = (Pij.Real * ratedCapacity).ToString();
                    elcDev.COL5 = (Pij.Image * ratedCapacity).ToString();

                    elcDev.COL6 = ((Pij.Real - Pji.Real) * ratedCapacity).ToString();
                    elcDev.COL7 = ((Pij.Image - Pij.Image) * ratedCapacity).ToString();

                    elcDev.COL8 = (Pji.Real * ratedCapacity).ToString();

                    elcDev.COL9 = (Pji.Image * ratedCapacity).ToString();

                    elcDev.COL12 = GetColValue(elcDevi, 0).COL2;

                    elcDev.COL13 = GetColValue(elcDevj, 0).COL2;

                    elcDev.COL14 = (Math.Sqrt(Iij.Real * Iij.Real + Iij.Image * Iij.Image) * ratedCapacity / (Math.Sqrt(3) * devLine.ReferenceVolt)).ToString();

                    elcDev.COL15 = (Math.Atan(Iij.Image / Iij.Real) * Rad_to_Deg).ToString();
                    PSP_ElcDevice elcTemp = (PSP_ElcDevice)Services.BaseService.GetObject("SelectPSP_ElcDeviceByKey", elcDev);

                    Services.BaseService.Update<PSP_ElcDevice>(elcDev);
                }
            }
            return true;
        }
예제 #9
0
        //乘法运算
        public complex complex_multi(complex c)
        {
            //取得乘法运算后的实部
            double complex_real = this.complex_real * c.complex_real - this.complex_imagin * c.complex_imagin;

            //取得乘法运算后的虚部
            double complex_imagin = this.complex_real * c.complex_imagin + this.complex_imagin * c.complex_real;

            //返回一个复数类
            return new complex(complex_real, complex_imagin);
        }