示例#1
0
        private BladedData GetBladedResults(string filePath, string resultType)//打开文件获取数据结果
        {
            BladedData result = new BladedData();

            if (filePath == String.Empty)
            {
                Console.WriteLine("File path is null!");
            }
            var mode = CheckBladedResultType(resultType);

            switch (mode)
            {
            case 0:
                result.ultimateLoads = GetUltimateLoadsResultsFromFile(filePath).ultimateLoads;
                break;

            case 1:
                result.equivalentFatigueLoads = GetEquivalentFatigueLoadsResultsFromFile(filePath).equivalentFatigueLoads;
                break;

            default:
                Console.WriteLine("CheckBladedResultType error!");
                break;
            }
            return(result);
        }
示例#2
0
        private string[,] GetFormatResult(string filePath, string[] header, string resultsType)//格式化excel输出数据
        {
            if (resultsType == "UltimateLoads")
            {
                BladedData brResults = new BladedData();
                string[,] brArrary = new string[9, 5];
                brResults          = GetBladedResults(filePath, resultsType);//"EquivalentFatigueLoads"
                string[,] temp     = brResults.ultimateLoads.arrayResults;

                for (int i = 1; i < 9; i++)//提取工况和载荷
                {
                    string   maxmum = temp[2 * (i - 1), i];
                    string   dlc1   = temp[2 * (i - 1), 0];
                    string   minmum = temp[2 * (i - 1) + 1, i];
                    string   dlc2   = temp[2 * (i - 1) + 1, 0];
                    string[] row    = ComparisionStringNumValue(filePath, maxmum, minmum, dlc1, dlc2, header[i - 1]);
                    for (int j = 0; j < 4; j++)
                    {
                        brArrary[i - 1, j] = row[j];
                    }
                }
                return(brArrary);
            }
            if (resultsType == "EquivalentFatigueLoads")
            {
                BladedData brResults = new BladedData();
                string[,] formatToExcelResult = new string[12, 13];
                brResults      = GetBladedResults(filePath, resultsType);//"EquivalentFatigueLoads"
                string[,] temp = brResults.equivalentFatigueLoads.arrayResults;

                for (int j = 0; j < 7; j++)//添加表头
                {
                    formatToExcelResult[0, j] = header[j];
                }
                for (int i = 0; i < 11; i++)
                {
                    if (i < 1)
                    {
                        formatToExcelResult[i, 0] = "m";
                    }
                    else
                    {
                        formatToExcelResult[i, 0] = (i + 2).ToString();
                    }
                }
                for (int i = 0; i < 6; i++)//添加内容
                {
                    for (int j = 0; j < 10; j++)
                    {
                        formatToExcelResult[j + 1, i + 1] = (Convert.ToSingle(temp[j, i]) / 1000.0f).ToString("G5");
                    }
                }
                return(formatToExcelResult);
            }
            else
            {
                return(null);
            }
        }
示例#3
0
 private void InitialBladedDataOperation()
 {
     br = new BladedData();
     hr = new BladedData();
     hs = new BladedData();
     tt = new BladedData();
     tb = new BladedData();
 }
示例#4
0
        void SaveAsExcelFile(BladedData b)
        {
            var dir      = Directory.GetCurrentDirectory();
            var filePath = dir + "\\" + b.turbineMainCompenontResult.turbineID + "-" + "Comparison" + DateTime.Today.ToString("yyyyMMdd") + ".xlsx";

            wb.SaveAs(filePath);
//            app.Quit();
        }
