Hello All.
I have source of already wrote program on Borland C++, but I can't convert it to QT4.
I need read data from file. I include full overview about file format into zip file and less below.
I use mdi sample and rewrite function openFile(), and it's work:
Code:
isUntitled = true; setWindowTitle(curFile + "[*]"); { tr("Cannot open file %1:\n%2.") .arg(curFile) .arg(file.errorString())); } else { } file.close(); }
But I don't know how write code witch I have already in Borland. I don't understand how read binary file. Maybe I don't need source on Borland, and I can write other program:
Where DSPZ Q and DSP WCode:
void TMainForm::vOpenDSPZdata(){ Chart->Title->Text->Clear(); Chart->Title->Text->Add("Converting to DSP data format"); int NF = OpenMultiDialog->Files->Count; for (int nf=0;nf<NF;nf++){ FLName=OpenMultiDialog->Files->Strings[nf]; FH=FileOpen(FLName,fmOpenRead); if(FH==-1){ShowMessage("Error with FileOpen");return;} FSName = ExtractFileName(OpenMultiDialog->Files->Strings[nf]); FSName = FSName.SubString(0,FSName.Length()-4)+".dsp"; FSName = ExtractFilePath(FLName) + FSName; filec = 0; file_razmer = FileSeek(FH,filec,2); FileSeek(FH,0,0); FileRead(FH,&Q.fh, sizeof Q.fh); Q.fh2dspp(66000,0,0); Q.allocate_spectr(); n_vib = (file_razmer - (sizeof Q.fh))/(sizeof 4*2*Q.nDSPZ); Memo->Lines->Add(">Open file name : " + FLName); Memo->Lines->Add(">Saving file name : " + FSName); Memo->Lines->Add(">File size : " + IntToStr(file_razmer) + " Byte"); Memo->Lines->Add(">sizeof header : " + IntToStr(sizeof Q.fh) + " Byte"); Memo->Lines->Add(">sizeof spectr : " + IntToStr(sizeof 4*2*Q.nDSPZ) + " Byte"); Memo->Lines->Add(">Count of spectra : " + IntToStr(n_vib)); Memo->Lines->Add(">Count of chanel DSPZ: " + IntToStr(Q.nDSPZ)); Memo->Lines->Add(">Resolution DSPZ: " + FloatToStrF(Q.dspp.NAvr * Q.NDSPZ * 1./ Q.dspp.frcl,ffFixed,8,2) + " ms"); Memo->Lines->Add(">Averaging factor DSPZ: " + IntToStr(Q.dspp.NAvr)); Memo->Lines->Add(">Resolution DSP: " + FloatToStrF(Q.dspp.NAvr * Q.NDSPZ * 1./ Q.dspp.frcl , ffFixed,8,2) + " ms"); Memo->Lines->Add(Q.fh.time); astr=""; for (i=0;i<16;i++){ astr+= IntToStr(i) + ": " + Q.fh.syst[i] + " "; } Memo->Lines->Add("> "+ astr); Memo->Lines->Add(Q.fh.desc); int Naver; if (OF->nAverCB->Checked && n_vib>Naver) Naver = StrToInt(OF->nAverEdit->Text); else Naver = n_vib; Memo->Lines->Add(">Number of spectr for DSP file: " + IntToStr(Naver)); Naver=10; for(i=0;i<Naver;i++){ FileRead(FH,Q.spectr, sizeof 4*2*Q.nDSPZ); Q.get_spectrAB_prop(); SeriesShow(); if (!((i+1)%100)){ Caption = CaptInfo + " file# " + IntToStr(nf+1) + "/" + IntToStr(NF) + " - " + IntToStr(i*100/Naver) + "%"; SeriesShow(); Sleep(20); Application->ProcessMessages(); } } Application->ProcessMessages(); FileClose(FH); }//nf }
Code:
class DSP{ public: DBUFFH fh; DBUFSP sp; int nDSP; DSP::DSP(); DSP::~DSP(); int intLEtoBE(int le); int intfLEtoBE(float fl); float floatLEtoBE(int le); float getchA(int k); float getchB(int k); private: int i,j; float tmp; };
Code:
class DSPZ{ public: int nDSPZ; int NDSPZ; DSP_FH fh; int *spectr; float *chA,*chB; SPECTR_PROP spp; DSPP_PROP dspp; DSPZ::DSPZ(); DSPZ::~DSPZ(); void get_spectrAB_prop(); void allocate_spectr(); void fh2dspp(float freqclock, int winchA, int winchB); private: int i,j; float tmp; };
The file header is placed at begin of the file (0x0h offset). File header has size 1024 bytes and contains following fields:
In “Câ€-language notation header can by considered as structure:
In the “Câ€-language notation processing parameters structure PP can by considered as following structure:Code:
typedef struct FHEADER_Tag { char name[32]; char time[32]; char gmtt[32]; char sysn[32]; char syst[32]; char place[96]; char desc[256]; DWORD PP[128]; DWORD DSPP[384]; } FHEADER;
In the “Câ€-language notation processing parameters structure PP can by considered as following structure:Code:
typedef struct UP_EXCH_Tag //DSP parameters { DWORD mode; //mode of operation DWORD size; //size of DMA data block DWORD prc_mode; //processing parameters DWORD tst_gen; //not used DWORD clk; //not used DWORD fft_size; //used for data trasferering }UP_EXCH;
Code:
typedef struct DSPP_tag //DSP processing parameetrs { int FFT_Size; //for using in the DSP int MinDSPSize; // for using in the DSP int MinDMASize; // for using in the DSP int DMASizeCnt; // for using in the DSP int DMASize; // for using in the DSP float CLCfrq; int Synch; int SSht; int Mode; int Wch; int Smd; int Offt, int Lb; int Hb; int Wb; int NAvr; BOOL CAvr; BOOL Weight; BOOL DCRem; BOOL ExtSyn; BOOL Ch1; BOOL Ch2; BOOL ExtWin; int Clip; //RF parts int HPF0; int HPF1; int LPF0; int LPF1; int ATT0; int ATT1; } DSPP;
Just after file header, the data follow. So, the data offset in the file is 0x400h. In the Spectrum Mode (Mode=1) the Wb pair of samples (spectrum lines) are stored. First sample is from A channel, and second sample is from B channel (see (2) and (4) on Fig.I.1). Just after 2*Wb samples of the spectrum the next 2*Wb spectrum samples are stored… and so on.
Each FFT sample (SSAMPLE) has 4 byte size SSAMPLE is in the DSP floating point format. To get the sample presented in conventional floating point format (FLOAT_NUM) one should apply the following transformation (in “C†notation):
Fig.1 Data sequence in the “Spectrum†mode