#include <iostream>
#include <sstream>
#include <iomanip>
using std::cout;
using std::cin;
using std::endl;
#if defined(RSH_MSWINDOWS)
#include <conio.h>
const char* FilePath = "";
#elif defined(RSH_LINUX)
const char* FilePath ="";
#endif
const char* BoardName = "LA5NET" ;
const double SampleFreq = 1000.0;
const U32 ChannelNumber = 2;
const U32 InternalBufferSize = 512;
const U32 InternalBufferCount = 5;
const std::string screenDelimiter(80, '=');
const char* StringSuccess = "SUCCESS!";
{
cout<<endl<<screenDelimiter<<endl;
if(desc)
cout << "Error on " << desc << " call." << endl;
cout << endl << "Press 'Enter' key to end up the program.";
cin.ignore();
return st;
}
int main()
{
std::vector<std::string> allDevices;
{
cout << "List of registered device libraries:" << endl;
for(std::vector<std::string>::iterator it = allDevices.begin();
it != allDevices.end(); ++it)
{
cout << *it << endl;
}
}
cout << screenDelimiter << endl;
cout << "Loading device interface from dynamic library... ";
return SayGoodBye(Client, st, "Client.GetDeviceInterface(DevKey)");
else
cout << StringSuccess << endl;
return SayGoodBye(Client, st, "device->Get(RSH_GET_LIBRARY_FILENAME)");
else
cout << "Library Name: "<< libname << endl;
return SayGoodBye(Client, st, "device->Get(RSH_GET_LIBRARY_VERSION_STR)");
else
cout << "Library Version: " << libVersion << endl;
return SayGoodBye(Client, st, "device->Get(RSH_GET_CORELIB_FILENAME)");
else
cout << "Core Library Name: " << libCoreName << endl;
return SayGoodBye(Client, st, "device->Get(RSH_GET_CORELIB_VERSION_STR)");
else
cout << "Core Library Version: " << libCoreVersion << endl;
return SayGoodBye(Client, st, "device->Get(RSH_GET_DEVICE_IS_CAPABLE)");
cout << "Connecting to device (it may take some time)... ";
return SayGoodBye(Client, st,"device->Connect()");
else
cout << StringSuccess << endl;
return SayGoodBye(Client, st, "device->Get(RSH_GET_DEVICE_NAME_VERBOSE)");
else
cout << "The name of the connected device: " << fullDeviceName << endl;
return SayGoodBye(Client, st, "device->Get(RSH_GET_DEVICE_SERIAL_NUMBER)");
else
cout << "Serial number of the connected device: " << serialNumber << endl;
cout << screenDelimiter << endl;
cout << "--> Persistent data acquisition mode <--"<<endl;
cout << screenDelimiter << endl;
for(int i=0;i<ChannelNumber;++i)
{
}
cout << "Initializing device with Init structure... ";
return SayGoodBye(Client, st, "device->Init(&p)");
else
cout <<StringSuccess << endl;
return SayGoodBye(Client, st, "device->Get(RSH_GET_DEVICE_ACTIVE_CHANNELS_NUMBER)");
if(activeChanNumber == 0)
{
cout << "ActiveChanNumber is zero, something is wrong!" << endl;
}
cout << endl << "Initialization parameters:" << endl << p << endl;
cout << "The number of active channels: " << activeChanNumber << endl;
cout <<
"Data to be collected per channel: " << (p.
bufferSize * InternalBufferCount) << endl;
cout <<
"The estimated time of gathering completion: " << (p.
bufferSize * InternalBufferCount / p.
frequency ) <<
"s"<< endl;
userBuffer.
Allocate( bBufSize * InternalBufferCount );
do
{
cout << screenDelimiter << endl;
cout << "Press Esc key to exit, any other key to start data acquisition..." << endl;
#if defined(RSH_MSWINDOWS)
if (_getch() == 27) break;
#else
if (getc(stdin) == 27) break;
#endif
return SayGoodBye(Client, st, "device->Start()");
do
{
return SayGoodBye(Client, st, "device->Get(RSH_GET_WAIT_BUFFER_READY_EVENT)");
return SayGoodBye(Client, st, "device->GetData(&iBuffer)");
memcpy(userBuffer.
ptr + Loops * bBufSize, iBuffer.ptr, iBuffer.ByteSize());
cout << "\r" << std::setw(3) << std::setfill('0') << Loops + 1 << " piece(s) has been collected";
} while (++Loops != InternalBufferCount);
cout << endl << "Data successfully collected!" << endl;
std::ostringstream nameStream;
nameStream << FilePath << BoardName << "_PG_" << std::setw(4) << std::setfill('0') << ++loopNum << ".dat";
std::string fileName = nameStream.str();
{
cout <<"Data was successfully collected and saved to " << fileName << endl;
cout <<
"File size: " << userBuffer.
BytePSize()/1024.0 <<
"kilobytes" << endl;
}
else
{
cout << "Couldn't write to file " << fileName << endl;
}
} while (true);
}