把这个读wis文件的程序转换为C#版本的,能出正确的结果
黯然若水 2012-03-14 11:03:05 原网址http://blog.csdn.net/syunqiang/article/details/6
大侠们,救命啦!
/** ***************************************************************** */
/** This Program is for converting wis format file to txt format file */
/** Command: wis2txt_win.exe args1 args2 */
/** Description: */
/** wis2txt_win.exe: the executable file as command */
/** args1: the first argument that is the wis file name */
/** args2: the second argument that is the txt file name */
/** ***************************************************************** */
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <time.h>
#include <math.h>
#define ROW 65536
#define COL 512
/* **************************************** */
/* Below blocks are the structs of wis file */
/* **************************************** */
typedef struct tagWIS_HEAD
{
WORD MachineType; // 0-PC 1-SUN 2-IBM 3-HP
WORD MaxObjectNumber;
WORD ObjectNumber;
WORD BlockLen;
DWORD EntryOffset;
DWORD DataOffset;
DWORD FileSize;
time_t TimeCreate;
char Reserved[32];
}WIS_HEAD;
typedef struct tagWIS_OBJECT_ENTRY
{
char Name[16];
long Status;
short Attribute; // 1-通道对象 2-表对象 3-流对象
short SubAttribute; // 1-曲线对象 2-波形对象 3-地层测试对象 4-时深时对象
DWORD Position; // 对象数据体从文件开始处的偏移量
DWORD BlockNum;
time_t TimeCreate;
time_t TimeWrite;
char Reserved[32];
}WIS_OBJECT_ENTRY;
typedef struct tagWIS_CHANNEL_DIMENSION
{
char Name[8];
char Unit[8];
char AliasName[16];
float StartVal;
float Delta;
DWORD Samples;
DWORD MaxSamples;
DWORD Size;
WORD RepCode;
WORD Reserved;
}WIS_CHANNEL_DIMENSION;
typedef struct tagWIS_CHANNEL
{
char Unit[8];
char AliasName[16];
char AliasUnit[16];
WORD RepCode;
WORD CodeLen;
float MinVal;
float MaxVal;
WORD Reserved;
WORD NumOfDimension;
WIS_CHANNEL_DIMENSION DimInfo[4];
}WIS_CHANNEL;
typedef struct tagWIS_STREAM
{
DWORD Length;
DWORD Offset;
}WIS_STREAM;
typedef struct tagWIS_TABLE_FIELD
{
char Name[32];
WORD RepCode;
WORD Length;
DWORD Reserved;
} WIS_TABLE_FIELD;
typedef struct tagWIS_TABLE
{
DWORD RecordCount;
DWORD FieldCount;
WIS_TABLE_FIELD *pField;
}WIS_TABLE;
typedef struct tagWIS_TABLE_DEFAULT_FILED
{
char Name[16];
char Alias[16];
char Unit[8];
char Type[8];
WORD Length;
WORD Count;
char DefVal[64][12];
} WIS_TABLE_DEFAULT_FIELD;
typedef struct tagWIS_DEFAULT_TABLE
{
char Name[16];
char Alias[16];
char Attrb[8];
DWORD FieldCount;
WIS_TABLE_DEFAULT_FIELD *pField;
} WIS_DEFAULT_TABLE;
/* 曲线的信息结构体*/
typedef struct tagCURVE_HEAD
{
char Name[16]; // 曲线的名字
char Unit[8]; // 曲线的单位
float startMD; // 曲线的起始深度
float stopMD; // 曲线的结束深度
int pointNum; // 数据样点数
int position; // 数据位置
struct tagCURVE_HEAD *next;
} CURVE_HEAD;
/* 曲线的数据结构体 */
typedef struct tagCURVE_DATA
{
char Name[16]; // 曲线的名字
char Unit[8]; // 曲线的单位
float Depth[ROW]; // 曲线的深度值
float Value[ROW]; // 曲线的值
struct tagCURVE_DATA *next;
} CURVE_DATA;