beautypg.com

Teledyne LeCroy WaveExpert 100H Operators Manual User Manual

Page 201

background image

Wave Expert

WE-OM-E Rev A

199

// Map a view of this file for writing.

short *m_lpMMFile = (short *)MapViewOfFile (m_hMMFile, FILE_MAP_ALL_ACCESS, 0, 0,
0);

if(m_lpMMFile == 0)

{

printf("Unable to map view of file\n");

return 0;

}

// create/open events used for synchronization

// if the client app. was run before the scope then these events will be created, if the scope was
run first then these events

// will just be opened

HANDLE m_hDataAvailable = CreateEvent(NULL, FALSE, FALSE /* initial state */,
szMutexDataAvailableName);

HANDLE m_hProcessingComplete = CreateEvent(NULL, FALSE, FALSE /* initial state */,
szMutexProcessingCompleteName);

if(m_hDataAvailable == 0 || m_hProcessingComplete == 0)

{

printf("Unable to open events\n");

return 0;

}

// main loop

while(1)

{

int i = 0;

printf("Waiting for new data...\n");

// wait an infinite amount of time for data to be available

DWORD waitSuccess = WaitForSingleObject(m_hDataAvailable, INFINITE);

// print the first few bytes of the input waveform

CDescHeader *descHeader = (CDescHeader *) &m_lpMMFile[0];

short *m_lpWaveform = &m_lpMMFile[descHeader->headerSize / sizeof(short)];