
生成的comtrade.dat文件存在问题,打开波形分析软件会引起混淆吗?
将连续采样数据写入comtrade文件中,数据类型为shortint什么软件可以看dat格式,并且只有一个数据通道,以确保数据没有问题(来自波形的正弦),但是使用以下命令打开生成的dat文件: 波形分析工具来看看Messy,大家帮我看看.
首先发送生成的CFG文件内容:
测试台,1997年
1,1A,0D

1什么软件可以看dat格式,当前1 ,, 1,A,1.000000,0.000000,0.000000,-32767,32767,1.00000,1.00000,p
50
1
4000,64991
2012年12月14日,04: 46: 40.000000

2012年12月14日,04: 46: 40.000000
BINARY
1
生成dat文件的代码:
char converInput[256];
int mycomtrade_build_dat(DATETYPE *date,char *channelName,short int data[][SVAEFILELEN],int id,int samplelen)
{
char datName[100]={0},datContex[100];
FILE *fp;
int i,writelen;
unsigned int iLoop, tmp_u32, bufferLength, dataLength;
unsigned short int tmp_u16,chlNum,chlIndex;
if(date==NULL || channelName==NULL || samplelen<0)
return 1;
sprintf(datName,"%s_ddd_ddd.dat",channelName,\
date->Year,date->Month,date->Date,date->Hour,date->Minute,date->Msecond);
fp=fopen(datName,"w");//这里的文件名均没有问题
if(fp==NULL)
{
zz("%s生成失败\n",datName);
return 1;
}
memset( converInput, 0, sizeof(converInput) );
bufferLength=0;
dataLength = samplelen;
for( iLoop=0; iLoop< dataLength; iLoop++ )
{
//写dat文件
// 序号4,时标微秒4,2字节数据
//4字节序号
tmp_u32 = iLoop;
memcpy(converInput+bufferLength, &tmp_u32, 4 ); bufferLength += 4;
//4字节时标(微秒单位)
tmp_u32 = iLoop * 250 ;
memcpy(converInput+bufferLength, &tmp_u32, 4 ); bufferLength += 4;
///写2字节数据:交换高低字节顺序
tmp_u16 = data[id][iLoop];
memcpy(converInput+bufferLength, &tmp_u16, 2 ); bufferLength += 2;
//每组写一次,还是固定长度写一次
if( bufferLength > 100 )
{
//写一组数据
fwrite( converInput, bufferLength, 1, fp );
bufferLength = 0;
memset( converInput, 0, sizeof(converInput) );
}
}
if( bufferLength > 100 )
{
fwrite( converInput, bufferLength, 1, fp );
bufferLength = 0;
}
fclose(fp);
}

------解决方案--------------------
恭喜!
------解决方案--------------------
报价: 发现问题,创建一个w-> wb
文件

不要放
fopen(“ ...”,“ ...”); fscanf,fprintf,fclose //在读取时将\ r \ n替换为\ n,在读取时将\ n替换为\ r \ n;读取将EOF设置为\ x1a;以字符形式读取和写入内容
和
fopen(“ ...”,“ ... b”); fread,fwrite,fclose //不进行上述替换,遇到\ x1a时继续读取;读写内容被视为字节
误解
房东可以搜索此句子在CSDN论坛中出现了多少次.
------解决方案--------------------
zz(
退出
本文来自电脑杂谈,转载请注明本文网址:
https://www.pc-fly.com/a/shumachanpin/article-251807-1.html
任何东西都要一分为二看问题
什么也不要说了
希望美方谨言慎行别伤害中国人的感情