示例#5
0
        //public string[,] GetFormatBladeRootUltimateLoadsResult(string filePath)
        //{
        //    return GetFormatUltimateLoadsResult(filePath, headerU1);
        //}

        //public string[,] GetFormatStationHubUltimateLoadsResult(string filePath)
        //{
        //    return GetFormatUltimateLoadsResult(filePath, headerU2);
        //}

        //public string[,] GetFormatRotorHubUltimateLoadsResult(string filePath)
        //{
        //    return GetFormatUltimateLoadsResult(filePath, headerU2);
        //}

        //public string[,] GetFormatTowerTopUltimateLoadsResult(string filePath)
        //{
        //    return GetFormatUltimateLoadsResult(filePath, headerU1);
        //}

        //public string[,] GetTowerBaseUltimateLoadResult(string filePath)
        //{
        //    return GetFormatUltimateLoadsResult(filePath, headerU1);
        //}

        //private string[,] GetFormatEquivalentFatigueLoadsResult(string filePath, string[] header)
        //{
        //    string[,] formatToExcelResult = new string[11, 7];
        //    string[,] temp = GetEquivalentFatigueLoadsResultsFromFile(filePath).equivalentFatigueLoads.arrayResults;

        //    for(int j=0; j<7; j++)//添加表头
        //    {
        //        formatToExcelResult[0, j] = header[j];
        //    }
        //    for(int i=0; i<7; i++)//添加内容
        //    {
        //        for(int j=0; j<10; j++)
        //        {
        //            formatToExcelResult[j + 1, i] = temp[j, i];
        //        }
        //    }
        //    return formatToExcelResult;
        //}

        //public string[,] GetFormatBladedRootEquivalentFatigueLoadsResult(string filePath)
        //{
        //    return GetFormatEquivalentFatigueLoadsResult(filePath, headerF);
        //}

        //public string[,] GetFormatRotorHubEquivalentFatigueLoadsResult(string filePath)
        //{
        //    return GetFormatEquivalentFatigueLoadsResult(filePath, headerF);
        //}

        //public string[,] GetFormatStationHubEquivalentFatigueLoadsResult(string filePath)
        //{
        //    return GetFormatEquivalentFatigueLoadsResult(filePath, headerF);
        //}

        //public string[,] GetFormatTowerTopEquivalentFatigueLoadsResult(string filePath)
        //{
        //    return GetFormatEquivalentFatigueLoadsResult(filePath, headerF);
        //}

        //public string[,] GetFormatTowerBaseEquivalentFatigueLoadsResult(string filePath)
        //{
        //    return GetFormatEquivalentFatigueLoadsResult(filePath, headerF);
        //}

        public List <BladedData> GetMainCompinentLoadsResult(List <BladedData> bladedPath)
        {
            List <BladedData> bladedDlist = new List <BladedData>();

            foreach (var dd in bladedPath)  //打开每个地址文件读取各部件的地址
            {
                BladedData bladedDataTemp = new BladedData();
                bladedDataTemp.ultimateLoads.path                   = dd.ultimateLoads.path;
                bladedDataTemp.equivalentFatigueLoads.path          = dd.equivalentFatigueLoads.path;
                bladedDataTemp.turbineMainCompenontResult.turbineID = dd.turbineMainCompenontResult.turbineID;

                var ComponentU = dd.turbineMainCompenontResult.results.ultmateData.component;
                var ComponentF = dd.turbineMainCompenontResult.results.equivalentFatigueData.component;
                foreach (var dic in ComponentU)
                {
                    dic.variableHeader = new string[headerU1.Length, 1];
                    if ((dic.name.Contains("Blade") || dic.name.Contains("Tower")))
                    {
                        int h = 0;
                        foreach (string hh in headerU1)
                        {
                            dic.variableHeader[h++, 0] = hh;
                        }
                        dic.resultMatrix = this.GetFormatResult(dic.path, headerU1, "UltimateLoads");
                    }

                    else if (dic.name.Contains("Hub"))
                    {
                        int h = 0;
                        foreach (string hh in headerU2)
                        {
                            dic.variableHeader[h++, 0] = hh;
                        }
                        dic.resultMatrix = this.GetFormatResult(dic.path, headerU2, "UltimateLoads");
                    }

                    else
                    {
                        Console.WriteLine("GetMainCompinentLoadsResult error!");
                    }
                    dic.mainDlcData = GetEachDlcMaxValueFromMainCom(dic); //向部件数据中添加热力图数据源
                    bladedDataTemp.turbineMainCompenontResult.results.ultmateData.component.Add(GetMatrixMaxValue(dic));
                }
                //疲劳载荷
                foreach (var dic in ComponentF)
                {
                    dic.resultMatrix = this.GetFormatResult(dic.path, headerF, "EquivalentFatigueLoads");
                    bladedDataTemp.turbineMainCompenontResult.results.equivalentFatigueData.component.Add(dic);
                }
                bladedDlist.Add(bladedDataTemp);
            }
            return(bladedDlist);
        }
