public bool ReadData() { Data = new SortedList <DateTime, SvodDataRecord>(); PumpTypeEnum type = PumpTypeEnum.Drenage; ReportOutputFile outFile = new ReportOutputFile(FileName); try { outFile.ReadData(); } catch (Exception e) { Logger.Info("Ошибка инициализации файла " + FileName); Logger.Info(e.ToString()); return(false); } for (int i = 2; i < outFile.Data.Count; i++) { try { Dictionary <int, string> fileRec = outFile.Data[i]; SvodDataRecord rec = new SvodDataRecord(); rec.DateStart = ReportOutputFile.getDate(fileRec[0]); rec.DateEnd = ReportOutputFile.getDate(fileRec[1]); rec.PMin = ReportOutputFile.getDouble(fileRec[2]); rec.PMax = ReportOutputFile.getDouble(fileRec[3]); rec.PAvg = ReportOutputFile.getDouble(fileRec[4]); rec.LN1Time = ReportOutputFile.getDouble(fileRec[5]); rec.LN2Time = ReportOutputFile.getDouble(fileRec[6]); rec.DN1Time = ReportOutputFile.getDouble(fileRec[7]); rec.DN2Time = ReportOutputFile.getDouble(fileRec[8]); rec.MNU1Time = ReportOutputFile.getDouble(fileRec[9]); rec.MNU2Time = ReportOutputFile.getDouble(fileRec[10]); rec.MNU3Time = ReportOutputFile.getDouble(fileRec[11]); rec.LN1Pusk = (int)ReportOutputFile.getDouble(fileRec[12]); rec.LN2Pusk = (int)ReportOutputFile.getDouble(fileRec[13]); rec.DN1Pusk = (int)ReportOutputFile.getDouble(fileRec[14]); rec.DN2Pusk = (int)ReportOutputFile.getDouble(fileRec[15]); rec.MNU1Pusk = (int)ReportOutputFile.getDouble(fileRec[16]); rec.MNU2Pusk = (int)ReportOutputFile.getDouble(fileRec[17]); rec.MNU3Pusk = (int)ReportOutputFile.getDouble(fileRec[18]); rec.GPHot = ReportOutputFile.getDouble(fileRec[19]); rec.GPCold = ReportOutputFile.getDouble(fileRec[20]); rec.GPLevel = ReportOutputFile.getDouble(fileRec[21]); rec.PPHot = ReportOutputFile.getDouble(fileRec[22]); rec.PPCold = ReportOutputFile.getDouble(fileRec[23]); rec.PPLevel = ReportOutputFile.getDouble(fileRec[24]); double GPLevelMin = ReportOutputFile.getDouble(fileRec[25]); double PPLevelMin = ReportOutputFile.getDouble(fileRec[26]); double GPLevelMax = ReportOutputFile.getDouble(fileRec[27]); double PPLevelMax = ReportOutputFile.getDouble(fileRec[28]); double gpHotMin = ReportOutputFile.getDouble(fileRec[29]); double gpColdMin = ReportOutputFile.getDouble(fileRec[30]); double gpHotMax = ReportOutputFile.getDouble(fileRec[31]); double gpColdMax = ReportOutputFile.getDouble(fileRec[32]); double ppHotMin = ReportOutputFile.getDouble(fileRec[33]); double ppColdMin = ReportOutputFile.getDouble(fileRec[34]); double ppHotMax = ReportOutputFile.getDouble(fileRec[35]); double ppColdMax = ReportOutputFile.getDouble(fileRec[36]); double gpOhlAvg = ReportOutputFile.getDouble(fileRec[37]); double gpOhlMin = ReportOutputFile.getDouble(fileRec[38]); double gpOhlMax = ReportOutputFile.getDouble(fileRec[39]); double ppOhlAvg1 = ReportOutputFile.getDouble(fileRec[40]); double ppOhlMin1 = ReportOutputFile.getDouble(fileRec[41]); double ppOhlMax1 = ReportOutputFile.getDouble(fileRec[42]); double ppOhlAvg2 = ReportOutputFile.getDouble(fileRec[43]); double ppOhlMin2 = ReportOutputFile.getDouble(fileRec[44]); double ppOhlMax2 = ReportOutputFile.getDouble(fileRec[45]); rec.GPOhlRashod = gpOhlAvg; rec.PPOhlRashod = ppOhlAvg1 + ppOhlAvg2; rec.IsUst = IsUst(rec.PMin, rec.PMax, rec.PAvg, 2); rec.IsUstGP = IsUst(GPLevelMin, GPLevelMax, rec.GPLevel, 3); rec.IsUstGP = rec.IsUstGP && IsUst(gpHotMin, gpHotMax, rec.GPHot, 3); rec.IsUstGP = rec.IsUstGP && IsUst(gpColdMin, gpColdMax, rec.GPCold, 3); rec.IsUstPP = IsUst(PPLevelMin, PPLevelMax, rec.PPLevel, 3); rec.IsUstPP = rec.IsUstPP && IsUst(ppHotMin, ppHotMax, rec.PPHot, 3); rec.IsUstPP = rec.IsUstPP && IsUst(ppColdMin, ppColdMax, rec.PPCold, 3); rec.IsUstGPOhl = IsUst(gpOhlMin, gpOhlMax, gpOhlAvg, 5); rec.IsUstPPOhl = IsUst(ppOhlMin1, ppOhlMax1, ppOhlAvg1, 5) && IsUst(ppOhlMin2, ppOhlMax2, ppOhlAvg2, 5); while (Data.ContainsKey(rec.DateStart)) { rec.DateStart = rec.DateStart.AddMilliseconds(1); } Data.Add(rec.DateStart, rec); } catch (Exception e) { Logger.Info("ошибка при разборе строки"); Logger.Info(e.ToString()); return(false); } } return(true); }
public bool ReadData() { Data = new SortedList <DateTime, PumpDataRecord>(); PumpTypeEnum type = PumpTypeEnum.Drenage; int pumpNumber = 0; ReportOutputFile outFile = new ReportOutputFile(FileName); try { outFile.ReadData(); FileInfo fi = new FileInfo(FileName); if (fi.Name.Contains("DN_")) { type = PumpTypeEnum.Drenage; } else if (fi.Name.Contains("MNU_")) { type = PumpTypeEnum.MNU; } else if (fi.Name.Contains("LN_")) { type = PumpTypeEnum.Leakage; } else { Logger.Info("Не определен тип насоса в файле " + FileName); return(false); } switch (type) { case PumpTypeEnum.Drenage: pumpNumber = (int)ReportOutputFile.getDouble(outFile.Data[0][3]); break; case PumpTypeEnum.Leakage: pumpNumber = (int)ReportOutputFile.getDouble(outFile.Data[0][3]); break; case PumpTypeEnum.MNU: pumpNumber = (int)ReportOutputFile.getDouble(outFile.Data[0][4]); break; } if (pumpNumber < 0) { Logger.Info("pumpNumber=" + pumpNumber); } }catch (Exception e) { Logger.Info("Ошибка инициализации файла " + FileName); Logger.Info(e.ToString()); return(false); } for (int i = 2; i < outFile.Data.Count; i++) { try { Dictionary <int, string> fileRec = outFile.Data[i]; PumpDataRecord rec = new PumpDataRecord(); rec.DateStart = ReportOutputFile.getDate(fileRec[0]); rec.DateEnd = ReportOutputFile.getDate(fileRec[1]); rec.PAvg = ReportOutputFile.getDouble(fileRec[2]); rec.PMin = ReportOutputFile.getDouble(fileRec[3]); rec.PMax = ReportOutputFile.getDouble(fileRec[4]); rec.RunTime = ReportOutputFile.getDouble(fileRec[5]); rec.LevelStart = ReportOutputFile.getDouble(fileRec[6]); rec.LevelStop = ReportOutputFile.getDouble(fileRec[7]); rec.PumpType = type; rec.PumpNum = pumpNumber; double diff = rec.PAvg / 100 * 2; rec.IsUst = Math.Abs(rec.PAvg - rec.PMax) <= diff; rec.IsUst = rec.IsUst && Math.Abs(rec.PAvg - rec.PMin) <= diff; while (Data.ContainsKey(rec.DateStart)) { rec.DateStart = rec.DateStart.AddMilliseconds(1); } Data.Add(rec.DateStart, rec); }catch (Exception e) { Logger.Info("ошибка при разборе строки"); Logger.Info(e.ToString()); return(false); } } return(true); }