private BladedData.TurbineMainCompenontResult.Results.MainComponentDataStruct GetMatrixMaxValue(BladedData.TurbineMainCompenontResult.Results.MainComponentDataStruct mainCom) //格式化矩阵输出单个工况各变量的最大值 { float[] maxValue = new float[8]; List <string> dlcNameList = new List <string>(); List <float[]> dlcMaxValueList = new List <float[]>(); float[,] templist = new float[8, mainCom.mainDlcData.Count]; int n = 0; foreach (BladedData.TurbineMainCompenontResult.Results.MainDlcDataStruct dd in mainCom.mainDlcData) { float[,] dataResults = dd.resultMatrix; //数据 dlcNameList.Add(dd.dlcName); //列表头 var row = dataResults.GetLength(0); var col = dataResults.GetLength(1); float[] maxTemp = new float[8]; for (int j = 0; j < col; j++) { templist[j, n] = Math.Max(Math.Abs(dataResults[2 * j, j]), Math.Abs(dataResults[2 * j + 1, j])); maxValue[j] = Math.Max(templist[j, n], maxValue[j]); } n++; } for (int i = 0; i < templist.GetLength(0); i++) //转化为与最大值的百分比 { for (int j = 0; j < templist.GetLength(1); j++) { templist[i, j] = templist[i, j] / maxValue[i]; } } mainCom.dlcNameList = dlcNameList; mainCom.dlcMaxValueList = templist; return(mainCom); }
List <BladedData.TurbineMainCompenontResult.Results.MainDlcDataStruct> GetEachDlcMaxValueFromMainCom(BladedData.TurbineMainCompenontResult.Results.MainComponentDataStruct mainCom) { List <string> dlcPathList; BladedData.TurbineMainCompenontResult.Results.MainDlcDataStruct mainDlcData; List <BladedData.TurbineMainCompenontResult.Results.MainDlcDataStruct> mainDlcDataList = new List <BladedData.TurbineMainCompenontResult.Results.MainDlcDataStruct>(); string pjName = Path.GetFullPath(Directory.GetFiles(mainCom.path, "*.$PJ")[0]).Replace(".$PJ", ".$MX"); string[] dlcPath = Directory.GetFiles(mainCom.path, "*.$MX"); dlcPathList = new List <string>(); string sameDlc = null; int endFlag = 0; foreach (string ss in dlcPath) { if (ss.Equals(pjName)) { continue; } else if (pjName.Contains("br.$MX") || pjName.Contains("hr.$MX") || pjName.Contains("hs.$MX")) { string[] tempName = Path.GetFileNameWithoutExtension(ss).Split(new char[] { '-', '_' }, StringSplitOptions.RemoveEmptyEntries); if (string.IsNullOrEmpty(sameDlc)) { sameDlc = tempName[0]; } else if (sameDlc == tempName[0]) { dlcPathList.Add(ss); } else { mainDlcData = new BladedData.TurbineMainCompenontResult.Results.MainDlcDataStruct(); mainDlcData.resultMatrix = GetUltimateLoadsDlcMaxValueFromFile(dlcPathList); mainDlcData.dlcName = sameDlc.Replace(Path.GetFileNameWithoutExtension(pjName) + ".", "DLC"); //修改输出工况名称 mainDlcDataList.Add(mainDlcData); sameDlc = tempName[0]; dlcPathList.Clear(); dlcPathList.Add(ss); } } else //塔架的命名分割与其他不同 { string[] tempName = Path.GetFileNameWithoutExtension(ss).Split(new char[] { '-', '_' }, StringSplitOptions.RemoveEmptyEntries); string tempDlcName = tempName[0] + "_" + tempName[1]; if (string.IsNullOrEmpty(sameDlc)) { sameDlc = tempDlcName; } else if (sameDlc == tempDlcName) { dlcPathList.Add(ss); } else { mainDlcData = new BladedData.TurbineMainCompenontResult.Results.MainDlcDataStruct(); mainDlcData.resultMatrix = GetUltimateLoadsDlcMaxValueFromFile(dlcPathList); mainDlcData.dlcName = sameDlc.Replace(Path.GetFileNameWithoutExtension(pjName) + ".", "DLC"); //修改输出工况名称 mainDlcDataList.Add(mainDlcData); sameDlc = tempDlcName; dlcPathList.Clear(); dlcPathList.Add(ss); } } ++endFlag; if (dlcPath.Length == endFlag + 1) //文件遍历完后获取最后一部分数据+1为br.$MX { mainDlcData = new BladedData.TurbineMainCompenontResult.Results.MainDlcDataStruct(); mainDlcData.resultMatrix = GetUltimateLoadsDlcMaxValueFromFile(dlcPathList); mainDlcData.dlcName = sameDlc.Replace(Path.GetFileNameWithoutExtension(pjName) + ".", "DLC"); //修改输出工况名称 mainDlcDataList.Add(mainDlcData); } } return(mainDlcDataList); }
void GetMainComPathFromPostPath() // 从excel表中获取post路径 { foreach (BladedData dd in bladedDatas) { string[] comPaths = Directory.GetDirectories(dd.ultimateLoads.path); foreach (string s in comPaths) { BladedData.TurbineMainCompenontResult.Results.MainComponentDataStruct com = new BladedData.TurbineMainCompenontResult.Results.MainComponentDataStruct(); com.path = s; string[] temp = s.Split(new char[] { '\\' }, StringSplitOptions.RemoveEmptyEntries); com.name = temp.LastOrDefault(); dd.turbineMainCompenontResult.results.ultmateData.component.Add(com); } string[] comPaths2 = Directory.GetDirectories(dd.equivalentFatigueLoads.path); foreach (string s in comPaths2) { BladedData.TurbineMainCompenontResult.Results.MainComponentDataStruct com = new BladedData.TurbineMainCompenontResult.Results.MainComponentDataStruct(); com.path = s; string[] temp = s.Split(new char[] { '\\' }, StringSplitOptions.RemoveEmptyEntries); com.name = temp.LastOrDefault(); dd.turbineMainCompenontResult.results.equivalentFatigueData.component.Add(com); } } bladedDataOperation.GetMainCompinentLoadsResult(bladedDatas); }