|
|
| Author |
Message |
siongboon Guest
|
Posted: Wed Feb 02, 2005 8:11 am Post subject: Software code for *.plw to *.txt |
|
|
I saw many needs for such batch conversion software.
I wrote for might own use and thought it might be useful to anyone.
So I posted here to share.
Hopes it helps in some way.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <conio.h>
void plwToText(char *filename);
typedef struct PICO_header_struct
{
unsigned short header_bytes;
char signature[40];
unsigned long version;
unsigned long no_of_parameters;
unsigned short parameters[250]; // !! The value in the PICOlog documentation is entirely bogus!
unsigned long sample_no;
unsigned long no_of_samples;
unsigned long max_samples;
unsigned long interval;
unsigned short interval_units;
unsigned long trigger_sample;
unsigned short triggered;
unsigned long first_sample;
unsigned long sample_bytes;
unsigned long settings_bytes;
unsigned long start_date;
unsigned long start_time;
long minimum_time;
long maximum_time;
char notes[200];
long current_time;
unsigned char spare[78];
};
class PICO_data_reading
{
public:
unsigned long time_count;
float voltage;
};
void main(int argc,char **argv)
{
clrscr();
if(argc==1)
{
printf("file name not specified (program 'filename' 'start range' 'end range')\n");
}
else if(argc==2)
{
printf("Converting %s\n",argv[1]);
getch();
plwToText(argv[1]);
}
else if(argc==3)
{
printf("End range required\n");
}
else if(argc==4)
{
int start=atoi(argv[2]);
int end=atoi(argv[3]);
printf("Converting files \"%s\" from %d to %d\n",argv[1],start,end);
getch();
for(int x=start;x<=end;x++)
{
char string[50];
sprintf(string,"%s%d",argv[1],x);
plwToText(string);
}
}
else
{
printf("too many parameter\n");
}
printf("Program terminated\n");
}
void plwToText(char *filename)
{
PICO_header_struct file_header;
FILE *fptr;
FILE *fptrOut;
char out_file[50];
sprintf(out_file,"%s.txt",filename);
strcat(filename,".plw");
printf("Convert file \"%s\" to \"*.txt\" \n",filename);
if((fptr=fopen(filename,"rb"))==NULL)
{
printf("Error: file open fail\n");
getch();
return;
}
if((fptrOut=fopen(out_file,"w+t"))==NULL)
{
printf("Error: file open fail\n");
getch();
return;
}
if(!fread(&file_header, sizeof(file_header), 1,fptr))
{
printf("Error: file header read fail\n");
getch();
return;
}
fseek(fptr,800,SEEK_CUR);
unsigned long y=0;
for(unsigned long x=0;x<100000;x++)
{
PICO_data_reading temp;
if(!fread(&temp,sizeof(PICO_data_reading), 1,fptr))
{
printf("Error: file data read fail\n");
getch();
return;
}
char string[50];
sprintf(string,"%ld\t\t%f\n",temp.time_count,temp.voltage);
fwrite(string,strlen(string),1,fptrOut);
x=99900;
x=0;
/*
printf("%s, %ld\n",file_header.signature,file_header.version);
printf("no of parameters\t%ld\n",file_header.no_of_parameters);
printf("sample_no \t%ld\n",file_header.sample_no);
printf("no_of_samples \t%ld\n",file_header.no_of_samples);
printf("max_samples \t%ld\n",file_header.max_samples);
printf("interval \t%ld\n",file_header.interval);
printf("interval_units \t%d\n",file_header.interval_units);
printf("trigger_sample \t%ld\n",file_header.trigger_sample);
printf("triggered \t%d\n",file_header.triggered);
printf("first_sample \t%ld\n",file_header.first_sample);
printf("sample_bytes \t%ld\n",file_header.sample_bytes);
printf("settings_bytes \t%ld\n",file_header.settings_bytes);
printf("start_date \t%ld\n",file_header.start_date);
printf("start_time \t%ld\n",file_header.start_time);
printf("minimum_time \t%ld\n",file_header.minimum_time);
printf("maximum_time \t%ld\n",file_header.maximum_time);
printf("notes \t%s\n",file_header.notes);
printf("maximum_time \t%ld\n",file_header.maximum_time);
printf("spare \t%s\n",file_header.spare);
*/
fclose(fptr);
fclose(fptrOut);
} |
|
| Back to top |
|
 |
Guest
|
|
| Back to top |
|
 |
Sarah Guest
|
Posted: Wed Jun 22, 2005 9:21 am Post subject: |
|
|
Hi
Many thanks for this - I am sure it will be useful to many of our forum users.
Best Regards |
|
| Back to top |
|
 |
siong boon Guest
|
Posted: Sat Aug 27, 2005 4:22 pm Post subject: Some useful download |
|
|
I had since receive a number of enquiry on my pico-log convertion code.
It is a short/small program, to helps me to convert to a format that
I can export for other software purpose.
I had updated my website to provide
the *.plw to *.txt code and program for download.
If you are interested in the software,
you can visit my website at,
http://sg.geocities.com/siongboon/
Regards,
Lim Siong Boon
siongboon@yahoo.com.sg |
|
| Back to top |
|
 |
Guest
|
Posted: Tue Oct 25, 2005 7:52 pm Post subject: Help |
|
|
c:\program files\microsoft visual studio\myprojects\convert\convert.cpp(32) : warning C4091: 'typedef ' : ignored on left of 'struct PICO_header_struct' when no variable is declared
c:\program files\microsoft visual studio\myprojects\convert\convert.cpp(43) : error C2065: 'clrscr' : undeclared identifier
c:\program files\microsoft visual studio\myprojects\convert\convert.cpp(155) : fatal error C1004: unexpected end of file found
Error executing cl.exe.
When I compile your code this is what I get. |
|
| Back to top |
|
 |
Guest
|
Posted: Tue Dec 20, 2005 11:08 am Post subject: |
|
|
Hi everybody,
I have just set up a website.
My pico codes is available for download at
www.siongboon.com
Hope that this would be useful to you.
Have a nice day.
siongboon@yahoo.com.sg |
|
| Back to top |
|
 |
|
Powered by phpBB © 2001, 2005 phpBB Group
|