logplus/DataOutput/include/MyDlisLib.h
2025-10-29 17:23:30 +08:00

349 lines
8.6 KiB
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/////////////////////////////////////////////
// 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; //坐标区总个数
BYTE DepthAreaNo; //深度区号
BYTE ThinLine; //细线间隔
BYTE ThickLine; //粗线间隔
BYTE UnitMode; //坐标单位 0:象素; 1:厘米; 2:英寸.
BYTE DepthCharDir; //深度字符显示方向,0为纵向
short LeftMargin; //左边距
short RightMargin; //右边距
short Width[10]; //坐标区宽度
short IfLine[10]; //是否是线性坐标区
short IfDepthLine[10]; //是否有深度线(TRUE:画 FALSE:不画)
short LineNum[10]; //坐标网格纵向线数
short LogStart[10]; //对数坐标起始值(1/2/3)
short PrintScale; //打印比例
short DisplayScale; //显示比例
};
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不存在!");
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