/*有深度 SLF_TEXT_FORMAT STDEP ENDEP RLEV NUMLOG 70.0000 2320.6299 0.1250 9 1 1 1 1 1 1 1 1 1 1 DEPTH GR rild rilm rfoc AC CAL RD RS SP 150.0000 92.600 4.164 3.828 3.611 339.737 22.447 4.477 3.737 87.759 150.1250 94.691 4.148 3.814 3.627 341.601 22.432 4.451 3.714 88.057 150.2500 96.415 4.107 3.768 3.657 342.669 22.457 4.453 3.732 88.364 150.3750 97.639 4.052 3.701 3.677 343.100 22.534 4.452 3.765 88.670 150.5000 98.257 3.997 3.625 3.685 343.198 22.670 4.424 3.788 88.949 */ /*无深度 SLF_TEXT_FORMAT STDEP ENDEP RLEV NUMLOG 70.0000 2320.6299 0.1250 9 0 1 1 1 1 1 1 1 1 1 GR rild rilm rfoc AC CAL RD RS SP 92.6 4.164 3.828 3.611 339.737 22.447 4.477 3.737 87.759 94.691 4.148 3.814 3.627 341.601 22.432 4.451 3.714 88.057 96.415 4.107 3.768 3.657 342.669 22.457 4.453 3.732 88.364 97.639 4.052 3.701 3.677 343.1 22.534 4.452 3.765 88.67*/ /*wave SLF_TEXT_FORMAT STDEP ENDEP RLEV NUMLOG 70.0000 2320.6299 0.1250 2 1 1 8 DEPTH GR WF 150.0000 92.600 4.164 3.828 3.611 339.737 22.447 4.477 3.737 87.759 150.1250 94.691 4.148 3.814 3.627 341.601 22.432 4.451 3.714 88.057 150.2500 96.415 4.107 3.768 3.657 342.669 22.457 4.453 3.732 88.364 150.3750 97.639 4.052 3.701 3.677 343.100 22.534 4.452 3.765 88.670 */ /*wave SLF_TEXT_FORMAT_TIME STDEP ENDEP RLEV NUMLOG 70.0000 2320.6299 0.1250 2 5 40 TIME WF 14 1 1 40 776 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 14 1 1 40 835 244 243 244 244 244 243 243 244 244 243 243 244 244 243 243 244 244 243 243 244 243 243 243 244 244 243 243 244 244 243 243 243 243 243 243 244 243 243 243 243 14 1 1 40 892 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 14 1 1 40 950 243 243 244 244 243 243 244 244 243 243 244 244 243 243 244 244 243 243 244 244 243 243 244 244 243 243 244 244 243 243 244 244 243 243 244 243 243 243 244 244 14 1 1 41 9 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 */ #pragma warning( push ,0) #include "ObjectIDDescription.h" #include"SLFAsciiConvertor.h" #include #include #include "CStringType.h" #include "MemRdWt.h" #include "BaseFun.h" // #include "WellBaseInfo.h" #include #include "geometryutils.h" #include "..\\..\\TexOutFun\\TxtOutFun.cpp" extern int HeadLineNum;//文件头行数 #pragma warning( pop) BEGIN_OSGGRAPHICS_NAMESPACE; #define GetSLFAsciiConvertorTypeID() "{BB64AD58-A7F7-4AF7-956F-518372C298D2}" Slf_FILE_MESSAGE FILE_MESSAGE={}; BEGIN_REGISTER_ID_DESCRIPTION() ID_ITEM_DATA(GetSLFAsciiConvertorTypeID(),"SLFAsciiConvertor") END_REGISTER_ID_DESCRIPTION(); CSLFAsciiConvertor::CSLFAsciiConvertor() { isinst=false; m_thisModuleName="SLFAsciiConvertor"; m_CurveData.Curve_Num=0; m_CurveData.Curve_Step=0.0; m_CurveData.Curve_StartDepth=0.0; m_CurveData.Curver_EndDepth=0.0; m_CurveData.Curver_MaxDim=0; InitFormatSuffixName(); image=0; } CSLFAsciiConvertor::~CSLFAsciiConvertor() { } QVector CSLFAsciiConvertor::GetSupportFileExtensions() { return m_vFileFormatSuffixName; } void CSLFAsciiConvertor::InitFormatSuffixName() { m_vFileFormatSuffixName.clear(); m_vFileFormatSuffixName.push_back("txt"); m_vFileFormatSuffixName.push_back("dat"); QVector suffixname=InterIConvertor::GetSupportFileExtensions(); m_vFileFormatSuffixName+=suffixname; } int CSLFAsciiConvertor::ScanLogFile(char *FileName,char *Message,char **CurveName,char **CurveUnit) { isinst=0; ddep=0; QStringList StrList; cfg=""; dates.clear(); depths.clear(); CString sss; /* open SLFAscii file */ char name[curve_name_len+1],temps[15]; int i,j,num; // CString cs,csOutName; QFile InFile(FileName); if( !InFile.open(QIODevice::ReadOnly ) )return 0; QTextStream textstream( &InFile ); QString str = textstream.readLine(); if(str.size()<=0){ InFile.close(); return 0; } if(str.indexOf("SLF_TEXT_FORMAT")<0) { InFile.close(); return 0; } image=0; str = textstream.readLine();//read STDEP ENDEP RLEV NUMLOG if(str.indexOf("FILE=")>0) { cfg=str.right(str.length()-(str.indexOf("FILE=")+5)); //2019.9.9 王卫让加 int pos=cfg.indexOf(" "); if(pos>1) cfg=cfg.left(pos); } if(str.indexOf("IMAGE=")>0) { QString IMAGEcfg=str.right(str.length()-(str.indexOf("IMAGE=")+6)); //2019.9.9 王卫让加 image=IMAGEcfg.toInt(); } if(str.indexOf("ERR=")>0) { QString serr=str.right(str.length()-(str.indexOf("ERR=")+4)); serr=serr.trimmed(); int pos=serr.indexOf(" "); if(pos>0) serr=serr.left(pos); err=serr.toFloat(); if(err<1) err=1; } if(str.indexOf("DDEP=")>0) { QString SDDEP=str.right(str.length()-(str.indexOf("DDEP=")+5)); ddep=SDDEP.toFloat(); } str = textstream.readLine(); if ( sscanf(str.toLatin1(),"%f %f %f %d %d\n",&stdep,&endep,&rlev,&dCurveNum,&isinst) < 4 ) { InFile.close(); return 0; } else { if ( stdep > 99999 || stdep < -1000 ){ InFile.close(); sss.Format("SLF_SLFAscii文件起始深度%f不正确",stdep); AfxMessageBox(sss); return 0; } if ( endep > 99999 || endep < -1000 ){ InFile.close(); sss.Format("SLF_SLFAscii文件结束深度%f不正确",endep);AfxMessageBox(sss); return 0; } if ( rlev > 99999 || rlev < -1000 ){ InFile.close(); sss.Format("SLF_SLFAscii文件采样间隔%f不正确",rlev); AfxMessageBox(sss);return 0; } if(dCurveNum<=0||dCurveNum>500) { InFile.close(); sss.Format("SLF_SLFAscii文件曲线条数%d不正确",dCurveNum);AfxMessageBox(sss); return 0; } } str = textstream.readLine(); str=str.simplified();//simplified()函数把一个字符串首尾的空格全部清除,不管首尾是几个空格,字符串中间的空格(包括单个空格、多个空格、\t、\n)都统一转化成一个空格 StrList=str.split(" "); if(StrList.size()!=1+dCurveNum) { InFile.close(); sss.Format("SLF_SLFAscii文件深度标示及曲线维数信息和曲线条数不一致:%s",str.toLatin1().data()); AfxMessageBox(sss); return 0; } NumCurve=NumWave=0; HaveDepth=StrList[0].toInt(); //assert(HaveDepth>=0);assert(HaveDepth<6); if(HaveDepth<0||HaveDepth>6) { sss="深度标示不正确,请检查您的文件头信息\r\n说明:深度标示:\r\n=0-无深度\r\n=1有深度,首列为深度值\r\n"; sss+=">1-时间域数据,如等于n,则前n列为时间信息,需要时深转换,如:\r\n"; sss+="SLF_TEXT_FORMAT\r\nSTDEP ENDEP RLEV NUMLOG FILE=LJ.CFG ERR=30\r\n1097 6314 0.0125 2\r\rn2 1 1\r\nDEPTH SP RT\r\n"; sss+="2019/7/17 11:46:35 45.8 21.8"; AfxMessageBox(sss);InFile.close(); return 0; } LineDataPoint=0; for(int i=0;i1)NumWave++; else { sss.Format("第%d条曲线的数据点数%d不正确\r\n数据点数必须>=1:=1是曲线,>1是波列",i+1,DataPoint[i]);AfxMessageBox(sss); InFile.close(); return 0; } LineDataPoint+=DataPoint[i]; } str = textstream.readLine();//读曲线名 str=str.simplified(); StrList=str.split(" "); int Begin=0; if(HaveDepth)Begin=1; if(StrList.size()!=dCurveNum+Begin){ AfxMessageBox("曲线名个数和定义的曲线条数不一致,请检查文件头信息是否正确"); InFile.close(); return 0; } for(int i=0;i1){ strcat(strr,CurveName[i]); strcat(strr," "); } } } strcat(Message,strr); //检查是否需要时深转换,需要的话,检查文件是否存在 if(HaveDepth>1){ if(cfg==""){ AfxMessageBox("请指定时深转换参数文件,如:\r\nSTDEP ENDEP RLEV NUMLOG FILE=LJ.CFG ERR=30"); InFile.close(); return 0; } int cou=GetDepthS(FileName,cfg);//读时深转换参数文件 } //调用该函数,向解编信息中压入深度信息 PutScanDepthMes(Message,stdep,endep); strcpy(WellDynamicInfo.LogCompanyName,"中国石化石油工程技术研究院"); InFile.close(); return dCurveNum; } bool CSLFAsciiConvertor::Transfer(char *FileName,char *outfile,int *OutCurveNo,char **OutCurve,char **strChineseName,char **strUnit,int dCurveNum) { if(HaveDepth>1) { if(dates.size()<=0) { AfxMessageBox("无时深转换参数数据,无法进行转换\r\n请检查文件是否存在"); return 0; } } if(HaveSameCurve(dCurveNum,OutCurveNo,OutCurve))return 0; ScanInf.stdep=stdep,ScanInf.endep=endep,ScanInf.rlev=rlev; ScanInf.dCurveNum=dCurveNum; for(int i=0;i