logplus/DataOutput/include/MyDlisLib.h

349 lines
8.6 KiB
C
Raw Permalink Normal View History

2025-10-29 17:23:30 +08:00
/////////////////////////////////////////////
// MyDlisLib.h
#ifndef _MY_DLIS_LIB_H
#define _MY_DLIS_LIB_H
#define MAX_CURVE_NUM 256
struct Well_Info
{
char FileID[80];
char WellName[80];
char FieldName[80];
char Company[80];
char Producer[80];
};
struct Curve_Prop
{
char Name[32];
char Units[32];
BYTE RepCode;
BYTE DotCount;
short Dimension;
short Element_Limit;
};
struct Curve_Set
{
BYTE Start_Track;
BYTE Stop_Track;
float Left_Limit;
float Right_Limit;
unsigned long Color;
BYTE Scale;
BYTE LineType;
BYTE Thickness;
BYTE WrapMode;
BYTE WrapCount;
BYTE DispMode;
};
struct Log_Track
{
BYTE AreaNum; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܸ<EFBFBD><DCB8><EFBFBD>
BYTE DepthAreaNo; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
BYTE ThinLine; //ϸ<>߼<EFBFBD><DFBC><EFBFBD>
BYTE ThickLine; //<2F><><EFBFBD>߼<EFBFBD><DFBC><EFBFBD>
BYTE UnitMode; //<2F><><EFBFBD>굥λ 0:<3A><><EFBFBD><EFBFBD>; 1:<3A><><EFBFBD><EFBFBD>; 2:Ӣ<><D3A2>.
BYTE DepthCharDir; //<2F><><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>,0Ϊ<30><CEAA><EFBFBD><EFBFBD>
short LeftMargin; //<2F><><EFBFBD>߾<EFBFBD>
short RightMargin; //<2F>ұ߾<D2B1>
short Width[10]; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
short IfLine[10]; //<2F>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
short IfDepthLine[10]; //<2F>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(TRUE:<3A><> FALSE:<3A><><EFBFBD><EFBFBD>)
short LineNum[10]; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
short LogStart[10]; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼֵ(1/2/3)<29><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
short PrintScale; //<2F><>ӡ<EFBFBD><D3A1><EFBFBD><EFBFBD>
short DisplayScale; //<2F><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>
};
class MyDlisLib
{
public:
//attrib
short MaxRecordLength;
BYTE DLISVersion;
BYTE ORIGIN_TAG;
BYTE SystemCode;
short IndexType;
double IndexStart,IndexEnd,FrameStep;
double DepthStart; //m
SYSTEMTIME TimeStart;
char IndexUnit[10];
short CurveNum;
unsigned long RecordTotal;
struct Well_Info WellInfo;
struct Curve_Prop Curve[MAX_CURVE_NUM];
struct Curve_Set CurveSet[MAX_CURVE_NUM];
struct Log_Track Track;
MyDlisLib()
{
MaxRecordLength=8192;
DLISVersion=1;
IndexType=0;
ORIGIN_TAG = 6;
SystemCode = 2;
memset(&WellInfo,0,sizeof(Well_Info));
for(int k=0;k<MAX_CURVE_NUM;k++)
{
memset(&Curve[k],0,sizeof(Curve_Prop));
memset(&CurveSet[k],0,sizeof(Curve_Set));
}
memset(&Track,0,sizeof(Log_Track));
char str1[300]="";
memset(str1,0,MAX_PATH);
GetSystemDirectory(str1,MAX_PATH); strcat(str1,"\\");strcat(str1,"MyDlisLib.dll");
strcpy(str1,"MyDlisLib.dll");
// strcat(str1,"dlis.dll");
hDLIS = AfxLoadLibrary(str1);
if(hDLIS==NULL)
{
GetSystemDirectory(str1,MAX_PATH); strcat(str1,"\\");strcat(str1,"MyDlisLib.dll");
hDLIS = AfxLoadLibrary(str1);
if(hDLIS==NULL)
{
AfxMessageBox("MyDlisLib.dll<6C><6C><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!");
return ;
}
}
////////////////////// /PROP //////////////////////
SetIndexType = (SetShortParam)GetProcAddress(hDLIS,"SetIndexType");
GetIndexType = (GetShortParam)GetProcAddress(hDLIS,"GetIndexType");
SetFrameStep = (SetDoubleParam)GetProcAddress(hDLIS,"SetFrameStep");
GetFrameStep = (GetDoubleParam)GetProcAddress(hDLIS,"GetFrameStep");
SetIndexUnit = (SetUnitParam)GetProcAddress(hDLIS,"SetIndexUnit");
GetIndexUnit = (GetUnitParam)GetProcAddress(hDLIS,"GetIndexUnit");
SetIndexStart = (SetDoubleParam)GetProcAddress(hDLIS,"SetIndexStart");
GetIndexStart = (GetDoubleParam)GetProcAddress(hDLIS,"GetIndexStart");
SetIndexEnd = (SetDoubleParam)GetProcAddress(hDLIS,"SetIndexEnd");
GetIndexEnd = (GetDoubleParam)GetProcAddress(hDLIS,"GetIndexEnd");
SetDepthStart = (SetDoubleParam)GetProcAddress(hDLIS,"SetDepthStart");
GetDepthStart = (GetDoubleParam)GetProcAddress(hDLIS,"GetDepthStart");
////////////////////// /PROP //////////////////////
SetTimeStart = (TimeParam)GetProcAddress(hDLIS,"SetTimeStart");
GetTimeStart = (TimeParam)GetProcAddress(hDLIS,"GetTimeStart");
SetCurveNum = (SetShortParam)GetProcAddress(hDLIS,"SetCurveNum");
GetCurveNum = (GetShortParam)GetProcAddress(hDLIS,"GetCurveNum");
SetRecordTotal = (SetLongtParam)GetProcAddress(hDLIS,"SetRecordTotal");
GetRecordTotal = (GetLongParam)GetProcAddress(hDLIS,"GetRecordTotal");
SetWellInfo = (UNKNOWNParam)GetProcAddress(hDLIS,"SetWellInfo");
GetWellInfo = (UNKNOWNParam)GetProcAddress(hDLIS,"GetWellInfo");
SetCurveProp = (CurveParam)GetProcAddress(hDLIS,"SetCurveProp");
GetCurveProp = (CurveParam)GetProcAddress(hDLIS,"GetCurveProp");
SetCurveSetting = (CurveParam)GetProcAddress(hDLIS,"SetCurveSetting");
GetCurveSetting = (CurveParam)GetProcAddress(hDLIS,"GetCurveSetting");
SetLogTrack = (UNKNOWNParam)GetProcAddress(hDLIS,"SetLogTrack");
GetLogTrack = (UNKNOWNParam)GetProcAddress(hDLIS,"GetLogTrack");
//////////////////OPERATION/////////////////////
OpenDataFile = (OpenDataFileParam)GetProcAddress(hDLIS,"OpenDataFile");
CloseDataFile = (voidParam)GetProcAddress(hDLIS,"CloseDataFile");
Head_Write = (voidParam)GetProcAddress(hDLIS,"Head_Write");
Head_Read = (voidParam)GetProcAddress(hDLIS,"Head_Read");
End_Flush = (voidParam)GetProcAddress(hDLIS,"End_Flush");
Data_Flush = (voidParam)GetProcAddress(hDLIS,"Data_Flush");
Data_Write = (DataRecordParam)GetProcAddress(hDLIS,"Data_Write");
Data_Read = (DataRecordParam)GetProcAddress(hDLIS,"Data_Read");
Data_Seek = (SeekParam)GetProcAddress(hDLIS,"Data_Seek");
};
~MyDlisLib()
{
AfxFreeLibrary(hDLIS);
};
///////////// PROP///////////////
typedef void (*SetDoubleParam)(double param);
SetDoubleParam SetFrameStep,SetIndexStart,SetIndexEnd,SetDepthStart;
typedef double (*GetDoubleParam)(void);
GetDoubleParam GetFrameStep,GetIndexStart,GetIndexEnd,GetDepthStart;
typedef void (*SetShortParam)(short param);
SetShortParam SetCurveNum;
typedef short (*GetShortParam)(void);
GetShortParam GetCurveNum;
SetShortParam SetIndexType;
GetShortParam GetIndexType;
typedef void (*SetUnitParam)(char *unit);
SetUnitParam SetIndexUnit;
typedef char* (*GetUnitParam)(void);
GetUnitParam GetIndexUnit;
typedef void (*TimeParam)(SYSTEMTIME & mTime);
TimeParam SetTimeStart,GetTimeStart;
typedef void (*SetLongtParam)(unsigned long param);
SetLongtParam SetRecordTotal;
typedef unsigned long (*GetLongParam)(void);
GetLongParam GetRecordTotal;
typedef void (*UNKNOWNParam)(LPUNKNOWN param);
UNKNOWNParam SetWellInfo,GetWellInfo;
UNKNOWNParam SetLogTrack,GetLogTrack;
typedef void (*CurveParam)(short CurveNo,LPUNKNOWN param);
CurveParam SetCurveProp,GetCurveProp;
CurveParam SetCurveSetting,GetCurveSetting;
///////////////////////////
//operator
HMODULE hDLIS;
typedef unsigned long (*OpenDataFileParam)(CString dataFileName,int nOpenFlags);
OpenDataFileParam OpenDataFile;
typedef unsigned long (*voidParam)(void);
voidParam CloseDataFile,Head_Write,Head_Read,End_Flush,Data_Flush;
typedef unsigned long (*DataRecordParam)(BYTE *ProjBuf);
DataRecordParam Data_Write,Data_Read;
typedef unsigned long (*SeekParam)(unsigned long recordN);
SeekParam Data_Seek;
//////////////////OVER ///////////////////////
unsigned long FileHead_Read()
{
unsigned long FileHeadLen=0;
if(Head_Read)
FileHeadLen = Head_Read();
if(GetIndexType)
IndexType =GetIndexType();
if(GetFrameStep)
FrameStep =GetFrameStep();
if(GetIndexUnit)
strcpy(IndexUnit,GetIndexUnit());
if(GetIndexStart)
IndexStart =GetIndexStart();
if(GetIndexEnd)
IndexEnd =GetIndexEnd();
if(GetDepthStart)
DepthStart =GetDepthStart();
if(GetTimeStart)
GetTimeStart(TimeStart);
if(GetCurveNum)
CurveNum=GetCurveNum();
if(SetRecordTotal)
RecordTotal= GetRecordTotal();
if(GetWellInfo)
{
GetWellInfo((LPUNKNOWN )&WellInfo);
}
if(GetCurveProp)
{
for(int i=0;i<CurveNum;i++)
GetCurveProp(i,(LPUNKNOWN )&Curve[i]);
}
if(GetCurveSetting)
{
for(int i=0;i<CurveNum;i++)
GetCurveSetting(i,(LPUNKNOWN )&CurveSet[i]);
}
if(GetLogTrack)
{
GetLogTrack((LPUNKNOWN )&Track);
}
return FileHeadLen;
};
unsigned long FileHead_Write()
{
unsigned long FileHeadLen=0;
if(SetIndexType)
SetIndexType(IndexType);
if(SetFrameStep)
SetFrameStep(FrameStep);
if(SetIndexUnit)
SetIndexUnit(IndexUnit);
if(SetIndexStart)
SetIndexStart(IndexStart);
if(SetIndexEnd)
SetIndexEnd(IndexEnd);
if(SetDepthStart)
SetDepthStart(DepthStart);
if(SetTimeStart)
SetTimeStart(TimeStart);
if(SetCurveNum)
SetCurveNum(CurveNum);
if(SetRecordTotal)
SetRecordTotal(RecordTotal);
if(SetWellInfo)
{
SetWellInfo((LPUNKNOWN )&WellInfo);
}
if(SetCurveProp)
{
for(int i=0;i<CurveNum;i++)
SetCurveProp(i,(LPUNKNOWN )&Curve[i]);
}
if(SetCurveSetting)
{
for(int i=0;i<CurveNum;i++)
SetCurveSetting(i,(LPUNKNOWN )&CurveSet[i]);
}
if(SetLogTrack)
{
SetLogTrack((LPUNKNOWN )&Track);
}
if(Head_Write)
FileHeadLen= Head_Write();
return FileHeadLen;
};
};
#endif