📄 cz_cl.cpp
字号:
theApp.DataBase.MotifyRecord(i+rec);
}
}
theApp.DataBase.CloseTable();
return rec;
}
int CCz_cl::czj_xcjs(int chs)//计算垂直角限差
{
double L,R,A0,I;
CJbjs js;
CString str;
int rec,index=0;
if(!theApp.DataBase.OpenTable(theApp.DataBase.szFileName,_T("DXCZJ")))
{
AfxMessageBox(_T("不能打开DXCZJ数据库"));
return -1;
}
TCHAR CDM[20];
theApp.DataBase.ReadRecord(0);
wcscpy(CDM,theApp.DataBase.m_values.GetAt(2));
theApp.DataBase.CloseTable();
rec = search_czj_record(_T("DXCZJ"),theApp.clsx.GetAt(clsx_index)->chs,CDM);
if(rec!=-1)
{
if(!theApp.DataBase.OpenTable(theApp.DataBase.szFileName,_T("DXCZJ")))
{
AfxMessageBox(_T("不能打开DXCZJ数据库1"));
return -1;
}
theApp.I=new double[theApp.czj_rec_len];
for(int i=0;i<theApp.czj_rec_len;i++)
{
theApp.DataBase.ReadRecord(rec+i);
L=m_wtof(theApp.DataBase.m_values.GetAt(4));
R=m_wtof(theApp.DataBase.m_values.GetAt(5));
A0=js.A(L,R);
str.Format(_T("%f"),A0);
theApp.DataBase.m_values.SetAt(6,str);
I=js.I(L,R);
theApp.I[i]=I;
str.Format(_T("%f"),I);
theApp.DataBase.m_values.SetAt(7,str);
theApp.DataBase.MotifyRecord(i+rec);
}
}
theApp.DataBase.CloseTable();
return rec;
}
bool CCz_cl::compare_spj_2c()//比较水平2c
{
double max_2c=0,temp_2c=0;
if(spj_xcjs(theApp.clsx.GetAt(clsx_index)->chs)==-1)
return true;
for(int i=0; i<theApp.spj_rec_len;i++)
for(int j=i;j<theApp.spj_rec_len;j++)
{
temp_2c=fabs(theApp.c2[i]-theApp.c2[j]);
max_2c= max_2c>temp_2c? max_2c:temp_2c;
}
delete [] theApp.c2;
if(max_2c>theApp.p_2c)
{
AfxMessageBox(_T("2c超限"));
return false;
}
else
{
return true;
}
}
bool CCz_cl::compare_I()//比较垂直 I
{
double max_I=0,temp_I=0;
if(czj_xcjs(theApp.clsx.GetAt(clsx_index)->chs)==-1)
return true;
for(int i=0; i<theApp.czj_rec_len;i++)
for(int j=i;j<theApp.czj_rec_len;j++)
{
temp_I=fabs(theApp.I[i]-theApp.I[j]);
max_I>temp_I? max_I=max_I:max_I=temp_I;
}
delete [] theApp.I;
if(max_I>theApp.I_c)
{
AfxMessageBox(_T("I指标超限"));
return false;
}
else
return true;
}
bool CCz_cl::compare_one_ch()//比较一测回I 2c
{
if(!compare_spj_2c()||!compare_I())
{
return false;
}else
{
return true;
}
}
bool CCz_cl::compare_f()//比较方向值差
{
int n,j;
int maxrec,minrec;
double *fxc,*fz;
bool ret=true;
if(!theApp.DataBase.OpenTable(theApp.DataBase.szFileName,_T("DXSPJ")))
{
AfxMessageBox(_T("不能打开DXSPJ数据库"));
return false;
}
fxc=new double[theApp.spj_chs_kz*theApp.spj_rec_len];
for(j=0;j<theApp.spj_chs_kz;j++)
for(n=0;n<theApp.spj_rec_len;n++)
{
theApp.DataBase.ReadRecord(j*theApp.spj_rec_len+n);
fxc[j*theApp.spj_rec_len+n]=m_wtof(theApp.DataBase.m_values.GetAt(6));
}
theApp.DataBase.CloseTable();
//比较数据
fz=new double[theApp.spj_chs_kz];
for(n=0;n<theApp.spj_rec_len;n++)
{
for(j=0;j<theApp.spj_chs_kz;j++)
{
fz[j]=fxc[j*theApp.spj_rec_len+n];
}
if(n>0)
{
if(theApp.spj_rec_len<4)
{
//没有归零方向
if(GetMax(fxc,theApp.spj_chs_kz,&maxrec,&minrec)>theApp.p_fc)
{
ret=false;
break;
}
}
else
{
//有归零方向
if(n<theApp.spj_rec_len-1)
{
if(GetMax(fxc,theApp.spj_chs_kz,&maxrec,&minrec)>theApp.p_fc)
{
ret=false;
break;
}
}
}
}
}
delete [] fz;
delete [] fxc;
return ret;
}
bool CCz_cl::compare_a()//比较垂直角
{
int i,j;
int maxrec,minrec;
double *cza,*czj;
bool ret=true;
CString str;
if(!theApp.DataBase.OpenTable(theApp.DataBase.szFileName,_T("DXCZJ")))
{
AfxMessageBox(_T("不能打开DXCZJ数据库"));
return false;
}
cza=new double[theApp.czj_chs_kz*theApp.czj_rec_len];
for(j=0;j<theApp.czj_chs_kz;j++)
for(i=0;i<theApp.czj_rec_len;i++)
{
theApp.DataBase.ReadRecord(j*theApp.czj_rec_len+i);
cza[j*theApp.czj_rec_len+i]=m_wtof(theApp.DataBase.m_values.GetAt(6));
}
theApp.DataBase.CloseTable();
//比较数据
czj=new double[theApp.czj_chs_kz];
for(i=0;i<theApp.czj_rec_len;i++)
{
for(j=0;j<theApp.czj_chs_kz;j++)
{
czj[j]=cza[j*theApp.czj_rec_len+i];
}
if(GetMax(czj,theApp.czj_chs_kz,&maxrec,&minrec)>theApp.A_c)
{
ret=false;
break;
}
}
delete [] cza;
delete [] czj;
return ret;
}
double CCz_cl::GetMax(double *fxz,int rec, int *maxrec,int *minrec)//返回最大的差值
{
int i;
double m_min=1296001,m_max=-1296001;
for(i=0;i<rec;i++)
{
if(m_min>fxz[i])
{
m_min=fxz[i];
*minrec=i;
}
if(m_max<fxz[i])
{
m_max= fxz[i];
*maxrec=i;
}
}
return fabs(m_max-m_min);
}
bool CCz_cl::clean()//清除内存数据
{
FXMC *mobj;
int index=theApp.fxmc.GetSize();
while(index>0)
{
mobj=theApp.fxmc.GetAt(0);
theApp.fxmc.RemoveAt(0);
index=theApp.fxmc.GetSize();
delete mobj;
}
CTSX *m_obj;
index=theApp.clsx.GetSize();
while(index>0)
{
m_obj=theApp.clsx.GetAt(0);
theApp.clsx.RemoveAt(0);
index=theApp.clsx.GetSize();
delete m_obj;
}
return true;
}
bool CCz_cl::sj_save(CString talbe)//数据入库
{
int i,rec,rec_index=0;
KZD_GCJL_Jd *jl;
bool ret=true;
CString str;
if(!theApp.DataBase.OpenTable(theApp.DataBase.szFileName,talbe))
{
str.Format(_T("不能打开数据库%s"),talbe);
AfxMessageBox(str);
ret=false;
}
rec=theApp.DataBase.GetRecordNumber();
if(ret&&rec>0)
{
jl=new KZD_GCJL_Jd [rec];
//读DXSPJ数据库
for(i=0;i<rec;i++)
{
theApp.DataBase.ReadRecord(i);
jl[i].chs=theApp.DataBase.m_values.GetAt(0);
jl[i].zdm=theApp.DataBase.m_values.GetAt(1);
jl[i].cdm=theApp.DataBase.m_values.GetAt(2);
jl[i].cbg=theApp.DataBase.m_values.GetAt(3);
jl[i].l=theApp.DataBase.m_values.GetAt(4);
jl[i].r=theApp.DataBase.m_values.GetAt(5);
jl[i].rec=theApp.DataBase.m_values.GetAt(8);
}
theApp.DataBase.CloseTable();
//写JDXSPJ数据库
str.Format(_T("J%s"),talbe);
if(!theApp.DataBase.OpenTable(theApp.DataBase.szFileName,str))
{
str.Format(_T("不能打开数据库J%s"),talbe);
AfxMessageBox(str);
ret=false;
}
if(ret)
{
rec_index=theApp.DataBase.GetRecordNumber();
if(rec_index<0)rec_index=0;
str.Format(_T("%d"),rec_index);
AfxMessageBox(str);
for(i=0;i<rec;i++)
{
theApp.DataBase.m_values.Add(jl[i].chs);
theApp.DataBase.m_values.Add(jl[i].zdm);
theApp.DataBase.m_values.Add(jl[i].cdm);
theApp.DataBase.m_values.Add(jl[i].cbg);
theApp.DataBase.m_values.Add(jl[i].l);
theApp.DataBase.m_values.Add(jl[i].r);
str.Format(_T("%d"),i+rec_index);
theApp.DataBase.m_values.Add(str);
str=theApp.zdrec;
theApp.DataBase.m_values.Add(str);
// AfxMessageBox(str);
if(!theApp.DataBase.AddNewRecord())
{
str.Format(_T("不能增加数据库J%s"),talbe);
AfxMessageBox(str);
ret=false;
break;
}
}
}
theApp.DataBase.CloseTable();
delete [] jl;
}
theApp.DataBase.CloseTable();
return ret;
}
bool CCz_cl::jul_save(CString table)//距离入库
{
int i,rec,rec_index=0;
KZD_GCJL_Jl *jl;
bool ret=true;
CString str;
if(!theApp.DataBase.OpenTable(theApp.DataBase.szFileName,table))
{
str.Format(_T("不能打开数据库%s"),table);
AfxMessageBox(str);
ret=false;
}
rec=theApp.DataBase.GetRecordNumber();
if(ret&&rec>0)
{
jl=new KZD_GCJL_Jl [rec];
//读Jl数据库
for(i=0;i<rec;i++)
{
theApp.DataBase.ReadRecord(i);
jl[i].chs=theApp.DataBase.m_values.GetAt(0);
jl[i].zdm=theApp.DataBase.m_values.GetAt(1);
jl[i].cdm=theApp.DataBase.m_values.GetAt(2);
jl[i].cbg=theApp.DataBase.m_values.GetAt(3);
jl[i].j1=theApp.DataBase.m_values.GetAt(4);
jl[i].j2=theApp.DataBase.m_values.GetAt(5);
jl[i].j3=theApp.DataBase.m_values.GetAt(6);
jl[i].j4=theApp.DataBase.m_values.GetAt(7);
jl[i].rec=theApp.DataBase.m_values.GetAt(8);
}
theApp.DataBase.CloseTable();
//写jl数据库
str.Format(_T("J%s"),table);
if(!theApp.DataBase.OpenTable(theApp.DataBase.szFileName,str))
{
str.Format(_T("不能打开数据库J%s"),table);
AfxMessageBox(str);
ret=false;
}
if(ret)
{
rec_index=theApp.DataBase.GetRecordNumber();
for(i=0;i<rec;i++)
{
theApp.DataBase.m_values.Add(jl[i].chs);
theApp.DataBase.m_values.Add(jl[i].zdm);
theApp.DataBase.m_values.Add(jl[i].cdm);
theApp.DataBase.m_values.Add(jl[i].cbg);
theApp.DataBase.m_values.Add(jl[i].j1);
theApp.DataBase.m_values.Add(jl[i].j2);
theApp.DataBase.m_values.Add(jl[i].j3);
theApp.DataBase.m_values.Add(jl[i].j4);
// str.Format(_T("%d"),rec_index+i);
theApp.DataBase.m_values.Add(jl[i].rec);
theApp.DataBase.m_values.Add(theApp.zdrec);
if(!theApp.DataBase.AddNewRecord())
{
str.Format(_T("不能增加数据库J%s"),table);
AfxMessageBox(str);
ret=false;
break;
}
}
}
theApp.DataBase.CloseTable();
delete [] jl;
}
theApp.DataBase.CloseTable();
return ret;
}
bool CCz_cl::saveall()
{
bool ret=true;
ret=sj_save(_T("DXCZJ"));
ret=sj_save(_T("DXSPJ"));
ret=jul_save(_T("DXJL"));
return ret;
}
int CCz_cl::getfxsum(int chs)//得到某测回的方向数
{
int rec=0,index=theApp.fxmc.GetSize();
for(int i=0;i<index;i++)
{
if(theApp.clsx.GetAt(i)->chs==chs)
{
rec++;
}
}
return rec;
}
bool CCz_cl::jl_check()//检查距离是否测完
{
if(!theApp.DataBase.OpenTable(theApp.DataBase.szFileName,_T("DXJL")))
{
AfxMessageBox(_T("不能打开DXJL数据库"));
return true;
}
int sumrec=theApp.DataBase.GetRecordNumber();
CTSX *m_obj;
int i,j, index=theApp.clsx.GetSize();
while(index>0)
{
m_obj=theApp.clsx.GetAt(0);
theApp.clsx.RemoveAt(0);
index=theApp.clsx.GetSize();
delete m_obj;
}
index=theApp.fxmc.GetSize();
CString str;
for(i=0;i<index;i++)
{
str=theApp.fxmc.GetAt(i)->cdm;
for(j=0;j<sumrec;j++)
{
theApp.DataBase.ReadRecord(j);
if(str.Compare(theApp.DataBase.m_values.GetAt(2))==0)
{
if(theApp.DataBase.m_values.GetAt(5).Compare(_T("-10.0"))==0)
{
m_obj=new CTSX;
wcscpy(m_obj->CDM,theApp.DataBase.m_values.GetAt(2));
m_obj->cbg=-10.0;
wcscpy(m_obj->L_R,_T("盘左"));
m_obj->chs=(int) m_wtof(theApp.DataBase.m_values.GetAt(0));
m_obj->czj=false;
m_obj->spj=false;
m_obj->jl=true;
m_obj->chjsbz=0;
theApp.clsx.Add(m_obj);
}
}
}
}
index=theApp.clsx.GetSize();
if(index>0)
{
theApp.clsx.GetAt(index-1)->chjsbz=1;
return false;
}else
return true;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -