5025 lines
149 KiB
C++
5025 lines
149 KiB
C++
#include "LogIO.h"
|
||
#include <QDataStream>
|
||
#include <QObject>
|
||
#include <QDir>
|
||
#include <QCoreApplication>
|
||
#pragma execution_character_set("utf-8")
|
||
char* GetDescription(LAYER_DATA &m_Result,char *buf)
|
||
{
|
||
buf[0]=0;
|
||
if(m_Result.Zone[0]!=' '&&m_Result.Zone[0]!='\0') {
|
||
int n=strlen(m_Result.Zone);
|
||
if(n>16) n=16;
|
||
strncpy(buf,m_Result.Zone,n);
|
||
buf[n]=0;
|
||
}
|
||
else {
|
||
int n=strlen(m_Result.Description1);
|
||
if(n>48) n=48;
|
||
strncpy(buf,m_Result.Description1,n);
|
||
buf[n]=0;
|
||
if(strlen(m_Result.Description2)){
|
||
if(strlen(buf))strcat(buf,"-");
|
||
strcat(buf,m_Result.Description2);
|
||
}
|
||
if(strlen(m_Result.Description3)){
|
||
if(strlen(buf))strcat(buf,"-");
|
||
strcat(buf,m_Result.Description3);
|
||
}
|
||
if(strlen(m_Result.Description4)){
|
||
if(strlen(buf))strcat(buf,"-");
|
||
strcat(buf,m_Result.Description4);
|
||
}
|
||
if(strlen(m_Result.Description5)){
|
||
if(strlen(buf))strcat(buf,"-");
|
||
strcat(buf,m_Result.Description5);
|
||
}
|
||
if(strlen(m_Result.Description6)){
|
||
if(strlen(buf))strcat(buf,"-");
|
||
strcat(buf,m_Result.Description6);
|
||
}
|
||
if(strlen(m_Result.Description7)){
|
||
if(strlen(buf))strcat(buf,"-");
|
||
strcat(buf,m_Result.Description7);
|
||
}
|
||
if(strlen(m_Result.Description8)){
|
||
if(strlen(buf))strcat(buf,"-");
|
||
strcat(buf,m_Result.Description8);
|
||
}
|
||
if(strlen(m_Result.Description9)){
|
||
if(strlen(buf))strcat(buf,"-");
|
||
strcat(buf,m_Result.Description9);
|
||
}
|
||
/*
|
||
if(strlen(m_Result.Description10)){
|
||
if(strlen(buf))strcat(buf,"-");
|
||
strcat(buf,m_Result.Description10);
|
||
}
|
||
*/
|
||
}
|
||
return buf;
|
||
}
|
||
void ComputeH(QString zonename,LAYER_DATA &tempRes,float h,float total)
|
||
{
|
||
h=QString::number(h+0.0001,'f',1).toFloat();
|
||
if(zonename=="干层") {
|
||
tempRes.Tt-=h;
|
||
}
|
||
if(strcmp(zonename.toStdString().c_str(),"油层")==0||
|
||
strcmp(zonename.toStdString().c_str(),"偏干油层")==0||
|
||
strcmp(zonename.toStdString().c_str(),"含水油层")==0||
|
||
strcmp(zonename.toStdString().c_str(),"含气油层")==0
|
||
) {
|
||
if(total) h=total-tempRes.Oil;
|
||
tempRes.Oil+=h;
|
||
}
|
||
else if(zonename=="差油层") {
|
||
if(total) h=total-tempRes.PoorOil;
|
||
tempRes.PoorOil+=h;
|
||
}
|
||
else if(zonename=="油水同层") {
|
||
if(total) h=total-tempRes.OilWater;
|
||
tempRes.OilWater+=h;
|
||
}
|
||
else if(zonename=="含油水层") {
|
||
if(total) h=total-tempRes.WaterOil;
|
||
tempRes.WaterOil+=h;
|
||
}
|
||
else if(zonename=="气层") {
|
||
if(total) h=total-tempRes.Gas;
|
||
tempRes.Gas+=h;
|
||
}
|
||
else if(zonename=="差气层") {
|
||
if(total) h=total-tempRes.PoorGas;
|
||
tempRes.PoorGas+=h;
|
||
}
|
||
else if(zonename=="气水同层") {
|
||
if(total) h=total-tempRes.GasWater;
|
||
tempRes.GasWater+=h;
|
||
}
|
||
else if(zonename=="含气水层") {
|
||
if(total) h=total-tempRes.WaterGas;
|
||
tempRes.WaterGas+=h;
|
||
}
|
||
}
|
||
void GetWellNameAndPath(QString slf,QString &wellname,QString &path)//,QString &slffilename)
|
||
{
|
||
QString slffilename=QString("");
|
||
|
||
int ind=slf.lastIndexOf('\\');
|
||
int ind2=slf.lastIndexOf('/');
|
||
if(ind2>ind) ind=ind2;
|
||
if(ind>-1) {
|
||
slffilename=slf.mid(ind+1);
|
||
path=slf.left(ind);
|
||
ind=slffilename.lastIndexOf('.');
|
||
if(ind>0) wellname=slffilename.left(ind);
|
||
}
|
||
}
|
||
void ComputeTT(LAYER_DATA &m_Result,
|
||
QString &result,
|
||
QString &result1,
|
||
QString &result2,
|
||
QString &result3,
|
||
QString &result4,
|
||
QString &result5,
|
||
QString &result6,
|
||
QString &result7,
|
||
QString &result8,
|
||
QString &result9,
|
||
QString &result10
|
||
)
|
||
{
|
||
float d1=QString::number(m_Result.StartDepth+0.0001,'f',1).toFloat();
|
||
float d2=QString::number(m_Result.EndDepth+0.0001,'f',1).toFloat();
|
||
m_Result.Thick=d2-d1+0.000001;
|
||
m_Result.Tt=m_Result.Thick;
|
||
QStringList strs;
|
||
strs.append("油层");
|
||
strs.append("偏干油层");
|
||
strs.append("含水油层");
|
||
strs.append("含气油层");
|
||
strs.append("差油层");
|
||
strs.append("油水同层");
|
||
strs.append("含油水层");
|
||
strs.append("气层");
|
||
strs.append("差气层");
|
||
strs.append("气水同层");
|
||
strs.append("含气水层");
|
||
int ind=0;
|
||
int fc=0;
|
||
int isw=0;
|
||
float tt=0;
|
||
if(m_Result.MDepth10){
|
||
fc=1;
|
||
float h=m_Result.EndDepth-m_Result.MDepth10;
|
||
QString path,zonename;
|
||
GetWellNameAndPath(result10,zonename,path);
|
||
ComputeH(zonename,m_Result,h);
|
||
if(strs.indexOf(zonename)<0) isw=1;
|
||
else tt+=QString::number(h+0.0001,'f',1).toFloat();
|
||
ind=10;
|
||
}
|
||
if(m_Result.MDepth9){
|
||
fc=1;
|
||
float h=0;
|
||
if(!ind) h=m_Result.EndDepth-m_Result.MDepth9;
|
||
else h=m_Result.MDepth10-m_Result.MDepth9;
|
||
QString path,zonename;
|
||
GetWellNameAndPath(result9,zonename,path);
|
||
ComputeH(zonename,m_Result,h);
|
||
if(!ind)ind=9;
|
||
if(strs.indexOf(zonename)<0) isw=1;
|
||
else tt+=QString::number(h+0.0001,'f',1).toFloat();
|
||
}
|
||
if(m_Result.MDepth8){
|
||
fc=1;
|
||
float h=0;
|
||
if(!ind) h=m_Result.EndDepth-m_Result.MDepth8;
|
||
else h=m_Result.MDepth9-m_Result.MDepth8;
|
||
QString path,zonename;
|
||
GetWellNameAndPath(result8,zonename,path);
|
||
ComputeH(zonename,m_Result,h);
|
||
if(!ind)ind=8;
|
||
if(strs.indexOf(zonename)<0) isw=1;
|
||
else tt+=QString::number(h+0.0001,'f',1).toFloat();
|
||
}
|
||
if(m_Result.MDepth7){
|
||
fc=1;
|
||
float h=0;
|
||
if(!ind) h=m_Result.EndDepth-m_Result.MDepth7;
|
||
else h=m_Result.MDepth8-m_Result.MDepth7;
|
||
QString path,zonename;
|
||
GetWellNameAndPath(result7,zonename,path);
|
||
ComputeH(zonename,m_Result,h);
|
||
if(!ind)ind=7;
|
||
if(strs.indexOf(zonename)<0) isw=1;
|
||
else tt+=QString::number(h+0.0001,'f',1).toFloat();
|
||
}
|
||
if(m_Result.MDepth6){
|
||
fc=1;
|
||
float h=0;
|
||
if(!ind) h=m_Result.EndDepth-m_Result.MDepth6;
|
||
else h=m_Result.MDepth7-m_Result.MDepth6;
|
||
QString path,zonename;
|
||
GetWellNameAndPath(result6,zonename,path);
|
||
ComputeH(zonename,m_Result,h);
|
||
if(!ind)ind=6;
|
||
if(strs.indexOf(zonename)<0) isw=1;
|
||
else tt+=QString::number(h+0.0001,'f',1).toFloat();
|
||
}
|
||
if(m_Result.MDepth5){
|
||
fc=1;
|
||
float h=0;
|
||
if(!ind) h=m_Result.EndDepth-m_Result.MDepth5;
|
||
else h=m_Result.MDepth6-m_Result.MDepth5;
|
||
QString path,zonename;
|
||
GetWellNameAndPath(result5,zonename,path);
|
||
ComputeH(zonename,m_Result,h);
|
||
if(!ind)ind=5;
|
||
if(strs.indexOf(zonename)<0) isw=1;
|
||
else tt+=QString::number(h+0.0001,'f',1).toFloat();
|
||
}
|
||
if(m_Result.MDepth4) {
|
||
fc=1;
|
||
float h=0;
|
||
if(!ind) h=m_Result.EndDepth-m_Result.MDepth4;
|
||
else h=m_Result.MDepth5-m_Result.MDepth4;
|
||
QString path,zonename;
|
||
GetWellNameAndPath(result4,zonename,path);
|
||
ComputeH(zonename,m_Result,h);
|
||
if(!ind)ind=4;
|
||
if(strs.indexOf(zonename)<0) isw=1;
|
||
else tt+=QString::number(h+0.0001,'f',1).toFloat();
|
||
}
|
||
if(m_Result.MDepth3) {
|
||
fc=1;
|
||
float h=0;
|
||
if(!ind) h=m_Result.EndDepth-m_Result.MDepth3;
|
||
else h=m_Result.MDepth4-m_Result.MDepth3;
|
||
QString path,zonename;
|
||
GetWellNameAndPath(result3,zonename,path);
|
||
ComputeH(zonename,m_Result,h);
|
||
if(!ind)ind=3;
|
||
if(strs.indexOf(zonename)<0) isw=1;
|
||
else tt+=QString::number(h+0.0001,'f',1).toFloat();
|
||
}
|
||
if(m_Result.MDepth2) {
|
||
fc=1;
|
||
float h=0;
|
||
if(!ind) h=m_Result.EndDepth-m_Result.MDepth2;
|
||
else h=m_Result.MDepth3-m_Result.MDepth2;
|
||
QString path,zonename;
|
||
GetWellNameAndPath(result2,zonename,path);
|
||
ComputeH(zonename,m_Result,h);
|
||
if(!ind)ind=2;
|
||
if(strs.indexOf(zonename)<0) isw=1;
|
||
else tt+=QString::number(h+0.0001,'f',1).toFloat();
|
||
}
|
||
if(m_Result.MDepth1) {
|
||
fc=1;
|
||
float h=0;
|
||
if(!ind) h=m_Result.EndDepth-m_Result.MDepth1;
|
||
else h=m_Result.MDepth2-m_Result.MDepth1;
|
||
QString path,zonename;
|
||
GetWellNameAndPath(result1,zonename,path);
|
||
ComputeH(zonename,m_Result,h);
|
||
if(strs.indexOf(zonename)<0) isw=1;
|
||
else tt+=QString::number(h+0.0001,'f',1).toFloat();
|
||
GetWellNameAndPath(result,zonename,path);
|
||
if(strs.indexOf(zonename)<0) isw=1;
|
||
if(isw) h=m_Result.MDepth1-m_Result.StartDepth;
|
||
else h=m_Result.Thick-tt;
|
||
ComputeH(zonename,m_Result,h);
|
||
if(!ind)ind=1;
|
||
}
|
||
if(!fc) {
|
||
fc=1;
|
||
float h=m_Result.Thick;
|
||
QString path,zonename;
|
||
GetWellNameAndPath(result,zonename,path);
|
||
ComputeH(zonename,m_Result,h);
|
||
}
|
||
}
|
||
CLogIO ::CLogIO()
|
||
{
|
||
m_Curve=NULL;
|
||
m_Wave=NULL;
|
||
m_Fmt=NULL;
|
||
Slf_Info=NULL;
|
||
m_MenuNumber=0;
|
||
}
|
||
QString GetOilFieldName()
|
||
{
|
||
QString strProjectDir = QCoreApplication::applicationDirPath()+ QDir::separator() + "..";
|
||
strProjectDir += QDir::separator();
|
||
QString path=strProjectDir;
|
||
path+="oilfield.ini";
|
||
FILE *fp=fopen(path.toStdString().c_str(),"rt");
|
||
char oilfield[200];
|
||
oilfield[0]=0;
|
||
if(fp) {
|
||
fscanf(fp,"%s\n",oilfield);
|
||
fclose(fp);
|
||
}
|
||
QString cs=oilfield;
|
||
if(!cs.isEmpty()) return cs+QDir::separator();
|
||
else return cs;
|
||
}
|
||
CLogIO ::CLogIO(const char* szLogFileName,int FileType):CSlfIO(szLogFileName,FileType)
|
||
{
|
||
m_Curve=NULL;
|
||
m_Wave=NULL;
|
||
m_Fmt=NULL;
|
||
m_MenuNumber=0;
|
||
int MaxObjectNumber=m_Head.MaxObjectNumber;
|
||
if(!IsWis) MaxObjectNumber=m_SlfHead.MaxTableNumber;
|
||
Slf_Info= new char * [MaxObjectNumber];
|
||
for(int i=0;i<MaxObjectNumber;i++) Slf_Info[i]=NULL;
|
||
QString strConfPath;
|
||
{
|
||
QString strPathTmp = QCoreApplication::applicationDirPath()+ QDir::separator() ;
|
||
strConfPath = QDir::toNativeSeparators( strPathTmp );
|
||
strConfPath=strPathTmp + "conf" + QDir::separator();
|
||
}
|
||
if(GetOilFieldName().indexOf("胜利")>-1) isShengLi=1;
|
||
QString strPathTmp=strConfPath+"ENUM.ini";
|
||
FILE *fp=fopen(strPathTmp.toStdString().c_str(),"r+t");
|
||
if(fp) {
|
||
char tem[100];
|
||
while(!feof(fp)) {
|
||
int ret=fscanf(fp,"%s",tem);
|
||
if(ret<1) break;
|
||
if(tem[0]) {
|
||
QString strPathTmp1=strConfPath+GetOilFieldName()+tem+".ini";
|
||
FILE *fp1=fopen(strPathTmp1.toStdString().c_str(),"r+t");
|
||
if(fp1) {
|
||
char buf1[100];
|
||
Slf_Menu[m_MenuNumber].clear();
|
||
while(!feof(fp1)) {
|
||
int ret=fscanf(fp1,"%s",buf1);
|
||
if(ret<1) break;
|
||
Slf_Menu[m_MenuNumber].append(buf1);
|
||
}
|
||
fclose(fp1);
|
||
m_MenuNumber++;
|
||
}
|
||
}
|
||
}
|
||
fclose(fp);
|
||
}
|
||
}
|
||
CLogIO ::CLogIO(const char* szLogFileName,unsigned int nOpenFlags,int BlockLen,int MaxObjectNumber, int MachineType,int FileType)
|
||
{
|
||
m_Curve=NULL;
|
||
m_Wave=NULL;
|
||
m_Fmt=NULL;
|
||
if(!Open(szLogFileName,nOpenFlags,BlockLen,MaxObjectNumber,MachineType,FileType)) exit(0);
|
||
}
|
||
bool CLogIO ::Open(const char* szLogFileName,unsigned int nOpenFlags,int BlockLen,int MaxObjectNumber, int MachineType,int FileType)
|
||
{
|
||
if(CSlfIO::Open(szLogFileName,nOpenFlags,BlockLen,MaxObjectNumber,MachineType,FileType))
|
||
{
|
||
m_MenuNumber=0;
|
||
int MaxObjectNumber=m_Head.MaxObjectNumber;
|
||
if(!IsWis) MaxObjectNumber=m_SlfHead.MaxTableNumber;
|
||
Slf_Info= new char * [MaxObjectNumber];
|
||
for(int i=0;i<MaxObjectNumber;i++) Slf_Info[i]=NULL;
|
||
QString strConfPath;
|
||
{
|
||
QString strPathTmp = QCoreApplication::applicationDirPath()+ QDir::separator() ;
|
||
strConfPath = QDir::toNativeSeparators( strPathTmp );
|
||
strConfPath=strPathTmp + "conf" + QDir::separator();
|
||
}
|
||
QString strPathTmp=strConfPath+"ENUM.ini";
|
||
FILE *fp=fopen(strPathTmp.toStdString().c_str(),"r+t");
|
||
if(fp) {
|
||
char tem[100];
|
||
while(!feof(fp)) {
|
||
int ret=fscanf(fp,"%s",tem);
|
||
if(ret<1) break;
|
||
if(tem[0]) {
|
||
QString strPathTmp1=strConfPath+GetOilFieldName()+tem+".ini";
|
||
FILE *fp1=fopen(strPathTmp1.toStdString().c_str(),"r+t");
|
||
if(fp1) {
|
||
char buf1[100];
|
||
Slf_Menu[m_MenuNumber].clear();
|
||
while(!feof(fp1)) {
|
||
int ret=fscanf(fp1,"%s",buf1);
|
||
if(ret<1) break;
|
||
Slf_Menu[m_MenuNumber].append(buf1);
|
||
}
|
||
fclose(fp1);
|
||
m_MenuNumber++;
|
||
}
|
||
}
|
||
}
|
||
fclose(fp);
|
||
}
|
||
return TRUE;
|
||
}
|
||
else {
|
||
return FALSE;
|
||
}
|
||
}
|
||
CLogIO ::~CLogIO()
|
||
{
|
||
if(Slf_Info) {
|
||
int MaxObjectNumber=0;
|
||
if(!IsWis) MaxObjectNumber=m_SlfHead.MaxTableNumber;
|
||
else MaxObjectNumber=m_Head.MaxObjectNumber;
|
||
for(int i=0;i<MaxObjectNumber;i++) {
|
||
if(Slf_Info[i]) delete Slf_Info[i];
|
||
}
|
||
delete []Slf_Info;
|
||
}
|
||
Slf_Info=NULL;
|
||
}
|
||
void CLogIO::Close()
|
||
{
|
||
if(Slf_Info&&Slf_Info!=(char **)0xcccccccc){
|
||
int MaxObjectNumber=m_Head.MaxObjectNumber;
|
||
if(!IsWis) MaxObjectNumber=m_SlfHead.MaxTableNumber;
|
||
for(int i=0;i<MaxObjectNumber;i++) {
|
||
if(Slf_Info[i]) delete Slf_Info[i];
|
||
}
|
||
delete []Slf_Info;
|
||
}
|
||
Slf_Info=NULL;
|
||
CSlfIO::Close();
|
||
}
|
||
bool CLogIO :: MoveDepth(int index,float sdep, float edep, float delta)
|
||
{
|
||
if(IsWis) {
|
||
return WisMoveDepth(index,sdep,edep,delta);
|
||
}
|
||
return SlfMoveDepth(index,sdep,edep,delta);
|
||
}
|
||
bool CLogIO :: WisMoveDepth(int index,float sdep, float edep, float delta)
|
||
{
|
||
m_Curve=(Slf_CURVE *)Slf_Info[index];
|
||
int samples1=Slf_Int(sdep,m_Curve->StartDepth,m_Curve->DepLevel);//(int)((sdep-m_Curve->StartDepth)/m_Curve->DepLevel+0.5);
|
||
if(samples1<0) samples1=0;
|
||
int samples2=Slf_Int(edep,m_Curve->StartDepth,m_Curve->DepLevel);//(int)((edep-m_Curve->StartDepth)/m_Curve->DepLevel+0.5);
|
||
if(samples2<0) samples2=0;
|
||
int move=0;
|
||
if(delta>0) move=(int)(delta/m_Curve->DepLevel+0.5);
|
||
else move=(int)(delta/m_Curve->DepLevel-0.5);
|
||
MoveChannel(index,0,samples1,move,samples2);
|
||
return 1;
|
||
}
|
||
bool CLogIO :: SlfMoveDepth(int index,float sdep, float edep, float delta)
|
||
{
|
||
Slf_CURVE m_Curve;
|
||
GetSlfCurveInfo(index,&m_Curve);
|
||
int samples1=Slf_Int(sdep,m_Curve.StartDepth,m_Curve.DepLevel);//((sdep-m_Curve.StartDepth)/m_Curve.DepLevel+1.5);
|
||
if(samples1<0) samples1=0;
|
||
int samples2=Slf_Int(edep,m_Curve.StartDepth,m_Curve.DepLevel);//((edep-m_Curve.StartDepth)/m_Curve.DepLevel+0.5);
|
||
samples2++;
|
||
if(m_Curve.StartDepth+samples2*m_Curve.DepLevel>m_Curve.EndDepth) samples2-=1;
|
||
if(samples2<0) samples2=0;
|
||
int move=1;
|
||
if(delta>0) move=(int)(delta/m_Curve.DepLevel+0.5);
|
||
else move=(int)(delta/m_Curve.DepLevel-0.5);
|
||
MoveSlfTable(index,samples1,samples2,move);
|
||
return 1;
|
||
}
|
||
bool CLogIO :: WisCorrectDepth(int index,float delta)
|
||
{
|
||
CorrectChannel(index,0,delta);
|
||
return TRUE;
|
||
}
|
||
bool CLogIO :: SlfCorrectDepth(int index,float delta)
|
||
{
|
||
CorrectSlfTableField(index,0,delta);
|
||
return TRUE;
|
||
}
|
||
bool CLogIO :: CorrectDepth(int index,float delta)
|
||
{
|
||
if(IsWis) return WisCorrectDepth(index,delta);
|
||
return SlfCorrectDepth(index,delta);
|
||
}
|
||
bool CLogIO :: ExpandDepth(int index,float sdep,float edep)
|
||
{
|
||
if(IsWis) return WisExpandDepth(index,sdep,edep);
|
||
return SlfExpandDepth(index,sdep,edep);
|
||
}
|
||
bool CLogIO :: WisExpandDepth(int index,float sdep,float edep)
|
||
{
|
||
m_Curve=(Slf_CURVE*)Slf_Info[index];
|
||
int samples1=Slf_Int(sdep,m_Curve->StartDepth,m_Curve->DepLevel);//(int)((sdep-m_Curve->StartDepth)/m_Curve->DepLevel+0.5);
|
||
if(samples1<0) samples1=0;
|
||
int samples2=Slf_Int(edep,m_Curve->StartDepth,m_Curve->DepLevel);//(int)((edep-m_Curve->StartDepth)/m_Curve->DepLevel+0.5);
|
||
if(samples2<0) samples2=0;
|
||
ExpandChannel(index,0,samples1,samples2);
|
||
return 1;
|
||
}
|
||
bool CLogIO :: SlfExpandDepth(int index,float sdep,float edep)
|
||
{
|
||
Slf_CURVE m_Curve;
|
||
GetSlfCurveInfo(index,&m_Curve);
|
||
int samples1=Slf_Int(sdep,m_Curve.StartDepth,m_Curve.DepLevel);//(int)((sdep-m_Curve.StartDepth)/m_Curve.DepLevel+0.5);
|
||
int samples2=Slf_Int(edep,m_Curve.StartDepth,m_Curve.DepLevel);//(int)((edep-m_Curve.StartDepth)/m_Curve.DepLevel+0.5);
|
||
if(samples1<0) samples1=0;
|
||
if(samples2<0) samples2=0;
|
||
SetSlfTableRecordCount(index,samples2);
|
||
return 1;
|
||
}
|
||
int CLogIO :: OpenCurve(const char* name)
|
||
{
|
||
if( IsWis) return OpenWisCurve(name);
|
||
return OpenSlfCurve(name);
|
||
}
|
||
int CLogIO :: OpenSlfCurve(const char* name)
|
||
{
|
||
int index=FindSlfObjectName((char *)name,CURVE_OBJECT);
|
||
if(index<0)return -1;
|
||
return OpenSlfTable(name,CURVE_OBJECT);
|
||
}
|
||
int CLogIO :: OpenWisCurve(const char* name)
|
||
{
|
||
int index = OpenChannel(name,CURVE_OBJECT);
|
||
if(index>-1) {
|
||
if(!Slf_Info[index]) Slf_Info[index]=new char [sizeof(Slf_CURVE)];
|
||
m_Curve=(Slf_CURVE*)Slf_Info[index];
|
||
GetCurveInfo(index,m_Curve);
|
||
return index;
|
||
}
|
||
else return -1;
|
||
}
|
||
|
||
int CLogIO :: OpenCurve(Slf_CURVE *pCurve,bool bFailExist)
|
||
{
|
||
if(IsWis) return OpenWisCurve(pCurve,bFailExist);
|
||
return OpenSlfCurve(pCurve,bFailExist);
|
||
}
|
||
int CLogIO :: OpenWisCurve(Slf_CURVE *pCurve,bool bFailExist)
|
||
{
|
||
int index = OpenCurve(pCurve->Name);
|
||
if(index>-1) {
|
||
Slf_CURVE info;
|
||
GetCurveInfo(index,&info);
|
||
if(info.CodeLen!=pCurve->CodeLen||info.RepCode!=pCurve->RepCode) {
|
||
char newname[200];
|
||
strcpy(newname,pCurve->Name);
|
||
strcat(newname,".bak");
|
||
CString sss;
|
||
sss.Format("OpenWisCurve %s",newname);
|
||
AfxMessageBox(sss);
|
||
RenameObject(pCurve->Name,newname);
|
||
index=-1;
|
||
}
|
||
}
|
||
if(index<0) index=CreateCurve(pCurve,bFailExist);
|
||
else if(bFailExist) CreateCurve(pCurve,bFailExist);
|
||
return index;
|
||
}
|
||
int CLogIO :: OpenSlfCurve(Slf_CURVE *pCurve,bool bFailExist)
|
||
{
|
||
int index = OpenSlfCurve(pCurve->Name);
|
||
if(index>-1) {
|
||
Slf_CURVE info;
|
||
GetCurveInfo(index,&info);
|
||
if(info.CodeLen!=pCurve->CodeLen||info.RepCode!=pCurve->RepCode)//||info.DefVal!=pCurve->DefVal)
|
||
{
|
||
char newname[200];
|
||
strcpy(newname,pCurve->Name);
|
||
strcat(newname,".bak");
|
||
//CString s1;
|
||
QString str=QObject::tr("info.CodeLen=%d,pCurve->CodeLen=%d\r\ninfo.RepCode=%d,pCurve->RepCode=%d\r\n").arg(info.CodeLen)
|
||
.arg(pCurve->CodeLen)
|
||
.arg(info.RepCode)
|
||
.arg(pCurve->RepCode);
|
||
//s1.Format("info.CodeLen=%d,pCurve->CodeLen=%d\r\ninfo.RepCode=%d,pCurve->RepCode=%d\r\n",
|
||
// info.CodeLen,pCurve->CodeLen,info.RepCode,pCurve->RepCode);
|
||
CString s1(str.toStdString().c_str());
|
||
CString sss;
|
||
sss.Format("OpenSlfCurve %s\r\n",newname);
|
||
AfxMessageBox(sss+s1);
|
||
RenameObject(pCurve->Name,newname);
|
||
index=-1;
|
||
}
|
||
}
|
||
|
||
if(index<0) index=CreateSlfCurve(pCurve,bFailExist);
|
||
else if(bFailExist) CreateSlfCurve(pCurve,bFailExist);
|
||
return index;
|
||
}
|
||
bool CLogIO :: GetWisCurveInfo(int index,Slf_CURVE* pInfo)
|
||
{
|
||
GetChannelInfo(index,&cpInfo);
|
||
memmove(pInfo->AliasName,cpInfo.AliasName,sizeof(pInfo->AliasName));
|
||
memmove(pInfo->Name,m_ObjectEntry[index].Name,sizeof(pInfo->Name));
|
||
pInfo->CodeLen=cpInfo.CodeLen;
|
||
pInfo->RepCode=cpInfo.RepCode;
|
||
pInfo->DepLevel=cpInfo.DimInfo[0].Delta;
|
||
pInfo->MaxValue=cpInfo.MaxVal;
|
||
pInfo->MinValue=cpInfo.MinVal;
|
||
memmove(pInfo->Unit,cpInfo.Unit,sizeof(pInfo->Unit));
|
||
memmove(pInfo->AliasUnit,cpInfo.AliasUnit,sizeof(pInfo->AliasUnit));
|
||
memmove(pInfo->DepthUnit,cpInfo.DimInfo[0].Unit,sizeof(pInfo->DepthUnit));
|
||
pInfo->StartDepth=cpInfo.DimInfo[0].StartVal;
|
||
pInfo->EndDepth=pInfo->StartDepth+(cpInfo.DimInfo[0].Samples-1)*cpInfo.DimInfo[0].Delta;
|
||
return TRUE;
|
||
}
|
||
bool CLogIO :: SetWisCurveInfo(int index,Slf_CURVE* pInfo)
|
||
{
|
||
GetChannelInfo(index,&cpInfo);
|
||
|
||
memmove(cpInfo.AliasName,pInfo->AliasName,sizeof(cpInfo.AliasName));
|
||
memmove(m_ObjectEntry[index].Name,pInfo->Name,sizeof(pInfo->Name));
|
||
WriteObjectEntry();
|
||
/*
|
||
pInfo->CodeLen=cpInfo.CodeLen;
|
||
pInfo->RepCode=cpInfo.RepCode;
|
||
pInfo->MaxValue=cpInfo.MaxVal;
|
||
pInfo->MinValue=cpInfo.MinVal;
|
||
*/
|
||
if(pInfo->DepLevel!=cpInfo.DimInfo[0].Delta) WisChannelResamples(index,pInfo->DepLevel);
|
||
memmove(cpInfo.Unit,pInfo->Unit,sizeof(cpInfo.Unit));
|
||
memmove(cpInfo.AliasUnit,pInfo->AliasUnit,sizeof(cpInfo.AliasUnit));
|
||
memmove(cpInfo.DimInfo[0].Unit,pInfo->DepthUnit,sizeof(cpInfo.DimInfo[0].Unit));
|
||
cpInfo.DimInfo[0].StartVal=pInfo->StartDepth;
|
||
SetChannelInfo(index,&cpInfo);
|
||
return TRUE;
|
||
}
|
||
bool CLogIO :: GetCurveInfo(int index,Slf_CURVE* pInfo)
|
||
{
|
||
if(IsWis) return GetWisCurveInfo(index,pInfo);
|
||
return GetSlfCurveInfo(index,pInfo);
|
||
}
|
||
bool CLogIO :: GetSlfCurveInfo(int index,Slf_CURVE* pInfo)
|
||
{
|
||
if(index<0) return 0;
|
||
int FieldNum=GetSlfTableFieldCount(index);
|
||
int rec=GetSlfTableRecordCount(index);
|
||
Slf_TABLE_ENTRY obj;
|
||
GetSlfObjectEntry(index,&obj);
|
||
Slf_OBJECT_FIELD *pf=new Slf_OBJECT_FIELD[FieldNum];
|
||
memset(pf,0,sizeof(Slf_OBJECT_FIELD)*FieldNum);
|
||
GetSlfTableFieldInfo(index,pf);
|
||
|
||
memmove(pInfo->Name,obj.Name,sizeof(pInfo->Name));
|
||
memmove(pInfo->AliasName,obj.HZName,sizeof(pInfo->AliasName));
|
||
memmove(pInfo->Unit,obj.Unit,sizeof(pInfo->Unit));
|
||
memmove(pInfo->AliasUnit,obj.HZUnit,sizeof(pInfo->AliasUnit));
|
||
memmove(pInfo->LogCopanyName,obj.LogCopanyName,sizeof(pInfo->LogCopanyName));
|
||
memmove(pInfo->LoggingTeam,obj.LoggingTeam,sizeof(pInfo->LoggingTeam));
|
||
memmove(pInfo->DataSource,obj.DataSource,sizeof(pInfo->DataSource));
|
||
memmove(pInfo->Operator,obj.Operator,sizeof(pInfo->Operator));
|
||
pInfo->SerialID=obj.SerialID;
|
||
pInfo->LoggingDate=obj.LoggingDate;
|
||
pInfo->ChangeNum=obj.ChangeNum;
|
||
|
||
pInfo->CodeLen=pf[1].CodeLength;
|
||
pInfo->RepCode=pf[1].RepCode;
|
||
pInfo->DepLevel=pf[0].Rlev;
|
||
pInfo->MaxValue=pf[1].Vmax;
|
||
pInfo->MinValue=pf[1].Vmin;
|
||
pInfo->DefVal=pf[1].DefVal;
|
||
|
||
memmove(pInfo->Unit,pf[1].Unit,sizeof(pInfo->Unit));
|
||
memmove(pInfo->AliasUnit,pf[1].HZUnit,sizeof(pInfo->AliasUnit));
|
||
memmove(pInfo->DepthUnit,pf[0].Unit,sizeof(pInfo->DepthUnit));
|
||
memmove(pInfo->DepthHZUnit,pf[0].HZUnit,sizeof(pInfo->DepthHZUnit));
|
||
|
||
pInfo->StartDepth=pf[0].Start;
|
||
pInfo->EndDepth=pf[0].Start+(rec-1)*pf[0].Rlev;
|
||
|
||
delete []pf;
|
||
return TRUE;
|
||
}
|
||
bool CLogIO :: SetSlfCurveInfo(int index,Slf_CURVE* pInfo)
|
||
{
|
||
if(index<0) return 0;
|
||
int FieldNum=GetSlfTableFieldCount(index);
|
||
int rec=GetSlfTableRecordCount(index);
|
||
Slf_TABLE_ENTRY obj;
|
||
GetSlfObjectEntry(index,&obj);
|
||
Slf_OBJECT_FIELD *pf=new Slf_OBJECT_FIELD[FieldNum];
|
||
memset(pf,0,sizeof(Slf_OBJECT_FIELD)*FieldNum);
|
||
GetSlfTableFieldInfo(index,pf);
|
||
//whp add
|
||
if(strlen(pInfo->AliasName)>sizeof(pInfo->AliasName))strcpy(pInfo->AliasName,pInfo->Name);
|
||
if(strlen(pInfo->Unit)>sizeof(pInfo->Unit))strcpy(pInfo->Unit,"");
|
||
if(strlen(pInfo->AliasUnit)>sizeof(pInfo->AliasUnit))strcpy(pInfo->AliasUnit,pInfo->Unit);
|
||
if(strlen(pInfo->DepthUnit)>sizeof(pInfo->DepthUnit))strcpy(pInfo->DepthUnit,"m");
|
||
if(strlen(pInfo->DepthHZUnit)>sizeof(pInfo->DepthHZUnit))strcpy(pInfo->DepthHZUnit,"米");
|
||
if(strlen(pInfo->LogCopanyName)>sizeof(pInfo->LogCopanyName))strcpy(pInfo->LogCopanyName,"");
|
||
if(strlen(pInfo->Operator)>sizeof(pInfo->Operator))strcpy(pInfo->Operator,"");
|
||
if(strlen(pInfo->DataSource)>sizeof(pInfo->DataSource))strcpy(pInfo->DataSource,"create");
|
||
if(strlen(pInfo->LoggingTeam)>sizeof(pInfo->LoggingTeam))strcpy(pInfo->LoggingTeam,"");
|
||
//
|
||
memmove(obj.HZName,pInfo->AliasName,sizeof(obj.HZName));
|
||
memmove(obj.Name,pInfo->Name,sizeof(pInfo->Name));
|
||
memmove(obj.HZName,pInfo->AliasName,sizeof(obj.HZName));
|
||
memmove(obj.Unit,pInfo->Unit,sizeof(obj.Unit));
|
||
memmove(obj.HZUnit,pInfo->AliasUnit,sizeof(obj.HZUnit));
|
||
memmove(obj.LogCopanyName,pInfo->LogCopanyName,sizeof(obj.LogCopanyName));
|
||
memmove(obj.LoggingTeam,pInfo->LoggingTeam,sizeof(obj.LoggingTeam));
|
||
memmove(obj.DataSource,pInfo->DataSource,sizeof(obj.DataSource));
|
||
memmove(obj.Operator,pInfo->Operator,sizeof(obj.Operator));
|
||
obj.SerialID=pInfo->SerialID;
|
||
obj.LoggingDate=pInfo->LoggingDate;
|
||
obj.ChangeNum=pInfo->ChangeNum;
|
||
|
||
WriteSlfObjectEntry(index,&obj);
|
||
|
||
pf[1].Vmax=pInfo->MaxValue;
|
||
pf[1].Vmin=pInfo->MinValue;
|
||
pf[1].DefVal=pInfo->DefVal;
|
||
|
||
if(pf[0].Rlev!=pInfo->DepLevel) SlfTableResamples(index,pInfo->DepLevel);
|
||
|
||
memmove(pf[1].Unit,pInfo->Unit,sizeof(pf[1].Unit));
|
||
memmove(pf[1].HZUnit,pInfo->AliasUnit,sizeof(pf[1].HZUnit));
|
||
memmove(pf[0].Unit,pInfo->DepthUnit,sizeof(pf[0].Unit));
|
||
memmove(pf[0].HZUnit,pInfo->DepthHZUnit,sizeof(pf[0].Unit));
|
||
pf[0].Start=pInfo->StartDepth;
|
||
SetSlfTableFieldInfo(index,pf,0);
|
||
delete []pf;
|
||
return TRUE;
|
||
}
|
||
|
||
int CLogIO :: CreateWisCurve(Slf_CURVE* pInfo,bool bFailExist)
|
||
{
|
||
if(pInfo->RepCode==0||pInfo->CodeLen==0) {
|
||
pInfo->CodeLen=sizeof(float);
|
||
pInfo->RepCode=REPR_FLOAT;
|
||
}
|
||
cpInfo.CodeLen=pInfo->CodeLen;
|
||
cpInfo.RepCode=pInfo->RepCode;
|
||
cpInfo.MaxVal=pInfo->MaxValue;
|
||
cpInfo.MinVal=pInfo->MinValue;
|
||
memmove(cpInfo.AliasName,pInfo->AliasName,sizeof(cpInfo.AliasName));
|
||
memmove(cpInfo.Unit,pInfo->Unit,sizeof(cpInfo.Unit));
|
||
memmove(cpInfo.AliasUnit,pInfo->AliasUnit,sizeof(cpInfo.AliasUnit));
|
||
memmove(cpInfo.DimInfo[0].Name,"Depth",sizeof("Depth"));
|
||
cpInfo.DimInfo[0].RepCode=pInfo->RepCode;
|
||
cpInfo.DimInfo[0].Delta=pInfo->DepLevel;
|
||
memmove(cpInfo.DimInfo[0].AliasName,"none",sizeof(cpInfo.DimInfo[0].AliasName));
|
||
memmove(cpInfo.DimInfo[0].Unit,pInfo->DepthUnit,sizeof(cpInfo.DimInfo[0].Unit));
|
||
cpInfo.DimInfo[0].StartVal=pInfo->StartDepth;
|
||
cpInfo.NumOfDimension=1;
|
||
cpInfo.Reserved=0;
|
||
cpInfo.DimInfo[0].Reserved=0;
|
||
int ssam=((pInfo->EndDepth-pInfo->StartDepth)/cpInfo.DimInfo[0].Delta+1.5);
|
||
if(ssam<0) ssam=0;
|
||
cpInfo.DimInfo[0].Samples=ssam;
|
||
cpInfo.DimInfo[0].MaxSamples=cpInfo.DimInfo[0].Samples;
|
||
cpInfo.DimInfo[0].Size=pInfo->CodeLen;
|
||
int index=CreateChannel(CURVE_OBJECT,pInfo->Name,&cpInfo,bFailExist);
|
||
if(index>-1) {
|
||
if(!Slf_Info[index]) Slf_Info[index]=new char [sizeof(Slf_CURVE)];
|
||
memmove(Slf_Info[index],pInfo,sizeof(Slf_CURVE));
|
||
return index;
|
||
}
|
||
else return -1;
|
||
}
|
||
|
||
int CLogIO :: CreateCurve(Slf_CURVE* pInfo,bool bFailExist)
|
||
{
|
||
if(pInfo->StartDepth<-1.0e+3||pInfo->EndDepth<-1.0e+3||pInfo->DepLevel<-1.0e+3)
|
||
{
|
||
QString cs=pInfo->Name;
|
||
cs+="深度不正常,无法创建曲线!";
|
||
AfxMessageBox(cs);
|
||
return -1;
|
||
}
|
||
if(IsWis) {
|
||
return CreateWisCurve(pInfo,bFailExist);
|
||
}
|
||
return CreateSlfCurve(pInfo,bFailExist);
|
||
}
|
||
int CLogIO :: CreateSlfCurve(Slf_CURVE* pInfo,bool bFailExist)
|
||
{
|
||
//whp add
|
||
if(strlen(pInfo->AliasName)>sizeof(pInfo->AliasName))strcpy(pInfo->AliasName,pInfo->Name);
|
||
if(strlen(pInfo->Unit)>sizeof(pInfo->Unit))strcpy(pInfo->Unit,"");
|
||
if(strlen(pInfo->AliasUnit)>sizeof(pInfo->AliasUnit))strcpy(pInfo->AliasUnit,pInfo->Unit);
|
||
if(strlen(pInfo->DepthUnit)>sizeof(pInfo->DepthUnit))strcpy(pInfo->DepthUnit,"m");
|
||
if(strlen(pInfo->DepthHZUnit)>sizeof(pInfo->DepthHZUnit))strcpy(pInfo->DepthHZUnit,"米");
|
||
if(strlen(pInfo->LogCopanyName)>sizeof(pInfo->LogCopanyName))strcpy(pInfo->LogCopanyName,"");
|
||
if(strlen(pInfo->Operator)>sizeof(pInfo->Operator))strcpy(pInfo->Operator,"");
|
||
if(strlen(pInfo->DataSource)>sizeof(pInfo->DataSource))strcpy(pInfo->DataSource,"create");
|
||
if(strlen(pInfo->LoggingTeam)>sizeof(pInfo->LoggingTeam))strcpy(pInfo->LoggingTeam,"");
|
||
//
|
||
int FieldNum=2;
|
||
Slf_OBJECT_FIELD *pf=new Slf_OBJECT_FIELD[FieldNum];
|
||
memset(pf,0,sizeof(Slf_OBJECT_FIELD)*FieldNum);
|
||
strcpy(pf[0].Name,"Depth");
|
||
strcpy(pf[0].HZName,"深度");
|
||
//memmove(pf[0].HZUnit,pInfo->DepthUnit,sizeof(pf[0].Unit));
|
||
//memmove(pf[0].Unit,pInfo->DepthHZUnit,sizeof(pf[0].Unit));
|
||
if(pInfo->DepthUnit=="m"&&pInfo->DepthHZUnit!="m"&&pInfo->DepthHZUnit!="米")
|
||
{
|
||
strcpy(pInfo->DepthHZUnit,"米");
|
||
}
|
||
else if(pInfo->DepthUnit=="ft"&&pInfo->DepthHZUnit!="ft"&&pInfo->DepthHZUnit!="英尺")
|
||
{
|
||
strcpy(pInfo->DepthHZUnit,"英尺");
|
||
}
|
||
|
||
memmove(pf[0].HZUnit,pInfo->DepthHZUnit,sizeof(pf[0].HZUnit));
|
||
memmove(pf[0].Unit,pInfo->DepthUnit,sizeof(pf[0].Unit));
|
||
pf[0].DefVal=0;
|
||
pf[0].ArrayNum=1;
|
||
pf[0].CodeLength=pInfo->CodeLen;
|
||
pf[0].RepCode=pInfo->RepCode;
|
||
pf[0].Rlev=pInfo->DepLevel;
|
||
pf[0].Vmax=pInfo->EndDepth;
|
||
pf[0].Vmin=pInfo->StartDepth;
|
||
pf[0].Start=pInfo->StartDepth;
|
||
pf[0].SamplePoint=1;
|
||
pf[0].Sequence=1;
|
||
strcpy(pf[0].Reserved,"WangWei 2.0");
|
||
|
||
memmove(pf[1].Name,pInfo->Name,sizeof(pf[1].Name));
|
||
memmove(pf[1].HZName,pInfo->AliasName,sizeof(pf[1].HZName));
|
||
pf[1].DefVal=pInfo->DefVal;
|
||
memmove(pf[1].Unit,pInfo->Unit,sizeof(pf[1].Unit));
|
||
memmove(pf[1].HZUnit,pInfo->AliasUnit,sizeof(pf[1].HZUnit));
|
||
pf[1].CodeLength=pInfo->CodeLen;
|
||
pf[1].RepCode=pInfo->RepCode;
|
||
pf[1].Rlev=1;
|
||
pf[1].Vmax=pInfo->MaxValue;
|
||
pf[1].Vmin=pInfo->MinValue;
|
||
pf[1].Start=pInfo->StartDepth;
|
||
pf[1].ArrayNum=1;
|
||
pf[1].SamplePoint=1;
|
||
pf[1].Sequence=0;
|
||
strcpy(pf[1].Reserved,"WangWei 2.0");
|
||
int index=CreateSlfTable(CURVE_OBJECT,pInfo->Name,pInfo->AliasName,2,pf);
|
||
Slf_TABLE_ENTRY obj;
|
||
GetSlfObjectEntry(index,&obj);
|
||
memmove(obj.HZName,pf[1].HZName,sizeof(obj.HZName));
|
||
memmove(obj.Unit,pf[1].Unit,sizeof(obj.Unit));
|
||
memmove(obj.HZUnit,pf[1].HZUnit,sizeof(obj.HZUnit));
|
||
memmove(obj.LogCopanyName,pInfo->LogCopanyName,sizeof(obj.LogCopanyName));
|
||
memmove(obj.LoggingTeam,pInfo->LoggingTeam,sizeof(obj.LoggingTeam));
|
||
memmove(obj.DataSource,pInfo->DataSource,sizeof(obj.DataSource));
|
||
memmove(obj.Operator,pInfo->Operator,sizeof(obj.Operator));
|
||
obj.SerialID=pInfo->SerialID;
|
||
obj.LoggingDate=pInfo->LoggingDate;
|
||
obj.ChangeNum=pInfo->ChangeNum;
|
||
WriteSlfObjectEntry(index,&obj);
|
||
delete []pf;
|
||
if(index>-1) {
|
||
int rec=(pInfo->EndDepth-pInfo->StartDepth)/pInfo->DepLevel+1.5;
|
||
SetSlfTableRecordCount(index,rec);
|
||
}
|
||
return index;
|
||
}
|
||
|
||
void CLogIO :: CloseWisCurve(int index)
|
||
{
|
||
if(Slf_Info[index])delete Slf_Info[index];
|
||
Slf_Info[index]=NULL;
|
||
CloseChannel(index);
|
||
}
|
||
void CLogIO :: CloseSlfCurve(int index)
|
||
{
|
||
CloseSlfTable(index);
|
||
}
|
||
void CLogIO :: CloseCurve(int index)
|
||
{
|
||
if(IsWis) CloseWisCurve(index);
|
||
else CloseSlfCurve(index);
|
||
}
|
||
|
||
DWORD CLogIO ::ReadWisCurve(int index, float depth, DWORD count, char* buffer)
|
||
{
|
||
m_Curve=(Slf_CURVE*)Slf_Info[index];
|
||
int pos=0;
|
||
Slf_CHANNEL *m_Channel=(Slf_CHANNEL *)Slf_Info_Head[index];
|
||
float val=-9999.0;
|
||
int len=m_Channel->DimInfo[0].Size/RepSize[m_Channel->RepCode];
|
||
if(depth<m_Curve->StartDepth)
|
||
{
|
||
pos=(m_Curve->StartDepth-depth)/m_Curve->DepLevel+0.5;
|
||
if(pos>count) pos=count;
|
||
for(int i=0;i<pos;i++) {
|
||
for(int j=0;j<len;j++) {
|
||
SetData(m_Curve->RepCode,&buffer[m_Channel->DimInfo[0].Size*i+j*m_Channel->CodeLen],&val);
|
||
}
|
||
}
|
||
count-=pos;
|
||
pos*=m_Channel->DimInfo[0].Size;
|
||
depth=m_Curve->StartDepth;
|
||
}
|
||
if(count>m_Channel->DimInfo[0].Samples) {
|
||
for(int i=m_Channel->DimInfo[0].Samples;i<count;i++) {
|
||
for(int j=0;j<len;j++) {
|
||
SetData(m_Curve->RepCode,&buffer[m_Channel->DimInfo[0].Size*i+j*m_Channel->CodeLen],&val);
|
||
}
|
||
}
|
||
}
|
||
int samples=Slf_Int(depth,m_Curve->StartDepth,m_Curve->DepLevel);//((depth-m_Curve->StartDepth)/m_Curve->DepLevel+0.5);
|
||
if(samples<0) samples=0;
|
||
return ReadChannel(index,&buffer[pos],count,samples);
|
||
}
|
||
DWORD CLogIO ::ReadCurve(int index, float depth, DWORD count, void* buffer)
|
||
{
|
||
if(IsWis) {
|
||
return ReadWisCurve(index,depth,count,(char *)buffer);
|
||
}
|
||
return ReadSlfCurve(index,depth,count,(char *)buffer);
|
||
}
|
||
DWORD CLogIO ::ReadCurve(int index, float depth, DWORD count, char* buffer)
|
||
{
|
||
Slf_CURVE m_Curve;
|
||
GetCurveInfo(index,&m_Curve);
|
||
if(m_Curve.RepCode==REPR_CHAR) return ReadCurve(index, depth, count, (void *)buffer);
|
||
|
||
MyDataTypeEnum vVdl;
|
||
vVdl.vchar=new char[count*m_Curve.CodeLen];
|
||
DWORD len=ReadCurve(index, depth, count, (void *)vVdl.vchar);
|
||
for(DWORD i=0;i<count;i++)
|
||
{
|
||
switch(m_Curve.RepCode)
|
||
{
|
||
case 1:
|
||
buffer[i]=vVdl.vint[i];
|
||
break;
|
||
case 2:
|
||
buffer[i]=vVdl.vshort[i];
|
||
break;
|
||
case 3:
|
||
buffer[i]=vVdl.vlong[i];
|
||
break;
|
||
case 4:
|
||
buffer[i]=vVdl.vfloat[i];
|
||
break;
|
||
case 5:
|
||
buffer[i]=vVdl.vdouble[i];
|
||
break;
|
||
case 6:
|
||
buffer[i]=vVdl.vchar[i];
|
||
break;
|
||
case 7:
|
||
buffer[i]=vVdl.vchar[i];
|
||
break;
|
||
|
||
case 8:
|
||
buffer[i]=vVdl.vuchar[i];
|
||
break;
|
||
|
||
case 9:
|
||
buffer[i]=vVdl.vushort[i];
|
||
break;
|
||
case 10:
|
||
buffer[i]=vVdl.vuint[i];
|
||
break;
|
||
|
||
case 11:
|
||
buffer[i]=vVdl.vuint[i];
|
||
break;
|
||
}
|
||
}
|
||
delete vVdl.vchar;
|
||
return len;
|
||
}
|
||
DWORD CLogIO ::ReadSlfCurve(int index, float depth, DWORD count, char* buffer)
|
||
{
|
||
int FieldNum=GetSlfTableFieldCount(index);
|
||
int rec=GetSlfTableRecordCount(index);
|
||
int reclen=GetSlfTableRecordLength(index);
|
||
Slf_TABLE_ENTRY obj;
|
||
GetSlfObjectEntry(index,&obj);
|
||
Slf_OBJECT_FIELD *pf=new Slf_OBJECT_FIELD[FieldNum];
|
||
memset(pf,0,sizeof(Slf_OBJECT_FIELD)*FieldNum);
|
||
GetSlfTableFieldInfo(index,pf);
|
||
if(pf[0].Start>10000000) return 0;
|
||
if(pf[0].Start<=-4.3160208e+008) return 0;
|
||
if(pf[0].RepCode<0||pf[0].RepCode>REPR_ULONG)return 0;
|
||
if(pf[0].CodeLength<0)return 0;
|
||
if(pf[1].CodeLength<=0) return 0;
|
||
if(pf[1].ArrayNum<0) return 0;
|
||
if(pf[1].RepCode<0) return 0;
|
||
if(pf[1].DefVal!=-999.25&&pf[1].DefVal!=-9999||pf[1].DefVal!=-99999) pf[1].DefVal=-9999;
|
||
int pos=Slf_Int(depth,pf[0].Start,pf[0].Rlev);
|
||
if(pos<0)
|
||
{
|
||
pos=(pf[0].Start-depth)/pf[0].Rlev+0.5;
|
||
int m=pos;
|
||
if(pos>count) m=count;
|
||
char *t=new char[pf[1].CodeLength];
|
||
SetData(pf[1].RepCode,t,&pf[1].DefVal);
|
||
for(int i=0;i<m*pf[1].ArrayNum*pf[1].SamplePoint;i++) {
|
||
memmove(&buffer[i*pf[1].CodeLength],t,pf[1].CodeLength);
|
||
}
|
||
delete t;
|
||
if(count<=pos) {
|
||
return count;
|
||
}
|
||
count-=pos;
|
||
depth=pf[0].Start;//m_Curve->StartDepth;
|
||
pos*=reclen;
|
||
}
|
||
else pos=0;
|
||
if(count>rec) {
|
||
if(pf[1].CodeLength<0) {
|
||
delete []pf;
|
||
return 0;
|
||
}
|
||
char *t=new char[pf[1].CodeLength];
|
||
SetData(pf[1].RepCode,t,&pf[1].DefVal);
|
||
for(int i=rec*pf[1].ArrayNum*pf[1].SamplePoint;i<count*pf[1].ArrayNum*pf[1].SamplePoint;i++) {
|
||
memmove(&buffer[i*pf[1].CodeLength],t,pf[1].CodeLength);
|
||
}
|
||
delete t;
|
||
}
|
||
DWORD First=(DWORD)((depth-pf[0].Start)/pf[0].Rlev+0.5);
|
||
DWORD EndRec=First+count;
|
||
delete []pf;
|
||
DWORD n=ReadSlfTable(index,EndRec,&buffer[pos],First);
|
||
return n*reclen;
|
||
}
|
||
|
||
DWORD CLogIO ::ReadCurve(int index, float depth, DWORD count, short* buffer)
|
||
{
|
||
Slf_CURVE m_Curve;
|
||
GetCurveInfo(index,&m_Curve);
|
||
if(m_Curve.RepCode==REPR_SHORT) return ReadCurve(index, depth, count, (void *)buffer);
|
||
|
||
MyDataTypeEnum vVdl;
|
||
vVdl.vchar=new char[count*m_Curve.CodeLen];
|
||
DWORD len=ReadCurve(index, depth, count, (void *)vVdl.vchar);
|
||
for(DWORD i=0;i<count;i++)
|
||
{
|
||
switch(m_Curve.RepCode)
|
||
{
|
||
case 1:
|
||
buffer[i]=vVdl.vint[i];
|
||
break;
|
||
case 2:
|
||
buffer[i]=vVdl.vshort[i];
|
||
break;
|
||
case 3:
|
||
buffer[i]=vVdl.vlong[i];
|
||
break;
|
||
case 4:
|
||
buffer[i]=vVdl.vfloat[i];
|
||
break;
|
||
case 5:
|
||
buffer[i]=vVdl.vdouble[i];
|
||
break;
|
||
case 6:
|
||
buffer[i]=vVdl.vchar[i];
|
||
break;
|
||
case 7:
|
||
buffer[i]=vVdl.vchar[i];
|
||
break;
|
||
|
||
case 8:
|
||
buffer[i]=vVdl.vuchar[i];
|
||
break;
|
||
|
||
case 9:
|
||
buffer[i]=vVdl.vushort[i];
|
||
break;
|
||
case 10:
|
||
buffer[i]=vVdl.vuint[i];
|
||
break;
|
||
|
||
case 11:
|
||
buffer[i]=vVdl.vuint[i];
|
||
break;
|
||
}
|
||
}
|
||
delete vVdl.vchar;
|
||
return len;
|
||
}
|
||
DWORD CLogIO ::ReadCurve(int index, float depth, DWORD count, int* buffer)
|
||
{
|
||
Slf_CURVE m_Curve;
|
||
GetCurveInfo(index,&m_Curve);
|
||
if(m_Curve.RepCode==REPR_INT) return ReadCurve(index, depth, count, (void *)buffer);
|
||
|
||
MyDataTypeEnum vVdl;
|
||
vVdl.vchar=new char[count*m_Curve.CodeLen];
|
||
DWORD len=ReadCurve(index, depth, count, (void *)vVdl.vchar);
|
||
for(DWORD i=0;i<count;i++)
|
||
{
|
||
switch(m_Curve.RepCode)
|
||
{
|
||
case 1:
|
||
buffer[i]=vVdl.vint[i];
|
||
break;
|
||
case 2:
|
||
buffer[i]=vVdl.vshort[i];
|
||
break;
|
||
case 3:
|
||
buffer[i]=vVdl.vlong[i];
|
||
break;
|
||
case 4:
|
||
buffer[i]=vVdl.vfloat[i];
|
||
break;
|
||
case 5:
|
||
buffer[i]=vVdl.vdouble[i];
|
||
break;
|
||
case 6:
|
||
buffer[i]=vVdl.vchar[i];
|
||
break;
|
||
case 7:
|
||
buffer[i]=vVdl.vchar[i];
|
||
break;
|
||
|
||
case 8:
|
||
buffer[i]=vVdl.vuchar[i];
|
||
break;
|
||
|
||
case 9:
|
||
buffer[i]=vVdl.vushort[i];
|
||
break;
|
||
case 10:
|
||
buffer[i]=vVdl.vuint[i];
|
||
break;
|
||
|
||
case 11:
|
||
buffer[i]=vVdl.vuint[i];
|
||
break;
|
||
}
|
||
}
|
||
delete vVdl.vchar;
|
||
return len;
|
||
}
|
||
/*
|
||
DWORD CLogIO ::ReadCurve(int index, float depth, DWORD count, long* buffer)
|
||
{
|
||
Slf_CURVE m_Curve;
|
||
GetCurveInfo(index,&m_Curve);
|
||
if(m_Curve.RepCode==REPR_LONG) return ReadCurve(index, depth, count,(void *)buffer);
|
||
|
||
MyDataTypeEnum vVdl;
|
||
vVdl.vchar=new char[count*m_Curve.CodeLen];
|
||
DWORD len=ReadCurve(index, depth, count, (void *)vVdl.vchar);
|
||
for(DWORD i=0;i<count;i++)
|
||
{
|
||
switch(m_Curve.RepCode)
|
||
{
|
||
case 1:
|
||
buffer[i]=vVdl.vint[i];
|
||
break;
|
||
case 2:
|
||
buffer[i]=vVdl.vshort[i];
|
||
break;
|
||
case 3:
|
||
buffer[i]=vVdl.vlong[i];
|
||
break;
|
||
case 4:
|
||
buffer[i]=vVdl.vfloat[i];
|
||
break;
|
||
case 5:
|
||
buffer[i]=vVdl.vdouble[i];
|
||
break;
|
||
case 6:
|
||
buffer[i]=vVdl.vchar[i];
|
||
break;
|
||
case 7:
|
||
buffer[i]=vVdl.vchar[i];
|
||
break;
|
||
|
||
case 8:
|
||
buffer[i]=vVdl.vuchar[i];
|
||
break;
|
||
|
||
case 9:
|
||
buffer[i]=vVdl.vushort[i];
|
||
break;
|
||
case 10:
|
||
buffer[i]=vVdl.vuint[i];
|
||
break;
|
||
|
||
case 11:
|
||
buffer[i]=vVdl.vuint[i];
|
||
break;
|
||
}
|
||
}
|
||
delete vVdl.vchar;
|
||
return len;
|
||
}
|
||
*/
|
||
DWORD CLogIO ::ReadCurve(int index, float depth, DWORD count, unsigned char* buffer)
|
||
{
|
||
return ReadCurve(index, depth, count, (char*) buffer);
|
||
}
|
||
DWORD CLogIO ::ReadCurve(int index, float depth, DWORD count, unsigned short* buffer)
|
||
{
|
||
Slf_CURVE m_Curve;
|
||
GetCurveInfo(index,&m_Curve);
|
||
if(m_Curve.RepCode==REPR_USHORT) return ReadCurve(index, depth, count, (void *)buffer);
|
||
|
||
MyDataTypeEnum vVdl;
|
||
vVdl.vchar=new char[count*m_Curve.CodeLen];
|
||
DWORD len=ReadCurve(index, depth, count, (void *)vVdl.vchar);
|
||
for(DWORD i=0;i<count;i++)
|
||
{
|
||
switch(m_Curve.RepCode)
|
||
{
|
||
case 1:
|
||
buffer[i]=vVdl.vint[i];
|
||
break;
|
||
case 2:
|
||
buffer[i]=vVdl.vshort[i];
|
||
break;
|
||
case 3:
|
||
buffer[i]=vVdl.vlong[i];
|
||
break;
|
||
case 4:
|
||
buffer[i]=vVdl.vfloat[i];
|
||
break;
|
||
case 5:
|
||
buffer[i]=vVdl.vdouble[i];
|
||
break;
|
||
case 6:
|
||
buffer[i]=vVdl.vchar[i];
|
||
break;
|
||
case 7:
|
||
buffer[i]=vVdl.vchar[i];
|
||
break;
|
||
case 8:
|
||
buffer[i]=vVdl.vuchar[i];
|
||
break;
|
||
case 9:
|
||
buffer[i]=vVdl.vushort[i];
|
||
break;
|
||
case 10:
|
||
buffer[i]=vVdl.vuint[i];
|
||
break;
|
||
case 11:
|
||
buffer[i]=vVdl.vuint[i];
|
||
break;
|
||
}
|
||
}
|
||
delete vVdl.vchar;
|
||
return len;
|
||
}
|
||
DWORD CLogIO ::ReadCurve(int index, float depth, DWORD count, unsigned int* buffer)
|
||
{
|
||
Slf_CURVE m_Curve;
|
||
GetCurveInfo(index,&m_Curve);
|
||
if(m_Curve.RepCode==REPR_UINT) return ReadCurve(index, depth, count, (void *)buffer);
|
||
|
||
MyDataTypeEnum vVdl;
|
||
vVdl.vchar=new char[count*m_Curve.CodeLen];
|
||
DWORD len=ReadCurve(index, depth, count, (void *)vVdl.vchar);
|
||
for(DWORD i=0;i<count;i++)
|
||
{
|
||
switch(m_Curve.RepCode)
|
||
{
|
||
case 1:
|
||
buffer[i]=vVdl.vint[i];
|
||
break;
|
||
case 2:
|
||
buffer[i]=vVdl.vshort[i];
|
||
break;
|
||
case 3:
|
||
buffer[i]=vVdl.vlong[i];
|
||
break;
|
||
case 4:
|
||
buffer[i]=vVdl.vfloat[i];
|
||
break;
|
||
case 5:
|
||
buffer[i]=vVdl.vdouble[i];
|
||
break;
|
||
case 6:
|
||
buffer[i]=vVdl.vchar[i];
|
||
break;
|
||
case 7:
|
||
buffer[i]=vVdl.vchar[i];
|
||
break;
|
||
|
||
case 8:
|
||
buffer[i]=vVdl.vuchar[i];
|
||
break;
|
||
|
||
case 9:
|
||
buffer[i]=vVdl.vushort[i];
|
||
break;
|
||
case 10:
|
||
buffer[i]=vVdl.vuint[i];
|
||
break;
|
||
|
||
case 11:
|
||
buffer[i]=vVdl.vuint[i];
|
||
break;
|
||
}
|
||
}
|
||
delete vVdl.vchar;
|
||
return len;
|
||
}
|
||
/*
|
||
DWORD CLogIO ::ReadCurve(int index, float depth, DWORD count, unsigned long* buffer)
|
||
{
|
||
Slf_CURVE m_Curve;
|
||
GetCurveInfo(index,&m_Curve);
|
||
if(m_Curve.RepCode==REPR_ULONG) return ReadCurve(index, depth, count, (void *)buffer);
|
||
|
||
MyDataTypeEnum vVdl;
|
||
vVdl.vchar=new char[count*m_Curve.CodeLen];
|
||
DWORD len=ReadCurve(index, depth, count, (void *)vVdl.vchar);
|
||
for(DWORD i=0;i<count;i++)
|
||
{
|
||
switch(m_Curve.RepCode)
|
||
{
|
||
case 1:
|
||
buffer[i]=vVdl.vint[i];
|
||
break;
|
||
case 2:
|
||
buffer[i]=vVdl.vshort[i];
|
||
break;
|
||
case 3:
|
||
buffer[i]=vVdl.vlong[i];
|
||
break;
|
||
case 4:
|
||
buffer[i]=vVdl.vfloat[i];
|
||
break;
|
||
case 5:
|
||
buffer[i]=vVdl.vdouble[i];
|
||
break;
|
||
case 6:
|
||
buffer[i]=vVdl.vchar[i];
|
||
break;
|
||
case 7:
|
||
buffer[i]=vVdl.vchar[i];
|
||
break;
|
||
|
||
case 8:
|
||
buffer[i]=vVdl.vuchar[i];
|
||
break;
|
||
|
||
case 9:
|
||
buffer[i]=vVdl.vushort[i];
|
||
break;
|
||
case 10:
|
||
buffer[i]=vVdl.vuint[i];
|
||
break;
|
||
|
||
case 11:
|
||
buffer[i]=vVdl.vuint[i];
|
||
break;
|
||
}
|
||
}
|
||
delete vVdl.vchar;
|
||
return len;
|
||
}
|
||
*/
|
||
DWORD CLogIO ::ReadCurve(int index, float depth, DWORD count, float* buffer)
|
||
{
|
||
Slf_CURVE m_Curve;
|
||
GetCurveInfo(index,&m_Curve);
|
||
if(m_Curve.RepCode==REPR_FLOAT) return ReadCurve(index, depth, count, (void *)buffer);
|
||
|
||
MyDataTypeEnum vVdl;
|
||
vVdl.vchar=new char[count*m_Curve.CodeLen];
|
||
DWORD len=ReadCurve(index, depth, count, (void *)vVdl.vchar);
|
||
for(DWORD i=0;i<count;i++)
|
||
{
|
||
switch(m_Curve.RepCode)
|
||
{
|
||
case 1:
|
||
buffer[i]=vVdl.vint[i];
|
||
break;
|
||
case 2:
|
||
buffer[i]=vVdl.vshort[i];
|
||
break;
|
||
case 3:
|
||
buffer[i]=vVdl.vlong[i];
|
||
break;
|
||
case 4:
|
||
buffer[i]=vVdl.vfloat[i];
|
||
break;
|
||
case 5:
|
||
buffer[i]=vVdl.vdouble[i];
|
||
break;
|
||
case 6:
|
||
buffer[i]=vVdl.vchar[i];
|
||
break;
|
||
case 7:
|
||
buffer[i]=vVdl.vchar[i];
|
||
break;
|
||
|
||
case 8:
|
||
buffer[i]=vVdl.vuchar[i];
|
||
break;
|
||
|
||
case 9:
|
||
buffer[i]=vVdl.vushort[i];
|
||
break;
|
||
case 10:
|
||
buffer[i]=vVdl.vuint[i];
|
||
break;
|
||
|
||
case 11:
|
||
buffer[i]=vVdl.vuint[i];
|
||
break;
|
||
}
|
||
}
|
||
delete vVdl.vchar;
|
||
return len;
|
||
}
|
||
DWORD CLogIO ::ReadCurve(int index, float depth, DWORD count, double* buffer)
|
||
{
|
||
Slf_CURVE m_Curve;
|
||
GetCurveInfo(index,&m_Curve);
|
||
if(m_Curve.RepCode==REPR_DOUBLE) return ReadCurve(index, depth, count, (void *)buffer);
|
||
|
||
MyDataTypeEnum vVdl;
|
||
vVdl.vchar=new char[(count+1)*m_Curve.CodeLen];
|
||
DWORD len=ReadCurve(index, depth, count, (void *)vVdl.vchar);
|
||
for(DWORD i=0;i<count;i++)
|
||
{
|
||
switch(m_Curve.RepCode)
|
||
{
|
||
case 1:
|
||
buffer[i]=vVdl.vint[i];
|
||
break;
|
||
case 2:
|
||
buffer[i]=vVdl.vshort[i];
|
||
break;
|
||
case 3:
|
||
buffer[i]=vVdl.vlong[i];
|
||
break;
|
||
case 4:
|
||
buffer[i]=vVdl.vfloat[i];
|
||
break;
|
||
case 5:
|
||
buffer[i]=vVdl.vdouble[i];
|
||
break;
|
||
case 6:
|
||
buffer[i]=vVdl.vchar[i];
|
||
break;
|
||
case 7:
|
||
buffer[i]=vVdl.vchar[i];
|
||
break;
|
||
|
||
case 8:
|
||
buffer[i]=vVdl.vuchar[i];
|
||
break;
|
||
|
||
case 9:
|
||
buffer[i]=vVdl.vushort[i];
|
||
break;
|
||
case 10:
|
||
buffer[i]=vVdl.vuint[i];
|
||
break;
|
||
|
||
case 11:
|
||
buffer[i]=vVdl.vuint[i];
|
||
break;
|
||
}
|
||
}
|
||
delete vVdl.vchar;
|
||
return len;
|
||
}
|
||
DWORD CLogIO ::WriteWisCurve(int index, float depth, DWORD count, char* buffer)
|
||
{
|
||
Slf_CHANNEL *m_Channel=(Slf_CHANNEL *)Slf_Info_Head[index];
|
||
m_Curve=(Slf_CURVE*)Slf_Info[index];
|
||
if(depth<m_Curve->StartDepth) {
|
||
float move=m_Curve->StartDepth-depth;
|
||
WisExpandDepth(index,m_Curve->EndDepth,m_Curve->EndDepth+move);
|
||
WisMoveDepth(index,m_Curve->StartDepth,m_Curve->EndDepth,move);
|
||
m_Curve->StartDepth-=move;
|
||
m_Channel->DimInfo[0].StartVal=m_Curve->StartDepth;
|
||
depth=m_Curve->StartDepth;
|
||
}
|
||
int samples=((depth-m_Curve->StartDepth)/m_Curve->DepLevel+0.5);
|
||
if(samples<0) samples=0;
|
||
float yy;
|
||
DWORD POS=0;
|
||
for(DWORD i=0;i<count;i++) {
|
||
GetData(m_Channel->RepCode,&buffer[POS],&yy);
|
||
if(m_Channel->MaxVal<yy) m_Channel->MaxVal=yy;
|
||
if(m_Channel->MinVal>yy) m_Channel->MinVal=yy;
|
||
POS+=m_Channel->CodeLen;
|
||
}
|
||
WriteChannelInfo(index);
|
||
return WriteChannel(index,buffer,count,samples);
|
||
}
|
||
|
||
DWORD CLogIO ::WriteCurve(int index, float depth, DWORD count, char* buffer)
|
||
{
|
||
Slf_CURVE m_Curve;
|
||
GetCurveInfo(index,&m_Curve);
|
||
if(m_Curve.RepCode==REPR_CHAR) return WriteCurve(index, depth, count, (void *)buffer);
|
||
|
||
MyDataTypeEnum vVdl;
|
||
vVdl.vchar=new char[count*m_Curve.CodeLen];
|
||
WriteBuf((char *)buffer,REPR_CHAR,sizeof(short),vVdl,m_Curve.RepCode,count,1);
|
||
DWORD len=WriteCurve(index, depth, count, (void *)vVdl.vchar);
|
||
delete vVdl.vchar;
|
||
return len;
|
||
}
|
||
|
||
DWORD CLogIO ::WriteCurve(int index, float depth, DWORD count, void* buffer)
|
||
{
|
||
if(IsWis) {
|
||
return WriteWisCurve(index,depth,count,(char *)buffer);
|
||
}
|
||
return WriteSlfCurve(index,depth,count,(char *)buffer);
|
||
}
|
||
|
||
DWORD CLogIO ::WriteSlfCurve(int index, float depth, DWORD count, char* buffer)
|
||
{
|
||
int FieldNum=GetSlfTableFieldCount(index);
|
||
Slf_OBJECT_FIELD *pf=new Slf_OBJECT_FIELD[FieldNum];
|
||
memset(pf,0,sizeof(Slf_OBJECT_FIELD)*FieldNum);
|
||
GetSlfTableFieldInfo(index,pf);
|
||
int First=Slf_Int(depth,pf[0].Start,pf[0].Rlev);
|
||
int EndRec=First+count;
|
||
delete []pf;
|
||
return WriteSlfTable(index,EndRec,buffer,First);
|
||
}
|
||
|
||
DWORD CLogIO ::WriteCurve(int index, float depth, DWORD count, short* buffer)
|
||
{
|
||
Slf_CURVE m_Curve;
|
||
GetCurveInfo(index,&m_Curve);
|
||
if(m_Curve.RepCode==REPR_SHORT) return WriteCurve(index, depth, count, (void *)buffer);
|
||
|
||
MyDataTypeEnum vVdl;
|
||
vVdl.vchar=new char[count*m_Curve.CodeLen];
|
||
WriteBuf((char *)buffer,REPR_SHORT,sizeof(short),vVdl,m_Curve.RepCode,count,1);
|
||
DWORD len=WriteCurve(index, depth, count, (void *)vVdl.vchar);
|
||
delete vVdl.vchar;
|
||
return len;
|
||
}
|
||
DWORD CLogIO ::WriteCurve(int index, float depth, DWORD count, int* buffer)
|
||
{
|
||
Slf_CURVE m_Curve;
|
||
GetCurveInfo(index,&m_Curve);
|
||
if(m_Curve.RepCode==REPR_INT) return WriteCurve(index, depth, count, (void *)buffer);
|
||
|
||
MyDataTypeEnum vVdl;
|
||
vVdl.vchar=new char[count*m_Curve.CodeLen];
|
||
WriteBuf((char *)buffer,REPR_INT,sizeof(int),vVdl,m_Curve.RepCode,count,1);
|
||
DWORD len=WriteCurve(index, depth, count, (void *)vVdl.vchar);
|
||
delete vVdl.vchar;
|
||
return len;
|
||
}
|
||
/*
|
||
DWORD CLogIO ::WriteCurve(int index, float depth, DWORD count, long* buffer)
|
||
{
|
||
Slf_CURVE m_Curve;
|
||
GetCurveInfo(index,&m_Curve);
|
||
if(m_Curve.RepCode==REPR_LONG) return WriteCurve(index, depth, count, (void *)buffer);
|
||
|
||
MyDataTypeEnum vVdl;
|
||
vVdl.vchar=new char[count*m_Curve.CodeLen];
|
||
WriteBuf((char *)buffer,REPR_LONG,sizeof(long),vVdl,m_Curve.RepCode,count,1);
|
||
DWORD len=WriteCurve(index, depth, count, (void *)vVdl.vchar);
|
||
delete vVdl.vchar;
|
||
return len;
|
||
}*/
|
||
DWORD CLogIO ::WriteCurve(int index, float depth, DWORD count, unsigned char* buffer)
|
||
{
|
||
return WriteCurve(index, depth, count, (char*) buffer);
|
||
}
|
||
DWORD CLogIO ::WriteCurve(int index, float depth, DWORD count, unsigned short* buffer)
|
||
{
|
||
Slf_CURVE m_Curve;
|
||
GetCurveInfo(index,&m_Curve);
|
||
if(m_Curve.RepCode==REPR_SHORT) return WriteCurve(index, depth, count, (void *)buffer);
|
||
|
||
MyDataTypeEnum vVdl;
|
||
vVdl.vchar=new char[count*m_Curve.CodeLen];
|
||
WriteBuf((char *)buffer,REPR_USHORT,sizeof(short),vVdl,m_Curve.RepCode,count,1);
|
||
DWORD len=WriteCurve(index, depth, count, (void *)vVdl.vchar);
|
||
delete vVdl.vchar;
|
||
return len;
|
||
}
|
||
DWORD CLogIO ::WriteCurve(int index, float depth, DWORD count, unsigned int* buffer)
|
||
{
|
||
Slf_CURVE m_Curve;
|
||
GetCurveInfo(index,&m_Curve);
|
||
if(m_Curve.RepCode==REPR_UINT) return WriteCurve(index, depth, count, (void *)buffer);
|
||
|
||
MyDataTypeEnum vVdl;
|
||
vVdl.vchar=new char[count*m_Curve.CodeLen];
|
||
WriteBuf((char *)buffer,REPR_UINT,sizeof(int),vVdl,m_Curve.RepCode,count,1);
|
||
DWORD len=WriteCurve(index, depth, count, (void *)vVdl.vchar);
|
||
delete vVdl.vchar;
|
||
return len;
|
||
}
|
||
/*
|
||
DWORD CLogIO ::WriteCurve(int index, float depth, DWORD count, unsigned long* buffer)
|
||
{
|
||
Slf_CURVE m_Curve;
|
||
GetCurveInfo(index,&m_Curve);
|
||
if(m_Curve.RepCode==REPR_ULONG) return WriteCurve(index, depth, count, (void *)buffer);
|
||
|
||
MyDataTypeEnum vVdl;
|
||
vVdl.vchar=new char[count*m_Curve.CodeLen];
|
||
WriteBuf((char *)buffer,REPR_ULONG,sizeof(long),vVdl,m_Curve.RepCode,count,1);
|
||
DWORD len=WriteCurve(index, depth, count, (void *)vVdl.vchar);
|
||
delete vVdl.vchar;
|
||
return len;
|
||
}*/
|
||
DWORD CLogIO ::WriteCurve(int index, float depth, DWORD count, float* buffer)
|
||
{
|
||
Slf_CURVE m_Curve;
|
||
GetCurveInfo(index,&m_Curve);
|
||
if(m_Curve.RepCode==REPR_FLOAT) return WriteCurve(index, depth, count, (void *)buffer);
|
||
|
||
MyDataTypeEnum vVdl;
|
||
vVdl.vchar=new char[count*m_Curve.CodeLen];
|
||
WriteBuf((char *)buffer,REPR_FLOAT,sizeof(float),vVdl,m_Curve.RepCode,count,1);
|
||
DWORD len=WriteCurve(index, depth, count, (void *)vVdl.vchar);
|
||
delete vVdl.vchar;
|
||
return len;
|
||
}
|
||
DWORD CLogIO ::WriteCurve(int index, float depth, DWORD count, double* buffer)
|
||
{
|
||
Slf_CURVE m_Curve;
|
||
GetCurveInfo(index,&m_Curve);
|
||
if(m_Curve.RepCode==REPR_DOUBLE) return WriteCurve(index, depth, count, (void *)buffer);
|
||
|
||
MyDataTypeEnum vVdl;
|
||
vVdl.vchar=new char[count*m_Curve.CodeLen];
|
||
WriteBuf((char *)buffer,REPR_DOUBLE,sizeof(double),vVdl,m_Curve.RepCode,count,1);
|
||
DWORD len=WriteCurve(index, depth, count, (void *)vVdl.vchar);
|
||
delete vVdl.vchar;
|
||
return len;
|
||
}
|
||
//whp add 不关心曲线的数据类型,将数据读到浮点缓冲区或将浮点缓冲区中的数据写入曲线
|
||
DWORD CLogIO ::ReadCurveToFloatBuf(int index, float depth, DWORD count, float* buffer)
|
||
{
|
||
Slf_CURVE m_Curve;
|
||
GetCurveInfo(index,&m_Curve);
|
||
MyDataTypeEnum vVdl;
|
||
vVdl.vchar=new char[(count+1)*m_Curve.CodeLen];
|
||
DWORD len=ReadCurve(index, depth, count, (void *)vVdl.vchar);
|
||
if(m_Curve.RepCode==4)memmove(buffer,vVdl.vfloat,count*sizeof(float));
|
||
else
|
||
{
|
||
for(DWORD i=0;i<count;i++)
|
||
{
|
||
switch(m_Curve.RepCode)
|
||
{
|
||
case 1:
|
||
buffer[i]=vVdl.vint[i];
|
||
break;
|
||
case 2:
|
||
buffer[i]=vVdl.vshort[i];
|
||
break;
|
||
case 3:
|
||
buffer[i]=vVdl.vlong[i];
|
||
break;
|
||
/*case 4:
|
||
buffer[i]=vVdl.vfloat[i];
|
||
break;*/
|
||
case 5:
|
||
buffer[i]=vVdl.vdouble[i];
|
||
break;
|
||
case 6:
|
||
buffer[i]=vVdl.vchar[i];
|
||
break;
|
||
|
||
case 7:
|
||
buffer[i]=vVdl.vchar[i];
|
||
break;
|
||
|
||
case 8:
|
||
buffer[i]=vVdl.vuchar[i];
|
||
break;
|
||
|
||
case 9:
|
||
buffer[i]=vVdl.vushort[i];
|
||
break;
|
||
|
||
case 10:
|
||
buffer[i]=vVdl.vuint[i];
|
||
break;
|
||
|
||
case 11:
|
||
buffer[i]=vVdl.vuint[i];
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
delete vVdl.vchar;
|
||
return len;
|
||
}
|
||
DWORD CLogIO ::WriteCurveFromFloatBuf(int index, float depth, DWORD count, float* buffer)
|
||
{
|
||
Slf_CURVE m_Curve;
|
||
GetCurveInfo(index,&m_Curve);
|
||
MyDataTypeEnum vVdl;
|
||
vVdl.vchar=new char[count*m_Curve.CodeLen];
|
||
WriteBuf((char *)buffer,REPR_FLOAT,sizeof(float),vVdl,m_Curve.RepCode,count,1);
|
||
DWORD len=WriteCurve(index, depth, count, (void *)vVdl.vchar);
|
||
delete vVdl.vchar;
|
||
return len;
|
||
}
|
||
//add end
|
||
int CLogIO ::OpenWave(const char* name)
|
||
{
|
||
if(IsWis) {
|
||
return OpenWisWave(name);
|
||
}
|
||
return OpenSlfWave(name);
|
||
}
|
||
int CLogIO ::OpenWisWave(const char* name)
|
||
{
|
||
int index= OpenChannel(name,WAVE_OBJECT);
|
||
if(index>-1)
|
||
{
|
||
if(!Slf_Info[index]) Slf_Info[index]=new char [sizeof(Slf_WAVE)];
|
||
m_Wave=(Slf_WAVE*)Slf_Info[index];
|
||
GetWaveInfo(index,m_Wave);
|
||
return index;
|
||
}
|
||
else return -1;
|
||
}
|
||
int CLogIO ::OpenSlfWave(const char* name)
|
||
{
|
||
int index=FindSlfObjectName((char *)name,WAVE_OBJECT);
|
||
if(index<0)return -1;
|
||
return OpenSlfTable(name,WAVE_OBJECT);
|
||
}
|
||
int CLogIO ::OpenWave(Slf_WAVE* pInfo)
|
||
{
|
||
int index=OpenWave(pInfo->Name);
|
||
if(index>-1)
|
||
{
|
||
Slf_WAVE info;
|
||
GetWaveInfo(index,&info);
|
||
if(IsWis)
|
||
{
|
||
if(info.CodeLen!=pInfo->CodeLen||info.RepCode!=pInfo->RepCode||info.TimeSamples!=pInfo->TimeSamples)
|
||
{
|
||
char newname[200];
|
||
strcpy(newname,pInfo->Name);
|
||
strcat(newname,".bak");
|
||
char sss[200];
|
||
sprintf(sss,"The wave is renamed:%s",newname);
|
||
AfxMessageBox(sss);
|
||
RenameObject(pInfo->Name,newname);
|
||
index=-1;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
//if(info.CodeLen!=pInfo->CodeLen||info.RepCode!=pInfo->RepCode||info.DefVal!=pInfo->DefVal||info.TimeSamples!=pInfo->TimeSamples)
|
||
if(info.CodeLen!=pInfo->CodeLen||info.RepCode!=pInfo->RepCode||info.TimeSamples!=pInfo->TimeSamples)
|
||
{
|
||
char newname[200];
|
||
strcpy(newname,pInfo->Name);
|
||
strcat(newname,".bak");
|
||
// CString s1;
|
||
//s1.Format("info.CodeLen=%d,pInfo->CodeLen=%d\r\ninfo.RepCode=%d,pInfo->RepCode=%d\r\ninfo.TimeSamples=%d,pInfo->TimeSamples=%d",
|
||
// info.CodeLen,pInfo->CodeLen,info.RepCode,pInfo->RepCode,info.TimeSamples,pInfo->TimeSamples);
|
||
char buf[500];
|
||
sprintf(buf,"info.CodeLen=%d,pInfo->CodeLen=%d\r\ninfo.RepCode=%d,pInfo->RepCode=%d\r\ninfo.TimeSamples=%d,pInfo->TimeSamples=%d",
|
||
info.CodeLen,
|
||
pInfo->CodeLen,
|
||
info.RepCode,
|
||
pInfo->RepCode,
|
||
info.TimeSamples,
|
||
pInfo->TimeSamples);
|
||
//s1.Format("info.CodeLen=%d,pCurve->CodeLen=%d\r\ninfo.RepCode=%d,pCurve->RepCode=%d\r\n",
|
||
// info.CodeLen,pCurve->CodeLen,info.RepCode,pCurve->RepCode);
|
||
QString s1(buf);
|
||
char sss[500];
|
||
sprintf(sss,"The wave is renname as:%s\r\n",newname);
|
||
AfxMessageBox(sss+s1);
|
||
RenameObject(pInfo->Name,newname);
|
||
index=-1;
|
||
}
|
||
}
|
||
}
|
||
if(index<0) {
|
||
if(IsWis) return CreateWisWave(pInfo);
|
||
else return CreateSlfWave(pInfo);
|
||
}
|
||
return index;
|
||
}
|
||
int CLogIO ::CreateWave(Slf_WAVE* pInfo,bool bFailExist)
|
||
{
|
||
if(IsWis) return CreateWisWave(pInfo,bFailExist);
|
||
return CreateSlfWave(pInfo,bFailExist);
|
||
}
|
||
int CLogIO ::CreateSlfWave(Slf_WAVE* pInfo,bool bFailExist)
|
||
{
|
||
//whp add
|
||
if(pInfo->ArrayNum<1)pInfo->ArrayNum=1;
|
||
if(pInfo->ArrayNum>10000)pInfo->ArrayNum=1;
|
||
//if(pInfo->ArrayNum>10000)pInfo->ArrayNum=1;语句是为了防止pInfo->ArrayNum变量没有初始化的情况
|
||
//当变量没有初始化时,在debug版本中,往往是一个负无穷大值;而在release版本中,经常是一个正的无穷大值,但有时也会是一个看起来很正常的值(如4)
|
||
//所以建议在调用CreateSlfWave函数时,要给pInfo->ArrayNum赋初值
|
||
//pInfo->ArrayNum>10000,认为正常情况下,不会有大于10000维的阵列数据,如果真的有,这个限制就会得出错误的结果
|
||
if(strlen(pInfo->AliasName)>sizeof(pInfo->AliasName))strcpy(pInfo->AliasName,pInfo->Name);
|
||
if(strlen(pInfo->Unit)>sizeof(pInfo->Unit))strcpy(pInfo->Unit,"");
|
||
if(strlen(pInfo->AliasUnit)>sizeof(pInfo->AliasUnit))strcpy(pInfo->AliasUnit,pInfo->Unit);
|
||
if(strlen(pInfo->DepthUnit)>sizeof(pInfo->DepthUnit))strcpy(pInfo->DepthUnit,"m");
|
||
if(strlen(pInfo->DepthHZUnit)>sizeof(pInfo->DepthHZUnit))strcpy(pInfo->DepthHZUnit,"米");
|
||
if(strlen(pInfo->LogCopanyName)>sizeof(pInfo->LogCopanyName))strcpy(pInfo->LogCopanyName,"");
|
||
if(strlen(pInfo->Operator)>sizeof(pInfo->Operator))strcpy(pInfo->Operator,"");
|
||
if(strlen(pInfo->DataSource)>sizeof(pInfo->DataSource))strcpy(pInfo->DataSource,"create");
|
||
if(strlen(pInfo->LoggingTeam)>sizeof(pInfo->LoggingTeam))strcpy(pInfo->LoggingTeam,"");
|
||
if(strlen(pInfo->TimeName)>sizeof(pInfo->TimeName)||pInfo->TimeName==NULL)strcpy(pInfo->TimeName,"TIME");
|
||
if(strlen(pInfo->TimeHZName)>sizeof(pInfo->TimeHZName)||pInfo->TimeHZName==NULL)strcpy(pInfo->TimeHZName,"时间");
|
||
if(strlen(pInfo->TimeUnit)>sizeof(pInfo->TimeUnit)||pInfo->TimeUnit==NULL)strcpy(pInfo->TimeUnit,"us");
|
||
if(strlen(pInfo->TimeHZUnit)>sizeof(pInfo->TimeHZUnit)||pInfo->TimeHZUnit==NULL)strcpy(pInfo->TimeHZUnit,pInfo->TimeUnit);
|
||
//
|
||
int FieldNum=3;
|
||
Slf_OBJECT_FIELD *pf=new Slf_OBJECT_FIELD[FieldNum];
|
||
memset(pf,0,sizeof(Slf_OBJECT_FIELD)*FieldNum);
|
||
strcpy(pf[0].Name,"Depth");
|
||
strcpy(pf[0].HZName,"深度");
|
||
if(pInfo->DepthUnit=="m"&&pInfo->DepthHZUnit!="m"&&pInfo->DepthHZUnit!="米")
|
||
{
|
||
strcpy(pInfo->DepthHZUnit,"米");
|
||
}
|
||
else if(pInfo->DepthUnit=="ft"&&pInfo->DepthHZUnit!="ft"&&pInfo->DepthHZUnit!="英尺")
|
||
{
|
||
strcpy(pInfo->DepthHZUnit,"英尺");
|
||
}
|
||
memmove(pf[0].HZUnit,pInfo->DepthHZUnit,sizeof(pf[0].HZUnit));
|
||
memmove(pf[0].Unit,pInfo->DepthUnit,sizeof(pf[0].Unit));
|
||
pf[0].DefVal=0;
|
||
pf[0].ArrayNum=1;
|
||
pf[0].CodeLength=pInfo->CodeLen;
|
||
pf[0].RepCode=pInfo->RepCode;
|
||
pf[0].Rlev=pInfo->DepLevel;
|
||
pf[0].Vmax=pInfo->EndDepth;
|
||
pf[0].Vmin=pInfo->StartDepth;
|
||
pf[0].Start=pInfo->StartDepth;
|
||
pf[0].SamplePoint=1;
|
||
pf[0].Sequence=1;
|
||
strcpy(pf[0].Reserved,"WangWei 2.0");
|
||
strcpy(pf[1].Name,pInfo->Name);
|
||
strcpy(pf[1].HZName,pInfo->AliasName);
|
||
pf[1].DefVal=pInfo->DefVal;
|
||
memmove(pf[1].Unit,pInfo->Unit,sizeof(pf[1].Unit));
|
||
memmove(pf[1].HZUnit,pInfo->AliasUnit,sizeof(pf[1].HZUnit));
|
||
pf[1].CodeLength=pInfo->CodeLen;
|
||
pf[1].RepCode=pInfo->RepCode;
|
||
pf[1].Rlev=1;
|
||
pf[1].Vmax=pInfo->MaxValue;
|
||
pf[1].Vmin=pInfo->MinValue;
|
||
pf[1].Start=pInfo->StartDepth;
|
||
pf[1].ArrayNum=pInfo->ArrayNum;
|
||
pf[1].SamplePoint=pInfo->TimeSamples/pInfo->ArrayNum;
|
||
pf[1].Sequence=0;
|
||
strcpy(pf[1].Reserved,"WangWei 2.0");
|
||
memmove(pf[2].Name,pInfo->TimeName,sizeof(pf[2].Name));
|
||
memmove(pf[2].HZName,pInfo->TimeHZName,sizeof(pf[2].HZName));
|
||
//strcpy(pf[2].Name,"TIME");
|
||
//strcpy(pf[2].HZName,"时间");
|
||
pf[2].DefVal=-9999.0;
|
||
memmove(pf[2].Unit,pInfo->TimeUnit,sizeof(pf[2].Unit));
|
||
memmove(pf[2].HZUnit,pInfo->TimeHZUnit,sizeof(pf[2].HZUnit));
|
||
pf[2].CodeLength=pInfo->CodeLen;
|
||
pf[2].RepCode=pInfo->RepCode;
|
||
pf[2].Rlev=pInfo->TimeLevel;
|
||
pf[2].Vmax=-1024;
|
||
pf[2].Vmin=1024;
|
||
pf[2].Start=pInfo->StartTime;
|
||
pf[2].ArrayNum=pInfo->ArrayNum;
|
||
pf[2].SamplePoint=pInfo->TimeSamples/pInfo->ArrayNum;
|
||
pf[2].Sequence=1;
|
||
strcpy(pf[2].Reserved,"WangWei 2.0");
|
||
int index=CreateSlfTable(WAVE_OBJECT,pInfo->Name,pInfo->AliasName,3,pf);
|
||
Slf_TABLE_ENTRY obj;
|
||
GetSlfObjectEntry(index,&obj);
|
||
memmove(obj.HZName,pf[1].HZName,sizeof(obj.HZName));
|
||
memmove(obj.Unit,pf[1].Unit,sizeof(obj.Unit));
|
||
memmove(obj.HZUnit,pf[1].HZUnit,sizeof(obj.HZUnit));
|
||
memmove(obj.LogCopanyName,pInfo->LogCopanyName,sizeof(obj.LogCopanyName));
|
||
memmove(obj.LoggingTeam,pInfo->LoggingTeam,sizeof(obj.LoggingTeam));
|
||
memmove(obj.DataSource,pInfo->DataSource,sizeof(obj.DataSource));
|
||
memmove(obj.Operator,pInfo->Operator,sizeof(obj.Operator));
|
||
obj.SerialID=pInfo->SerialID;
|
||
obj.LoggingDate=pInfo->LoggingDate;
|
||
obj.ChangeNum=pInfo->ChangeNum;
|
||
WriteSlfObjectEntry(index,&obj);
|
||
delete []pf;
|
||
if(index>-1)
|
||
{
|
||
int recnum=(pInfo->EndDepth-pInfo->StartDepth)/pInfo->DepLevel+1.5;
|
||
SetSlfTableRecordCount(index,recnum);
|
||
}
|
||
return index;
|
||
}
|
||
int CLogIO ::CreateWisWave(Slf_WAVE* pInfo,bool bFailExist)
|
||
{
|
||
memmove(cpInfo.AliasName,pInfo->AliasName,sizeof(cpInfo.AliasName));
|
||
memmove(cpInfo.Unit,pInfo->Unit,sizeof(cpInfo.Unit));
|
||
memmove(cpInfo.AliasUnit,pInfo->AliasUnit,sizeof(cpInfo.AliasUnit));
|
||
|
||
cpInfo.RepCode=pInfo->RepCode;
|
||
cpInfo.CodeLen=pInfo->CodeLen;
|
||
cpInfo.MaxVal =pInfo->MaxValue;
|
||
cpInfo.MinVal =pInfo->MinValue;
|
||
cpInfo.NumOfDimension=2;
|
||
|
||
memmove(cpInfo.DimInfo[0].Name,"Depth",sizeof(cpInfo.DimInfo[0].Name));
|
||
memmove(cpInfo.DimInfo[0].Unit,pInfo->DepthUnit,sizeof(cpInfo.DimInfo[0].Unit));
|
||
memmove(cpInfo.DimInfo[0].AliasName,"none",strlen("none"));
|
||
|
||
cpInfo.DimInfo[0].StartVal=pInfo->StartDepth;
|
||
cpInfo.DimInfo[0].Delta =pInfo->DepLevel;
|
||
int ssam=(pInfo->EndDepth-pInfo->StartDepth)/cpInfo.DimInfo[0].Delta+1.5;
|
||
if(ssam<0)ssam=0;
|
||
cpInfo.DimInfo[0].Samples =ssam;
|
||
cpInfo.DimInfo[0].MaxSamples=ssam;
|
||
cpInfo.DimInfo[0].RepCode =4;
|
||
cpInfo.DimInfo[0].Size =pInfo->CodeLen*pInfo->TimeSamples;
|
||
|
||
memmove(cpInfo.DimInfo[1].Name,"Time",strlen("Time"));
|
||
memmove(cpInfo.DimInfo[1].AliasName,cpInfo.DimInfo[1].Name,sizeof(cpInfo.DimInfo[1].Name));
|
||
memmove(cpInfo.DimInfo[1].Unit,pInfo->TimeUnit,sizeof(pInfo->TimeUnit));
|
||
|
||
cpInfo.DimInfo[1].RepCode =pInfo->RepCode;
|
||
cpInfo.DimInfo[1].Delta =pInfo->TimeLevel;
|
||
cpInfo.DimInfo[1].StartVal=pInfo->StartTime;
|
||
cpInfo.DimInfo[1].Samples =pInfo->TimeSamples;
|
||
cpInfo.DimInfo[1].MaxSamples=pInfo->TimeSamples;
|
||
cpInfo.DimInfo[1].Size=1;
|
||
cpInfo.DimInfo[1].RepCode=pInfo->RepCode;
|
||
|
||
int index=CreateChannel(WAVE_OBJECT,pInfo->Name,&cpInfo,bFailExist);
|
||
if(index>-1) {
|
||
if(!Slf_Info[index]) Slf_Info[index]=new char [sizeof(Slf_WAVE)];
|
||
memmove(Slf_Info[index],pInfo,sizeof(Slf_WAVE));
|
||
return index;
|
||
}
|
||
else return -1;
|
||
}
|
||
void CLogIO ::CloseWave(int index)
|
||
{
|
||
CloseChannel(index);
|
||
}
|
||
bool CLogIO ::GetWaveInfo(int index,Slf_WAVE* pInfo)
|
||
{
|
||
if(IsWis) {
|
||
return GetWisWaveInfo(index,pInfo);
|
||
}
|
||
return GetSlfWaveInfo(index,pInfo);
|
||
}
|
||
bool CLogIO ::GetSlfWaveInfo(int index,Slf_WAVE* pInfo)
|
||
{
|
||
if(index<0) return 0;
|
||
int FieldNum=GetSlfTableFieldCount(index);
|
||
int rec=GetSlfTableRecordCount(index);
|
||
Slf_TABLE_ENTRY obj;
|
||
GetSlfObjectEntry(index,&obj);
|
||
Slf_OBJECT_FIELD *pf=new Slf_OBJECT_FIELD[FieldNum];
|
||
memset(pf,0,sizeof(Slf_OBJECT_FIELD)*FieldNum);
|
||
GetSlfTableFieldInfo(index,pf);
|
||
|
||
memmove(pInfo->AliasName,obj.HZName,sizeof(pInfo->AliasName));
|
||
memmove(pInfo->Name,obj.Name,sizeof(pInfo->Name));
|
||
memmove(pInfo->Unit,pf[1].Unit,sizeof(pInfo->Unit));
|
||
memmove(pInfo->AliasUnit,pf[1].HZUnit,sizeof(pInfo->AliasUnit));
|
||
memmove(pInfo->DepthUnit,pf[0].Unit,sizeof(pInfo->DepthUnit));
|
||
memmove(pInfo->DepthHZUnit,pf[0].HZUnit,sizeof(pInfo->DepthHZUnit));
|
||
|
||
memmove(pInfo->LogCopanyName,obj.LogCopanyName,sizeof(pInfo->LogCopanyName));
|
||
memmove(pInfo->LoggingTeam,obj.LoggingTeam,sizeof(pInfo->LoggingTeam));
|
||
memmove(pInfo->DataSource,obj.DataSource,sizeof(pInfo->DataSource));
|
||
memmove(pInfo->Operator,obj.Operator,sizeof(pInfo->Operator));
|
||
pInfo->SerialID=obj.SerialID;
|
||
pInfo->LoggingDate=obj.LoggingDate;
|
||
pInfo->ChangeNum=obj.ChangeNum;
|
||
|
||
pInfo->CodeLen=pf[1].CodeLength;
|
||
pInfo->RepCode=pf[1].RepCode;
|
||
if(pInfo->RepCode>=sizeof(RepSize)) {
|
||
pInfo->RepCode=2;
|
||
}
|
||
pInfo->DepLevel=pf[0].Rlev;
|
||
pInfo->MaxValue=pf[1].Vmax;
|
||
pInfo->MinValue=pf[1].Vmin;
|
||
|
||
pInfo->StartDepth=pf[0].Start;
|
||
pInfo->EndDepth=pf[0].Start+(rec-1)*pf[0].Rlev;
|
||
pInfo->StartTime=pf[2].Start;
|
||
pInfo->TimeLevel=pf[2].Rlev;
|
||
pInfo->SamplePoint=pf[2].SamplePoint;
|
||
pInfo->TimeSamples=pf[2].SamplePoint*pf[1].ArrayNum;
|
||
memmove(pInfo->TimeUnit,pf[2].Unit,sizeof(pInfo->TimeUnit));
|
||
memmove(pInfo->TimeHZUnit,pf[2].HZUnit,sizeof(pInfo->TimeHZUnit));
|
||
memmove(pInfo->TimeName,pf[2].Name,sizeof(pInfo->TimeName));
|
||
memmove(pInfo->TimeHZName,pf[2].HZName,sizeof(pInfo->TimeHZName));
|
||
pInfo->ArrayNum=pf[1].ArrayNum;//whp add 2011.11.8
|
||
delete []pf;
|
||
return TRUE;
|
||
}
|
||
bool CLogIO ::SetSlfWaveInfo(int index,Slf_WAVE* pInfo)
|
||
{
|
||
if(index<0) return 0;
|
||
int FieldNum=GetSlfTableFieldCount(index);
|
||
int rec=GetSlfTableRecordCount(index);
|
||
Slf_TABLE_ENTRY obj;
|
||
GetSlfObjectEntry(index,&obj);
|
||
Slf_OBJECT_FIELD *pf=new Slf_OBJECT_FIELD[FieldNum];
|
||
memset(pf,0,sizeof(Slf_OBJECT_FIELD)*FieldNum);
|
||
GetSlfTableFieldInfo(index,pf);
|
||
//whp add
|
||
if(pInfo->ArrayNum<1)pInfo->ArrayNum=1;
|
||
if(strlen(pInfo->AliasName)>sizeof(pInfo->AliasName))strcpy(pInfo->AliasName,pInfo->Name);
|
||
if(strlen(pInfo->Unit)>sizeof(pInfo->Unit))strcpy(pInfo->Unit,"");
|
||
if(strlen(pInfo->AliasUnit)>sizeof(pInfo->AliasUnit))strcpy(pInfo->AliasUnit,pInfo->Unit);
|
||
if(strlen(pInfo->DepthUnit)>sizeof(pInfo->DepthUnit))strcpy(pInfo->DepthUnit,"m");
|
||
if(strlen(pInfo->DepthHZUnit)>sizeof(pInfo->DepthHZUnit))strcpy(pInfo->DepthHZUnit,"米");
|
||
if(strlen(pInfo->LogCopanyName)>sizeof(pInfo->LogCopanyName))strcpy(pInfo->LogCopanyName,"");
|
||
if(strlen(pInfo->Operator)>sizeof(pInfo->Operator))strcpy(pInfo->Operator,"");
|
||
if(strlen(pInfo->DataSource)>sizeof(pInfo->DataSource))strcpy(pInfo->DataSource,"create");
|
||
if(strlen(pInfo->LoggingTeam)>sizeof(pInfo->LoggingTeam))strcpy(pInfo->LoggingTeam,"");
|
||
if(strlen(pInfo->TimeName)>sizeof(pInfo->TimeName)||pInfo->TimeName==NULL)strcpy(pInfo->TimeName,"TIME");
|
||
if(strlen(pInfo->TimeHZName)>sizeof(pInfo->TimeHZName)||pInfo->TimeHZName==NULL)strcpy(pInfo->TimeHZName,"时间");
|
||
if(strlen(pInfo->TimeUnit)>sizeof(pInfo->TimeUnit)||pInfo->TimeUnit==NULL)strcpy(pInfo->TimeUnit,"us");
|
||
if(strlen(pInfo->TimeHZUnit)>sizeof(pInfo->TimeHZUnit)||pInfo->TimeHZUnit==NULL)strcpy(pInfo->TimeHZUnit,pInfo->TimeUnit);
|
||
//
|
||
memmove(obj.Name,pInfo->Name,sizeof(obj.Name));
|
||
memmove(obj.HZName,pInfo->AliasName,sizeof(obj.HZName));
|
||
memmove(obj.Unit,pInfo->Unit,sizeof(obj.Unit));
|
||
memmove(obj.HZUnit,pInfo->AliasUnit,sizeof(obj.HZUnit));
|
||
memmove(obj.LogCopanyName,pInfo->LogCopanyName,sizeof(obj.LogCopanyName));
|
||
memmove(obj.LoggingTeam,pInfo->LoggingTeam,sizeof(obj.LoggingTeam));
|
||
memmove(obj.DataSource,pInfo->DataSource,sizeof(obj.DataSource));
|
||
memmove(obj.Operator,pInfo->Operator,sizeof(obj.Operator));
|
||
obj.SerialID=pInfo->SerialID;
|
||
obj.LoggingDate=pInfo->LoggingDate;
|
||
obj.ChangeNum=pInfo->ChangeNum;
|
||
|
||
WriteSlfObjectEntry(index,&obj);
|
||
|
||
pf[1].Vmax=pInfo->MaxValue;
|
||
pf[1].Vmin=pInfo->MinValue;
|
||
|
||
if(pf[0].Rlev!=pInfo->DepLevel) SlfTableResamples(index,pInfo->DepLevel);
|
||
|
||
memmove(pf[1].Unit,pInfo->Unit,sizeof(pf[1].Unit));
|
||
memmove(pf[1].HZUnit,pInfo->AliasUnit,sizeof(pf[1].HZUnit));
|
||
|
||
memmove(pf[0].Unit,pInfo->DepthUnit,sizeof(pf[0].Unit));
|
||
memmove(pf[0].HZUnit,pInfo->DepthHZUnit,sizeof(pf[0].HZUnit));
|
||
pf[0].Start=pInfo->StartDepth;
|
||
|
||
pf[2].Start=pInfo->StartTime;
|
||
pf[2].Rlev=pInfo->TimeLevel;
|
||
pf[2].SamplePoint=pInfo->SamplePoint;
|
||
//TimeSamples;
|
||
//whp add
|
||
memmove(pf[2].Name,pInfo->TimeName,sizeof(pf[2].Name));
|
||
memmove(pf[2].HZName,pInfo->TimeHZName,sizeof(pf[2].HZName));
|
||
memmove(pf[2].Unit,pInfo->TimeUnit,sizeof(pf[2].Unit));
|
||
memmove(pf[2].HZUnit,pInfo->TimeHZUnit,sizeof(pf[2].Unit));
|
||
pf[1].ArrayNum=pInfo->ArrayNum;//whp add 2011.11.8
|
||
SetSlfTableFieldInfo(index,pf,0);
|
||
delete []pf;
|
||
return TRUE;
|
||
}
|
||
bool CLogIO ::GetWisWaveInfo(int index,Slf_WAVE* pInfo)
|
||
{
|
||
GetChannelInfo(index,&cpInfo);
|
||
memmove(pInfo->AliasName,cpInfo.AliasName,sizeof(pInfo->AliasName));
|
||
memmove(pInfo->Name,m_ObjectEntry[index].Name,sizeof(pInfo->Name));
|
||
pInfo->RepCode=cpInfo.RepCode;
|
||
pInfo->CodeLen=cpInfo.CodeLen;
|
||
pInfo->MaxValue=cpInfo.MaxVal ;
|
||
pInfo->MinValue=cpInfo.MinVal ;
|
||
memmove(pInfo->Unit,cpInfo.Unit,sizeof(pInfo->Unit));
|
||
memmove(pInfo->AliasUnit,cpInfo.AliasUnit,sizeof(pInfo->AliasUnit));
|
||
memmove(pInfo->DepthUnit,cpInfo.DimInfo[0].Unit,sizeof(pInfo->DepthUnit));
|
||
pInfo->StartDepth=cpInfo.DimInfo[0].StartVal;
|
||
pInfo->EndDepth=pInfo->StartDepth+(cpInfo.DimInfo[0].Samples-1)*cpInfo.DimInfo[0].Delta;
|
||
pInfo->DepLevel=cpInfo.DimInfo[0].Delta;
|
||
pInfo->TimeLevel=cpInfo.DimInfo[1].Delta;
|
||
pInfo->StartTime=cpInfo.DimInfo[1].StartVal;
|
||
pInfo->TimeSamples=cpInfo.DimInfo[1].Samples;
|
||
memmove(pInfo->TimeUnit,cpInfo.DimInfo[1].Unit,sizeof(pInfo->TimeUnit));
|
||
pInfo->ArrayNum=1;
|
||
return TRUE;
|
||
}
|
||
bool CLogIO ::SetWisWaveInfo(int index,Slf_WAVE* pInfo)
|
||
{
|
||
GetChannelInfo(index,&cpInfo);
|
||
memmove(cpInfo.AliasName,pInfo->AliasName,sizeof(cpInfo.AliasName));
|
||
Slf_OBJECT_ENTRY mEntry;
|
||
|
||
GetWisObjectEntry(index,&mEntry);
|
||
memmove(mEntry.Name,pInfo->Name,sizeof(mEntry.Name));
|
||
WriteWisObjectEntry(index,&mEntry);
|
||
/*
|
||
cpInfo.RepCode=pInfo->RepCode;
|
||
cpInfo.CodeLen=pInfo->CodeLen;
|
||
cpInfo.MaxVal=pInfo->MaxValue;
|
||
cpInfo.MinVal=pInfo->MinValue;
|
||
*/
|
||
memmove(cpInfo.Unit,pInfo->Unit,sizeof(cpInfo.Unit));
|
||
memmove(cpInfo.AliasUnit,pInfo->AliasUnit,sizeof(cpInfo.AliasUnit));
|
||
memmove(cpInfo.DimInfo[0].Unit,pInfo->DepthUnit,sizeof(cpInfo.DimInfo[0].Unit));
|
||
cpInfo.DimInfo[0].StartVal=pInfo->StartDepth;
|
||
if(cpInfo.DimInfo[0].Delta!=pInfo->DepLevel) WisChannelResamples(index,pInfo->DepLevel);
|
||
int samm=(pInfo->EndDepth-pInfo->StartDepth)/cpInfo.DimInfo[0].Delta+1.5;
|
||
if(samm<0) samm=0;
|
||
cpInfo.DimInfo[0].Samples=samm;
|
||
cpInfo.DimInfo[1].Delta=pInfo->TimeLevel;
|
||
cpInfo.DimInfo[1].StartVal=pInfo->StartTime;
|
||
cpInfo.DimInfo[1].Samples=pInfo->TimeSamples;
|
||
memmove(cpInfo.DimInfo[1].Unit,pInfo->TimeUnit,sizeof(cpInfo.DimInfo[1].Unit));
|
||
SetChannelInfo(index,&cpInfo);
|
||
return TRUE;
|
||
}
|
||
DWORD CLogIO ::ReadWisWave(int index, float depth, DWORD count, char* buffer)
|
||
{
|
||
m_Wave=(Slf_WAVE*)Slf_Info[index];
|
||
int samples=Slf_Int(depth,m_Wave->StartDepth,m_Wave->DepLevel);//((depth-m_Wave->StartDepth)/m_Wave->DepLevel+0.5);
|
||
if(samples<0) samples=0;
|
||
return ReadChannel(index,buffer,count,0,samples);
|
||
}
|
||
DWORD CLogIO ::ReadWave(int index, float depth, DWORD count, float* buffer)
|
||
{
|
||
Slf_WAVE m_Wave;
|
||
GetWaveInfo(index,&m_Wave);
|
||
if(m_Wave.RepCode==REPR_FLOAT) return ReadWave(index, depth, count, (void *)buffer)/m_Wave.CodeLen;
|
||
MyDataTypeEnum vVdl;
|
||
vVdl.vchar=new char[count*m_Wave.SamplePoint*m_Wave.ArrayNum*m_Wave.CodeLen];
|
||
DWORD len=ReadWave(index, depth, count, (void *)vVdl.vchar);
|
||
for(DWORD i=0;i<count*m_Wave.SamplePoint*m_Wave.ArrayNum;i++)
|
||
{
|
||
switch(m_Wave.RepCode)
|
||
{
|
||
case 1:
|
||
buffer[i]=vVdl.vint[i];
|
||
break;
|
||
case 2:
|
||
buffer[i]=vVdl.vshort[i];
|
||
break;
|
||
case 3:
|
||
buffer[i]=vVdl.vlong[i];
|
||
break;
|
||
case 4:
|
||
buffer[i]=vVdl.vfloat[i];
|
||
break;
|
||
case 5:
|
||
buffer[i]=vVdl.vdouble[i];
|
||
break;
|
||
case 6:
|
||
buffer[i]=vVdl.vchar[i];
|
||
break;
|
||
case 7:
|
||
buffer[i]=vVdl.vchar[i];
|
||
break;
|
||
|
||
case 8:
|
||
buffer[i]=vVdl.vuchar[i];
|
||
break;
|
||
|
||
case 9:
|
||
buffer[i]=vVdl.vushort[i];
|
||
break;
|
||
|
||
case 10:
|
||
buffer[i]=vVdl.vuint[i];
|
||
break;
|
||
|
||
case 11:
|
||
buffer[i]=vVdl.vuint[i];
|
||
break;
|
||
}
|
||
}
|
||
delete vVdl.vchar;
|
||
return len/m_Wave.CodeLen;
|
||
}
|
||
DWORD CLogIO ::ReadWave(int index, float depth, DWORD count, short* buffer)
|
||
{
|
||
Slf_WAVE m_Wave;
|
||
GetWaveInfo(index,&m_Wave);
|
||
if(m_Wave.RepCode==REPR_SHORT) return ReadWave(index, depth, count, (void *)buffer)/m_Wave.CodeLen;
|
||
MyDataTypeEnum vVdl;
|
||
vVdl.vchar=new char[count*m_Wave.SamplePoint*m_Wave.ArrayNum*m_Wave.CodeLen];
|
||
DWORD len=ReadWave(index, depth, count, (void *)vVdl.vchar);
|
||
for(DWORD i=0;i<count*m_Wave.SamplePoint*m_Wave.ArrayNum;i++)
|
||
{
|
||
switch(m_Wave.RepCode)
|
||
{
|
||
case 1:
|
||
buffer[i]=vVdl.vint[i];
|
||
break;
|
||
case 2:
|
||
buffer[i]=vVdl.vshort[i];
|
||
break;
|
||
case 3:
|
||
buffer[i]=vVdl.vlong[i];
|
||
break;
|
||
case 4:
|
||
buffer[i]=vVdl.vfloat[i];
|
||
break;
|
||
case 5:
|
||
buffer[i]=vVdl.vdouble[i];
|
||
break;
|
||
case 6:
|
||
buffer[i]=vVdl.vchar[i];
|
||
break;
|
||
case 7:
|
||
buffer[i]=vVdl.vchar[i];
|
||
break;
|
||
|
||
case 8:
|
||
buffer[i]=vVdl.vuchar[i];
|
||
break;
|
||
|
||
case 9:
|
||
buffer[i]=vVdl.vushort[i];
|
||
break;
|
||
|
||
case 10:
|
||
buffer[i]=vVdl.vuint[i];
|
||
break;
|
||
|
||
case 11:
|
||
buffer[i]=vVdl.vuint[i];
|
||
break;
|
||
}
|
||
}
|
||
delete vVdl.vchar;
|
||
return len/m_Wave.CodeLen;
|
||
}
|
||
DWORD CLogIO ::ReadWave(int index, float depth, DWORD count, int* buffer)
|
||
{
|
||
Slf_WAVE m_Wave;
|
||
GetWaveInfo(index,&m_Wave);
|
||
if(m_Wave.RepCode==REPR_INT) return ReadWave(index, depth, count, (void *)buffer)/m_Wave.CodeLen;
|
||
MyDataTypeEnum vVdl;
|
||
vVdl.vchar=new char[count*m_Wave.SamplePoint*m_Wave.ArrayNum*m_Wave.CodeLen];
|
||
DWORD len=ReadWave(index, depth, count, (void *)vVdl.vchar);
|
||
for(DWORD i=0;i<count*m_Wave.SamplePoint*m_Wave.ArrayNum;i++)
|
||
{
|
||
switch(m_Wave.RepCode)
|
||
{
|
||
case 1:
|
||
buffer[i]=vVdl.vint[i];
|
||
break;
|
||
case 2:
|
||
buffer[i]=vVdl.vshort[i];
|
||
break;
|
||
case 3:
|
||
buffer[i]=vVdl.vlong[i];
|
||
break;
|
||
case 4:
|
||
buffer[i]=vVdl.vfloat[i];
|
||
break;
|
||
case 5:
|
||
buffer[i]=vVdl.vdouble[i];
|
||
break;
|
||
case 6:
|
||
buffer[i]=vVdl.vchar[i];
|
||
break;
|
||
case 7:
|
||
buffer[i]=vVdl.vchar[i];
|
||
break;
|
||
|
||
case 8:
|
||
buffer[i]=vVdl.vuchar[i];
|
||
break;
|
||
|
||
case 9:
|
||
buffer[i]=vVdl.vushort[i];
|
||
break;
|
||
|
||
case 10:
|
||
buffer[i]=vVdl.vuint[i];
|
||
break;
|
||
|
||
case 11:
|
||
buffer[i]=vVdl.vuint[i];
|
||
break;
|
||
}
|
||
}
|
||
delete vVdl.vchar;
|
||
return len/m_Wave.CodeLen;
|
||
}
|
||
DWORD CLogIO ::ReadWave(int index, float depth, DWORD count, void* buffer)
|
||
{
|
||
if(IsWis) return ReadWisWave(index,depth,count,(char *)buffer);
|
||
DWORD n=ReadSlfCurve(index,depth,count,(char*)buffer);
|
||
return n;
|
||
}
|
||
DWORD CLogIO ::ReadWave(int index, float depth, DWORD count, char* buffer)
|
||
{
|
||
Slf_WAVE m_Wave;
|
||
GetWaveInfo(index,&m_Wave);
|
||
if(m_Wave.RepCode==REPR_CHAR) return ReadWave(index, depth, count, (void *)buffer)/m_Wave.CodeLen;
|
||
MyDataTypeEnum vVdl;
|
||
vVdl.vchar=new char[count*m_Wave.SamplePoint*m_Wave.ArrayNum*m_Wave.CodeLen];
|
||
DWORD len=ReadWave(index, depth, count, (void *)vVdl.vchar);
|
||
for(DWORD i=0;i<count*m_Wave.SamplePoint*m_Wave.ArrayNum;i++)
|
||
{
|
||
switch(m_Wave.RepCode)
|
||
{
|
||
case 1:
|
||
buffer[i]=vVdl.vint[i];
|
||
break;
|
||
case 2:
|
||
buffer[i]=vVdl.vshort[i];
|
||
break;
|
||
case 3:
|
||
buffer[i]=vVdl.vlong[i];
|
||
break;
|
||
case 4:
|
||
buffer[i]=vVdl.vfloat[i];
|
||
break;
|
||
case 5:
|
||
buffer[i]=vVdl.vdouble[i];
|
||
break;
|
||
case 6:
|
||
buffer[i]=vVdl.vchar[i];
|
||
break;
|
||
case 7:
|
||
buffer[i]=vVdl.vchar[i];
|
||
break;
|
||
|
||
case 8:
|
||
buffer[i]=vVdl.vuchar[i];
|
||
break;
|
||
|
||
case 9:
|
||
buffer[i]=vVdl.vushort[i];
|
||
break;
|
||
|
||
case 10:
|
||
buffer[i]=vVdl.vuint[i];
|
||
break;
|
||
|
||
case 11:
|
||
buffer[i]=vVdl.vuint[i];
|
||
break;
|
||
}
|
||
}
|
||
delete vVdl.vchar;
|
||
return len/m_Wave.CodeLen;
|
||
}
|
||
DWORD CLogIO ::WriteWave(int index, float depth, DWORD count, void* buffer)
|
||
{
|
||
if(IsWis) {
|
||
return WriteWisCurve(index,depth,count,(char *)buffer);
|
||
}
|
||
return WriteSlfCurve(index,depth,count,(char *)buffer);
|
||
}
|
||
DWORD CLogIO ::WriteWave(int index, float depth, DWORD count, int* buffer)
|
||
{
|
||
Slf_WAVE m_Wave;
|
||
GetWaveInfo(index,&m_Wave);
|
||
if(m_Wave.RepCode==REPR_INT) return WriteWave(index, depth, count, (void *)buffer);
|
||
|
||
MyDataTypeEnum vVdl;
|
||
vVdl.vchar=new char[count*m_Wave.TimeSamples*m_Wave.CodeLen];
|
||
WriteBuf((char *)buffer,REPR_INT,sizeof(int),vVdl,m_Wave.RepCode,count,m_Wave.TimeSamples);
|
||
DWORD len=WriteWave(index, depth, count, (void *)vVdl.vchar);
|
||
delete vVdl.vchar;
|
||
return len;
|
||
}
|
||
DWORD CLogIO ::WriteWave(int index, float depth, DWORD count, float* buffer)
|
||
{
|
||
Slf_WAVE m_Wave;
|
||
GetWaveInfo(index,&m_Wave);
|
||
if(m_Wave.RepCode==REPR_FLOAT) return WriteWave(index, depth, count, (void *)buffer);
|
||
|
||
MyDataTypeEnum vVdl;
|
||
vVdl.vchar=new char[count*m_Wave.TimeSamples*m_Wave.CodeLen];
|
||
WriteBuf((char *)buffer,REPR_FLOAT,sizeof(float),vVdl,m_Wave.RepCode,count,m_Wave.TimeSamples);
|
||
DWORD len=WriteWave(index, depth, count, (void *)vVdl.vchar);
|
||
delete vVdl.vchar;
|
||
return len;
|
||
}
|
||
DWORD CLogIO ::WriteWave(int index, float depth, DWORD count, short* buffer)
|
||
{
|
||
Slf_WAVE m_Wave;
|
||
GetWaveInfo(index,&m_Wave);
|
||
if(m_Wave.RepCode==REPR_SHORT) return WriteWave(index, depth, count, (void *)buffer);
|
||
|
||
MyDataTypeEnum vVdl;
|
||
vVdl.vchar=new char[count*m_Wave.TimeSamples*m_Wave.CodeLen];
|
||
WriteBuf((char *)buffer,REPR_SHORT,sizeof(short),vVdl,m_Wave.RepCode,count,m_Wave.TimeSamples);
|
||
DWORD len=WriteWave(index, depth, count, (void *)vVdl.vchar);
|
||
delete vVdl.vchar;
|
||
return len;
|
||
}
|
||
DWORD CLogIO ::WriteWave(int index, float depth, DWORD count, char* buffer)
|
||
{
|
||
Slf_WAVE m_Wave;
|
||
GetWaveInfo(index,&m_Wave);
|
||
if(m_Wave.RepCode==REPR_CHAR) return WriteWave(index, depth, count, (void *)buffer);
|
||
|
||
MyDataTypeEnum vVdl;
|
||
vVdl.vchar=new char[count*m_Wave.TimeSamples*m_Wave.CodeLen];
|
||
WriteBuf((char *)buffer,REPR_CHAR,sizeof(char),vVdl,m_Wave.RepCode,count,m_Wave.TimeSamples);
|
||
DWORD len=WriteWave(index, depth, count, (void *)vVdl.vchar);
|
||
delete vVdl.vchar;
|
||
return len;
|
||
}
|
||
int CLogIO ::OpenOG_RESULT(const char *name)
|
||
{
|
||
return Open_Set_Table(name,GUJING_OBJECT,4,
|
||
"NO,SDEP,EDEP,RESULT",
|
||
"4,4,4,4",
|
||
"1,4,4,1",
|
||
"0,0,0,2");
|
||
}
|
||
int CLogIO ::OpenFRAC_MODEL(const char *name)
|
||
{
|
||
return Open_Set_Table(name,FRAC_MODEL_OBJECT,5,"NO,DEPTH,WIDTH,ANGLE,COLOR",
|
||
"4,4,4,4,4",
|
||
"1,4,4,4,1",
|
||
"0,0,0,0,0");
|
||
}
|
||
int CLogIO ::OpenFRAC_LEVEL(const char *name)
|
||
{
|
||
return Open_Set_Table(name,FRAC_LEVEL_OBJECT,3,
|
||
"NO,DEPTH,LEVEL",
|
||
"4,4,4",
|
||
"1,4,1",
|
||
"0,0,0");
|
||
}
|
||
int CLogIO ::OpenCORE_PHYSICS(const char *name)
|
||
{
|
||
return Open_Set_Table(name,CORE_PHYSICS_OBJECT,8,
|
||
"NO,DEPTH,CORRDEPTH,DEN,POR,PERM,SW,VCAL",
|
||
"4,4,4,4,4,4,4,4",
|
||
"1,4,4,4,4,4,4,4",
|
||
"0,0,0,0,0,0,0,0");
|
||
}
|
||
int CLogIO ::OpenFMT_MODEL(const char *name)
|
||
{
|
||
return Open_Set_Table(name,FMT_MODEL_OBJECT,9,
|
||
"NO,SDEP,EDEP,RXO,RI,RT,RXORADIUS,RIRADIUS,CORENO",
|
||
"4,4,4,4,4,4,4,4,4",
|
||
"1,4,4,4,4,4,4,4,1",
|
||
"0,0,0,0,0,0,0,0,0");
|
||
}
|
||
int CLogIO ::OpenFMT_RESULT(const char *name)
|
||
{
|
||
return Open_Set_Table(name,FMT_OBJECT,8,
|
||
"POINTNO,DEPTH,PMUD,PFMT,PFLOW,FTIME,FDEN,PERM",
|
||
"4,4,4,4,4,4,4,4",
|
||
"1,4,4,4,4,4,4,4",
|
||
"0,0,0,0,0,0,0,0");
|
||
}
|
||
int CLogIO ::OpenSTATIC(const char *name)
|
||
{
|
||
return Open_Set_Table(name,STATIC_OBJECT,30,
|
||
"AreaName,OilCompanyName,WellName,APICode,WellType,XCoor,YCoor,As1,Bs1,StartDrillDate,EndDrillDate,CompleteDate,MethodCWell,BitProg1,BitProg2,BitProg3,BitProg4,BitProg5,CasProg1,CasProg2,CasProg3,CasProg4,CasProg5,shotCas1,Sc1sdep,Sc1Edep,shotCas2,Sc2sdep,Sc2Edep,Remark",
|
||
"40,40,40,4,4,4,4,4,4,12,12,12,16,24,24,24,24,24,24,24,24,24,24,4,4,4,4,4,4,64",
|
||
"6, 6, 6, 1,1,4,4,4,4, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,4,4,4,4,4,4,6",
|
||
"0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0");
|
||
}
|
||
int CLogIO ::OpenDYNAMIC(const char *name)
|
||
{
|
||
return Open_Set_Table(name,DYNAMIC_OBJECT,19,
|
||
"LogCompanyName,Operator,Date,Serial,Item,Section,MudType,WaterLoss,MudViscosity,MudDensity,MudResi,MudTemp,LogRange,IntRange,TempBot,IntProg,IntDress,Author,Remark",
|
||
"40,16,12,16,16,16,12,4,4,4,4,4,24,24,4,12,16,16,64",
|
||
"6, 6, 6, 6, 6, 6, 6, 4,4,4,4,4,6, 6, 4,6, 6, 6,6",
|
||
"0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0");
|
||
}
|
||
int CLogIO ::OpenCORE(const char *name)
|
||
{
|
||
return Open_Set_Table(name,CORE_OBJECT,10,
|
||
"Depth,oil,Lith,Color,Date,Tool,Number,LithName,Remark",
|
||
"4,4,4,4,4,12,12,4,32,64",
|
||
"4,1,1,1,1,6,6,1,6,6",
|
||
"0,1,1,1,0,0,0,0,0,0");
|
||
}
|
||
int CLogIO ::Open_Set_Table(const char *name,short Subattriber,int fieldcount,const char *FieldName,const char *FieldLength,const char *FieldType,const char *FieldResave,const char *FieldHZName,const char *FieldUnit,const char *FieldHZUnit)
|
||
{
|
||
int index=OpenTable(name);
|
||
if(fieldcount<=0) return index;
|
||
if(index<0) {
|
||
if(IsWis) index=CreateTable(Subattriber,name);
|
||
else index=CreateTable(Subattriber,name,fieldcount);
|
||
Slf_TABLE_FIELD *FieldInfo=new Slf_TABLE_FIELD[fieldcount+1];
|
||
memset(FieldInfo,0,sizeof(Slf_TABLE_FIELD)*fieldcount);
|
||
SetFieldInfo(fieldcount,const_cast<char*>(FieldName),const_cast<char*>(FieldLength),const_cast<char*>(FieldType),const_cast<char*>(FieldResave),(FieldInfo),const_cast<char*>(FieldHZName),const_cast<char*>(FieldUnit),const_cast<char*>(FieldHZUnit));
|
||
SetTableHead(index,0,fieldcount,FieldInfo);
|
||
delete FieldInfo;
|
||
}
|
||
return index;
|
||
}
|
||
void CLogIO ::SetFieldInfo(int num, char *str1,char *str2,char *str3,char *str4,Slf_TABLE_FIELD *FieldInfo,char *str5,char *FieldUnit,char *FieldHZUnit)
|
||
{
|
||
char p1[2000],p2[2000],p3[2000],p4[2000],p5[2000],p6[2000],p7[2000];
|
||
char *pp1,*pp2,*pp3,*pp4,*pp5,*pp6,*pp7;
|
||
pp1=str1;
|
||
pp2=str2;
|
||
pp3=str3;
|
||
pp4=str4;
|
||
pp5=str5;
|
||
|
||
pp6=FieldUnit;
|
||
pp7=FieldHZUnit;
|
||
|
||
if(!pp5) pp5=str1;
|
||
for(int i=0;i<num;i++) {
|
||
//
|
||
strcpy(p1,pp1);
|
||
if(strchr(p1,',')) {
|
||
pp1=strchr(p1,',')+1;
|
||
*strchr(p1,',')='\0';
|
||
}
|
||
strcpy(FieldInfo[i].Name,p1);
|
||
//
|
||
strcpy(p5,pp5);
|
||
if(strchr(p5,',')) {
|
||
pp5=strchr(p5,',')+1;
|
||
*strchr(p5,',')='\0';
|
||
}
|
||
strcpy(FieldInfo[i].HZName,p5);
|
||
//
|
||
|
||
strcpy(p2,pp2);
|
||
if(strchr(p2,',')) {
|
||
pp2=strchr(p2,',')+1;
|
||
*strchr(p2,',')='\0';
|
||
}
|
||
FieldInfo[i].Length=atoi(p2);
|
||
//
|
||
strcpy(p3,pp3);
|
||
if(strchr(p3,',')) {
|
||
pp3=strchr(p3,',')+1;
|
||
*strchr(p3,',')='\0';
|
||
}
|
||
FieldInfo[i].RepCode=atoi(p3);
|
||
//
|
||
strcpy(p4,pp4);
|
||
if(strchr(p4,',')) {
|
||
pp4=strchr(p4,',')+1;
|
||
*strchr(p4,',')='\0';
|
||
}
|
||
FieldInfo[i].Reserved=atoi(p4);
|
||
//
|
||
if(pp6){
|
||
strcpy(p6,pp6);
|
||
if(strchr(p6,',')) {
|
||
pp6=strchr(p6,',')+1;
|
||
*strchr(p6,',')='\0';
|
||
}
|
||
strcpy(FieldInfo[i].Unit,p6);
|
||
}
|
||
if(pp7){
|
||
strcpy(p7,pp7);
|
||
if(strchr(p7,',')) {
|
||
pp7=strchr(p7,',')+1;
|
||
*strchr(p7,',')='\0';
|
||
}
|
||
strcpy(FieldInfo[i].HZUnit,p7);
|
||
}
|
||
}
|
||
}
|
||
|
||
int CLogIO::GetTableFieldData(char *TableName,char *FieldName,char *buf,int Rec,bool islink)
|
||
{
|
||
int index=FindObjectIndex(TableName);
|
||
int Flag=0;
|
||
if(index<0) return -1;
|
||
if(!Slf_Info_Head[index]) {
|
||
Flag=1;
|
||
index=OpenTable(TableName);
|
||
};
|
||
int re=GetTableFieldData(index,FieldName,buf,Rec,islink);
|
||
if(Flag) CloseTable(index);
|
||
return re;
|
||
}
|
||
int CLogIO::GetTableFieldData(char *TableName,char *FieldName,char *buf,float &yy,int Rec,bool islink)
|
||
{
|
||
int index=FindObjectIndex(TableName);
|
||
int Flag=0;
|
||
if(index<0) return -1;
|
||
if(!Slf_Info_Head[index]) {
|
||
Flag=1;
|
||
index=OpenTable(TableName);
|
||
};
|
||
int re=GetTableFieldData(index,FieldName,buf,yy,Rec,islink);
|
||
if(Flag) CloseTable(index);
|
||
return re;
|
||
}
|
||
int CLogIO::GetTableFieldData(int index,int FieldNo,float *buf,int Rec,bool islink)
|
||
{
|
||
char buf1[300];
|
||
int ret=GetTableFieldData(index,FieldNo,buf1,Rec,islink);
|
||
sscanf(buf1,"%f",buf);
|
||
return ret;
|
||
}
|
||
int CLogIO::GetReservedIndex(char *buf,int Reserved)
|
||
{
|
||
QStringList Vals;
|
||
if(Reserved==1) {
|
||
Vals=QString(buf).split("上");
|
||
Vals.removeAll("");
|
||
Vals.removeAll("上");
|
||
QStringList Vars;
|
||
if(Vals.indexOf("中水淹层")>-1||
|
||
Vals.indexOf("中水淹层1")>-1||
|
||
Vals.indexOf("中水淹层2")>-1||
|
||
Vals.indexOf("中水淹层3")>-1||
|
||
Vals.indexOf("中水淹层4")>-1||
|
||
|
||
Vals.indexOf("中含水层")>-1||
|
||
Vals.indexOf("中含水层1")>-1||
|
||
Vals.indexOf("中含水层2")>-1||
|
||
Vals.indexOf("中含水层3")>-1||
|
||
Vals.indexOf("中含水层4")>-1)
|
||
{
|
||
}
|
||
else {
|
||
foreach(QString cs,Vals)
|
||
{
|
||
QStringList vals1=cs.split("中");
|
||
Vars.append(vals1);
|
||
}
|
||
Vars.removeAll("中");
|
||
Vars.removeAll("");
|
||
Vals.clear();
|
||
|
||
foreach(QString cs,Vars)
|
||
{
|
||
QStringList vals1=cs.split("下");
|
||
Vals.append(vals1);
|
||
}
|
||
Vals.removeAll("下");
|
||
}
|
||
//////////
|
||
Vars=Vals;
|
||
Vals.clear();
|
||
foreach(QString cs,Vars)
|
||
{
|
||
bool isspik=false;
|
||
for(int i=0;i<10;i++)
|
||
{
|
||
if(cs.indexOf("层"+QString::number(i))>-1)
|
||
{
|
||
isspik=true;
|
||
break;
|
||
}
|
||
}
|
||
if(isspik) Vals.append(cs);
|
||
else {
|
||
QStringList vals1=cs.split("层");
|
||
Vals.append(vals1);
|
||
}
|
||
}
|
||
Vals.removeAll("");
|
||
Vars=Vals;
|
||
Vals.clear();
|
||
foreach(QString cs,Vars)
|
||
{
|
||
if(cs.lastIndexOf("层")<0&&cs!="空") cs.append("层");
|
||
Vals.append(cs);
|
||
}
|
||
}
|
||
else Vals.append(buf);
|
||
Vals.removeAll("");
|
||
int index=0;
|
||
foreach(QString cs,Vals) {
|
||
int ind=Slf_Menu[Reserved-1].indexOf(cs);
|
||
if(ind>-1) {
|
||
if(Reserved==5) index=Slf_Menu[Reserved][ind].toInt();
|
||
else if(Reserved==2) index=ind;
|
||
else index=index*10+ind+1;
|
||
}
|
||
}
|
||
return index;
|
||
}
|
||
void CLogIO::GetReservedValue(float yy,int Reserved,char *Buffer,char *buf,int len,bool islink,bool isList)
|
||
{
|
||
int no=(int)(yy-1);
|
||
if(Reserved==2) no=yy;
|
||
if(no<0&&Reserved!=5) sprintf(buf,"%f",yy);
|
||
else {
|
||
if(Reserved==1) {
|
||
LAYER_DATA *result=(LAYER_DATA *)Buffer;
|
||
QString str=QString::number((int)yy);
|
||
if((len==sizeof(LAYER_DATA)||len==sizeof(LAYER_DATA_OLD))&&result->MDepth1&&str.length()>1){
|
||
QString val;
|
||
QStringList vals;
|
||
int loop=0;
|
||
for(int k=0;k<str.length();k++) {
|
||
int n=str[k].toLatin1()-'1';
|
||
if(n<0||n>=Slf_Menu[Reserved-1].size()) continue;
|
||
if(str.length()>1/*&&k!=str.length()-1*/) {
|
||
if(!islink&&Slf_Menu[Reserved-1][n].indexOf("干层")>-1) continue;
|
||
}
|
||
if(!islink&&val==Slf_Menu[Reserved-1][n].toStdString().c_str()) {
|
||
continue;
|
||
}
|
||
if(!islink) {
|
||
if(!loop) vals.append("上");
|
||
else if(k!=str.length()-1) {
|
||
vals.append("中");
|
||
}
|
||
else vals.append("下");
|
||
loop++;
|
||
}
|
||
vals.append(Slf_Menu[Reserved-1][n].toStdString().c_str());
|
||
val=Slf_Menu[Reserved-1][n].toStdString().c_str();
|
||
}
|
||
if(vals.indexOf("上")>-1&&vals.indexOf("下")==-1) {
|
||
int flag=0;
|
||
for(int i=vals.size()-1;i>-1;i--)
|
||
{
|
||
if(vals[i]=="中") {
|
||
vals[i]="下";
|
||
flag=1;
|
||
break;
|
||
}
|
||
}
|
||
if(!flag) vals.removeAll("上");
|
||
};
|
||
if(!isList) strcpy(buf,vals.join("").toStdString().c_str());
|
||
else strcpy(buf,vals.join(";").toStdString().c_str());
|
||
}
|
||
else {
|
||
if(no<0||no>=Slf_Menu[Reserved-1].size()) strcpy(buf,"");
|
||
else strcpy(buf,Slf_Menu[Reserved-1][no].toStdString().c_str());
|
||
}
|
||
if(!islink){
|
||
if(isShengLi){
|
||
if(strstr(buf,"水淹")) strcpy(buf,"水淹层");
|
||
if(strcmp(buf,"偏干油层")==0) strcpy(buf,"油层");
|
||
if(strcmp(buf,"含水油层")==0) strcpy(buf,"油层");
|
||
if(strcmp(buf,"含气油层")==0) strcpy(buf,"油层");
|
||
}
|
||
}
|
||
}
|
||
else if(Reserved==5) {
|
||
int ind=Slf_Menu[Reserved].indexOf(QString::number(no+1));
|
||
if(ind>=0&&ind<Slf_Menu[Reserved-1].size()) {
|
||
strcpy(buf,Slf_Menu[Reserved-1][ind].toStdString().c_str());
|
||
}
|
||
else sprintf(buf,"%f",yy);
|
||
}
|
||
else {
|
||
if(no>=0&&no<Slf_Menu[Reserved-1].size()) strcpy(buf,Slf_Menu[Reserved-1][no].toStdString().c_str());
|
||
else sprintf(buf,"%f",yy);
|
||
}
|
||
}
|
||
}
|
||
int CLogIO::GetTableFieldData(int index,int FieldNo,char *buf,float &yy,int Rec,bool islink)
|
||
{
|
||
if(!buf) return 0;
|
||
int count=GetTableFieldCount(index);
|
||
Slf_TABLE_FIELD *field=new Slf_TABLE_FIELD[count+1];
|
||
GetTableFieldInfo(index,field);
|
||
int reclen=GetTableRecordLength(index);
|
||
if(reclen<1) {
|
||
buf[0]=0;
|
||
delete field;
|
||
return 0;
|
||
}
|
||
char *Buffer=new char[reclen+1];
|
||
memset(Buffer,0,reclen+1);
|
||
ReadTable(index,Rec,Buffer);
|
||
int i=0,len=0;
|
||
for(i=0;i<FieldNo;i++) len+=field[i].Length;
|
||
int ty=field[i].RepCode;
|
||
if(field[i].RepCode!=6) {
|
||
GetData(field[i].RepCode,&Buffer[len],&yy);
|
||
if(field[i].Reserved&&!IsChange) {
|
||
ty=sizeof(RepSize)+1;
|
||
if(field[i].Reserved>0&&field[i].Reserved<=m_MenuNumber)
|
||
{
|
||
GetReservedValue(yy,field[i].Reserved,Buffer,buf,reclen,islink);
|
||
}
|
||
else sprintf(buf,"%.8f",yy);
|
||
}
|
||
else sprintf(buf,"%.8f",yy);
|
||
}
|
||
else {
|
||
strncpy(buf,&Buffer[len],field[i].Length);
|
||
buf[field[i].Length]='\0';
|
||
}
|
||
delete []Buffer;
|
||
delete []field;
|
||
return ty;
|
||
}
|
||
int CLogIO::GetTableFieldData(int index,int FieldNo,char *buf,int Rec,bool islink)
|
||
{
|
||
if(!buf) return 0;
|
||
int count=GetTableFieldCount(index);
|
||
Slf_TABLE_FIELD *field=new Slf_TABLE_FIELD[count+1];
|
||
GetTableFieldInfo(index,field);
|
||
int reclen=GetTableRecordLength(index);
|
||
if(reclen<1) {
|
||
buf[0]=0;
|
||
delete field;
|
||
return 0;
|
||
}
|
||
char *Buffer=new char[reclen+1];
|
||
memset(Buffer,0,reclen+1);
|
||
ReadTable(index,Rec,Buffer);
|
||
int i=0,len=0;
|
||
for(i=0;i<FieldNo;i++) len+=field[i].Length;
|
||
float yy;
|
||
int ty=field[i].RepCode;
|
||
if(field[i].RepCode!=6) {
|
||
GetData(field[i].RepCode,&Buffer[len],&yy);
|
||
if(field[i].Reserved&&!IsChange) {
|
||
ty=sizeof(RepSize)+1;
|
||
if(field[i].Reserved>0&&field[i].Reserved<=m_MenuNumber)
|
||
{
|
||
GetReservedValue(yy,field[i].Reserved,Buffer,buf,reclen,islink);
|
||
}
|
||
else sprintf(buf,"%.8f",yy);
|
||
}
|
||
else sprintf(buf,"%.8f",yy);
|
||
}
|
||
else {
|
||
strncpy(buf,&Buffer[len],field[i].Length);
|
||
buf[field[i].Length]='\0';
|
||
}
|
||
delete []Buffer;
|
||
delete []field;
|
||
return ty;
|
||
}
|
||
int CLogIO::GetTableFieldData(int index,int FieldNo,int Rec,char *value,bool islink)
|
||
{
|
||
if(!value) return 0;
|
||
int count=GetTableFieldCount(index);
|
||
Slf_TABLE_FIELD *field=new Slf_TABLE_FIELD[count+1];
|
||
GetTableFieldInfo(index,field);
|
||
int reclen=GetTableRecordLength(index);
|
||
if(reclen<1) {
|
||
value[0]=0;
|
||
delete field;
|
||
return 0;
|
||
}
|
||
char *Buffer=new char[reclen+1];
|
||
memset(Buffer,0,reclen+1);
|
||
ReadTable(index,Rec,Buffer);
|
||
int i=0,len=0;
|
||
for(i=0;i<FieldNo;i++) len+=field[i].Length;
|
||
int ty=field[i].RepCode;
|
||
if(field[i].RepCode!=6) {
|
||
GetData(field[i].RepCode,&Buffer[len],(float *)value);
|
||
if(field[i].Reserved&&!IsChange) {
|
||
ty=sizeof(RepSize)+1;
|
||
if(field[i].Reserved>0&&field[i].Reserved<=m_MenuNumber)
|
||
{
|
||
float yy=*(float *)value;
|
||
GetReservedValue(yy,field[i].Reserved,Buffer,value,reclen,islink);
|
||
}
|
||
}
|
||
}
|
||
else {
|
||
strncpy(value,&Buffer[len],field[i].Length);
|
||
value[field[i].Length]='\0';
|
||
}
|
||
delete []Buffer;
|
||
delete []field;
|
||
return ty;
|
||
}
|
||
int CLogIO::SetTableFieldData(int index,int FieldNo,char *buf,int Rec)
|
||
{
|
||
int count=GetTableFieldCount(index);
|
||
Slf_TABLE_FIELD *field=new Slf_TABLE_FIELD[count+1];
|
||
GetTableFieldInfo(index,field);
|
||
char *Buffer=new char[GetTableRecordLength(index)+1];
|
||
memset(Buffer,0,GetTableRecordLength(index)+1);
|
||
ReadTable(index,Rec,Buffer);
|
||
int i=0,len=0;
|
||
for(i=0;i<FieldNo;i++) len+=field[i].Length;
|
||
if(field[FieldNo].RepCode!=6) {
|
||
if(field[i].Reserved&&!IsChange) {
|
||
int flag=0;
|
||
if(field[i].Reserved>0&&field[i].Reserved<=m_MenuNumber)
|
||
{
|
||
if(/*isalpha(buf[0])||*/(buf[0]&0x80&&buf[1]&0x80)) {
|
||
float ind=GetReservedIndex(buf,field[i].Reserved);
|
||
if(ind>-1) {
|
||
SetData(field[FieldNo].RepCode,&Buffer[len],(float *)&ind);
|
||
flag=1;
|
||
}
|
||
}
|
||
}
|
||
if(!flag){
|
||
if(isalpha(buf[0])||(buf[0]&0x80&&buf[1]&0x80)) {
|
||
float val=atof(buf);
|
||
SetData(field[FieldNo].RepCode,&Buffer[len],(float *)&val);
|
||
}
|
||
else SetData(field[FieldNo].RepCode,&Buffer[len],(float *)buf);
|
||
}
|
||
}
|
||
else SetData(field[FieldNo].RepCode,&Buffer[len],(float *)buf);
|
||
}
|
||
else {
|
||
strncpy(&Buffer[len],buf,field[FieldNo].Length);
|
||
}
|
||
WriteTable(index,Rec,Buffer);
|
||
delete []Buffer;
|
||
delete []field;
|
||
return 1;
|
||
}
|
||
int CLogIO::GetTableFieldData(int fieldcount,Slf_TABLE_FIELD *field,char *FieldName,char *InBuffer,char *buf,int reclen,bool islink)
|
||
{
|
||
int i=0,len=0;
|
||
for(i=0;i<fieldcount;i++) {
|
||
if(stricmp(FieldName,field[i].Name)==0||stricmp(FieldName,field[i].HZName)==0) {
|
||
float yy;
|
||
if(field[i].RepCode!=6) {
|
||
GetData(field[i].RepCode,&InBuffer[len],&yy);
|
||
sprintf(buf,"%g",yy);
|
||
}
|
||
else {
|
||
strncpy(buf,&InBuffer[len],field[i].Length);
|
||
buf[field[i].Length]='\0';
|
||
}
|
||
int ty=field[i].RepCode;
|
||
if(field[i].Reserved&&!IsChange) {
|
||
ty=sizeof(RepSize)+1;
|
||
if(field[i].Reserved>0&&field[i].Reserved<=m_MenuNumber)
|
||
{
|
||
GetReservedValue(yy,field[i].Reserved,InBuffer,buf,reclen,islink);
|
||
}
|
||
else sprintf(buf,"%f",yy);
|
||
}
|
||
return ty;
|
||
}
|
||
len+=field[i].Length;
|
||
}
|
||
return 0;;
|
||
}
|
||
int CLogIO::GetTableFieldData(int fieldcount,Slf_TABLE_FIELD *field,char *FieldName,char *InBuffer,char *buf,float &yy,int reclen,bool islink)
|
||
{
|
||
int i=0,len=0;
|
||
for(i=0;i<fieldcount;i++) {
|
||
if(stricmp(FieldName,field[i].Name)==0||stricmp(FieldName,field[i].HZName)==0) {
|
||
if(field[i].RepCode!=6) {
|
||
GetData(field[i].RepCode,&InBuffer[len],&yy);
|
||
sprintf(buf,"%g",yy);
|
||
}
|
||
else {
|
||
strncpy(buf,&InBuffer[len],field[i].Length);
|
||
buf[field[i].Length]='\0';
|
||
}
|
||
int ty=field[i].RepCode;
|
||
if(field[i].Reserved&&!IsChange) {
|
||
ty=sizeof(RepSize)+1;
|
||
if(field[i].Reserved>0&&field[i].Reserved<=m_MenuNumber)
|
||
{
|
||
GetReservedValue(yy,field[i].Reserved,InBuffer,buf,reclen,islink);
|
||
}
|
||
else sprintf(buf,"%f",yy);
|
||
}
|
||
return ty;
|
||
}
|
||
len+=field[i].Length;
|
||
}
|
||
return 0;;
|
||
}
|
||
|
||
int CLogIO::GetTableFieldData(int index,char *FieldName,char *buf,int Rec,bool islink)
|
||
{
|
||
int count=GetTableFieldCount(index);
|
||
int reclen=GetTableRecordLength(index);
|
||
Slf_TABLE_FIELD *field=new Slf_TABLE_FIELD[count+1];
|
||
GetTableFieldInfo(index,field);
|
||
char *Buffer=new char[reclen+1];
|
||
memset(Buffer,0,reclen+1);
|
||
ReadTable(index,Rec,Buffer);
|
||
int i=0,len=0;
|
||
for(i=0;i<count;i++) {
|
||
if(stricmp(FieldName,field[i].Name)==0||stricmp(FieldName,field[i].HZName)==0) {
|
||
float yy;
|
||
if(field[i].RepCode!=6) {
|
||
GetData(field[i].RepCode,&Buffer[len],&yy);
|
||
sprintf(buf,"%f",yy);
|
||
}
|
||
else {
|
||
strncpy(buf,&Buffer[len],field[i].Length);
|
||
buf[field[i].Length]='\0';
|
||
}
|
||
int ty=field[i].RepCode;
|
||
if(field[i].Reserved&&!IsChange) {
|
||
ty=sizeof(RepSize)+1;
|
||
if(field[i].Reserved>0&&field[i].Reserved<=m_MenuNumber)
|
||
{
|
||
int reclen=GetTableRecordLength(index);
|
||
GetReservedValue(yy,field[i].Reserved,Buffer,buf,reclen,islink);
|
||
}
|
||
else sprintf(buf,"%f",yy);
|
||
}
|
||
delete []Buffer;
|
||
delete []field;
|
||
return ty;
|
||
}
|
||
len+=field[i].Length;
|
||
}
|
||
delete []Buffer;
|
||
delete []field;
|
||
return 0;
|
||
}
|
||
int CLogIO::GetTableFieldData(int index,char *FieldName,char *buf,float &yy,int Rec,bool islink)
|
||
{
|
||
yy=0;
|
||
int count=GetTableFieldCount(index);
|
||
int reclen=GetTableRecordLength(index);
|
||
Slf_TABLE_FIELD *field=new Slf_TABLE_FIELD[count+1];
|
||
GetTableFieldInfo(index,field);
|
||
char *Buffer=new char[reclen+1];
|
||
memset(Buffer,0,reclen+1);
|
||
ReadTable(index,Rec,Buffer);
|
||
int i=0,len=0;
|
||
for(i=0;i<count;i++) {
|
||
if(stricmp(FieldName,field[i].Name)==0||stricmp(FieldName,field[i].HZName)==0) {
|
||
if(field[i].RepCode!=6) {
|
||
GetData(field[i].RepCode,&Buffer[len],&yy);
|
||
sprintf(buf,"%f",yy);
|
||
}
|
||
else {
|
||
strncpy(buf,&Buffer[len],field[i].Length);
|
||
buf[field[i].Length]='\0';
|
||
}
|
||
int ty=field[i].RepCode;
|
||
if(field[i].Reserved&&!IsChange) {
|
||
ty=sizeof(RepSize)+1;
|
||
if(field[i].Reserved>0&&field[i].Reserved<=m_MenuNumber)
|
||
{
|
||
int reclen=GetTableRecordLength(index);
|
||
GetReservedValue(yy,field[i].Reserved,Buffer,buf,reclen,islink);
|
||
}
|
||
else sprintf(buf,"%f",yy);
|
||
}
|
||
delete []Buffer;
|
||
delete []field;
|
||
return ty;
|
||
}
|
||
len+=field[i].Length;
|
||
}
|
||
delete []Buffer;
|
||
delete []field;
|
||
return 0;
|
||
}
|
||
int CLogIO::SetTableFieldData(int index,char *FieldName,char *buf,int Rec)
|
||
{
|
||
int count=GetTableFieldCount(index);
|
||
int reclen=GetTableRecordLength(index);
|
||
Slf_TABLE_FIELD *field=new Slf_TABLE_FIELD[count+1];
|
||
GetTableFieldInfo(index,field);
|
||
char *Buffer=new char[reclen+1];
|
||
memset(Buffer,0,reclen+1);
|
||
ReadTable(index,Rec,Buffer);
|
||
int i=0,len=0;
|
||
for(i=0;i<count;i++) {
|
||
if(stricmp(FieldName,field[i].Name)==0||stricmp(FieldName,field[i].HZName)==0) {
|
||
if(field[i].RepCode!=6) {
|
||
SetData(field[i].RepCode,&Buffer[len],(float *)buf);
|
||
}
|
||
else {
|
||
strncpy(&Buffer[len],buf,field[i].Length);
|
||
// buf[field[i].Length]='\0';
|
||
}
|
||
WriteTable(index,Rec,Buffer);
|
||
int ty=field[i].RepCode;
|
||
if(field[i].Reserved) {
|
||
ty=sizeof(RepSize)+1;
|
||
}
|
||
delete []Buffer;
|
||
delete []field;
|
||
return ty;
|
||
}
|
||
len+=field[i].Length;
|
||
}
|
||
delete []Buffer;
|
||
delete []field;
|
||
return 0;
|
||
}
|
||
|
||
int CLogIO::GetTableFieldData(int index,char *FieldName,char *OutFormat,char *buf,int Rec)
|
||
{
|
||
int count=GetTableFieldCount(index);
|
||
int reclen=GetTableRecordLength(index);
|
||
Slf_TABLE_FIELD *field=new Slf_TABLE_FIELD[count+1];
|
||
GetTableFieldInfo(index,field);
|
||
char *Buffer=new char[reclen+1];
|
||
memset(Buffer,0,reclen+1);
|
||
ReadTable(index,Rec,Buffer);
|
||
int i=0,len=0;
|
||
for(i=0;i<count;i++) {
|
||
if(stricmp(FieldName,field[i].Name)==0||stricmp(FieldName,field[i].HZName)==0) {
|
||
GetData(field[i].RepCode,&Buffer[len],OutFormat,buf);
|
||
int ty=field[i].RepCode;
|
||
if(field[i].Reserved) {
|
||
ty=sizeof(RepSize)+1;
|
||
}
|
||
delete []Buffer;
|
||
delete []field;
|
||
return ty;
|
||
}
|
||
len+=field[i].Length;
|
||
}
|
||
delete []Buffer;
|
||
delete []field;
|
||
return 0;
|
||
}
|
||
int CLogIO::GetTableFieldNo(char *TableName,char *FieldName)
|
||
{
|
||
int index=FindObjectIndex(TableName);
|
||
int Flag=0;
|
||
if(index<0) return -1;
|
||
if(!Slf_Info_Head[index]) {
|
||
Flag=1;
|
||
index=OpenTable(TableName);
|
||
};
|
||
int re=GetTableFieldNo(index,FieldName);
|
||
if(Flag) CloseTable(index);
|
||
return re;
|
||
}
|
||
int CLogIO::GetTableFieldNo(int index,const char *FieldName)
|
||
{
|
||
int count=GetTableFieldCount(index);
|
||
Slf_TABLE_FIELD *field=new Slf_TABLE_FIELD[count+1];
|
||
GetTableFieldInfo(index,field);
|
||
int i=0,len=0;
|
||
for(i=0;i<count;i++) {
|
||
if(stricmp(FieldName,field[i].Name)==0||stricmp(FieldName,field[i].HZName)==0) {
|
||
delete []field;
|
||
return i;
|
||
}
|
||
}
|
||
delete []field;
|
||
return -1;
|
||
}
|
||
DWORD CLogIO ::ReadWaveToFloatBuf(int index, float depth, DWORD count, float* buffer)
|
||
{
|
||
Slf_WAVE m_Wave;
|
||
GetWaveInfo(index,&m_Wave);
|
||
MyDataTypeEnum vVdl;
|
||
vVdl.vchar=new char[count*m_Wave.SamplePoint*m_Wave.ArrayNum*m_Wave.CodeLen];
|
||
DWORD len=ReadWave(index, depth, count, (void*)vVdl.vchar);
|
||
if(m_Wave.RepCode==4)memmove(buffer,vVdl.vfloat,count*m_Wave.SamplePoint*m_Wave.ArrayNum*sizeof(float));
|
||
else
|
||
{
|
||
for(DWORD i=0;i<count*m_Wave.SamplePoint*m_Wave.ArrayNum;i++)
|
||
{
|
||
switch(m_Wave.RepCode)
|
||
{
|
||
case 1:
|
||
buffer[i]=vVdl.vint[i];
|
||
break;
|
||
case 2:
|
||
buffer[i]=vVdl.vshort[i];
|
||
break;
|
||
case 3:
|
||
buffer[i]=vVdl.vlong[i];
|
||
break;
|
||
case 4:
|
||
buffer[i]=vVdl.vfloat[i];
|
||
break;
|
||
case 5:
|
||
buffer[i]=vVdl.vdouble[i];
|
||
break;
|
||
case 6:
|
||
buffer[i]=vVdl.vchar[i];
|
||
break;
|
||
case 7:
|
||
buffer[i]=vVdl.vchar[i];
|
||
break;
|
||
|
||
case 8:
|
||
buffer[i]=vVdl.vuchar[i];
|
||
break;
|
||
|
||
case 9:
|
||
buffer[i]=vVdl.vushort[i];
|
||
break;
|
||
|
||
case 10:
|
||
buffer[i]=vVdl.vuint[i];
|
||
break;
|
||
|
||
case 11:
|
||
buffer[i]=vVdl.vuint[i];
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
delete vVdl.vchar;
|
||
return len;
|
||
}
|
||
DWORD CLogIO ::WriteWaveFromFloatBuf(int index, float depth, DWORD count, float* buffer)
|
||
{
|
||
Slf_WAVE m_Wave;
|
||
GetWaveInfo(index,&m_Wave);
|
||
MyDataTypeEnum vVdl;
|
||
vVdl.vchar=new char[count*m_Wave.TimeSamples*m_Wave.CodeLen];
|
||
WriteBuf((char *)buffer,REPR_FLOAT,sizeof(float),vVdl,m_Wave.RepCode,count,m_Wave.TimeSamples);
|
||
DWORD len=WriteWave(index, depth, count, vVdl.vchar);
|
||
delete vVdl.vchar;
|
||
return len;
|
||
}
|
||
void CLogIO ::WriteBuf(char *buffer,int RepCode1,int CodeLen,MyDataTypeEnum &vVdl,int RepCode,DWORD count,int TimeSamples)
|
||
{
|
||
float yy=0;
|
||
for(DWORD i=0;i<count*TimeSamples;i++)
|
||
{
|
||
switch(RepCode)
|
||
{
|
||
case 1:
|
||
vVdl.vint[i]=GetData(RepCode1,&buffer[i*CodeLen],&yy);
|
||
break;
|
||
case 2:
|
||
vVdl.vshort[i]=GetData(RepCode1,&buffer[i*CodeLen],&yy);
|
||
break;
|
||
case 3:
|
||
vVdl.vlong[i]=GetData(RepCode1,&buffer[i*CodeLen],&yy);
|
||
break;
|
||
case 4:
|
||
vVdl.vfloat[i]=GetData(RepCode1,&buffer[i*CodeLen],&yy);
|
||
break;
|
||
case 5:
|
||
vVdl.vdouble[i]=GetData(RepCode1,&buffer[i*CodeLen],&yy);
|
||
break;
|
||
case 6:
|
||
vVdl.vchar[i]=GetData(RepCode1,&buffer[i*CodeLen],&yy);
|
||
break;
|
||
case 7:
|
||
vVdl.vchar[i]=GetData(RepCode1,&buffer[i*CodeLen],&yy);
|
||
break;
|
||
case 8:
|
||
vVdl.vuchar[i]=GetData(RepCode1,&buffer[i*CodeLen],&yy);
|
||
break;
|
||
case 9:
|
||
vVdl.vushort[i]=GetData(RepCode1,&buffer[i*CodeLen],&yy);
|
||
break;
|
||
case 10:
|
||
vVdl.vuint[i]=GetData(RepCode1,&buffer[i*CodeLen],&yy);
|
||
break;
|
||
case 11:
|
||
vVdl.vuint[i]=GetData(RepCode1,&buffer[i*CodeLen],&yy);
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
|
||
int CLogIO :: OpenTDT(const char* name)
|
||
{
|
||
if(IsWis) {
|
||
return OpenWisTDT(name);
|
||
}
|
||
else return OpenSlfTDT(name);
|
||
}
|
||
int CLogIO :: OpenTDT(Slf_TDT* pInfo)
|
||
{
|
||
if(IsWis) {
|
||
return OpenWisTDT(pInfo);
|
||
}
|
||
else return OpenSlfTDT(pInfo);
|
||
}
|
||
int CLogIO :: CreateTDT(Slf_TDT* pInfo,bool bFailExist)
|
||
{
|
||
if(IsWis) {
|
||
return CreateWisTDT(pInfo,bFailExist);
|
||
}
|
||
else return CreateSlfTDT(pInfo,bFailExist);
|
||
}
|
||
|
||
int CLogIO ::OpenWisTDT(const char* name)
|
||
{
|
||
int index= OpenWisChannel(name,TDT_OBJECT);
|
||
if(index>-1) {
|
||
if(!Slf_Info[index]) Slf_Info[index]=new char [sizeof(Slf_TDT)];
|
||
m_Tdt=(Slf_TDT *)Slf_Info[index];
|
||
GetTDTInfo(index,m_Tdt);
|
||
return index;
|
||
}
|
||
else return -1;
|
||
}
|
||
int CLogIO ::OpenWisTDT(Slf_TDT* pInfo)
|
||
{
|
||
int index=OpenWisTDT(pInfo->Name);
|
||
if(index<0) return CreateWisTDT(pInfo);
|
||
return index;
|
||
}
|
||
int CLogIO ::CreateWisTDT(Slf_TDT* pInfo,bool bFailExist)
|
||
{
|
||
memmove(cpInfo.AliasName,pInfo->AliasName,sizeof(cpInfo.AliasName));
|
||
strcpy(cpInfo.DimInfo[0].Name,"LTime");
|
||
strcpy(cpInfo.DimInfo[1].Name,"Depth");
|
||
strcpy(cpInfo.DimInfo[2].Name,"Time");
|
||
strcpy(cpInfo.DimInfo[0].AliasName,"LTime");
|
||
strcpy(cpInfo.DimInfo[1].AliasName,"Depth");
|
||
strcpy(cpInfo.DimInfo[2].AliasName,"Time");
|
||
cpInfo.CodeLen=sizeof(float);
|
||
cpInfo.RepCode=REPR_FLOAT;
|
||
cpInfo.MaxVal =pInfo->MaxValue;
|
||
cpInfo.MinVal =pInfo->MinValue;
|
||
memmove(cpInfo.Unit,pInfo->Unit,sizeof(cpInfo.Unit));
|
||
memmove(cpInfo.AliasUnit,pInfo->AliasUnit,sizeof(cpInfo.AliasUnit));
|
||
cpInfo.NumOfDimension=3;
|
||
|
||
memmove(cpInfo.DimInfo[0].Unit,pInfo->LogTimeUnit,sizeof(cpInfo.DimInfo[0].Unit));
|
||
cpInfo.DimInfo[0].StartVal=0;
|
||
cpInfo.DimInfo[0].Samples=0;
|
||
cpInfo.DimInfo[0].RepCode=REPR_LONG;
|
||
cpInfo.DimInfo[0].Delta =0;
|
||
cpInfo.DimInfo[0].MaxSamples=pInfo->TotalLogNumber;
|
||
cpInfo.DimInfo[0].Size=pInfo->MaxLogSamples*sizeof(TDT_DATA)+sizeof(float);
|
||
|
||
cpInfo.DimInfo[1].RepCode=REPR_FLOAT;
|
||
cpInfo.DimInfo[1].Delta =0;
|
||
cpInfo.DimInfo[1].StartVal=0;
|
||
cpInfo.DimInfo[1].Samples=0;
|
||
cpInfo.DimInfo[1].MaxSamples=pInfo->MaxLogSamples;
|
||
cpInfo.DimInfo[1].Size=sizeof(float);
|
||
memmove(cpInfo.DimInfo[1].Unit,pInfo->DepthUnit,sizeof(cpInfo.DimInfo[1].Unit));
|
||
|
||
cpInfo.DimInfo[2].RepCode=REPR_FLOAT;
|
||
cpInfo.DimInfo[2].Delta =0;
|
||
cpInfo.DimInfo[2].StartVal=0;
|
||
cpInfo.DimInfo[2].Samples=1;
|
||
cpInfo.DimInfo[2].MaxSamples=1;
|
||
cpInfo.DimInfo[2].Size=sizeof(float);
|
||
memmove(cpInfo.DimInfo[2].Unit,pInfo->TimeUnit,sizeof(cpInfo.DimInfo[2].Unit));
|
||
|
||
int index=CreateWisChannel(TDT_OBJECT,pInfo->Name,&cpInfo,bFailExist);
|
||
if(index>-1) {
|
||
if(!Slf_Info[index]) Slf_Info[index]=new char [sizeof(Slf_TDT)];
|
||
memmove(Slf_Info[index],pInfo,sizeof(Slf_TDT));
|
||
m_Tdt=(Slf_TDT *)Slf_Info[index];
|
||
SetWisChannelPointNum(index,pInfo->TotalLogNumber);///?????
|
||
return index;
|
||
}
|
||
return -1;
|
||
}
|
||
void CLogIO ::CloseTDT(int index)
|
||
{
|
||
if ( Slf_Info[index] )
|
||
{
|
||
delete Slf_Info[index];
|
||
}
|
||
Slf_Info[index]=NULL;
|
||
CloseChannel(index);
|
||
}
|
||
bool CLogIO ::GetTDTInfo(int index,Slf_TDT* pInfo)
|
||
{
|
||
if(IsWis) return GetWisTDTInfo(index,pInfo);
|
||
return GetSlfTDTInfo(index,pInfo);
|
||
}
|
||
bool CLogIO ::GetWisTDTInfo(int index,Slf_TDT* pInfo)
|
||
{
|
||
GetChannelInfo(index,&cpInfo);
|
||
memmove(pInfo->AliasName,cpInfo.AliasName,16);
|
||
memmove(pInfo->AliasUnit,cpInfo.AliasUnit,16);
|
||
memmove(pInfo->Name,m_ObjectEntry[index].Name,16);
|
||
pInfo->MaxValue =cpInfo.MaxVal;
|
||
pInfo->MinValue =cpInfo.MinVal;
|
||
pInfo->TotalLogNumber=cpInfo.DimInfo[0].MaxSamples;
|
||
pInfo->MaxLogSamples =cpInfo.DimInfo[1].MaxSamples;
|
||
memmove(pInfo->DepthUnit,cpInfo.DimInfo[1].Unit,8);
|
||
memmove(pInfo->LogTimeUnit,cpInfo.DimInfo[0].Unit,8);
|
||
memmove(pInfo->Unit,cpInfo.Unit,8);
|
||
memmove(pInfo->TimeUnit,cpInfo.DimInfo[2].Unit,8);
|
||
return 1;
|
||
}
|
||
bool CLogIO ::SetWisTDTInfo(int index,Slf_TDT* pInfo)
|
||
{
|
||
GetChannelInfo(index,&cpInfo);
|
||
memmove(cpInfo.AliasName,pInfo->AliasName,sizeof(cpInfo.AliasName));
|
||
memmove(cpInfo.AliasUnit,pInfo->AliasUnit,sizeof(cpInfo.AliasUnit));
|
||
memmove(m_ObjectEntry[index].Name,pInfo->Name,sizeof(m_ObjectEntry[index].Name));
|
||
|
||
cpInfo.MaxVal =pInfo->MaxValue;
|
||
cpInfo.MinVal =pInfo->MinValue;
|
||
cpInfo.DimInfo[0].MaxSamples=pInfo->TotalLogNumber;
|
||
cpInfo.DimInfo[1].MaxSamples =pInfo->MaxLogSamples;
|
||
memmove(cpInfo.DimInfo[1].Unit,pInfo->DepthUnit,sizeof(cpInfo.DimInfo[1].Unit));
|
||
memmove(cpInfo.DimInfo[0].Unit,pInfo->LogTimeUnit,sizeof(cpInfo.DimInfo[0].Unit));
|
||
memmove(cpInfo.Unit,pInfo->Unit,sizeof(cpInfo.Unit));
|
||
memmove(cpInfo.DimInfo[2].Unit,pInfo->TimeUnit,sizeof(cpInfo.DimInfo[2].Unit));
|
||
SetChannelInfo(index,&cpInfo);
|
||
return 1;
|
||
}
|
||
DWORD CLogIO ::GetWisTDTAllLogTime(int index,unsigned int* pLogTime,unsigned int *length)
|
||
{
|
||
DWORD point;
|
||
int nPointNo;
|
||
int no;
|
||
Slf_TDT info;
|
||
GetTDTInfo(index,&info);
|
||
point=m_ObjectEntry[index].Position+m_Head.BlockLen;
|
||
mFile->seek(point);
|
||
mFile->read((char *)&no,sizeof(int));
|
||
point+=sizeof(int);
|
||
for(nPointNo=1;nPointNo<=no;nPointNo++) {
|
||
mFile->seek(point);
|
||
mFile->read((char *)&pLogTime[nPointNo-1],sizeof(int));
|
||
if(length){
|
||
mFile->read((char *)&length[nPointNo-1],sizeof(int));
|
||
}
|
||
point+=info.MaxLogSamples*sizeof(TDT_DATA)+2*sizeof(int);
|
||
}
|
||
return no;
|
||
}
|
||
DWORD CLogIO ::ReadWisTDT(int index, int nPointNo, unsigned int* pLogTime, TDT_DATA* buffer)
|
||
{
|
||
DWORD samples=nPointNo;
|
||
DWORD point;
|
||
int PointNum;
|
||
int no;
|
||
Slf_TDT info;
|
||
GetTDTInfo(index,&info);
|
||
if(nPointNo<1) nPointNo=1;
|
||
point=m_ObjectEntry[index].Position+m_Head.BlockLen;
|
||
mFile->seek(point);
|
||
mFile->read((char *)&no,sizeof(int));
|
||
if(nPointNo>no) return 0;
|
||
point+=sizeof(int)+(nPointNo-1)*(info.MaxLogSamples*sizeof(TDT_DATA)+2*sizeof(int));
|
||
mFile->seek(point);
|
||
mFile->read((char *)pLogTime ,sizeof(int));
|
||
mFile->read((char *)&PointNum,sizeof(int));
|
||
mFile->read((char *)(buffer),sizeof(TDT_DATA)*PointNum);
|
||
return PointNum;//0;
|
||
}
|
||
DWORD CLogIO ::ReadWisTDT(int index, float Depth, unsigned int* pLogTime, TDT_DATA* buffer)
|
||
{
|
||
DWORD point;
|
||
int PointNum;
|
||
int no;
|
||
Slf_TDT info;
|
||
GetTDTInfo(index,&info);
|
||
point=m_ObjectEntry[index].Position+m_Head.BlockLen;
|
||
mFile->seek(point);
|
||
mFile->read((char *)&no,sizeof(int));
|
||
point+=sizeof(int);
|
||
int i;
|
||
for(i=0;i<no;i++) {
|
||
mFile->read((char *)pLogTime ,sizeof(int));
|
||
mFile->read((char *)&PointNum,sizeof(int));
|
||
mFile->read((char *)(buffer),sizeof(TDT_DATA)*PointNum);
|
||
if(buffer[0].Depth==Depth) break;
|
||
point+=info.MaxLogSamples*sizeof(TDT_DATA)+2*sizeof(int);
|
||
}
|
||
if(i>=no) return 0;
|
||
return PointNum;//0;
|
||
}
|
||
DWORD CLogIO ::ReadWisTDT(int index, float Depth, unsigned int* pLogTime, TDT_DATA* buffer,int *n)
|
||
{
|
||
DWORD point;
|
||
int PointNum;
|
||
int no;
|
||
Slf_TDT info;
|
||
GetTDTInfo(index,&info);
|
||
point=m_ObjectEntry[index].Position+m_Head.BlockLen;
|
||
mFile->seek(point);
|
||
mFile->read((char *)&no,sizeof(int));
|
||
point+=sizeof(int);
|
||
int i;
|
||
for(i=0;i<no;i++) {
|
||
mFile->read((char *)pLogTime ,sizeof(int));
|
||
mFile->read((char *)&PointNum,sizeof(int));
|
||
mFile->read((char *)(buffer),sizeof(TDT_DATA)*PointNum);
|
||
if(buffer[0].Depth==Depth) break;
|
||
point+=info.MaxLogSamples*sizeof(TDT_DATA)+2*sizeof(int);
|
||
}
|
||
*n=i;
|
||
if(i>=no) return 0;
|
||
return PointNum;//0;
|
||
}
|
||
DWORD CLogIO ::WriteWisTDT(int index, int nPointNo, unsigned int LogTime, TDT_DATA* buffer, DWORD count)
|
||
{
|
||
DWORD point;
|
||
Slf_TDT info;
|
||
GetTDTInfo(index,&info);
|
||
if(count>info.MaxLogSamples) {
|
||
return AddTDT(index,0,buffer,count);
|
||
}
|
||
if(nPointNo<1) nPointNo=1;
|
||
point=m_ObjectEntry[index].Position+m_Head.BlockLen;
|
||
mFile->seek(point);
|
||
long aa=mFile->pos();
|
||
int no=0;
|
||
int t;
|
||
int l,i;
|
||
point+=sizeof(int);
|
||
mFile->read((char *)&no,sizeof(int));
|
||
if(no>=nPointNo) {
|
||
for( i=0;i<no;i++) {
|
||
mFile->seek(point);
|
||
mFile->read((char *)&t,sizeof(int));
|
||
mFile->read((char *)&l,sizeof(int));
|
||
if(LogTime==t||t==0) {
|
||
mFile->seek(point);
|
||
mFile->write(reinterpret_cast<char*>(&LogTime),sizeof(int));
|
||
mFile->write(reinterpret_cast<char*>(&count),sizeof(int));
|
||
mFile->write(reinterpret_cast<char*>(buffer),sizeof(TDT_DATA)*count);
|
||
mFile->flush();
|
||
break;
|
||
}
|
||
point+=sizeof(int)+info.MaxLogSamples*sizeof(TDT_DATA)+sizeof(int);
|
||
}
|
||
if(i<no) return sizeof(TDT_DATA)*count;
|
||
}
|
||
return AddWisTDT(index,LogTime,buffer,count);
|
||
}
|
||
DWORD CLogIO ::AddWisTDT(int index, unsigned int LogTime, TDT_DATA* buffer, DWORD count)
|
||
{
|
||
Slf_CHANNEL info;
|
||
int k;
|
||
GetChannelInfo(index,&info);
|
||
DWORD nPointNo=info.DimInfo[0].MaxSamples;
|
||
DWORD point;
|
||
if(nPointNo<1) nPointNo=1;
|
||
if(info.DimInfo[0].MaxSamples<nPointNo) {
|
||
ExpandChannel(index,0,nPointNo,nPointNo);
|
||
info.DimInfo[0].MaxSamples=nPointNo;
|
||
}
|
||
unsigned int pLogTime[1000];
|
||
unsigned int len[1000];
|
||
int ls=GetTDTAllLogTime(index,pLogTime,len);
|
||
DWORD length=(ls+1)*count*sizeof(TDT_DATA)+2*sizeof(int)+sizeof(int);
|
||
if(length>info.DimInfo[0].MaxSamples*info.DimInfo[0].Size+sizeof(double)) {
|
||
DWORD BlockNum=mod(length-m_ObjectEntry[index].BlockNum*m_Head.BlockLen,m_Head.BlockLen);
|
||
ExpandObject(index,BlockNum);
|
||
}
|
||
if(info.DimInfo[1].MaxSamples<count) {
|
||
char *buf=(char *)malloc(ls*sizeof(TDT_DATA)*info.DimInfo[1].MaxSamples);
|
||
for(k=0;k<ls;k++) {
|
||
ReadTDT(index,k+1,&pLogTime[k], (TDT_DATA *)&buf[k*sizeof(TDT_DATA)*info.DimInfo[1].MaxSamples]);
|
||
}
|
||
for(k=0;k<ls;k++) {
|
||
point=m_ObjectEntry[index].Position+m_Head.BlockLen+k*(count*sizeof(TDT_DATA)+2*sizeof(int))+sizeof(int);
|
||
mFile->seek(point);
|
||
mFile->write(reinterpret_cast<char*>(&pLogTime[k]),sizeof(unsigned int));
|
||
mFile->write(reinterpret_cast<char*>(&len[k]),sizeof(unsigned int));
|
||
mFile->write(reinterpret_cast<char*>(&buf[k*sizeof(TDT_DATA)*info.DimInfo[1].MaxSamples]),info.DimInfo[1].MaxSamples*sizeof(TDT_DATA));
|
||
mFile->flush();
|
||
}
|
||
free(buf);
|
||
info.DimInfo[0].Size=count*sizeof(TDT_DATA)+sizeof(unsigned int);
|
||
info.DimInfo[1].MaxSamples=count;
|
||
WriteChannelInfo(index,&info);
|
||
}
|
||
ReadChannelInfo(index,&info);
|
||
point=m_ObjectEntry[index].Position+m_Head.BlockLen;
|
||
mFile->seek(point);
|
||
int no;
|
||
unsigned int t;
|
||
int l,i;
|
||
mFile->read((char *)&no,sizeof(int));
|
||
point+=sizeof(int);
|
||
if(no>nPointNo) {
|
||
for(i=0;i<no;i++) {
|
||
mFile->seek(point);
|
||
mFile->read((char *)&t,sizeof(int));
|
||
mFile->read((char *)&l,sizeof(int));
|
||
if(LogTime==t||t==0) {
|
||
mFile->seek(point);
|
||
mFile->write(reinterpret_cast<char*>(&LogTime),sizeof(int));
|
||
mFile->write(reinterpret_cast<char*>(&count),sizeof(int));
|
||
mFile->write(reinterpret_cast<char*>(buffer),sizeof(TDT_DATA)*count);
|
||
mFile->flush();
|
||
break;
|
||
}
|
||
point+=info.DimInfo[0].Size+sizeof(int);
|
||
}
|
||
if(i<no) return sizeof(TDT_DATA)*count;
|
||
}
|
||
point=m_ObjectEntry[index].Position+m_Head.BlockLen;
|
||
mFile->seek(point);
|
||
no++;
|
||
mFile->write(reinterpret_cast<char*>(&no),sizeof(int));
|
||
mFile->write(reinterpret_cast<char*>(&LogTime),sizeof(int));
|
||
mFile->write(reinterpret_cast<char*>(&count),sizeof(int));
|
||
int len1=sizeof(TDT_DATA)*count;
|
||
mFile->write(reinterpret_cast<char*>(&buffer[0]),len1);
|
||
mFile->flush();
|
||
return sizeof(TDT_DATA)*count;
|
||
}
|
||
int CLogIO ::OpenWisFMT(const char* name)
|
||
{
|
||
int index =OpenChannel(name,FMT_OBJECT);
|
||
if(index>-1) {
|
||
if(!Slf_Info[index]) Slf_Info[index]=new char [sizeof(Slf_FMT)];
|
||
m_Fmt=(Slf_FMT *)Slf_Info[index];
|
||
GetFMTInfo(index,m_Fmt);
|
||
return index;
|
||
}
|
||
else return -1;
|
||
}
|
||
int CLogIO ::OpenWisFMT(Slf_FMT* pInfo)
|
||
{
|
||
int index=OpenWisFMT(pInfo->Name);
|
||
if(index<0) return CreateWisFMT(pInfo);
|
||
return index;
|
||
}
|
||
int CLogIO ::CreateWisFMT(Slf_FMT* pInfo,bool bFailExist)
|
||
{
|
||
memmove(cpInfo.AliasName,pInfo->AliasName,sizeof(cpInfo.AliasName));
|
||
strcpy(cpInfo.DimInfo[0].Name,"Depth");
|
||
cpInfo.CodeLen=sizeof(float);
|
||
cpInfo.MaxVal =pInfo->MaxValue;
|
||
cpInfo.MinVal =pInfo->MinValue;
|
||
memmove(cpInfo.Unit,pInfo->Unit,sizeof(cpInfo.Unit));
|
||
memmove(cpInfo.AliasUnit,pInfo->AliasUnit,sizeof(cpInfo.AliasUnit));
|
||
cpInfo.NumOfDimension=2;
|
||
memmove(cpInfo.DimInfo[0].Unit,pInfo->DepthUnit,sizeof(cpInfo.DimInfo[0].Unit));
|
||
cpInfo.DimInfo[0].StartVal=0;
|
||
cpInfo.DimInfo[0].Samples=pInfo->TotalPointNum;
|
||
cpInfo.DimInfo[0].RepCode=REPR_FLOAT;
|
||
cpInfo.DimInfo[0].Delta =0;
|
||
cpInfo.DimInfo[0].MaxSamples=pInfo->MaxPointSamples;
|
||
cpInfo.DimInfo[0].Size=(pInfo->TimeSamples+1)*sizeof(float);
|
||
|
||
cpInfo.DimInfo[1].RepCode=REPR_FLOAT;
|
||
cpInfo.DimInfo[1].Delta =pInfo->TimeLevel;
|
||
cpInfo.DimInfo[1].StartVal=pInfo->StartTime;
|
||
cpInfo.DimInfo[1].Samples=0;
|
||
cpInfo.DimInfo[1].MaxSamples=pInfo->TimeSamples;
|
||
cpInfo.DimInfo[1].Size=sizeof(float);
|
||
cpInfo.DimInfo[1].RepCode=REPR_FLOAT;
|
||
memmove(cpInfo.DimInfo[1].Unit,pInfo->TimeUnit,sizeof(cpInfo.DimInfo[1].Unit));
|
||
int index=CreateChannel(FMT_OBJECT,pInfo->Name,&cpInfo,bFailExist);
|
||
if(index>-1) {
|
||
if(!Slf_Info[index]) Slf_Info[index]=new char [sizeof(Slf_FMT)];
|
||
memmove(Slf_Info[index],pInfo,sizeof(Slf_FMT));
|
||
return index;
|
||
}
|
||
return -1;
|
||
}
|
||
|
||
void CLogIO ::CloseFMT(int index)
|
||
{
|
||
if(Slf_Info[index])
|
||
{
|
||
delete Slf_Info[index];
|
||
}
|
||
Slf_Info[index]=NULL;
|
||
CloseChannel(index);
|
||
}
|
||
bool CLogIO ::GetFMTInfo(int index,Slf_FMT* pInfo)
|
||
{
|
||
if(IsWis) return GetWisFMTInfo(index,pInfo);
|
||
else return GetSlfFMTInfo(index,pInfo);
|
||
}
|
||
bool CLogIO ::GetWisFMTInfo(int index,Slf_FMT* pInfo)
|
||
{
|
||
GetChannelInfo(index,&cpInfo);
|
||
char name[200];
|
||
GetObjectName(index,name);
|
||
memmove(pInfo->AliasName,cpInfo.AliasName,sizeof(pInfo->AliasName));
|
||
memmove(pInfo->Name,name,sizeof(pInfo->Name));
|
||
pInfo->MaxValue =cpInfo.MaxVal;
|
||
pInfo->MinValue =cpInfo.MinVal;
|
||
memmove(pInfo->Unit,cpInfo.Unit,sizeof(pInfo->Unit));
|
||
memmove(pInfo->AliasUnit,cpInfo.AliasUnit,sizeof(pInfo->AliasUnit));
|
||
memmove(pInfo->DepthUnit,cpInfo.DimInfo[0].Unit,sizeof(pInfo->DepthUnit));
|
||
pInfo->MaxPointSamples=cpInfo.DimInfo[0].MaxSamples;
|
||
pInfo->TimeLevel=cpInfo.DimInfo[1].Delta;
|
||
pInfo->StartTime=cpInfo.DimInfo[1].StartVal;
|
||
pInfo->TimeSamples=cpInfo.DimInfo[1].MaxSamples;
|
||
memmove(pInfo->TimeUnit,cpInfo.DimInfo[1].Unit,sizeof(pInfo->TimeUnit));
|
||
pInfo->TotalPointNum=GetChannelPointNum(index);
|
||
return TRUE;
|
||
}
|
||
bool CLogIO ::SetWisFMTInfo(int index,Slf_FMT* pInfo)
|
||
{
|
||
GetChannelInfo(index,&cpInfo);
|
||
char name[200];
|
||
GetObjectName(index,name);
|
||
Slf_OBJECT_ENTRY mEntry;
|
||
GetWisObjectEntry(index,&mEntry);
|
||
memmove(cpInfo.AliasName,pInfo->AliasName,sizeof(cpInfo.AliasName));
|
||
memmove(mEntry.Name,pInfo->Name,sizeof(mEntry.Name));
|
||
WriteWisObjectEntry(index,&mEntry);
|
||
// cpInfo.MaxVal =pInfo->MaxValue;
|
||
// cpInfo.MinVal =pInfo->MinValue;
|
||
memmove(cpInfo.Unit,pInfo->Unit,sizeof(cpInfo.Unit));
|
||
memmove(cpInfo.AliasUnit,pInfo->AliasUnit,sizeof(cpInfo.AliasUnit));
|
||
memmove(cpInfo.DimInfo[0].Unit,pInfo->DepthUnit,sizeof(cpInfo.DimInfo[0].Unit));
|
||
cpInfo.DimInfo[0].MaxSamples=pInfo->MaxPointSamples;
|
||
cpInfo.DimInfo[1].Delta=pInfo->TimeLevel;
|
||
cpInfo.DimInfo[1].StartVal=pInfo->StartTime;
|
||
cpInfo.DimInfo[1].MaxSamples=pInfo->TimeSamples;
|
||
memmove(cpInfo.DimInfo[1].Unit,pInfo->TimeUnit,sizeof(cpInfo.DimInfo[1].Unit));
|
||
SetChannelInfo(index,&cpInfo);
|
||
return TRUE;
|
||
}
|
||
bool CLogIO ::GetSlfFMTInfo(int index,Slf_FMT* pInfo)
|
||
{
|
||
if(index<0) return 0;
|
||
int FieldNum=GetSlfTableFieldCount(index);
|
||
int rec=GetSlfTableRecordCount(index);
|
||
Slf_TABLE_ENTRY obj;
|
||
GetSlfObjectEntry(index,&obj);
|
||
Slf_OBJECT_FIELD *pf=new Slf_OBJECT_FIELD[FieldNum];
|
||
memset(pf,0,sizeof(Slf_OBJECT_FIELD)*FieldNum);
|
||
GetSlfTableFieldInfo(index,pf);
|
||
|
||
memmove(pInfo->AliasName,obj.HZName,sizeof(pInfo->AliasName));
|
||
memmove(pInfo->Name,obj.Name,sizeof(pInfo->Name));
|
||
pInfo->MaxValue=pf[1].Vmax;
|
||
pInfo->MinValue=pf[1].Vmin;
|
||
memmove(pInfo->Unit,pf[1].Unit,sizeof(pInfo->Unit));
|
||
memmove(pInfo->AliasUnit,pf[1].HZUnit,sizeof(pInfo->AliasUnit));
|
||
memmove(pInfo->DepthUnit,pf[0].Unit,sizeof(pInfo->DepthUnit));
|
||
memmove(pInfo->TimeUnit,pf[1].Unit,sizeof(pInfo->TimeUnit));
|
||
|
||
pInfo->MaxPointSamples=rec;
|
||
pInfo->TimeLevel=pf[3].Rlev;
|
||
pInfo->StartTime=pf[3].Start;
|
||
pInfo->TimeSamples=pf[3].SamplePoint;
|
||
pInfo->TotalPointNum=rec;
|
||
delete []pf;
|
||
return TRUE;
|
||
}
|
||
bool CLogIO ::SetSlfFMTInfo(int index,Slf_FMT* pInfo)
|
||
{
|
||
if(index<0) return 0;
|
||
int FieldNum=GetSlfTableFieldCount(index);
|
||
int rec=GetSlfTableRecordCount(index);
|
||
Slf_TABLE_ENTRY obj;
|
||
GetSlfObjectEntry(index,&obj);
|
||
Slf_OBJECT_FIELD *pf=new Slf_OBJECT_FIELD[FieldNum];
|
||
memset(pf,0,sizeof(Slf_OBJECT_FIELD)*FieldNum);
|
||
GetSlfTableFieldInfo(index,pf);
|
||
memmove(obj.HZName,pInfo->AliasName,sizeof(obj.HZName));
|
||
memmove(obj.Name,pInfo->Name,sizeof(obj.Name));
|
||
WriteSlfObjectEntry(index,&obj);
|
||
pf[1].Vmax=pInfo->MaxValue;
|
||
pf[1].Vmin=pInfo->MinValue;
|
||
memmove(pf[1].Unit,pInfo->Unit,sizeof(pf[1].Unit));
|
||
memmove(pf[1].HZUnit,pInfo->AliasUnit,sizeof(pf[1].HZUnit));
|
||
memmove(pf[0].Unit,pInfo->DepthUnit,sizeof(pf[0].Unit));
|
||
memmove(pf[1].Unit,pInfo->TimeUnit,sizeof(pf[1].Unit));
|
||
|
||
pf[2].SamplePoint=pInfo->TimeSamples;
|
||
pf[3].Rlev=pInfo->TimeLevel;
|
||
pf[3].Start=pInfo->StartTime;
|
||
pf[3].SamplePoint=pInfo->TimeSamples;
|
||
SetSlfTableFieldInfo(index,pf,0);
|
||
delete []pf;
|
||
return TRUE;
|
||
}
|
||
DWORD CLogIO ::GetWisFMTAllDepth(int index,float* pDepth)
|
||
{
|
||
DWORD point;
|
||
int PointNum;//,num=0;
|
||
point=m_ObjectEntry[index].Position+m_Head.BlockLen+sizeof(DWORD);
|
||
m_Fmt=(Slf_FMT *)Slf_Info[index];
|
||
for(DWORD i=0;i<m_Fmt->TotalPointNum;i++) {
|
||
mFile->seek(point);
|
||
mFile->read((char *)&pDepth[i],sizeof(int));
|
||
point+=ComputerChannelLength(index);
|
||
}
|
||
return m_Fmt->TotalPointNum;
|
||
}
|
||
bool CLogIO ::SetWisFMTDepth(int index,int Count,float* pDepth1,float* pDepth2)
|
||
{
|
||
DWORD point;
|
||
int PointNum,num=0;
|
||
float Depth;
|
||
point=m_ObjectEntry[index].Position+m_Head.BlockLen+sizeof(DWORD);
|
||
m_Fmt=(Slf_FMT *)Slf_Info[index];
|
||
for(DWORD i=0;i<m_Fmt->TotalPointNum;i++) {
|
||
mFile->seek(point);
|
||
mFile->read((char *)&Depth,sizeof(int));
|
||
for(int j=0;j<Count;j++) {
|
||
if(Depth==pDepth1[j]) {
|
||
mFile->seek(point);
|
||
mFile->write(reinterpret_cast<char*>(&Depth),sizeof(int));
|
||
mFile->flush();
|
||
break;
|
||
}
|
||
}
|
||
point+=ComputerChannelLength(index);
|
||
}
|
||
return 1;
|
||
}
|
||
DWORD CLogIO ::ReadWisFMT(int index, int nPointNo, float* pDep, float* buffer)
|
||
{
|
||
DWORD len;
|
||
float *buf=new float[ComputerChannelLength(index)/sizeof(float)+4];
|
||
ReadChannel(index,(char*)buf,1,nPointNo);
|
||
*pDep=buf[0];
|
||
memmove((char *)buffer,(const char*)&buf[2],ComputerChannelLength(index)-4);
|
||
memmove((char *)&len,(char *)&buf[1],sizeof(int));
|
||
delete buf;
|
||
return len;
|
||
}
|
||
DWORD CLogIO ::WriteWisFMT(int index, int nPointNo, float dep, float* buffer, DWORD count)
|
||
{
|
||
Slf_CHANNEL *m_Channel=(Slf_CHANNEL *)Slf_Info_Head[index];
|
||
m_Fmt=(Slf_FMT *)Slf_Info[index];
|
||
float *buf=new float[ComputerChannelLength(index)/sizeof(float)];
|
||
buf[0]=dep;
|
||
for(DWORD i=count;i<m_Fmt->TimeSamples+2;i++) buf[i]=(float)-9999.0;
|
||
memmove((char *)&buf[1],(char *)&count,sizeof(DWORD));
|
||
for(int i=0;i<count;i++)
|
||
{
|
||
memmove((char *)&buf[2+i],(const char*)&buffer[i],m_Channel->DimInfo[1].Size);
|
||
}
|
||
WriteChannel(index,(char*)buf,1,nPointNo);
|
||
delete buf;
|
||
return count;
|
||
}
|
||
void CLogIO ::DeleteWisFMT(int index, int nPointNo, float dep)
|
||
{
|
||
m_Fmt=(Slf_FMT *)Slf_Info[index];
|
||
int no=nPointNo;
|
||
if(no<0) {
|
||
float *pDepth=new float[m_Fmt->TotalPointNum];
|
||
GetFMTAllDepth(index,pDepth);
|
||
for(int i=0;i<m_Fmt->TotalPointNum;i++) {
|
||
if(pDepth[i]==dep) {
|
||
no=i+1;
|
||
}
|
||
}
|
||
delete pDepth;
|
||
|
||
}
|
||
if(no<0) return;
|
||
float *buf=new float[ComputerChannelLength(index)/sizeof(float)+4];
|
||
for(int i=no;i<m_Fmt->TotalPointNum;i++) {
|
||
ReadChannel(index,(char*)buf,1,i+1);
|
||
WriteChannel(index,(char*)buf,1,i);
|
||
}
|
||
delete buf;
|
||
--m_Fmt->TotalPointNum;
|
||
if(m_Fmt->TotalPointNum<0) m_Fmt->TotalPointNum=0;
|
||
SetChannelPointNum(index,m_Fmt->TotalPointNum);
|
||
}
|
||
DWORD CLogIO ::AddWisFMT(int index, float dep, float* buffer, DWORD count)
|
||
{
|
||
m_Fmt=(Slf_FMT *)Slf_Info[index];
|
||
int nPointNo=++m_Fmt->TotalPointNum;
|
||
SetChannelPointNum(index,nPointNo);
|
||
WriteFMT(index, nPointNo,dep, buffer, count);
|
||
return 1;
|
||
}
|
||
|
||
DWORD CLogIO ::GetFMTAllDepth(int index,float* pDepth)
|
||
{
|
||
if(IsWis) {
|
||
return GetWisFMTAllDepth(index,pDepth);
|
||
}
|
||
else return GetSlfFMTAllDepth(index,pDepth);
|
||
}
|
||
DWORD CLogIO ::ReadFMT(int index, int nPointNo, float* pDep, float* buffer)
|
||
{
|
||
if(IsWis) {
|
||
return ReadWisFMT(index, nPointNo, pDep, buffer);
|
||
}
|
||
else return ReadSlfFMT(index, nPointNo, pDep, buffer);;
|
||
}
|
||
DWORD CLogIO ::WriteFMT(int index, int nPointNo, float dep, float* buffer, DWORD count)
|
||
{
|
||
if(IsWis) {
|
||
return WriteWisFMT(index, nPointNo, dep, buffer,count);
|
||
}
|
||
else return WriteSlfFMT(index, nPointNo, dep, buffer,count);
|
||
}
|
||
DWORD CLogIO ::AddFMT(int index, float dep, float* buffer, DWORD count)
|
||
{
|
||
if(IsWis) {
|
||
return AddWisFMT(index, dep, buffer, count);
|
||
}
|
||
else return AddSlfFMT(index, dep, buffer, count);
|
||
}
|
||
void CLogIO ::DeleteFMT(int index, int nPointNo, float dep)
|
||
{
|
||
if(IsWis) {
|
||
return DeleteWisFMT(index, nPointNo, dep);
|
||
}
|
||
else return DeleteSlfFMT(index, nPointNo, dep);;
|
||
}
|
||
DWORD CLogIO ::ReadTDT(int index, float Depth, unsigned int* pLogTime, TDT_DATA* buffer)
|
||
{
|
||
if(IsWis) {
|
||
return ReadWisTDT(index, Depth, pLogTime, buffer);
|
||
}
|
||
else return ReadSlfTDT(index, Depth, pLogTime, buffer);
|
||
}
|
||
bool CLogIO ::SetWisTDTDepth(int index,int Count,float* pDepth1,float* pDepth2)
|
||
{
|
||
return 1;
|
||
}
|
||
bool CLogIO ::SetTDTDepth(int index,int Count,float* pDepth1,float* pDepth2)
|
||
{
|
||
if(IsWis) {
|
||
return SetWisTDTDepth(index,Count,pDepth1,pDepth2);
|
||
}
|
||
else return SetSlfTDTDepth(index,Count,pDepth1,pDepth2);
|
||
}
|
||
DWORD CLogIO ::ReadTDT(int index, float Depth, unsigned int* pLogTime, TDT_DATA* buffer,int *n)
|
||
{
|
||
if(IsWis) {
|
||
return ReadWisTDT(index,Depth,pLogTime,buffer,n);
|
||
}
|
||
else return ReadSlfTDT(index,Depth,pLogTime,buffer,n);
|
||
}
|
||
DWORD CLogIO ::GetTDTAllLogTime(int index,unsigned int* pLogTime,unsigned int *l)
|
||
{
|
||
if(IsWis) {
|
||
return GetWisTDTAllLogTime(index,pLogTime,l);
|
||
}
|
||
else return GetSlfTDTAllLogTime(index,pLogTime,l);
|
||
}
|
||
DWORD CLogIO ::ReadTDT(int index, int nPointNo, unsigned int* pLogTime, TDT_DATA* buffer)
|
||
{
|
||
if(IsWis) {
|
||
return ReadWisTDT(index,nPointNo,pLogTime,buffer);
|
||
}
|
||
else return ReadSlfTDT(index,nPointNo,pLogTime,buffer);;
|
||
}
|
||
DWORD CLogIO ::WriteTDT(int index, int nPointNo, unsigned int LogTime, TDT_DATA* buffer, DWORD count)
|
||
{
|
||
if(IsWis) {
|
||
return WriteWisTDT(index,nPointNo,LogTime,buffer,count);
|
||
}
|
||
else return WriteSlfTDT(index,nPointNo,LogTime,buffer,count);
|
||
}
|
||
DWORD CLogIO ::AddTDT(int index, unsigned int LogTime, TDT_DATA* buffer, DWORD count)
|
||
{
|
||
if(IsWis) {
|
||
return AddWisTDT(index,LogTime,buffer,count);
|
||
}
|
||
else return AddSlfTDT(index,LogTime,buffer,count);
|
||
}
|
||
|
||
////////////////////////////////////////////////////////////////////////
|
||
int CLogIO ::OpenFMT(const char* name)
|
||
{
|
||
if(IsWis) return OpenWisFMT(name);
|
||
else return OpenSlfFMT(name);
|
||
}
|
||
int CLogIO ::OpenFMT(Slf_FMT* pInfo)
|
||
{
|
||
if(IsWis) return OpenWisFMT(pInfo);
|
||
else return OpenSlfFMT(pInfo);
|
||
}
|
||
int CLogIO ::OpenSlfFMT(const char* name)
|
||
{
|
||
int index=FindSlfObjectName((char *)name,FMT_OBJECT);
|
||
if(index<0)return -1;
|
||
return OpenSlfTable(name);
|
||
}
|
||
int CLogIO ::OpenSlfFMT(Slf_FMT* pInfo)
|
||
{
|
||
int index=OpenSlfTable(pInfo->Name);
|
||
if(index<0) return CreateSlfFMT(pInfo);
|
||
return index;
|
||
}
|
||
int CLogIO ::CreateSlfFMT(Slf_FMT* pInfo,bool bFailExist)
|
||
{
|
||
int FieldNum=4;
|
||
Slf_OBJECT_FIELD *pField=new Slf_OBJECT_FIELD[FieldNum];
|
||
int FieldNo=0;
|
||
//// depth
|
||
strcpy(pField[0].Name,"Depth");
|
||
strcpy(pField[0].HZName,"Depth");
|
||
pField[FieldNo].ArrayNum=1;
|
||
pField[FieldNo].CodeLength=RepSize[REPR_FLOAT];
|
||
pField[FieldNo].RepCode=REPR_FLOAT;
|
||
pField[FieldNo].Start=0;
|
||
pField[FieldNo].DefVal=0;
|
||
pField[FieldNo].Rlev=1;
|
||
pField[FieldNo].SamplePoint=1;
|
||
pField[FieldNo].Sequence=0;
|
||
memmove(pField[FieldNo].Unit,pInfo->DepthUnit,sizeof(pField[FieldNo].Unit));
|
||
strcpy(pField[FieldNo].Reserved,"");
|
||
//// point num
|
||
FieldNo++;
|
||
strcpy(pField[FieldNo].Name,"Point");
|
||
strcpy(pField[FieldNo].HZName,"Point");
|
||
pField[FieldNo].ArrayNum=1;
|
||
pField[FieldNo].CodeLength=RepSize[REPR_INT];
|
||
pField[FieldNo].RepCode=REPR_INT;
|
||
pField[FieldNo].Start=0;
|
||
pField[FieldNo].DefVal=0;
|
||
pField[FieldNo].Rlev=0;
|
||
pField[FieldNo].SamplePoint=1;
|
||
pField[FieldNo].Sequence=0;
|
||
strcpy(pField[FieldNo].Unit,"");
|
||
strcpy(pField[FieldNo].Reserved,"");
|
||
//// Pressure
|
||
FieldNo++;
|
||
strcpy(pField[FieldNo].Name,"Pressure");
|
||
strcpy(pField[FieldNo].HZName,"Pressure");
|
||
pField[FieldNo].ArrayNum=1;
|
||
pField[FieldNo].CodeLength=RepSize[REPR_FLOAT];
|
||
pField[FieldNo].RepCode=REPR_FLOAT;
|
||
pField[FieldNo].Start=0;
|
||
pField[FieldNo].DefVal=0;
|
||
pField[FieldNo].Rlev=0;
|
||
pField[FieldNo].SamplePoint=pInfo->TimeSamples;
|
||
pField[FieldNo].Sequence=0;
|
||
pField[FieldNo].Vmax=pInfo->MaxValue;
|
||
pField[FieldNo].Vmin=pInfo->MinValue;
|
||
memmove(pField[FieldNo].Unit,pInfo->Unit,sizeof(pField[FieldNo].Unit));
|
||
strcpy(pField[FieldNo].Reserved,"");
|
||
|
||
//// Time
|
||
FieldNo++;
|
||
strcpy(pField[FieldNo].Name,"Time");
|
||
strcpy(pField[FieldNo].HZName,"Time");
|
||
pField[FieldNo].ArrayNum=1;
|
||
pField[FieldNo].CodeLength=RepSize[REPR_FLOAT];
|
||
pField[FieldNo].RepCode=REPR_FLOAT;
|
||
pField[FieldNo].Start=pInfo->StartTime;
|
||
pField[FieldNo].DefVal=0;
|
||
pField[FieldNo].Rlev=pInfo->TimeLevel;
|
||
pField[FieldNo].SamplePoint=pInfo->TimeSamples;
|
||
pField[FieldNo].Sequence=1;
|
||
memmove(pField[FieldNo].Unit,pInfo->TimeUnit,sizeof(pField[FieldNo].Unit));
|
||
strcpy(pField[FieldNo].Reserved,"");
|
||
|
||
int index=CreateSlfTable(FMT_OBJECT,pInfo->Name,"Pressure",FieldNum,pField);
|
||
Slf_TABLE_ENTRY obj;
|
||
GetSlfObjectEntry(index,&obj);
|
||
memmove(obj.HZName,pField[2].Name,sizeof(obj.HZName));
|
||
memmove(obj.Unit,pField[2].Unit,sizeof(obj.Unit));
|
||
memmove(obj.HZUnit,pField[2].HZUnit,sizeof(obj.HZUnit));
|
||
WriteSlfObjectEntry(index,&obj);
|
||
|
||
if(index>-1) SetSlfTableRecordCount(index,pInfo->TotalPointNum);
|
||
delete []pField;
|
||
return index;
|
||
}
|
||
|
||
DWORD CLogIO ::GetSlfFMTAllDepth(int index,float* pDepth)
|
||
{
|
||
int count=GetSlfTableRecordCount(index);
|
||
ReadSlfTableFieldData(index,0,count,(char *)pDepth);
|
||
return count;
|
||
}
|
||
|
||
DWORD CLogIO ::ReadSlfFMT(int index, int nPointNo, float* pDep, float* buffer)
|
||
{
|
||
int count;
|
||
ReadSlfTableFieldData(index,0,nPointNo,(char *)pDep,nPointNo-1);
|
||
ReadSlfTableFieldData(index,1,nPointNo,(char *)&count,nPointNo-1);
|
||
ReadSlfTableFieldData(index,2,nPointNo,(char *)buffer,nPointNo-1,count);
|
||
return count;
|
||
}
|
||
DWORD CLogIO ::WriteSlfFMT(int index, int nPointNo, float dep, float* buffer, DWORD count)
|
||
{
|
||
WriteSlfTableFieldData(index,0,nPointNo,(char *)&dep,nPointNo-1);
|
||
WriteSlfTableFieldData(index,1,nPointNo,(char *)&count,nPointNo-1);
|
||
WriteSlfTableFieldData(index,2,nPointNo,(char *)buffer,nPointNo-1,count);
|
||
return 1;
|
||
}
|
||
DWORD CLogIO ::AddSlfFMT(int index, float dep, float* buffer, DWORD count)
|
||
{
|
||
int nPointNo=GetSlfTableRecordCount(index);
|
||
nPointNo++;
|
||
WriteSlfTableFieldData(index,0,nPointNo,(char *)&dep,nPointNo-1);
|
||
WriteSlfTableFieldData(index,1,nPointNo,(char *)&count,nPointNo-1);
|
||
WriteSlfTableFieldData(index,2,nPointNo,(char *)buffer,nPointNo-1,count);
|
||
return nPointNo;
|
||
}
|
||
void CLogIO ::DeleteSlfFMT(int index, int nPointNo, float dep)
|
||
{
|
||
DeleteSlfTableRecord(index,nPointNo,nPointNo-1);
|
||
}
|
||
|
||
/////////////////////////////////////////////////////////////
|
||
int CLogIO ::OpenSlfTDT(const char* name)
|
||
{
|
||
int index=FindSlfObjectName((char *)name,TDT_OBJECT);
|
||
if(index<0)return -1;
|
||
return OpenSlfTable(name,TDT_OBJECT);
|
||
}
|
||
int CLogIO ::OpenSlfTDT(Slf_TDT* pInfo)
|
||
{
|
||
int index=OpenTDT(pInfo->Name);
|
||
if(index<0) return CreateSlfTDT(pInfo);
|
||
return index;
|
||
}
|
||
int CLogIO ::CreateSlfTDT(Slf_TDT* pInfo,bool bFailExist)
|
||
{
|
||
int FieldNum=5;
|
||
Slf_OBJECT_FIELD *pField=new Slf_OBJECT_FIELD[FieldNum];
|
||
int FieldNo=0;
|
||
//// depth
|
||
strcpy(pField[0].Name,"Depth");
|
||
strcpy(pField[0].HZName,"深度");
|
||
pField[FieldNo].ArrayNum=1;
|
||
pField[FieldNo].CodeLength=RepSize[REPR_FLOAT];
|
||
pField[FieldNo].RepCode=REPR_FLOAT;
|
||
pField[FieldNo].Start=0;
|
||
pField[FieldNo].DefVal=0;
|
||
pField[FieldNo].Rlev=0;
|
||
pField[FieldNo].SamplePoint=1;
|
||
pField[FieldNo].Sequence=0;
|
||
memmove(pField[FieldNo].Unit,pInfo->DepthUnit,sizeof(pField[FieldNo].Unit));
|
||
strcpy(pField[FieldNo].Unit,"m");
|
||
strcpy(pField[FieldNo].HZUnit,"米");
|
||
strcpy(pField[FieldNo].Reserved,"");
|
||
//// point num
|
||
FieldNo++;
|
||
strcpy(pField[FieldNo].Name,"LogTime");
|
||
strcpy(pField[FieldNo].HZName,"测量时间");
|
||
pField[FieldNo].ArrayNum=1;
|
||
pField[FieldNo].CodeLength=RepSize[REPR_INT];
|
||
pField[FieldNo].RepCode=REPR_INT;
|
||
pField[FieldNo].Start=0;
|
||
pField[FieldNo].DefVal=0;
|
||
pField[FieldNo].Rlev=0;
|
||
pField[FieldNo].SamplePoint=1;
|
||
pField[FieldNo].Sequence=0;
|
||
memmove(pField[FieldNo].Unit,pInfo->LogTimeUnit,sizeof(pField[FieldNo].Unit));
|
||
memmove(pField[FieldNo].HZUnit,pInfo->LogTimeUnit,sizeof(pField[FieldNo].HZUnit));
|
||
strcpy(pField[FieldNo].Reserved,"");
|
||
//// point num
|
||
FieldNo++;
|
||
strcpy(pField[FieldNo].Name,"Point");
|
||
strcpy(pField[FieldNo].HZName,"数据点数");
|
||
pField[FieldNo].ArrayNum=1;
|
||
pField[FieldNo].CodeLength=RepSize[REPR_INT];
|
||
pField[FieldNo].RepCode=REPR_INT;
|
||
pField[FieldNo].Start=0;
|
||
pField[FieldNo].DefVal=0;
|
||
pField[FieldNo].Rlev=0;
|
||
pField[FieldNo].SamplePoint=1;
|
||
pField[FieldNo].Sequence=0;
|
||
strcpy(pField[FieldNo].Unit,"");
|
||
strcpy(pField[FieldNo].Reserved,"");
|
||
//// Value
|
||
FieldNo++;
|
||
//strcpy(pField[FieldNo].Name,"Value");
|
||
//strcpy(pField[FieldNo].HZName,"Value");
|
||
strcpy(pField[FieldNo].Name,pInfo->Name);
|
||
strcpy(pField[FieldNo].HZName,pInfo->AliasName);
|
||
pField[FieldNo].ArrayNum=1;
|
||
pField[FieldNo].CodeLength=RepSize[REPR_FLOAT];
|
||
pField[FieldNo].RepCode=REPR_FLOAT;
|
||
pField[FieldNo].Start=0;
|
||
pField[FieldNo].DefVal=0;
|
||
pField[FieldNo].Rlev=0;
|
||
pField[FieldNo].SamplePoint=pInfo->MaxLogSamples;
|
||
pField[FieldNo].Sequence=0;
|
||
pField[FieldNo].Vmax=pInfo->MaxValue;
|
||
pField[FieldNo].Vmin=pInfo->MinValue;
|
||
memmove(pField[FieldNo].HZUnit,pInfo->AliasUnit,sizeof(pField[FieldNo].HZUnit));
|
||
memmove(pField[FieldNo].Unit,pInfo->Unit,sizeof(pField[FieldNo].Unit));
|
||
strcpy(pField[FieldNo].Reserved,"");
|
||
|
||
//// Time
|
||
FieldNo++;
|
||
strcpy(pField[FieldNo].Name,"Time");
|
||
strcpy(pField[FieldNo].HZName,"Time");
|
||
pField[FieldNo].ArrayNum=1;
|
||
pField[FieldNo].CodeLength=RepSize[REPR_FLOAT];
|
||
pField[FieldNo].RepCode=REPR_FLOAT;
|
||
pField[FieldNo].Start=0;
|
||
pField[FieldNo].DefVal=0;
|
||
pField[FieldNo].Rlev=0;
|
||
pField[FieldNo].SamplePoint=pInfo->MaxLogSamples;
|
||
pField[FieldNo].Sequence=0;
|
||
memmove(pField[FieldNo].Unit,pInfo->TimeUnit,sizeof(pField[FieldNo].Unit));
|
||
memmove(pField[FieldNo].HZUnit,pInfo->TimeUnit,sizeof(pField[FieldNo].HZUnit));
|
||
strcpy(pField[FieldNo].Reserved,"");
|
||
|
||
//int index=CreateSlfTable(TDT_OBJECT,pInfo->Name,NULL,FieldNum,pField);
|
||
int index=CreateSlfTable(TDT_OBJECT,pInfo->Name,pInfo->AliasName,FieldNum,pField);
|
||
Slf_TABLE_ENTRY obj;
|
||
GetSlfObjectEntry(index,&obj);
|
||
//memmove(obj.HZName,pField[3].Name,sizeof(obj.HZName));
|
||
memmove(obj.HZName,pField[3].HZName,sizeof(obj.HZName));
|
||
memmove(obj.Unit,pField[3].Unit,sizeof(obj.Unit));
|
||
memmove(obj.HZUnit,pField[3].HZUnit,sizeof(obj.HZUnit));
|
||
WriteSlfObjectEntry(index,&obj);
|
||
|
||
if(index>-1) SetSlfTableRecordCount(index,pInfo->TotalLogNumber);
|
||
delete []pField;
|
||
return index;
|
||
}
|
||
bool CLogIO ::GetSlfTDTInfo(int index,Slf_TDT* pInfo)
|
||
{
|
||
if(index<0) return 0;
|
||
int FieldNum=GetSlfTableFieldCount(index);
|
||
int rec=GetSlfTableRecordCount(index);
|
||
Slf_TABLE_ENTRY obj;
|
||
GetSlfObjectEntry(index,&obj);
|
||
Slf_OBJECT_FIELD *pf=new Slf_OBJECT_FIELD[FieldNum];
|
||
memset(pf,0,sizeof(Slf_OBJECT_FIELD)*FieldNum);
|
||
GetSlfTableFieldInfo(index,pf);
|
||
|
||
memmove(pInfo->AliasName,obj.HZName,sizeof(pInfo->AliasName));
|
||
memmove(pInfo->Name,obj.Name,sizeof(pInfo->Name));
|
||
pInfo->MaxValue=pf[3].Vmax;
|
||
pInfo->MinValue=pf[3].Vmin;
|
||
|
||
memmove(pInfo->Unit,pf[3].Unit,sizeof(pInfo->Unit));
|
||
memmove(pInfo->AliasUnit,pf[3].HZUnit,sizeof(pInfo->AliasUnit));
|
||
memmove(pInfo->DepthUnit,pf[0].Unit,sizeof(pInfo->DepthUnit));
|
||
memmove(pInfo->TimeUnit,pf[4].Unit,sizeof(pInfo->TimeUnit));
|
||
memmove(pInfo->LogTimeUnit,pf[1].Unit,sizeof(pInfo->LogTimeUnit));
|
||
|
||
pInfo->MaxLogSamples=pf[3].SamplePoint;
|
||
pInfo->TotalLogNumber=GetSlfTableRecordCount(index);
|
||
delete []pf;
|
||
return TRUE;
|
||
}
|
||
bool CLogIO ::SetSlfTDTInfo(int index,Slf_TDT* pInfo)
|
||
{
|
||
if(index<0) return 0;
|
||
int FieldNum=GetSlfTableFieldCount(index);
|
||
int rec=GetSlfTableRecordCount(index);
|
||
Slf_TABLE_ENTRY obj;
|
||
GetSlfObjectEntry(index,&obj);
|
||
Slf_OBJECT_FIELD *pf=new Slf_OBJECT_FIELD[FieldNum];
|
||
memset(pf,0,sizeof(Slf_OBJECT_FIELD)*FieldNum);
|
||
GetSlfTableFieldInfo(index,pf);
|
||
|
||
memmove(obj.HZName,pInfo->AliasName,sizeof(obj.HZName));
|
||
memmove(obj.Name,pInfo->Name,sizeof(obj.Name));
|
||
// pf[3].Vmax=pInfo->MaxValue;
|
||
// pf[3].Vmin=pInfo->MinValue;
|
||
WriteSlfObjectEntry(index,&obj);
|
||
memmove(pf[3].Unit,pInfo->Unit,sizeof(pf[3].Unit));
|
||
memmove(pf[3].HZUnit,pInfo->AliasUnit,sizeof(pf[3].HZUnit));
|
||
memmove(pf[0].Unit,pInfo->DepthUnit,sizeof(pf[0].Unit));
|
||
memmove(pf[4].Unit,pInfo->TimeUnit,sizeof(pf[4].Unit));
|
||
memmove(pf[1].Unit,pInfo->LogTimeUnit,sizeof(pf[1].Unit));
|
||
pf[3].SamplePoint=pInfo->MaxLogSamples;
|
||
SetSlfTableFieldInfo(index,pf,0);
|
||
delete []pf;
|
||
return TRUE;
|
||
}
|
||
|
||
DWORD CLogIO ::ReadSlfTDT(int index, float Depth, unsigned int* pLogTime, TDT_DATA* buffer)
|
||
{
|
||
int rec=GetSlfTableRecordCount(index);
|
||
int reclen=GetSlfTableRecordLength(index);
|
||
int pos1=GetSlfTableFieldOffset(index,3)/float(sizeof(float))+0.1;
|
||
int pos2=GetSlfTableFieldOffset(index,4)/float(sizeof(float))+0.1;
|
||
int buffsize=reclen/float(sizeof(float))+1;
|
||
float *buff=new float[buffsize];
|
||
int pos=0;
|
||
int n=0;
|
||
for(int i=0;i<rec;i++) {
|
||
ReadSlfTable(index,i+1,buff,i);
|
||
if(buff[0]==Depth) {
|
||
memmove(&pLogTime[pos++],&buff[1],sizeof(unsigned int));
|
||
n=*(unsigned int *)&buff[2];
|
||
for(int j=0;j<n;j++) {
|
||
buffer[j].Depth=buff[0];
|
||
buffer[j].Value=buff[pos1+j];
|
||
buffer[j].Time=buff[pos2+j];
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
delete []buff;
|
||
return n;
|
||
}
|
||
bool CLogIO ::SetSlfTDTDepth(int index,int Count,float* pDepth1,float* pDepth2)
|
||
{
|
||
int rec=GetSlfTableRecordCount(index);
|
||
int reclen=GetSlfTableRecordLength(index);
|
||
int buffsize=reclen/float(sizeof(float))+1;
|
||
float *buff=new float[buffsize];
|
||
|
||
int pos=0;
|
||
int n=0;
|
||
for(int i=0;i<rec;i++) {
|
||
ReadSlfTable(index,i+1,buff,i);
|
||
if(buff[0]==*pDepth1) {
|
||
buff[0]=*pDepth2;
|
||
WriteSlfTable(index,i+1,buff,i);
|
||
break;
|
||
}
|
||
}
|
||
delete []buff;
|
||
return 1;
|
||
}
|
||
bool CLogIO ::SetSlfTDTLogTime(int index,float pDepth1,unsigned int* LogTime)
|
||
{
|
||
int rec=GetSlfTableRecordCount(index);
|
||
int reclen=GetSlfTableRecordLength(index);
|
||
int buffsize=reclen/float(sizeof(float))+1;
|
||
float *buff=new float[buffsize];
|
||
|
||
int pos=0;
|
||
int n=0;
|
||
for(int i=0;i<rec;i++) {
|
||
ReadSlfTable(index,i+1,buff,i);
|
||
if(buff[0]==pDepth1) {
|
||
memmove(&buff[1],LogTime,sizeof(unsigned int));
|
||
WriteSlfTable(index,i+1,buff,i);
|
||
break;
|
||
}
|
||
}
|
||
delete []buff;
|
||
return 1;
|
||
}
|
||
bool CLogIO ::SetFMTDepth(int index,int Count,float* pDepth1,float* pDepth2)
|
||
{
|
||
if(IsWis) {
|
||
return SetWisFMTDepth(index,Count,pDepth1,pDepth2);
|
||
}
|
||
return SetSlfFMTDepth(index,Count,pDepth1,pDepth2);
|
||
}
|
||
bool CLogIO ::SetSlfFMTDepth(int index,int Count,float* pDepth1,float* pDepth2)
|
||
{
|
||
int rec=GetSlfTableRecordCount(index);
|
||
int reclen=GetSlfTableRecordLength(index);
|
||
int buffsize=reclen/float(sizeof(float))+1;
|
||
float *buff=new float[buffsize];
|
||
int pos=0;
|
||
int n=0;
|
||
for(int i=0;i<rec;i++) {
|
||
ReadSlfTable(index,i+1,buff,i);
|
||
if(buff[0]==*pDepth1) {
|
||
buff[0]=*pDepth2;
|
||
WriteSlfTable(index,i+1,buff,i);
|
||
break;
|
||
}
|
||
}
|
||
delete []buff;
|
||
return 1;
|
||
}
|
||
DWORD CLogIO ::ReadSlfTDT(int index, float Depth, unsigned int* pLogTime, TDT_DATA* buffer,int *recno)
|
||
{
|
||
int rec=GetSlfTableRecordCount(index);
|
||
int reclen=GetSlfTableRecordLength(index);
|
||
int pos1=GetSlfTableFieldOffset(index,3)/float(sizeof(float))+0.1;
|
||
int pos2=GetSlfTableFieldOffset(index,4)/float(sizeof(float))+0.1;
|
||
int buffsize=reclen/float(sizeof(float))+1;
|
||
float *buff=new float[buffsize];
|
||
int pos=0;
|
||
int n=0;
|
||
for(int i=0;i<rec;i++) {
|
||
ReadSlfTable(index,i+1,buff,i);
|
||
if(buff[0]==Depth) {
|
||
memmove(&pLogTime[pos++],&buff[1],sizeof(unsigned int));
|
||
n=*(unsigned int *)&buff[2];
|
||
*recno=i;
|
||
for(int j=0;j<n;j++) {
|
||
buffer[j].Depth=buff[0];
|
||
buffer[j].Value=buff[pos1+j];
|
||
buffer[j].Time=buff[pos2+j];
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
delete []buff;
|
||
return n;
|
||
}
|
||
DWORD CLogIO ::GetSlfTDTAllLogTime(int index,unsigned int* pLogTime,unsigned int *l)
|
||
{
|
||
int rec=GetSlfTableRecordCount(index);
|
||
int reclen=GetSlfTableRecordLength(index);
|
||
int buffsize=reclen/float(sizeof(float))+1;
|
||
float *buff=new float[buffsize];
|
||
int pos=0;
|
||
for(int i=0;i<rec;i++) {
|
||
ReadSlfTable(index,i+1,buff,i);
|
||
memmove(&pLogTime[pos],&buff[1],sizeof(unsigned int));
|
||
if(l) memmove(&l[pos],&buff[2],sizeof(unsigned int));
|
||
pos++;
|
||
}
|
||
delete []buff;
|
||
return rec;
|
||
}
|
||
DWORD CLogIO ::ReadSlfTDT(int index, int nPointNo, unsigned int* pLogTime, TDT_DATA* buffer)
|
||
{
|
||
if(nPointNo<1) nPointNo=1;
|
||
int rec=GetSlfTableRecordCount(index);
|
||
int reclen=GetSlfTableRecordLength(index);
|
||
int pos1=GetSlfTableFieldOffset(index,3)/float(sizeof(float))+0.1;
|
||
int pos2=GetSlfTableFieldOffset(index,4)/float(sizeof(float))+0.1;
|
||
int buffsize=reclen/float(sizeof(float))+1;
|
||
float *buff=new float[buffsize];
|
||
int pos=0;
|
||
int n=0;
|
||
ReadSlfTable(index,nPointNo,buff,nPointNo-1);
|
||
memmove(&pLogTime[pos++],&buff[1],sizeof(unsigned int));
|
||
n=*(unsigned int *)&buff[2];
|
||
for(int j=0;j<n;j++) {
|
||
buffer[j].Depth=buff[0];
|
||
buffer[j].Value=buff[pos1+j];
|
||
buffer[j].Time=buff[pos2+j];
|
||
}
|
||
delete []buff;
|
||
return n;
|
||
}
|
||
DWORD CLogIO ::WriteSlfTDT(int index, int nPointNo, unsigned int LogTime, TDT_DATA* buffer, DWORD count)
|
||
{
|
||
if(nPointNo<=0) nPointNo=1;
|
||
int rec=GetSlfTableRecordCount(index);
|
||
int reclen=GetSlfTableRecordLength(index);
|
||
int pos1=GetSlfTableFieldOffset(index,3)/float(sizeof(float))+0.1;
|
||
int pos2=GetSlfTableFieldOffset(index,4)/float(sizeof(float))+0.1;
|
||
int buffsize=reclen/float(sizeof(float))+1;
|
||
float *buff=new float[buffsize];
|
||
int pos=0;
|
||
int n=0;
|
||
buff[0]=buffer[0].Depth;
|
||
memmove(&buff[1],&LogTime,sizeof(unsigned int));
|
||
*(unsigned int *)&buff[2]=count;
|
||
for(int j=0;j<count;j++) {
|
||
buff[pos1+j]=buffer[j].Value;
|
||
buff[pos2+j]=buffer[j].Time;
|
||
}
|
||
WriteSlfTable(index,nPointNo,buff,nPointNo-1);
|
||
delete []buff;
|
||
return count;
|
||
}
|
||
DWORD CLogIO ::AddSlfTDT(int index, unsigned int LogTime, TDT_DATA* buffer, DWORD count)
|
||
{
|
||
int rec=GetSlfTableRecordCount(index);
|
||
return WriteSlfTDT(index,rec+1,LogTime,buffer,count);
|
||
}
|
||
void CLogIO::GetChannelInfo(int index,Slf_CHANNEL* pInfo)
|
||
{
|
||
if(IsWis) return GetWisChannelInfo(index,pInfo);
|
||
else return GetSlfChannelInfo(index,pInfo);
|
||
}
|
||
void CLogIO::GetWisChannelInfo(int index,Slf_CHANNEL* pInfo)
|
||
{
|
||
if(index<0) return ;
|
||
ReadChannelInfo(index,pInfo);
|
||
}
|
||
void CLogIO::GetSlfChannelInfo(int index,Slf_CHANNEL* pInfo)
|
||
{
|
||
if(index<0) return;
|
||
if(!Slf_Info_Head[index]) return;
|
||
Slf_TABLE_MESSAGE *temp=(Slf_TABLE_MESSAGE *)Slf_Info_Head[index];
|
||
Slf_OBJECT_FIELD *pFieldInfo=temp->pField;
|
||
int no=0;
|
||
if(m_SlfObjectEntry[index].FieldNum>1) no=1;
|
||
memmove(pInfo->AliasName,m_SlfObjectEntry[index].HZName,sizeof(pInfo->AliasName));
|
||
if(m_SlfObjectEntry[index].Type==CURVE_OBJECT) no=1;
|
||
else if(m_SlfObjectEntry[index].Type==WAVE_OBJECT) no=1;
|
||
else if(m_SlfObjectEntry[index].Type==FMT_OBJECT) no=2;
|
||
else if(m_SlfObjectEntry[index].Type==TDT_OBJECT) no=3;
|
||
pInfo->CodeLen=pFieldInfo[no].CodeLength;
|
||
pInfo->RepCode=pFieldInfo[no].RepCode;
|
||
pInfo->MaxVal=pFieldInfo[no].Vmax;
|
||
pInfo->MinVal=pFieldInfo[no].Vmin;
|
||
pInfo->NumOfDimension=m_SlfObjectEntry[index].FieldNum;
|
||
if(pInfo->NumOfDimension>4) pInfo->NumOfDimension=4;
|
||
memmove(pInfo->Unit,pFieldInfo[no].Unit,sizeof(pInfo->Unit));
|
||
memmove(pInfo->AliasUnit,pFieldInfo[no].HZUnit,sizeof(pInfo->AliasUnit));//whp add
|
||
if(m_SlfObjectEntry[index].Type==FMT_OBJECT) {
|
||
pInfo->NumOfDimension=2;
|
||
pInfo->DimInfo[0].Samples=GetSlfTableRecordCount(index);
|
||
pInfo->DimInfo[0].MaxSamples=pInfo->DimInfo[0].Samples;
|
||
pInfo->DimInfo[0].RepCode=pFieldInfo[0].RepCode;
|
||
memmove(pInfo->DimInfo[0].Name,pFieldInfo[0].Name,sizeof(pInfo->DimInfo[0].Name));
|
||
memmove(pInfo->DimInfo[0].AliasName,pFieldInfo[0].HZName,sizeof(pInfo->DimInfo[0].AliasName));
|
||
pInfo->DimInfo[0].Reserved=0;
|
||
//pInfo->DimInfo[0].Size=pFieldInfo[0].CodeLength;
|
||
pInfo->DimInfo[0].Size=GetSlfTableRecordLength(index,pFieldInfo);
|
||
|
||
pInfo->DimInfo[0].Delta=pFieldInfo[0].Rlev;
|
||
pInfo->DimInfo[0].StartVal=pFieldInfo[0].Start;
|
||
|
||
pInfo->DimInfo[1].Delta=pFieldInfo[3].Rlev;
|
||
pInfo->DimInfo[1].StartVal=pFieldInfo[3].Start;
|
||
pInfo->DimInfo[1].Samples=pFieldInfo[3].SamplePoint;
|
||
pInfo->DimInfo[1].MaxSamples=pFieldInfo[3].SamplePoint;
|
||
memmove(pInfo->DimInfo[1].Unit,pFieldInfo[3].Unit,sizeof(pInfo->DimInfo[1].Unit));
|
||
memmove(pInfo->DimInfo[1].Name,pFieldInfo[3].Name,sizeof(pInfo->DimInfo[1].Name));
|
||
memmove(pInfo->DimInfo[1].AliasName,pFieldInfo[3].HZName,sizeof(pInfo->DimInfo[1].AliasName));
|
||
pInfo->DimInfo[1].Reserved=0;
|
||
pInfo->DimInfo[1].Size=pFieldInfo[3].ArrayNum*pFieldInfo[3].CodeLength*pFieldInfo[3].SamplePoint;
|
||
pInfo->DimInfo[1].RepCode=pFieldInfo[3].RepCode;//pFieldInfo[4].RepCode;whp change 2011.11.19 FMT只有4维!
|
||
}
|
||
else if(m_SlfObjectEntry[index].Type==TDT_OBJECT) {
|
||
pInfo->NumOfDimension=2;
|
||
memmove(pInfo->DimInfo[0].Unit,pFieldInfo[0].Unit,sizeof(pInfo->DimInfo[0].Unit));
|
||
pInfo->DimInfo[0].Samples=GetSlfTableRecordCount(index);
|
||
pInfo->DimInfo[0].MaxSamples=pInfo->DimInfo[0].Samples;
|
||
pInfo->DimInfo[0].RepCode=pFieldInfo[0].RepCode;
|
||
memmove(pInfo->DimInfo[0].Name,pFieldInfo[0].Name,sizeof(pInfo->DimInfo[0].Name));
|
||
memmove(pInfo->DimInfo[0].AliasName,pFieldInfo[0].HZName,sizeof(pInfo->DimInfo[0].AliasName));
|
||
pInfo->DimInfo[0].Reserved=0;
|
||
//pInfo->DimInfo[0].Size=pFieldInfo[0].CodeLength;
|
||
pInfo->DimInfo[0].Size=GetSlfTableRecordLength(index,pFieldInfo);
|
||
|
||
pInfo->DimInfo[0].Delta=pFieldInfo[0].Rlev;
|
||
pInfo->DimInfo[0].StartVal=pFieldInfo[0].Start;
|
||
|
||
pInfo->DimInfo[1].Delta=pFieldInfo[4].Rlev;
|
||
pInfo->DimInfo[1].StartVal=pFieldInfo[4].Start;
|
||
pInfo->DimInfo[1].Samples=pFieldInfo[4].SamplePoint;
|
||
pInfo->DimInfo[1].MaxSamples=pFieldInfo[4].SamplePoint;
|
||
memmove(pInfo->DimInfo[1].Unit,pFieldInfo[4].Unit,sizeof(pInfo->DimInfo[1].Unit));
|
||
memmove(pInfo->DimInfo[1].Name,pFieldInfo[4].Name,sizeof(pInfo->DimInfo[1].Name));
|
||
memmove(pInfo->DimInfo[1].AliasName,pFieldInfo[4].HZName,sizeof(pInfo->DimInfo[1].AliasName));
|
||
pInfo->DimInfo[1].Reserved=0;
|
||
pInfo->DimInfo[1].Size=pFieldInfo[4].ArrayNum*pFieldInfo[4].CodeLength*pFieldInfo[4].SamplePoint;
|
||
pInfo->DimInfo[1].RepCode=pFieldInfo[4].RepCode;
|
||
}
|
||
else if(m_SlfObjectEntry[index].Type==WAVE_OBJECT){
|
||
pInfo->NumOfDimension=2;
|
||
memmove(pInfo->DimInfo[0].Unit,pFieldInfo[0].Unit,sizeof(pInfo->DimInfo[0].Unit));
|
||
pInfo->DimInfo[0].Samples=GetSlfTableRecordCount(index);
|
||
pInfo->DimInfo[0].MaxSamples=pInfo->DimInfo[0].Samples;
|
||
pInfo->DimInfo[0].RepCode=pFieldInfo[0].RepCode;
|
||
memmove(pInfo->DimInfo[0].Name,pFieldInfo[0].Name,sizeof(pInfo->DimInfo[0].Name));
|
||
memmove(pInfo->DimInfo[0].AliasName,pFieldInfo[0].HZName,sizeof(pInfo->DimInfo[0].AliasName));
|
||
pInfo->DimInfo[0].Reserved=0;
|
||
//pInfo->DimInfo[0].Size=pFieldInfo[0].CodeLength;
|
||
pInfo->DimInfo[0].Size=GetSlfTableRecordLength(index,pFieldInfo);
|
||
|
||
pInfo->DimInfo[0].Delta=pFieldInfo[0].Rlev;
|
||
pInfo->DimInfo[0].StartVal=pFieldInfo[0].Start;
|
||
|
||
pInfo->DimInfo[1].Delta=pFieldInfo[2].Rlev;
|
||
pInfo->DimInfo[1].StartVal=pFieldInfo[2].Start;
|
||
pInfo->DimInfo[1].Samples=pFieldInfo[2].SamplePoint;
|
||
pInfo->DimInfo[1].MaxSamples=pFieldInfo[2].SamplePoint;
|
||
memmove(pInfo->DimInfo[1].Unit,pFieldInfo[2].Unit,sizeof(pInfo->DimInfo[1].Unit));
|
||
memmove(pInfo->DimInfo[1].Name,pFieldInfo[2].Name,sizeof(pInfo->DimInfo[1].Name));
|
||
memmove(pInfo->DimInfo[1].AliasName,pFieldInfo[2].HZName,sizeof(pInfo->DimInfo[1].AliasName));
|
||
pInfo->DimInfo[1].Reserved=0;
|
||
pInfo->DimInfo[1].Size=pFieldInfo[2].ArrayNum*pFieldInfo[2].CodeLength*pFieldInfo[2].SamplePoint;
|
||
pInfo->DimInfo[1].RepCode=pFieldInfo[2].RepCode;
|
||
}
|
||
else if(m_SlfObjectEntry[index].Type==CURVE_OBJECT){
|
||
pInfo->NumOfDimension=1;
|
||
memmove(pInfo->DimInfo[0].Unit,pFieldInfo[0].Unit,sizeof(pInfo->DimInfo[0].Unit));
|
||
pInfo->DimInfo[0].Samples=GetSlfTableRecordCount(index);
|
||
pInfo->DimInfo[0].MaxSamples=pInfo->DimInfo[0].Samples;
|
||
pInfo->DimInfo[0].RepCode=pFieldInfo[0].RepCode;
|
||
memmove(pInfo->DimInfo[0].Name,pFieldInfo[0].Name,sizeof(pInfo->DimInfo[0].Name));
|
||
memmove(pInfo->DimInfo[0].AliasName,pFieldInfo[0].HZName,sizeof(pInfo->DimInfo[0].AliasName));
|
||
pInfo->DimInfo[0].Reserved=0;
|
||
//pInfo->DimInfo[0].Size=pFieldInfo[0].CodeLength;
|
||
pInfo->DimInfo[0].Size=GetSlfTableRecordLength(index,pFieldInfo);
|
||
|
||
pInfo->DimInfo[0].Delta=pFieldInfo[0].Rlev;
|
||
pInfo->DimInfo[0].StartVal=pFieldInfo[0].Start;
|
||
}
|
||
else {
|
||
for(int i=0;i<pInfo->NumOfDimension;i++) {
|
||
memmove(pInfo->DimInfo[i].AliasName,pFieldInfo[i].HZName,sizeof(pInfo->DimInfo[i].AliasName));
|
||
memmove(pInfo->DimInfo[i].Name,pFieldInfo[i].Name,sizeof(pInfo->DimInfo[i].Name));
|
||
memmove(pInfo->AliasUnit,pFieldInfo[i].HZUnit,sizeof(pInfo->AliasUnit));
|
||
pInfo->DimInfo[i].RepCode=pFieldInfo[i].RepCode;
|
||
pInfo->DimInfo[i].Delta=pFieldInfo[i].Rlev;
|
||
pInfo->DimInfo[i].StartVal=pFieldInfo[i].Start;
|
||
if(!i)pInfo->DimInfo[i].Samples=GetSlfTableRecordCount(index);
|
||
else pInfo->DimInfo[i].Samples=pFieldInfo[i].ArrayNum*pFieldInfo[i].SamplePoint;
|
||
pInfo->DimInfo[i].MaxSamples=pInfo->DimInfo[i].Samples;
|
||
pInfo->DimInfo[i].Size=pFieldInfo[i].ArrayNum*pFieldInfo[i].CodeLength*pFieldInfo[i].SamplePoint;
|
||
}
|
||
}
|
||
}
|
||
void CLogIO::SetChannelInfo(int index,Slf_CHANNEL* pInfo)
|
||
{
|
||
if(IsWis) WriteWisChannelInfo(index,pInfo);
|
||
else SetSlfChannelInfo(index,pInfo);
|
||
|
||
}
|
||
void CLogIO::SetSlfChannelInfo(int index,Slf_CHANNEL* pInfo)
|
||
{
|
||
if(index<0) return;
|
||
if(!Slf_Info_Head[index]) return;
|
||
Slf_TABLE_MESSAGE *temp=(Slf_TABLE_MESSAGE *)Slf_Info_Head[index];
|
||
Slf_OBJECT_FIELD *pFieldInfo=temp->pField;
|
||
int no=0;
|
||
if(m_SlfObjectEntry[index].FieldNum>1) no=1;
|
||
memmove(m_SlfObjectEntry[index].HZName,pInfo->AliasName,sizeof(m_SlfObjectEntry[index].HZName));
|
||
//whp add 2011.10.30 for SetChannelInfo没有保存对象别名信息
|
||
WriteSlfObjectEntry();
|
||
if(m_SlfObjectEntry[index].Type==CURVE_OBJECT) no=1;
|
||
else if(m_SlfObjectEntry[index].Type==WAVE_OBJECT) no=1;
|
||
else if(m_SlfObjectEntry[index].Type==FMT_OBJECT) no=2;
|
||
else if(m_SlfObjectEntry[index].Type==TDT_OBJECT) no=3;
|
||
pFieldInfo[no].Vmax=pInfo->MaxVal;
|
||
pFieldInfo[no].Vmin=pInfo->MinVal;
|
||
memmove(pFieldInfo[no].Unit,pInfo->Unit,sizeof(pFieldInfo[no].Unit));
|
||
memmove(pFieldInfo[no].HZUnit,pInfo->AliasUnit,sizeof(pInfo->AliasUnit));//,sizeof(pFieldInfo[no].HZUnit));//whp add
|
||
if(m_SlfObjectEntry[index].Type==FMT_OBJECT) {
|
||
//SetSlfTableRecordCount(index,pInfo->DimInfo[0].Samples);
|
||
memmove(pFieldInfo[0].Name,pInfo->DimInfo[0].Name,sizeof(pFieldInfo[0].Name));
|
||
memmove(pFieldInfo[0].HZName,pInfo->DimInfo[0].AliasName,sizeof(pFieldInfo[0].HZName));
|
||
pFieldInfo[0].Start=pInfo->DimInfo[0].StartVal;
|
||
|
||
pFieldInfo[3].Start=pInfo->DimInfo[1].StartVal;
|
||
memmove(pFieldInfo[3].Unit,pInfo->DimInfo[1].Unit,sizeof(pFieldInfo[3].Unit));
|
||
memmove(pFieldInfo[3].Name,pInfo->DimInfo[1].Name,sizeof(pFieldInfo[3].Name));
|
||
memmove(pFieldInfo[3].HZName,pInfo->DimInfo[1].AliasName,sizeof(pFieldInfo[3].HZName));
|
||
SetSlfTableFieldInfo(index,pFieldInfo,0);
|
||
}
|
||
else if(m_SlfObjectEntry[index].Type==TDT_OBJECT) {
|
||
//SetSlfTableRecordCount(index,pInfo->DimInfo[0].Samples);
|
||
memmove(pFieldInfo[0].Unit,pInfo->DimInfo[0].Unit,sizeof(pFieldInfo[0].Unit));
|
||
memmove(pFieldInfo[0].Name,pInfo->DimInfo[0].Name,sizeof(pFieldInfo[0].Name));
|
||
memmove(pFieldInfo[0].HZName,pInfo->DimInfo[0].AliasName,sizeof(pFieldInfo[0].HZName));
|
||
pFieldInfo[0].Start=pInfo->DimInfo[0].StartVal;
|
||
|
||
pFieldInfo[4].Rlev=pInfo->DimInfo[1].Delta;
|
||
pFieldInfo[4].Start=pInfo->DimInfo[1].StartVal;
|
||
memmove(pFieldInfo[4].Unit,pInfo->DimInfo[1].Unit,sizeof(pFieldInfo[4].Unit));
|
||
memmove(pFieldInfo[4].Name,pInfo->DimInfo[1].Name,sizeof(pFieldInfo[4].Name));
|
||
memmove(pFieldInfo[4].HZName,pInfo->DimInfo[1].AliasName,sizeof(pFieldInfo[4].HZName));
|
||
SetSlfTableFieldInfo(index,pFieldInfo,0);
|
||
}
|
||
else if(m_SlfObjectEntry[index].Type==WAVE_OBJECT){
|
||
//SetSlfTableRecordCount(index,pInfo->DimInfo[0].Samples);
|
||
memmove(pFieldInfo[0].Unit,pInfo->DimInfo[0].Unit,sizeof(pFieldInfo[0].Unit));
|
||
memmove(pFieldInfo[0].Name,pInfo->DimInfo[0].Name,sizeof(pFieldInfo[0].Name));
|
||
memmove(pFieldInfo[0].HZName,pInfo->DimInfo[0].AliasName,sizeof(pFieldInfo[0].HZName));
|
||
pFieldInfo[0].Start=pInfo->DimInfo[0].StartVal;
|
||
|
||
pFieldInfo[2].Rlev=pInfo->DimInfo[1].Delta;
|
||
pFieldInfo[2].Start=pInfo->DimInfo[1].StartVal;
|
||
|
||
memmove(pFieldInfo[2].Unit,pInfo->DimInfo[1].Unit,sizeof(pFieldInfo[1].Unit));
|
||
memmove(pFieldInfo[2].Name,pInfo->DimInfo[1].Name,sizeof(pFieldInfo[1].Name));
|
||
memmove(pFieldInfo[2].HZName,pInfo->DimInfo[1].AliasName,sizeof(pFieldInfo[1].HZName));
|
||
SetSlfTableFieldInfo(index,pFieldInfo,0);
|
||
}
|
||
else if(m_SlfObjectEntry[index].Type==CURVE_OBJECT){
|
||
//SetSlfTableRecordCount(index,pInfo->DimInfo[0].Samples);
|
||
memmove(pFieldInfo[0].Unit,pInfo->DimInfo[0].Unit,sizeof(pFieldInfo[0].Unit));
|
||
memmove(pFieldInfo[0].Name,pInfo->DimInfo[0].Name,sizeof(pFieldInfo[0].Name));
|
||
memmove(pFieldInfo[0].HZName,pInfo->DimInfo[0].AliasName,sizeof(pFieldInfo[0].HZName));
|
||
pFieldInfo[0].Start=pInfo->DimInfo[0].StartVal;
|
||
SetSlfTableFieldInfo(index,pFieldInfo,0);
|
||
}
|
||
}
|
||
bool CLogIO:: SetTDTInfo(int index,Slf_TDT* pInfo)
|
||
{
|
||
if(IsWis) return SetWisTDTInfo(index,pInfo);
|
||
else return SetSlfTDTInfo(index,pInfo);
|
||
}
|
||
bool CLogIO:: SetFMTInfo(int index,Slf_FMT* pInfo)
|
||
{
|
||
if(IsWis) return SetWisFMTInfo(index,pInfo);
|
||
else return SetSlfFMTInfo(index,pInfo);
|
||
}
|
||
bool CLogIO:: SetWaveInfo(int index,Slf_WAVE* pInfo)
|
||
{
|
||
if(IsWis) return SetWisWaveInfo(index,pInfo);
|
||
else return SetSlfWaveInfo(index,pInfo);
|
||
}
|
||
bool CLogIO:: SetCurveInfo(int index,Slf_CURVE* pInfo)
|
||
{
|
||
if(IsWis) return SetWisCurveInfo(index,pInfo);
|
||
else return SetSlfCurveInfo(index,pInfo);
|
||
}
|
||
void CLogIO:: GetWisMessage(Slf_FILE_MESSAGE &mssage)
|
||
{
|
||
memset(&mssage,0,sizeof(mssage));
|
||
WELL_STATIC_INFO inf;
|
||
int indexSTable=OpenTable("井基本信息");
|
||
if(indexSTable<0) {
|
||
indexSTable=OpenTable("STATIC");
|
||
}
|
||
if(indexSTable>=0) ReadTable(indexSTable,1,&inf);
|
||
else {
|
||
memset(&inf,0,sizeof(inf));
|
||
}
|
||
Slf_CONST xy;
|
||
bool flag=0;
|
||
indexSTable=OpenTable("LONG_CONST");
|
||
if(indexSTable>=0) {
|
||
int rec=this->GetTableRecordCount(indexSTable);
|
||
for(int i=0;i<rec;i++) {
|
||
ReadTable(indexSTable,i+1,&xy);
|
||
QString vd=xy.MNEM;
|
||
if(vd=="XLOC") {
|
||
inf.XCoor=xy.VALUE;
|
||
flag=1;
|
||
}
|
||
if(vd=="YLOC") {
|
||
inf.YCoor=xy.VALUE;
|
||
flag=1;
|
||
}
|
||
if(vd=="BXHB") {
|
||
inf.As1=xy.VALUE;
|
||
flag=1;
|
||
}
|
||
}
|
||
}
|
||
if(!flag) {
|
||
indexSTable=OpenTable("STRING_CONST");
|
||
Slf_STRING strval;
|
||
if(indexSTable>=0) {
|
||
int rec=this->GetTableRecordCount(indexSTable);
|
||
for(int i=0;i<rec;i++) {
|
||
ReadTable(indexSTable,i+1,&strval);
|
||
QString vd=strval.MNEM;
|
||
if(vd=="CN"||vd=="XLOC") {
|
||
inf.XCoor=atof(strval.VALUE);
|
||
flag=1;
|
||
}
|
||
if(vd=="WN"||vd=="YLOC") {
|
||
inf.YCoor=atof(strval.VALUE);
|
||
flag=1;
|
||
}
|
||
if(vd=="WC"||vd=="BXHB"||vd=="EGL") {
|
||
inf.As1=atof(strval.VALUE);
|
||
flag=1;
|
||
}
|
||
if(vd=="EKB") {
|
||
inf.Bs1=atof(strval.VALUE);
|
||
flag=1;
|
||
}
|
||
if(vd=="MDEC") {
|
||
mssage.azca=atof(strval.VALUE);
|
||
flag=1;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
if(inf.XCoor>99999999||inf.XCoor<0.1) inf.XCoor=0;
|
||
if(inf.YCoor>99999999||inf.YCoor<0.1) inf.YCoor=0;
|
||
mssage.Xcoor=inf.XCoor;
|
||
mssage.Ycoor=inf.YCoor;
|
||
|
||
if(!strstr(m_SlfHead.Version,"Slf 3.0"))
|
||
{
|
||
memmove(&mssage.X0,&inf.Remark[20],8);
|
||
memmove(&mssage.Y0,&inf.Remark[28],8);
|
||
}
|
||
else
|
||
{
|
||
mssage.X0=inf.XCoor;
|
||
mssage.Y0=inf.YCoor;
|
||
}
|
||
memmove(mssage.Item,inf.MethodCWell,sizeof(mssage.Item));
|
||
memmove(mssage.WellName,inf.WellName,sizeof(mssage.WellName));
|
||
memmove(mssage.AreaName,inf.AreaName,sizeof(mssage.AreaName));
|
||
memmove(mssage.OilCompanyName,inf.OilCompanyName,sizeof(mssage.OilCompanyName));
|
||
if(inf.As1<0.1) inf.As1=0;
|
||
if(inf.Bs1<0.1) inf.Bs1=0;
|
||
mssage.Altitude=inf.As1;
|
||
mssage.Kelly=inf.Bs1;
|
||
mssage.EndDrillDate=StringToTime(inf.EndDrillDate);
|
||
mssage.StartDrillDate=StringToTime(inf.StartDrillDate);
|
||
mssage.StartDepth=inf.Sc1Edep;
|
||
mssage.EndDepth=inf.Sc2sdep;
|
||
|
||
memmove(&mssage.X0,&inf.Remark[0],8);
|
||
memmove(&mssage.Y0,&inf.Remark[8],8);
|
||
memmove(&mssage.TVD,&inf.Remark[16],4);
|
||
|
||
WELL_DYNAMIC_INFO dinf;
|
||
indexSTable=OpenTable("测井信息");
|
||
if(indexSTable>=0) ReadTable(indexSTable,1,&dinf);
|
||
else memset(&dinf,0,sizeof(dinf));
|
||
memmove(mssage.LogCompanyName,dinf.LogCompanyName,sizeof(mssage.LogCompanyName));
|
||
memmove(mssage.Operator,dinf.Operator,sizeof(mssage.Operator));
|
||
memmove(mssage.LoggingTeam,dinf.Item,sizeof(mssage.LoggingTeam));
|
||
mssage.LoggingDate=StringToTime(dinf.Date);
|
||
}
|
||
void CLogIO:: SetWisMessage(Slf_FILE_MESSAGE mssage)
|
||
{
|
||
int indexSTable=OpenSTATIC("井基本信息");
|
||
WELL_STATIC_INFO inf;
|
||
if(indexSTable>-1) {
|
||
ReadTable(indexSTable,1,&inf);
|
||
}
|
||
else memset(&inf,0,sizeof(inf));
|
||
|
||
inf.XCoor=mssage.Xcoor;
|
||
inf.YCoor=mssage.Ycoor;
|
||
|
||
memmove(inf.MethodCWell,mssage.Item,sizeof(inf.MethodCWell));
|
||
memmove(inf.WellName,mssage.WellName,sizeof(inf.WellName));
|
||
memmove(inf.AreaName,mssage.AreaName,sizeof(inf.AreaName));
|
||
memmove(inf.OilCompanyName,mssage.OilCompanyName,sizeof(inf.OilCompanyName));
|
||
inf.As1=mssage.Altitude;
|
||
inf.Bs1=mssage.Kelly;
|
||
if(mssage.EndDrillDate<0) mssage.EndDrillDate=0;
|
||
CString css=ctime((time_t *)&mssage.EndDrillDate);
|
||
char buf[200];
|
||
strcpy(buf,css.GetString());
|
||
memmove(inf.EndDrillDate,buf,sizeof(inf.EndDrillDate));
|
||
memmove(inf.StartDrillDate,ctime((time_t *)&mssage.StartDrillDate),sizeof(inf.StartDrillDate));
|
||
inf.Sc1Edep=mssage.StartDepth;
|
||
inf.Sc2sdep=mssage.EndDepth;
|
||
memmove(&inf.Remark[0],&mssage.X0,8);
|
||
memmove(&inf.Remark[8],&mssage.Y0,8);
|
||
memmove(&inf.Remark[16],&mssage.TVD,4);
|
||
memmove(&inf.Remark[20],&mssage.Xcoor,8);
|
||
memmove(&inf.Remark[28],&mssage.Ycoor,8);
|
||
|
||
WriteTable(indexSTable,1,&inf);
|
||
WELL_DYNAMIC_INFO dinf;
|
||
indexSTable=OpenDYNAMIC("测井信息");
|
||
if(indexSTable>=0) ReadTable(indexSTable,1,&dinf);
|
||
else memset(&dinf,0,sizeof(dinf));
|
||
memmove(dinf.LogCompanyName,mssage.LogCompanyName,sizeof(dinf.LogCompanyName));
|
||
memmove(dinf.Operator,mssage.Operator,sizeof(dinf.Operator));
|
||
memmove(dinf.Item,mssage.LoggingTeam,sizeof(dinf.Item));
|
||
css=ctime((time_t *)&mssage.LoggingDate);
|
||
strcpy(buf,css.GetString());
|
||
memmove(dinf.Date,buf,sizeof(dinf.Date));
|
||
WriteTable(indexSTable,1,&dinf);
|
||
}
|
||
void CLogIO:: GetFileMessage(Slf_FILE_MESSAGE &mssage)
|
||
{
|
||
if(IsWis) GetWisMessage(mssage);
|
||
else GetSlfMessage(mssage);
|
||
if(mssage.Xcoor==-999.25||mssage.Xcoor==-9999||mssage.Xcoor==-99999) mssage.Xcoor=0;
|
||
if(mssage.Ycoor==-999.25||mssage.Ycoor==-9999||mssage.Ycoor==-99999) mssage.Ycoor=0;
|
||
|
||
if(mssage.Kelly==999999||mssage.Kelly==9999999) mssage.Kelly=0;
|
||
}
|
||
void CLogIO:: SetFileMessage(Slf_FILE_MESSAGE mssage)
|
||
{
|
||
if(mssage.Xcoor==-999.25||mssage.Xcoor==-9999||mssage.Xcoor==-99999) mssage.Xcoor=0;
|
||
if(mssage.Ycoor==-999.25||mssage.Ycoor==-9999||mssage.Ycoor==-99999) mssage.Ycoor=0;
|
||
if(mssage.Kelly==999999||mssage.Kelly==9999999) mssage.Kelly=0;
|
||
if(IsWis) SetWisMessage(mssage);
|
||
else SetSlfMessage(mssage);
|
||
}
|
||
|
||
int CLogIO::SetDepthOffset(int iIndex,int no1,int j,int Count,float *dep1,float *dep2,char *buf,int &IsChange)
|
||
{
|
||
float Depth=0;
|
||
GetTableFieldData(iIndex,no1,buf,j+1);
|
||
sscanf(buf,"%f",&Depth);
|
||
if(Count==0) {
|
||
IsChange=1;
|
||
float dep=Depth+dep1[0];
|
||
dep=(int)(dep*10000+0.5)/10000.0;
|
||
SetTableFieldData(iIndex,no1,(char *)&dep,j+1);
|
||
}
|
||
else {
|
||
float dep=0;
|
||
for(int i=0;i<Count-1;i++) {
|
||
if(Depth<dep1[i]||Depth>dep1[i+1]) continue;
|
||
IsChange=1;
|
||
if(dep1[i+1]==dep1[i]) SetTableFieldData(iIndex,no1,(char *)&dep2[i],j+1);
|
||
else {
|
||
dep=dep2[i]+(dep2[i+1]-dep2[i])/(dep1[i+1]-dep1[i])*(Depth-dep1[i]);
|
||
dep=(int)(dep*10000+0.5)/10000.0;
|
||
SetTableFieldData(iIndex,no1,(char *)&dep,j+1);
|
||
}
|
||
}
|
||
}
|
||
return IsChange;
|
||
}
|
||
|
||
//whp add
|
||
bool CLogIO :: CorrectTableDepth(int iIndex,float delta)
|
||
{
|
||
int i;
|
||
if (iIndex < 0) return FALSE;
|
||
int numrec=GetTableRecordCount(iIndex);
|
||
if(numrec<1) return FALSE;
|
||
int no1=GetTableFieldNo(iIndex,"SDEP");
|
||
int no2=GetTableFieldNo(iIndex,"EDEP");
|
||
int no3=GetTableFieldNo(iIndex,"DEP");
|
||
int no4=GetTableFieldNo(iIndex,"DEPTH");
|
||
int no5=GetTableFieldNo(iIndex,"MDEPTH1");
|
||
int no6=GetTableFieldNo(iIndex,"MDEPTH2");
|
||
int no7=GetTableFieldNo(iIndex,"MDEPTH3");
|
||
int no8=GetTableFieldNo(iIndex,"MDEPTH4");
|
||
int no9=GetTableFieldNo(iIndex,"MDEPTH5");
|
||
int no10=GetTableFieldNo(iIndex,"MDEPTH6");
|
||
int no11=GetTableFieldNo(iIndex,"MDEPTH7");
|
||
int no12=GetTableFieldNo(iIndex,"MDEPTH8");
|
||
int no13=GetTableFieldNo(iIndex,"MDEPTH9");
|
||
int no14=GetTableFieldNo(iIndex,"MDEPTH10");
|
||
int no15=GetTableFieldNo(iIndex,"STDEP");
|
||
int no16=GetTableFieldNo(iIndex,"ENDEP");
|
||
if(no1<0&&
|
||
no2<0&&
|
||
no3<0
|
||
&&no4<0
|
||
&&no5<0
|
||
&&no6<0
|
||
&&no7<0
|
||
&&no8<0
|
||
&&no9<0
|
||
&&no10<0
|
||
&&no11<0
|
||
&&no12<0
|
||
&&no13<0
|
||
&&no14<0
|
||
&&no15<0
|
||
&&no16<0
|
||
) return FALSE;
|
||
int len=GetTableRecordLength(iIndex);
|
||
char *buf=new char[len+1];
|
||
float Depth,dep;
|
||
for(int j=0;j<numrec;j++)
|
||
{
|
||
if(no1>-1)
|
||
{
|
||
GetTableFieldData(iIndex,no1,buf,j+1);
|
||
sscanf(buf,"%f",&Depth);
|
||
Depth+=delta;
|
||
SetTableFieldData(iIndex,no1,(char *)&Depth,j+1);
|
||
}
|
||
if(no2>-1)
|
||
{
|
||
GetTableFieldData(iIndex,no2,buf,j+1);
|
||
sscanf(buf,"%f",&Depth);
|
||
Depth+=delta;
|
||
SetTableFieldData(iIndex,no2,(char *)&Depth,j+1);
|
||
|
||
}
|
||
if(no3>-1)
|
||
{
|
||
GetTableFieldData(iIndex,no3,buf,j+1);
|
||
sscanf(buf,"%f",&Depth);
|
||
Depth+=delta;
|
||
SetTableFieldData(iIndex,no3,(char *)&Depth,j+1);
|
||
}
|
||
if(no4>-1)
|
||
{
|
||
GetTableFieldData(iIndex,no4,buf,j+1);
|
||
sscanf(buf,"%f",&Depth);
|
||
Depth+=delta;
|
||
SetTableFieldData(iIndex,no4,(char *)&Depth,j+1);
|
||
}
|
||
if(no5>-1)
|
||
{
|
||
GetTableFieldData(iIndex,no5,buf,j+1);
|
||
sscanf(buf,"%f",&Depth);
|
||
if(Depth) {
|
||
Depth+=delta;
|
||
SetTableFieldData(iIndex,no5,(char *)&Depth,j+1);
|
||
}
|
||
}
|
||
if(no6>-1)
|
||
{
|
||
GetTableFieldData(iIndex,no6,buf,j+1);
|
||
sscanf(buf,"%f",&Depth);
|
||
if(Depth) {
|
||
Depth+=delta;
|
||
SetTableFieldData(iIndex,no6,(char *)&Depth,j+1);
|
||
}
|
||
}
|
||
if(no7>-1)
|
||
{
|
||
GetTableFieldData(iIndex,no7,buf,j+1);
|
||
sscanf(buf,"%f",&Depth);
|
||
if(Depth) {
|
||
Depth+=delta;
|
||
SetTableFieldData(iIndex,no7,(char *)&Depth,j+1);
|
||
}
|
||
}
|
||
if(no8>-1)
|
||
{
|
||
GetTableFieldData(iIndex,no8,buf,j+1);
|
||
sscanf(buf,"%f",&Depth);
|
||
if(Depth) {
|
||
Depth+=delta;
|
||
SetTableFieldData(iIndex,no8,(char *)&Depth,j+1);
|
||
}
|
||
}
|
||
if(no9>-1)
|
||
{
|
||
GetTableFieldData(iIndex,no9,buf,j+1);
|
||
sscanf(buf,"%f",&Depth);
|
||
if(Depth) {
|
||
Depth+=delta;
|
||
SetTableFieldData(iIndex,no9,(char *)&Depth,j+1);
|
||
}
|
||
}
|
||
if(no10>-1)
|
||
{
|
||
GetTableFieldData(iIndex,no10,buf,j+1);
|
||
sscanf(buf,"%f",&Depth);
|
||
if(Depth) {
|
||
Depth+=delta;
|
||
SetTableFieldData(iIndex,no10,(char *)&Depth,j+1);
|
||
}
|
||
}
|
||
if(no11>-1)
|
||
{
|
||
GetTableFieldData(iIndex,no11,buf,j+1);
|
||
sscanf(buf,"%f",&Depth);
|
||
if(Depth) {
|
||
Depth+=delta;
|
||
SetTableFieldData(iIndex,no11,(char *)&Depth,j+1);
|
||
}
|
||
}
|
||
if(no12>-1)
|
||
{
|
||
GetTableFieldData(iIndex,no12,buf,j+1);
|
||
sscanf(buf,"%f",&Depth);
|
||
if(Depth) {
|
||
Depth+=delta;
|
||
SetTableFieldData(iIndex,no12,(char *)&Depth,j+1);
|
||
}
|
||
}
|
||
if(no13>-1)
|
||
{
|
||
GetTableFieldData(iIndex,no13,buf,j+1);
|
||
sscanf(buf,"%f",&Depth);
|
||
if(Depth) {
|
||
Depth+=delta;
|
||
SetTableFieldData(iIndex,no13,(char *)&Depth,j+1);
|
||
}
|
||
}
|
||
if(no14>-1)
|
||
{
|
||
GetTableFieldData(iIndex,no14,buf,j+1);
|
||
sscanf(buf,"%f",&Depth);
|
||
if(Depth) {
|
||
Depth+=delta;
|
||
SetTableFieldData(iIndex,no14,(char *)&Depth,j+1);
|
||
}
|
||
}
|
||
if(no15>-1)
|
||
{
|
||
GetTableFieldData(iIndex,no15,buf,j+1);
|
||
sscanf(buf,"%f",&Depth);
|
||
{
|
||
Depth+=delta;
|
||
SetTableFieldData(iIndex,no15,(char *)&Depth,j+1);
|
||
}
|
||
}
|
||
if(no16>-1)
|
||
{
|
||
GetTableFieldData(iIndex,no16,buf,j+1);
|
||
sscanf(buf,"%f",&Depth);
|
||
{
|
||
Depth+=delta;
|
||
SetTableFieldData(iIndex,no16,(char *)&Depth,j+1);
|
||
}
|
||
}
|
||
}
|
||
delete buf;
|
||
return TRUE;
|
||
}
|