[более не актуально]
Всем привет!
Имеется код:
#include "Windows.h"
#include <stdio.h>
#define DIM(a) (sizeof(a) / sizeof(a[0]))
#include "Include/DLLClient.h"
#include "Include/IADCDevice.h"
#include "Alf.cpp"
/*######################################################################*/
int Write(HANDLE hFile, void* p, unsigned size)
{
if(hFile == INVALID_HANDLE_VALUE)
return 0;
DWORD dw = 0;
WriteFile(hFile, p, size, &dw, 0);
return dw != size ? -1 : 1;
}
/*----------------------------------------------------------------------*/
int ReadALFFile(char* name, char* oname)
{
// ìàññèâ äëÿ âðåìåííîãî áóôåðà
float fVolts[8 * 1024];
// óêàçàòåëü íà èíòåðôåéñ "IALF"
IALF* pALF;
DllClient DClient;
// ïîëó÷åíèå ôèçè÷åñêîãî èíòåðôåéñà.
pALF = (IALF*)DClient.LoadDriver("EL200E", "IALF");
if(pALF == 0)
{
printf("\n ERROR - EL200E driver not found! \n");
return 0;
}
// îòêðûâàåì ôàéë ñ SD äàííûìè
if(pALF->Open(name) <= 0)
{
printf("\n ERROR - Invalid ALF File! {%s}! \n", name);
return 0;
}
unsigned nBlockSize = 0;
int nChan = 1;
double dFreq = 1000.0;
__int64 lFSize = 0L;
unsigned nSSize = 0;
int nCycle = 0;
FILETIME ft;
SYSTEMTIME st;
// ïå÷àòü èíôîðìàöèè î ôàéëå
pALF->Get(IALF_BLOCKSIZE, &nBlockSize);
pALF->Get(IALF_CHANNELLS, &nChan);
pALF->Get(IALF_FREQ_DOUBLE, &dFreq);
pALF->Get(IALF_SIZE_IN_SAMPLES, &lFSize);
pALF->Get(IALF_SIZE_IN_SECTORS, &nSSize);
pALF->Get(IALF_CYCLEMODE, &nCycle);
pALF->Get(IALF_FILETIME, &ft);
pALF->Get(IALF_SYSTEMTIME, &st);
printf("\n ----------------------------------");
printf("\n File : %s", name);
printf("\n Cnannels : %d", nChan);
printf("\n Freq per Channell : %.2f", dFreq);
printf("\n Size in samples : %LdKs", lFSize / 1024L);
printf("\n Record Time : %.2f min.", lFSize / (dFreq * nChan * 60.0));
printf("\n Size in sectors : %u", nSSize);
printf("\n Start date : %02d-%02d-%d", st.wDay, st.wMonth, st.wYear);
printf("\n Start time : %02d:%02d:%02d", st.wHour, st.wMinute, st.wSecond);
printf("\n Cycle mode : %s", nCycle ? "YES" : "NO");
printf("\n ----------------------------------\n");
// â çàâèñèìîñòè îò òîãî êàêîé ôàéë ñîçäàâàëñÿ, öèêëè÷åñêèé èëè íåò,
// íóæíî íàéòè ïîçèöèþ íà÷àëà çàïèñè. Ýòî ìåñòî íóæíî ïðîñòî ïåðåíåñòè â
// ñâîé êîä.
pALF->Reset(0, 1);
__int64 sm = 0x7FFFFFFFFFFFFFFFL;
unsigned sindex = 0;
if(nCycle)
{
for(unsigned j = 0; j < nSSize; ++j)
{
__int64 in[2];
if(pALF->GetIndex(1, in) <= 0)
break;
if(in[0] == in[1])
break;
if(sm > in[0])
{
sm = in[0];
sindex = j;
}
if(sm > in[1])
{
sm = in[1];
sindex = j;
}
if((j & 0x7F) == 0)
printf("\r Scan = %u sec. ", j);
}
printf("\n First sector Found! Sector = %u, %Ld \n", sindex, sm);
ULARGE_INTEGER ut;
ut.LowPart = ft.dwLowDateTime;
ut.HighPart = ft.dwHighDateTime;
-->> ut.QuadPart += __int64(sm * nBlockSize / (dFreq * nChan) * 1e7);
ft.dwLowDateTime = ut.LowPart;
ft.dwHighDateTime = ut.HighPart;
}
pALF->Reset(sindex);
// çàïèñûâàåòñÿ çàãîëîâîê âûõîäíîãî ôàéëà,
// Âû ìîæåòå çàïèñûâàòü äàííûå â ëþáîì ñâîåì ôîðìàòå.
HANDLE hFile = SaveALFHeader(oname, nChan, dFreq, 0);
for(unsigned i = 0; ; ++i)
{
// ïîëó÷åíèå ïîðöèè äàíûõ. Âñå äàííûå ïîëó÷àþòñÿ â ôîðìàòå
// float è ïðåäñòàâëÿþò ñîáîé íàïðÿæåíèå â Âîëüòàõ ïðèâåäåííîå êî âõîäó.
unsigned n = pALF->GetVoltage(0, fVolts, DIM(fVolts));
if(n == 0)
break;
printf("\r Save = %u Ks. ", i * DIM(fVolts) / 1024);
// Â ýòîì ìåñòå ìîæíî çàïèñûâàòü äàííûå â ëþáîì äðóãîì ôîðìàòå,
// èëè íåïîñðåäñòâåííî èñïîëüçîààòü èõ.
if(Write(hFile, fVolts, n * sizeof(float)) <= 0)
{
printf("\n ERROR - Save File! \n");
break;
}
if(n < DIM(fVolts))
break;
}
CloseALF(hFile, ft);
pALF->Release();
return 1;
}
/*----------------------------------------------------------------------*/
int main(int argc, char **argv)
{
if(argc < 2)
{
printf("\n Usage : Input[ALFSD FileName] Output[ALFVolt FileName].");
return 0;
}
-->> if(ReadALFFile(argv[1], argc > 2 ? argv[2] : "Dat.ALF") > 0)
printf("\n ALF file save OK!");
else
printf("\n Invalid ALF File!");
return 0;
}
/*######################################################################*/
При компиляции возникают две ошибки:
Проблемные места в коде я пометил стрелочками -->>.
Среда выполнения Dev C++ 5.11.
Не пойму, чего он хочет. Прошу подсказать.