示例#6
0
        private BladedData GetEquivalentFatigueLoadsResultsFromFile(string filePath)
        {
            BladedData results = new BladedData();

            string[,] dataResults = new string[10, 6];
            var fileNameTemp = Path.GetFileNameWithoutExtension(Directory.GetFiles(filePath, "*.$PJ")[0]);
            var filePathTemp = filePath + "\\" + fileNameTemp + ".$EQ";

            if (filePathTemp.Length <= 1 || !File.Exists(filePathTemp))
            {
                Console.WriteLine("GetEquivalentFatigueLoadsResults filePath error!");
                return(null);
            }

            var buff = File.ReadAllText(filePath + "\\" + fileNameTemp + ".$EQ");

            string[] temp = buff.Split('\n');

            int j = 0;
            int i = 0;

            foreach (string ii in temp)
            {
                if (ii.Contains("Case   0") && ((ii.Contains("FXT")) || (ii.Contains("FYT")) || (ii.Contains("FZT")) || (ii.Contains("MXT")) || (ii.Contains("MYT")) || (ii.Contains("MZT")) ||
                                                (ii.Contains("Fx")) || (ii.Contains("Fy")) || (ii.Contains("Fz")) || (ii.Contains("Mx")) || (ii.Contains("My")) || (ii.Contains("Mz"))))
                {
                    var      tempii = ii.Remove(0, ii.IndexOf("Case   0") + "Case   0".Length);
                    string[] data   = tempii.Split(new string[] { " ", "\r", "\t" }, StringSplitOptions.RemoveEmptyEntries);
                    for (j = 0; j < 10; j++)
                    {
                        dataResults[j, i] = data[j];
                    }
                    i++;
                }
            }
            if (i > 6)
            {
                Console.WriteLine("GetEquivalentFatigueLoadsResults error");
                return(null);
            }
            results.equivalentFatigueLoads.arrayResults = dataResults;
            return(results);
        }
示例#7
0
 void GetPostPathFromInfoSheet()
 {
     Excel.Worksheet ws = (Excel.Worksheet)wb.Worksheets["Info"];
     for (int i = 0; ; i++)
     {
         BladedData bladedDataTemp = new BladedData();
         if (ws.get_Range(ws.Cells[i * 2 + 2, 1], ws.Cells[i * 2 + 2, 1]).Value == (object)null)
         {
             break;
         }
         else
         {
             bladedDataTemp.turbineMainCompenontResult.turbineID = ws.get_Range(ws.Cells[i * 2 + 2, 1], ws.Cells[i * 2 + 2, 1]).Value.ToString();
             bladedDataTemp.ultimateLoads.path          = ws.get_Range(ws.Cells[i * 2 + 2, 2], ws.Cells[i * 2 + 2, 2]).Value.ToString();
             bladedDataTemp.equivalentFatigueLoads.path = ws.get_Range(ws.Cells[i * 2 + 3, 2], ws.Cells[i * 2 + 3, 2]).Value.ToString();
             bladedDatas.Add(bladedDataTemp);
         }
     }
     GetMainComPathFromPostPath();
 }
示例#8
0
        private BladedData GetUltimateLoadsResultsFromFile(string filePath)
        {
            BladedData ultimateLoadsResults = new BladedData();
            var        pjFilePath           = Directory.GetFiles(filePath, "*.$PJ")[0]; //获取.$pj文件路径
            var        fileNameTemp         = Path.GetFileNameWithoutExtension(pjFilePath);
            var        filePathTemp         = filePath + "\\" + fileNameTemp + ".$MX";
            var        buff = File.ReadAllText(filePathTemp);

            string[,] dataResults = new string[16, 10];
            string temp = buff.Replace(" ", "");

            string[] data = temp.Split('\n');

            int j = 0;
            int i = 0;

            foreach (string ii in data)
            {
                i = 0;
                string[] temp1 = ii.Split('\t');

                foreach (string jj in temp1)
                {
                    if (j > 1 && i > 1 && j < 18 && i < 12)
                    {
                        dataResults[j - 2, i - 2] = jj;
                    }
                    i++;
                }
                j++;
            }
            if (j > 19)
            {
                Console.WriteLine("GetUltimateLoadsResults error!");
                return(null);
            }
            ultimateLoadsResults.ultimateLoads.arrayResults = dataResults;
            return(ultimateLoadsResults);
        }