📄 tableoperation.cpp
字号:
// TableOperation.cpp: implementation of the TableOperation class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "测井服务表.h"
#include "TableOperation.h"
#include "math.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
TableOperation::TableOperation()
{
}
TableOperation::~TableOperation()
{
}
//******************************************************************
//以下函数供读写时调用
double TableOperation::f3786(unsigned int x1,unsigned int x2)
{
double fds,fds1,fds2;
float jmn;
char q1,q2,q3;
unsigned int fh,i,i1,jm,dsh,dsl;
unsigned int a[24];
jm=(x1&(0x7f00))>>8;
jmn=(float)jm-64.0;
dsh=x1&(0x00ff);
dsl=x2;
fh=0;
if((x1&(0x8000))!=0x0000)fh=1;
for(i=0;i<24;i++)
{
a[i]=0;
}
for(i=0;i<8;i++)
{
i1=(dsh)&((unsigned int)(pow(2,(7-i))));
if(i1!=0)a[i]=1;
}
for(i=8;i<24;i++)
{
i1=(dsl)&((unsigned int)(pow(2,(15+8-i))));
if(i1!=0)a[i]=1;
}
fds=a[0];
for(i=0;i<23;i++)
{
fds=fds*2.0+a[i+1];
}
fds=fds/pow(2.0,24.0-jmn*4.0);
if(fh==1)fds=-fds;
return(fds);
}
void TableOperation::f8637(double x, unsigned int y[4])
{
unsigned char sign=1;
double x1;
unsigned long int c1;
unsigned int i;
int wei;
if(x<0.0){sign=0;x=-x;}
if(x>=1.)
{
x1=x;
for(i=1;i<10;i++)
{
x1=x1/16.;
if(x1<1.){wei=i;break;}
}
y[0]=wei+0x40;
c1=(long int)(((x1*256.)*256.)*256.);
y[1]=(int)(c1>>16);
y[3]=(int)(c1&(0x0000ff));
y[2]=(int)((c1&(0x00ff00))>>8);
if(sign==0)y[0]=y[0]+0x80;
}
else
{
x1=x;
wei=0;
if(x1==0.0)
{
y[0]=0x00;y[1]=0x00;y[2]=0x00;y[3]=0x00;
}
else
{
for(i=0;x1<1./16.;i++)
{
x1=x1*16.;
wei=wei+1;
}
wei=-wei;
y[0]=wei+0x40;
c1=(long int)(((x1*256.)*256.)*256.);
y[1]=(int)(c1>>16);
y[3]=(int)(c1&(0x0000ff));
y[2]=(int)((c1&(0x00ff00))>>8);
if(sign==0)y[0]=y[0]+0x80;
}
}
}
//******************************************************************************
//读表操作
TableOperation::OnTableRead(CString szlstfile)
{
int i,i1;
int tem,tem1,tem2,tem3,tem4;
int curvenumber,x1,x2;
unsigned char buff1[64];
unsigned char c1,c2;
//unsigned char buffer[2560]; //已经在类中做了声明
CFileDialog ReadFileDlg(1,NULL,NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,"测井服务表(*.*)|*.*|");
if ( ReadFileDlg.DoModal() == IDOK)
{
CString szlstfile = ReadFileDlg.GetPathName(); //选择文件的路径
//AfxMessageBox("Your file name is :" +szlstfile ); //路径显示
CFile file;
if(!file.Open(szlstfile,CFile::modeRead,NULL))
AfxMessageBox("文件不能打开");
file.Read(buffer,2560*sizeof(unsigned char));//放置读取后数据
for(i=0;i<6;i++) //读取服务表号
tablenum[i]=(char)buffer[i];
tablenum[6]='\0';
//AfxMessageBox(tablenum); //显示服务表号
//读取CRT表
//*************************************************
i1=2176+16;
c1=buffer[i1];
c2=buffer[i1+1];
crttbl.UNITS[0]=' ';
crttbl.UNITS[1]='\0';
if((c1==0x00)&&(c2==0x00))
crttbl.UNITS[0]='E';
if((c1==0x00)&&(c2==0x01))
crttbl.UNITS[0]='M';
//AfxMessageBox(crttbl.UNITS); //要将crttbl.UNITS[0]的值显示
i1=0;
for(i=2560-36;i<2560-36+3;i++)
{
crttbl.UPPGRID[i1]=buffer[i];
i1=i1+1;
}
crttbl.UPPGRID[i1]='\0';
//AfxMessageBox(crttbl.UPPGRID);//要将这里的值显示
i1=0;
for(i=2560-36+4;i<2560-36+4+3;i++)
{
crttbl.LOWGRID[i1]=buffer[i];
i1=i1+1;
}
crttbl.LOWGRID[i1]='\0';
//AfxMessageBox(crttbl.LOWGRID);//还要显示的
//************************************************
//读取SRPTBL表
i1=0;
for(i=6;i<46;i+=2)
{
tem1=buffer[i];
tem2=buffer[i+1];
tem=256*tem1+tem2;
order[i1]=tem; //将表SRPTBL中的数据取出并保存,这里还要将其显示在列表框中的
if(tem==0x8000)
break;
i1=i1+1;
};
if(tem!=0x8000)
{
for(i=53;i<64;i+=2)
{
tem1=buffer[i];
tem2=buffer[i+1];
tem=256*tem1+tem2;
order[i1]=tem; //将表SRPTBL中存储在地址空间为35H~40H的数据取出并保存在,要将其显示在列表框中
if(tem==0x8000)
break;
i1=i1+1;
}
}
//*********************************************
//读取STATBL
i1=0;
i=32+14;
tem=buffer[i];
for(i=32+15;i<32+15+18;i++)
{
relay[i1]=buffer[i];
if(buffer[i]==0xff)
break;
i1=i1+1;
}
//*********************************************
//读取CALTBL
for(i=0;i<=10;i++)
{
tem1=TNAME[i].toolname[0]=buffer[64+16+i*6];
tem2=TNAME[i].toolname[1]=buffer[64+16+i*6+1];
tem=256*tem1+tem2;
if(tem==0xFFFF)
break;
for(i1=0;i1<=5;i1++)
TNAME[i].toolname[i1]=buffer[64+16+i*6+i1];
// AfxMessageBox(TNAME[i].toolname);//测试正常,还要显示
}
//*********************************************
//读取表CMTBL数据
/* TYPE[i].BIT.uall */
UPP_SCALE_COM=buffer[66];
LOW_SCALE_COM=buffer[67];
tem1=buffer[64+4];
tem2=buffer[64+5];
tem=tem1*256+tem2;
tem3=1;
for(i=1;i<16;i++)
{
tem4=(tem)&(tem3);
tem3=2*tem3;
TYPE[i].BIT.uall=0;
if(tem4!=0x00)
TYPE[i].BIT.uall=1;
};
/* TYPE[i].BIT.lall */
tem1=buffer[64+4+2];
tem2=buffer[64+5+2];
tem=tem1*256+tem2;
tem3=1;
for(i=1;i<16;i++)
{
tem4=(tem)&(tem3);
tem3=2*tem3;
TYPE[i].BIT.lall=0;
if(tem4!=0x00)
TYPE[i].BIT.lall=1;
};
/* TYPE[i].BIT.udotted */
tem1=buffer[64+4+4];
tem2=buffer[64+5+4];
tem=tem1*256+tem2;
tem3=1;
for(i=1;i<16;i++)
{
tem4=(tem)&(tem3);
tem3=2*tem3;
TYPE[i].BIT.udotted=0;
if(tem4!=0x00)
TYPE[i].BIT.udotted=1;
};
/* TYPE[i].BIT.ldotted */
tem1=buffer[64+4+6];
tem2=buffer[64+5+6];
tem=tem1*256+tem2;
tem3=1;
for(i=1;i<16;i++)
{
tem4=(tem)&(tem3);
tem3=2*tem3;
TYPE[i].BIT.ldotted=0;
if(tem4!=0x00)TYPE[i].BIT.ldotted=1;
};
/*TYPE[i].BIT.udashed*/
tem1=buffer[64+4+8];
tem2=buffer[64+5+8];
tem=tem1*256+tem2;
tem3=1;
for(i=1;i<16;i++)
{
tem4=(tem)&(tem3);
tem3=2*tem3;
TYPE[i].BIT.udashed=0;
if(tem4!=0x00)
TYPE[i].BIT.udashed=1;
};
/*TYPE[i].BIT.ldashed*/
tem1=buffer[64+4+10];
tem2=buffer[64+5+10];
tem=tem1*256+tem2;
tem3=1;
for(i=1;i<16;i++)
{
tem4=(tem)&(tem3);
tem3=2*tem3;
TYPE[i].BIT.ldashed=0;
if(tem4!=0x00)
TYPE[i].BIT.ldashed=1;
};
/* TYPE[i].BIT.ureal */
for(i=1;i<16;i++)
{
TYPE[i].BIT.ureal=0;
if(TYPE[i].BIT.uall==1)
{
if((TYPE[i].BIT.udotted==0)&&(TYPE[i].BIT.udashed==0))
TYPE[i].BIT.ureal=1;
}
};
/* TYPE[i].BIT.lreal */
for(i=1;i<16;i++)
{
TYPE[i].BIT.lreal=0;
if(TYPE[i].BIT.lall==1)
{
if((TYPE[i].BIT.ldotted==0)&&(TYPE[i].BIT.ldashed==0))
TYPE[i].BIT.lreal=1;
}
};
//*********************************************************
//读取主曲线表MCTBL
curvenumber=0;
for(i=0;i<32;i++)
{
for(i1=0;i1<64;i1++)
{
buff1[i1]=buffer[128+14+64*i+i1];
}
tem1=buff1[50];
tem2=buff1[51];
x1=256*tem1+tem2;
tem1=buff1[52];
tem2=buff1[53];
x2=256*tem1+tem2;
MCTBL[i].LOW=f3786(x1,x2);
tem1=buff1[50+4];
tem2=buff1[51+4];
x1=256*tem1+tem2;
tem1=buff1[52+4];
tem2=buff1[53+4];
x2=256*tem1+tem2;
MCTBL[i].HIGH=f3786(x1,x2);
if((MCTBL[i].HIGH==0.0)&&(MCTBL[i].LOW==0.0))
{
strcpy(MCTBL[i].crvnam,"/ ");
break;
}
curvenumber=curvenumber+1;
for(i1=0;i1<4;i1++)
{
if (((buff1[i1]>='A')&&(buff1[i1]<='Z'))||((buff1[i1]>='0')&&(buff1[i1]<='9')))
MCTBL[i].crvnam[i1]=buff1[i1];
else
MCTBL[i].crvnam[i1]=' ';
}
MCTBL[i].crvnam[i1]='\0';
//AfxMessageBox(MCTBL[i].crvnam);//曲线名读取成功
tem1=buff1[4]; /*读取深度延迟表地址 */
tem2=buff1[5];
MCTBL[i].DLSTAD=256*tem1+tem2;
tem1=buff1[6]; /*读取深度延迟表长度 */
tem2=buff1[7];
MCTBL[i].DLSTLN=256*tem1+tem2;
tem1=buff1[8]; /*深度延迟输入指针*/
tem2=buff1[9];
MCTBL[i].DLIPTR=256*tem1+tem2;
tem1=buff1[10]; /*深度延迟输出指针*/
tem2=buff1[11];
MCTBL[i].DLOPTR=256*tem1+tem2;
MCTBL[i].OPTIONS.ac=0; /* 初始化选择项 */
MCTBL[i].OPTIONS.cm=0;
MCTBL[i].OPTIONS.lg=0;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -